From 46a9f7da425721069e9ca80656dba7e72b3f406a Mon Sep 17 00:00:00 2001 From: nobody <> Date: Sun, 2 Apr 2000 08:24:55 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'binutils- 2_10-branch'. Sprout from cygnus 2000-02-22 16:18:13 UTC Ian Lance Taylor 'import libiberty from egcs' Cherrypick from master 2000-04-02 08:24:54 UTC Richard Henderson ' * config/tc-d30v.c (check_range): Allow signed or unsigned 32-bit': ChangeLog Makefile.in bfd/ChangeLog bfd/Makefile.am bfd/Makefile.in bfd/acinclude.m4 bfd/aclocal.m4 bfd/aix386-core.c bfd/aout-adobe.c bfd/aout-arm.c bfd/aout-ns32k.c bfd/aout-target.h bfd/aout-tic30.c bfd/aoutx.h bfd/archive.c bfd/archures.c bfd/armnetbsd.c bfd/bfd-in.h bfd/bfd-in2.h bfd/bfd.c bfd/binary.c bfd/bout.c bfd/cisco-core.c bfd/coff-a29k.c bfd/coff-alpha.c bfd/coff-apollo.c bfd/coff-arm.c bfd/coff-go32.c bfd/coff-h8300.c bfd/coff-h8500.c bfd/coff-i386.c bfd/coff-i860.c bfd/coff-i960.c bfd/coff-m68k.c bfd/coff-m88k.c bfd/coff-mcore.c bfd/coff-mips.c bfd/coff-ppc.c bfd/coff-rs6000.c bfd/coff-sh.c bfd/coff-sparc.c bfd/coff-stgo32.c bfd/coff-tic30.c bfd/coff-tic80.c bfd/coff-w65.c bfd/coff-we32k.c bfd/coff-z8k.c bfd/coffcode.h bfd/coffgen.c bfd/cofflink.c bfd/coffswap.h bfd/config.bfd bfd/config.in bfd/configure bfd/configure.host bfd/configure.in bfd/cpu-arm.c bfd/cpu-avr.c bfd/cpu-d10v.c bfd/cpu-h8500.c bfd/cpu-hppa.c bfd/cpu-i370.c bfd/cpu-m10300.c bfd/cpu-m32r.c bfd/cpu-mcore.c bfd/cpu-ns32k.c bfd/cpu-pj.c bfd/cpu-sh.c bfd/cpu-w65.c bfd/doc/Makefile.in bfd/dwarf1.c bfd/dwarf2.c bfd/ecoff.c bfd/ecofflink.c bfd/elf-bfd.h bfd/elf-hppa.h bfd/elf-m10200.c bfd/elf-m10300.c bfd/elf.c bfd/elf32-arc.c bfd/elf32-arm.h bfd/elf32-avr.c bfd/elf32-d10v.c bfd/elf32-d30v.c bfd/elf32-fr30.c bfd/elf32-gen.c bfd/elf32-hppa.c bfd/elf32-hppa.h bfd/elf32-i370.c bfd/elf32-i386.c bfd/elf32-i860.c bfd/elf32-i960.c bfd/elf32-m32r.c bfd/elf32-m68k.c bfd/elf32-m88k.c bfd/elf32-mcore.c bfd/elf32-mips.c bfd/elf32-pj.c bfd/elf32-ppc.c bfd/elf32-sh.c bfd/elf32-sparc.c bfd/elf32-v850.c bfd/elf64-alpha.c bfd/elf64-gen.c bfd/elf64-mips.c bfd/elf64-sparc.c bfd/elfarm-nabi.c bfd/elfarm-oabi.c bfd/elfcode.h bfd/elflink.c bfd/elflink.h bfd/elfxx-target.h bfd/epoc-pe-arm.c bfd/epoc-pei-arm.c bfd/freebsd.h bfd/hash.c bfd/hosts/alphalinux.h bfd/hp300hpux.c bfd/hppabsd-core.c bfd/hpux-core.c bfd/i386linux.c bfd/i386lynx.c bfd/i386msdos.c bfd/i386os9k.c bfd/ieee.c bfd/ihex.c bfd/irix-core.c bfd/libbfd-in.h bfd/libbfd.c bfd/libbfd.h bfd/libcoff-in.h bfd/libcoff.h bfd/libecoff.h bfd/libhppa.h bfd/libpei.h bfd/linker.c bfd/m68klinux.c bfd/mipsbsd.c bfd/netbsd-core.c bfd/netbsd.h bfd/nlm-target.h bfd/nlm32-ppc.c bfd/nlm32-sparc.c bfd/nlmcode.h bfd/oasys.c bfd/osf-core.c bfd/pc532-mach.c bfd/pe-arm.c bfd/pe-i386.c bfd/pe-mips.c bfd/pe-ppc.c bfd/pe-sh.c bfd/pei-arm.c bfd/pei-i386.c bfd/pei-mcore.c bfd/pei-mips.c bfd/pei-ppc.c bfd/pei-sh.c bfd/peicode.h bfd/peigen.c bfd/po/POTFILES.in bfd/po/bfd.pot bfd/ppcboot.c bfd/ptrace-core.c bfd/reloc.c bfd/reloc16.c bfd/riscix.c bfd/rs6000-core.c bfd/sco5-core.c bfd/section.c bfd/som.c bfd/sparclinux.c bfd/srec.c bfd/stabs.c bfd/sunos.c bfd/syms.c bfd/targets.c bfd/tekhex.c bfd/trad-core.c bfd/versados.c bfd/vms-gsd.c bfd/vms-hdr.c bfd/vms-misc.c bfd/vms-tir.c bfd/vms.c bfd/vms.h bfd/xcofflink.c binutils/ChangeLog binutils/Makefile.am binutils/Makefile.in binutils/NEWS binutils/aclocal.m4 binutils/addr2line.c binutils/ar.1 binutils/ar.c binutils/arparse.y binutils/arsup.c binutils/binutils.texi binutils/config.in binutils/configure binutils/configure.in binutils/debug.c binutils/deflex.l binutils/defparse.y binutils/dlltool.c binutils/dllwrap.c binutils/dyn-string.c binutils/dyn-string.h binutils/filemode.c binutils/ieee.c binutils/nm.c binutils/objcopy.1 binutils/objcopy.c binutils/objdump.c binutils/po/POTFILES.in binutils/po/binutils.pot binutils/prdbg.c binutils/rclex.l binutils/rcparse.y binutils/rdcoff.c binutils/rddbg.c binutils/readelf.c binutils/rename.c binutils/rescoff.c binutils/resrc.c binutils/resres.c binutils/size.c binutils/stabs.c binutils/strings.1 binutils/strings.c binutils/testsuite/ChangeLog binutils/testsuite/binutils-all/hppa/freg.s binutils/testsuite/binutils-all/hppa/objdump.exp binutils/testsuite/binutils-all/objcopy.exp binutils/testsuite/binutils-all/objdump.exp binutils/testsuite/binutils-all/readelf.h binutils/testsuite/binutils-all/readelf.r binutils/testsuite/binutils-all/readelf.s binutils/testsuite/binutils-all/readelf.ss binutils/testsuite/binutils-all/readelf.wi binutils/testsuite/binutils-all/testprog.c binutils/windres.c binutils/windres.h binutils/wrstabs.c config.guess config.sub config/ChangeLog config/mh-i370pic config/mt-aix43 config/mt-i370pic config/mt-wince configure configure.in gas/ChangeLog gas/Makefile.am gas/Makefile.in gas/NEWS gas/aclocal.m4 gas/app.c gas/as.c gas/as.h gas/atof-generic.c gas/cgen.c gas/cond.c gas/config/atof-ieee.c gas/config/atof-vax.c gas/config/e-i386aout.c gas/config/m68k-parse.h gas/config/obj-aout.c gas/config/obj-aout.h gas/config/obj-bout.c gas/config/obj-coff.c gas/config/obj-coff.h gas/config/obj-ecoff.c gas/config/obj-ecoff.h gas/config/obj-elf.c gas/config/obj-elf.h gas/config/obj-evax.h gas/config/obj-multi.h gas/config/obj-som.c gas/config/obj-vms.h gas/config/tc-alpha.c gas/config/tc-alpha.h gas/config/tc-arc.c gas/config/tc-arc.h gas/config/tc-arm.c gas/config/tc-arm.h gas/config/tc-avr.c gas/config/tc-avr.h gas/config/tc-d10v.c gas/config/tc-d10v.h gas/config/tc-d30v.c gas/config/tc-d30v.h gas/config/tc-fr30.c gas/config/tc-h8300.c gas/config/tc-hppa.c gas/config/tc-hppa.h gas/config/tc-i370.c gas/config/tc-i370.h gas/config/tc-i386.c gas/config/tc-i386.h gas/config/tc-i860.c gas/config/tc-i960.c gas/config/tc-i960.h gas/config/tc-m32r.c gas/config/tc-m68k.c gas/config/tc-m68k.h gas/config/tc-m88k.c gas/config/tc-m88k.h gas/config/tc-mcore.c gas/config/tc-mcore.h gas/config/tc-mips.c gas/config/tc-mips.h gas/config/tc-mn10200.c gas/config/tc-mn10300.c gas/config/tc-ns32k.c gas/config/tc-ns32k.h gas/config/tc-pj.c gas/config/tc-pj.h gas/config/tc-ppc.c gas/config/tc-ppc.h gas/config/tc-sh.c gas/config/tc-sh.h gas/config/tc-sparc.c gas/config/tc-sparc.h gas/config/tc-tahoe.c gas/config/tc-tic30.c gas/config/tc-v850.c gas/config/tc-vax.c gas/config/tc-w65.c gas/config/tc-z8k.c gas/config/te-go32.h gas/config/te-interix.h gas/config/te-wince-pe.h gas/configure gas/configure.in gas/dep-in.sed gas/doc/Makefile.am gas/doc/Makefile.in gas/doc/all.texi gas/doc/as.1 gas/doc/as.texinfo gas/doc/c-arm.texi gas/doc/c-i370.texi gas/doc/c-i386.texi gas/doc/c-m32r.texi gas/doc/c-mips.texi gas/doc/c-pj.texi gas/doc/c-sparc.texi gas/doc/internals.texi gas/dwarf2dbg.c gas/dwarf2dbg.h gas/ecoff.c gas/ecoff.h gas/expr.c gas/expr.h gas/frags.c gas/frags.h gas/gasp.c gas/hash.c gas/hash.h gas/input-file.c gas/input-scrub.c gas/itbl-ops.c gas/itbl-ops.h gas/listing.c gas/macro.c gas/macro.h gas/obj.h gas/output-file.c gas/po/POTFILES.in gas/po/gas.pot gas/read.c gas/read.h gas/sb.h gas/stabs.c gas/struc-symbol.h gas/subsegs.c gas/symbols.c gas/symbols.h gas/testsuite/ChangeLog gas/testsuite/gas/all/cond.d gas/testsuite/gas/all/gas.exp gas/testsuite/gas/all/itbl-test.c gas/testsuite/gas/arm/arm7t.d gas/testsuite/gas/arm/arm7t.s gas/testsuite/gas/arm/float.s gas/testsuite/gas/arm/inst.d gas/testsuite/gas/arm/inst.s gas/testsuite/gas/arm/thumb.s gas/testsuite/gas/d10v/d10.exp gas/testsuite/gas/d10v/inst.d gas/testsuite/gas/d10v/inst.s gas/testsuite/gas/elf/elf.exp gas/testsuite/gas/elf/section0.d gas/testsuite/gas/elf/section0.s gas/testsuite/gas/elf/section1.d gas/testsuite/gas/elf/section1.s gas/testsuite/gas/hppa/basic/add.s gas/testsuite/gas/hppa/basic/add2.s gas/testsuite/gas/hppa/basic/addi.s gas/testsuite/gas/hppa/basic/basic.exp gas/testsuite/gas/hppa/basic/branch.s gas/testsuite/gas/hppa/basic/branch2.s gas/testsuite/gas/hppa/basic/comclr.s gas/testsuite/gas/hppa/basic/copr.s gas/testsuite/gas/hppa/basic/coprmem.s gas/testsuite/gas/hppa/basic/dcor.s gas/testsuite/gas/hppa/basic/dcor2.s gas/testsuite/gas/hppa/basic/deposit.s gas/testsuite/gas/hppa/basic/deposit2.s gas/testsuite/gas/hppa/basic/deposit3.s gas/testsuite/gas/hppa/basic/ds.s gas/testsuite/gas/hppa/basic/extract.s gas/testsuite/gas/hppa/basic/extract2.s gas/testsuite/gas/hppa/basic/extract3.s gas/testsuite/gas/hppa/basic/fmem.s gas/testsuite/gas/hppa/basic/fp_comp.s gas/testsuite/gas/hppa/basic/fp_comp2.s gas/testsuite/gas/hppa/basic/fp_conv.s gas/testsuite/gas/hppa/basic/fp_fcmp.s gas/testsuite/gas/hppa/basic/fp_misc.s gas/testsuite/gas/hppa/basic/imem.s gas/testsuite/gas/hppa/basic/immed.s gas/testsuite/gas/hppa/basic/logical.s gas/testsuite/gas/hppa/basic/media.s gas/testsuite/gas/hppa/basic/perf.s gas/testsuite/gas/hppa/basic/purge.s gas/testsuite/gas/hppa/basic/purge2.s gas/testsuite/gas/hppa/basic/sh1add.s gas/testsuite/gas/hppa/basic/sh2add.s gas/testsuite/gas/hppa/basic/sh3add.s gas/testsuite/gas/hppa/basic/shift.s gas/testsuite/gas/hppa/basic/shift2.s gas/testsuite/gas/hppa/basic/shift3.s gas/testsuite/gas/hppa/basic/shladd.s gas/testsuite/gas/hppa/basic/shladd2.s gas/testsuite/gas/hppa/basic/special.s gas/testsuite/gas/hppa/basic/spop.s gas/testsuite/gas/hppa/basic/sub.s gas/testsuite/gas/hppa/basic/sub2.s gas/testsuite/gas/hppa/basic/subi.s gas/testsuite/gas/hppa/basic/system.s gas/testsuite/gas/hppa/basic/system2.s gas/testsuite/gas/hppa/basic/unit.s gas/testsuite/gas/hppa/basic/unit2.s gas/testsuite/gas/hppa/parse/align1.s gas/testsuite/gas/hppa/parse/align2.s gas/testsuite/gas/hppa/parse/badfmpyadd.s gas/testsuite/gas/hppa/parse/block1.s gas/testsuite/gas/hppa/parse/block2.s gas/testsuite/gas/hppa/parse/calldatabug.s gas/testsuite/gas/hppa/parse/callinfobug.s gas/testsuite/gas/hppa/parse/defbug.s gas/testsuite/gas/hppa/parse/entrybug.s gas/testsuite/gas/hppa/parse/exportbug.s gas/testsuite/gas/hppa/parse/exprbug.s gas/testsuite/gas/hppa/parse/fixup7bug.s gas/testsuite/gas/hppa/parse/global.s gas/testsuite/gas/hppa/parse/labelbug.s gas/testsuite/gas/hppa/parse/linesepbug.s gas/testsuite/gas/hppa/parse/lselbug.s gas/testsuite/gas/hppa/parse/parse.exp gas/testsuite/gas/hppa/parse/procbug.s gas/testsuite/gas/hppa/parse/regpopbug.s gas/testsuite/gas/hppa/parse/stdreg.s gas/testsuite/gas/hppa/parse/stringer.s gas/testsuite/gas/hppa/parse/undefbug.s gas/testsuite/gas/hppa/parse/versionbug.s gas/testsuite/gas/hppa/parse/xmpyubug.s gas/testsuite/gas/hppa/reloc/applybug.s gas/testsuite/gas/hppa/reloc/blebug.s gas/testsuite/gas/hppa/reloc/blebug2.s gas/testsuite/gas/hppa/reloc/blebug3.s gas/testsuite/gas/hppa/reloc/exitbug.s gas/testsuite/gas/hppa/reloc/fixupbug.s gas/testsuite/gas/hppa/reloc/funcrelocbug.s gas/testsuite/gas/hppa/reloc/labelopbug.s gas/testsuite/gas/hppa/reloc/longcall.s gas/testsuite/gas/hppa/reloc/picreloc.s gas/testsuite/gas/hppa/reloc/plabelbug.s gas/testsuite/gas/hppa/reloc/r_no_reloc.s gas/testsuite/gas/hppa/reloc/reduce.s gas/testsuite/gas/hppa/reloc/reduce3.s gas/testsuite/gas/hppa/reloc/reloc.exp gas/testsuite/gas/hppa/reloc/roundmode.s gas/testsuite/gas/hppa/reloc/selectorbug.s gas/testsuite/gas/hppa/unsorted/brlenbug.s gas/testsuite/gas/hppa/unsorted/common.s gas/testsuite/gas/hppa/unsorted/fragbug.s gas/testsuite/gas/hppa/unsorted/importbug.s gas/testsuite/gas/hppa/unsorted/labeldiffs.s gas/testsuite/gas/hppa/unsorted/locallabel.s gas/testsuite/gas/hppa/unsorted/unsorted.exp gas/testsuite/gas/i386/amd.d gas/testsuite/gas/i386/amd.s gas/testsuite/gas/i386/float.l gas/testsuite/gas/i386/float.s gas/testsuite/gas/i386/general.l gas/testsuite/gas/i386/general.s gas/testsuite/gas/i386/i386.exp gas/testsuite/gas/i386/intel.d gas/testsuite/gas/i386/intel.s gas/testsuite/gas/i386/jump.d gas/testsuite/gas/i386/jump.s gas/testsuite/gas/i386/jump16.d gas/testsuite/gas/i386/jump16.s gas/testsuite/gas/i386/katmai.d gas/testsuite/gas/i386/katmai.s gas/testsuite/gas/i386/modrm.l gas/testsuite/gas/i386/modrm.s gas/testsuite/gas/i386/naked.d gas/testsuite/gas/i386/naked.s gas/testsuite/gas/i386/opcode.d gas/testsuite/gas/i386/prefix.d gas/testsuite/gas/i386/prefix.s gas/testsuite/gas/i386/reloc.d gas/testsuite/gas/i386/reloc.s gas/testsuite/gas/i386/white.l gas/testsuite/gas/i386/white.s gas/testsuite/gas/ieee-fp/x930509a.exp gas/testsuite/gas/m32r/error.exp gas/testsuite/gas/m32r/fslotx.d gas/testsuite/gas/m32r/fslotx.s gas/testsuite/gas/m32r/interfere.s gas/testsuite/gas/m32r/m32rx.d gas/testsuite/gas/m32r/m32rx.exp gas/testsuite/gas/m32r/m32rx.s gas/testsuite/gas/m32r/relax-2.d gas/testsuite/gas/m32r/relax-2.s gas/testsuite/gas/m32r/wrongsize.s gas/testsuite/gas/macros/irp.d gas/testsuite/gas/macros/irp.s gas/testsuite/gas/macros/rept.d gas/testsuite/gas/macros/rept.s gas/testsuite/gas/macros/test2.d gas/testsuite/gas/macros/test2.s gas/testsuite/gas/macros/test3.d gas/testsuite/gas/macros/test3.s gas/testsuite/gas/mcore/allinsn.d gas/testsuite/gas/mips/e32-rel2.d gas/testsuite/gas/mips/elf-rel.d gas/testsuite/gas/mips/elf-rel.s gas/testsuite/gas/mips/elf-rel2.d gas/testsuite/gas/mips/elf-rel2.s gas/testsuite/gas/mips/elf_e_flags.c gas/testsuite/gas/mips/elf_e_flags.s gas/testsuite/gas/mips/elf_e_flags1.d gas/testsuite/gas/mips/elf_e_flags2.d gas/testsuite/gas/mips/elf_e_flags3.d gas/testsuite/gas/mips/elf_e_flags4.d gas/testsuite/gas/mips/empic.d gas/testsuite/gas/mips/empic.s gas/testsuite/gas/mips/la-svr4pic.d gas/testsuite/gas/mips/la-xgot.d gas/testsuite/gas/mips/la.d gas/testsuite/gas/mips/mips.exp gas/testsuite/gas/mips/mips16-e.d gas/testsuite/gas/mips/mips16-e.s gas/testsuite/gas/mips/mips16-f.d gas/testsuite/gas/mips/mips16-f.s gas/testsuite/gas/mips/sync.d gas/testsuite/gas/mn10300/am33.s gas/testsuite/gas/mn10300/am33_2.s gas/testsuite/gas/mn10300/am33_3.s gas/testsuite/gas/mn10300/am33_4.s gas/testsuite/gas/mn10300/am33_5.s gas/testsuite/gas/mn10300/am33_6.s gas/testsuite/gas/mn10300/am33_7.s gas/testsuite/gas/mn10300/am33_8.s gas/testsuite/gas/mn10300/basic.exp gas/testsuite/gas/pj/ops.d gas/testsuite/gas/pj/ops.s gas/testsuite/gas/pj/pj.exp gas/testsuite/gas/sparc/prefetch.d gas/testsuite/gas/sparc/rdpr.d gas/testsuite/gas/sparc/reloc64.d gas/testsuite/gas/sparc/set64.d gas/testsuite/gas/sparc/set64.s gas/testsuite/gas/sparc/sparc.exp gas/testsuite/gas/sparc/synth64.d gas/testsuite/gas/sparc/synth64.s gas/testsuite/gas/sparc/wrpr.d gas/testsuite/gas/vtable/vtable.exp gas/testsuite/lib/gas-defs.exp gas/write.c gprof/ChangeLog gprof/Makefile.am gprof/Makefile.in gprof/alpha.c gprof/basic_blocks.c gprof/call_graph.c gprof/cg_dfn.c gprof/configure gprof/configure.in gprof/corefile.c gprof/gmon_io.c gprof/gprof.texi gprof/hertz.h gprof/hist.c gprof/i386.c gprof/po/POTFILES.in gprof/po/gprof.pot gprof/sparc.c gprof/sym_ids.c gprof/symtab.c gprof/tahoe.c gprof/utils.c gprof/vax.c include/ChangeLog include/ansidecl.h include/aout/ChangeLog include/aout/aout64.h include/bfdlink.h include/coff/ChangeLog include/coff/arm.h include/coff/internal.h include/coff/mcore.h include/coff/mipspe.h include/coff/pe.h include/coff/sh.h include/dis-asm.h include/elf/ChangeLog include/elf/arm-oabi.h include/elf/arm.h include/elf/avr.h include/elf/common.h include/elf/dwarf.h include/elf/dwarf2.h include/elf/hppa.h include/elf/i370.h include/elf/i386.h include/elf/i960.h include/elf/m32r.h include/elf/m68k.h include/elf/mcore.h include/elf/mips.h include/elf/mn10300.h include/elf/pj.h include/elf/reloc-macros.h include/elf/sh.h include/elf/sparc.h include/hashtab.h include/hp-symtab.h include/opcode/ChangeLog include/opcode/alpha.h include/opcode/cgen.h include/opcode/d10v.h include/opcode/d30v.h include/opcode/hppa.h include/opcode/i370.h include/opcode/i386.h include/opcode/m68k.h include/opcode/mips.h include/opcode/mn10300.h include/opcode/pj.h include/opcode/ppc.h include/partition.h include/remote-sim.h include/sim-d10v.h ld/ChangeLog ld/Makefile.am ld/Makefile.in ld/NEWS ld/aclocal.m4 ld/config.in ld/configure ld/configure.host ld/configure.in ld/configure.tgt ld/deffile.h ld/deffilep.y ld/emulparams/arm_epoc_pe.sh ld/emulparams/armelf.sh ld/emulparams/armelf_linux.sh ld/emulparams/armelf_linux26.sh ld/emulparams/armelf_oabi.sh ld/emulparams/armnbsd.sh ld/emulparams/armpe.sh ld/emulparams/avr1200.sh ld/emulparams/avr23xx.sh ld/emulparams/avr4433.sh ld/emulparams/avr44x4.sh ld/emulparams/avr85xx.sh ld/emulparams/avrmega103.sh ld/emulparams/avrmega161.sh ld/emulparams/avrmega603.sh ld/emulparams/d10velf.sh ld/emulparams/elf32_i960.sh ld/emulparams/elf32bmipn32.sh ld/emulparams/elf32i370.sh ld/emulparams/elf32mcore.sh ld/emulparams/elf32ppc.sh ld/emulparams/elf32ppclinux.sh ld/emulparams/elf64_sparc.sh ld/emulparams/elf64bmip.sh ld/emulparams/elf64hppa.sh ld/emulparams/i386pe.sh ld/emulparams/i386pe_posix.sh ld/emulparams/mcorepe.sh ld/emulparams/mipspe.sh ld/emulparams/pjelf.sh ld/emulparams/pjlelf.sh ld/emulparams/ppcpe.sh ld/emulparams/shpe.sh ld/emultempl/aix.em ld/emultempl/armcoff.em ld/emultempl/armelf.em ld/emultempl/armelf_oabi.em ld/emultempl/astring.sed ld/emultempl/beos.em ld/emultempl/elf32.em ld/emultempl/generic.em ld/emultempl/gld960.em ld/emultempl/gld960c.em ld/emultempl/hppaelf.em ld/emultempl/linux.em ld/emultempl/lnk960.em ld/emultempl/mipsecoff.em ld/emultempl/ostring.sed ld/emultempl/pe.em ld/emultempl/sunos.em ld/emultempl/vanilla.em ld/genscripts.sh ld/ld.h ld/ld.texinfo ld/ldcref.c ld/ldemul.c ld/ldemul.h ld/ldexp.c ld/ldfile.c ld/ldfile.h ld/ldgram.y ld/ldlang.c ld/ldlang.h ld/ldmain.c ld/ldmisc.c ld/lexsup.c ld/mri.c ld/pe-dll.c ld/pe-dll.h ld/po/POTFILES.in ld/po/ld.pot ld/scripttempl/armcoff.sc ld/scripttempl/elf.sc ld/scripttempl/elf32avr.sc ld/scripttempl/elfd10v.sc ld/scripttempl/elfi370.sc ld/scripttempl/epocpe.sc ld/scripttempl/i386go32.sc ld/scripttempl/mcorepe.sc ld/scripttempl/pe.sc ld/scripttempl/pj.sc ld/scripttempl/v850.sc ld/testsuite/ChangeLog ld/testsuite/ld-cdtest/cdtest-foo.cc ld/testsuite/ld-cdtest/cdtest-main.cc ld/testsuite/ld-checks/asm.s ld/testsuite/ld-checks/checks.exp ld/testsuite/ld-elfvers/vers.exp ld/testsuite/ld-elfvers/vers1.c ld/testsuite/ld-elfvers/vers15.c ld/testsuite/ld-elfvers/vers17.c ld/testsuite/ld-elfvers/vers17.dsym ld/testsuite/ld-elfvers/vers17.map ld/testsuite/ld-elfvers/vers17.ver ld/testsuite/ld-elfvers/vers18.c ld/testsuite/ld-elfvers/vers18.dsym ld/testsuite/ld-elfvers/vers18.map ld/testsuite/ld-elfvers/vers18.sym ld/testsuite/ld-elfvers/vers18.ver ld/testsuite/ld-elfvers/vers19.c ld/testsuite/ld-elfvers/vers19.dsym ld/testsuite/ld-elfvers/vers19.ver ld/testsuite/ld-elfvers/vers2.c ld/testsuite/ld-elfvers/vers3.c ld/testsuite/ld-elfvers/vers4.c ld/testsuite/ld-elfvers/vers6.c ld/testsuite/ld-elfvers/vers7.c ld/testsuite/ld-elfvers/vers9.c ld/testsuite/ld-scripts/phdrs.exp ld/testsuite/ld-scripts/phdrs.t ld/testsuite/ld-scripts/script.exp ld/testsuite/ld-scripts/weak.exp ld/testsuite/ld-selective/selective.exp ld/testsuite/ld-shared/main.c ld/testsuite/ld-shared/sh1.c ld/testsuite/ld-shared/shared.exp ld/testsuite/ld-srec/sr3.cc ld/testsuite/ld-srec/srec.exp ld/testsuite/ld-undefined/undefined.exp ld/testsuite/lib/ld-lib.exp libiberty/ChangeLog libiberty/Makefile.in libiberty/argv.c libiberty/choose-temp.c libiberty/config.in libiberty/configure libiberty/configure.in libiberty/cplus-dem.c libiberty/floatformat.c libiberty/getruntime.c libiberty/hashtab.c libiberty/partition.c libiberty/pexecute.c libiberty/splay-tree.c libiberty/vasprintf.c libiberty/xmalloc.c ltconfig ltmain.sh mkdep opcodes/ChangeLog opcodes/Makefile.am opcodes/Makefile.in opcodes/aclocal.m4 opcodes/alpha-dis.c opcodes/alpha-opc.c opcodes/arm-dis.c opcodes/arm-opc.h opcodes/avr-dis.c opcodes/cgen-opc.c opcodes/configure opcodes/configure.in opcodes/d10v-opc.c opcodes/d30v-dis.c opcodes/d30v-opc.c opcodes/dis-buf.c opcodes/disassemble.c opcodes/fr30-asm.c opcodes/fr30-desc.h opcodes/fr30-dis.c opcodes/fr30-ibld.c opcodes/fr30-opc.c opcodes/hppa-dis.c opcodes/i370-dis.c opcodes/i370-opc.c opcodes/i386-dis.c opcodes/m10300-dis.c opcodes/m10300-opc.c opcodes/m32r-asm.c opcodes/m32r-desc.c opcodes/m32r-desc.h opcodes/m32r-dis.c opcodes/m32r-ibld.c opcodes/m32r-opc.c opcodes/m32r-opc.h opcodes/m32r-opinst.c opcodes/m68k-dis.c opcodes/m68k-opc.c opcodes/mcore-dis.c opcodes/mcore-opc.h opcodes/mips-dis.c opcodes/mips-opc.c opcodes/pj-dis.c opcodes/pj-opc.c opcodes/po/POTFILES.in opcodes/po/opcodes.pot opcodes/ppc-opc.c opcodes/sh-dis.c opcodes/sh-opc.h opcodes/sparc-dis.c opcodes/sparc-opc.c opcodes/tic30-dis.c texinfo/texinfo.tex Delete: bfd/configure.bat bfd/makefile.dos binutils/configure.bat config/mh-aix43 configure.bat gas/config/go32.cfg gas/config/te-multi.h gas/configure.bat gprof/configure.bat include/wait.h intl/ChangeLog.Cygnus ld/configure.bat ld/emulparams/go32.sh ld/emultempl/stringify.sed ld/scripttempl/go32coff.sc ld/testsuite/ld-selective/5.cc libiberty/configure.bat libiberty/makefile.dos makeall.bat opcodes/configure.bat --- ChangeLog | 177 +- Makefile.in | 91 +- bfd/ChangeLog | 3556 +++++++++++++- bfd/Makefile.am | 148 +- bfd/Makefile.in | 156 +- bfd/acinclude.m4 | 23 +- bfd/aclocal.m4 | 325 +- bfd/aix386-core.c | 2 + bfd/aout-adobe.c | 13 +- bfd/aout-arm.c | 28 +- bfd/aout-ns32k.c | 4 +- bfd/aout-target.h | 15 +- bfd/aout-tic30.c | 47 +- bfd/aoutx.h | 73 +- bfd/archive.c | 17 +- bfd/archures.c | 103 +- bfd/armnetbsd.c | 49 + bfd/bfd-in.h | 42 +- bfd/bfd-in2.h | 300 +- bfd/bfd.c | 28 +- bfd/binary.c | 14 +- bfd/bout.c | 18 +- bfd/cisco-core.c | 172 +- bfd/coff-a29k.c | 100 +- bfd/coff-alpha.c | 15 +- bfd/coff-apollo.c | 55 +- bfd/coff-arm.c | 495 +- bfd/coff-go32.c | 18 +- bfd/coff-h8300.c | 63 +- bfd/coff-h8500.c | 42 +- bfd/coff-i386.c | 362 +- bfd/coff-i860.c | 38 +- bfd/coff-i960.c | 73 +- bfd/coff-m68k.c | 61 +- bfd/coff-m88k.c | 49 +- bfd/coff-mcore.c | 309 +- bfd/coff-mips.c | 75 +- bfd/coff-ppc.c | 145 +- bfd/coff-rs6000.c | 943 +++- bfd/coff-sh.c | 725 ++- bfd/coff-sparc.c | 66 +- bfd/coff-stgo32.c | 102 +- bfd/coff-tic30.c | 8 +- bfd/coff-tic80.c | 109 +- bfd/coff-w65.c | 43 +- bfd/coff-we32k.c | 73 +- bfd/coff-z8k.c | 42 +- bfd/coffcode.h | 1405 ++++-- bfd/coffgen.c | 115 +- bfd/cofflink.c | 518 +- bfd/coffswap.h | 34 +- bfd/config.bfd | 129 +- bfd/config.in | 9 + bfd/configure | 1346 ++--- bfd/configure.bat | 18 - bfd/configure.host | 2 + bfd/configure.in | 65 +- bfd/cpu-arm.c | 15 +- bfd/cpu-avr.c | 89 + bfd/cpu-d10v.c | 59 +- bfd/cpu-h8500.c | 4 +- bfd/cpu-hppa.c | 19 +- bfd/cpu-i370.c | 94 + bfd/cpu-m10300.c | 27 +- bfd/cpu-m32r.c | 7 + bfd/cpu-mcore.c | 4 +- bfd/cpu-ns32k.c | 6 +- bfd/cpu-pj.c | 85 + bfd/cpu-sh.c | 66 +- bfd/cpu-w65.c | 4 +- bfd/doc/Makefile.in | 8 +- bfd/dwarf1.c | 18 +- bfd/dwarf2.c | 321 +- bfd/ecoff.c | 46 +- bfd/ecofflink.c | 14 +- bfd/elf-bfd.h | 251 +- bfd/elf-hppa.h | 1884 +++++++ bfd/elf-m10200.c | 18 +- bfd/elf-m10300.c | 210 +- bfd/elf.c | 542 ++- bfd/elf32-arc.c | 8 +- bfd/elf32-arm.h | 663 ++- bfd/elf32-avr.c | 963 ++++ bfd/elf32-d10v.c | 25 +- bfd/elf32-d30v.c | 8 +- bfd/elf32-fr30.c | 30 +- bfd/elf32-gen.c | 11 +- bfd/elf32-hppa.c | 1775 +------ bfd/elf32-hppa.h | 29 +- bfd/elf32-i370.c | 1742 +++++++ bfd/elf32-i386.c | 66 +- bfd/elf32-i860.c | 7 +- bfd/elf32-i960.c | 168 + bfd/elf32-m32r.c | 182 +- bfd/elf32-m68k.c | 330 +- bfd/elf32-m88k.c | 1 + bfd/elf32-mcore.c | 69 +- bfd/elf32-mips.c | 4941 ++++++++++++------- bfd/elf32-pj.c | 349 ++ bfd/elf32-ppc.c | 241 +- bfd/elf32-sh.c | 243 +- bfd/elf32-sparc.c | 182 +- bfd/elf32-v850.c | 74 +- bfd/elf64-alpha.c | 110 +- bfd/elf64-gen.c | 1 + bfd/elf64-mips.c | 325 +- bfd/elf64-sparc.c | 1010 +++- bfd/elfarm-nabi.c | 10 +- bfd/elfarm-oabi.c | 101 +- bfd/elfcode.h | 188 +- bfd/elflink.c | 152 +- bfd/elflink.h | 1425 ++++-- bfd/elfxx-target.h | 94 +- bfd/epoc-pe-arm.c | 6 + bfd/freebsd.h | 6 +- bfd/hash.c | 6 +- bfd/hosts/alphalinux.h | 4 +- bfd/hp300hpux.c | 13 +- bfd/hppabsd-core.c | 2 + bfd/hpux-core.c | 2 + bfd/i386linux.c | 5 +- bfd/i386lynx.c | 7 +- bfd/i386msdos.c | 9 +- bfd/i386os9k.c | 8 +- bfd/ieee.c | 47 +- bfd/ihex.c | 10 +- bfd/irix-core.c | 2 + bfd/libbfd-in.h | 19 +- bfd/libbfd.c | 135 +- bfd/libbfd.h | 55 +- bfd/libcoff-in.h | 51 +- bfd/libcoff.h | 83 +- bfd/libecoff.h | 4 +- bfd/libhppa.h | 165 +- bfd/libpei.h | 254 + bfd/linker.c | 32 +- bfd/m68klinux.c | 5 +- bfd/makefile.dos | 49 - bfd/mipsbsd.c | 24 +- bfd/netbsd-core.c | 2 + bfd/netbsd.h | 6 +- bfd/nlm-target.h | 18 + bfd/nlm32-ppc.c | 12 +- bfd/nlm32-sparc.c | 14 +- bfd/nlmcode.h | 6 +- bfd/oasys.c | 30 +- bfd/osf-core.c | 2 + bfd/pc532-mach.c | 6 +- bfd/pe-arm.c | 13 + bfd/pe-i386.c | 9 +- bfd/pe-mips.c | 998 ++++ bfd/pe-ppc.c | 3 + bfd/pe-sh.c | 31 + bfd/pei-arm.c | 1 - bfd/pei-i386.c | 13 +- bfd/pei-mcore.c | 1 - bfd/pei-mips.c | 32 + bfd/pei-ppc.c | 8 +- bfd/pei-sh.c | 35 + bfd/peicode.h | 2849 ++++------- bfd/peigen.c | 1911 ++++++++ bfd/po/POTFILES.in | 76 +- bfd/po/bfd.pot | 1581 +++++- bfd/ppcboot.c | 14 +- bfd/ptrace-core.c | 2 + bfd/reloc.c | 378 +- bfd/reloc16.c | 13 +- bfd/riscix.c | 20 +- bfd/rs6000-core.c | 55 +- bfd/sco5-core.c | 2 + bfd/section.c | 171 +- bfd/som.c | 82 +- bfd/sparclinux.c | 5 +- bfd/srec.c | 35 +- bfd/stabs.c | 8 +- bfd/sunos.c | 14 +- bfd/syms.c | 109 +- bfd/targets.c | 68 +- bfd/tekhex.c | 15 +- bfd/trad-core.c | 25 +- bfd/versados.c | 24 +- bfd/vms-gsd.c | 23 +- bfd/vms-hdr.c | 6 +- bfd/vms-misc.c | 17 +- bfd/vms-tir.c | 50 +- bfd/vms.c | 241 +- bfd/vms.h | 4 +- bfd/xcofflink.c | 19 +- binutils/ChangeLog | 893 +++- binutils/Makefile.am | 83 +- binutils/Makefile.in | 122 +- binutils/NEWS | 16 +- binutils/aclocal.m4 | 351 +- binutils/addr2line.c | 2 +- binutils/ar.1 | 32 +- binutils/ar.c | 121 +- binutils/arparse.y | 2 +- binutils/arsup.c | 5 +- binutils/binutils.texi | 228 +- binutils/config.in | 6 + binutils/configure | 970 ++-- binutils/configure.bat | 63 - binutils/configure.in | 53 +- binutils/debug.c | 55 +- binutils/deflex.l | 11 +- binutils/defparse.y | 30 +- binutils/dlltool.c | 864 +++- binutils/dllwrap.c | 229 +- binutils/dyn-string.c | 4 +- binutils/dyn-string.h | 4 +- binutils/filemode.c | 6 +- binutils/ieee.c | 36 +- binutils/nm.c | 12 +- binutils/objcopy.1 | 19 +- binutils/objcopy.c | 171 +- binutils/objdump.c | 611 ++- binutils/po/POTFILES.in | 9 +- binutils/po/binutils.pot | 1545 +++--- binutils/prdbg.c | 8 +- binutils/rclex.l | 201 +- binutils/rcparse.y | 2 + binutils/rdcoff.c | 6 +- binutils/rddbg.c | 10 + binutils/readelf.c | 3041 +++++++++--- binutils/rename.c | 20 +- binutils/rescoff.c | 15 +- binutils/resrc.c | 485 +- binutils/resres.c | 19 +- binutils/size.c | 12 +- binutils/stabs.c | 87 +- binutils/strings.1 | 2 +- binutils/strings.c | 2 +- binutils/testsuite/ChangeLog | 56 + binutils/testsuite/binutils-all/hppa/freg.s | 23 + binutils/testsuite/binutils-all/hppa/objdump.exp | 31 + binutils/testsuite/binutils-all/objcopy.exp | 7 +- binutils/testsuite/binutils-all/objdump.exp | 4 +- binutils/testsuite/binutils-all/readelf.h | 8 +- binutils/testsuite/binutils-all/readelf.r | 2 +- binutils/testsuite/binutils-all/readelf.s | 19 +- binutils/testsuite/binutils-all/readelf.ss | 22 +- binutils/testsuite/binutils-all/readelf.wi | 48 +- binutils/testsuite/binutils-all/testprog.c | 2 + binutils/windres.c | 88 +- binutils/windres.h | 4 +- binutils/wrstabs.c | 6 +- config.guess | 515 +- config.sub | 368 +- config/ChangeLog | 14 + config/mh-i370pic | 1 + config/{mh-aix43 => mt-aix43} | 0 config/mt-i370pic | 1 + config/mt-wince | 10 + configure | 40 +- configure.bat | 17 - configure.in | 84 +- gas/ChangeLog | 2436 ++++++++++ gas/Makefile.am | 552 ++- gas/Makefile.in | 580 ++- gas/NEWS | 26 +- gas/aclocal.m4 | 302 +- gas/app.c | 142 +- gas/as.c | 245 +- gas/as.h | 49 +- gas/atof-generic.c | 2 +- gas/cgen.c | 3 +- gas/cond.c | 94 +- gas/config/atof-ieee.c | 31 +- gas/config/atof-vax.c | 7 +- gas/config/e-i386aout.c | 17 + gas/config/go32.cfg | 93 - gas/config/m68k-parse.h | 44 +- gas/config/obj-aout.c | 123 +- gas/config/obj-aout.h | 29 +- gas/config/obj-bout.c | 7 +- gas/config/obj-coff.c | 508 +- gas/config/obj-coff.h | 68 +- gas/config/obj-ecoff.c | 24 +- gas/config/obj-ecoff.h | 12 +- gas/config/obj-elf.c | 748 +-- gas/config/obj-elf.h | 145 +- gas/config/obj-evax.h | 4 +- gas/config/obj-multi.h | 138 +- gas/config/obj-som.c | 36 +- gas/config/obj-vms.h | 7 +- gas/config/tc-alpha.c | 1231 ++++- gas/config/tc-alpha.h | 46 +- gas/config/tc-arc.c | 35 +- gas/config/tc-arc.h | 4 +- gas/config/tc-arm.c | 1795 ++++--- gas/config/tc-arm.h | 25 +- gas/config/tc-avr.c | 1252 +++++ gas/config/tc-avr.h | 118 + gas/config/tc-d10v.c | 57 +- gas/config/tc-d10v.h | 1 + gas/config/tc-d30v.c | 85 +- gas/config/tc-d30v.h | 9 +- gas/config/tc-fr30.c | 2 +- gas/config/tc-h8300.c | 28 +- gas/config/tc-hppa.c | 3441 +++++++++---- gas/config/tc-hppa.h | 22 +- gas/config/tc-i370.c | 2967 ++++++++++++ gas/config/tc-i370.h | 104 + gas/config/tc-i386.c | 2681 +++++----- gas/config/tc-i386.h | 101 +- gas/config/tc-i860.c | 10 +- gas/config/tc-i960.c | 136 +- gas/config/tc-i960.h | 31 +- gas/config/tc-m32r.c | 655 ++- gas/config/tc-m68k.c | 223 +- gas/config/tc-m68k.h | 11 +- gas/config/tc-m88k.c | 12 +- gas/config/tc-m88k.h | 4 +- gas/config/tc-mcore.c | 505 +- gas/config/tc-mcore.h | 22 +- gas/config/tc-mips.c | 722 +-- gas/config/tc-mips.h | 8 +- gas/config/tc-mn10200.c | 6 +- gas/config/tc-mn10300.c | 353 +- gas/config/tc-ns32k.c | 8 +- gas/config/tc-ns32k.h | 4 +- gas/config/tc-pj.c | 594 +++ gas/config/tc-pj.h | 62 + gas/config/tc-ppc.c | 483 +- gas/config/tc-ppc.h | 43 +- gas/config/tc-sh.c | 740 ++- gas/config/tc-sh.h | 27 +- gas/config/tc-sparc.c | 1081 +++-- gas/config/tc-sparc.h | 51 +- gas/config/tc-tahoe.c | 2 +- gas/config/tc-tic30.c | 5 +- gas/config/tc-v850.c | 64 +- gas/config/tc-vax.c | 5 +- gas/config/tc-w65.c | 2 +- gas/config/tc-z8k.c | 4 +- gas/config/te-go32.h | 2 + gas/config/te-interix.h | 16 + gas/config/te-multi.h | 22 - gas/config/te-wince-pe.h | 2 + gas/configure | 1256 ++--- gas/configure.bat | 57 - gas/configure.in | 92 +- gas/dep-in.sed | 1 - gas/doc/Makefile.am | 3 + gas/doc/Makefile.in | 12 +- gas/doc/all.texi | 16 +- gas/doc/as.1 | 10 +- gas/doc/as.texinfo | 171 +- gas/doc/c-arm.texi | 84 +- gas/doc/c-i370.texi | 200 + gas/doc/c-i386.texi | 19 +- gas/doc/c-m32r.texi | 131 +- gas/doc/c-mips.texi | 18 + gas/doc/c-pj.texi | 28 + gas/doc/c-sparc.texi | 17 +- gas/doc/internals.texi | 251 +- gas/dwarf2dbg.c | 770 +++ gas/dwarf2dbg.h | 69 + gas/ecoff.c | 74 +- gas/ecoff.h | 10 +- gas/expr.c | 159 +- gas/expr.h | 35 +- gas/frags.c | 15 +- gas/frags.h | 11 +- gas/gasp.c | 56 +- gas/hash.c | 1103 ++--- gas/hash.h | 87 +- gas/input-file.c | 19 +- gas/input-scrub.c | 30 +- gas/itbl-ops.c | 57 +- gas/itbl-ops.h | 8 +- gas/listing.c | 83 +- gas/macro.c | 55 +- gas/macro.h | 39 +- gas/obj.h | 5 +- gas/output-file.c | 6 +- gas/po/POTFILES.in | 118 +- gas/po/gas.pot | 5654 ++++++++++++++++++---- gas/read.c | 358 +- gas/read.h | 6 + gas/sb.h | 2 +- gas/stabs.c | 31 +- gas/struc-symbol.h | 124 +- gas/subsegs.c | 51 +- gas/symbols.c | 863 +++- gas/symbols.h | 117 +- gas/testsuite/ChangeLog | 352 ++ gas/testsuite/gas/all/cond.d | 14 +- gas/testsuite/gas/all/gas.exp | 9 +- gas/testsuite/gas/all/itbl-test.c | 4 +- gas/testsuite/gas/arm/arm7t.d | 24 +- gas/testsuite/gas/arm/arm7t.s | 7 +- gas/testsuite/gas/arm/float.s | 22 +- gas/testsuite/gas/arm/inst.d | 69 +- gas/testsuite/gas/arm/inst.s | 38 +- gas/testsuite/gas/arm/thumb.s | 1 + gas/testsuite/gas/d10v/d10.exp | 19 + gas/testsuite/gas/d10v/inst.d | 22 + gas/testsuite/gas/d10v/inst.s | 31 + gas/testsuite/gas/elf/elf.exp | 15 + gas/testsuite/gas/elf/section0.d | 16 + gas/testsuite/gas/elf/section0.s | 16 + gas/testsuite/gas/elf/section1.d | 16 + gas/testsuite/gas/elf/section1.s | 32 + gas/testsuite/gas/hppa/basic/add.s | 79 +- gas/testsuite/gas/hppa/basic/add2.s | 92 + gas/testsuite/gas/hppa/basic/addi.s | 64 +- gas/testsuite/gas/hppa/basic/basic.exp | 1662 ++++++- gas/testsuite/gas/hppa/basic/branch.s | 11 +- gas/testsuite/gas/hppa/basic/branch2.s | 32 + gas/testsuite/gas/hppa/basic/comclr.s | 11 +- gas/testsuite/gas/hppa/basic/copr.s | 11 +- gas/testsuite/gas/hppa/basic/coprmem.s | 11 +- gas/testsuite/gas/hppa/basic/dcor.s | 27 +- gas/testsuite/gas/hppa/basic/dcor2.s | 34 + gas/testsuite/gas/hppa/basic/deposit.s | 11 +- gas/testsuite/gas/hppa/basic/deposit2.s | 78 + gas/testsuite/gas/hppa/basic/deposit3.s | 79 + gas/testsuite/gas/hppa/basic/ds.s | 11 +- gas/testsuite/gas/hppa/basic/extract.s | 11 +- gas/testsuite/gas/hppa/basic/extract2.s | 42 + gas/testsuite/gas/hppa/basic/extract3.s | 43 + gas/testsuite/gas/hppa/basic/fmem.s | 11 +- gas/testsuite/gas/hppa/basic/fp_comp.s | 11 +- gas/testsuite/gas/hppa/basic/fp_comp2.s | 30 + gas/testsuite/gas/hppa/basic/fp_conv.s | 11 +- gas/testsuite/gas/hppa/basic/fp_fcmp.s | 11 +- gas/testsuite/gas/hppa/basic/fp_misc.s | 11 +- gas/testsuite/gas/hppa/basic/imem.s | 11 +- gas/testsuite/gas/hppa/basic/immed.s | 11 +- gas/testsuite/gas/hppa/basic/logical.s | 11 +- gas/testsuite/gas/hppa/basic/media.s | 38 + gas/testsuite/gas/hppa/basic/perf.s | 10 + gas/testsuite/gas/hppa/basic/purge.s | 11 +- gas/testsuite/gas/hppa/basic/purge2.s | 12 + gas/testsuite/gas/hppa/basic/sh1add.s | 11 +- gas/testsuite/gas/hppa/basic/sh2add.s | 11 +- gas/testsuite/gas/hppa/basic/sh3add.s | 11 +- gas/testsuite/gas/hppa/basic/shift.s | 11 +- gas/testsuite/gas/hppa/basic/shift2.s | 24 + gas/testsuite/gas/hppa/basic/shift3.s | 26 + gas/testsuite/gas/hppa/basic/shladd.s | 160 + gas/testsuite/gas/hppa/basic/shladd2.s | 161 + gas/testsuite/gas/hppa/basic/special.s | 11 +- gas/testsuite/gas/hppa/basic/spop.s | 11 +- gas/testsuite/gas/hppa/basic/sub.s | 96 +- gas/testsuite/gas/hppa/basic/sub2.s | 109 + gas/testsuite/gas/hppa/basic/subi.s | 28 +- gas/testsuite/gas/hppa/basic/system.s | 11 +- gas/testsuite/gas/hppa/basic/system2.s | 19 + gas/testsuite/gas/hppa/basic/unit.s | 26 +- gas/testsuite/gas/hppa/basic/unit2.s | 47 + gas/testsuite/gas/hppa/parse/align1.s | 14 +- gas/testsuite/gas/hppa/parse/align2.s | 11 +- gas/testsuite/gas/hppa/parse/badfmpyadd.s | 16 +- gas/testsuite/gas/hppa/parse/block1.s | 9 +- gas/testsuite/gas/hppa/parse/block2.s | 11 +- gas/testsuite/gas/hppa/parse/calldatabug.s | 13 +- gas/testsuite/gas/hppa/parse/callinfobug.s | 3 +- gas/testsuite/gas/hppa/parse/defbug.s | 11 +- gas/testsuite/gas/hppa/parse/entrybug.s | 14 +- gas/testsuite/gas/hppa/parse/exportbug.s | 11 +- gas/testsuite/gas/hppa/parse/exprbug.s | 3 +- gas/testsuite/gas/hppa/parse/fixup7bug.s | 31 +- gas/testsuite/gas/hppa/parse/global.s | 10 +- gas/testsuite/gas/hppa/parse/labelbug.s | 10 +- gas/testsuite/gas/hppa/parse/linesepbug.s | 10 +- gas/testsuite/gas/hppa/parse/lselbug.s | 10 +- gas/testsuite/gas/hppa/parse/parse.exp | 1 + gas/testsuite/gas/hppa/parse/procbug.s | 3 +- gas/testsuite/gas/hppa/parse/regpopbug.s | 10 +- gas/testsuite/gas/hppa/parse/stdreg.s | 11 +- gas/testsuite/gas/hppa/parse/stringer.s | 10 +- gas/testsuite/gas/hppa/parse/undefbug.s | 10 +- gas/testsuite/gas/hppa/parse/versionbug.s | 7 +- gas/testsuite/gas/hppa/parse/xmpyubug.s | 11 +- gas/testsuite/gas/hppa/reloc/applybug.s | 20 +- gas/testsuite/gas/hppa/reloc/blebug.s | 11 +- gas/testsuite/gas/hppa/reloc/blebug2.s | 11 +- gas/testsuite/gas/hppa/reloc/blebug3.s | 11 +- gas/testsuite/gas/hppa/reloc/exitbug.s | 13 +- gas/testsuite/gas/hppa/reloc/fixupbug.s | 12 +- gas/testsuite/gas/hppa/reloc/funcrelocbug.s | 19 +- gas/testsuite/gas/hppa/reloc/labelopbug.s | 13 +- gas/testsuite/gas/hppa/reloc/longcall.s | 14 +- gas/testsuite/gas/hppa/reloc/picreloc.s | 8 +- gas/testsuite/gas/hppa/reloc/plabelbug.s | 14 +- gas/testsuite/gas/hppa/reloc/r_no_reloc.s | 16 +- gas/testsuite/gas/hppa/reloc/reduce.s | 13 +- gas/testsuite/gas/hppa/reloc/reduce3.s | 17 +- gas/testsuite/gas/hppa/reloc/reloc.exp | 112 +- gas/testsuite/gas/hppa/reloc/roundmode.s | 10 +- gas/testsuite/gas/hppa/reloc/selectorbug.s | 14 +- gas/testsuite/gas/hppa/unsorted/brlenbug.s | 26 +- gas/testsuite/gas/hppa/unsorted/common.s | 2 +- gas/testsuite/gas/hppa/unsorted/fragbug.s | 3 +- gas/testsuite/gas/hppa/unsorted/importbug.s | 12 +- gas/testsuite/gas/hppa/unsorted/labeldiffs.s | 3 +- gas/testsuite/gas/hppa/unsorted/locallabel.s | 10 +- gas/testsuite/gas/hppa/unsorted/unsorted.exp | 35 +- gas/testsuite/gas/i386/amd.d | 9 +- gas/testsuite/gas/i386/amd.s | 6 +- gas/testsuite/gas/i386/float.l | 4 + gas/testsuite/gas/i386/float.s | 2 + gas/testsuite/gas/i386/general.l | 323 +- gas/testsuite/gas/i386/general.s | 58 +- gas/testsuite/gas/i386/i386.exp | 11 +- gas/testsuite/gas/i386/intel.d | 574 +++ gas/testsuite/gas/i386/intel.s | 568 +++ gas/testsuite/gas/i386/jump.d | 26 + gas/testsuite/gas/i386/jump.s | 24 + gas/testsuite/gas/i386/jump16.d | 40 + gas/testsuite/gas/i386/jump16.s | 43 + gas/testsuite/gas/i386/katmai.d | 172 + gas/testsuite/gas/i386/katmai.s | 167 + gas/testsuite/gas/i386/modrm.l | 2 +- gas/testsuite/gas/i386/modrm.s | 2 +- gas/testsuite/gas/i386/naked.d | 32 + gas/testsuite/gas/i386/naked.s | 25 + gas/testsuite/gas/i386/opcode.d | 2 +- gas/testsuite/gas/i386/prefix.s | 4 +- gas/testsuite/gas/i386/reloc.d | 21 +- gas/testsuite/gas/i386/reloc.s | 3 + gas/testsuite/gas/i386/white.l | 3 + gas/testsuite/gas/i386/white.s | 3 + gas/testsuite/gas/ieee-fp/x930509a.exp | 7 +- gas/testsuite/gas/m32r/error.exp | 15 + gas/testsuite/gas/m32r/fslotx.d | 23 + gas/testsuite/gas/m32r/fslotx.s | 19 + gas/testsuite/gas/m32r/interfere.s | 14 + gas/testsuite/gas/m32r/m32rx.d | 337 ++ gas/testsuite/gas/m32r/m32rx.exp | 7 + gas/testsuite/gas/m32r/m32rx.s | 590 +++ gas/testsuite/gas/m32r/relax-2.d | 18 + gas/testsuite/gas/m32r/relax-2.s | 11 + gas/testsuite/gas/m32r/wrongsize.s | 10 + gas/testsuite/gas/macros/irp.d | 12 +- gas/testsuite/gas/macros/irp.s | 4 +- gas/testsuite/gas/macros/rept.d | 6 +- gas/testsuite/gas/macros/rept.s | 2 +- gas/testsuite/gas/macros/test2.d | 6 +- gas/testsuite/gas/macros/test2.s | 2 +- gas/testsuite/gas/macros/test3.d | 2 +- gas/testsuite/gas/macros/test3.s | 2 +- gas/testsuite/gas/mcore/allinsn.d | 263 +- gas/testsuite/gas/mips/e32-rel2.d | 30 + gas/testsuite/gas/mips/elf-rel.d | 42 + gas/testsuite/gas/mips/elf-rel.s | 33 + gas/testsuite/gas/mips/elf-rel2.d | 26 + gas/testsuite/gas/mips/elf-rel2.s | 29 + gas/testsuite/gas/mips/elf_e_flags.c | 6 +- gas/testsuite/gas/mips/elf_e_flags.s | 6 +- gas/testsuite/gas/mips/elf_e_flags1.d | 13 +- gas/testsuite/gas/mips/elf_e_flags2.d | 9 +- gas/testsuite/gas/mips/elf_e_flags3.d | 9 +- gas/testsuite/gas/mips/elf_e_flags4.d | 9 +- gas/testsuite/gas/mips/empic.d | 155 + gas/testsuite/gas/mips/empic.s | 112 + gas/testsuite/gas/mips/la-svr4pic.d | 925 ++-- gas/testsuite/gas/mips/la-xgot.d | 1213 +++-- gas/testsuite/gas/mips/la.d | 745 ++- gas/testsuite/gas/mips/mips.exp | 15 + gas/testsuite/gas/mips/mips16-e.d | 41 + gas/testsuite/gas/mips/mips16-e.s | 13 + gas/testsuite/gas/mips/mips16-f.d | 33 + gas/testsuite/gas/mips/mips16-f.s | 6 + gas/testsuite/gas/mips/sync.d | 2 +- gas/testsuite/gas/mn10300/am33.s | 46 + gas/testsuite/gas/mn10300/am33_2.s | 64 + gas/testsuite/gas/mn10300/am33_3.s | 44 + gas/testsuite/gas/mn10300/am33_4.s | 47 + gas/testsuite/gas/mn10300/am33_5.s | 65 + gas/testsuite/gas/mn10300/am33_6.s | 70 + gas/testsuite/gas/mn10300/am33_7.s | 71 + gas/testsuite/gas/mn10300/am33_8.s | 70 + gas/testsuite/gas/mn10300/basic.exp | 782 +++ gas/testsuite/gas/pj/ops.d | 407 ++ gas/testsuite/gas/pj/ops.s | 397 ++ gas/testsuite/gas/pj/pj.exp | 7 + gas/testsuite/gas/sparc/prefetch.d | 2 +- gas/testsuite/gas/sparc/rdpr.d | 2 +- gas/testsuite/gas/sparc/reloc64.d | 22 +- gas/testsuite/gas/sparc/set64.d | 131 +- gas/testsuite/gas/sparc/set64.s | 15 +- gas/testsuite/gas/sparc/sparc.exp | 33 +- gas/testsuite/gas/sparc/synth64.d | 4 +- gas/testsuite/gas/sparc/synth64.s | 3 + gas/testsuite/gas/sparc/wrpr.d | 2 +- gas/testsuite/gas/vtable/vtable.exp | 16 +- gas/testsuite/lib/gas-defs.exp | 19 +- gas/write.c | 273 +- gprof/ChangeLog | 69 + gprof/Makefile.am | 2 +- gprof/Makefile.in | 6 +- gprof/alpha.c | 11 +- gprof/basic_blocks.c | 10 +- gprof/call_graph.c | 5 +- gprof/cg_dfn.c | 14 +- gprof/configure | 329 +- gprof/configure.bat | 18 - gprof/configure.in | 2 +- gprof/corefile.c | 22 +- gprof/gmon_io.c | 21 +- gprof/gprof.texi | 2 +- gprof/hertz.h | 7 - gprof/hist.c | 20 +- gprof/i386.c | 10 +- gprof/po/POTFILES.in | 1 - gprof/po/gprof.pot | 112 +- gprof/sparc.c | 9 +- gprof/sym_ids.c | 12 +- gprof/symtab.c | 13 +- gprof/tahoe.c | 15 +- gprof/utils.c | 2 +- gprof/vax.c | 14 +- include/ChangeLog | 228 +- include/ansidecl.h | 1 - include/aout/ChangeLog | 5 + include/aout/aout64.h | 4 + include/bfdlink.h | 14 +- include/coff/ChangeLog | 81 +- include/coff/arm.h | 125 +- include/coff/internal.h | 58 +- include/coff/mcore.h | 3 +- include/coff/mipspe.h | 223 + include/coff/pe.h | 65 +- include/coff/sh.h | 38 + include/dis-asm.h | 35 +- include/elf/ChangeLog | 251 +- include/elf/arm-oabi.h | 39 +- include/elf/arm.h | 25 +- include/elf/avr.h | 58 + include/elf/common.h | 123 +- include/elf/dwarf.h | 5 +- include/elf/dwarf2.h | 1 + include/elf/hppa.h | 341 +- include/elf/i370.h | 46 + include/elf/i386.h | 2 +- include/elf/i960.h | 38 + include/elf/m32r.h | 2 + include/elf/m68k.h | 2 + include/elf/mcore.h | 6 +- include/elf/mips.h | 48 +- include/elf/mn10300.h | 1 + include/elf/pj.h | 45 + include/elf/reloc-macros.h | 4 +- include/elf/sh.h | 27 + include/elf/sparc.h | 25 +- include/hashtab.h | 109 +- include/hp-symtab.h | 11 +- include/opcode/ChangeLog | 304 ++ include/opcode/alpha.h | 4 +- include/opcode/cgen.h | 21 +- include/opcode/d10v.h | 4 + include/opcode/d30v.h | 83 +- include/opcode/hppa.h | 971 ++-- include/opcode/i370.h | 265 + include/opcode/i386.h | 689 +-- include/opcode/m68k.h | 33 +- include/opcode/mips.h | 26 + include/opcode/mn10300.h | 23 + include/opcode/pj.h | 46 + include/opcode/ppc.h | 3 + include/partition.h | 81 + include/remote-sim.h | 52 +- include/sim-d10v.h | 103 + include/wait.h | 63 - intl/ChangeLog.Cygnus | 30 - ld/ChangeLog | 1060 +++- ld/Makefile.am | 166 +- ld/Makefile.in | 176 +- ld/NEWS | 10 + ld/aclocal.m4 | 351 +- ld/config.in | 3 + ld/configure | 1294 +++-- ld/configure.bat | 72 - ld/configure.host | 111 +- ld/configure.in | 52 +- ld/configure.tgt | 67 +- ld/deffile.h | 5 + ld/deffilep.y | 56 +- ld/emulparams/arm_epoc_pe.sh | 5 +- ld/emulparams/armelf.sh | 3 +- ld/emulparams/armelf_linux.sh | 6 +- ld/emulparams/armelf_linux26.sh | 4 + ld/emulparams/armelf_oabi.sh | 2 +- ld/emulparams/armnbsd.sh | 7 + ld/emulparams/armpe.sh | 3 + ld/emulparams/avr1200.sh | 11 + ld/emulparams/avr23xx.sh | 12 + ld/emulparams/avr4433.sh | 12 + ld/emulparams/avr44x4.sh | 12 + ld/emulparams/avr85xx.sh | 12 + ld/emulparams/avrmega103.sh | 12 + ld/emulparams/avrmega161.sh | 12 + ld/emulparams/avrmega603.sh | 12 + ld/emulparams/d10velf.sh | 2 +- ld/emulparams/elf32_i960.sh | 8 + ld/emulparams/elf32bmipn32.sh | 75 + ld/emulparams/elf32i370.sh | 8 + ld/emulparams/elf32mcore.sh | 85 +- ld/emulparams/elf32ppc.sh | 2 +- ld/emulparams/elf32ppclinux.sh | 8 + ld/emulparams/elf64_sparc.sh | 34 + ld/emulparams/elf64bmip.sh | 79 + ld/emulparams/elf64hppa.sh | 56 + ld/emulparams/go32.sh | 7 - ld/emulparams/i386pe.sh | 3 + ld/emulparams/i386pe_posix.sh | 9 + ld/emulparams/mcorepe.sh | 5 +- ld/emulparams/mipspe.sh | 8 + ld/emulparams/pjelf.sh | 5 + ld/emulparams/pjlelf.sh | 5 + ld/emulparams/ppcpe.sh | 3 + ld/emulparams/shpe.sh | 6 + ld/emultempl/aix.em | 7 +- ld/emultempl/armcoff.em | 92 +- ld/emultempl/armelf.em | 1157 ++++- ld/emultempl/armelf_oabi.em | 22 +- ld/emultempl/astring.sed | 13 + ld/emultempl/beos.em | 10 +- ld/emultempl/elf32.em | 118 +- ld/emultempl/generic.em | 16 +- ld/emultempl/gld960.em | 41 +- ld/emultempl/gld960c.em | 41 +- ld/emultempl/hppaelf.em | 37 +- ld/emultempl/linux.em | 40 +- ld/emultempl/lnk960.em | 42 +- ld/emultempl/mipsecoff.em | 16 +- ld/emultempl/{stringify.sed => ostring.sed} | 0 ld/emultempl/pe.em | 339 +- ld/emultempl/sunos.em | 52 +- ld/emultempl/vanilla.em | 12 +- ld/genscripts.sh | 42 +- ld/ld.h | 22 +- ld/ld.texinfo | 125 +- ld/ldcref.c | 8 +- ld/ldemul.c | 18 +- ld/ldemul.h | 11 +- ld/ldexp.c | 10 +- ld/ldfile.c | 46 +- ld/ldfile.h | 3 + ld/ldgram.y | 80 +- ld/ldlang.c | 1273 +++-- ld/ldlang.h | 17 +- ld/ldmain.c | 45 +- ld/ldmisc.c | 23 +- ld/lexsup.c | 57 +- ld/mri.c | 3 +- ld/pe-dll.c | 435 +- ld/pe-dll.h | 48 + ld/po/POTFILES.in | 41 +- ld/po/ld.pot | 745 +-- ld/scripttempl/armcoff.sc | 2 +- ld/scripttempl/elf.sc | 110 +- ld/scripttempl/elf32avr.sc | 149 + ld/scripttempl/elfd10v.sc | 137 +- ld/scripttempl/elfi370.sc | 218 + ld/scripttempl/epocpe.sc | 151 + ld/scripttempl/go32coff.sc | 33 - ld/scripttempl/i386go32.sc | 18 +- ld/scripttempl/mcorepe.sc | 14 +- ld/scripttempl/pe.sc | 32 +- ld/scripttempl/pj.sc | 55 + ld/scripttempl/v850.sc | 8 +- ld/testsuite/ChangeLog | 121 + ld/testsuite/ld-cdtest/cdtest-foo.cc | 2 +- ld/testsuite/ld-cdtest/cdtest-main.cc | 2 +- ld/testsuite/ld-checks/asm.s | 5 +- ld/testsuite/ld-checks/checks.exp | 11 +- ld/testsuite/ld-elfvers/vers.exp | 10 +- ld/testsuite/ld-elfvers/vers1.c | 7 +- ld/testsuite/ld-elfvers/vers15.c | 1 + ld/testsuite/ld-elfvers/vers17.c | 5 + ld/testsuite/ld-elfvers/vers17.dsym | 2 + ld/testsuite/ld-elfvers/vers17.map | 4 + ld/testsuite/ld-elfvers/vers17.ver | 3 + ld/testsuite/ld-elfvers/vers18.c | 42 + ld/testsuite/ld-elfvers/vers18.dsym | 7 + ld/testsuite/ld-elfvers/vers18.map | 15 + ld/testsuite/ld-elfvers/vers18.sym | 4 + ld/testsuite/ld-elfvers/vers18.ver | 12 + ld/testsuite/ld-elfvers/vers19.c | 10 + ld/testsuite/ld-elfvers/vers19.dsym | 1 + ld/testsuite/ld-elfvers/vers19.ver | 3 + ld/testsuite/ld-elfvers/vers2.c | 3 + ld/testsuite/ld-elfvers/vers3.c | 3 + ld/testsuite/ld-elfvers/vers4.c | 4 + ld/testsuite/ld-elfvers/vers6.c | 6 + ld/testsuite/ld-elfvers/vers7.c | 2 + ld/testsuite/ld-elfvers/vers9.c | 2 + ld/testsuite/ld-scripts/phdrs.exp | 4 +- ld/testsuite/ld-scripts/phdrs.t | 2 +- ld/testsuite/ld-scripts/script.exp | 15 +- ld/testsuite/ld-scripts/weak.exp | 4 +- ld/testsuite/ld-selective/5.cc | 32 - ld/testsuite/ld-selective/selective.exp | 36 +- ld/testsuite/ld-shared/main.c | 1 + ld/testsuite/ld-shared/sh1.c | 2 +- ld/testsuite/ld-shared/shared.exp | 11 +- ld/testsuite/ld-srec/sr3.cc | 7 +- ld/testsuite/ld-srec/srec.exp | 17 +- ld/testsuite/ld-undefined/undefined.exp | 8 +- ld/testsuite/lib/ld-lib.exp | 60 +- libiberty/ChangeLog | 170 +- libiberty/Makefile.in | 34 +- libiberty/configure.bat | 14 - libiberty/floatformat.c | 10 +- libiberty/hashtab.c | 431 +- libiberty/makefile.dos | 29 - libiberty/partition.c | 185 + libiberty/pexecute.c | 4 +- ltconfig | 816 ++-- ltmain.sh | 748 ++- makeall.bat | 16 - mkdep | 87 + opcodes/ChangeLog | 683 ++- opcodes/Makefile.am | 77 +- opcodes/Makefile.in | 94 +- opcodes/aclocal.m4 | 351 +- opcodes/alpha-dis.c | 1 - opcodes/alpha-opc.c | 40 +- opcodes/arm-dis.c | 502 +- opcodes/arm-opc.h | 9 +- opcodes/avr-dis.c | 577 +++ opcodes/cgen-opc.c | 26 +- opcodes/configure | 1126 ++--- opcodes/configure.bat | 24 - opcodes/configure.in | 5 +- opcodes/d10v-opc.c | 15 +- opcodes/d30v-dis.c | 59 +- opcodes/d30v-opc.c | 115 +- opcodes/dis-buf.c | 25 +- opcodes/disassemble.c | 31 +- opcodes/fr30-asm.c | 25 +- opcodes/fr30-desc.h | 4 + opcodes/fr30-dis.c | 8 +- opcodes/fr30-ibld.c | 39 +- opcodes/fr30-opc.c | 4 +- opcodes/hppa-dis.c | 803 ++- opcodes/i370-dis.c | 167 + opcodes/i370-opc.c | 959 ++++ opcodes/i386-dis.c | 3203 ++++++------ opcodes/m10300-dis.c | 134 + opcodes/m10300-opc.c | 756 ++- opcodes/m32r-asm.c | 52 +- opcodes/m32r-desc.c | 423 +- opcodes/m32r-desc.h | 32 +- opcodes/m32r-dis.c | 22 +- opcodes/m32r-ibld.c | 119 +- opcodes/m32r-opc.c | 452 +- opcodes/m32r-opc.h | 54 +- opcodes/m32r-opinst.c | 479 +- opcodes/m68k-dis.c | 75 +- opcodes/m68k-opc.c | 493 +- opcodes/mcore-dis.c | 60 +- opcodes/mcore-opc.h | 11 +- opcodes/mips-dis.c | 24 +- opcodes/mips-opc.c | 132 +- opcodes/pj-dis.c | 175 + opcodes/pj-opc.c | 536 ++ opcodes/po/POTFILES.in | 5 +- opcodes/po/opcodes.pot | 155 +- opcodes/ppc-opc.c | 50 +- opcodes/sh-dis.c | 352 +- opcodes/sh-opc.h | 731 ++- opcodes/sparc-dis.c | 15 +- opcodes/sparc-opc.c | 122 +- opcodes/tic30-dis.c | 5 +- texinfo/texinfo.tex | 5431 +++++++++++++++++++++ 870 files changed, 109328 insertions(+), 36392 deletions(-) create mode 100644 bfd/armnetbsd.c delete mode 100644 bfd/configure.bat create mode 100644 bfd/cpu-avr.c create mode 100644 bfd/cpu-i370.c create mode 100644 bfd/cpu-pj.c create mode 100644 bfd/elf-hppa.h create mode 100644 bfd/elf32-avr.c create mode 100644 bfd/elf32-i370.c create mode 100644 bfd/elf32-i960.c create mode 100644 bfd/elf32-pj.c create mode 100644 bfd/libpei.h delete mode 100644 bfd/makefile.dos create mode 100644 bfd/pe-mips.c create mode 100644 bfd/pe-sh.c create mode 100644 bfd/pei-mips.c create mode 100644 bfd/pei-sh.c create mode 100644 bfd/peigen.c delete mode 100755 binutils/configure.bat create mode 100644 binutils/testsuite/binutils-all/hppa/freg.s create mode 100644 config/mh-i370pic rename config/{mh-aix43 => mt-aix43} (100%) create mode 100644 config/mt-i370pic create mode 100644 config/mt-wince delete mode 100644 configure.bat create mode 100644 gas/config/e-i386aout.c delete mode 100644 gas/config/go32.cfg create mode 100644 gas/config/tc-avr.c create mode 100644 gas/config/tc-avr.h create mode 100644 gas/config/tc-i370.c create mode 100644 gas/config/tc-i370.h create mode 100644 gas/config/tc-pj.c create mode 100644 gas/config/tc-pj.h create mode 100644 gas/config/te-interix.h delete mode 100644 gas/config/te-multi.h create mode 100644 gas/config/te-wince-pe.h delete mode 100644 gas/configure.bat create mode 100644 gas/doc/c-i370.texi create mode 100644 gas/doc/c-pj.texi create mode 100644 gas/dwarf2dbg.c create mode 100644 gas/dwarf2dbg.h create mode 100644 gas/testsuite/gas/d10v/d10.exp create mode 100644 gas/testsuite/gas/d10v/inst.d create mode 100644 gas/testsuite/gas/d10v/inst.s create mode 100644 gas/testsuite/gas/elf/elf.exp create mode 100644 gas/testsuite/gas/elf/section0.d create mode 100644 gas/testsuite/gas/elf/section0.s create mode 100644 gas/testsuite/gas/elf/section1.d create mode 100644 gas/testsuite/gas/elf/section1.s create mode 100644 gas/testsuite/gas/hppa/basic/add2.s create mode 100644 gas/testsuite/gas/hppa/basic/branch2.s create mode 100644 gas/testsuite/gas/hppa/basic/dcor2.s create mode 100644 gas/testsuite/gas/hppa/basic/deposit2.s create mode 100644 gas/testsuite/gas/hppa/basic/deposit3.s create mode 100644 gas/testsuite/gas/hppa/basic/extract2.s create mode 100644 gas/testsuite/gas/hppa/basic/extract3.s create mode 100644 gas/testsuite/gas/hppa/basic/fp_comp2.s create mode 100644 gas/testsuite/gas/hppa/basic/media.s create mode 100644 gas/testsuite/gas/hppa/basic/perf.s create mode 100644 gas/testsuite/gas/hppa/basic/purge2.s create mode 100644 gas/testsuite/gas/hppa/basic/shift2.s create mode 100644 gas/testsuite/gas/hppa/basic/shift3.s create mode 100644 gas/testsuite/gas/hppa/basic/shladd.s create mode 100644 gas/testsuite/gas/hppa/basic/shladd2.s create mode 100644 gas/testsuite/gas/hppa/basic/sub2.s create mode 100644 gas/testsuite/gas/hppa/basic/system2.s create mode 100644 gas/testsuite/gas/hppa/basic/unit2.s create mode 100644 gas/testsuite/gas/i386/intel.d create mode 100644 gas/testsuite/gas/i386/intel.s create mode 100644 gas/testsuite/gas/i386/jump.d create mode 100644 gas/testsuite/gas/i386/jump.s create mode 100644 gas/testsuite/gas/i386/jump16.d create mode 100644 gas/testsuite/gas/i386/jump16.s create mode 100644 gas/testsuite/gas/i386/katmai.d create mode 100644 gas/testsuite/gas/i386/katmai.s create mode 100644 gas/testsuite/gas/i386/naked.d create mode 100644 gas/testsuite/gas/i386/naked.s create mode 100644 gas/testsuite/gas/m32r/error.exp create mode 100644 gas/testsuite/gas/m32r/fslotx.d create mode 100644 gas/testsuite/gas/m32r/fslotx.s create mode 100644 gas/testsuite/gas/m32r/interfere.s create mode 100644 gas/testsuite/gas/m32r/m32rx.d create mode 100644 gas/testsuite/gas/m32r/m32rx.exp create mode 100644 gas/testsuite/gas/m32r/m32rx.s create mode 100644 gas/testsuite/gas/m32r/relax-2.d create mode 100644 gas/testsuite/gas/m32r/relax-2.s create mode 100644 gas/testsuite/gas/m32r/wrongsize.s create mode 100644 gas/testsuite/gas/mips/e32-rel2.d create mode 100644 gas/testsuite/gas/mips/elf-rel.d create mode 100644 gas/testsuite/gas/mips/elf-rel.s create mode 100644 gas/testsuite/gas/mips/elf-rel2.d create mode 100644 gas/testsuite/gas/mips/elf-rel2.s create mode 100644 gas/testsuite/gas/mips/empic.d create mode 100644 gas/testsuite/gas/mips/empic.s create mode 100644 gas/testsuite/gas/mips/mips16-e.d create mode 100644 gas/testsuite/gas/mips/mips16-e.s create mode 100644 gas/testsuite/gas/mips/mips16-f.d create mode 100644 gas/testsuite/gas/mips/mips16-f.s create mode 100644 gas/testsuite/gas/mn10300/am33.s create mode 100644 gas/testsuite/gas/mn10300/am33_2.s create mode 100644 gas/testsuite/gas/mn10300/am33_3.s create mode 100644 gas/testsuite/gas/mn10300/am33_4.s create mode 100644 gas/testsuite/gas/mn10300/am33_5.s create mode 100644 gas/testsuite/gas/mn10300/am33_6.s create mode 100644 gas/testsuite/gas/mn10300/am33_7.s create mode 100644 gas/testsuite/gas/mn10300/am33_8.s create mode 100644 gas/testsuite/gas/pj/ops.d create mode 100644 gas/testsuite/gas/pj/ops.s create mode 100644 gas/testsuite/gas/pj/pj.exp delete mode 100644 gprof/configure.bat create mode 100644 include/coff/mipspe.h create mode 100644 include/elf/avr.h create mode 100644 include/elf/i370.h create mode 100644 include/elf/i960.h create mode 100644 include/elf/pj.h create mode 100644 include/opcode/i370.h create mode 100644 include/opcode/pj.h create mode 100644 include/partition.h create mode 100644 include/sim-d10v.h delete mode 100644 include/wait.h delete mode 100644 intl/ChangeLog.Cygnus delete mode 100644 ld/configure.bat create mode 100644 ld/emulparams/armnbsd.sh create mode 100644 ld/emulparams/avr1200.sh create mode 100644 ld/emulparams/avr23xx.sh create mode 100644 ld/emulparams/avr4433.sh create mode 100644 ld/emulparams/avr44x4.sh create mode 100644 ld/emulparams/avr85xx.sh create mode 100644 ld/emulparams/avrmega103.sh create mode 100644 ld/emulparams/avrmega161.sh create mode 100644 ld/emulparams/avrmega603.sh create mode 100644 ld/emulparams/elf32_i960.sh create mode 100755 ld/emulparams/elf32bmipn32.sh create mode 100644 ld/emulparams/elf32i370.sh create mode 100644 ld/emulparams/elf32ppclinux.sh create mode 100755 ld/emulparams/elf64bmip.sh create mode 100755 ld/emulparams/elf64hppa.sh delete mode 100644 ld/emulparams/go32.sh create mode 100644 ld/emulparams/i386pe_posix.sh create mode 100644 ld/emulparams/mipspe.sh create mode 100644 ld/emulparams/pjelf.sh create mode 100644 ld/emulparams/pjlelf.sh create mode 100644 ld/emulparams/shpe.sh create mode 100644 ld/emultempl/astring.sed rename ld/emultempl/{stringify.sed => ostring.sed} (100%) create mode 100644 ld/pe-dll.h create mode 100644 ld/scripttempl/elf32avr.sc create mode 100644 ld/scripttempl/elfi370.sc create mode 100644 ld/scripttempl/epocpe.sc delete mode 100644 ld/scripttempl/go32coff.sc create mode 100644 ld/scripttempl/pj.sc create mode 100644 ld/testsuite/ld-elfvers/vers17.c create mode 100644 ld/testsuite/ld-elfvers/vers17.dsym create mode 100644 ld/testsuite/ld-elfvers/vers17.map create mode 100644 ld/testsuite/ld-elfvers/vers17.ver create mode 100644 ld/testsuite/ld-elfvers/vers18.c create mode 100644 ld/testsuite/ld-elfvers/vers18.dsym create mode 100644 ld/testsuite/ld-elfvers/vers18.map create mode 100644 ld/testsuite/ld-elfvers/vers18.sym create mode 100644 ld/testsuite/ld-elfvers/vers18.ver create mode 100644 ld/testsuite/ld-elfvers/vers19.c create mode 100644 ld/testsuite/ld-elfvers/vers19.dsym create mode 100644 ld/testsuite/ld-elfvers/vers19.ver delete mode 100644 ld/testsuite/ld-selective/5.cc delete mode 100644 libiberty/configure.bat delete mode 100644 libiberty/makefile.dos create mode 100644 libiberty/partition.c delete mode 100644 makeall.bat create mode 100755 mkdep create mode 100644 opcodes/avr-dis.c delete mode 100644 opcodes/configure.bat create mode 100644 opcodes/i370-dis.c create mode 100644 opcodes/i370-opc.c create mode 100644 opcodes/pj-dis.c create mode 100644 opcodes/pj-opc.c create mode 100644 texinfo/texinfo.tex diff --git a/ChangeLog b/ChangeLog index 2604b21..78a8122 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,147 @@ +2000-03-29 Jason Merrill + + * configure.in: -linux-gnu*, not -linux-gnu. + +2000-03-10 H.J. Lu + + * Makefile.in (all-gcc): Backed out the last change. + +2000-03-10 H.J. Lu + + * Makefile.in (all-gcc): Run ld/ld-new if necessary. + +Fri Mar 3 18:44:08 2000 Andrew Cagney + + * Makefile.in (taz): Set PACKAGE to TOOL when not defined. + (do-tar-bz2): Replace TOOL with PACKAGE. + (gdb.tar.bz2): Remove GDBTK from GDB package. + (gdb+dejagnu.tar.bz2, insight.tar.bz2, insight+dejagnu.tar.bz2, + dejagnu.tar.bz2): New packages. + +2000-02-27 Andreas Jaeger + + * configure.in: Add entry for mips*-*-linux*, move catch all + *-*-*linux* entry below this one. + +2000-02-27 Ian Lance Taylor + + * ltconfig, ltmain.sh: Update to libtool 1.3.4. + +2000-02-24 Nick Clifton + + * config.sub: Support an OS of "wince". + +Thu Feb 24 16:15:56 2000 Andrew Cagney + + * config.guess, config.sub: Updated to match config's 2000-02-15 + version. + +2000-02-23 Linas Vepstas + + * config.sub: Add support for Linux/IBM 370. + * configure.in: Likewise. + +2000-02-22 Nick Clifton + + * configure.in: Add mips-pe, sh-pe and arm-wince-pe targets. + +2000-02-20 Christopher Faylor + + * config.guess: Guess "cygwin" rather than "cygwin32". + +2000-02-16 Kaveh R. Ghazi + + * configure (gcc_version): When setting, narrow search to + lines containing `version_string'. + +2000-01-06 Geoff Keating + + * configure.in: Use mt-aix43 to handle *_TARGET defs, + not mh-aix43. + +1999-09-04 Steve Chamberlain + + * config.sub: Add support for configuring for pj. + +1999-08-31 Nick Clifton + + * config.sub (maybe_os): Add support for configuring for fr30. + +1999-08-27 Nick Clifton + + * configure.in: Do not configure or build ld for AIX + platforms. ld is known to be broken on these platforms. + +1999-08-09 Ian Lance Taylor + + * Makefile.in (LDFLAGS): Define. + +1999-08-08 Mumit Khan + + * configure.in (i[3456]-*-mingw32*): Don't put gprof in + noconfigdirs. + (*-*-cygwin*): Likewise. + +1999-08-08 Ian Lance Taylor + + * mkdep: New file. + * Makefile.in (GAS_SUPPORT_DIRS): Add mkdep. + (BINUTILS_SUPPORT_DIRS): Add mkdep. + + From Eli Zaretskii : + * configure (tmpfile): Change cONf$$ to cNf$$ to avoid an overly + long file name when using DJGPP on MS-DOS. + +1999-07-30 Alan Modra + + * Makefile.in (check-target-libio): Remove all-target-libstdc++ + dependency as this causes "make check" to globally "make all" + +1999-07-22 Ian Lance Taylor + + * Makefile.in (binutils.tar.bz2): Don't pass makeall.bat and + configure.bat in SUPPORT_FILES. + (gas+binutils.tar.bz2): Likewise. + + * makeall.bat: Remove; obsolete. + +1999-07-21 Ian Lance Taylor + + From Mark Elbrecht: + * configure.bat: Remove; obsolete. + +1999-07-11 Ian Lance Taylor + + * configure: Add -W -Wall to the default CFLAGS when compiling with + gcc. + +Thu Jul 8 12:32:23 1999 John David Anglin + + * configure.in: Build ld, binutils & gas for hppa*-*-linux-gnu*. + +1999-06-30 Mark Mitchell + + * configure.in: Build ld on IRIX6. + +1999-06-12 Ian Lance Taylor + + * Makefile.in: Change distribution targets to use bzip2 instead of + gzip. + (TEXINFO_SUPPORT): Set to just texinfo/texinfo.tex. + (taz): Don't use texinfo/gpl.texinfo or texinfo/lgpl.texinfo. + +1999-06-04 Nick Clifton + + * config.sub: Add mcore target. + +Sun May 30 16:03:16 1999 Cort Dougan + + * config.guess (ppc-*-linux-gnu): Also use ld emul elf32ppclinux. + +1999-05-24 Nick Clifton + + * config.sub: Updated to match latest EGCS version. + 1999-04-30 Tom Tromey * ltmain.sh: [mode link] Always use CC given by ltconfig. @@ -131,7 +275,7 @@ Wed Feb 17 01:38:59 1999 H.J. Lu (hjl@gnu.org) Patch from: Scott Bambrough - * config.guess: Modified to recognize uname's armv* syntax. + * config.guess: Modified to recognize uname's armv* syntax. * config.sub: Modified to recognize uname's armv* syntax. @@ -653,6 +797,11 @@ Tue May 5 18:02:24 1998 Ian Lance Taylor * Makefile.in (EXTRA_GCC_FLAGS): Remove backslash at end; Solaris `make' causes it to continue to next definition. +Tue Apr 28 16:24:24 1998 Jason Molenda (crash@bugshack.cygnus.com) + + * Makefile.in (install-gdbtk): Call this 'install-gdb' so that + the right GUI libraries and files are installed along with GDB. + Tue Apr 28 18:11:24 1998 Ian Lance Taylor * configure.in: Change alpha to alpha* in several places. @@ -754,6 +903,10 @@ Thu Mar 26 12:53:20 1998 Tom Tromey (noconfigdirs) [various cases]: Likewise. (host_libs): Added intl. +Thu Mar 26 15:00:11 1998 Keith Seitz + + * configure: Do not disable building gdbtk for cygwin32 hosts. + Wed Mar 25 11:49:12 1998 Jason Molenda (crash@bugshack.cygnus.com) * Makefile.in: Revert yesterday's change. @@ -1202,6 +1355,11 @@ Thu Sep 18 21:43:23 1997 Alexandre Oliva (all-bootstrap): Remove outdated and confusing target. (bootstrap, bootstrap2, bootstrap3): Don't pass BOOT_CFLAGS down. +Thu Sep 18 15:37:42 1997 Andrew Cagney + + * configure (tooldir): enable_gdbtk=YES for cygwin32, NO for + windows. Consistent with gdb/configure. + 1997-09-15 02:37 Ulrich Drepper @@ -2295,6 +2453,7 @@ Mon Jun 17 16:34:46 1996 Jason Merrill Sat Jun 15 17:13:25 1996 Geoffrey Noer + * configure: enable_gdbtk=no for cygwin32-hosted toolchains * configure.in: remove make from disable-if-Can-Cross list enable gdb if ${host} and ${target} are cygwin32 @@ -2687,6 +2846,12 @@ Fri Jan 12 15:25:35 1996 Ian Lance Taylor * configure.in: Make sure that ${CC} can be used to compile an executable. +Sat Jan 6 07:23:33 1996 Michael Meissner + + * Makefile.in (all-gdb): Depend on $(GDB_TK). + * configure (GDB_TK): Set GDB_TK to either "all-tcl all-tk" or + nothing depending on whether gdbtk is being built. + Wed Jan 3 17:54:41 1996 Doug Evans * Makefile.in (newlib.tar.gz): Delete building of newlib's info files. @@ -3284,6 +3449,11 @@ Mon Aug 7 09:21:35 1995 Doug Evans * configure.in (i386-go32 host): Fix typo (deja-gnu -> dejagnu). (i386-win32 host): Likewise. Don't build readline. +Sat Aug 5 09:51:49 1995 Fred Fish + + * Makefile.in (GDBTK_SUPPORT_DIRS): Define and pass as part of + SUPPORT_FILES to submakes. + Fri Aug 4 13:04:36 1995 Fred Fish * Makefile.in (GDB_SUPPORT_DIRS): Add utils. @@ -3462,6 +3632,11 @@ Tue Apr 11 18:55:40 1995 Doug Evans * configure.in: Recognize --with-newlib. (sparc-*-sunos4*): Build sim, dejagnu, expect, tcl if cross target. +Mon Apr 10 14:38:20 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in: move {all,check,install}-gdb from *_MODULES + to *_X11_MODULES due to gdbtk needing X include files et al. + Mon Apr 10 11:42:22 1995 Stan Shebs Merge in support for Mac MPW as a host. diff --git a/Makefile.in b/Makefile.in index 7f1bb8c..beab8be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,6 +84,7 @@ HOST_PREFIX_1 = loser- CFLAGS = -g CXXFLAGS = -g -O2 +LDFLAGS = LIBCFLAGS = $(CFLAGS) CFLAGS_FOR_TARGET = $(CFLAGS) LDFLAGS_FOR_TARGET = @@ -109,8 +110,7 @@ NM = nm LD = ld -# Not plain GZIP, since gzip looks there for extra command-line options. -GZIPPROG = gzip +BZIPPROG = bzip2 # These values are substituted by configure. DEFAULT_YACC = yacc @@ -1584,7 +1584,7 @@ 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++ +check-target-libio: all-libgui: all-tcl all-tk all-tcl8.1 all-tk8.1 all-itcl all-libiberty: configure-target-librx: $(ALL_GCC) configure-target-newlib @@ -1632,6 +1632,7 @@ 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) +install-gdb: install-tcl install-tk install-itcl install-tix install-libgui ### other supporting targets MAKEDIRS= \ @@ -1691,8 +1692,7 @@ 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 +taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex # Take out texinfo from a few places. sed -e '/^all\.normal: /s/\all-texinfo //' \ -e '/^ install-texinfo /d' \ @@ -1737,8 +1737,6 @@ taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \ # 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 ; \ @@ -1749,55 +1747,84 @@ taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \ else \ ver=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \ fi; \ - $(MAKE) -f Makefile.in do-tar-gz TOOL=$(TOOL) VER=$$ver + if test x"$(PACKAGE)" = x; then \ + package="$(TOOL)"; \ + else \ + package="$(PACKAGE)"; \ + fi; \ + $(MAKE) -f Makefile.in do-tar-bz2 TOOL=$(TOOL) VER=$$ver PACKAGE=$$package -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 +do-tar-bz2: + echo "==> Making $(PACKAGE)-$(VER).tar.bz2" + -rm -f $(PACKAGE)-$(VER) + ln -s proto-toplev $(PACKAGE)-$(VER) + tar cfh $(PACKAGE)-$(VER).tar $(PACKAGE)-$(VER) + $(BZIPPROG) -v -9 $(PACKAGE)-$(VER).tar -TEXINFO_SUPPORT= texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo +TEXINFO_SUPPORT= texinfo/texinfo.tex 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 +.PHONY: gas.tar.bz2 +GAS_SUPPORT_DIRS= bfd include libiberty opcodes intl setup.com makefile.vms mkdep +gas.tar.bz2: $(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 +.PHONY: binutils.tar.bz2 +BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof intl setup.com makefile.vms mkdep +binutils.tar.bz2: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils $(MAKE) -f Makefile.in taz TOOL=binutils \ - SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS) makeall.bat configure.bat" + SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS)" -.PHONY: gas+binutils.tar.gz +.PHONY: gas+binutils.tar.bz2 GASB_SUPPORT_DIRS= $(GAS_SUPPORT_DIRS) binutils ld gprof -gas+binutils.tar.gz: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas +gas+binutils.tar.bz2: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas $(MAKE) -f Makefile.in taz TOOL=gas \ - SUPPORT_FILES="$(GASB_SUPPORT_DIRS) makeall.bat configure.bat" + SUPPORT_FILES="$(GASB_SUPPORT_DIRS)" -.PHONY: libg++.tar.gz +.PHONY: libg++.tar.bz2 LIBGXX_SUPPORT_DIRS=include libstdc++ libio librx libiberty -libg++.tar.gz: $(DIST_SUPPORT) libg++ +libg++.tar.bz2: $(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 +gnats.tar.bz2: $(DIST_SUPPORT) $(GNATS_SUPPORT_DIRS) gnats $(MAKE) -f Makefile.in taz TOOL=gnats \ SUPPORT_FILES="$(GNATS_SUPPORT_DIRS)" -.PHONY: gdb.tar.gz +.PHONY: gdb.tar.bz2 GDB_SUPPORT_DIRS= bfd include libiberty mmalloc opcodes readline sim utils intl -gdb.tar.gz: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb +gdb.tar.bz2: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb $(MAKE) -f Makefile.in taz TOOL=gdb \ SUPPORT_FILES="$(GDB_SUPPORT_DIRS)" -.PHONY: newlib.tar.gz +.PHONY: dejagnu.tar.bz2 +DEJAGNU_SUPPORT_DIRS= tcl expect libiberty +dejagnu.tar.bz2: $(DIST_SUPPORT) $(DEJAGNU_SUPPORT_DIRS) dejagnu + $(MAKE) -f Makefile.in taz TOOL=dejagnu \ + SUPPORT_FILES="$(DEJAGNU_SUPPORT_DIRS)" + +.PHONY: gdb+dejagnu.tar.bz2 +GDBD_SUPPORT_DIRS= $(GDB_SUPPORT_DIRS) tcl expect dejagnu +gdb+dejagnu.tar.bz2: $(DIST_SUPPORT) $(GDBD_SUPPORT_DIRS) gdb + $(MAKE) -f Makefile.in taz TOOL=gdb PACKAGE=gdb+dejagnu \ + SUPPORT_FILES="$(GDBD_SUPPORT_DIRS)" + +.PHONY: insight.tar.bz2 +INSIGHT_SUPPORT_DIRS= $(GDB_SUPPORT_DIRS) tcl tk itcl tix libgui +insight.tar.bz2: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb + $(MAKE) -f Makefile.in taz TOOL=gdb PACKAGE=insight \ + SUPPORT_FILES="$(INSIGHT_SUPPORT_DIRS)" + +.PHONY: insight+dejagnu.tar.bz2 +INSIGHTD_SUPPORT_DIRS= $(INSIGHT_SUPPORT_DIRS) expect dejagnu +insight+dejagnu.tar.bz2: $(DIST_SUPPORT) $(INSIGHTD_SUPPORT_DIRS) gdb + $(MAKE) -f Makefile.in taz TOOL=gdb PACKAGE="insight+dejagnu" \ + SUPPORT_FILES="$(INSIGHTD_SUPPORT_DIRS)" + +.PHONY: newlib.tar.bz2 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. @@ -1810,7 +1837,7 @@ NEWLIB_SUPPORT_DIRS=libgloss # 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 +newlib.tar.bz2: $(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 diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 66a5b24..82f7eb5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,3239 @@ +2000-03-31 Thomas de Lellis + + * srec.c : Set CHUNK size to 16 bytes to prevent download failures + on some targets. + * ihex.c : Ditto. + +Wed Mar 30 15:28:00 2000 Donald Lindsay + + * elf32-m32r.c (m32r_elf_generic_reloc): new function. All + HOWTO references to bfd_elf_generic_reloc, that have + partial_inplace == true, now use the new function. The function + is based on the recent rewrite of m32r_elf_lo16_reloc(), and + extends its fixes to the R_M32R_{16,24,32} relocs. + The new logic in m32r_elf_lo16_reloc() has been removed, and + it instead calls the new routine to obtain that functionality. + +2000-03-27 Alan Modra + + * elf32-avr.c (elf32_avr_gc_mark_hook, elf32_avr_gc_sweep_hook, + elf32_avr_check_relocs, avr_final_link_relocate, + elf32_avr_relocate_section, bfd_elf_avr_final_write_processing, + elf32_avr_object_p): Add prototypes. + (elf32_avr_gc_mark_hook): Add default for h->root.type. + (bfd_elf_avr_final_write_processing): Make static. + +2000-03-27 Denis Chertykov + + * cpu-avr.c: New file. BFD support routines for AVR architecture. + * archures.c (bfd_architecture): Add AVR architecture. + (bfd_archures_list): Add reference to AVR architecture info. + * elf.c (prep_headers): Handle bfd_arch_avr. + * reloc.c: Add various AVR relocation enums. + * targets.c (bfd_elf32_avr_vec): Declare and add to target vector + list. + * Makefile.am: Add support for AVR elf. + * configure.in: Likewise. + * config.bfd: Likewise. + * Makefile.in: Regenerate. + * configure: This too. + * bfd-in2.h: And this. + * libbfd.h: And this. + +2000-03-24 H.J. Lu + + * elf64-alpha.c (elf64_alpha_merge_ind_symbols): Add prototype. + (elf64_alpha_find_reloc_at_ofs): Likewise. + +2000-03-17 Alan Modra + + * reloc.c (bfd_check_overflow): In case complain_overflow_bitfield, + flag an overflow if the bitfield is outside -2**n to 2**n-1. The + allowable range used to be -2**(n-1) to 2**n-1. + * reloc.c (_bfd_relocate_contents): Same here. Also replace + "boolean overflow" with "bfd_reloc_status_type flag". + +2000-03-14 Doug Evans + + * elf32-m32r.c (m32r_elf_lo16_reloc): Rewrite. + +2000-03-14 Kazu Hirata + + * reloc16.c (bfd_coff_reloc16_relax_section): Count the total number + of shrinks properly, including the last reloc. + +2000-03-13 Kazu Hirata + + * coff-h8300.c (h8300_reloc16_extra_cases): Fix the sanity + check for R_MOVL2. + +2000-03-11 Alan Modra + + * ieee.c (ieee_archive_p): Return bfd_error_wrong_format on + a format mismatch rather than an "error" from bfd_read such as + bfd_error_file_truncated. + +2000-03-10 Geoff Keating + + * elf32-mips.c (_bfd_mips_elf_relocate_section): Do proper + sign-extension and big-endian compensation for + R_MIPS_64 even in ld -r. + +2000-03-10 Geoffrey Keating + + * elf32-mips.c (mips_elf_next_relocation): Rename from + mips_elf_next_lo16_relocation, and generalize to look + for any relocation type. + (elf_mips_howto_table): Make R_MIPS_PC16 pcrel_offset. + (elf_mips_gnu_rel_hi16): Howto for R_MIPS_GNU_REL_HI16. + (elf_mips_gnu_rel_lo16): Howto for R_MIPS_GNU_REL_LO16. + (elf_mips_gnu_rel16_s2): Howto for R_MIPS_GNU_REL16_S2. + (elf_mips_gnu_pcrel64): Howto for R_MIPS_PC64. + (elf_mips_gnu_pcrel32): Howto for R_MIPS_PC32. + (bfd_elf32_bfd_reloc_type_lookup): Add new relocs. + (mips_rtype_to_howto): Likewise. + (mips_elf_calculate_relocation): Handle new relocs. + (_bfd_mips_elf_relocate_section): REL_HI16/REL_LO16 relocs + are paired. The addend for R_MIPS_GNU_REL16_S2 + is shifted right two bits. + +2000-03-10 Alan Modra + + * reloc.c (bfd_perform_relocation): Undo emacs formatting of + comment, and ensure it doesn't happen again. + (bfd_install_relocation): Same here. + (_bfd_relocate_contents): Don't bother assigning unused signmask + shift result. Fix typos in comments. + Remove trailing whitespace throughout file. + +2000-03-07 Doug Evans + + * reloc.c (reloc_howto_struct): Fix partial_inplace comment. + * bfd-in2.h: Rebuild. + +2000-03-06 Nick Clifton + + * peicode.h (struct pe_ILF_vars): Add sym_ptr_table and + sym_ptr_ptr fields. + (SIZEOF_ILF_SYM_PTR_TABLE): Define. + (SIZEOF_ILF_STRINGS): Redefine. + (pe_ILF_make_a_symbol-reloc): New function. Creates a symbol + relative reloc, as opposed to a section relative reloc. + (pe_ILF_make_a_symbol): Set the class of local symbols to C_STAT + not C_LABEL. + Add length of symbol's prefix to string pointer. + Store a pointer to the symbol in the symbol pointer table. + (pe_ILF_build_a_bfd): Do not build .idata$2 or .idata$7. + Initialise the symbol pointer table. + Store the hint in the Hint/Name table. + Make the jump reloc be symbol realtive, not section relative. + Create an import symbol for imported code. + +2000-03-06 Catherine Moore + + * elf.c (swap_out_syms): Check for null type_ptr. + +2000-03-01 Hans-Peter Nilsson + + * aout-target.h (MY(write_object_contents)): Remove unused + and unusable "#if CHOOSE_RELOC_SIZE". + * pc532-mach.c (MY(write_object_contents)): Ditto. + * netbsd.h (MY(write_object_contents)): Ditto. + * hp300hpux.c (MY(write_object_contents)): Ditto. + * freebsd.h (MY(write_object_contents)): Ditto. + * aout-tic30.c (tic30_aout_write_object_contents): Ditto. + +2000-02-29 H.J. Lu + + * peicode.h (jtab): Make it static. + + * coff-sh.c (sh_align_load_span): Declared if COFF_WITH_PE is + defined and COFF_IMAGE_WITH_PE is not defined. + (_bfd_sh_align_load_span): Defined as sh_align_load_span if + COFF_WITH_PE is defined and COFF_IMAGE_WITH_PE is not defined. + +2000-03-01 Nick Clifton + + * coff-arm.c (bfd_arm_process_before_allocation): Make + 'symndx' signed to prevent compile time warning. + + * coff-mcore.c: Remove unused prototype for pe_object_p. + + * coff-sh.c: Add "#ifndef COFF_IMAGE_WITH_PE" around static + functions that are not used when COFF_IMAGE_WITH_PE is + defined. + (struct sh_opcode): Change type of 'flags' field to unsigned + long so that it can hold the USESAS flag. + + * coffcode.h (styp_to_sec_flags): Initialise 'target_name'. + + * elf-m10300.c (mn10300_elf_relax_section): Initialise + 'sym_sec'. + + * elf32-i370.c: Add ATTRIBUTE_UNUSED to unused function + parameters. + Remove unusued variables and code. + (elf_backend_add_symbol_hook): Fix prototype. + + * elf32-m68k.c (elf_m68k_gc_sweep_hook): Initialise 'sgot' and + 'srelgot'. + + * elf32-mcore.c (mcore_elf_relocate_section): Initialise + 'oldinst'. + + * elf32-mips.c: Add ATTRIBUTE_UNUSED to unused function + parameters. + Remove unusued variables and code. + (elf_backend_add_symbol_hook): Fix prototype. + + * elf32-sh.c (sh_elf_set_mach_from_flags): Use 'flags'. + + * elflink.h (elf_bfd_link_add_symbols): Add ATTRIBUTE_UNUSED + to unused function parameter. + + * pe-mips.c: Add ATTRIBUTE_UNUSED to unused function + parameters. + Use EMPTY_HOWTO to initialise empty howto slots. + Remove unused variables. + + * peicode.h (pe_ILF_build_a_bfd): Initialise id6. + +2000-03-01 H.J. Lu + + * aoutx.h (aout_link_input_section_std): Pass "true" to + the undefined_symbol callback. + (aout_link_input_section_ext): Likewise. + * bout.c (get_value): Likewise. + * coff-a29k.c (coff_a29k_relocate_section): Likewise. + * coff-alpha.c (alpha_ecoff_get_relocated_section_conten): + Likewise. + (alpha_relocate_section): Likewise. + * coff-arm.c (coff_arm_relocate_section): Likewise. + * coff-i960.c (coff_i960_relocate_section): Likewise. + * coff-mcore.c (coff_mcore_relocate_section): Likewise. + * coff-mips.c (mips_relocate_section): Likewise. + * coff-ppc.c (coff_ppc_relocate_section): Likewise. + * coff-sh.c (sh_relocate_section): Likewise. + * coff-tic80.c (coff_tic80_relocate_section): Likewise. + * cofflink.c (_bfd_coff_generic_relocate_section): Likewise. + * elf-m10200.c (mn10200_elf_relocate_section): Likewise. + * elf-m10300.c (mn10300_elf_relocate_section): Likewise. + * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. + * elf32-fr30.c (fr30_elf_relocate_section): Likewise. + * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. + * elf32-i370.c (i370_elf_relocate_section): Likewise. + * elf32-m32r.c (m32r_elf_relocate_section): Likewise. + * elf32-mcore.c (mcore_elf_relocate_section): Likewise. + * elf32-sh.c (sh_elf_relocate_section): Likewise. + * elf32-v850.c (v850_elf_relocate_section): Likewise. + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Likewise. + * elflink.h (elf_link_output_extsym): Likewise. + * pe-mips.c (coff_pe_mips_relocate_section): Likewise. + * reloc.c (bfd_generic_get_relocated_section_conten): Likewise. + * reloc16.c (_bfd_ppc_xcoff_relocate_section): Likewise. + + * elf-hppa.h (elf_hppa_relocate_section): Pass "false" to the + undefined_symbol callback when building shared library with + -Bsymbolic and undefined symbols are allowed. Otherwise, pass + "true". + * elf32-arm.h (elf32_arm_relocate_section): Likewise. + * elf32-i386.c (elf_i386_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-mips.c (mips_elf_calculate_relocation): Likewise. + (elf32_mips_get_relocated_section_content): 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. + +2000-02-28 Nick Clifton + + * Makefile.am: Add rules to build pe[i]-{sh|mips}.lo objects. + * Makefile.in: Regenerate. + + * configure.in: Add support for mips and sh pe vectors. + * configure: regenerate. + + * config.bfd: Add support for arm-wince, mips-pe and sh-pe + targets. + + * targets.c: Add mips and sh pe vectors. + + * libpei.h (coff_final_link_postscript): Only define if not + already defined. + + * coffcode.h: Add support for WinCE magic numbers. + + * peigen.c (pe_print_reloc): Update comment and rearrange + appending of newline character. + + * peicode.h: Add support for Image Library Format. + (pe_ILF_vars): Structure containing data used by ILF code. + (pe_ILF_make_a_section): New function. Create a section based + on ILF data. + (pe_ILF_make_a_reloc): New function. Create a reloc based on + ILF data. + (pe_ILF_make_a_symbol): New function. Create a symbol based + on ILF data. + (pe_ILF_save_relocs): New function. Store the relocs created + by pe_ILF_make_a_reloc in a section. + (pe_ILF_build_a_bfd): New function. Create a BFD describing + an ILF object. + (pe_ILF_object_p): New function. Return a bfd_target pointer + for an ILF object. + (pe_bfd_object_p): If an ILF object is detected call + pe_ILF_object_p on it. + + * coff-arm.c: Add support for WinCE relocs which are different + from normal ARM COFF relocs. + * pe-arm.c: Unset TARGET_UNDERSCORE for a WinCE target. + + * coff-sh.c: Add support for sh-pe target. + * pe-sh.c: New file. Support code for sh-pe target. + * pei-sh.c: New file. Support code for sh-pe target. + + * pe-mips.c: New file. Support code for mips-pe target. + * pei-mips.c: New file. Support code for mips-pe target. + +2000-02-27 Jakub Jelinek + + * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Don't bump + architecture if the object causing the bump is dynamic. + * elf64-sparc.c (sparc64_elf_merge_private_bfd_data): Likewise, + and also don't it for memory ordering. + (sparc64_elf_write_relocs): Take src_rela out of the loop. + +2000-02-27 Ian Lance Taylor + + * dwarf2.c (read_abbrevs): Use _raw_size directly rather than + calling bfd_get_section_size_before_reloc. + (decode_line_info): Likewise. + (_bfd_dwarf2_find_nearest_line): Likewise. + +2000-02-27 Eli Zaretskii + + * Makefile.am (stamp-lib): Use $(LIBTOOL) --config to get the + name of the libtool directory. + * Makefile.in: Rebuild. + +Fri Feb 25 18:39:26 2000 Rodney Brown (RodneyBrown@pmsc.com) + + * som.c (SOM_HOWTO): Define. + (som_hppa_howto_table): Use it. + +2000-02-25 Alexandre Oliva + + * config.bfd: Enable 64 bit support for GNU/Linux/sparc. + + * config.bfd: Enable 64 bit support for Solaris7+/sparc. + +2000-02-24 Catherine Moore + + * som.c (som_misc_symbol_info): Add field + secondary_def. + (som_bfd_derive_misc_symbol_info): Initialize + secondary_def. + (som_build_and_write_symbol_table): Keep track + of secondary_def field. + (som_slurp_symbol_table): Set BSF_WEAK symbol flag + if secondary_def field is set. + (som_bfd_ar_write_symbol_stuff): Initialize + secondary_def. + +2000-02-23 Stephane Carrez + + * dwarf2.c (read_address): Read 16-bits addresses. + (parse_comp_unit): Accept addr_size == 2. + +2000-02-23 Alan Modra + + * bfd-in.h: Update copyright date. + +2000-02-23 Linas Vepstas + + * cpu-i370.c: New file. + * elf32-i370.c: New file. + * archures.c (enum bfd_architecture): Add bfd_arch_i370. + (bfd_i370_arch): New. + (bfd_archures_list): Add bfd_i370_arch. + * elf.c (prep_headers): Add bfd_arch_i370. + * Makefile.am: Add support for IBM 370 elf. + * config.bfd: Likewise. + * configure.in: Likewise. + * libbfd.h (bfd_reloc_code_real_names): Likewise. + * reloc.c (bfd_reloc_code_type): Likewise. + * targets.c: Likewise. + + * Makefile.in: Regenerate. + * configure: Regenerate. + * bfd-in2.h: Regenerate. + +2000-02-22 Ian Lance Taylor + + * elf32-i386.c (elf_i386_info_to_howto_rel): Give a warning for + invalid relocation types, and change them to R_386_NONE. + +2000-02-22 H.J. Lu + + * elflink.h (elf_link_add_object_symbols): If a version symbol is + not defined, don't add a second ELF_VER_CHR. + + * elflink.h (elf_bfd_final_link): Call output_extsym for global + symbols converted to local symbols even when stripping all + symbols. + (elf_link_output_extsym): Process global symbols converted to + local symbols even if they are being stripped. + +2000-02-21 Alan Modra + + * archures.c (bfd_octets_per_byte): Return unsigned int. + (bfd_arch_mach_octets_per_byte): Ditto. + * libbfd.c (bfd_read, bfd_seek): Quell signed vs. unsigned + comparison warning. + * section.c (bfd_get_section_size_before_reloc): Quell signed + vs. unsigned comparison warning. + (bfd_get_section_size_after_reloc): Same here. Fix parentheses too. + * trad-core.c (trad_unix_core_file_p): Correct 2000-01-27 + change. What was I thinking? + * bfd-in2.h: Regenerate. + + * elflink.h (elf_gc_sweep): Skip non-elf input bfds. + (elf_gc_sections): Same here. + (elf_gc_common_finalize_got_offsets): And here. + +2000-02-21 Ian Lance Taylor + + ELF HPPA doesn't work at present; remove it until it does. + * config.bfd: Comment out setting targ_defvec to + bfd_elf32_hppa_vec. + * Makefile.am: Rebuild dependencies. + (BFD32_BACKENDS): Remove elf32-hppa.lo. + (BFD32_BACKENDS_CFILES): Remove elf32-hppa.c. + (SOURCE_HFILES): Remove elf32-hppa.h and hppa_stubs.h. + * Makefile.in: Rebuild. + * targets.c (bfd_target_vector): Comment out bfd_elf32_hppa_vec. + +2000-02-18 Geoff Keating + + * coffcode.h (coff_set_arch_mach_hook): Use free(), because there + is no bfd_free(). Revert bfd_free part of previous change. + +2000-02-18 Geoff Keating + + * coffcode.h (coff_set_arch_mach_hook): Don't use variable-size + arrays. + (coff_compute_section_file_positions): Use bfd_free to pair + bfd_malloc. + (coff_write_object_contents): Likewise. + + * coff-rs6000.c (xcoff_howto_table_16): New variable. + (xcoff_rtype2howto): Handle 16-bit variants of 32-bit relocs. + +2000-02-18 Ulrich Drepper + + * coff-rs6000.c (XCOFFARMAGBIG): New macro. + (xcoff_ar_file_hdr_big): New structure. + (SIZEOF_AR_FILE_HDR_BIG): New macro. + (xcoff_ar_hdr_big): New structure. + (SIZEOF_AR_HDR_BIG): New macro. + (xcoff_big_format_p): New macro. + (xcoff_ardata_big): New macro. + (arch_xhdr_big): New macro. + (xcoff_slurp_armap): Handle large archives. + (xcoff_archive_p): Detect large archives. + (xcoff_read_ar_hdr): Handle large archives. + (xcoff_openr_next_archived_file): Handle large archives. + (xcoff_generic_stat_arch_elt): Handle large archives. + (xcoff_write_armap_old): Rename from xcoff_write_armap. + (xcoff_write_armap_big): New function. + (xcoff_write_armap): New function, dispatch to _old or _big. + (xcoff_write_archive_contents_old): Rename from + xcoff_write_archive_contents. + (xcoff_write_archive_contents_big): New function. + (xcoff_write_archive_contents): New function, dispatch to _old or + _big. + +2000-02-18 Richard Henderson + + * elf-bfd.h (struct elf_link_hash_table): Remove copy_indirect + and hide_symbol members. + (elf_link_hash_copy_indirect): Remove. + (elf_link_hash_hide_symbol): Remove. + (struct elf_backend_data): Add elf_backend_copy_indirect_symbol + and elf_backend_hide_symbol. + (_bfd_elf_link_hash_copy_indirect): Declare. + (_bfd_elf_link_hash_hide_symbol): Declare. + * elf.c (_bfd_elf_link_hash_copy_indirect): Remove table argument. + (_bfd_elf_link_hash_hide_symbol): Likewise. + (_bfd_elf_link_hash_table_init): Don't init killed members. + * elflink.h (elf_link_add_object_symbols): Use the bed function + pointers not elf_link_hash_{copy_indirect,hide_symbol}. + (elf_link_assign_sym_version): Likewise. + * elfxx-target.h (elf_backend_copy_indirect_symbol): Default. + (elf_backend_hide_symbol): Likewise. + (elfNN_bed): Update for new members. + +2000-02-17 Kevin Buettner + + * rs6000-core.c (CORE_DATA_SIZE_FIELD, CORE_COMM_FIELD, SAVE_FIELD, + STACK_END_ADDR): Define for new core file format. + (LOADER_OFFSET_FIELD, LOADER_REGION_SIZE, CORE_DUMP): New defines + for handling the vagaries of the various core file structures used + by AIX over the years. + (rs6000coff_core_p, rs6000coff_core_file_matches_executable, + Rs6kCorData): Use above defines to adapt code to use AIX 4.3's + core_dumpx structure. + +Thu Feb 17 00:04:48 2000 J"orn Rennecke + + * archures.c (bfd_mach_sh2, bfd_mach_sh_dsp): New macros. + (bfd_mach_sh3_dsp): Likewise. + (bfd_mach_sh4): Reinstate. + (bfd_default_scan): Recognize 7410, 7708, 7729 and 7750. + * bfd-in2.h: Regenerate. + * coff-sh.c (struct sh_opcode): flags is no longer short. + (USESAS, USESAS_REG, USESR8, SETSAS, SETSAS_REG): New macros. + (sh_opcode41, sh_opcode42): Integrate as sh_opcode41. + (sh_opcode01, sh_opcode02, sh_opcode40): Add sh-dsp opcodes. + (sh_opcode41, sh_opcode4, sh_opcode80): Likewise. + (sh_opcodes): No longer const. + (sh_dsp_opcodef0, sh_dsp_opcodef): New arrays. + (sh_insn_uses_reg): Check for USESAS and USESR8. + (sh_insn_sets_reg, sh_insns_conflict): Check for SETSAS. + (_bfd_sh_align_load_span): Return early for SH4. + Modify sh_opcodes lookup table for sh-dsp / sh3-dsp. + Take into account that field b of a parallel processing insn + could be mistaken for a separate insn. + * cpu-sh.c (arch_info_struct): New array elements for + sh2, sh-dsp and sh3-dsp. + Reinstate element for sh4. + (SH2_NEXT, SH_DSP_NEXT, SH3_DSP_NEXT): New macros. + (SH4_NEXT): Reinstate. + (SH3_NEXT, SH3E_NEXT): Adjust. + * elf-bfd.h (_sh_elf_set_mach_from_flags): Declare. + * elf32-sh.c (sh_elf_set_private_flags): New function. + (sh_elf_copy_private_data, sh_elf_set_mach_from_flags): Likewise. + (sh_elf_merge_private_data): New function. + (elf_backend_object_p, bfd_elf32_bfd_set_private_bfd_flags): Define. + (bfd_elf32_bfd_copy_private_bfd_data): Define. + (bfd_elf32_bfd_merge_private_bfd_data): Change to + sh_elf_merge_private_data. + +2000-02-13 Richard Henderson + + * elf-bfd.h (struct elf_link_hash_table): Add copy_indirect and + hide_symbol members. + (elf_link_hash_copy_indirect): New. + (elf_link_hash_hide_symbol): New. + * elflink.h (elf_link_add_object_symbols): Break out copy from + indirect new new symbol to elf.c. + (elf_link_assign_sym_version): Break out privatization of + non-exported symbol to elf.c. + * elf.c (_bfd_elf_link_hash_copy_indirect): New. + (_bfd_elf_link_hash_hide_symbol): New. + (_bfd_elf_link_hash_table_init): Init copy_indirect and hide_symbol. + +2000-02-13 Ian Lance Taylor + + * section.c (_bfd_strip_section_from_output): Add info parameter. + If it passed as non-NULL, use it to check whether any input BFD + has an input section which uses this output section. Change all + callers. + * bfd-in2.h: Rebuild. + + * bfd-in.h: Move declarations of bfd_get_elf_phdr_upper_bound and + bfd_get_elf_phdrs in from bfd-in2.h, correcting patch of + 1999-11-29. + * bfd-in2.h: Rebuild. + +2000-02-10 Timothy Wall + + * coffswap.h (coff_swap_sym_in): Add hook SWAP_SYM_IN_POST to + allow final modifications of swapped-in symbol. + (coff_swap_sym_out): Ditto with SWAP_SYM_OUT_POST. + * coffcode.h (coff_write_relocs): Use macro + SECTION_RELATIVE_ABSOLUTE_SYMBOL_P if defined to determine whether + symbol index should be set to -1. + +Thu Feb 10 20:07:50 GMT 2000 Toshiyasu Morita (toshi.morita@sega.com) + + * coff-sh.c (USES1_REG, USES2_REG, SETS1_REG, SETS2_REG, + USESF1_REG, USESF2_REG, SETSF1_REG, SETSF2_REG): New macros. + * (sh_insn_sets_reg, sh_insn_sets_freg): New prototypes. + * (sh_insn_sets_reg, sh_insn_uses_or_sets_reg, sh_insns_sets_freg, + sh_insns_uses_or_sets_freg): New functions. + * (sh_insn_uses_reg, sh_insn_uses_freg): Use new macros. + * (sh_insns_conflict): Use new functions and new macros to + detect conflicts when two instructions both set same integer registers, + both set same fp register, and both set special register. + +2000-02-09 Timothy Wall + + * coffgen.c (coff_real_object_p): Set arch/mach info prior to + swapping in sections, so that the swapping routines have access to + the arch/mach info. + +2000-02-08 Mark Elbrecht + + * coff-go32.c: Update comment. Update copyright. + +2000-01-27 Thomas de Lellis + + * syms.c (bfd_decode_symclass) + Two new class characters were added - 'V' and 'v'. The + meaning of 'W' is now restricted to just weak non-object + symbols. This allows differentiation between, for example, + weak functions vs weak objects. nm for example now dumps: + 'W' = weak global + 'w' = weak unresolved + 'V' = weak global object + 'v' = weak unresolved object + + (bfd_is_undefined_symclass): New function. Return true if the + given symbol class represents and undefined/unresolved symbol. + + (bfd_symbol_info): Use bfd_is_undefined_symclass to check for + unresolved symbols. + + * bfd-in2.h: Add prototype for bfd_is_undefined_symbol(). + + * elf32-arm.h (elf32_arm_get_symbol_type): If a symbol has the + STT_ARM_16BIT flag set, but it is not attached to a data object + return STT_ARM_16BIT so that it will be treated as code by the + disassembler. + +2000-01-27 Alan Modra + + * coff-i386.c (i3coff_object_p): Remove prototype. + Update copyright. + + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Add const + to name. Update copyright. + + * trad-core.c (trad_unix_core_file_p): Cast core_regsec + assignment to avoid warning. Update copyright. + +2000-01-24 Robert Lipe (robertl@sco.com) + + * coffcode.h (coff_write_object_contents): Get buff via bfd_malloc + instead of using GNU C extension. + +2000-01-21 Nick Clifton + + * libbfd.c (bfd_read): Do not attempt to get a negativly sized + amount from a bfd_in_memory structure. + (bfd_seek): Do not allow seeks past the end of a bfd_in_memory + structure. + +2000-01-14 Nick Clifton + + * linker.c (default_indirect_link_order): oops - fix incorrectly + applied patch from Tim Wall. + +2000-01-13 Timothy Wall (twall@tiac.net> + + * coffcode.h: Use bfd_coff_xxx instead of the macro XXX (where xxx + = scnhsz, filhsz, relsz, aoutsz, etc) + + * coffswap.h: Ditto. + +2000-01-13 Nick Clifton + + * elf32-arm.h (elf32_thumb_to_arm_stub): Fix offset in branch to + interwork thumb to arm stub. + +2000-01-13 Timothy Wall (twall@tiac.net> + + * archures.c (bfd_octets_per_byte): New function: Return + target byte size. + (bfd_arch_mach_octets_per_byte): New function: Return target + byte size. + + * section.c: Distinguish between octets and bytes for usage of + _cooked_size, _raw_size, and output_offset. Clarify + description of bfd_set_section_contents. + + * bfd-in2.h: Regenerate. + + * coffgen.c: Indicate that the offset parameter is in bytes, not + octets. + + * cofflink.c (bfd_coff_link_input_bfd): Use bfd_octets_per_byte + where appropriate to get the octet offset when calling + bfd_set_section_contents. + (bfd_coff_reloc_link_order): Ditto. + + * linker.c (bfd_generic_reloc_link_order): Ditto. + (_bfd_default_link_order): Ditto. + + * reloc.c (bfd_perform_relocation): Distinguish between octets + and bytes. Use octets when indexing into octet data; use bytes + when calculating target addresses. + (bfd_install_relocation): Ditto. + + * srec.c (srec_write_section): Ditto. + +2000-01-13 Nick Clifton + + * coff-mcore.c (COFF_DEFAULT_SECTION_ALIGNMENT_POWER): Change from + 3 to 2. This allows 4 byte sized sections, which is necessary for + dlltool to build funcitoning DLLs. + +2000-01-10 Philip Blundell + + * config.bfd (arm*-*-linux-gnu*): Match instead of arm*-*-linux-gnu. + (arm*-*-conix*): New target. + +2000-01-10 Egor Duda + + * config.bfd: Include elf32_i386 vector to target list for cygwin + and mingw. + + * config.in: Undefine HAVE_WIN32_PSTATUS_T. + * configure.in: Test for structure win32_pstatus_t in + + * configure: Regenerate. + + * elf.c (elfcore_grok_win32pstatus): New function: process + win32_pstatus_t notes in elf core file. + (elfcore_grok_note): Detect win32_pstatus notes. + +2000-01-03 Martin v. Loewis + + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Process symbol + visibility. + * elflink.h (elf_link_add_object_symbols): Combine visibilities. + * elf.c (bfd_elf_print_symbol): Interpret st_other as visibility. + +1999-12-29 Richard Henderson + + * elflink.h (bfd_elf,size_dynamic_sections): Don't export all + if no dynamic sections created. + +1999-12-27 Nick Clifton + + * peicode.h (pe_bfd_object_p): Only define for PE format + targets. + +1999-12-17 Nick Clifton + + * coff-i386.c (i3coff_object_p): Delete. + (i386coff_vec): Replace reference to i3coff_object_p with a + reference to coff_object_p. + + * coff-mcore.c (pe_object_p): Delete. + + * peicode.h (pe_bfd_object_p): New function: Detect the + presence of a PE format COFF object file. Also detect and + warn about the presence of LINK6 format Image Library Format + object files. + +1999-12-16 Nick Clifton + + * coff-arm.c (NUM_ELEM): New macro. + (NUM_RELOCS): New macro: The number of known ARM relocs. + (RTYPE2HOWTO): Return NULL if the reloc type is out of range. + (coff_arm_rtype_to_howto): Return NULL if the reloc type is out + of range. + (bfd_arm_process_before_allocation): Produce a warning message if + an out of range symbol index is encountered. + +1999-12-14 Nick Clifton + + * elflink.h (is_global_symbol_definition): New Function: Return + true iff the symbol is being given a global definition in this + bfd. + (elf_link_is_defined_archive_symbol): Do not bother processing + symbols for an archive element that has already been included + in the link. + Use is_global_symbol_definition(). + +1999-12-09 Andrew Cagney + + * config.bfd: Add support for sparc-*-netbsdelf* and + sparc-*-netbsdaout*. + +1999-12-13 Nick Clifton + + * elflink.h (elf_link_is_defined_archive_symbol): Check to see + if the symbol is in the common section. + +1999-12-10 Nick Clifton + + * elflink.h (elf_link_is_defined_archive_symbol): New + function: Decide if a symbol, in an archive map is there + because it is defined in the archive element, or because it is + just another common declaration of it. + (elf_link_add_archive_symbols): Use + elf_link_is_defined_archive_symbol to decide if an archive + element contain a reference to a common symbol should be + linked in or not. + +1999-12-10 Nick Clifton + + * elflink.h: Revert previous patch. + * targets.c: Revert previous patch. + * libbfd-in2.h: Revert previous patch. + * libbfd.h: Revert previous patch. + * elfxx-target.h: Revert previous patch. + * archive.c: Revert previous patch. + * aout-target.h: Revert previous patch. + * aout-tic30.h: Revert previous patch. + * bfd.c: Revert previous patch. + * coff-alpha.c: Revert previous patch. + * coff-rs6000.c: Revert previous patch. + * elf64-mips.c: Revert previous patch. + * ieee.c: Revert previous patch. + * libecoff.h: Revert previous patch. + * oasys.c: Revert previous patch. + * som.c: Revert previous patch. + * vms.c: Revert previous patch. + +1999-12-09 Nick Clifton + + * elflink.h (elf_link_add_archive_symbols): Add an archive + element even if contains a symbol which is currently only + considered to be a common. + + * targets.c (struct bfd_target): Add new field + _bfd_allow_commons_in_armap. + * bfd-in2.h:Regenerate. + + * libbfd-in2.h (_bfd_noarchive_allow_commons_in_armap): + Define. + (_bfd_archive_bsd_allow_commons_in_armap): Define. + * libbfd.h: Regenerate. + + * elfxx-target.h: If using COFF archive map, override + definition of allow_commons_in_armap and replace with + bfd_false. + + * archive.c (bfd_compute_and_write_armap): Do not place common + symbols into the archive map unless _bfd_allow_commons_in_armap + returns true. + + * aout-target.h (MY_allow_commons_in_armap): Define. + * aout-tic30.h (MY_allow_commons_in_armap): Define. + * bfd.c (bfd_allow_commons_in_armap): Define. + * coff-alpha.h (alpha_ecoff_allow_commons_in_armap): Define. + * coff-rs6000.h (xcoff_allow_commons_in_armap): Define. + * elf64-mips.c (bfd_elf64_allow_commons_in_armap): Define. + * ieee.c (ieee_ecoff_allow_commons_in_armap): Define. + * libecoff.h (_bfd_ecoff_allow_commons_in_armap): Define. + * oasys.c (oasys_allow_commons_in_armap): Define. + * som.c (som_allow_commons_in_armap): Define. + * vms.c (vms_allow_commons_in_armap): Define. + +1999-12-07 Jim Blandy + + Add support for SSE registers in ELF core files. + * elf.c (elfcore_make_note_pseudosection): New function. + (elfcore_grok_prfpreg): Use it. + (elfcore_grok_prxfpreg): New function. + (elfcore_grok_note): Recognize Linux NT_PRXFPREG notes. + +1999-12-03 Ian Lance Taylor + + * elf32-mips.c (mips_elf_calculate_relocation): Divide R_MIPS_PC16 + value by 4 before storing it back in the field. From + Koundinya. K . + +Tue Nov 30 22:41:14 1999 Jeffrey A Law (law@cygnus.com) + + * archures.c (bfd_mach_am33): Define. + * bfd-in2.h: Rebuilt. + * cpu-m10300.c (bfd_am33_arch): Add to the mn103 architecture list + * elf-m10300.c (mn10300_elf_relax_section): Handle am33 instructions. + (compute_function_info): Handle additional registers saved by + movm on the am33. + (elf_mn10300_mach): Handle E_MN10300_MACH_AM33. + (_bfd_mn10300_elf_final_write_processing): Handle bfd_mach_am33. + +1999-11-29 Jim Blandy + + * elf.c (bfd_get_elf_phdrs, bfd_get_elf_phdr_upper_bound): New + functions. + * bfd-in2.h (bfd_get_elf_phdrs, bfd_get_elf_phdr_upper_bound): New + declarations. + +1999-11-27 Michael Meissner + + * reloc.c (BFD_RELOC_ALPHA_USER_LITERAL): New relocation for + internal use within gas for alpha explicit relocations. + (BFD_RELOC_ALPHA_USER_LITUSE_BASE): Ditto. + (BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF): Ditto. + (BFD_RELOC_ALPHA_USER_LITUSE_JSR): Ditto. + (BFD_RELOC_ALPHA_USER_GPDISP): Ditto. + (BFD_RELOC_ALPHA_USER_GPRELHIGH): Ditto. + (BFD_RELOC_ALPHA_USER_GPRELLOW): Ditto. + + * elf64-alpha.c (elf64_alpha_reloc_map): Add mappings for + BFD_RELOC_ALPHA_USER_*. + + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + +1999-11-26 Fred Fish + + * elf.c (elfcore_read_notes): Add prototype for static function. + (_bfd_elf_make_section_from_phdr): Renamed from bfd_section_from_phdr. + (bfd_section_from_phdr): Replacement function that calls + _bfd_elf_make_section_from_phdr for generic segment types and + backend fucntion pointed to by elf_backend_section_from_phdr for + backend specific segment types. + (_bfd_elfcore_section_from_phdr): Remove call to elfcore_read_notes, + now called by _bfd_elf_make_section_from_phdr. Note that this func + is now just a stub between the caller and bfd_section_from_phdr. + + * elf-bfd.h (struct elf_backend_data): Add new function pointer + elf_backend_section_from_phdr. + (elf_backend_section_from_phdr): Add prototype. + + * elfxx-target.h (elf_backend_section_from_phdr): Define default. + (elfNN_bed): Add elf_backend_section_from_phdr. + +1999-11-25 Nick Clifton + + * coff-arm.c (bfd_arm_get_bfd_for_interworking): Add + SEC_CODE and SEC_READONLY flags to glue sections. + + * elf32-arm.h (bfd_elf32_arm_get_bfd_for_interworking): Add + SEC_CODE and SEC_READONLY flags to glue sections. + +1999-11-20 Nick Clifton + + * coff-mcore.c (coff_mcore_relocate_section): Fix typo in previous + delta. + +1999-11-19 Catherine Moore + + * elf32-m68k.c (elf_cpu32_plt0_entry): Fix encoding. + (elf_cpu32_plt_entry): Likewise. + +1999-11-18 Nick Clifton + + * coff-mcore.c (coff_mcore_rtype_to_howto): Special case handling + for RVA relocs. + (coff_mcore_relocate_section): Initialise addend to 0. + Special case processing of RVA reloc. + +1999-11-17 Richard Henderson + + * elf-bfd.h (struct elf_backend_data): Reorder collect and + type_change_ok; add sign_extend_vma. + * elf32-mips.c (elf_backend_sign_extend_vma): Define. + * elfcode.h (elf_swap_symbol_in): Mind be->sign_extend_vma. + (elf_swap_shdr_in, elf_swap_phdr_in): Likewise. + * elfxx-target.h (elf_backend_sign_extend_vma): Default. + (elfNN_bed): Follow struture changes. + +1999-11-09 Ian Lance Taylor + + * libbfd.c (bfd_read): Check result of read against desired result + using !=, not <. + (_bfd_generic_get_section_contents): Set bfd_error if the seek is + invalid compared to the section size. + + * ieee.c (ieee_slurp_debug): Get the length of the debug + information right if there is no data part. + +Tue Nov 2 01:44:41 1999 Jeffrey A Law (law@cygnus.com) + + * som.c (som_fixup_formats): Improve handling of R_AUX_UNWIND, + R_LINETAB, R_LINETAB_ESC, and R_COMMENT. + +1999-10-28 Ian Lance Taylor + + * elflink.h (elf_bfd_final_link): Make last_local signed. + +1999-10-27 Ian Lance Taylor + + * stabs.c (_bfd_link_section_stabs): Make sure .stabstr section + starts with a zero. + +Sat Oct 23 17:36:12 1999 Andrew Cagney + + * archures.c: Add definitions bfd_mach_d10v, bfd_mach_d10v_ts2 and + bfd_mach_d10v_ts3. + * cpu-d10v.c (d10v_ts3_info, d10v_ts2_info): Add. + * bfd-in2.h: Regenerate. + +1999-10-15 Andrew Haley + + * dwarf1.c (parse_die): Fail to parse a die if its length is zero. + +Sun Oct 17 17:19:00 1999 Jeffrey A Law (law@cygnus.com) + + * libhppa.h (bfd_hppa_insn2fmt): Change to return an int. + +1999-10-08 Ian Lance Taylor + + * elflink.h (elf_merge_symbol): When overriding a weak symbol with + a defined symbol in a shared library, clear the DEF_DYNAMIC flag + too. + +Fri Oct 8 13:03:45 1999 Geoffrey Keating + + * elf32-mips.c (mips_elf_calculate_relocation): R_MIPS_LITERAL + relocs also need the GP value. + (_bfd_mips_elf_relocate_section): Handle unpaired LO16 relocs + properly. Handle sign-extension for R_MIPS_64 correctly. Correct + the GP value for R_MIPS_LITERAL relocs too. Handle + R_MIPS_64 relocs properly on big-endian MIPS. + (mips_elf_sign_extend): Behave properly with 'long long'. + (mips_elf_highest): Correct typo. + +Mon Oct 4 17:49:45 1999 Nick Clifton + + * cpu-m32r.c (arch_info_struct): New static global. + (bfd_m32r_arch): Refer to it. + * elf32-m32r.c (m32r_elf_object_p): Recognize E_M32RX_ARCH. + (m32r_elf_print_private_bfd_data): Ditto. + (m32r_elf_final_write_processing): Handle bfd_mach_m32rx. + * archures.c (bfd_mach_m32rx): Define it. + * bfd-in2.h: Rebuild. + +1999-09-28 Fred Fish + + * targets.c (cisco_core_vec): Replaced with two new vecs ... + (cisco_core_big_vec): Add new bigendian vec. + (cisco_core_little_vec): Add new little endian vec. + + * cisco-core.c (CRASH_INFO): Fixed offset replaced with ... + (crash_info_locs): Add array of possible offsets. + (MASK_ADDR): Mask to apply to crash info offset. + (crashinfo_external): Add textbase, database, bssbase and + turn into a typedef. + (cisco_core_file_validate): Renamed from cisco_core_file_p. + Many small changes to account for additional hardware versions. + Pick a reasonable size for ".reg" section. Add a ".crash" + section to allow access to crashinfo_external struct. + (cisco_core_file_p): New version of this function that + iterates over crash_info_locs, calling cisco_core_file_validate. + (cisco_core_vec): Old big endian only vec replaced with ... + (cisco_core_big_vec): Add big endian version. + (cisco_core_little_vec): Add little endian version. + + * configure.in (cisco_core_vec): Split to two new vectors ... + (cisco_core_big_vec): New target vector. + (cisco_core_little_vec): New target vector. + * configure: Regenerate. + * config.bfd (targ): For m68*-*-aout* targ, change cisco_core_vec + to cisco_core_big_vec in targ_selvecs. + +1999-09-28 Geoffrey Keating + + * elf32-mips.c (mips_elf_relocate_hi16): Unused, delete. + (mips_elf_relocate_got_local): Unused, delete. + (mips_elf_relocate_global_got): Unused, delete. + +1999-09-24 Fred Fish + + * elf.c (bfd_section_from_phdr): Add typename variable. Use p_type + to initialize it to something meaningful. Then use it to generate + more useful segment names. + +Sun Sep 19 12:16:47 1999 Jeffrey A Law (law@cygnus.com) + + * som.c (NO_PCREL_MODES): Define if the system does not define + R_SHORT_PCREL_MODE. + (hppa_som_gen_reloc_type): Handle both short and long pcrel branches. + (som_write_fixups): Eliminate redundant pcrel mode relocs. Handle + R_LONG_PCREL_MODE and R_SHORT_PCREL_MODE + * libhppa.h (dis_assemble_22): New function. + (bfd_hppa_insn2fmt): Handle long branch. + + * libhppa.h (bfd_hppa_insn2fmt): Decode and handle formats found + in PA2.0. + +1999-09-17 Alan Modra + + * coff-i386.c (coff_i386_reloc_type_lookup): Support BFD_RELOC_16, + BFD_RELOC_16_PCREL, BFD_RELOC_8, BFD_RELOC_8_PCREL relocs. + (reloc_howto_type howto_table): Tidy comments and whitespace. + +1999-09-17 Nick Clifton + + * elf32-arm.h (bfd_elf32_arm_get_bfd_for_interworking): Undo + previous delta. Set sec->gc_mark instead. + +Thu Sep 16 11:21:13 1999 Catherine Moore + + * elf32-m68k.c (elf_cpu32_plt0_entry): Use a1 instead of a0. + (elf_cpu32_plt_entry): Likewise. + +Thu Sep 16 10:48:17 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_final_write_processing): Turn on TRAPNIL. + + * elf-hppa.h (elf_hppa_final_link): If unable to find __gp in the + symbol table, then just compute a suitable value (but do not + create a __gp symbol). + + * elf-hppa.h (elf_hppa_relocate_section): Allow undefined + symbols when building shared libraries. + (elf_hppa_final_link_relocate): Correct handling of PCREL + relocations against undefined symbols. + +1999-09-16 Nick Clifton + + * elf32-arm.h (bfd_elf32_arm_get_bfd_for_interworking): Mark + interworking sections as linker created so that they will not + be removed by garbage collection. + +Wed Sep 15 02:31:57 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_final_link): Revamp __gp handling. + (elf_hppa_final_link_relocate): Consistently create an absolute + address, then subtract out the value of __gp. + +1999-09-14 Michael Meissner + + * configure.in (Canonicalization of target names): Remove adding + ${CONFIG_SHELL} in front of $ac_config_sub, since autoconfig 2.14 + generates $ac_config_sub with a ${CONFIG_SHELL} already. + * configure: Regenerate. + +1999-09-14 Nick Clifton + + * elf32-m32r.c (ELF_MAXPAGESIZE): Change to 0x1 (at request of + Mitsubishi). + +Mon Sep 13 20:01:47 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_record_segment_addrs): New function. + (elf_hppa_final_link): Initialize text_segment_base and + data_segment_base. + (elf_hppa_final_link_relocate): Handle SEGREL relocations. + + * elf-hppa.h (elf_hppa_final_link): Remove unused variables. + (elf_hppa_final_link_relocate): Likewise. + (elf_hppa_relocate_insn): Likewise. + (elf_hppa_relocate_section): Initialize HOWTO. + +1999-09-13 Donn Terry + + * coffcode.h (styp_to_sec_flags): Further refinement of COMDAT + handling to support both GNU and MS objects. + + * coffcode.h (coff_write_object_contents): Don't check reloc_count + when determining whether to set F_RELFLG. + +1999-09-13 Philip Blundell + + * elf32-arm.h (elf32_arm_final_link_relocate): Don't range-check + PC24 relocs if the target is an undefined weak symbol. + (arm_add_to_rel): Fix compiler warning. + (elf32_arm_plt0_entry): Correct comments. + +1999-09-13 Alan Modra + + * elfcode.h (write_relocs): Check for the_bfd NULL when handling + an absolute symbol in REL relocs. + +Sun Sep 12 23:47:58 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle SECREL32. + Stub SEGREL32. Return an error for any relocation not handled. + +1999-09-12 Ian Lance Taylor + + * cofflink.c (coff_link_add_symbols): Look for special MSVC string + constant symbols, and avoid multiple definition errors on them. + +1999-09-12 Donn Terry + + * libbfd.c (bfd_log2): Rewrite to avoid infinite loop if most + significant bit is set. + +1999-09-11 Ian Lance Taylor + + * coff-ppc.c (COFF_SECTION_ALIGNMENT_ENTRIES): Define. + + * elfcode.h (write_relocs): Handle an absolute symbol in REL + relocs as we do for RELA relocs. + +1999-09-11 Donn Terry + + * libpei.h (_bfd_pei_final_link_postscript): Declare. + (coff_final_link_postscript): Define. + * peigen.c (_bfd_pei_swap_aouthdr_out): Don't set value for data + directory entries here. + (_bfd_pei_final_link_postscript): New function. + + * peigen.c (_bfd_pei_swap_scnhdr_out): Remove code which sets + section flags based on the section name. + + * peicode.h (coff_swap_scnhdr_in): If COFF_IMAGE_WITH_PE, the + get the overflow of the s_nlnno field from the s_nreloc field. + * peigen.c (_bfd_pei_swap_scnhdr_out): If doing a final link, swap + the s_nlnno overflow of the .text section into the s_nreloc + field. + + * peigen.c (add_data_entry): Declare. + (pei_swap_aouthdr_out): Get image size right. Set linker version + more intuitively. + (pei_swap_scnhdr_out): Test for UNINIT section, not .bss. + (pe_print_idata): Code cleanup, print more info, get rid of (now) + extraneous ImageBase. + (pe_print_edata): Likewise. + (pe_print_pdata): Likewise. Print exception entries. + (pe_print_reloc): Likewise. Print MIPS_JMPADDR. + (tbl): Make const, add "UNKNOWN". + (_bfd_pe_print_private_bfd_data_common): Print timestamp. + (_bfd_pe_bfd_copy_private_bfd_data_common): Don't copy deleted + section data directory. + (_bfd_pe_bfd_copy_private_section_data): Copy pe_flags. + + * libpei.h (_bfd_pe_bfd_get_symbol_info): Declare. + * peigen.c (_bfd_pe_bfd_get_symbol_info): New function. + * peicode.h (coff_get_symbol_info): Define. + + * config.bfd (i[3456]86-*-interix*): Set targ_cflags to + -DSTRICT_PE_FORMAT. + * coffcode.h (styp_to_sec_flags): Check STRICT_PE_FORMAT rather + than __INTERIX. + (coff_classify_symbol): Re-revert 1999-08-08 patch if + STRICT_PE_FORMAT. + + * libpei.h: New file, broken out of peicode.h. + * peigen.c: New file, broken out of peicode.h. + * peicode.h: A bunch of code moved out to libpei.h and peigen.c. + * configure.in: Add peigen.lo to list of files required for each + PE target. + * Makefile.am: Rebuild dependencies. + (BFD32_BACKENDS): Add peigen.lo. + (BFD32_BACKENDS_CFILES): Add peigen.c. + (SOURCE_HFILES): Add libpei.h. + * configure, Makefile.in: Rebuild. + + * peicode.h (coff_swap_scnhdr_in): Don't check for a special + section name of _BSS; check IMAGE_SCN_CNT_UNINITIALIZED_DATA + instead. Don't clear the s_paddr field for an uninitialized data + section. + + * coffcode.h (coff_mkobject_hook): Set timestamp field in + coff_data_type to f_timdat. + * peicode.h (pe_mkobject_hook): Likewise. + + * peicode.h (coff_swap_filehdr_in): Check the NT executable magic + number if COFF_IMAGE_WITH_PE. + + * coffcode.h (coff_mkobject_hook): If COFF_WITH_PE, set HAS_DEBUG + to the reverse of IMAGE_FILE_DEBUG_STRIPPED. + (coff_write_object_contents): Set IMAGE_FILE_DEBUG_STRIPPED if + there is no SEC_DEBUGGING section. + * peicode.h (pe_mkobject_hook): Set HAS_DEBUG to the reverse of + IMAGE_FILE_DEBUG_STRIPPED. + + * pe-i386.c (COFF_LONG_FILENAMES): Define. + (COFF_SECTION_ALIGNMENT_ENTRIES): Define. + * pei-i386.c (COFF_LONG_FILENAMES): Define. + (COFF_SECTION_ALIGNMENT_ENTRIES): Define. + + * coffswap.h (IMAGE_BASE): Don't define. + * pei-arm.c (IMAGE_BASE): Don't define. + * pei-i386.c (IMAGE_BASE): Don't define. + * pei-mcore.c (IMAGE_BASE): Don't define. + * pei-ppc.c (IMAGE_BASE): Don't define. + + * cofflink.c (_bfd_coff_link_input_bfd): When writing out a + symbol, switch on the class when determining whether to modify the + value. For PE, don't modify the value of a C_FCN symbol not named + .bf. + + * libbfd-in.h (_bfd_abort): Declare. + (abort): Define. + * bfd.c (_bfd_abort): New function. + * libbfd.h: Rebuild. + + * coffcode.h (coff_set_alignment_hook): Delete POWERPC_LE_PE + special handling. + + * cofflink.c (_bfd_coff_link_input_bfd): If a symbol is stripped, + don't write out the associated line numbers. + + * cofflink.c (_bfd_coff_write_global_sym): Handle section symbol + aux entries. + + * cofflink.c (coff_link_add_symbols): Don't warn about symbol type + changes when the base type is unknown. + + * coffgen.c (coff_print_symbol): Fix printing of aux record for + function symbols. + + * syms.c (BSF_DEBUGGING_RELOC): Define. + * coffcode.h (coff_slurp_symbol_table): If PE, set BSF_DEBUGGING + for C_FCN/C_EFCN symbols, and set BSF_DEBUGGING_RELOC for such + symbols named .bf. + * coffgen.c (fixup_symbol_value): Relocate a symbol which has + BSF_DEBUGGING_RELOC set. + * bfd-in2.h: Rebuild. + +1999-09-10 Ian Lance Taylor + + * ecoff.c (bfd_debug_section): Update initialization for new + comdat_info field. + (_bfd_ecoff_styp_to_sec_flags): Add section parameter. + * libecoff.h (_bfd_ecoff_styp_to_sec_flags): Update declaration. + +1999-09-10 H.J. Lu + + * coff-alpha.c (alpha_ecoff_backend_data): Initialize the new + _bfd_filnmlen field. + * coff-mips.c (mips_ecoff_backend_data): Likewise. + +Fri Sep 10 00:35:14 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_final_link_relocate): Create .opd entries + for FPTR relocs involving local symbols. + + * elf-hppa.h (elf_hppa_final_link_relocate): Get the right + value for the stub address in a call through a stub. + Install the value for a local symbol directly into the DLT + instead of generating a reloc. Correctly handle FPTR64 relocs. + + * elf-hppa.h (elf_hppa_unmark_useless_dynamic_symbols): New function. + (elf_hppa_remark_useless_dynamic_symbols): Similarly. + (elf_hppa_final_link): Call them. + +1999-09-10 Ian Lance Taylor + + * elflink.h (elf_fix_symbol_flags): Move weakdef handling here... + (elf_adjust_dynamic_symbol): ...from here. + +Wed Sep 8 17:56:11 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_howto_table); There is no DIR64WR, DIR64DR + relocation, remove them. SECREL64->LTOFF16WF. + (elf_hppa_final_link_relocate): Handle LTOFF* relocations. Handle + DIR* relocations. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle PLTOFF* relocs. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle DPREL* and + GPREL* relocations. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_link_final_relocate): Fix typos. + Handle LTOFF_TP* relocs. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle PCREL* relocs. + Consistently deal with addends. Handle DLTIND14F and DLTREL14F. + (elf_hppa_relocate_insn): Handle PCREL* relocs. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle LT_OFF_FPTR*, + DIR32, DIR64 and FPTR64 relocations. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link): Set the value of __gp to the + address of the .PARISC.global section. + (elf_hppa_relocate_section): Lookup and pass the PA64 hash + table entry elf_hppa_final_link_relocate. Do not give a warning + for a reloc against an external symbol if it has a PA64 hash + table entry. + (elf_hppa_final_link_relocate): Significantly rework. Handle + DLTIND relocations. Compute the final value of the relocation + before passing the value of elf_hppa_relocate_insn. + (elf_hppa_relocate_insn): Revamp to handle just bit tiwiddling + relocation support. Handle DLTIND relocation requests just like + DLTREL relocation requests. Simplify branch handling. + +1999-09-08 Ulrich Drepper + + * elf-hppa.h (elf_hppa_relocate_section): Catch problems with + non-allocated section as done in i386 version. + (elf_hppa_final_link_relocate): Uncomment R_PARISC_14F in switch + statement since this is no know relocation. + +Tue Sep 7 17:25:12 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle DLTREL14F + relocs. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle DLTREL14WR and + DLTREL14WD relocs. + (elf_hppa_relocate_insn): Similarly. + + * elf-hppa.h (elf_hppa_final_link_relocate): Handle DLTREL14R and + DLTREL21L relocs. Pass the output bfd to elf_hppa_relocate_insn. + Pass the relocate type rather than the insn format to + elf_hppa_relocate_insn. + (elf_hppa_relocate_insn): Make switch dependent on relocation type + rather than the opcode. Handle DLTREL21L and DLTREL14R relocs. + +1999-09-07 Ian Lance Taylor + + * coffcode.h (bfd_coff_backend_data): Add _bfd_filnmlen field. + (bfd_coff_filnmlen): Define. + (bfd_coff_std_swap_table): Initialize new field. + * coffgen.c (coff_fix_symbol_name): Use bfd_coff_filnmlen rather + than FILNMLEN. + (coff_write_symbols): Likewise. + (coff_get_normalized_symtab): Likewise. + * coff-sh.c (bfd_coff_small_swap_table): Initialize new field. + * libcoff.h: Rebuild. + +1999-09-06 Donn Terry + + * coffcode.h (sort_by_secaddr): New static function if + COFF_IMAGE_WITH_PE. + (coff_compute_section_file_positions): If COFF_IMAGE_WITH_PE, sort + sections by VMA when assigning target_index values. Always set + virt_size. + + * libcoff-in.h (struct pei_section_tdata): Add pe_flags field. + * coffcode.h (coff_set_alignment_hook) [COFF_WITH_PE version]: Set + pe_flags field. + * libcoff.h: Rebuild. + + * coffcode.h (coff_set_custom_section_alignment): Add const to + declaration to match definition. + (coff_write_object_contents): Don't set F_AR32W(R)? if + COFF_WITH_PE. + + * coff-i386.c (in_reloc_p): Add declaration. + (i386coff_vec): Simplify initialization of + application_section_flags. + + * coffcode.h (sec_to_styp_flags): Write separate COFF_WITH_PE + version. Move COFF_WITH_PE specific code to new version. + (stype_to_sec_flags): Likewise. Add section parameter. + * coffgen.c (make_a_section_from_file): Set target_index before + calling styp_to_sec_flags. Pass section to styp_to_sec_flags. + * libcoff.h: Rebuild. + + * syms.c (stt): Add some PE/PEI section names. + (bfd_decode_symclass): Return 'w', not 'U', for a weak undefined + symbol. + (bfd_symbol_info): Check for 'w'. + + * section.c (struct bfd_comdat_info): Define. + (asection): Add comdat field. + (STD_SECTION): Initialize comdat field. + (bfd_make_section_anyway): Likewise. + * bfd-in2.h: Rebuild. + +1999-09-06 Andreas Schwab + + * elflink.h (elf_link_add_object_symbols): Copy NON_GOT_REF flag + to version symbols. + +1999-09-06 Nick Clifton + + * elflink.h (elf_gc_record_vtentry): Use bfd_zmalloc and + bfd_realloc instead of calloc and realloc. + +1999-09-04 Steve Chamberlain + + * cpu-pj.c: New file. + * elf32-pj.c: New file. + * config.bfd (pj*): New cpu. + (pj-*-*, pjl-*-*): New targets. + * configure.in (bfd_elf32_pj_vec): New target vector. + (bfd_elf32_pjl_vec): New target vector. + * archures.c (bfd_arch_pj): Define. + * elf.c (prep_headers): Handle bfd_arch_pj. + * reloc.c: Define BFD_RELOC_PJ_* relocations. + * targets.c (bfd_elf32_pj_vec, bfd_elf32_pjl_vec): Declare and add + to target vector list. + * Makefile.am: Rebuild dependencies. + (ALL_MACHINES): Add cpu-pj.lo. + (ALL_MACHINES_CFILES): Add cpu-pj.c. + (BFD32_BACKENDS): Add elf32-pj.lo. + (BFD32_BACKENDS_CFILES): Add elf32-pj.c. + * configure, Makefile.in, bfd-in2.h, libbfd.h: Rebuild. + +1999-09-04 Ian Lance Taylor + + * elf-bfd.h (ELF_LINK_NON_GOT_REF): Define. + * elflink.h (elf_adjust_dynamic_symbol): Copy REF_REGULAR_NONWEAK + and NON_GOT_REF from weak defined symbol to real symbol. + * elf32-i386.c (elf_i386_check_relocs): Set NON_GOT_REF. + (elf_i386_adjust_dynamic_symbol): If NON_GOT_REF is not set, don't + create a COPY reloc. + * elf32-sparc.c (elf32_sparc_check_relocs): Set NON_GOT_REF. + (elf32_sparc_adjust_dynamic_symbol): If NON_GOT_REF is not set, + don't create a COPY reloc. + +1999-09-03 Ian Lance Taylor + + * elflink.h (elf_bfd_final_link): When counting relocations, don't + count those in sections we are not including in the link. + +Thu Sep 2 17:41:20 1999 Jeffrey A Law (law@cygnus.com) + + * elflink.h (elf_link_add_object_symbols): Work around bogus SH_LINK + field in hpux11 shared libraries. + +1999-09-02 Nick Clifton + + * elflink.h (elf_gc_record_vtentry): Fix memory leak. + +Wed Sep 1 13:34:29 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_add_symbol_hook): New function. + (elf_hppa_final_link, elf_hppa_relocate_section): Likewise. + (elf_hppa_final_link_relocate, elf_hppa_relocate_insn): Likewise. + +1999-08-31 Alexandre Petit-Bianco + + * elflink.h (record_link_assignment): When possible, keep the + original type of the symbol. + +Mon Aug 30 15:26:48 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Allow both + R_PARISC_DIR32 and R_PARISC_DIR64 regardless of how the + tools were configured. + * elf32-hppa.h (_bfd_elf32_hppa_gen_reloc_type): Declare. + +1999-08-26 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_check_relocs): Don't allocate local + GOT entries for GOT16 relocations; they're not required. + +1999-08-24 Nick Clifton + + From a patch submitted by Roland McGrath + + * config.bfd (arm-*-netbsd*): New target. + * configure.in (armnetbsd_vec): New target vector. + * configure: Regenerate + * targets.c (bfd_target_vector): Add &armnetbsd_vec. + + * Makefile.am (BFD32_BACKENDS): Add armnetbsd.lo. + (ALL_MACHINES_CFILES): Add armnetbsd.c. + (armnetbsd.lo): New rule with deps. + * Makefile.in: Regenerate. + + * armnetbsd.c: New file: Definitions specific to arm-netbsd + target. + +Tue Aug 24 00:25:58 1999 Jeffrey A Law (law@cygnus.com) + + * som.c (som_slurp_symbol_table): Fix typo in comment. + +Fri Aug 20 17:01:23 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_fake_sections): Compute section indices + here instead of using elf_section_data... + +1999-08-19 Nick Clifton + + * coff-mcore.c (mcore_emit_base_file_entry): New function: Emit + relocations into the base file. + (coff_mcore_relocate_section): Call mcore_emit_base_file_entry if + we are building a base file. + +1999-08-19 Nick Clifton + + * elf32-arm.h (arm_add_to_rel): New function. Add a value to + a REL style reloc. + (elf32_arm_relocate_section): Use arm_add_to_rel to increment + REL relocs when performing a partial relocation. + +1999-08-18 Donn Terry + + * cofflink.c: Move definitions of N_TMASK, et. al., out of + _bfd_coff_link_input_bfd into top level. + + * coff-i386.c (coff_i386_reloc): Handle R_IMAGEBASE. + (RTYPE2HOWTO): Return NULL if reloc type is out of range. + (coff_i386_rtype_to_howto): Likewise. + * coffcode.h (coff_slurp_symbol_table): Change a -2 to N_DEBUG. + Completely ignore symbols which are all zero. + (dummy_reloc16_estimate): Add return 0. + * cofflink.c (_bfd_coff_link_input_bfd): Rename inner scope + variable copy to name_copy to avoid shadowing outer scope + variable. + * libcoff-in.h (coff_data_type): Change raw_syment_count field + from unsigned int to unsigned long. Add timestamp field. + * libcoff.h: Rebuild. + +1999-08-17 H.J. Lu + + * elf32-hppa.c (bfd_elf32_bfd_is_local_label_name): Fix typo in + macro definition. + +1999-08-17 Ian Lance Taylor + + * elf32-mips.c (_bfd_mips_elf_add_symbol_hook): Set BSF_DYNAMIC + for special section symbols. + * elflink.h (elf_merge_symbol): If we have no old BFD, check + BSF_DYNAMIC on the section symbol to see whether the old BFD is + dynamic. + +1999-08-15 Mark Mitchell + + * elf32-mips.c (mips_elf_calculate_relocation): Fix unfortunate + coincidence of variable names between old and new code. + +1999-08-12 Nick Clifton + + * elf32-arm.h (elf32_arm_to_thumb_stub): Make 'offset' parameter + into a bfd_vma and 'addend' parameter a 'bfd_signed_vma'. + (elf32_thumb_to_arm_stub): Make 'offset' parameter into a bfd_vma + and 'addend' parameter a 'bfd_signed_vma'. + (elf32_arm_final_link_relocate): Do not involve stubs in + R_ARM_THM_PC22 relocs relative to section symbols, they are long + jumps, not function calls. + +1999-08-11 Robin Farine + + * elf32-arm.h (elf32_arm_final_link_relocate): Check for overflow + in R_ARM_PC24 relocs. + +Tue Aug 10 12:48:09 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (elf_hppa_fake_sections): New function. + * elf32-hppa.c (elf_backend_fake_sections): Define. + + * elf-hppa.h (elf_hppa_final_write_processing): Update for + recent changes to the arch_info structure. + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Handle + R_HPPA_SEGBASE and R_HPPA_SEGREL32. + * cpu-hppa.c (bfd_hppa20w_arch): New entry in architecture info + list. + +Tue Aug 10 00:34:29 1999 Mark P. Mitchell + Ralf Baechle + + * elf32-mips.c (_bfd_mips_elf_size_dynamic_sections): Always + output DT_MIPS_GOTSYM. + (_bfd_mips_elf_finish_dynamic_sections): Use the same value as + DT_MIPS_SYMTABNO if there are no global GOT symbols. + +Tue Aug 10 00:21:08 1999 Mark P. Mitchell + + * elf32-mips.c (mips_elf_create_dynamic_relocation): Change + prototype. Handle local symbols. Add commentary. + (mips_elf_calculate_relocation): Adjust accordingly. + (_bfd_mips_elf_check_relocs): Handle local symbols in R_MIPS_32 + relocations. + + * elflink.h (elf_bfd_final_link): Tweak last change. + +1999-08-09 Mark Mitchell + + * elflink.h (elf_link_size_reloc_section): Use the counts in the + elf-section data to allocate just the right amount of relocation + space. Don't allocate the hash space twice. + (elf_bfd_final_link): Calculate the amount of space to allocate in + each relocation section. + +Mon Aug 9 17:37:30 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type, case 32): When in + 64bit mode, generate a section relative relocation for a 32bit + wide relocation. + (elf_hppa_is_local_label_name): New function. + * elf32-hppa.c (elf_hppa_is_local_label_name): Deleted. To be + shared between 32bit and 64bit port. + +1999-08-09 Mark Mitchell + + * elf32-mips.c (elf_mips_howto_table): Fix src_mask for + R_MIPS_GOT16 and R_MIPS_CALL16. + (mips_elf_got16_entry): Use mips_elf_high to calculate the value + to use when looking for a preexisting GOT entry. + +1999-08-09 Jakub Jelinek + + * elf64-sparc.c (sparc64_elf_relocate_section): Back out part of + the Sep. 4th, 1998 change. glibc 2.0.x dynamic linker had bug, + not binutils. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + +1999-08-09 Geoff Keating + + * elflink.h (elf_link_output_extsym): Don't output a weak + reference to an undefined symbol just because it was defined weak + in a shared object. + +1999-08-09 Eli Zaretskii + + * coffgen.c (coff_find_nearest_line): When looking for file, use + last best match rather than first. If address is beyond last line + number record, don't return the last line as the correct value. + +1999-08-08 Ian Lance Taylor + + * section.c (SEC_SMALL_DATA): Rename from SEC_SHORT. + * bfd-in2.h: Rebuild. + +1999-08-08 Mark Elbrecht + + * libcoff-in.h (struct coff_section_alignment_entry): Define. + * coffcode.h (coff_set_custom_section_alignment): New static + function. + (coff_section_alignment_table): New static array. + (coff_new_section_hook): Use coff_set_customer_section_alignment. + * coff-go32.c (COFF_SECTION_ALIGNMENT_ENTRIES): Define. + * coff-stgo32.c (COFF_SECTION_ALIGNMENT_ENTRIES): Define. + * libcoff.h: Rebuild. + +1999-08-08 Ian Lance Taylor + + * Makefile.am: Rename .dep* files to DEP*. Change DEP variable to + MKDEP. + * Makefile.in: Rebuild. + +1999-08-08 Mumit Khan + + * section.c (SEC_SHARED): Define. + * coffcode.h (sec_to_styp_flags): Handle SEC_SHARED. + (styp_to_sec_flags): Likewise. + * peicode.h (coff_swap_scnhdr_out): Likewise. + * bfd-in2.h: Rebuild. + +1999-08-08 Ian Lance Taylor + + * coffcode.h (coff_classify_symbol): Comment out part of + 1999-08-05 change which breaks cygwin DLLs. + + * acinclude.m4 (BFD_BINARY_FOPEN): Change -windows to -windows*. + * aclocal.m4, configure: Rebuild. + +1999-08-06 Ian Lance Taylor + + * section.c (global_syms): Only initialize union field if + __STDC__. + +1999-08-04 Mark Mitchell + + * elf32-mips.c (mips_elf_got16_entry): Don't multiply GOT index by + the size of a GOT entry here. + (mips_elf_calculate_relocation): Don't create a local GOT entry + for the symbol in a GOT16 relocation; just for it's high-order bit + (_bfd_mips_elf_relocate_section): Fix thinko. + +1999-08-05 Ian Lance Taylor + + Based on patches from Donn Terry : + * coffcode.h (enum coff_symbol_classification): Define. + (bfd_coff_backend_data): Rename _bfd_coff_sym_is_global to + _bfd_coff_classify_symbol. Change return type. + (bfd_coff_classify_symbol): Rename from bfd_coff_sym_is_global. + (coff_slurp_symbol_table): Use coff_classify_symbol. + (coff_classify_symbol): New static function. + (coff_sym_is_global): Never define. + (bfd_coff_std_swap_table): Initialize with coff_classify_symbol. + * cofflink.c (coff_link_check_ar_symbols): Use + bfd_coff_classify_symbol rather than bfd_coff_sym_is_global. + (coff_link_add_symbols): Likewise. + (_bfd_coff_link_input_bfd): Likewise. + * coff-sh.c (bfd_coff_small_swap_table): Initialize with + coff_classify_symbol. + * libcoff.h: Rebuild. + +Wed Aug 4 18:08:07 1999 Jeffrey A Law (law@cygnus.com) + + * libhppa.h (R_HPPA_LTPSEL, R_HPPA_RTPSEL): New field selectors + (e_ltpsel, e_rtpsel): Similarly. + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Handle 21bit e_ltpsel + and 14bit ertpsel. Handle 64bit psel. + +1999-08-04 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_relocate_section): Tweak HI16/LO16 + handling for REL relocations. And only left-shift R_MIPS26 + relocation addends where necessary. + +1999-08-03 Mark Mitchell + + * elf32-mips.c (mips_elf_next_lo16_addend): Rename to ... + (mips_elf_next_lo16_relocation): Don't compute the addend here. + Just return the relocation found. + (mips_elf_relocate_section): Pull the LO16 addend out of the + section itself when using REL relocations. + + * elf32-mips.c (mips_elf_calculate_relocation): Restore + _DYNAMIC_LINK handling and handling of undefined symbols in shared + libraries. + +1999-08-03 Ian Lance Taylor + + * elf32-ppc.c (ppc_elf_relocate_section): Don't use the relocation + value of a symbol in a SEC_DEBUGGING section. Warn when doing a + relocation against a symbol in an input section with no output + section. From Daniel Jacobowitz . + + * coff-stgo32.c (go32_stubbed_coff_object_p): Remove; not used. + + * acinclude.m4 (BFD_CC_FOR_BUILD): Change to use conftest, and to + look for generated file correctly. + * aclocal.m4, configure: Rebuild. + +1999-08-02 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_relocate_section): Handle R_MIPS_26 + and R_MIPS16_26 relocations correctly when relocating. + (_bfd_mips_elf_check_relocs): Don't assume that R_MIPS_CALL_HI16 + and R_MIPS_CALL_LO16 are for global symbols. + +1999-08-02 Jakub Jelinek + + * elflink.h (elf_bfd_final_link): Copy the whole isym, not just + some fields. + * elf64-sparc.c (sparc64_elf_output_arch_syms): Declare used + variables and initialize them. + +1999-08-01 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_final_link): Handle the case where + there are no global symbols requiring GOT entries. + (_bfd_mips_elf_size_dynamic_sections): Likewise. + (_bfd_mips_elf_finish_dynamic_symbol): Likewise. + (_bfd_mips_elf_finish_dynamic_sections): Likewise. + + * elf32-mips.c (mips_elf_calculate_relocation): Undefined weak + symbols are considered to have the value zero. + (_bfd_mips_elf_relocate_section): Don't try to perform a + relocation for an undefined symbol. + (_bfd_mips_elf_check_relocs): Allocate locate GOT space for local + GOT16 relocations. + +1999-07-30 Jakub Jelinek + + * elf64-sparc.c (sparc64_elf_build_plt): Cosmetic change - ABI + wants ba,a,pt %xcc instead of %icc. + Emit correct .PLT0-(.PLTN+4) initial value into the pointer slots + of large PLT entries. + (sparc64_elf_plt_ptr_offset): Fix calculation. + (sparc64_elf_finish_dynamic_symbol): Negative value of R_SPARC_JMP_SLOT + addend should be relative to load address, not .plt section start. + (sparc64_elf_size_info): Sparc64 uses 32bit .hash entries. + +1999-07-30 Jakub Jelinek + + * elf-bfd.h (struct elf_backend_data): Add + print_symbol_all and output_arch_syms backend methods. + * elfxx-target.h: Likewise. + * elf64-sparc.c (sparc64_elf_bfd_link_hash_table_create, + sparc64_elf_add_symbol_hook, sparc64_elf_output_arch_syms, + sparc64_elf_get_symbol_type, sparc64_elf_symbol_processing): New + functions. + (sparc64_elf_size_dynamic_sections): Leave space for STT_REGISTER + symbols in .dynsym, add their names into .dynstr. Put those symbols + into dynlocal. + (sparc64_elf_finish_dynamic_sections): Fix up DT_SPARC_REGISTER + pointers to STT_REGISTER symbols in dynsym section. + (sparc64_elf_print_symbol_all): New function. + * elf.c (bfd_elf_print_symbol): Allow special backend symbol + printing using the print_symbol_all hook. + +1999-07-30 Catherine Moore + + * elf32-arm.h (elf32_arm_check_relocs): Use r_offset for + R_ARM_GNU_VTENTRY. + +1999-07-29 Richard Henderson + + * elf32-mips.c (_bfd_mips_elf_final_link): Only re-sort dynsyms if + dynamic_sections_created. + +1999-07-29 Richard Henderson + + * elf32-mips.c (mips_info_to_howto_rel): Split out switch to ... + (mips_rtype_to_howto): ... new function. + (_bfd_mips_elf_relocate_section): Use it. + +1999-07-28 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_relocate_section): Fix typo. + +1999-07-27 Nick Clifton + + Patch generated by Bernd Schmidt. + + * coff-arm.c (coff_arm_is_local_label_name): Change to strip + out only symbols that start with LOCAL_LABEL_PREFIX followed by 'L'. + +1999-07-23 Donn Terry + + * libcoff-in.h (coff_link_hash_entry): Add coff_link_hash_flags + field, and define COFF_LINK_HASH_PE_SECTION_SYMBOL. + * cofflink.c (coff_link_add_symbols): If PE, handle section + symbols specially. + * libcoff.h: Rebuild. + + * config.bfd (i[3456]86-*-interix*): New target. + +1999-07-21 Mark Elbrecht + + * coffcode.h (styp_to_sec_flags): If COFF_LONG_SECTION_NAMES and + COFF_SUPPORT_GNU_LINKONCE, mark sections whose names begin with + .gnu.linkonce with SEC_LINKONCE and SEC_LINK_DUPLICATES_DISCARD. + * coff-go32.c: (COFF_LONG_SECTION_NAMES): Define. + (COFF_SUPPORT_GNU_LINKONCE): Define. + * coff-stgo32.c: (COFF_LONG_SECTION_NAMES): Define. + (COFF_SUPPORT_GNU_LINKONCE): Define. + +1999-07-21 Ian Lance Taylor + + From Mark Elbrecht: + * makefile.dos: Remove; obsolete. + * configure.bat: Remove; obsolete. + +1999-07-21 H.J. Lu + + * config.bfd (i[3456]86-*-vxworks*): Add targ_underscore=yes. + +1999-07-21 Philippe De Muyter + + * cofflink.c (_bfd_coff_generic_relocate_section): Issue an error + message and fail if a symbol index is out of range. + +1999-07-21 Ian Lance Taylor + + * elf32-mips.c (mips_elf_calculate_relocation): Get the GP value + when looking at a R_MIPS_GOT16 relocation. + +1999-07-20 Nick Clifton + + * coff-m88k.c: Use CREATE_BIG_COFF_TARGET_VEC. + +Mon Jul 19 14:03:44 1999 Mark P. Mitchell + + * elf32-mips.c (_bfd_mips_elf_final_link): Restore setting of GP + removed in previous change. + (_bfd_mips_elf_relocate_section): Adjust GP relative relocations + in relocateable output. + +1999-07-19 Ian Lance Taylor + + * coff-m88k.c (m88kbcs_vec): Initialize new field of bfd_target + structure. + + * elflink.h (elf_merge_symbol): Do merge symbols from the same BFD + if they appear to be specially created by the linker. + +1999-07-19 Nick Clifton + + * targets.c (alternative_target): New field in bfd_target + structure. + (bfd_search_for_target): New function: Find a target that + satisifies a search function. + * bfd-in2.h: Regenerate. + + * elfxx-target.h: Initialise the alternative_target field of + the bfd_target structures to point to the other target (if + defined). + * nlm-target.h: Initialise the alternative_target field of + the bfd_target structures to point to the other target (if + defined). + + * coffcode.h (CREATE_BIG_COFF_TARGET_VEC): New macro. + (CREATE_LITTLE_COFF_TARGET_VEC): New macro. + + * aix386-core.c: Initialise new field of bfd_target structure. + * aout-adobe.c: Initialise new field of bfd_target structure. + * aout-arm.c: Initialise new field of bfd_target structure. + * aout-target.h: Initialise new field of bfd_target structure. + * aout-tic30.c: Initialise new field of bfd_target structure. + * binary.c: Initialise new field of bfd_target structure. + * bout.c: Initialise new field of bfd_target structure. + * cisco-core.c: Initialise new field of bfd_target structure. + * coff-a29k.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-alpha.c: Initialise new field of bfd_target structure. + * coff-apollo.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-arm.c: Use CREATE_{BIG|LITTLE}_COFF_TARGET_VEC. + * coff-h8300.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-h8500.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-i386.c: Initialise new field of bfd_target structure. + * coff-i860.c: Initialise new field of bfd_target structure. + * coff-i960.c: Use CREATE_LITTLE_COFF_TARGET_VEC. + * coff-m68k.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-mcore.c: Use CREATE_{BIG|LITTLE}_COFF_TARGET_VEC. + * coff-mips.c: Initialise new field of bfd_target structure. + * coff-ppc.c: Initialise new field of bfd_target structure. + * coff-rs6000.c: Initialise new field of bfd_target structure. + * coff-sh.c: Use CREATE_{BIG|LITTLE}_COFF_TARGET_VEC. + * coff-sparc.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-tic30.c: Initialise new field of bfd_target structure. + * coff-tic80.c: Use CREATE_LITTLE_COFF_TARGET_VEC. + * coff-w65.c: Use CREATE_LITTLE_COFF_TARGET_VEC. + * coff-we32k.c: Use CREATE_BIG_COFF_TARGET_VEC. + * coff-z8k.c: Use CREATE_BIG_COFF_TARGET_VEC. + * hppabsd-core.c: Initialise new field of bfd_target structure. + * hpux-core.c: Initialise new field of bfd_target structure. + * i386msdos.c: Initialise new field of bfd_target structure. + * i386os9k.c: Initialise new field of bfd_target structure. + * ieee.c: Initialise new field of bfd_target structure. + * ihex.c: Initialise new field of bfd_target structure. + * irix-core.c: Initialise new field of bfd_target structure. + * mipsbsd.c: Initialise new field of bfd_target structure. + * netbsd-core.c: Initialise new field of bfd_target structure. + * oasys.c: Initialise new field of bfd_target structure. + * osf-core.c: Initialise new field of bfd_target structure. + * ppcboot.c: Initialise new field of bfd_target structure. + * ptrace-core.c: Initialise new field of bfd_target structure. + * sco5-core.c: Initialise new field of bfd_target structure. + * som.c: Initialise new field of bfd_target structure. + * srec.c: Initialise new field of bfd_target structure. + * tekhex.c: Initialise new field of bfd_target structure. + * trad-core.c: Initialise new field of bfd_target structure. + * versados.c: Initialise new field of bfd_target structure. + * vms.c: Initialise new field of bfd_target structure. + +1999-07-19 Andreas Schwab + + * elflink.h (elf_bfd_final_link): Remove unused variables rel_hash + and rel_hdr. + +Sat Jul 17 02:28:28 1999 Mark P. Mitchell + + * elflink.h (elf_link_adjust_relocs): New function. + (elf_bfd_final_link): Use it. + (elf_link_input_bfd): Deal with the fact that there can be + two relocation sections for a single section. + (elf_reloc_link_order): Likewise. + + * elf32-mips.c (_bfd_mips_elf_final_link): Don't set GP for + a relocateable object. + (_bfd_mips_elf_relocate_section): Handle relocateable links. + +1999-07-16 Jakub Jelinek + + * elf64-sparc.c (sparc64_elf_info_to_howto): Use ELF64_R_TYPE_ID. + (sparc64_elf_get_reloc_upper_bound, + sparc64_elf_get_dynamic_reloc_upper_bound, + sparc64_elf_slurp_one_reloc_table, sparc64_elf_slurp_reloc_table, + sparc64_elf_canonicalize_dynamic_reloc, sparc64_elf_write_relocs): + New functions. + (sparc64_elf_check_relocs, sparc64_elf_relocate_section): Use + ELF64_R_TYPE_ID/DATA where appropriate. + +1999-07-16 Jakub Jelinek + + * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Remove + DT_SPARC_PLTFMT. + +1999-07-16 Ian Lance Taylor + + * elf32-mips.c (mips_elf_local_relocation_p): New static + function. + (mips_elf_next_lo16_addend): Call bfd_set_error on failure. + (mips_elf_calculate_relocation): Use mips_elf_local_relocation_p. + Always set *require_jalxp. + (mips_elf_stub_section_p): Mark abfd parameter as unused. + (_bfd_mips_elf_relocate_section): Only look for LO16 following + GOT16 if the GOT16 is against a local symbol. Don't return false + for an undefined symbol. If there is an overflow, assert that we + have a name. + +1999-07-16 Andreas Schwab + + * elflink.h (elf_link_record_local_dynamic_symbol): Remove unused + variables `link' and `elfsec'. + (elf_bfd_final_link): Remove unused variable `os'. + +Thu Jul 15 17:55:31 1999 Mark P. Mitchell + + * elf32-mips.c (_bfd_mips_elf_modify_segment_map): Don't require + a PT_PHDR program headers. + (_bfd_mips_elf_final_link): Don't assume there are going to be + section symbols when we're not building a shared object. + (_bfd_mips_elf_check_relocs): Make sure we have a GOT when + we need one. + +1999-07-15 J.T. Conklin + + * config.bfd (i[3456]86-*-vxworks*): New target. + +1999-07-15 Mark Mitchell + + * elf32-mips.c (mips_elf_stub_section_p): New function. + (mips_elf_calculate_relocation): Handle MIPS16 stub functions. + (mips_elf_relocate_section): Adjust calling sequence for + mips_elf_calculate_relocation and mips_elf_perform_relocation. + (mips_elf_perform_relocation): Turn `jal' into `jalx' where + required. + +1999-07-15 Ian Lance Taylor + + * configure.in: Bump version number to 2.9.5. + * configure: Rebuild. + +Thu Jul 15 02:56:15 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type, case R_HPPA): Handle + 64bit format. + (_bfd_elf_hppa_gen_reloc_type, case R_GOTOFF): Use base reloc type + to derive final type instead of hardwiring a selection. + +1999-07-14 Mark Mitchell + + * elf32-mips.c (mips_elf_obtain_contents): Swap 16-bit halves of + things relocated by R_MIPS16_GPREL. + (mips_elf_perform_relocation): Likewise. + +Wed Jul 14 15:23:19 1999 Jim Wilson + + * elfxx-target.h (elfNN_bed): Add elf_backend_want_dynbss. + +1999-07-14 Richard Henderson + + * elf32-mips.c (struct mips_got_info): Add global_gotno. + (_bfd_mips_elf_size_dynamic_sections): Set it. + (_bfd_mips_elf_final_link): Re-sort; verify the got did not grow. + (mips_elf_sort_hash_table): Set max_non_got_dynindex based off + new argument max_local. + +1999-07-14 Mark Mitchell + + * elf32-mips.c (mips_elf_obtain_contents): Swap the 16-bit + subwords when handling an R_MIPS16_26 relocation. + (mips_elf_perform_relocation): Don't be paranoid abour right-shift + semantics. + + * elf32-mips.c (elf_mips16_gprel_howto): Adjust src_mask and + dst_mask to match reality. + (_bfd_mips_elf_calculate_relocation): Handle R_MIPS16_GPREL. + (mips_elf_obtain_contents): Use bfd_get. + (mips_elf_perform_relocation): Handle R_MIPS16_GPREL. + (mips_elf_relocate_section): Likewise. + +1999-07-13 Mark Mitchell + + * elf32-mips.c (mips_elf_calculate_relocation): Handle R_MIPS16_26. + (mips_elf_relocate_section): Adjust calling sequence for + mips_elf_perform_relocation. + (mips_elf_perform_relocation): Take additional argument. Handle + R_MIPS16_26. Use bfd_put for convenience. + +1999-07-13 Richard Henderson + + * elf.c (assign_file_positions_for_segments): Thinko last change. + Always overwrite p_flags. + +1999-07-13 Richard Henderson + + * elf-bfd.h (struct elf_backend_data): Add want_dynbss. + * elflink.c (_bfd_elf_create_dynamic_sections): Only create + .dynbss and .rel[a].bss if want_dynbss. + * elfxx-target.h (elf_backend_want_dynbss): Provide default. + +1999-07-13 Richard Henderson + + * elf.c (assign_file_positions_for_segments): Don't overwrite p_flags. + +1999-07-13 Richard Henderson + + * elf-bfd.h (struct elf_link_local_dynamic_entry): New. + (struct elf_link_hash_table): Add dynlocal. + (_bfd_elf_link_lookup_local_dynindx): Prototype. + (_bfd_elf_link_adjust_dynindx): Delete. + (_bfd_elf_link_renumber_dynsyms): Prototype. + (_bfd_elf,link_record_local_dynamic_symbol): Prototype. + * elfcode.h (elf_link_record_local_dynamic_symbol): New alias. + * elflink.c (_bfd_elf_link_adjust_dynindx): Delete. + (_bfd_elf_link_lookup_local_dynindx): New function. + (elf_link_renumber_hash_table_dynsyms): New function. + (_bfd_elf_link_renumber_dynsyms): New function. + * elflink.h (elf_link_record_local_dynamic_symbol): New function. + (struct elf_assign_sym_version_info): Delete removed_dynamic. + (bfd_elf,size_dynamic_sections): Use _bfd_strip_section_from_output + instead of elf_link_remove_section_and_adjust_dynindices. + Remove removed_dynamic code. Use _bfd_elf_link_renumber_dynsyms. + (elf_link_assign_sym_version): Remove removed_dynamic code. + (elf_link_renumber_dynsyms): Delete. + (elf_bfd_final_link): Install section and local symbols into .dynsym. + + * elf32-m68k.c (elf_m68k_adjust_dynindx): Delete. + (elf_m68k_size_dynamic_sections): Don't set section dynindicies. + (elf_m68k_finish_dynamic_sections): Don't write section dynsyms. + * elf32-mips.c: Similarly. + * elf32-ppc.c: Similarly. + * elf32-sparc.c: Similarly. + * elf64-alpha.c: Similarly. + * elf64-sparc.c: Similarly. + +1999-07-13 Mark Mitchell + + * elf32-mips.c (mips_elf_calculate_relocation): Do not complain + when _gp_disp is undefined. Do not check R_MIPS_LO16 for overflow + when the relocation is against _gp_disp. + +1999-07-12 Mark Mitchell + + * dwarf2.c (read_attribute): Support DW_FORM_ref8. + * elf32-mips.c (mips_elf_link_hash_entry): Change mips_32_relocs + to possibly_dynamic_relocs. Adjust usage throughout code. + (elf_mips_howto_table): Handle R_MIPS_64 correctly. + (elf_mips_ctor64_howto): Likewise. + (mips_elf_calculate_relocation): Handle R_MIPS_64 like R_MIPS_32. + Adjust indentation. + (mips_elf_relocate_section): Handle R_MIPS_64 in 32-bit mode. + (_bfd_mips_elf_check_relocs): Handle R_MIPS_64 like R_MIPS_32. + Use MIPS_ELF_GOT_SIZE to calculate the size of GOT entries. + * elf64-mips.c (elf_backend_may_use_rel_p): Define. + +1999-07-12 Ian Lance Taylor + + * Makefile.am: Rebuild dependencies. + * Makefile.in: Rebuild. + + * bfd-in.h: Remove tests of COFF_IMAGE_WITH_PE. + * bfd-in2.h: Rebuild. + + * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSED + as appropriate. Use EMPTY_HOWTO as appropriate. Fill in + structure initializations. Add casts. + * reloc.c (EMPTY_HOWTO): Define. + * bfd-in2.h: Rebuild. + * coff-h8300.c (h8300_reloc16_extra_cases): Remove useless + comparisons against 0. + * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Change + previous_ibfd_e_flags to unsigned long. + * vms.h (struct vms_private_data_struct): Change section_count to + unsigned. + * vms-gsd.c (_bfd_vms_slurp_gsd): Change psect_idx to unsigned. + (_bfd_vms_write_gsd): Change symnum to unsigned. + * vms-hdr.c (_bfd_vms_write_hdr): Change symnum to unsigned. + * vms-tir.c (etir_sta): Change psect to unsigned. + (alloc_section): Change idx to unsigned. + (tir_sta, tir_ctl): Change psect to unsigned. + (_bfd_vms_write_tir): Change len and before to bfd_size_type. + * vms.c (priv_section_count): Change to unsigned. + +1999-07-12 Andreas Schwab + + * elf32-m68k.c: Add some ATTRIBUTE_UNUSED. + * m68klinux.c: Likewise. + +1999-07-12 Ian Lance Taylor + + * Many files: Changes to avoid gcc warnings: Remove unused local + variables. Add default case to enum switches. + * coff-arm.c (bfd_arm_allocate_interworking_sections): Only + compile if not COFF_IMAGE_WITH_PE. + (record_arm_to_thumb_glue, record_thumb_to_arm_glue): Likewise. + (bfd_arm_get_bfd_for_interworking): Likewise. + (bfd_arm_process_before_allocation): Likewise. + * epoc-pei-arm.c: Don't rename bfd_arm functions. + * pei-arm.c: Likewise. + * elf32-mips.c (mips_elf_link_hash_table_create): Don't declare. + (MIPS_ELF_ADD_DYNAMIC_ENTRY): Correct last change. + (mips_elf_got16_entry): Put parens around & in body of ==. + (mips_elf_calculate_relocation): Correct test for empty string. + * vms-gsd.c: Use _bfd_error_handler rather than fprintf to + stderr. + * vms-misc.c (_bfd_vms_length_hash_symbol): Correct sprintf + format. + +1999-07-11 Ian Lance Taylor + + * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSED + as appropriate. Fill in structure initializations. Add variable + initializations. Add casts. + * dwarf1.c (parse_line_table): Change eachLine to unsigned long. + (dwarf1_unit_find_nearest_line): Change i to unsigned long. + + * elf.c (bfd_elf_hash): Change parameter from unsigned char * to + char *. + * elf-bfd.h (bfd_elf_hash): Update declaration. + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Remove casts + when calling bfd_elf_hash. + +1999-07-11 Mark Mitchell + + * libbfd.c (bfd_put_8): Make it of type `void'. + * bfd-in2.h: Regenerated. + * elf32-mips.c (MIPS_ELF_ADD_DYNAMIC_ENTRY): Conditionalize + for 32-bit hosts. + (_bfd_mips_elf_final_link): Likewise. + + * elflink.h (elf_link_read_relocs_from_section): Be type-correct. + +Thu Jul 8 12:32:23 1999 John David Anglin + + * config.bfd (hppa*-*-linux-gnu*): New target + +1999-07-07 Mark Mitchell + + * elf-bfd.h (_bfd_mips_elf_section_from_shdr): Constify. + (_bfd_mips_elf_create_dynamic_sections): New function. + (_bfd_mips_elf_add_symbol_hook): Likewise. + (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. + (_bfd_mips_elf_finish_dynamic_symbol): Likewise. + (_bfd_mips_elf_finish_dynamic_sections): Likewise. + (_bfd_mips_elf_gc_mark_hook): Likewise. + (_bfd_mips_elf_gc_sweep_hook): Likewise. + (_bfd_mips_elf_always_size_sections): Likewise. + (_bfd_mips_elf_size_dynamic_sections): Likewise. + (_bfd_mips_elf_check_relocs): Likewise. + (_bfd_mips_elf_link_hash_table_create): Likewise. + (_bfd_mips_elf_print_private_data): Likewise. + (_bfd_mips_elf_link_output_symbol_hook): Likewise. + (_bfd_mips_elf_final_link): Likewise. + (_bfd_mips_elf_additional_program_headers): Likewise. + (_bfd_mips_elf_modify_segment_map): Likewise. + (_bfd_mips_elf_relocate_section): Likewise. + * elf32-mips.c (mips_elf32_object_p): Move contents into + _bfd_mips_elf_object_p. + (mips_elf_additional_program_headers): Rename to + _bfd_mips_elf_additional_program_headers. + (mips_elf_modify_segment_map): Rename to + _bfd_mips_elf_modify_segment_map. + (elf_mips_abi_name): Change prototype. + (mips_elf32_section_from_shdr): Merge into + _bfd_mips_elf_section_from_shdr. + (mips_elf32_section_processing): Merge into + _bfd_mips_elf_section_processing. + (mips_elf_final_link): Rename to _bfd_mips_elf_final_link. Invoke + the right back-end ELF linker. + (mips_elf_relocate_section): Rename to + _bfd_mips_elf_relocate_section. Clean up. Adjust for 64-bit code. + (mips_elf_link_output_symbol_hook): Rename to + _bfd_mips_elf_link_output_symbol_hook. + (mips_elf_create_dynamic_section): Rename to + _bfd_mips_elf_create_dynamic_section. + (mips_elf_check_relocs): Rename to _bfd_mips_elf_check_relocs. + Adjust for 64-bit code. Use mips_elf_got_section. + (mips_elf_adjust_dynamic_symbol): Rename to + _bfd_mips_elf_adjust_dynamic_symbol. Use + mips_elf_allocate_dynamic_relocations. + (mips_elf_finish_dynamic_symbol): Rename to + _bfd_mips_elf_finish_dynamic_symbol. Use mips_elf_got_section. + Adjust for 64-bit code. + (mips_elf_finish_dynamic_sections): Rename to + _bfd_mips_elf_finish_dynamic_sections. Adjust for 64-bit code. + (mips_elf_always_size_sections): Rename to + _bfd_mips_elf_always_size_sections. + (mips_elf_add_symbol_hook): Rename to + _bfd_mips_elf_add_symbol_hook. + (mips_elf_next_lo16_addend): Constify. + (mips_elf_calculate_relocation): Likewise. + (mips_elf_obtain_contents): Likewise. + (mips_elf_perform_relocation): Likewise. + (mips_elf_create_dynamic_relocation): Likewise. + (mips_elf_allocate_dynamic_relocations): New function. + (MIPS_ELF_REL_DYN_SECTION_NAME): New macro. + (MIPS_ELF_REL_SIZE): Likewise. + (MIPS_ELF_DYN_SIZE): Likewise. + (MIPS_ELF_GOT_SIZE): Likewise. + (MIPS_ELF_SYM_SIZE): Likewise. + (MIPS_ELF_LOG_FILE_ALIGN): Likewise. + (MIPS_ELF_GET_WORD): Likewise. + (MIPS_ELF_PUT_WORD): Likewise. + (MIPS_ELF_ADD_DYNAMIC_ENTRY): Likewise. + (STUB_LW): Conditionalize for 64-bit value. + (elf_mips_howto_table): Add R_MIPS_HIGHER and R_MIPS_HIGHEST + entries. + (_bfd_mips_elf_merge_private_bfd_data): Merge e_ident[EI_CLASS]. + Check it for inconsistency. + (_bfd_mips_elf_print_private_bfd_data): Print ABI=64 for 64-bit + ABI. + (_bfd_mips_elf_fake_sections): Remove duplicate handling of + .msym. + (mips_elf_global_got_index): Use MIPS_ELF_GOT_SIZE. + (mips_elf_got_offset_from_index): Use misp_elf_got_section. + (mips_elf_create_local_got_entry): Use MIPS_ELF_GOT_SIZE. + (mips_elf_local_got_index): Likewise. + (mips_elf_got_page): Likewise. + (mips_elf_got_info): Likewise. + (mips_elf_create_dynamic_relocation): Handle 32-bit/64-bit split. + (ELF_DYNAMIC_INTERPRETER): Handle 64-bit code. + (mips_elf_create_dynamic_sections): Use MIPS_ELF_LOG_FILE_ALIGN, + instead of constant `2'. + (mips_elf_create_got_section): Tidy. Use MIPS_ELF_GOT_SIZE. + (mips_elf_create_msym_section): Use MIPS_ELF_LOG_FILE_ALIGN. + (mips_elf_size_dynamic_sections): Use + MIPS_ELF_REL_DYN_SECTION_NAME, MIPS_ELF_GOT_SIZE, + MIPS_ELF_ADD_DYNAMIC_ENTRY. Remove #if 0'd code. + Adjust all releveant entries in elf backend table. + * elf64-mips.c (mips_elf64_section_from_shdr): Remove. + (mips_elf64_section_processing): Likewise. + Adjust elf backend entries to use _bfd_mips_elf variants now + publicly available. + + * elflink.h (elf_link_create_dynamic_sections): Handle non-standard + hash-entry sizes. + (size_dynamic_sections): Likewise. + (elf_link_output_extsym): Likewise. + * elf.c: (elf_fake_sections): Likewise. + * libbfd.c (bfd_get): New macro. + (bfd_put): Likewise. + * bfd-in2.h: Regenerated. + +1999-07-07 Mark Mitchell + + * elf-bfd.h (elf_size_info): Add hash_entry_size, + int_rels_per_ext_rel, swap_dyn_out, swap_reloc_in, swap_reloc_out, + wap_reloca_in, and swap_reloca_out. + * elflink.h (elf_link_read_relocs_from_section): Adjust to handle + multiple internal relocations per external relocation. + (link_read_relocs): Likewise. + (elf_bfd_final_link): Likewise. + (elf_link_input_bfd): Likewise. + (elf_gc_mark): Likewise. + (elf_gc_smash_unused_vtentry_relocs): Likewise. + * elfcode.h (elf_swap_dyn_out): Adjust type to match + elf_swap_dyn_in. + (size_info): Add entries for new fields. + * elf64-mips.c (mips_elf64_swap_reloc_out): Enable. + (mips_elf64_be_swap_reloc_in): New function. + (mips_elf64_be_swap_reloc_out): Likewise. + (mips_elf64_be_swap_reloca_in): Likewise. + (mips_elf64_be_swap_reloca_out): Likewise. + (mips_elf64_size_info): Add entries for new fields. + +1999-07-07 Ian Lance Taylor + + * elflink.h (elf_bfd_final_link): Assert that section reloc_count + field equals the new rel_count field. + (elf_link_input_bfd): When doing a relocateable link, use the new + rel_count field rather than the reloc_count field. + (elf_reloc_link_order): Likewise. + (elf_finish_pointer_linker_section): Likewise. + + Based on patch from H.J. Lu : + * elflink.h (elf_merge_symbol): Permit a non-weak definition in a + shared library to override a weak definition in a regular object. + +Tue Jul 6 10:23:39 1999 Jeffrey A Law (law@cygnus.com) + + * libhppa.h: Revert July 2, 1999 patch. + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): T mode selectors + need to generate DLTIND relocations, not DLTREL relocations. + +1999-07-05 Nick Clifton + + * coffcode.h (coff_set_arch_mach_hook): Recognise arm 5 + architectures. + (coff_set_flags): Recognise arm 5 architectures. + + * cpu-arm.c: Add support for strongarm and arm9 cpus. + Add support for armv5 architecture. + + * archures.c: Add bfd_mach_arm_5 and bfd_mach_arm_5T. + + * reloc.c: Add new, assembler only, ARM reloc: + BFD_RELOC_ARM_ADRL_IMMEDIATE. + + * bfd-in2.h: Regenerate. + +1999-07-02 Mark Mitchell + + * dwarf2.c (parse_comp_unit): Add ABBREV_LENGTH parameter. + (_bfd_dwarf2_find_nearest_line): Add ADDR_SIZE parameter. + * elf.c (_bfd_elf_find_nearest_line): Pass it. + * elf32-arm.h (elf32_arm_find_nearest_line): Likewise. + * elf32-mips.c (ABI_64_P): New macro. + (IRIX_COMPAT): We are IRIX6-compatible if ABI_64_P. + (_bfd_mips_elf_find_nearest_line): Adjust call to + _bfd_dwarf2_find_nearest_line. + * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype. + * libbfd.h: Regenerated. + +1999-07-02 Ian Lance Taylor + + * config.bfd: Add * at the end of i[3456]86-*-unixware. + +Fri Jul 2 12:21:10 1999 Jeffrey A Law (law@cygnus.com) + + * libhppa.h (HPPA_R_ARG_RELOC): Delete. + (HPPA_R_CONSTANT, HPPA_R_ADDEND): Likewise. + +1999-07-01 Mark Mitchell + + * elf-bfd.h (bfd_elf_section_data): Add rel_count and rel_count2 + fields. + (_bfd_elf_init_reloc_shdr): New function. + * elf.c (_bfd_elf_new_section_hook): Use bfd_zalloc, rather than + bfd_alloc followed by memset. + (_bfd_elf_init_reloc_shdr): New function, split out from ... + (elf_fake_sections): Here. + (assign_section_numbers): Assign section numbers for the second + relocation section, if required. + * elflink.h (elf_link_output_relocs): New function. + (elf_link_size_reloc_section): Likewise. + (elf_bfd_final_link): Use elf_link_size_reloc_section. + (elf_link_input_bfd): Use elf_link_output_relocs. + + * elf32-mips.c (_bfd_mips_elf_fake_sections): Use + _bfd_elf_init_reloc_shdr to initialize rel_hdr2. + +Thu Jul 1 13:58:48 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Handle R_PCREL_CALL + with 22bit format. + +1999-06-28 Mark Mitchell + + * elf32-mips.c (mips_elf_got_info): Move declaration before + prototypes. Change global_gotsym to be a pointer to a hash entry, + rather than a number index. + (mips_elf_link_hash_entry): Move declaration before prototypes. + (mips_elf_irix6_finish_dynamic_symbol): New function. + (mips_elf_sign_extend): Likewise. + (mips_elf_high): Likewise. + (mips_elf_higher): Likewise. + (mips_elf_highest): Likewise. + (mips_elf_global_got_index): Likewise. + (mips_elf_local_got_index): Likewise. + (mips_elf_got_offset_from_index): Likeiwse. + (mips_elf_record_global_got_symbol): Likewise. + (mips_elf_got_page): Likewise. + (mips_elf_next_lo16_addend): Likewise. + (mips_elf_calculate_relocation): Likewise. + (mips_elf_obtain_contents): Likewise. + (mips_elf_perform_relocation): Likewise. + (mips_elf_assign_gp): Likewise. + (mips_elf_sort_hash_table_f): Likewise. + (mips_elf_sort_hash_table): Likewise. + (mips_elf_got_section): Likewise. + (mips_elf_got_info): Likewise. + (mips_elf_create_local_got_entry): Likewise. + (mips_elf_got16_entry): Likewise. + (mips_elf_create_dynamic_relocation): Likewise. + (elf_mips_howto_table): Add description of R_MIPS_SCN_DISP. + (mips_elf_final_gp): Use mips_elf_assign_gp. + (_bfd_mips_elf_symbol_processing): Don't move SHN_COMMON symbols + into SHN_SCOMMON automatically on IRIX6. + (mips_elf_add_symbol_hook): Likewise. + (mips_elf_relocate_section): Rewrite, using + mips_elf_calculate_relocation and mips_elf_perform_relocation. + (mips_elf_create_dynamic_section): Use MIPS_ELF_STUB_SECTION_NAME. + Don't deal with .rld_map on IRIX6. + (mips_elf_create_got_section): Adjust use of global_gotsym. Set + section flags appropriately for .got. + (mips_elf_check_relocs): Handle IRIX6 relocations making use of + the got. Call mips_elf_record_global_got_symbol and allocate + local got space appropriately. + (mips_elf_size_dynamic_sections): Use bfd_byte *, not unsigned + char *. Rework calculation of GOT size. Sort dynamic symbol + table entries so entries that do not require GOT entries appear at + the beginning. Don't use DT_MIPS_HIPAGENO on IRIX6. Remove dead + code dealing with DT_INIT and DT_FINI. Remove fiddling with + global_gotsym. + (mips_elf_finish_dynamic_symbol): Adjust creation of global GOT + entries. + (mips_elf_finish_dynamic_symbol): Use + mips_elf_irix6_finish_dynamic_symbol. + (mips_elf_finish_dynamic_sections): Correct off-by-one error + setting DT_MIPS_UNREFEXTNO. Adjust setting of DT_MIPS_GOTSYM for + change to global_gotsym. Set DT_MIPS_OPTIONS on IRIX6. + +1999-06-30 Ian Lance Taylor + + * elf32-mips.c (mips_elf_final_link): Don't set CPIC when doing a + relocateable link. From Ralf Baechle . + +1999-06-04 Philip Blundell + + * elf32-arm.h (elf_backend_got_header_size): Define. + (elf_backend_plt_header_size): Likewise. + +1999-06-28 Jim Pick + + * elf32-arm.h (elf32_arm_relocate_section): Mind no_undefined + +Tue Jun 29 02:25:03 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.c (elf_hppa_howto_table): Use bfd_elf_generic_reloc as + relocation function. + * elf32-hppa.c (hppa_elf_reloc): Kill unused/unwanted function. + +1999-06-27 Mark Mitchell + + * elf32-mips.c (MIPS_ELF_SRDATA_SECTION_NAME): New macro. + (MIPS_ELF_OPTIONS_SECTION_NAME): Likewise. + (MIPS_ELF_STUB_SECTION_NAME): Likewise. + (_bfd_mips_elf_section_from_shdr): Use them. + (_bfd_mips_elf_fake_sections): Likewise. Add .srdata to the list + of GP-relative sections. + (_bfd_mips_elf_set_section_contents): Use them. + (_bfd_mips_elf_section_processing): Share code between .sdata and + .lit4/.lit8 sections. Set appropriate flags for .srdata. + (mips_elf_additional_program_headers): Add handling for + PT_MIPS_OPTIONS segment on IRIX6. + (mips_elf_modify_segment_map): Likeiwse. + (mips_elf_final_link): Set EF_MIPS_CPIC when required by the ABI. + Include the options sections on IRIX6. Don't look for GP-relative + sections by name; use SHF_MIPS_GPREL instead. + (ELF_DYNAMIC_INTERPRETER): Adjust to use /usr/lib32/libc.so.1 for + the N32 ABI. + (mips_elf_create_dynamic_sections): Don't muck about with section + alignments and such on IRIX6. + (mips_elf_adjust_dynamic_symbol): Use MIPS_ELF_STUB_SECTION_NAME. + (mips_elf_size_dynamic_sections): Likewise. Adjust to handle the + fact that ELF_DYNAMIC_INTERPRETER is no longer a constant. Use + bfd_zalloc rather than bfd_alloc and memset. + (mips_elf_finish_dynamic_symbol): Use MIPS_ELF_STUB_SECTION_NAME. + Don't assert the existence of .rld_map on IRIX6. + (mips_elf_finish_dynamic_sections): Use MIPS_ELF_STUB_SECTION_NAME. + + * elf32-mips.c (mips_elf_adjust_dynindx): Remove. + (mips_elf_size_dynamic_sections): Use _bfd_elf_link_adjust_dynindx + instead. + +1999-06-26 Mark Mitchell + + * elf32-mips.c (mips_elf_swap_msym_in): New function. + (mips_elf_swap_msym_out): New function. + (mips_elf_create_msym_section): Likewise. + (MIPS_ELF_MSYM_SECTION_NAME): New macro. + (_bfd_mips_elf_final_write_processing): Set sh_link for .msym. + (_bfd_mips_elf_section_from_shdr): Reject an SHT_MIPS_MSYM + section not named .msym. + (_bfd_mips_elf_fake_sections): Use MIPS_ELF_MSYM_SECTION_NAME, not + .msym directly. Set appropriate attributes for the .msym + section. + (mips_elf_link_hash_entry): Add min_dyn_reloc_index field. + (mips_elf_link_hash_newfunc): Clear it. + (mips_elf_create_dynamic_sections): Create the .msym section + on IRIX6. + (mips_elf_size_dynamic_sections): Allocate space for the + .msym section. Add a DT_MIPS_MSYM entry. + (mips_elf_finish_dynamic_symbol): Write out a .msym entry for + the symbol. + (mips_elf_finish_dynamic_sections): Assign a value for + DT_MIPS_MSYM. Add .msym entries for the section symbols as well. + + * elf32-mips.c (irix_compat_t): New enumeration. + (ABI_N32_P): New macro. + (IRIX_COMPAT): Likewise. + (SGI_COMPAT): Implement in terms of IRIX_COMPAT. + (mips_elf_relocate_section): Fix typo. + +1999-06-26 Mumit Khan + + * peicode.h (coff_swap_scnhdr_out): Mark non readonly BFD sections + as writable PE sections. + +1999-06-26 David Mosberger + + * dwarf2.c (struct arange): New type. + (struct comp_unit): Replace LOW and HIGH by member ARANGE. + (arange_add): New function. + (decode_line_info): Keep track of address ranges that a compilation + unit covers. + (comp_unit_contains_address): Return true if address is contained + in _any_ of the address ranges associated with a compilation unit. + (_bfd_dwarf2_find_nearest_line): Call comp_unit_find_nearest_line + on the first comp_unit that contains the address. + +1999-06-26 David Mosberger + + * dwarf2.c (struct dwarf2_debug): Add member dwarf_line_buffer. + (decode_line_info): Add variable STASH and initialize it to point + to the per-bfd dwarf2_debug info. Remove static variable + dwarf_line_buffer and use stash->dwarf_line_buffer in its place. + +1999-06-26 Ian Lance Taylor + + * elflink.h (elf_link_output_extsym): It's OK for a -Bsymbolic + shared library to have an undefined symbol. + + From Franz Sirl : + * elf32-ppc.c (ppc_elf_relocate_section): Fix last patch. + +Thu Jun 24 20:59:11 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.c (elf_hppa_final_write_processing): New function. + * elf32-hppa.c: Remove everything related to symbol extension + sections & records. Use the common elf_hppa_final_write_processing. + +1999-06-22 Mark Mitchell + + * elflink.h (size_dynamic_sections): Use user-specified init/fini + functions instead of _init/_fini if requested. + +1999-06-23 Ian Lance Taylor + + * elf.c (bfd_section_from_shdr): Avoid crashing on a bogus sh_link + field. + +1999-06-22 Ian Lance Taylor + + From Franz Sirl : + * elf32-ppc.c (ppc_elf_size_dynamic_sections): Set unused dynindx + field to 0, not -1. + (ppc_elf_finish_dynamic_sections): Check for positive section + dynindx field, rather than comparing against -1. + (ppc_elf_relocate_section): Only return false if undefined_symbol + or reloc_overflow fail, not always upon encountering an error. + +1999-06-22 Mark Mitchell + + * elflink.h (link_read_relocs): Explicitly cast external_relocs to + bfd_byte * before performing pointer arithmetic. + +Tue Jun 22 13:06:25 1999 Jeffrey A Law (law@cygnus.com) + + * elf-hppa.h: New file. Common stuff for elf32 and elf64 PA + support. + * elf32-hppa.c: Include elf-hppa.h. + (ARCH_SIZE): Define. + (elf_hppa_reloc_type_lookup): Delete. Found in the common code + now. + (elf32_hppa_info_to_howto): Similarly. + (elf_hppa_howto_table): Similarly. + (elf_hppa_reloc_type_lookup): Similarly. + (hppa_elf_gen_reloc_type): Similarly. + * elf32-hppa.h (ELF_HOWTO_TALBE, N_PARISC_RELOCS): Delete. + +1999-06-22 Nick Clifton + + * elf32-v850.c (v850_elf_final_link_relocate): Catch overflow + handling R_V850_22_PCREL relocation. + +1999-06-21 Ian Lance Taylor + + * coff-arm.c (arm_emit_base_file_entry): Explicitly declare return + type. + +Sun Jun 20 14:13:57 1999 Richard Henderson + + * section.c (_bfd_strip_section_from_output): Ignore sections + DISCARDed by the link script. + +1999-06-19 Ian Lance Taylor + + * elflink.h (elf_link_remove_section_and_adjust_dynindices): + Remove unused local variable spp. + + * xcofflink.c (bfd_xcoff_size_dynamic_sections): Don't crash if + the entry symbol is not set. + +Fri Jun 18 04:24:57 1999 Richard Henderson + + * elf64-alpha.c (elf64_alpha_relocate_section): Don't adjust + GPDISP or LITUSE in a relocatable link. + +Thu Jun 17 21:24:43 1999 J"orn Rennecke + + * dwarf1.c (alloc_dwarf1_unit): Allocate using bfd_zalloc. + * (alloc_dwarf1_func): Likewise. + +Wed Jun 16 03:09:57 1999 Jeffrey A Law (law@cygnus.com) + + * libhppa.h: Fix various formatting errors. + (assemble_3); Rewrite using CATENATE. + (assemble_17): Fix various bugs. + +1999-06-16 Nick Clifton + + * elf32-mcore.c (R_MCORE_RAW): Fix definition. + +1999-06-15 Richard Henderson + + * section.c (SEC_SHORT): Define. + * bfd-in2.h: Rebuild. + +1999-06-13 Mark Mitchell + + * elflink.h (elf_link_remove_section_and_adjust_dynindices): + Remove abfd parameter. Use _bfd_strip_section_from_output. + (bfd_elf_size_dynamic_sections): Adjust callers accordingly. + + * elf-bfd.h (_bfd_elf_link_adjust_dynindx): New function. + * elflink.c (_bfd_elf_link_adjust_dynindx): Define it. + * elflink.h (elf_link_remove_section_and_adjust_dynindices): New + function. + (bfd_elf_size_dynamic_sections): Use it. + +1999-06-13 Alan Modra + + * elf32-i386.c (elf_howto_table): Change R_386_PC8 from + complain_overflow_bitfield to complain_overflow_signed. + +1999-06-13 Mark Mitchell + + * elflink.h (elf_link_read_relocs_from_section): New function, + split out from ... + (elf_link_read_relocs): Here. Use it for both relocation + sections. + +1999-06-12 Mark Mitchell + + * elfcode.h (elf_slurp_reloc_table_from_section): Don't assume + asect->reloc_count is valid. + +1999-06-12 Ian Lance Taylor + + * elf32-mips.c (mips_elf32_section_processing): Permit a + SHT_MIPS_REGINFO section to have a size of 0. + +1999-06-12 David O'Brien + + * config.bfd (alpha*-*-freebsd*): New target. + (i[3456]86-*-freebsd*): Now defaults to ELF. + +1999-06-11 Ian Lance Taylor + + * reloc.c (_bfd_relocate_contents): Permit bitfield relocations to + wrap if the relocation covers the high bit of an address. + + * dwarf2.c (decode_line_info): Remove unused variable first_time. + +1999-06-10 Jakub Jelinek + + * elf64_sparc.c (sparc64_elf_relocate_section): Use R_SPARC_max_std + instead of R_SPARC_max. + (sparc64_elf_info_to_howto): Likewise. + * elf32_sparc.c (elf32_sparc_relocate_section): Likewise. + (elf32_sparc_info_to_howto): Likewise; handle vtable relocations. + +1999-06-07 Richard Henderson + + * section.c (_bfd_strip_section_from_output): Remove output + sections with no initial link_order. + +1999-06-07 Nick Clifton + + * elf32-m88k.c (ELF_MAXPAGESIZE): Define. + +Mon Jun 7 11:49:43 1999 Andreas Schwab + + * Makefile.am (SOURCE_HFILES): Add missing headers. + * Makefile.in: Regenerated. + +1999-06-06 Mark Mitchell + + * elf32-mips.c (_bfd_mips_elf_print_private_data): Recognize + the N32 ABI. + +1999-06-04 Franz Sirl + + * elf32-ppc.c (ppc_elf_relocate_section): Don't barf on out of + range undefweak symbols. + * hash.c: Add missing comma after @xref{} + * linker.c: Likewise. + +1999-06-04 Nick Clifton + + * elfxx-target.h (ELF_MAXPAGESIZE): Produce an error message + if not defined. + * elf32-gen.c (ELF_MAXPAGESIZE): Define. + * elf32-i860.c (ELF_MAXPAGESIZE): Define. + * elf32-i960.c (ELF_MAXPAGESIZE): Define. + * elf64-gen.c (ELF_MAXPAGESIZE): Define. + +1999-06-04 Ian Lance Taylor + + * Makefile.am: Rebuild dependencies. + (BFD32_BACKENDS): Add dwarf1.lo. + (BFD32_BACKENDS_CFILES): Add dwarf1.c. + * Makefile.in: Rebuild. + +1999-06-04 Nick Clifton + + * Makefile.am: Add epoc-arm-pe target. + * Makefile.in: Regenerate. + * pe-arm.c: Only redefine interworking function names if they have + not already been redefined. + * pei-arm.c: Only redefine interworking function names if they have + not already been redefined. + * epoc-pe-arm.c: Redefine interworking function names to avoid a + name space clash. + * epoc-pei-arm.c: Redefine interworking function names to avoid a + name space clash. + +1999-06-03 Nick Clifton + + * elfxx-target.h (ELF_MAXPAGESIZE): Default to 0x1000 not 1. + +Fri Jun 4 10:05:11 1999 Andreas Schwab + + * elf.c (elf_fake_sections): Undo change of 1999-05-10. + +Fri Jun 4 03:10:49 1999 J"orn Rennecke + + * elf32-sh.c (sh_elf_relax_delete_bytes): Fix setting of + start / stop for recalculating of r_addend of R_SH_SWITCH*. + +Fri Jun 4 02:53:13 1999 J"orn Rennecke + + * elf32-sh.c (sh_elf_relax_delete_bytes): Handle R_SH_SWITCH32 + in other text sections. + +Fri Jun 4 02:29:34 1999 J"orn Rennecke + + * libbfd.c (_bfd_generic_verify_endian_match): New function. + * libbfd-in.h (_bfd_generic_verify_endian_match): Declare. + * libbfd.h: Regenerate. + * coff-sh.c (sh_merge_private_data): Delete. + (coff_bfd_merge_private_bfd_data): Change to + _bfd_generic_verify_endian_match. + (elf32-sh.c): bfd_elf32_bfd_merge_private_bfd_data: Define. + +1999-06-03 Ulrich Drepper + + * elf32-arm.h: Fix typo: change ELF_MAXPAGE_SIZE to ELF_MAXPAGESIZE. + +1999-06-03 Ian Lance Taylor + + * bfd-in.h (bfd_elf32_arm_allocate_interworking_sections): Correct + prototype. + (bfd_elf32_arm_process_before_allocation): Likewise. + * bfd-in2.h: Rebuild. + +1999-06-03 David Mosberger + + * dwarf2.c (struct line_info): Add member END_SEQUENCE to keep + track of end_sequence markers. + (add_line_info): Add END_SEQUENCE arg. + (decode_line_info): Don't try to infer lo_pc and hi_pc from the + debug-line info---it doesn't work right if a compilation unit + consists of multiple discontiguous code-sequences. It would be + worthwhile to optimize for the common case where a compilation + unit results in a contiguous set of code sequences, but this is + quite tricky to get right for arbitrary DWARF2 files. + (lookup_address_in_line_info_table): Don't use the last line entry + for a compilation unit for anything with an address higher than + this line entry. Also, check for end_sequence markers to + correctly handle discontinuities. + (_bfd_dwarf2_find_nearest_line): When checking previously loaded + compilation units, check all compilation units with each->high==0 + just like when reading compilation units. + + * dwarf2.c (decode_line_info): Initialize table->files and + table->last_line to NULL to avoid segfaults due to random + values in these members. + (concat_filename): Check for out-of-range file number before + indexing filename table. Segfaults suck. + + * 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. + +1999-06-02 Mark Mitchell > + + * elf32-mips.c (elf_mips_howto_table): Add R_MIPS_JALR. + * elf64-mips.c (mips_elf64_howto_table_rel): Likewise. + (mips_elf64_howto_table_rela): Likewise. + + * elfcode.h (elf_slurp_reloc_table_from_section): New function, + split out from ... + (elf_slurp_reloc_table): Here. Use it to handle the case where a + single section has two associated relocation sections. + +1999-06-02 Mark Salter + + * coffcode.h (coff_set_alignment_hook): Set lma from s_vaddr if + COFF_WITH_PE defined. + +1999-06-02 Nick Clifton + + * pe-arm.c: Rename global arm interworking functions to avoid name + collision when all targets BFD is built. + * pei-arm.c: Ditto. + +1999-05-31 Mark Mitchell + + * elf-bfd.h (elf_backend_data): Remove use_rela_p. Add + may_use_rel_p, may_use_rela_p, default_use_rela_p. + (bfd_elf_section_data): Add use_rela_p. + * elf.c (bfd_section_from_shdr): Set use_rela_p appropriately. + (_bfd_elf_new_section_hook): Likewise. + (elf_fake_sections): Use may_use_rela_p, etc., instead of + use_rela_p. + (_bfd_elf_copy_private_section_data): Copy use_rela_p. + * elfcode.h (write_relocs): Determine whether or not use rela + relocs based on the relocation section header. + * elflink.c (_bfd_elf_create_dynamic_sections): Use default_use_rela_p + instead of use_rela_p. + * elfxx-target.h (elf_backend_may_use_relp): New macro. + (elf_backend_may_use_rela_p): Likewise. + (elf_backend_default_use_rela_p): Likewise. + (elfNN_bed): Use them. + +Wed Jun 2 12:38:49 1999 Miodrag Vallat + + * hosts/alphalinux.h (TRAD_CORE_EXTRA_SIZE_ALLOWED): Expand to 4096. + +Tue Jun 1 17:57:58 1999 Mark P. Mitchell + + * reloc.c (BFD_RELOC_MIPS_SUB): New relocation. + (BFD_RELOC_MIPS_GOT_PAGE): Likewise. + (BFD_RELOC_MIPS_GOT_OFST): Likewise. + (BFD_RELOC_MIPS_GOT_DISP): Likewise. + * bfd-in2.h: Regenerated. + * libbfd.h: Likewise. + * elf32-mips.c (mips_info_to_howto_rela): New function. + (USE_REL): Adjust for new conventions. + (MINUS_ONE): New macro. + (elf_mips_howto_table): Add R_MIPS_SUB. + (mips_r): Add entries for MIPS_SUB, MIPS_GOT_PAGE, MIPS_GOT_OFST, + and MIPS_GOT_DISP. + (mips_elf_final_write_processing): Set sh_link, not sh_info, for a + .MIPS.content section. + (_bfd_mips_elf_fake_sections): Treat all sections that begin + with .MIPS.content as .MIPS.content sections. Set + SHF_MNIPS_NOSTRIP for such section. + (elf_info_to_howto): Define to mips_info_to_howto_rela. + * elf64-mips.c (mips_r): Add entries for MIPS_SUB, MIPS_GOT_PAGE, + MIPS_GOT_OFST, and MIPS_GOT_DISP. + +Wed Jun 2 11:51:12 1999 Andreas Schwab + + * vms-misc.c (_bfd_vms_hash_newfunc): Fix use of uninitialized + variable. + + * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Avoid ambigous + `else'. + +1999-05-30 Philip Blundell + + * elf32-arm.h (elf32_arm_relocate_section): Reinstate change of + 1993-03-25 (!!). Take into account the bitmasks for the reloc so + the addend does not overflow into the rest of the word. + +1999-05-29 Nick Clifton + + * bfd-in.h: Amend prototype for + bfd_elf32_arm_process_before_allocation . + * bfd-in.h: Regenerate. + + * elfarm-oabi.c (NUM_ELEM): New macro: Compute the number of + elements in a fixed sized array. + (ARM_ELF_ABI_VERSION): Define. + (ARM_ELF_OS_ABI_VERSION): Define. + (R_ARM_THM_ABS5): Fix rightshift and size. + (R_ARM_THM_PC22): Fix size. + (R_ARM_PLT32): Define Howto. + (find_howto): New function: Locate a howto based on a reloc + number. + (elf32_arm_info_to_howto): Use find_howto if necessary. + (elf32_arm_reloc_map): Change type of field bfd_reloc_val to + bfd_reloc_code_real_type. + (elf32_arm_reloc_map[]): Add entries for BFD_RELOC_VTABLE_INHERIT + and BFD_RELOC_VTABLE_ENTRY. + (elf32_arm_reloc_type_lookup): Use find_howto if necessary. + + * elfarm-nabi.c (NUM_ELEM): New macro: Compute the number of + elements in a fixed sized array. + (ARM_ELF_ABI_VERSION): Define. + (ARM_ELF_OS_ABI_VERSION): Define. + (R_ARM_THM_ABS5): Fix rightshift and size. + (R_ARM_THM_PC22): Fix size. + (elf32_arm_info_to_howto_rel): Rename to elf32_arm_info_to_howto. + (elf32_arm_reloc_map): Change type of field bfd_reloc_val to + bfd_reloc_code_real_type. + + * elf32-arm.h (struct elf32_arm_link_hash_table): Add new field: + no_pipeline_knowledge. + (elf32_arm_link_hash_create): Initialise new field to zero. + (bfd_elf32_arm_process_before_allocation): Add new paraemter: + no_pipeline_knowledge. Use this parameter to initialise the field + in the globals data structure. + (elf32_arm_final_link_relocate): Only add in pipeline offset if + no_pipeline_knowledge is false and the binary is from an old + toolchain. + (elf32_arm_merge_private_data): Generate an error if an attempt is + made to linl together big endian and little endian code. + (elf32_arm_post_process_headers): New function: Initialise the + EI_OSABI and EI_ABIVERSION fields of the newly created ELF program + header. + (elf_backend_post_process_headers): Define. + +1999-05-28 Nick Clifton + + * elf-bfd.h (struct elf_backend_data): Add new field: + elf_backend_post_process_headers. + + * elfxx-target.h (elf_backend_post_process_headers): Define to + NULL if not already defined. + (elfNN_bed): Initialise elf_backend_post_process_headers field. + + * elf.c (prep_headers): Set the EI_OSABI and EI_ABIVERSION fields + to zero. + (_bfd_elf_compute_section_file_positions): Call + elf_backend_post_process_headers if defined. + +1999-05-28 Ian Lance Taylor + + * configure.in: Check whether getuid and getgid exist. + * archive.c: Define getuid and getgid as macros if HAVE_GETUID or + HAVE_GETGID are not defined, respectively. + (bfd_write_armap): Don't special case on _WIN32 for getuid and + getgid. + * configure.host: Set ac_cv_func_get{ug}id for *-*-windows*. + * configure, config.in: Rebuild. + +1999-05-28 Martin Dorey + + * elf32-i960.c: New file. + * elf.c (prep_headers): Handle bfd_arch_i960. + * targets.c (bfd_target_vector): Add &bfd_elf32_i960_vec. + * config.bfd (i960-*-elf*): New target. + * configure.in (bfd_elf32_i960_vec): New target vector. + * Makefile.am (BFD32_BACKENDS): Add elf32-i960.lo. + (BFD32_BACKENDS_CFILES): Add elf32-i960.c. + * Makefile.in, aclocal.m4, configure: Rebuild. + +1999-05-27 Nick Clifton + + * elfarm-oabi.c (elf32_arm_howto_table): Add entry for + R_ARM_PLT32. + (find_howto): New function: Find entries in the + elf32_arm_howto_table. + (elf32_arm_info_to_howto): Use find_howto if the entry cannot be + computed simply. + (elf32_arm_reloc_type_lookup): Add lookup for + BFD_RELOC_ARM_PLT32. + +1999-05-25 Philip Blundell + + * bfd/elf32-arm.h (elf32_arm_link_hash_newfunc): New function. + (elf32_arm_link_hash_table_create): Use above function as the + constructor for hash table entries. + (elf32_arm_relocate_section): Avoid crash when there is no output + section. + (elf32_arm_final_link_relocate): New parameter h. + (elf32_arm_relocate_section): Pass symbol hash entry to above + routine. + (elf32_arm_gc_sweep_hook, elf32_arm_check relocs): Correct + comments. + +1999-05-25 Catherine Moore + + * coff-arm.c (coff_arm_relocate_section): Don't emit + base file entries for pc-relative values. + +1999-05-25 DJ Delorie + + * peicode.h (coff_swap_sym_in): When we create the actual section + to reflect the not-there section C_SECTION symbols refer to, + change the symbol class to C_STAT as the section is now really + there. + +1999-05-24 Philip Blundell + + * elf32-arm.h (elf32_arm_relocate_section): Undo change of + 1999-03-25. + +Mon May 17 13:35:35 1999 Stan Cox + + * coff-arm.c (_bfd_coff_arm_set_private_flags): Changed + F_PIC_INT to F_PIC. + * coffcode.h (coff_set_arch_mach_hook): Added F_ARM_2a, and + F_ARM_3M labels. Changed F_PIC_INT to F_PIC. + +1999-05-16 Nick Clifton + + * coff-mcore.c (in_reloc_p): Reinstate. + +1999-05-15 Nick Clifton + + * reloc.c (BFD_RELOC_MCORE_RVA): Define. + * bfd-in2.h: Regenerate. + * coff-mcore.c (in_reloc_p): Remove defintion. + (mcore_coff_howto): Add IMAGE_REL_MCORE_RVA. + (mcore_coff_reloc_type_lookup): Map BFD_RELOC_RVA to + IMAGE_REL_MCORE_RVA. + (coff_mcore_rtype_to_howto): Add special processing for + IMAGE_REL_MCORE_RVA. + (coff_mcore_relocate_section): Add support for + IMAGE_REL_MCORE_RVA. + * elf32-mcore (mcore_elf_howto_): Add R_MCORE_RELATIVE. + (mcore_elf_reloc_type_lookup): Map BFD_RELOC_RVA to + R_MCORE_RELATIVE. + (mcore_elf_relocate_section): Delete redundant case labels. + +Fri May 14 10:59:55 1999 Andreas Schwab + + * elf32-arm.h (elf32_arm_relocate_section): Fix operator + precedence between bit-and and comparison. + +Thu May 13 09:45:23 1999 Joel Sherrill (joel@OARcorp.com) + + * config.bfd (i[3456]86*-*-rtems*, m68k*-*-rtems*): Added to + list of target formats (targ_selvecs). + (i[3456]86*-*-rtemself*, mips*el-*-rtems*): New targets. + (powerpcle*-*rtems*, sh-*-rtemself*): New targets. + +1999-05-10 DJ Delorie + + * ecoff.c (_bfd_ecoff_write_armap): give the symtab element a + reasonable mode until "ar x" is smart enough to skip it (fixes + gcc/libgcc.a builds on mips-ecoff targets + + * coffcode.h (styp_to_sec_flags): Explain how COMDATs are supposed + to work. Hack to support MS import libraries, which use different + COMDAT types than GNU. + (coff_slurp_symbol_table): C_SECTION symbols are local; they refer + to implied zero-length sections (see peicode below) + * coffgen.c (coff_get_normalized_symtab): Properly read long MS + filename symbols, which use one *or more* auxents. + * coffswap.h (coff_swap_aux_in): ditto + * peicode.h (coff_swap_sym_in): Build the implied zero-length + sections + +Tue May 11 15:51:58 1999 Jeffrey A Law (law@cygnus.com) + + * elf32-v850.c (v850_elf_howto_table): Make partial_inplace false + for all relocations. + +1999-05-10 Catherine Moore + + * bfd-in.h (bfd_arm_allocate_interworking_sections): Static + if COFF_IMAGE_WITH_PE. + (bfd_arm_process_before_allocation): Likewise. + (bfd_arm_get_bfd_for_interworking): Likewise. + * coff-arm.c: Likewise. + * bfd-in2.h: Regenerate. + * configure.in (armpe_little_vec): Remove coff-arm.lo. + (armpe_big_vec): Likewise. + * configure: Rebuild. + +1999-05-10 Nick Clifton + + * elf.c (elf_fake_sections): Check for .rel. as start of rel + section, not just .rel. Same for .rela. + +1999-05-07 Nick Clifton + + * coff-mcore.c (coff_mcore_relocate_section): Replace assert about + endianism with an error message. + +Thu May 6 17:09:09 1999 Fred Fish + + * dwarf2.c (read_abbrevs): Change cast of dwarf_abbrev_buffer + assignment from "unsigned char *" to "char *". + (decode_line_info): Likewise for dwarf_line_buffer assignment. + +1999-05-05 Catherine Moore + + * coff-arm.c (coff_arm_relocate_section): Add one to + address of ARM_RVA32 thumb functions. + +1999-05-05 Catherine Moore + + * elf32-m68k.c (elf32_m68k_set_private_flags): New. + (elf32_m68k_copy_private_bfd_data): New. + (elf32_m68k_merge_private_bfd_data): New. + (elf32_m68k_print_private_bfd_data): New. + (CPU32_FLAG): Define. + (PLT_CPU32_ENTRY_SIZE): Define. + (elf_cpu32_plt0_entry): Declare. + (elf_cpu32_plt_entry): Declare. + (elf_m68k_adjust_dynamic_symbol): Generate cpu32 plt entries. + (elf_m68k_finish_dynamic_symbol): Likewise. + (elf_m68k_finish_dynamic_sections): Likewise. + (elf_backend_plt_header_size): Remove definition. + (bfd_elf32_bfd_copy_private_bfd_data): Define. + (bfd_elf32_bfd_merge_private_bfd_data): Define. + (bfd_elf32_bfd_set_private_flags): Define. + (bfd_elf32_bfd_print_private_bfd_data): Define. + +Mon May 3 09:24:49 1999 Jeffrey A Law (law@cygnus.com) + + * som.c (som_fixup_formats): Fix comments for R_SHORT_PCREL_MODE + and R_LONG_PCREL_MODE. + 1999-04-29 Nick Clifton * coff-mcore.c (coff_mcore_relocate_section): Fix typos. @@ -29,7 +3265,7 @@ Fri Apr 28 16:36:19 1999 Stan Cox * libbfd.h: Rebuild. Sat Apr 17 20:55:15 1999 Catherine Moore - + * 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. @@ -127,7 +3363,7 @@ Sat Apr 10 15:12:09 1999 Richard Henderson * configure.in: Add support for MCore targets. * configure: Regenerate. * archures.c: Add support for MCore architecture. - * bfd-in2.h: Regenerate. + * 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. @@ -197,11 +3433,11 @@ Sat Apr 10 15:12:09 1999 Richard Henderson 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 + * 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 * elf.c (elf_map_symbols): Handle the case where section @@ -217,8 +3453,8 @@ Sat Apr 10 15:12:09 1999 Richard Henderson 1999-03-25 Philip Blundell * config.bfd: Eliminate redundancy in checks for Linux/ARM. - - * elf32-arm.h (elf32_arm_relocate_section): Take the rightshift into + + * 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 @@ -312,7 +3548,7 @@ Thu Feb 18 18:07:43 1999 Ian Lance Taylor The following patches are from: Scott Bambrough - + * libaout.h (M_ARM6_NETBSD): Set to 143. * reloc.c: Add ARM PIC relocs: BFD_RELOC_ARM_GOT12, @@ -331,7 +3567,7 @@ Thu Feb 18 18:07:43 1999 Ian Lance Taylor (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_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. @@ -349,7 +3585,7 @@ Thu Feb 18 18:07:43 1999 Ian Lance Taylor (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 * elf32-mips.c (_bfd_mips_elf_section_from_shdr): Make reginfo @@ -357,15 +3593,15 @@ Wed Feb 17 12:02:26 1999 Stan Cox (_bfd_mips_elf_fake_sections): Likewise. Wed Feb 17 12:07:23 1999 Andreas Schwab - - * 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. + + * 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 @@ -432,21 +3668,21 @@ Tue Feb 2 21:38:28 1999 Ian Lance Taylor Tue Feb 2 18:16:43 1999 Catherine Moore - * 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. + * 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 - * 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. + * 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 @@ -456,25 +3692,25 @@ Mon Feb 1 19:49:21 1999 Catherine Moore Mon Feb 1 12:21:47 1999 Catherine Moore - * targets.c (bfd_target_vector): Add bfd_elf32_littlearm_oabi_vec - and bfd_elf32_bigarm_oabi_vec. + * 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 - * 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. + * 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 @@ -519,13 +3755,13 @@ Wed Jan 27 13:35:35 1999 Stan Cox 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 * elf32-fr30.c (fr30_elf_howto_table): Fix name of R_FR30_48 - relocation. + relocation. (fr30_final_link_relocate): Use computed value as result of - relocation. + relocation. 1999-01-26 Frank Ch. Eigler @@ -544,16 +3780,16 @@ Mon Jan 18 03:35:35 1999 Ian Lance Taylor Tue Dec 22 15:21:41 1998 Catherine Moore - * archures.c (bfd_mach_i386_i386_intel_syntax): Define. - * bfd-in2.h: Likewise. - * cpu-i386.c (bfd_i386_arch_intel_syntax): New. + * 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 * 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_mips_elf_final_write_processing): bfd_mach_mips4111 -> E_MIPS_ARCH_3 | E_MIPS_MACH_4111. 1998-12-15 Gavin Romig-Koch @@ -563,7 +3799,7 @@ Tue Dec 22 15:21:41 1998 Catherine Moore 1998-12-12 Gavin Romig-Koch - * elf32-mips.c (_bfd_mips_elf_final_write_processing): + * elf32-mips.c (_bfd_mips_elf_final_write_processing): Handle bfd_mach_mips4300. 1998-12-11 Ulrich Drepper @@ -911,16 +4147,16 @@ Tue Nov 10 13:37:36 1998 Felix Lee Tue Nov 10 14:31:01 1998 Catherine Moore - * 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. + * 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 @@ -1002,12 +4238,12 @@ Sat Oct 31 20:10:09 1998 Jeffrey A Law (law@cygnus.com) Mon Oct 19 20:03:21 1998 Catherine Moore - * 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. + * 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 @@ -1028,13 +4264,13 @@ Mon Oct 19 01:47:21 1998 Felix Lee Fri Oct 16 14:07:45 1998 Catherine Moore - * 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. + * 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 @@ -1051,13 +4287,13 @@ Mon Oct 12 14:18:40 1998 Nick Clifton Tue Oct 6 09:20:44 1998 Catherine Moore - * 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. + * 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) @@ -1077,25 +4313,25 @@ Mon Oct 5 12:02:31 1998 Gavin Romig-Koch Mon Oct 5 10:06:22 1998 Catherine Moore - * elflink.h (elf_gc_sections): Do not allow garbage - collection if dynamic sections have been created. + * 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 - * 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. + * 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 - * elf32-m68k.c (elf_m68k_gc_sweep_hook): Don't assume - that dynobj exists. + * elf32-m68k.c (elf_m68k_gc_sweep_hook): Don't assume + that dynobj exists. Sun Oct 4 23:29:34 1998 David Edelsohn @@ -1123,19 +4359,19 @@ Sun Oct 4 21:19:09 1998 Ian Lance Taylor 1998-09-27 Andreas Schwab - * elflink.h (elf_link_add_object_symbols): Undo last change. + * elflink.h (elf_link_add_object_symbols): Undo last change. Wed Sep 23 16:09:31 1998 Richard Henderson - * elflink.h (elf_link_add_object_symbols): Don't record a dynamic - symbol for the indirect alias to a versioned symbol. + * 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 - * 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. + * 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 @@ -1169,13 +4405,13 @@ Thu Sep 17 17:20:36 1998 Nick Clifton Thu Sep 17 16:03:28 1998 Richard Henderson - * 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. + * 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 @@ -1192,8 +4428,8 @@ Wed Sep 16 10:34:13 1998 Nick Clifton Wed Sep 16 11:26:49 CDT 1998 Catherine Moore - * elf32-arm.c (elf32_arm_gc_mark_hook): Remove print - statement. + * elf32-arm.c (elf32_arm_gc_mark_hook): Remove print + statement. 1998-09-15 Geoff Keating @@ -1221,8 +4457,8 @@ Tue Sep 15 08:34:40 1998 Catherine Moore 1998-09-10 Geoff Keating - * elf32-ppc.c (ppc_elf_relocate_section): If dynobj is NULL, - assume there is no PLT or GOT. + * 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 @@ -1259,18 +4495,18 @@ Mon Aug 31 14:49:22 1998 Richard Henderson Mon Aug 31 10:23:40 1998 Catherine Moore - * 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. + * 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 @@ -1335,17 +4571,17 @@ Wed Aug 19 15:43:26 1998 Michael Snyder Tue Aug 18 11:48:12 1998 Catherine Moore - * elf32-arm.c: Add prefix bfd_ to elf32_arm_get_bfd_for_interworking, - elf32_arm_allocate_interworking_sections and - elf32_arm_process_before_allocation. + * 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 - * bfd-in.h: Ammend prototype for - elf32_arm_process_before_allocation to remove surplus third - argument. + * bfd-in.h: Ammend prototype for + elf32_arm_process_before_allocation to remove surplus third + argument. - * bfd-in2.h: Regenerate. + * bfd-in2.h: Regenerate. Sat Aug 15 20:55:08 1998 Richard Henderson @@ -1429,8 +4665,8 @@ Mon Aug 10 17:31:21 1998 Ian Lance Taylor Sun Aug 9 20:55:44 1998 Catherine Moore - * elf32-arm.c (elf32_arm_final_link_relocate): Rework - R_ARM_THM_RPC22 relocations. + * elf32-arm.c (elf32_arm_final_link_relocate): Rework + R_ARM_THM_RPC22 relocations. Sat Aug 8 15:15:30 1998 Richard Henderson @@ -1467,16 +4703,16 @@ Sun Aug 2 03:19:23 1998 Richard Henderson Fri Jul 31 16:38:14 1998 Catherine Moore - * 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. + * 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 @@ -1528,13 +4764,13 @@ 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. + * 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 @@ -1596,11 +4832,11 @@ Wed Jul 22 13:46:51 1998 Ian Lance Taylor Tue Jul 21 09:47:00 1998 Catherine Moore - * elf-m10200.c (mn10200_elf_final_link_relocate): - Modify range test for case R_MN10200_8. + * 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. + * 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 @@ -1749,7 +4985,7 @@ Thu Jul 2 14:59:42 1998 Klaus Kaempf 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.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) @@ -2377,7 +5613,7 @@ Tue Apr 7 16:25:31 1998 Gavin Romig-Koch * 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). + 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. @@ -2839,7 +6075,7 @@ Fri Feb 6 14:48:20 1998 Nick Clifton * 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 diff --git a/bfd/Makefile.am b/bfd/Makefile.am index a155311..f83fcf4 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = cygnus INCDIR = $(srcdir)/../include CSEARCH = -I. -I$(srcdir) -I$(INCDIR) -DEP = mkdep +MKDEP = mkdep SUBDIRS = doc po @@ -41,12 +41,14 @@ ALL_MACHINES = \ cpu-alpha.lo \ cpu-arc.lo \ cpu-arm.lo \ + cpu-avr.lo \ cpu-d10v.lo \ cpu-d30v.lo \ cpu-fr30.lo \ cpu-h8300.lo \ cpu-h8500.lo \ cpu-hppa.lo \ + cpu-i370.lo \ cpu-i386.lo \ cpu-i860.lo \ cpu-i960.lo \ @@ -58,6 +60,7 @@ ALL_MACHINES = \ cpu-mcore.lo \ cpu-mips.lo \ cpu-ns32k.lo \ + cpu-pj.lo \ cpu-powerpc.lo \ cpu-rs6000.lo \ cpu-sh.lo \ @@ -75,12 +78,14 @@ ALL_MACHINES_CFILES = \ cpu-alpha.c \ cpu-arc.c \ cpu-arm.c \ + cpu-avr.c \ cpu-d10v.c \ cpu-d30v.c \ cpu-fr30.c \ cpu-h8300.c \ cpu-h8500.c \ cpu-hppa.c \ + cpu-i370.c \ cpu-i386.c \ cpu-i860.c \ cpu-i960.c \ @@ -92,6 +97,7 @@ ALL_MACHINES_CFILES = \ cpu-mcore.c \ cpu-mips.c \ cpu-ns32k.c \ + cpu-pj.c \ cpu-powerpc.c \ cpu-rs6000.c \ cpu-sh.c \ @@ -114,6 +120,7 @@ BFD32_BACKENDS = \ aout-tic30.lo \ aout0.lo \ aout32.lo \ + armnetbsd.lo \ bout.lo \ cf-i386lynx.lo \ cf-m68klynx.lo \ @@ -144,6 +151,7 @@ BFD32_BACKENDS = \ coff-w65.lo \ coff-z8k.lo \ cofflink.lo \ + dwarf1.lo \ dwarf2.lo \ ecoff.lo \ ecofflink.lo \ @@ -151,13 +159,15 @@ BFD32_BACKENDS = \ elf32-arc.lo \ elfarm-oabi.lo \ elfarm-nabi.lo \ + elf32-avr.lo \ elf32-d10v.lo \ elf32-d30v.lo \ elf32-fr30.lo \ elf32-gen.lo \ - elf32-hppa.lo \ + elf32-i370.lo \ elf32-i386.lo \ elf32-i860.lo \ + elf32-i960.lo \ elf32-m32r.lo \ elf32-m68k.lo \ elf32-m88k.lo \ @@ -165,12 +175,15 @@ BFD32_BACKENDS = \ elf-m10300.lo \ elf32-mcore.lo \ elf32-mips.lo \ + elf32-pj.lo \ elf32-ppc.lo \ elf32-sh.lo \ elf32-sparc.lo \ elf32-v850.lo \ elf32.lo \ elflink.lo \ + epoc-pe-arm.lo \ + epoc-pei-arm.lo \ hp300bsd.lo \ hp300hpux.lo \ som.lo \ @@ -208,6 +221,11 @@ BFD32_BACKENDS = \ pei-mcore.lo \ pe-ppc.lo \ pei-ppc.lo \ + pe-sh.lo \ + pei-sh.lo \ + pe-mips.lo \ + pei-mips.lo \ + peigen.lo \ ppcboot.lo \ reloc16.lo \ riscix.lo \ @@ -232,6 +250,7 @@ BFD32_BACKENDS_CFILES = \ aout-tic30.c \ aout0.c \ aout32.c \ + armnetbsd.c \ bout.c \ cf-i386lynx.c \ cf-m68klynx.c \ @@ -262,6 +281,7 @@ BFD32_BACKENDS_CFILES = \ coff-w65.c \ coff-z8k.c \ cofflink.c \ + dwarf1.c \ dwarf2.c \ ecoff.c \ ecofflink.c \ @@ -269,13 +289,15 @@ BFD32_BACKENDS_CFILES = \ elf32-arc.c \ elfarm-oabi.c \ elfarm-nabi.c \ + elf32-avr.c \ elf32-d10v.c \ elf32-d30v.c \ elf32-fr30.c \ elf32-gen.c \ - elf32-hppa.c \ + elf32-i370.c \ elf32-i386.c \ elf32-i860.c \ + elf32-i960.c \ elf32-m32r.c \ elf32-m68k.c \ elf32-m88k.c \ @@ -283,12 +305,15 @@ BFD32_BACKENDS_CFILES = \ elf-m10300.c \ elf32-mcore.c \ elf32-mips.c \ + elf32-pj.c \ elf32-ppc.c \ elf32-sh.c \ elf32-sparc.c \ elf32-v850.c \ elf32.c \ elflink.c \ + epoc-pe-arm.c \ + epoc-pei-arm.c \ hp300bsd.c \ hp300hpux.c \ som.c \ @@ -326,6 +351,11 @@ BFD32_BACKENDS_CFILES = \ pei-mcore.c \ pe-ppc.c \ pei-ppc.c \ + pe-sh.c \ + pei-sh.c \ + pe-mips.c \ + pei-mips.c \ + peigen.c \ ppcboot.c \ reloc16.c \ riscix.c \ @@ -409,11 +439,11 @@ 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 \ + ecoffswap.h elf32-arm.h elfcode.h elfcore.h \ + elflink.h freebsd.h genlink.h go32stub.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 + libnlm.h liboasys.h libpei.h netbsd.h nlm-target.h nlmcode.h \ + nlmswap.h ns32k.h peicode.h som.h vms.h HFILES = \ elf32-target.h elf64-target.h targmatch.h \ @@ -462,8 +492,9 @@ noinst_LIBRARIES = libbfd.a libbfd_a_SOURCES = stamp-lib: libbfd.la - if [ -f .libs/libbfd.a ]; then \ - cp .libs/libbfd.a libbfd.tmp; \ + libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \ + if [ -f $$libtooldir/libbfd.a ]; then \ + cp $$libtooldir/libbfd.a libbfd.tmp; \ $(SHELL) $(srcdir)/../move-if-change libbfd.tmp libbfd.a; \ else true; fi touch stamp-lib @@ -512,25 +543,25 @@ install-data-local: $(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 +# 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) MKDEP=$(MKDEP) DEP1 + sed -f dep.sed 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 +DEP1: $(CFILES) + rm -f DEP2 DEP2a + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP2 + echo > DEP2a + $(MKDEP) -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 \ @@ -538,19 +569,19 @@ dep.sed: dep-in.sed config.status -e 's!@INCDIR@!$(INCDIR)!' \ -e 's!@SRCDIR@!$(srcdir)!' -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am host-aout.lo: Makefile @@ -613,7 +644,7 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES) 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 \ +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. @@ -666,6 +697,7 @@ 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-avr.lo: cpu-avr.c cpu-d10v.lo: cpu-d10v.c cpu-d30v.lo: cpu-d30v.c cpu-fr30.lo: cpu-fr30.c @@ -683,6 +715,7 @@ 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-pj.lo: cpu-pj.c cpu-powerpc.lo: cpu-powerpc.c cpu-rs6000.lo: cpu-rs6000.c cpu-sh.lo: cpu-sh.c @@ -715,6 +748,9 @@ aout0.lo: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.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 +armnetbsd.lo: armnetbsd.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 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 \ @@ -792,6 +828,9 @@ 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 +dwarf1.lo: dwarf1.c $(INCDIR)/libiberty.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf.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 @@ -817,6 +856,9 @@ 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-avr.lo: elf32-avr.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/avr.h $(INCDIR)/elf/reloc-macros.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 @@ -829,16 +871,18 @@ elf32-fr30.lo: elf32-fr30.c elf-bfd.h $(INCDIR)/elf/common.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-i370.lo: elf32-i370.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.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-i960.lo: elf32-i960.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/i960.h $(INCDIR)/elf/reloc-macros.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 @@ -865,6 +909,9 @@ elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.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-pj.lo: elf32-pj.c $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/pj.h $(INCDIR)/elf/reloc-macros.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 @@ -883,6 +930,13 @@ elf32.lo: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.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 +epoc-pe-arm.lo: epoc-pe-arm.c 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 libpei.h +epoc-pei-arm.lo: epoc-pei-arm.c 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 \ + libpei.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 @@ -963,28 +1017,42 @@ pc532-mach.lo: pc532-mach.c libaout.h $(INCDIR)/bfdlink.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 libpei.h +pe-mips.lo: pe-mips.c $(INCDIR)/coff/mipspe.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \ + peicode.h +pei-mips.lo: pei-mips.c pe-mips.c $(INCDIR)/coff/mipspe.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h +pe-sh.lo: pe-sh.c coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ + coffcode.h peicode.h +pei-sh.lo: pei-sh.c coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ + coffcode.h peicode.h +peigen.lo: peigen.c $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h \ + $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h libpei.h ppcboot.lo: ppcboot.c reloc16.lo: reloc16.c $(INCDIR)/bfdlink.h genlink.h \ $(INCDIR)/coff/internal.h libcoff.h diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 9258df1..322ecda 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -89,14 +89,13 @@ 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@ +OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ POFILES = @POFILES@ POSUB = @POSUB@ @@ -118,7 +117,7 @@ AUTOMAKE_OPTIONS = cygnus INCDIR = $(srcdir)/../include CSEARCH = -I. -I$(srcdir) -I$(INCDIR) -DEP = mkdep +MKDEP = mkdep SUBDIRS = doc po @@ -157,12 +156,14 @@ ALL_MACHINES = \ cpu-alpha.lo \ cpu-arc.lo \ cpu-arm.lo \ + cpu-avr.lo \ cpu-d10v.lo \ cpu-d30v.lo \ cpu-fr30.lo \ cpu-h8300.lo \ cpu-h8500.lo \ cpu-hppa.lo \ + cpu-i370.lo \ cpu-i386.lo \ cpu-i860.lo \ cpu-i960.lo \ @@ -174,6 +175,7 @@ ALL_MACHINES = \ cpu-mcore.lo \ cpu-mips.lo \ cpu-ns32k.lo \ + cpu-pj.lo \ cpu-powerpc.lo \ cpu-rs6000.lo \ cpu-sh.lo \ @@ -192,12 +194,14 @@ ALL_MACHINES_CFILES = \ cpu-alpha.c \ cpu-arc.c \ cpu-arm.c \ + cpu-avr.c \ cpu-d10v.c \ cpu-d30v.c \ cpu-fr30.c \ cpu-h8300.c \ cpu-h8500.c \ cpu-hppa.c \ + cpu-i370.c \ cpu-i386.c \ cpu-i860.c \ cpu-i960.c \ @@ -209,6 +213,7 @@ ALL_MACHINES_CFILES = \ cpu-mcore.c \ cpu-mips.c \ cpu-ns32k.c \ + cpu-pj.c \ cpu-powerpc.c \ cpu-rs6000.c \ cpu-sh.c \ @@ -232,6 +237,7 @@ BFD32_BACKENDS = \ aout-tic30.lo \ aout0.lo \ aout32.lo \ + armnetbsd.lo \ bout.lo \ cf-i386lynx.lo \ cf-m68klynx.lo \ @@ -262,6 +268,7 @@ BFD32_BACKENDS = \ coff-w65.lo \ coff-z8k.lo \ cofflink.lo \ + dwarf1.lo \ dwarf2.lo \ ecoff.lo \ ecofflink.lo \ @@ -269,13 +276,15 @@ BFD32_BACKENDS = \ elf32-arc.lo \ elfarm-oabi.lo \ elfarm-nabi.lo \ + elf32-avr.lo \ elf32-d10v.lo \ elf32-d30v.lo \ elf32-fr30.lo \ elf32-gen.lo \ - elf32-hppa.lo \ + elf32-i370.lo \ elf32-i386.lo \ elf32-i860.lo \ + elf32-i960.lo \ elf32-m32r.lo \ elf32-m68k.lo \ elf32-m88k.lo \ @@ -283,12 +292,15 @@ BFD32_BACKENDS = \ elf-m10300.lo \ elf32-mcore.lo \ elf32-mips.lo \ + elf32-pj.lo \ elf32-ppc.lo \ elf32-sh.lo \ elf32-sparc.lo \ elf32-v850.lo \ elf32.lo \ elflink.lo \ + epoc-pe-arm.lo \ + epoc-pei-arm.lo \ hp300bsd.lo \ hp300hpux.lo \ som.lo \ @@ -326,6 +338,11 @@ BFD32_BACKENDS = \ pei-mcore.lo \ pe-ppc.lo \ pei-ppc.lo \ + pe-sh.lo \ + pei-sh.lo \ + pe-mips.lo \ + pei-mips.lo \ + peigen.lo \ ppcboot.lo \ reloc16.lo \ riscix.lo \ @@ -351,6 +368,7 @@ BFD32_BACKENDS_CFILES = \ aout-tic30.c \ aout0.c \ aout32.c \ + armnetbsd.c \ bout.c \ cf-i386lynx.c \ cf-m68klynx.c \ @@ -381,6 +399,7 @@ BFD32_BACKENDS_CFILES = \ coff-w65.c \ coff-z8k.c \ cofflink.c \ + dwarf1.c \ dwarf2.c \ ecoff.c \ ecofflink.c \ @@ -388,13 +407,15 @@ BFD32_BACKENDS_CFILES = \ elf32-arc.c \ elfarm-oabi.c \ elfarm-nabi.c \ + elf32-avr.c \ elf32-d10v.c \ elf32-d30v.c \ elf32-fr30.c \ elf32-gen.c \ - elf32-hppa.c \ + elf32-i370.c \ elf32-i386.c \ elf32-i860.c \ + elf32-i960.c \ elf32-m32r.c \ elf32-m68k.c \ elf32-m88k.c \ @@ -402,12 +423,15 @@ BFD32_BACKENDS_CFILES = \ elf-m10300.c \ elf32-mcore.c \ elf32-mips.c \ + elf32-pj.c \ elf32-ppc.c \ elf32-sh.c \ elf32-sparc.c \ elf32-v850.c \ elf32.c \ elflink.c \ + epoc-pe-arm.c \ + epoc-pei-arm.c \ hp300bsd.c \ hp300hpux.c \ som.c \ @@ -445,6 +469,11 @@ BFD32_BACKENDS_CFILES = \ pei-mcore.c \ pe-ppc.c \ pei-ppc.c \ + pe-sh.c \ + pei-sh.c \ + pe-mips.c \ + pei-mips.c \ + peigen.c \ ppcboot.c \ reloc16.c \ riscix.c \ @@ -533,11 +562,11 @@ 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 \ + ecoffswap.h elf32-arm.h elfcode.h elfcore.h \ + elflink.h freebsd.h genlink.h go32stub.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 + libnlm.h liboasys.h libpei.h netbsd.h nlm-target.h nlmcode.h \ + nlmswap.h ns32k.h peicode.h som.h vms.h HFILES = \ @@ -579,7 +608,7 @@ 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 \ +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 @@ -613,7 +642,7 @@ configure.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(libbfd_a_SOURCES) $(libbfd_la_SOURCES) OBJECTS = $(libbfd_a_OBJECTS) $(libbfd_la_OBJECTS) @@ -868,7 +897,7 @@ 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; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -1006,8 +1035,9 @@ stamp-ofiles: Makefile ofiles: stamp-ofiles ; @true stamp-lib: libbfd.la - if [ -f .libs/libbfd.a ]; then \ - cp .libs/libbfd.a libbfd.tmp; \ + libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \ + if [ -f $$libtooldir/libbfd.a ]; then \ + cp $$libtooldir/libbfd.a libbfd.tmp; \ $(SHELL) $(srcdir)/../move-if-change libbfd.tmp libbfd.a; \ else true; fi touch stamp-lib @@ -1053,25 +1083,25 @@ install-data-local: $(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 +# 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) MKDEP=$(MKDEP) DEP1 + sed -f dep.sed 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 +DEP1: $(CFILES) + rm -f DEP2 DEP2a + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP2 + echo > DEP2a + $(MKDEP) -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 \ @@ -1079,19 +1109,19 @@ dep.sed: dep-in.sed config.status -e 's!@INCDIR@!$(INCDIR)!' \ -e 's!@SRCDIR@!$(srcdir)!' -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am host-aout.lo: Makefile @@ -1150,7 +1180,6 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES) 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 @@ -1196,6 +1225,7 @@ 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-avr.lo: cpu-avr.c cpu-d10v.lo: cpu-d10v.c cpu-d30v.lo: cpu-d30v.c cpu-fr30.lo: cpu-fr30.c @@ -1213,6 +1243,7 @@ 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-pj.lo: cpu-pj.c cpu-powerpc.lo: cpu-powerpc.c cpu-rs6000.lo: cpu-rs6000.c cpu-sh.lo: cpu-sh.c @@ -1245,6 +1276,9 @@ aout0.lo: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.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 +armnetbsd.lo: armnetbsd.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 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 \ @@ -1322,6 +1356,9 @@ 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 +dwarf1.lo: dwarf1.c $(INCDIR)/libiberty.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(INCDIR)/elf/dwarf.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 @@ -1347,6 +1384,9 @@ 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-avr.lo: elf32-avr.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/avr.h $(INCDIR)/elf/reloc-macros.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 @@ -1359,16 +1399,18 @@ elf32-fr30.lo: elf32-fr30.c elf-bfd.h $(INCDIR)/elf/common.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-i370.lo: elf32-i370.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.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-i960.lo: elf32-i960.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/i960.h $(INCDIR)/elf/reloc-macros.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 @@ -1395,6 +1437,9 @@ elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.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-pj.lo: elf32-pj.c $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/pj.h $(INCDIR)/elf/reloc-macros.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 @@ -1413,6 +1458,13 @@ elf32.lo: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.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 +epoc-pe-arm.lo: epoc-pe-arm.c 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 libpei.h +epoc-pei-arm.lo: epoc-pei-arm.c 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 \ + libpei.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 @@ -1493,28 +1545,42 @@ pc532-mach.lo: pc532-mach.c libaout.h $(INCDIR)/bfdlink.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 libpei.h +pe-mips.lo: pe-mips.c $(INCDIR)/coff/mipspe.h $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \ + peicode.h +pei-mips.lo: pei-mips.c pe-mips.c $(INCDIR)/coff/mipspe.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.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 + $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h +pe-sh.lo: pe-sh.c coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ + coffcode.h peicode.h +pei-sh.lo: pei-sh.c coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \ + coffcode.h peicode.h +peigen.lo: peigen.c $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h \ + $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h libpei.h ppcboot.lo: ppcboot.c reloc16.lo: reloc16.c $(INCDIR)/bfdlink.h genlink.h \ $(INCDIR)/coff/internal.h libcoff.h diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4 index dbe1c30..cac26e8 100644 --- a/bfd/acinclude.m4 +++ b/bfd/acinclude.m4 @@ -3,7 +3,7 @@ AC_DEFUN(BFD_BINARY_FOPEN, [AC_REQUIRE([AC_CANONICAL_SYSTEM]) case "${host}" in changequote(,)dnl -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows) +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) changequote([,])dnl AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;; esac])dnl @@ -24,15 +24,18 @@ 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]) + [rm -f conftest* + echo 'int main () { return 0; }' > conftest.c + bfd_cv_build_exeext= + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5 + for file in conftest.*; do + case $file in + *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + rm -f conftest* + 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 diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4 index 4358000..ca9d432 100644 --- a/bfd/aclocal.m4 +++ b/bfd/aclocal.m4 @@ -15,7 +15,7 @@ AC_DEFUN(BFD_BINARY_FOPEN, [AC_REQUIRE([AC_CANONICAL_SYSTEM]) case "${host}" in changequote(,)dnl -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows) +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) changequote([,])dnl AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;; esac])dnl @@ -36,15 +36,18 @@ 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]) + [rm -f conftest* + echo 'int main () { return 0; }' > conftest.c + bfd_cv_build_exeext= + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5 + for file in conftest.*; do + case $file in + *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + rm -f conftest* + 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 @@ -208,33 +211,75 @@ 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 +# serial 40 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" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| 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([AM_PROG_LD])dnl -AC_REQUIRE([AM_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_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 + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac # Check for any special flags to pass to ltconfig. -libtool_flags= +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 "$silent" = yes && libtool_flags="$libtool_flags --silent" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" 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" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext @@ -256,37 +301,41 @@ case "$host" in *-*-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*) - AM_SYS_LIBTOOL_CYGWIN +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; - +]) 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]) +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) -# Redirect the config.log output again, so that the ltconfig log is not -# clobbered by the next message. -exec 5>>./config.log -]) +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) -# AM_ENABLE_SHARED - implement the --enable-shared flag -# Usage: AM_ENABLE_SHARED[(DEFAULT)] +# 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(AM_ENABLE_SHARED, -[define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_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], +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case "$enableval" in @@ -304,26 +353,22 @@ no) enable_shared=no ;; IFS="$ac_save_ifs" ;; esac], -enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl +enable_shared=AC_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)]) +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) -# AM_ENABLE_STATIC - implement the --enable-static flag -# Usage: AM_ENABLE_STATIC[(DEFAULT)] +# 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(AM_ENABLE_STATIC, -[define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_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], +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case "$enableval" in @@ -341,28 +386,73 @@ no) enable_static=no ;; IFS="$ac_save_ifs" ;; esac], -enable_static=AM_ENABLE_STATIC_DEFAULT)dnl +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl ]) +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) -# AM_PROG_LD - find the path to the GNU or non-GNU linker -AC_DEFUN(AM_PROG_LD, + +# 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, [dnl +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_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +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]) +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. + # Accept absolute paths. changequote(,)dnl - /* | [A-Za-z]:\\*) + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' changequote([,])dnl - test -z "$LD" && LD="$ac_prog" - ;; + # 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 @@ -379,10 +469,10 @@ else fi AC_CACHE_VAL(ac_cv_path_LD, [if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -390,7 +480,7 @@ AC_CACHE_VAL(ac_cv_path_LD, 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 + test "$with_gnu_ld" != yes && break fi fi done @@ -405,11 +495,10 @@ 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_PROG_LD_GNU ]) -AC_DEFUN(AM_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 &5; then @@ -419,29 +508,31 @@ else fi]) ]) -# AM_PROG_NM - find the path to a BSD-compatible name lister -AC_DEFUN(AM_PROG_NM, +# 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 /usr/ucb /usr/ccs/bin $PATH /bin; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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" + 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" + ac_cv_path_NM="$ac_dir/nm -p" + break else - ac_cv_path_NM="$ac_dir/nm" + 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 - break fi done IFS="$ac_save_ifs" @@ -449,15 +540,85 @@ else 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) +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# 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, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + 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 + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# 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_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + 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 + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c index a75fa94..fb67b17 100644 --- a/bfd/aix386-core.c +++ b/bfd/aix386-core.c @@ -279,5 +279,7 @@ const bfd_target aix386_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index 2c11ffe..8216c7e 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -1,5 +1,6 @@ /* BFD back-end for a.out.adobe binaries. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. Based on bout.c. This file is part of BFD, the Binary File Descriptor library. @@ -372,8 +373,8 @@ aout_adobe_write_object_contents (abfd) static void aout_adobe_write_section (abfd, sect) - bfd *abfd; - sec_ptr sect; + bfd *abfd ATTRIBUTE_UNUSED; + sec_ptr sect ATTRIBUTE_UNUSED; { /* FIXME XXX */ } @@ -450,8 +451,8 @@ aout_adobe_set_arch_mach (abfd, arch, machine) static int aout_adobe_sizeof_headers (ignore_abfd, ignore) - bfd *ignore_abfd; - boolean ignore; + bfd *ignore_abfd ATTRIBUTE_UNUSED; + boolean ignore ATTRIBUTE_UNUSED; { return sizeof(struct internal_exec); } @@ -523,5 +524,7 @@ const bfd_target a_out_adobe_vec = BFD_JUMP_TABLE_LINK (aout_32), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c index beb900b..7365f9d 100644 --- a/bfd/aout-arm.c +++ b/bfd/aout-arm.c @@ -1,5 +1,5 @@ /* BFD back-end for raw ARM a.out binaries. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -87,7 +87,7 @@ reloc_howto_type MY(howto_table)[] = HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed, MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0, false), - {-1}, + EMPTY_HOWTO (-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, @@ -230,13 +230,13 @@ MY(relocatable_reloc)(howto, abfd, reloc, amount, r_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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* This is dead simple at present. */ return bfd_reloc_ok; @@ -251,7 +251,7 @@ MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; bfd_size_type addr = reloc_entry->address; @@ -343,7 +343,7 @@ MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount) struct reloc_std_external *bytes; arelent *cache_ptr; asymbol **symbols; - bfd_size_type symcount; + bfd_size_type symcount ATTRIBUTE_UNUSED; { int r_index; int r_extern; @@ -467,6 +467,8 @@ MY_swap_std_reloc_out (abfd, g, natptr) #include "aout-target.h" +extern const bfd_target aout_arm_big_vec; + const bfd_target aout_arm_little_vec = { "a.out-arm-little", /* name */ @@ -503,6 +505,8 @@ const bfd_target aout_arm_little_vec = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), + & aout_arm_big_vec, + (PTR) MY_backend_data, }; @@ -542,5 +546,7 @@ const bfd_target aout_arm_big_vec = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), + & aout_arm_little_vec, + (PTR) MY_backend_data, }; diff --git a/bfd/aout-ns32k.c b/bfd/aout-ns32k.c index c1335aa..05ac84e 100644 --- a/bfd/aout-ns32k.c +++ b/bfd/aout-ns32k.c @@ -156,7 +156,7 @@ reloc_howto_type MY(howto_table)[] = reloc_howto_type * MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct reloc_std_external *rel; int *r_index; int *r_extern; @@ -266,7 +266,7 @@ MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount) struct reloc_std_external *bytes; arelent *cache_ptr; asymbol **symbols; - bfd_size_type symcount; + bfd_size_type symcount ATTRIBUTE_UNUSED; { int r_index; int r_extern; diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 1aee07a..046417b 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -1,5 +1,5 @@ /* Define a target vector and some small routines for a variant of a.out. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -234,9 +234,9 @@ static boolean MY_bfd_copy_private_section_data static boolean MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) bfd *ibfd; - asection *isec; + asection *isec ATTRIBUTE_UNUSED; bfd *obfd; - asection *osec; + asection *osec ATTRIBUTE_UNUSED; { if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour && bfd_get_flavour (obfd) == bfd_target_aout_flavour) @@ -258,11 +258,7 @@ MY(write_object_contents) (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); @@ -645,6 +641,9 @@ const bfd_target MY(vec) = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), - (PTR) MY_backend_data, + /* Alternative_target */ + NULL, + + (PTR) MY_backend_data }; #endif /* MY_BFD_TARGET */ diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index eae6cb7..686c159 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -1,5 +1,5 @@ /* BFD back-end for TMS320C30 a.out binaries. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 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. @@ -131,7 +131,7 @@ static CONST struct aout_backend_data tic30_aout_backend_data = it. */ reloc_howto_type tic30_aout_howto_table[] = { - {-1}, + EMPTY_HOWTO (-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, @@ -142,18 +142,18 @@ reloc_howto_type tic30_aout_howto_table[] = "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} + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1) }; extern reloc_howto_type *NAME (aout, reloc_type_lookup) (); reloc_howto_type * tic30_aout_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -218,9 +218,9 @@ tic30_aout_fix_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, e arelent *reloc_entry; asymbol *symbol; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; @@ -245,9 +245,9 @@ tic30_aout_fix_32 (abfd, reloc_entry, symbol, data, input_section, arelent *reloc_entry; asymbol *symbol; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; @@ -274,11 +274,11 @@ tic30_aout_fix_pcrel_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) bfd *abfd; arelent *reloc_entry; - asymbol *symbol; + asymbol *symbol ATTRIBUTE_UNUSED; PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation = 1; bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1); @@ -590,9 +590,9 @@ tic30_aout_object_p (abfd) static boolean MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) bfd *ibfd; - asection *isec; + asection *isec ATTRIBUTE_UNUSED; bfd *obfd; - asection *osec; + asection *osec ATTRIBUTE_UNUSED; { if (bfd_get_flavour (obfd) == bfd_target_aout_flavour) obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); @@ -610,11 +610,8 @@ tic30_aout_write_object_contents (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; @@ -779,7 +776,7 @@ MY_bfd_final_link (abfd, info) enum machine_type tic30_aout_machine_type (arch, machine, unknown) enum bfd_architecture arch; - unsigned long machine; + unsigned long machine ATTRIBUTE_UNUSED; boolean *unknown; { enum machine_type arch_flags; @@ -1060,6 +1057,8 @@ const bfd_target tic30_aout_vec = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), - (PTR) MY_backend_data, + NULL, + + (PTR) MY_backend_data }; #endif /* MY_BFD_TARGET */ diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 2704eec..fa107a7 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1,5 +1,5 @@ /* BFD semi-generic back-end for a.out binaries. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -228,28 +228,35 @@ HOWTO( 7, 0, 4, 64, true, 0, complain_overflow_signed, 0,"DISP64", tr 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 }, +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-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 }, +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), HOWTO(32, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false), -{ -1 }, -{ -1 }, -{ -1 }, -{ -1 }, -{ -1 }, -{ -1 }, -{ -1 }, +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), +EMPTY_HOWTO (-1), HOWTO(40, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"BASEREL", false, 0,0x00000000, false), }; @@ -1072,7 +1079,7 @@ boolean NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end) bfd *abfd; bfd_size_type *text_size; - file_ptr *text_end; + file_ptr *text_end ATTRIBUTE_UNUSED; { struct internal_exec *execp = exec_hdr (abfd); @@ -2531,16 +2538,16 @@ NAME(aout,get_symtab_upper_bound) (abfd) /*ARGSUSED*/ alent * NAME(aout,get_lineno) (ignore_abfd, ignore_symbol) - bfd *ignore_abfd; - asymbol *ignore_symbol; + bfd *ignore_abfd ATTRIBUTE_UNUSED; + asymbol *ignore_symbol ATTRIBUTE_UNUSED; { -return (alent *)NULL; + return (alent *)NULL; } /*ARGSUSED*/ void NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -2568,7 +2575,7 @@ NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret) /*ARGSUSED*/ void NAME(aout,print_symbol) (ignore_abfd, afile, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; @@ -2878,7 +2885,7 @@ NAME(aout,find_nearest_line) int NAME(aout,sizeof_headers) (abfd, execable) bfd *abfd; - boolean execable; + boolean execable ATTRIBUTE_UNUSED; { return adata(abfd).exec_bytes_size; } @@ -4719,6 +4726,8 @@ aout_reloc_index_to_section (abfd, indx) default: abort (); } + /*NOTREACHED*/ + return NULL; } /* Relocate an a.out section using standard a.out relocs. */ @@ -5020,7 +5029,8 @@ aout_link_input_section_std (finfo, input_bfd, input_section, relocs, 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))) + (finfo->info, name, input_bfd, input_section, + r_addr, true))) return false; } @@ -5422,7 +5432,8 @@ aout_link_input_section_ext (finfo, input_bfd, input_section, relocs, 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))) + (finfo->info, name, input_bfd, input_section, + r_addr, true))) return false; } @@ -5493,7 +5504,7 @@ aout_link_reloc_link_order (finfo, o, p) int r_index; int r_extern; reloc_howto_type *howto; - file_ptr *reloff_ptr; + file_ptr *reloff_ptr = NULL; struct reloc_std_external srel; struct reloc_ext_external erel; PTR rel_ptr; diff --git a/bfd/archive.c b/bfd/archive.c index 8ac5aa4..19293af 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -1,5 +1,5 @@ /* BFD back-end for archive files (libraries). - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault. @@ -1178,7 +1178,7 @@ normalize (abfd, file) #else static const char * normalize (abfd, file) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *file; { const char *filename = strrchr (file, '/'); @@ -1340,6 +1340,14 @@ _bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen) /** A couple of functions for creating ar_hdrs */ +#ifndef HAVE_GETUID +#define getuid() 0 +#endif + +#ifndef HAVE_GETGID +#define getgid() 0 +#endif + /* 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 @@ -1901,13 +1909,8 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) 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++) diff --git a/bfd/archures.c b/bfd/archures.c index f243862..7462592 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -1,5 +1,6 @@ /* BFD library support routines for architectures. - Copyright (C) 1990, 91-98, 1999 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000 + 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. @@ -134,6 +135,7 @@ DESCRIPTION . bfd_arch_we32k, {* AT&T WE32xxx *} . bfd_arch_tahoe, {* CCI/Harris Tahoe *} . bfd_arch_i860, {* Intel 860 *} +. bfd_arch_i370, {* IBM 360/370 Mainframes *} . bfd_arch_romp, {* IBM ROMP PC/RT *} . bfd_arch_alliant, {* Alliant *} . bfd_arch_convex, {* Convex *} @@ -147,6 +149,9 @@ DESCRIPTION . bfd_arch_rs6000, {* IBM RS/6000 *} . bfd_arch_hppa, {* HP PA RISC *} . bfd_arch_d10v, {* Mitsubishi D10V *} +.#define bfd_mach_d10v 0 +.#define bfd_mach_d10v_ts2 2 +.#define bfd_mach_d10v_ts3 3 . bfd_arch_d30v, {* Mitsubishi D30V *} . bfd_arch_z8k, {* Zilog Z8000 *} .#define bfd_mach_z8001 1 @@ -154,19 +159,25 @@ DESCRIPTION . bfd_arch_h8500, {* Hitachi H8/500 *} . bfd_arch_sh, {* Hitachi SH *} .#define bfd_mach_sh 0 +.#define bfd_mach_sh2 0x20 +.#define bfd_mach_sh_dsp 0x2d .#define bfd_mach_sh3 0x30 +.#define bfd_mach_sh3_dsp 0x3d .#define bfd_mach_sh3e 0x3e +.#define bfd_mach_sh4 0x40 . 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_2a 2 .#define bfd_mach_arm_3 3 .#define bfd_mach_arm_3M 4 -.#define bfd_mach_arm_4 5 +.#define bfd_mach_arm_4 5 .#define bfd_mach_arm_4T 6 +.#define bfd_mach_arm_5 7 +.#define bfd_mach_arm_5T 8 . bfd_arch_ns32k, {* National Semiconductors ns32000 *} . bfd_arch_w65, {* WDC 65816 *} . bfd_arch_tic30, {* Texas Instruments TMS320C30 *} @@ -179,12 +190,20 @@ DESCRIPTION .#define bfd_mach_arc_base 0 . bfd_arch_m32r, {* Mitsubishi M32R/D *} .#define bfd_mach_m32r 0 {* backwards compatibility *} +.#define bfd_mach_m32rx 'x' . bfd_arch_mn10200, {* Matsushita MN10200 *} . bfd_arch_mn10300, {* Matsushita MN10300 *} .#define bfd_mach_mn10300 300 +.#define bfd_mach_am33 330 . bfd_arch_fr30, .#define bfd_mach_fr30 0x46523330 . bfd_arch_mcore, +. bfd_arch_pj, +. bfd_arch_avr, {* Atmel AVR microcontrollers *} +.#define bfd_mach_avr1 1 +.#define bfd_mach_avr2 2 +.#define bfd_mach_avr3 3 +.#define bfd_mach_avr4 4 . bfd_arch_last . }; @@ -232,6 +251,7 @@ 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_i370_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; @@ -243,6 +263,7 @@ 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_pj_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; @@ -255,6 +276,7 @@ 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; +extern const bfd_arch_info_type bfd_avr_arch; static const bfd_arch_info_type * const bfd_archures_list[] = { @@ -270,6 +292,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] = &bfd_h8300_arch, &bfd_h8500_arch, &bfd_hppa_arch, + &bfd_i370_arch, &bfd_i386_arch, &bfd_i860_arch, &bfd_i960_arch, @@ -292,7 +315,8 @@ static const bfd_arch_info_type * const bfd_archures_list[] = &bfd_w65_arch, &bfd_v850_arch, &bfd_fr30_arch, - & bfd_mcore_arch, + &bfd_mcore_arch, + &bfd_avr_arch, #endif 0 }; @@ -796,6 +820,26 @@ bfd_default_scan (info, string) arch = bfd_arch_rs6000; break; + case 7410: + arch = bfd_arch_sh; + number = bfd_mach_sh_dsp; + break; + + case 7708: + arch = bfd_arch_sh; + number = bfd_mach_sh3; + break; + + case 7729: + arch = bfd_arch_sh; + number = bfd_mach_sh3_dsp; + break; + + case 7750: + arch = bfd_arch_sh; + number = bfd_mach_sh4; + break; + default: return false; } @@ -888,9 +932,58 @@ bfd_printable_arch_mach (arch, machine) enum bfd_architecture arch; unsigned long machine; { - const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine); + const bfd_arch_info_type * ap = bfd_lookup_arch (arch, machine); if (ap) return ap->printable_name; return "UNKNOWN!"; } + +/* +FUNCTION + bfd_octets_per_byte + +SYNOPSIS + unsigned int bfd_octets_per_byte(bfd *abfd); + +DESCRIPTION + Return the number of octets (8-bit quantities) per target byte + (minimum addressable unit). In most cases, this will be one, but some + DSP targets have 16, 32, or even 48 bits per byte. + +*/ + +unsigned int +bfd_octets_per_byte (abfd) + bfd * abfd; +{ + return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd), + bfd_get_mach (abfd)); +} + +/* +FUNCTION + bfd_arch_mach_octets_per_byte + +SYNOPSIS + unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch, + unsigned long machine); + +DESCRIPTION + See bfd_octets_per_byte. + + This routine is provided for those cases where a bfd * is not + available +*/ + +unsigned int +bfd_arch_mach_octets_per_byte (arch, mach) + enum bfd_architecture arch; + unsigned long mach; +{ + const bfd_arch_info_type * ap = bfd_lookup_arch (arch, mach); + + if (ap) + return ap->bits_per_byte / 8; + return 1; +} diff --git a/bfd/armnetbsd.c b/bfd/armnetbsd.c new file mode 100644 index 0000000..3e6ee47 --- /dev/null +++ b/bfd/armnetbsd.c @@ -0,0 +1,49 @@ +/* BFD back-end for NetBSD/ARM a.out-ish binaries. + 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. */ + +#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_arm +#define DEFAULT_MID M_ARM6_NETBSD +/*#define MACHTYPE_OK(mtype) ((mtype) == M_ARM6_NETBSD)*/ + +#define MY(OP) CAT (armnetbsd_, OP) +/* This needs to start with a.out so GDB knows it is an a.out variant. */ +#define TARGETNAME "a.out-arm-netbsd" + +#if 0 +#define NAME(x,y) CAT3(aoutarm,_32_,y) + +#define aoutarm_32_get_section_contents aout_32_get_section_contents + +#define MY_bfd_reloc_type_lookup aoutarm_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)); +#endif + +#include "netbsd.h" diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 8bdbf80..1f67c0c 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -1,5 +1,5 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -626,6 +626,20 @@ extern boolean bfd_elf64_size_dynamic_sections extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); +/* Return an upper bound on the number of bytes required to store a + copy of ABFD's program header table entries. Return -1 if an error + occurs; bfd_get_error will return an appropriate code. */ +extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd)); + +/* Copy ABFD's program header table entries to *PHDRS. The entries + will be stored as an array of Elf_Internal_Phdr structures, as + defined in include/elf/internal.h. To find out how large the + buffer needs to be, call bfd_get_elf_phdr_upper_bound. + + Return the number of program header table entries read, or -1 if an + error occurs; bfd_get_error will return an appropriate code. */ +extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs)); + /* SunOS shared library support routines for the linker. */ extern struct bfd_link_needed_list *bfd_sunos_get_needed_list @@ -714,14 +728,24 @@ extern boolean bfd_arm_process_before_allocation extern boolean bfd_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +/* PE ARM Interworking support. Called from linker. */ +extern boolean bfd_arm_pe_allocate_interworking_sections + PARAMS ((struct bfd_link_info *)); + +extern boolean bfd_arm_pe_process_before_allocation + PARAMS ((bfd *, struct bfd_link_info *, int)); + +extern boolean bfd_arm_pe_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 *)); +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 *, int)); + +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 index 8e86304..fa1c5b9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1,5 +1,5 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -626,6 +626,20 @@ extern boolean bfd_elf64_size_dynamic_sections extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); +/* Return an upper bound on the number of bytes required to store a + copy of ABFD's program header table entries. Return -1 if an error + occurs; bfd_get_error will return an appropriate code. */ +extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd)); + +/* Copy ABFD's program header table entries to *PHDRS. The entries + will be stored as an array of Elf_Internal_Phdr structures, as + defined in include/elf/internal.h. To find out how large the + buffer needs to be, call bfd_get_elf_phdr_upper_bound. + + Return the number of program header table entries read, or -1 if an + error occurs; bfd_get_error will return an appropriate code. */ +extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs)); + /* SunOS shared library support routines for the linker. */ extern struct bfd_link_needed_list *bfd_sunos_get_needed_list @@ -714,15 +728,25 @@ extern boolean bfd_arm_process_before_allocation extern boolean bfd_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +/* PE ARM Interworking support. Called from linker. */ +extern boolean bfd_arm_pe_allocate_interworking_sections + PARAMS ((struct bfd_link_info *)); + +extern boolean bfd_arm_pe_process_before_allocation + PARAMS ((bfd *, struct bfd_link_info *, int)); + +extern boolean bfd_arm_pe_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 *)); +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 *, int)); + +extern boolean bfd_elf32_arm_get_bfd_for_interworking + PARAMS ((bfd *, struct bfd_link_info *)); /* And more from the source. */ void @@ -759,7 +783,7 @@ 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)) + ((void) (*((unsigned char *)(ptr)) = (unsigned char)(val))) #define bfd_put_signed_8 \ bfd_put_8 #define bfd_get_8(abfd, ptr) \ @@ -794,6 +818,20 @@ bfd_make_readable PARAMS ((bfd *abfd)); #define bfd_get_signed_64(abfd, ptr) \ BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) +#define bfd_get(bits, abfd, ptr) \ + ((bits) == 8 ? bfd_get_8 (abfd, ptr) \ + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ + : (abort (), (bfd_vma) - 1)) + +#define bfd_put(bits, abfd, val, ptr) \ + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ + : (abort (), (void) 0)) + /* Byte swapping macros for file header data. */ @@ -833,6 +871,27 @@ bfd_make_readable PARAMS ((bfd *abfd)); #define bfd_h_get_signed_64(abfd, ptr) \ BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) + /* This structure is used for a comdat section, as in PE. A comdat + section is associated with a particular symbol. When the linker + sees a comdat section, it keeps only one of the sections with a + given name and associated with a given symbol. */ + +struct bfd_comdat_info +{ + /* The name of the symbol associated with a comdat section. */ + const char *name; + + /* The local symbol table index of the symbol associated with a + comdat section. This is only meaningful to the object file format + specific code; it is not an index into the list returned by + bfd_canonicalize_symtab. */ + long symbol; + + /* If this section is being discarded, the linker uses this field + to point to the input section which is being kept. */ + struct sec *sec; +}; + typedef struct sec { /* The name of the section; the name isn't a copy, the pointer is @@ -990,6 +1049,14 @@ typedef struct sec /* This section should not be subject to garbage collection. */ #define SEC_KEEP 0x1000000 + /* This section contains "short" data, and should be placed + "near" the GP. */ +#define SEC_SMALL_DATA 0x2000000 + + /* This section contains data which may be shared with other + executables or shared objects. */ +#define SEC_SHARED 0x4000000 + /* End of section flags. */ /* Some internal packed boolean fields. */ @@ -1023,22 +1090,25 @@ typedef struct sec 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 */ + /* The size of the section in octets, 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 + /* The original size on disk of the section, in octets. 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. */ + offset in *bytes* into the output section of the first byte in the + input section (byte ==> smallest addressable unit on the + target). In most cases, if this was going to start at the + 100th octet (8-bit quantity) in the output section, this value + would be 100. However, if the target byte size is 16 bits + (bfd_octets_per_byte is "2"), this value would be 50. */ bfd_vma output_offset; @@ -1096,6 +1166,10 @@ typedef struct sec unsigned int lineno_count; + /* Optional information about a COMDAT entry; NULL if not COMDAT */ + + struct bfd_comdat_info *comdat; + /* When a section is being output, this value changes as more linenumbers are written out */ @@ -1155,9 +1229,11 @@ 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) + ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \ + : (section)->_raw_size) #define bfd_get_section_size_after_reloc(section) \ - ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) + ((section)->reloc_done ? (section)->_cooked_size \ + : (abort (), (bfd_size_type) 1)) asection * bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name)); @@ -1204,7 +1280,7 @@ bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, ase (ibfd, isection, obfd, osection)) void _bfd_strip_section_from_output - PARAMS ((asection *section)); + PARAMS ((struct bfd_link_info *info, asection *section)); enum bfd_architecture { @@ -1275,6 +1351,7 @@ enum bfd_architecture bfd_arch_we32k, /* AT&T WE32xxx */ bfd_arch_tahoe, /* CCI/Harris Tahoe */ bfd_arch_i860, /* Intel 860 */ + bfd_arch_i370, /* IBM 360/370 Mainframes */ bfd_arch_romp, /* IBM ROMP PC/RT */ bfd_arch_alliant, /* Alliant */ bfd_arch_convex, /* Convex */ @@ -1288,6 +1365,9 @@ enum bfd_architecture bfd_arch_rs6000, /* IBM RS/6000 */ bfd_arch_hppa, /* HP PA RISC */ bfd_arch_d10v, /* Mitsubishi D10V */ +#define bfd_mach_d10v 0 +#define bfd_mach_d10v_ts2 2 +#define bfd_mach_d10v_ts3 3 bfd_arch_d30v, /* Mitsubishi D30V */ bfd_arch_z8k, /* Zilog Z8000 */ #define bfd_mach_z8001 1 @@ -1295,19 +1375,25 @@ enum bfd_architecture bfd_arch_h8500, /* Hitachi H8/500 */ bfd_arch_sh, /* Hitachi SH */ #define bfd_mach_sh 0 +#define bfd_mach_sh2 0x20 +#define bfd_mach_sh_dsp 0x2d #define bfd_mach_sh3 0x30 +#define bfd_mach_sh3_dsp 0x3d #define bfd_mach_sh3e 0x3e +#define bfd_mach_sh4 0x40 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_2a 2 #define bfd_mach_arm_3 3 #define bfd_mach_arm_3M 4 -#define bfd_mach_arm_4 5 +#define bfd_mach_arm_4 5 #define bfd_mach_arm_4T 6 +#define bfd_mach_arm_5 7 +#define bfd_mach_arm_5T 8 bfd_arch_ns32k, /* National Semiconductors ns32000 */ bfd_arch_w65, /* WDC 65816 */ bfd_arch_tic30, /* Texas Instruments TMS320C30 */ @@ -1320,12 +1406,20 @@ enum bfd_architecture #define bfd_mach_arc_base 0 bfd_arch_m32r, /* Mitsubishi M32R/D */ #define bfd_mach_m32r 0 /* backwards compatibility */ +#define bfd_mach_m32rx 'x' bfd_arch_mn10200, /* Matsushita MN10200 */ bfd_arch_mn10300, /* Matsushita MN10300 */ #define bfd_mach_mn10300 300 +#define bfd_mach_am33 330 bfd_arch_fr30, #define bfd_mach_fr30 0x46523330 bfd_arch_mcore, + bfd_arch_pj, + bfd_arch_avr, /* Atmel AVR microcontrollers */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 bfd_arch_last }; @@ -1391,6 +1485,13 @@ const char * bfd_printable_arch_mach PARAMS ((enum bfd_architecture arch, unsigned long machine)); +unsigned int +bfd_octets_per_byte PARAMS ((bfd *abfd)); + +unsigned int +bfd_arch_mach_octets_per_byte PARAMS ((enum bfd_architecture arch, + unsigned long machine)); + typedef enum bfd_reloc_status { /* No errors detected */ @@ -1509,13 +1610,26 @@ struct reloc_howto_struct /* 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.*/ + /* Some formats record a relocation addend in the section contents + rather than with the relocation. For ELF formats this is the + distinction between USE_REL and USE_RELA (though the code checks + for USE_REL == 1/0). The value of this field is TRUE if the + addend is recorded with the section contents; when performing a + partial link (ld -r) the section contents (the data) will be + modified. The value of this field is FALSE if addends are + recorded with the relocation (in arelent.addend); when performing + a partial link the relocation will be modified. + All relocations for all ELF USE_RELA targets should set this field + to FALSE (values of TRUE should be looked on with suspicion). + However, the converse is not true: not all relocations of all ELF + USE_REL targets set this field to TRUE. Why this is so is peculiar + to each particular target. For relocs that aren't used in partial + links (e.g. GOT stuff) it doesn't matter what this is set to. */ 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 + byte 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 @@ -1541,6 +1655,9 @@ struct reloc_howto_struct {(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 EMPTY_HOWTO(C) \ + HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false) + #define HOWTO_PREPARE(relocation, symbol) \ { \ if (symbol != (asymbol *)NULL) { \ @@ -1773,6 +1890,17 @@ The GNU linker currently doesn't do any of this optimizing. */ BFD_RELOC_ALPHA_ELF_LITERAL, BFD_RELOC_ALPHA_LITUSE, +/* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to +process the explicit !!sequence relocations, and are mapped +into the normal relocations at the end of processing. */ + BFD_RELOC_ALPHA_USER_LITERAL, + BFD_RELOC_ALPHA_USER_LITUSE_BASE, + BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, + BFD_RELOC_ALPHA_USER_LITUSE_JSR, + BFD_RELOC_ALPHA_USER_GPDISP, + BFD_RELOC_ALPHA_USER_GPRELHIGH, + BFD_RELOC_ALPHA_USER_GPRELLOW, + /* 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. */ @@ -1828,6 +1956,10 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_MIPS_GOT_LO16, BFD_RELOC_MIPS_CALL_HI16, BFD_RELOC_MIPS_CALL_LO16, + BFD_RELOC_MIPS_SUB, + BFD_RELOC_MIPS_GOT_PAGE, + BFD_RELOC_MIPS_GOT_OFST, + BFD_RELOC_MIPS_GOT_DISP, /* i386/elf relocations */ @@ -1854,6 +1986,14 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_NS32K_DISP_16_PCREL, BFD_RELOC_NS32K_DISP_32_PCREL, +/* Picojava relocs. Not all of these appear in object files. */ + BFD_RELOC_PJ_CODE_HI16, + BFD_RELOC_PJ_CODE_LO16, + BFD_RELOC_PJ_CODE_DIR16, + BFD_RELOC_PJ_CODE_DIR32, + BFD_RELOC_PJ_CODE_REL16, + BFD_RELOC_PJ_CODE_REL32, + /* Power(rs6000) and PowerPC relocations. */ BFD_RELOC_PPC_B26, BFD_RELOC_PPC_BA26, @@ -1886,6 +2026,9 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_PPC_EMB_BIT_FLD, BFD_RELOC_PPC_EMB_RELSDA, +/* IBM 370/390 relocations */ + BFD_RELOC_I370_D12, + /* 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. */ @@ -1898,6 +2041,7 @@ not stored in the instruction. */ /* 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_ADRL_IMMEDIATE, BFD_RELOC_ARM_OFFSET_IMM, BFD_RELOC_ARM_SHIFT_IMM, BFD_RELOC_ARM_SWI, @@ -1984,39 +2128,39 @@ assumed to be 0. */ This is a 6-bit absolute reloc. */ BFD_RELOC_D30V_6, -/* This is a 6-bit pc-relative reloc with +/* 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 +/* 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 +/* 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 +/* 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 +/* 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 +/* 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 +/* 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 +/* 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. */ @@ -2162,8 +2306,77 @@ short offset into 11 bits. */ BFD_RELOC_MCORE_PCREL_IMM4BY2, BFD_RELOC_MCORE_PCREL_32, BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, + BFD_RELOC_MCORE_RVA, + +/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative +short offset into 7 bits. */ + BFD_RELOC_AVR_7_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative +short offset into 12 bits. */ + BFD_RELOC_AVR_13_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually +program memory address) into 16 bits. */ + BFD_RELOC_AVR_16_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of program memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually data memory address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_NEG, -/* These two relocations are used by the linker to determine which of +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of data memory address) into 8 bit immediate value of +SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(most high 8 bit of program memory address) into 8 bit immediate value +of LDI or SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually command address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of 16 bit command address) into 8 bit immediate value +of SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 6 bit of 22 bit command address) into 8 bit immediate +value of SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM_NEG, + +/* This is a 32 bit reloc for the AVR that stores 23 bit value +into 22 bits. */ + BFD_RELOC_AVR_CALL, + +/* 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 @@ -2177,7 +2390,7 @@ 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 +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, @@ -2236,7 +2449,7 @@ typedef struct symbol_cache_entry <> */ /* The symbol is a debugging record. The value has an arbitary - meaning. */ + meaning, unless BSF_DEBUGGING_RELOC is also set. */ #define BSF_DEBUGGING 0x08 /* The symbol denotes a function entry point. Used in ELF, @@ -2294,6 +2507,11 @@ typedef struct symbol_cache_entry others someday. */ #define BSF_OBJECT 0x10000 + /* This symbol is a debugging symbol. The value is the offset + into the section of the data. BSF_DEBUGGING should be set + as well. */ +#define BSF_DEBUGGING_RELOC 0x20000 + flagword flags; /* A pointer to the section to which this symbol is @@ -2335,6 +2553,9 @@ bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol)); int bfd_decode_symclass PARAMS ((asymbol *symbol)); +boolean +bfd_is_undefined_symclass PARAMS ((int symclass)); + void bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret)); @@ -2974,7 +3195,11 @@ CAT(NAME,_canonicalize_dynamic_reloc) long (*_bfd_canonicalize_dynamic_reloc) PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); + /* Opposite endian version of this target. */ + const struct bfd_target * alternative_target; + PTR backend_data; + } bfd_target; boolean bfd_set_default_target PARAMS ((const char *name)); @@ -2985,6 +3210,9 @@ bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd)); const char ** bfd_target_list PARAMS ((void)); +const bfd_target * +bfd_search_for_target PARAMS ((int (* search_func)(const bfd_target *, void *), void *)); + boolean bfd_check_format PARAMS ((bfd *abfd, bfd_format format)); diff --git a/bfd/bfd.c b/bfd/bfd.c index 597e8f0..e04172f 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1,5 +1,5 @@ /* Generic BFD library interface and support routines. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -618,7 +618,7 @@ DESCRIPTION /*ARGSUSED*/ void bfd_set_reloc (ignore_abfd, asect, location, count) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; sec_ptr asect; arelent **location; unsigned int count; @@ -679,6 +679,30 @@ bfd_assert (file, line) (*_bfd_error_handler) (_("bfd assertion fail %s:%d"), file, line); } +/* A more or less friendly abort message. In libbfd.h abort is + defined to call this function. */ + +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif + +void +_bfd_abort (file, line, fn) + const char *file; + int line; + const char *fn; +{ + if (fn != NULL) + (*_bfd_error_handler) + (_("BFD internal error, aborting at %s line %d in %s\n"), + file, line, fn); + else + (*_bfd_error_handler) + (_("BFD internal error, aborting at %s line %d\n"), + file, line); + (*_bfd_error_handler) (_("Please report this bug.\n")); + xexit (EXIT_FAILURE); +} /* FUNCTION diff --git a/bfd/binary.c b/bfd/binary.c index 6c63fff..c2980b0 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -58,7 +58,7 @@ static int binary_sizeof_headers PARAMS ((bfd *, boolean)); static boolean binary_mkobject (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { return true; } @@ -112,7 +112,7 @@ binary_object_p (abfd) static boolean binary_get_section_contents (abfd, section, location, offset, count) bfd *abfd; - asection *section; + asection *section ATTRIBUTE_UNUSED; PTR location; file_ptr offset; bfd_size_type count; @@ -127,7 +127,7 @@ binary_get_section_contents (abfd, section, location, offset, count) static long binary_get_symtab_upper_bound (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { return (BIN_SYMS + 1) * sizeof (asymbol *); } @@ -222,7 +222,7 @@ binary_make_empty_symbol (abfd) static void binary_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -318,8 +318,8 @@ binary_set_section_contents (abfd, sec, data, offset, size) static int binary_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -382,5 +382,7 @@ const bfd_target binary_vec = BFD_JUMP_TABLE_LINK (binary), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + NULL }; diff --git a/bfd/bout.c b/bfd/bout.c index 4ef10f5..c230e18 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -1,5 +1,6 @@ /* BFD back-end for Intel 960 b.out binaries. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 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. @@ -494,7 +495,7 @@ static reloc_howto_type howto_done_align_table[] = { static reloc_howto_type * b_out_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -1001,8 +1002,8 @@ b_out_set_arch_mach (abfd, arch, machine) static int b_out_sizeof_headers (ignore_abfd, ignore) - bfd *ignore_abfd; - boolean ignore; + bfd *ignore_abfd ATTRIBUTE_UNUSED; + boolean ignore ATTRIBUTE_UNUSED; { return sizeof(struct internal_exec); } @@ -1046,7 +1047,8 @@ get_value (reloc, link_info, input_section) { if (! ((*link_info->callbacks->undefined_symbol) (link_info, bfd_asymbol_name (symbol), - input_section->owner, input_section, reloc->address))) + input_section->owner, input_section, reloc->address, + true))) abort (); value = 0; } @@ -1452,6 +1454,8 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, #define aout_32_get_section_contents_in_window \ _bfd_generic_get_section_contents_in_window +extern const bfd_target b_out_vec_little_host; + const bfd_target b_out_vec_big_host = { "b.out.big", /* name */ @@ -1489,6 +1493,8 @@ const bfd_target b_out_vec_big_host = BFD_JUMP_TABLE_LINK (b_out), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & b_out_vec_little_host, + (PTR) 0, }; @@ -1530,5 +1536,7 @@ const bfd_target b_out_vec_little_host = BFD_JUMP_TABLE_LINK (b_out), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & b_out_vec_big_host, + (PTR) 0 }; diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index 11c9bbd..3492e75 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -36,43 +36,60 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # define SIGBUS 10 #endif -#define CRASH_INFO (0xffc) -#define CRASH_MAGIC 0xdead1234 +int crash_info_locs[] = { + 0x0250, /* mips, ppc, x86, i960 */ + 0x0400, /* m68k, mips, x86, i960 */ + 0x0FFC, /* m68k, mips, ppc, x86, i960 */ + 0x3000, /* ppc */ + 0x4FFC, /* m68k */ + -1 +}; + +#define CRASH_MAGIC 0xdead1234 +#define MASK_ADDR(x) ((x) & 0x0fffffff) /* Mask crash info address */ typedef enum { CRASH_REASON_NOTCRASHED = 0, CRASH_REASON_EXCEPTION = 1, CRASH_REASON_CORRUPT = 2, - } crashreason; +} crashreason; -struct crashinfo_external -{ - char magic[4]; /* Magic number */ +typedef struct { + 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) */ -}; + char textbase[4]; /* Base of .text section (not in V3 crash info) */ + char database[4]; /* Base of .data section (not in V3 crash info) */ + char bssbase[4]; /* Base of .bss section (not in V3 crash info) */ +} crashinfo_external; struct cisco_core_struct { int sig; }; +/* Examine the file for a crash info struct at the offset given by + CRASH_INFO_LOC. */ + static const bfd_target * -cisco_core_file_p (abfd) +cisco_core_file_validate (abfd, crash_info_loc) bfd *abfd; + int crash_info_loc; { char buf[4]; unsigned int crashinfo_offset; - struct crashinfo_external crashinfo; + crashinfo_external crashinfo; int nread; + unsigned int magic; + unsigned int version; unsigned int rambase; sec_ptr asect; struct stat statbuf; - if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0) + if (bfd_seek (abfd, crash_info_loc, SEEK_SET) != 0) return NULL; nread = bfd_read (buf, 1, 4, abfd); @@ -82,10 +99,14 @@ cisco_core_file_p (abfd) bfd_set_error (bfd_error_wrong_format); return NULL; } - crashinfo_offset = bfd_get_32 (abfd, buf); + crashinfo_offset = MASK_ADDR (bfd_get_32 (abfd, buf)); if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0) - return NULL; + { + /* Most likely we failed because of a bogus (huge) offset */ + bfd_set_error (bfd_error_wrong_format); + return NULL; + } nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd); if (nread != sizeof (crashinfo)) @@ -101,24 +122,27 @@ cisco_core_file_p (abfd) return NULL; } - if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC) + magic = bfd_get_32 (abfd, crashinfo.magic); + if (magic != CRASH_MAGIC) { bfd_set_error (bfd_error_wrong_format); return NULL; } - switch (bfd_get_32 (abfd, crashinfo.version)) + version = bfd_get_32 (abfd, crashinfo.version); + if (version == 0) { - case 0: bfd_set_error (bfd_error_wrong_format); return NULL; - case 1: + } + else if (version == 1) + { + /* V1 core dumps don't specify the dump base, assume 0 */ rambase = 0; - break; - default: - case 2: + } + else + { rambase = bfd_get_32 (abfd, crashinfo.rambase); - break; } /* OK, we believe you. You're a core file. */ @@ -211,22 +235,43 @@ cisco_core_file_p (abfd) abfd->sections = NULL; abfd->section_count = 0; + /* Create a ".reg" section to allow access to the saved + registers. */ + 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; + /* Since we don't know the exact size of the saved register info, + choose a register section size that is either the remaining part + of the file, or 1024, whichever is smaller. */ + nread = statbuf.st_size - asect->filepos; + asect->_raw_size = (nread < 1024) ? nread : 1024; 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. */ + /* Create a ".crash" section to allow access to the saved + crash information. */ + + asect = (asection *) bfd_zmalloc (sizeof (asection)); + if (asect == NULL) + goto error_return; + asect->name = ".crash"; + asect->flags = SEC_HAS_CONTENTS; + asect->vma = 0; + asect->filepos = crashinfo_offset; + asect->_raw_size = sizeof (crashinfo); + asect->next = abfd->sections; + abfd->sections = asect; + ++abfd->section_count; + + /* Create a ".data" section that maps the entire file, which is + essentially a dump of the target system's RAM. */ + asect = (asection *) bfd_zmalloc (sizeof (asection)); if (asect == NULL) goto error_return; @@ -242,6 +287,9 @@ cisco_core_file_p (abfd) return abfd->xvec; + /* Get here if we have already started filling out the BFD + and there is an error of some kind. */ + error_return: { sec_ptr nextsect; @@ -256,6 +304,22 @@ cisco_core_file_p (abfd) } } +static const bfd_target * +cisco_core_file_p (abfd) + bfd *abfd; +{ + int *crash_info_locp; + const bfd_target *target = NULL; + + for (crash_info_locp = crash_info_locs; + *crash_info_locp != -1 && target == NULL; + crash_info_locp++) + { + target = cisco_core_file_validate (abfd, *crash_info_locp); + } + return (target); +} + char * cisco_core_file_failing_command (abfd) bfd *abfd; @@ -278,9 +342,11 @@ cisco_core_file_matches_executable_p (core_bfd, exec_bfd) return true; } -const bfd_target cisco_core_vec = +extern const bfd_target cisco_core_little_vec; + +const bfd_target cisco_core_big_vec = { - "trad-core", + "cisco-ios-core-big", bfd_target_unknown_flavour, BFD_ENDIAN_BIG, /* target byte order */ BFD_ENDIAN_BIG, /* target headers byte order */ @@ -323,5 +389,57 @@ const bfd_target cisco_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & cisco_core_little_vec, + + (PTR) 0 /* backend_data */ +}; + +const bfd_target cisco_core_little_vec = + { + "cisco-ios-core-little", + 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 */ + 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_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), + + &cisco_core_big_vec, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c index bbf23ee..0374b20 100644 --- a/bfd/coff-a29k.c +++ b/bfd/coff-a29k.c @@ -1,5 +1,6 @@ /* BFD back-end for AMD 29000 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 97, 98, 1999 + 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. @@ -235,9 +236,29 @@ a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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}, + EMPTY_HOWTO (1), + EMPTY_HOWTO (2), + EMPTY_HOWTO (3), + EMPTY_HOWTO (4), + EMPTY_HOWTO (5), + EMPTY_HOWTO (6), + EMPTY_HOWTO (7), + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + EMPTY_HOWTO (13), + EMPTY_HOWTO (14), + EMPTY_HOWTO (15), + EMPTY_HOWTO (16), + EMPTY_HOWTO (17), + EMPTY_HOWTO (18), + EMPTY_HOWTO (19), + EMPTY_HOWTO (20), + EMPTY_HOWTO (21), + EMPTY_HOWTO (22), + EMPTY_HOWTO (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}, @@ -311,7 +332,7 @@ reloc_processing (relent,reloc, symbols, abfd, section) static boolean coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, syms, sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -395,7 +416,7 @@ coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -562,10 +583,10 @@ coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, /*ARGSUSED*/ static boolean coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) - bfd *obfd; - struct bfd_link_info *info; - bfd *ibfd; - asection *sec; + bfd *obfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + bfd *ibfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; struct internal_reloc *irel; boolean *adjustedp; { @@ -580,61 +601,4 @@ coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) #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 - }; +CREATE_BIG_COFF_TARGET_VEC (a29kcoff_big_vec, "coff-a29k-big", 0, SEC_READONLY, '_', NULL) diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index d841663..6bbc279 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -1,5 +1,5 @@ /* BFD back-end for ALPHA Extended-Coff files. - Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Modified from coff-mips.c by Steve Chamberlain and Ian Lance Taylor . @@ -1133,7 +1133,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, 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))) + input_bfd, input_section, rel->address, true))) goto error_return; break; case bfd_reloc_dangerous: @@ -1719,7 +1719,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, relocated. */ if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, (bfd_vma) 0))) + input_section, (bfd_vma) 0, true))) return false; addend = 0; } @@ -1921,7 +1921,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - r_vaddr - input_section->vma))) + r_vaddr - input_section->vma, true))) return false; relocation = 0; } @@ -2266,13 +2266,14 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = (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, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, 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 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL }, /* Supported architecture. */ bfd_arch_alpha, @@ -2398,5 +2399,7 @@ const bfd_target ecoffalpha_little_vec = BFD_JUMP_TABLE_LINK (_bfd_ecoff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) &alpha_ecoff_backend_data }; diff --git a/bfd/coff-apollo.c b/bfd/coff-apollo.c index 253ec89..6075d52 100644 --- a/bfd/coff-apollo.c +++ b/bfd/coff-apollo.c @@ -105,57 +105,16 @@ apollo_howto2rtype (internal) #include "coffcode.h" -const bfd_target -#ifdef TARGET_SYM - TARGET_SYM = -#else - apollocoff_vec = +#ifndef TARGET_SYM +#define TARGET_SYM 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), +#ifndef TARGET_NAME +#define TARGET_NAME "apollo-m68k" +#endif - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ #ifdef NAMES_HAVE_UNDERSCORE - '_', +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, '_', NULL) #else - 0, /* leading underscore */ +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, 0, NULL) #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 index d478ce5..2b89b84 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1,5 +1,5 @@ /* BFD back-end for ARM COFF files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -47,6 +47,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define SET_INTERWORK_FLAG( abfd, flg ) (coff_data (abfd)->flags = \ (coff_data (abfd)->flags & ~ F_INTERWORK) \ | (flg | F_INTERWORK_SET)) + +#ifndef NUM_ELEM +#define NUM_ELEM(a) ((sizeof (a)) / sizeof ((a)[0])) +#endif typedef enum {bunknown, b9, b12, b23} thumb_pcrel_branchtype; /* some typedefs for holding instructions */ @@ -89,10 +93,12 @@ 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 *)); +#ifndef COFF_IMAGE_WITH_PE 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 *)); +#endif static boolean coff_arm_merge_private_bfd_data PARAMS ((bfd *, bfd *)); static boolean coff_arm_print_private_bfd_data @@ -126,11 +132,11 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) bfd *abfd; arelent *reloc_entry; - asymbol *symbol; + asymbol *symbol ATTRIBUTE_UNUSED; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { symvalue diff; if (output_bfd == (bfd *) NULL) @@ -193,8 +199,7 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, #endif /* These most certainly belong somewhere else. Just had to get rid of - the manifest constants in the code. */ - + the manifest constants in the code. */ #define ARM_8 0 #define ARM_16 1 #define ARM_32 2 @@ -211,9 +216,127 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, #define ARM_THUMB12 13 #define ARM_THUMB23 14 +#ifdef ARM_WINCE +#undef ARM_32 +#undef ARM_RVA32 +#undef ARM_26 +#undef ARM_THUMB12 +#undef ARM_26D + +#define ARM_32 1 +#define ARM_RVA32 2 +#define ARM_26 3 +#define ARM_THUMB12 4 +#define ARM_26D 5 +#define ARM_SECTION 14 +#define ARM_SECREL 15 +#endif + static reloc_howto_type aoutarm_std_reloc_howto[] = { /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */ +#ifdef ARM_WINCE + EMPTY_HOWTO (-1), + HOWTO (ARM_32, + 0, + 2, + 32, + false, + 0, + complain_overflow_bitfield, + coff_arm_reloc, + "ARM_32", + true, + 0xffffffff, + 0xffffffff, + PCRELOFFSET), + HOWTO (ARM_RVA32, + 0, + 2, + 32, + false, + 0, + complain_overflow_bitfield, + coff_arm_reloc, + "ARM_RVA32", + 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_THUMB12, + 1, + 1, + 11, + true, + 0, + complain_overflow_signed, + coff_thumb_pcrel_12 , + "ARM_THUMB12", + false, + 0x000007ff, + 0x000007ff, + PCRELOFFSET), + HOWTO (ARM_26D, + 2, + 2, + 24, + false, + 0, + complain_overflow_dont, + aoutarm_fix_pcrel_26_done, + "ARM_26D", + true, + 0x00ffffff, + 0x0, + false), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + EMPTY_HOWTO (-1), + HOWTO (ARM_SECTION, + 0, + 1, + 16, + false, + 0, + complain_overflow_bitfield, + coff_arm_reloc, + "ARM_16", + true, + 0x0000ffff, + 0x0000ffff, + PCRELOFFSET), + HOWTO (ARM_SECREL, + 0, + 2, + 32, + false, + 0, + complain_overflow_bitfield, + coff_arm_reloc, + "ARM_32", + true, + 0xffffffff, + 0xffffffff, + PCRELOFFSET), +#else /* not ARM_WINCE */ HOWTO(ARM_8, /* type */ 0, /* rightshift */ 0, /* size */ @@ -319,7 +442,7 @@ static reloc_howto_type aoutarm_std_reloc_howto[] = 0x0, false), /* 8 is unused */ - {-1}, + EMPTY_HOWTO (-1), HOWTO( ARM_NEG16, 0, -1, @@ -397,61 +520,66 @@ static reloc_howto_type aoutarm_std_reloc_howto[] = false, 0x07ff07ff, 0x07ff07ff, - PCRELOFFSET), + PCRELOFFSET) +#endif /* not ARM_WINCE */ }; +#define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto) + #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; + bfd * abfd ATTRIBUTE_UNUSED; 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 RTYPE2HOWTO(cache_ptr, dst) \ + (cache_ptr)->howto = \ + (dst)->r_type < NUM_RELOCS \ + ? aoutarm_std_reloc_howto + (dst)->r_type \ + : NULL #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; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; bfd_vma *addendp; { - reloc_howto_type *howto; + reloc_howto_type * howto; + if (rel->r_type >= NUM_RELOCS) + return NULL; + howto = aoutarm_std_reloc_howto + rel->r_type; if (rel->r_type == ARM_RVA32) - { - *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; - } + *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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* This is dead simple at present. */ return bfd_reloc_ok; @@ -468,7 +596,7 @@ aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; bfd_size_type addr = reloc_entry->address; @@ -528,7 +656,7 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; thumb_pcrel_branchtype btype; { bfd_vma relocation = 0; @@ -696,7 +824,8 @@ 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] +#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) { @@ -708,6 +837,12 @@ coff_arm_reloc_type_lookup (abfd, code) switch (code) { +#ifdef ARM_WINCE + ASTD (BFD_RELOC_32, ARM_32); + ASTD (BFD_RELOC_RVA, ARM_RVA32); + ASTD (BFD_RELOC_ARM_PCREL_BRANCH, ARM_26); + ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12); +#else ASTD (BFD_RELOC_8, ARM_8); ASTD (BFD_RELOC_16, ARM_16); ASTD (BFD_RELOC_32, ARM_32); @@ -719,6 +854,7 @@ coff_arm_reloc_type_lookup (abfd, code) ASTD (BFD_RELOC_THUMB_PCREL_BRANCH9, ARM_THUMB9); ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12); ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23); +#endif default: return (CONST struct reloc_howto_struct *) 0; } } @@ -783,7 +919,7 @@ coff_arm_link_hash_table_create (abfd) return & ret->root.root; } -static +static void arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset) struct bfd_link_info *info; bfd *output_bfd; @@ -934,8 +1070,6 @@ 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 @@ -959,8 +1093,6 @@ 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; @@ -1099,6 +1231,13 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, howto = &fake_arm26_reloc; } +#ifdef ARM_WINCE + /* MS ARM-CE makes the reloc relative to the opcode's pc, not + the next opcode's pc, so is off by one. */ + if (howto->pc_relative && !info->relocateable) + addend -= 8; +#endif + /* 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, @@ -1211,7 +1350,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, s->contents + my_offset + 8); if (info->base_file) - arm_emit_base_file_entry (info, output_bfd, s, A2T3_OFFSET); + arm_emit_base_file_entry (info, output_bfd, s, + my_offset + 8); } @@ -1236,11 +1376,11 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, bfd_put_32 (output_bfd, tmp, contents + rel->r_vaddr - input_section->vma); - done = 1; } } +#ifndef ARM_WINCE /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12 */ else if (howto->type == ARM_THUMB23) { @@ -1319,6 +1459,9 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, /* 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); + + if (info->base_file) + arm_emit_base_file_entry (info, output_bfd, s, my_offset + 16); } else { @@ -1341,8 +1484,6 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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); } } @@ -1365,12 +1506,10 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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; } } +#endif } /* If the relocation type and destination symbol does not @@ -1396,7 +1535,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -1411,6 +1550,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, #if 1 /* THUMBEXTENSION */ if (done) rstat = bfd_reloc_ok; +#ifndef ARM_WINCE /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */ else if (! info->relocateable && howto->type == ARM_THUMB23) @@ -1525,6 +1665,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, rstat = overflow ? bfd_reloc_overflow : bfd_reloc_ok; } } +#endif else #endif /* THUMBEXTENSION */ rstat = _bfd_final_link_relocate (howto, input_bfd, input_section, @@ -1537,7 +1678,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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) + && (rel->r_type == ARM_32 || rel->r_type == ARM_RVA32)) { /* Determine if we need to set the bottom bit of a relocated address because the address is the address of a Thumb code symbol. */ @@ -1610,7 +1751,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, return true; } -#ifndef COFF_WITH_PE +#ifndef COFF_IMAGE_WITH_PE + boolean bfd_arm_allocate_interworking_sections (info) struct bfd_link_info * info; @@ -1797,6 +1939,7 @@ record_thumb_to_arm_glue (info, h) /* 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; @@ -1822,7 +1965,7 @@ bfd_arm_get_bfd_for_interworking (abfd, info) if (sec == NULL) { - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME); @@ -1836,7 +1979,7 @@ bfd_arm_get_bfd_for_interworking (abfd, info) if (sec == NULL) { - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME); @@ -1911,6 +2054,14 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) if (symndx == -1) continue; + /* If the index is outside of the range of our table, something has gone wrong. */ + if (symndx >= obj_conv_table_size (abfd)) + { + _bfd_error_handler (_("%s: illegal symbol index in reloc: %d"), + bfd_get_filename (abfd), symndx); + continue; + } + h = obj_coff_sym_hashes (abfd)[symndx]; /* If the relocation is against a static symbol it must be within @@ -1929,6 +2080,7 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) record_arm_to_thumb_glue (info, h); break; +#ifndef ARM_WINCE 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 @@ -1949,6 +2101,7 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) ; } break; +#endif default: break; @@ -1959,7 +2112,7 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) return true; } -#endif /* ! COFF_WITH_PE */ +#endif /* ! defined (COFF_IMAGE_WITH_PE) */ #define coff_bfd_reloc_type_lookup coff_arm_reloc_type_lookup #define coff_relocate_section coff_arm_relocate_section @@ -1979,8 +2132,8 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) static boolean coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) - bfd *obfd; - struct bfd_link_info *info; + bfd *obfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; bfd *ibfd; asection *sec; struct internal_reloc *irel; @@ -2183,7 +2336,7 @@ _bfd_coff_arm_set_private_flags (abfd, flags) 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)) + || (PIC_FLAG (abfd) != (flags & F_PIC)) )) return false; @@ -2289,21 +2442,16 @@ coff_arm_copy_private_bfd_data (src, dest) #define USER_LABEL_PREFIX "_" #endif +/* Like _bfd_coff_is_local_label_name, but + a) test against USER_LABEL_PREFIX, to avoid stripping labels known to be + non-local. + b) Allow other prefixes than ".", e.g. an empty prefix would cause all + labels of the form Lxxx to be stripped. */ static boolean coff_arm_is_local_label_name (abfd, name) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; 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) { @@ -2311,18 +2459,24 @@ coff_arm_is_local_label_name (abfd, name) return false; } #endif + +#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. */ - /* devo/gcc/config/dbxcoff.h defines ASM_OUTPUT_SOURCE_LINE to generate - local line numbers as .LM, so treat these as local. */ - - switch (name[0]) + if (LOCAL_LABEL_PREFIX[0] != 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. */ + int len = strlen (LOCAL_LABEL_PREFIX); + + if (strncmp (name, LOCAL_LABEL_PREFIX, len) != 0) + return false; + + /* Perform the checks below for the rest of the name. */ + name += len; } +#endif + + return name[0] == 'L'; } /* This piece of machinery exists only to guarantee that the bfd that holds @@ -2344,7 +2498,7 @@ coff_arm_link_output_has_begun (sub, info) static boolean coff_arm_final_link_postscript (abfd, pfinfo) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; struct coff_final_link_info * pfinfo; { struct coff_arm_link_hash_table * globals; @@ -2364,194 +2518,35 @@ coff_arm_final_link_postscript (abfd, pfinfo) 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 = +#ifndef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM armcoff_little_vec #endif -{ -#ifdef TARGET_LITTLE_NAME - TARGET_LITTLE_NAME, -#else - "coff-arm-little", +#ifndef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "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), +#ifndef TARGET_BIG_SYM +#define TARGET_BIG_SYM armcoff_big_vec #endif - -#ifdef TARGET_UNDERSCORE - TARGET_UNDERSCORE, /* leading underscore */ -#else - 0, /* leading underscore */ +#ifndef TARGET_BIG_NAME +#define TARGET_BIG_NAME "coff-arm-big" #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 = +#ifndef TARGET_UNDERSCORE +#define TARGET_UNDERSCORE 0 #endif -{ -#ifdef TARGET_BIG_NAME - TARGET_BIG_NAME, + +#ifdef COFF_WITH_PE +#define EXTRA_S_FLAGS (SEC_LINK_ONCE | SEC_LINK_DUPLICATES) #else - "coff-arm-big", +#define EXTRA_S_FLAGS 0 #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), +/* Forward declaration for use initialising alternative_target field. */ +extern const bfd_target TARGET_BIG_SYM ; -#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 +/* Target vectors. */ +CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED, EXTRA_S_FLAGS, TARGET_UNDERSCORE, & TARGET_BIG_SYM) +CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED, EXTRA_S_FLAGS, TARGET_UNDERSCORE, & TARGET_LITTLE_SYM) -#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-go32.c b/bfd/coff-go32.c index be4adb2..a6b28e1 100644 --- a/bfd/coff-go32.c +++ b/bfd/coff-go32.c @@ -1,5 +1,5 @@ -/* BFD back-end for Intel 386 COFF files (go32 variant). - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +/* BFD back-end for Intel 386 COFF files (DJGPP variant). + Copyright 1990, 91, 92, 93, 94, 1999, 2000 Free Software Foundation, Inc. Written by DJ Delorie. This file is part of BFD, the Binary File Descriptor library. @@ -21,5 +21,19 @@ 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 '_' +#define COFF_LONG_SECTION_NAMES +#define COFF_SUPPORT_GNU_LINKONCE + +#define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.d"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.t"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.r"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 } #include "coff-i386.c" diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index 74a4ec3..3d54f20 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -1,5 +1,6 @@ /* BFD back-end for Hitachi H8/300 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. Written by Steve Chamberlain, . This file is part of BFD, the Binary File Descriptor library. @@ -203,13 +204,13 @@ h8300_coff_link_hash_table_create (abfd) 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 *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd == (bfd *) NULL) return bfd_reloc_continue; @@ -795,7 +796,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); /* Sanity check. */ - if (value < 0x8000 || value > 0xff8000) + if (value <= 0x7fff || value >= 0xff8000) { /* Insert the 16bit value into the proper location. */ bfd_put_16 (abfd, value, data + dst_address); @@ -1060,13 +1061,13 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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)) + || 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) + if (value <= 0xff) { bfd_put_8 (abfd, value, data + dst_address); dst_address += 1; @@ -1345,44 +1346,4 @@ h8300_bfd_link_add_symbols(abfd, info) #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, -}; +CREATE_BIG_COFF_TARGET_VEC (h8300coff_vec, "coff-h8300", BFD_IS_RELAXABLE, 0, '_', NULL) diff --git a/bfd/coff-h8500.c b/bfd/coff-h8500.c index 91109ea..22eeaa5 100644 --- a/bfd/coff-h8500.c +++ b/bfd/coff-h8500.c @@ -311,44 +311,4 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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, -}; +CREATE_BIG_COFF_TARGET_VEC (h8500coff_vec, "coff-h8500", 0, 0, '_', NULL) diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index 7898cc1..84d4d14 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 COFF files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -37,13 +37,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "libcoff.h" -static bfd_reloc_status_type coff_i386_reloc +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 *)); +static reloc_howto_type *coff_i386_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) /* The page size is a guess based on ELF. */ @@ -66,9 +67,9 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, arelent *reloc_entry; asymbol *symbol; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { symvalue diff; @@ -106,8 +107,8 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, #ifdef COFF_WITH_PE /* FIXME: How should this case be handled? */ - if (reloc_entry->howto->type == R_IMAGEBASE && diff != 0) - abort (); + if (reloc_entry->howto->type == R_IMAGEBASE) + diff -= pe_data (output_bfd)->pe_opthdr.ImageBase; #endif #define DOIT(x) \ @@ -154,140 +155,150 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, } #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; +/* Return true if this relocation should appear in the output .reloc + section. */ + +static boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *)); + +static boolean in_reloc_p (abfd, howto) + bfd *abfd ATTRIBUTE_UNUSED; reloc_howto_type *howto; { return ! howto->pc_relative && howto->type != R_IMAGEBASE; -} -#endif +} + +#endif /* COFF_WITH_PE */ #ifndef PCRELOFFSET #define PCRELOFFSET false #endif -static reloc_howto_type howto_table[] = +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 */ + EMPTY_HOWTO (0), + EMPTY_HOWTO (1), + EMPTY_HOWTO (2), + EMPTY_HOWTO (3), + EMPTY_HOWTO (4), + EMPTY_HOWTO (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 */ + coff_i386_reloc, /* special_function */ + "dir32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + true), /* pcrel_offset */ + /* PE IMAGE_REL_I386_DIR32NB relocation (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 */ + coff_i386_reloc, /* special_function */ + "rva32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + EMPTY_HOWTO (010), + EMPTY_HOWTO (011), + EMPTY_HOWTO (012), + EMPTY_HOWTO (013), + EMPTY_HOWTO (014), + EMPTY_HOWTO (015), + EMPTY_HOWTO (016), + /* Byte relocation (017). */ + 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 */ + 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 */ + /* 16-bit word relocation (020). */ + 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 */ + 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 */ + /* 32-bit longword relocation (021). */ + 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 */ + 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 */ + /* Byte PC relative relocation (022). */ + 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 */ + 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 */ + /* 16-bit word PC relative relocation (023). */ + 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 */ + 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 */ + /* 32-bit longword PC relative relocation (024). */ + 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 */ + coff_i386_reloc, /* special_function */ + "DISP32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ PCRELOFFSET) /* pcrel_offset */ }; @@ -297,8 +308,11 @@ static reloc_howto_type howto_table[] = #define BADMAG(x) I386BADMAG(x) #define I386 1 /* Customize coffcode.h */ -#define RTYPE2HOWTO(cache_ptr, dst) \ - (cache_ptr)->howto = howto_table + (dst)->r_type; +#define RTYPE2HOWTO(cache_ptr, dst) \ + ((cache_ptr)->howto = \ + ((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \ + ? howto_table + (dst)->r_type \ + : NULL)) /* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared library. On some other COFF targets STYP_BSS is normally @@ -385,19 +399,25 @@ coff_pe_i386_relocate_section (output_bfd, info, input_bfd, static reloc_howto_type * coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; 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 > sizeof (howto_table) / sizeof (howto_table[0])) + { + bfd_set_error (bfd_error_bad_value); + return NULL; + } + howto = howto_table + rel->r_type; #ifdef COFF_WITH_PE + /* Cancel out code in _bfd_coff_generic_relocate_section. */ *addendp = 0; #endif @@ -411,7 +431,7 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp) 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 @@ -430,7 +450,7 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp) /* 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) + if (h != NULL && h->root.type == bfd_link_hash_common) *addendp += h->root.u.c.size; #endif @@ -458,23 +478,29 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp) 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 *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) { case BFD_RELOC_RVA: - return howto_table +R_IMAGEBASE; + return howto_table + R_IMAGEBASE; case BFD_RELOC_32: return howto_table + R_DIR32; case BFD_RELOC_32_PCREL: return howto_table + R_PCRLONG; + case BFD_RELOC_16: + return howto_table + R_RELWORD; + case BFD_RELOC_16_PCREL: + return howto_table + R_PCRWORD; + case BFD_RELOC_8: + return howto_table + R_RELBYTE; + case BFD_RELOC_8_PCREL: + return howto_table + R_PCRBYTE; default: BFD_FAIL (); return 0; @@ -508,69 +534,6 @@ coff_i386_is_local_label_name (abfd, name) #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 = @@ -591,14 +554,11 @@ const bfd_target 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), +#ifdef COFF_WITH_PE + | SEC_LINK_ONCE | SEC_LINK_DUPLICATES #endif + | SEC_CODE | SEC_DATA), #ifdef TARGET_UNDERSCORE TARGET_UNDERSCORE, /* leading underscore */ @@ -616,8 +576,8 @@ const bfd_target 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_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 */ @@ -633,5 +593,7 @@ const bfd_target BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - COFF_SWAP_TABLE, + NULL, + + COFF_SWAP_TABLE }; diff --git a/bfd/coff-i860.c b/bfd/coff-i860.c index 929fa42..ab3bb5f 100644 --- a/bfd/coff-i860.c +++ b/bfd/coff-i860.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 860 COFF files. - Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 97, 1999 Free Software Foundation, Inc. Created mostly by substituting "860" for "386" in coff-i386.c Harry Dolan , October 1995 @@ -57,9 +57,9 @@ coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, arelent *reloc_entry; asymbol *symbol; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { symvalue diff; @@ -141,12 +141,12 @@ coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, static reloc_howto_type howto_table[] = { - {0}, - {1}, - {2}, - {3}, - {4}, - {5}, + EMPTY_HOWTO (0), + EMPTY_HOWTO (1), + EMPTY_HOWTO (2), + EMPTY_HOWTO (3), + EMPTY_HOWTO (4), + EMPTY_HOWTO (5), HOWTO (R_DIR32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -174,13 +174,13 @@ static reloc_howto_type howto_table[] = 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ false), /* pcrel_offset */ - {010}, - {011}, - {012}, - {013}, - {014}, - {015}, - {016}, + EMPTY_HOWTO (010), + EMPTY_HOWTO (011), + EMPTY_HOWTO (012), + EMPTY_HOWTO (013), + EMPTY_HOWTO (014), + EMPTY_HOWTO (015), + EMPTY_HOWTO (016), HOWTO (R_RELBYTE, /* type */ 0, /* rightshift */ 0, /* size (0 = byte, 1 = short, 2 = long) */ @@ -313,7 +313,7 @@ static reloc_howto_type howto_table[] = static reloc_howto_type * coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; struct coff_link_hash_entry *h; @@ -418,5 +418,7 @@ const bfd_target BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - COFF_SWAP_TABLE, + NULL, + + COFF_SWAP_TABLE }; diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c index 25455d9..4c37fab 100644 --- a/bfd/coff-i960.c +++ b/bfd/coff-i960.c @@ -1,5 +1,6 @@ /* BFD back-end for Intel 960 COFF files. - Copyright (C) 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 97, 98, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -60,7 +61,7 @@ static boolean coff_i960_adjust_symndx static boolean coff_i960_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *name; { return (name[0] == 'L' @@ -106,7 +107,7 @@ optcall_callback (abfd, reloc_entry, symbol_in, data, asymbol *symbol_in; PTR data; asection *input_section; - bfd *ignore_bfd; + bfd *ignore_bfd ATTRIBUTE_UNUSED; char **error_message; { /* This item has already been relocated correctly, but we may be @@ -193,10 +194,10 @@ coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section, bfd *abfd; arelent *reloc_entry; asymbol *symbol; - PTR data; - asection *input_section; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { asection *osec; @@ -277,7 +278,7 @@ static reloc_howto_type howto_optcall = static reloc_howto_type * coff_i960_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -368,7 +369,7 @@ coff_i960_start_final_link (abfd, info) static boolean coff_i960_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, syms, sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -457,7 +458,7 @@ coff_i960_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -580,10 +581,10 @@ coff_i960_relocate_section (output_bfd, info, input_bfd, input_section, /*ARGSUSED*/ static boolean coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) - bfd *obfd; - struct bfd_link_info *info; + bfd *obfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; bfd *ibfd; - asection *sec; + asection *sec ATTRIBUTE_UNUSED; struct internal_reloc *irel; boolean *adjustedp; { @@ -615,49 +616,9 @@ coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) #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, -}; +extern const bfd_target icoff_big_vec; +CREATE_LITTLE_COFF_TARGET_VEC (icoff_little_vec, "coff-Intel-little", 0, 0, '_', & icoff_big_vec) const bfd_target icoff_big_vec = { @@ -699,5 +660,7 @@ bfd_getb64, bfd_getb_signed_64, bfd_putb64, BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - COFF_SWAP_TABLE, + & icoff_little_vec, + + COFF_SWAP_TABLE }; diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c index 5a06b17..d7138c0 100644 --- a/bfd/coff-m68k.c +++ b/bfd/coff-m68k.c @@ -1,5 +1,6 @@ /* BFD back-end for Motorola 68000 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -174,7 +175,7 @@ static #endif reloc_howto_type * m68k_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -215,11 +216,11 @@ static reloc_howto_type *m68kcoff_rtype_to_howto /*ARGSUSED*/ static reloc_howto_type * m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; bfd_vma *addendp; { arelent relent; @@ -257,9 +258,9 @@ m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data, arelent *reloc_entry; asymbol *symbol; PTR data; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { symvalue diff; @@ -376,7 +377,7 @@ m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data, /*ARGSUSED*/ static reloc_howto_type * m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; struct coff_link_hash_entry *h; @@ -433,48 +434,8 @@ m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp) #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 - '_', +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL) #else - 0, /* leading underscore */ +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, 0, NULL) #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 index 8da0b05..f78377a 100644 --- a/bfd/coff-m88k.c +++ b/bfd/coff-m88k.c @@ -1,5 +1,6 @@ /* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files. - Copyright 1990, 91, 92, 93, 94, 95, 97, 1998 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 97, 98, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -44,7 +45,7 @@ static void reloc_processing static boolean m88k_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *name; { return name[0] == '@'; @@ -59,7 +60,7 @@ m88k_special_reloc (abfd, reloc_entry, symbol, data, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { reloc_howto_type *howto = reloc_entry->howto; @@ -287,44 +288,4 @@ reloc_processing (relent, reloc, symbols, abfd, section) #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, -}; +CREATE_BIG_COFF_TARGET_VEC (m88kbcs_vec, "coff-m88kbcs", 0, 0, '_', NULL) diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c index d787096..19cbea1 100644 --- a/bfd/coff-mcore.c +++ b/bfd/coff-mcore.c @@ -1,6 +1,5 @@ -/* BFD back-end for Motorolla MCore COFF/PE - Copyright 1999 - Free Software Foundation, Inc. +/* BFD back-end for Motorola MCore COFF/PE + Copyright (C) 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -45,8 +44,6 @@ 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 **)); @@ -55,10 +52,6 @@ static reloc_howto_type * mcore_coff_reloc_type_lookup 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 @@ -67,7 +60,7 @@ static const bfd_target * pe_object_p #define TOC_SECTION_NAME ".private.toc" /* The main body of code is in coffcode.h. */ -#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) +#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value from smaller values. Start with zero, widen, *then* decrement. */ @@ -84,7 +77,7 @@ static reloc_howto_type mcore_coff_howto_table[] = false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* dont complain_on_overflow */ - 0, /* special_function */ + NULL, /* special_function */ "ABSOLUTE", /* name */ false, /* partial_inplace */ 0x00, /* src_mask */ @@ -98,7 +91,7 @@ static reloc_howto_type mcore_coff_howto_table[] = false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - 0, /* special_function */ + NULL, /* special_function */ "ADDR32", /* name */ true, /* partial_inplace */ 0xffffffff, /* src_mask */ @@ -114,7 +107,7 @@ static reloc_howto_type mcore_coff_howto_table[] = true, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - mcore_coff_unsupported_reloc, /* special_function */ + mcore_coff_unsupported_reloc, /* special_function */ "IMM8BY4", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -146,7 +139,7 @@ static reloc_howto_type mcore_coff_howto_table[] = true, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - mcore_coff_unsupported_reloc,/* special_function */ + mcore_coff_unsupported_reloc, /* special_function */ "IMM4BY2", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -187,6 +180,20 @@ static reloc_howto_type mcore_coff_howto_table[] = false, /* partial_inplace */ 0x0, /* src_mask */ 0x7ff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (IMAGE_REL_MCORE_RVA, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + NULL, /* special_function */ + "MCORE_RVA", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ true) /* pcrel_offset */ }; @@ -237,17 +244,36 @@ coff_mcore_link_hash_table_create (abfd) return & ret->root.root; } +/* Add an entry to the base file. */ +static void +mcore_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); +} + /*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; + asymbol * symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection * input_section ATTRIBUTE_UNUSED; + bfd * output_bfd ATTRIBUTE_UNUSED; + char ** error_message ATTRIBUTE_UNUSED; { BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0); @@ -266,7 +292,7 @@ mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section, static reloc_howto_type * mcore_coff_reloc_type_lookup (abfd, code) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -277,6 +303,7 @@ mcore_coff_reloc_type_lookup (abfd, code) 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); + HOW2MAP (BFD_RELOC_RVA, IMAGE_REL_MCORE_RVA); default: return NULL; } @@ -290,10 +317,10 @@ mcore_coff_reloc_type_lookup (abfd, code) static reloc_howto_type * coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; asection * sec; struct internal_reloc * rel; - struct coff_link_hash_entry * h; + struct coff_link_hash_entry * h ATTRIBUTE_UNUSED; struct internal_syment * sym; bfd_vma * addendp; { @@ -304,8 +331,11 @@ coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp) return NULL; howto = mcore_coff_howto_table + rel->r_type; + + if (rel->r_type == IMAGE_REL_MCORE_RVA) + * addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase; - if (howto->pc_relative) + else if (howto->pc_relative) { * addendp = sec->vma - 2; /* XXX guess - is this right ? */ @@ -323,16 +353,18 @@ coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp) return howto; } - -/* Return true if this relocation should - appear in the output .reloc section. */ -static boolean in_reloc_p (abfd, howto) - bfd * abfd; + +/* Return true if this relocation should appear in the output .reloc section. + This function is referenced in pe_mkobject in peicode.h. */ +static boolean +in_reloc_p (abfd, howto) + bfd * abfd ATTRIBUTE_UNUSED; reloc_howto_type * howto; { - return ! howto->pc_relative; + return ! howto->pc_relative && howto->type != IMAGE_REL_MCORE_RVA; } + /* The reloc processing routine for the optimized COFF linker. */ static boolean coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, @@ -357,8 +389,19 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, if (info->relocateable) return true; - BFD_ASSERT (input_bfd->xvec->byteorder - == output_bfd->xvec->byteorder); + /* Check if we have the same endianess */ + if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder + && output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) + { + (*_bfd_error_handler) + (_("%s: compiled for a %s endian system and target is %s endian.\n"), + bfd_get_filename (input_bfd), + bfd_big_endian (input_bfd) ? "big" : "little", + bfd_big_endian (output_bfd) ? "big" : "little"); + + bfd_set_error (bfd_error_wrong_format); + return false; + } hihalf = false; hihalf_val = 0; @@ -368,8 +411,6 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, for (; rel < relend; rel++) { - asection * toc_section = NULL; - bfd_vma relocation; long symndx; struct internal_syment * sym; bfd_vma val; @@ -395,6 +436,8 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, sym = syms + symndx; } + addend = 0; + /* Get the howto and initialise the addend. */ howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h, sym, & addend); @@ -445,7 +488,7 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } @@ -481,10 +524,25 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, case IMAGE_REL_MCORE_PCREL_32: case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2: case IMAGE_REL_MCORE_ADDR32: + /* XXX fixme - shouldn't this be like the code for the RVA reloc ? */ rstat = _bfd_relocate_contents (howto, input_bfd, val, loc); break; + + case IMAGE_REL_MCORE_RVA: + rstat = _bfd_final_link_relocate + (howto, input_bfd, + input_section, contents, rel->r_vaddr - input_section->vma, + val, addend); + break; } + 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)) + mcore_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr); + } + switch (rstat) { default: @@ -520,184 +578,9 @@ coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section, #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 +/* Forward declaration to initialise alterbative_target field. */ +extern const bfd_target TARGET_LITTLE_SYM; - 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, -}; - +CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED, (SEC_LINK_ONCE | SEC_LINK_DUPLICATES), 0, & TARGET_LITTLE_SYM) +CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED, (SEC_LINK_ONCE | SEC_LINK_DUPLICATES), 0, & TARGET_BIG_SYM) diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 051eb86..bb4b15e 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1,5 +1,5 @@ /* BFD back-end for MIPS Extended-Coff files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -273,10 +273,10 @@ static reloc_howto_type mips_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - { 8 }, - { 9 }, - { 10 }, - { 11 }, + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), /* This reloc is a Cygnus extension used when generating position independent code for embedded systems. It represents a 16 bit PC @@ -334,13 +334,13 @@ static reloc_howto_type mips_howto_table[] = 0xffff, /* dst_mask */ true), /* pcrel_offset */ - { 15 }, - { 16 }, - { 17 }, - { 18 }, - { 19 }, - { 20 }, - { 21 }, + EMPTY_HOWTO (15), + EMPTY_HOWTO (16), + EMPTY_HOWTO (17), + EMPTY_HOWTO (18), + EMPTY_HOWTO (19), + EMPTY_HOWTO (20), + EMPTY_HOWTO (21), /* This reloc is a Cygnus extension used when generating position independent code for embedded systems. It represents an entry in @@ -569,7 +569,7 @@ mips_adjust_reloc_in (abfd, intern, rptr) static void mips_adjust_reloc_out (abfd, rel, intern) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const arelent *rel; struct internal_reloc *intern; { @@ -604,13 +604,13 @@ mips_generic_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -651,13 +651,13 @@ mips_refhi_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_reloc_status_type ret; bfd_vma relocation; @@ -933,13 +933,13 @@ mips_relhi_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_reloc_status_type ret; bfd_vma relocation; @@ -1109,13 +1109,13 @@ mips_switch_reloc (abfd, 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 *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { return bfd_reloc_ok; } @@ -1124,7 +1124,7 @@ mips_switch_reloc (abfd, static reloc_howto_type * mips_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { int mips_type; @@ -1781,7 +1781,7 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section, if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - int_rel.r_vaddr - input_section->vma))) + int_rel.r_vaddr - input_section->vma, true))) return false; relocation = 0; } @@ -2329,9 +2329,9 @@ mips_relax_section (abfd, sec, info, again) static boolean mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address) - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; bfd *input_bfd; - asection *input_section; + asection *input_section ATTRIBUTE_UNUSED; struct ecoff_link_hash_entry *h; bfd_byte *location; bfd_vma address; @@ -2505,13 +2505,14 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = (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, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, 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 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL }, /* Supported architecture. */ bfd_arch_mips, @@ -2600,6 +2601,8 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = /* GC of sections is not done. */ #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections +extern const bfd_target ecoff_big_vec; + const bfd_target ecoff_little_vec = { "ecoff-littlemips", /* name */ @@ -2639,6 +2642,8 @@ const bfd_target ecoff_little_vec = BFD_JUMP_TABLE_LINK (_bfd_ecoff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & ecoff_big_vec, + (PTR) &mips_ecoff_backend_data }; @@ -2680,6 +2685,8 @@ const bfd_target ecoff_big_vec = BFD_JUMP_TABLE_LINK (_bfd_ecoff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & ecoff_little_vec, + (PTR) &mips_ecoff_backend_data }; @@ -2722,5 +2729,7 @@ const bfd_target ecoff_biglittle_vec = BFD_JUMP_TABLE_LINK (_bfd_ecoff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) &mips_ecoff_backend_data }; diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index cf45044..c5e695d 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -1,5 +1,5 @@ /* BFD back-end for PowerPC Microsoft Portable Executable files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Original version pieced together by Kim Knuttila (krk@cygnus.com) @@ -906,10 +906,10 @@ static void ppc_mark_symbol_as_glue static boolean ppc_record_toc_entry(abfd, info, sec, sym, toc_kind) bfd *abfd; - struct bfd_link_info *info; - asection *sec; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; int sym; - enum toc_type toc_kind; + enum toc_type toc_kind ATTRIBUTE_UNUSED; { struct ppc_coff_link_hash_entry *h; const char *name; @@ -1007,7 +1007,7 @@ ppc_mark_symbol_as_glue(abfd, sym, rel) appear in the output .reloc section. */ static boolean in_reloc_p(abfd, howto) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; reloc_howto_type *howto; { return @@ -1197,7 +1197,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -1700,7 +1700,7 @@ dump_toc (vfile) boolean ppc_allocate_toc_section (info) - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { asection *s; bfd_byte *foo; @@ -1806,13 +1806,13 @@ ppc_refhi_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("REFHI"); DUMP_RELOC("REFHI",reloc_entry); @@ -1860,13 +1860,13 @@ ppc_pair_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("PAIR"); DUMP_RELOC("PAIR",reloc_entry); @@ -1886,13 +1886,13 @@ ppc_toc16_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("TOCREL16"); DUMP_RELOC("TOCREL16",reloc_entry); @@ -1945,13 +1945,13 @@ ppc_secrel_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("SECREL"); DUMP_RELOC("SECREL",reloc_entry); @@ -1970,13 +1970,13 @@ ppc_section_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("SECTION"); DUMP_RELOC("SECTION",reloc_entry); @@ -1995,13 +1995,13 @@ ppc_imglue_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { UN_IMPL("IMGLUE"); DUMP_RELOC("IMGLUE",reloc_entry); @@ -2093,11 +2093,11 @@ ppc_coff_rtype2howto (relent, internal) static reloc_howto_type * coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; bfd_vma *addendp; { reloc_howto_type *howto; @@ -2175,7 +2175,7 @@ PARAMS ((bfd *, bfd_reloc_code_real_type)); static reloc_howto_type * ppc_coff_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -2214,6 +2214,7 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR)); #define coff_bfd_final_link ppc_bfd_coff_final_link #ifndef COFF_IMAGE_WITH_PE +/* FIXME: This no longer works. */ #define coff_swap_sym_in_hook ppc_coff_swap_sym_in_hook #endif @@ -2221,8 +2222,25 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR)); #define COFF_PAGE_SIZE 0x1000 +/* FIXME: This controls some code that used to be in peicode.h and is + now in peigen.c. It will not control the code in peigen.c. If + anybody wants to get this working, you will need to fix that. */ #define POWERPC_LE_PE +#define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_EXACT_MATCH (".idata$2"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".idata$3"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".idata$4"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".idata$5"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".idata$6"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 1 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".reloc"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 1 } + #include "coffcode.h" @@ -2245,7 +2263,7 @@ static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR)); static void ppc_coff_swap_sym_in_hook (abfd, ext1, in1) bfd *abfd; - PTR ext1; + PTR ext1 ATTRIBUTE_UNUSED; PTR in1; { struct internal_syment *in = (struct internal_syment *)in1; @@ -2316,7 +2334,6 @@ ppc_get_last() 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. */ @@ -2824,11 +2841,15 @@ ppc_bfd_coff_final_link (abfd, info) #endif +/* Forward declaration for use by alternative_target field. */ +#ifdef TARGET_BIG_SYM +extern const bfd_target TARGET_BIG_SYM; +#endif + /* The transfer vectors that lead the outside world to all of the above. */ #ifdef TARGET_LITTLE_SYM -const bfd_target -TARGET_LITTLE_SYM = +const bfd_target TARGET_LITTLE_SYM = { TARGET_LITTLE_NAME, /* name or coff-arm-little */ bfd_target_coff_flavour, @@ -2874,14 +2895,20 @@ TARGET_LITTLE_SYM = BFD_JUMP_TABLE_WRITE (coff), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + /* Alternative_target. */ +#ifdef TARGET_BIG_SYM + & TARGET_BIG_SYM, +#else + NULL, +#endif - COFF_SWAP_TABLE, + COFF_SWAP_TABLE }; #endif #ifdef TARGET_BIG_SYM -const bfd_target -TARGET_BIG_SYM = +const bfd_target TARGET_BIG_SYM = { TARGET_BIG_NAME, bfd_target_coff_flavour, @@ -2928,7 +2955,15 @@ TARGET_BIG_SYM = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - COFF_SWAP_TABLE, + + /* Alternative_target. */ +#ifdef TARGET_LITTLE_SYM + & TARGET_LITTLE_SYM, +#else + NULL, +#endif + + COFF_SWAP_TABLE }; #endif diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 6b4cd44..6f8563f 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -1,5 +1,6 @@ /* BFD back-end for IBM RS/6000 "XCOFF" files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + 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 @@ -139,8 +140,8 @@ xcoff_copy_private_bfd_data (ibfd, obfd) static boolean xcoff_is_local_label_name (abfd, name) - bfd *abfd; - const char *name; + bfd *abfd ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; { return false; } @@ -258,7 +259,7 @@ static reloc_howto_type xcoff_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - { 7 }, + EMPTY_HOWTO (7), /* Non modifiable absolute branch. */ HOWTO (8, /* type */ @@ -275,7 +276,7 @@ static reloc_howto_type xcoff_howto_table[] = 0x3fffffc, /* dst_mask */ false), /* pcrel_offset */ - { 9 }, + EMPTY_HOWTO (9), /* Non modifiable relative branch. */ HOWTO (0xa, /* type */ @@ -292,7 +293,7 @@ static reloc_howto_type xcoff_howto_table[] = 0x3fffffc, /* dst_mask */ false), /* pcrel_offset */ - { 0xb }, + EMPTY_HOWTO (0xb), /* Indirect load. */ HOWTO (0xc, /* type */ @@ -324,7 +325,7 @@ static reloc_howto_type xcoff_howto_table[] = 0xffff, /* dst_mask */ false), /* pcrel_offset */ - { 0xe }, + EMPTY_HOWTO (0xe), /* Non-relocating reference. */ HOWTO (0xf, /* type */ @@ -341,8 +342,8 @@ static reloc_howto_type xcoff_howto_table[] = 0, /* dst_mask */ false), /* pcrel_offset */ - { 0x10 }, - { 0x11 }, + EMPTY_HOWTO (0x10), + EMPTY_HOWTO (0x11), /* TOC relative indirect load. */ HOWTO (0x12, /* type */ @@ -495,6 +496,55 @@ static reloc_howto_type xcoff_howto_table[] = false) /* pcrel_offset */ }; +/* These are the first two like the above but for 16-bit relocs. */ +static reloc_howto_type xcoff_howto_table_16[] = +{ + /* Standard 16 bit relocation. */ + HOWTO (0, /* 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_POS_16", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 16 bit relocation, but store negative value. */ + HOWTO (1, /* 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_NEG_16", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 16 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_16", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ +}; + static void xcoff_rtype2howto (relent, internal) arelent *relent; @@ -502,6 +552,11 @@ xcoff_rtype2howto (relent, internal) { relent->howto = xcoff_howto_table + internal->r_type; + if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1 + && (internal->r_type + < sizeof(xcoff_howto_table_16)/sizeof(xcoff_howto_table_16[0]))) + relent->howto = xcoff_howto_table_16 + 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 @@ -518,7 +573,7 @@ xcoff_rtype2howto (relent, internal) static reloc_howto_type * xcoff_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -590,12 +645,25 @@ xcoff_reloc_type_lookup (abfd, code) 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. */ + null terminated strings, which are symbol names. -/* XCOFF archives use this as a magic string. */ + AIX 4.3 introduced a new archive format which can handle larger + files and also 32- and 64-bit objects in the same archive. The + things said above remain true except that there is now more than + one global symbol table. The one is used to index 32-bit objects, + the other for 64-bit objects. -#define XCOFFARMAG "\012" -#define SXCOFFARMAG 8 + The new archives (recognizable by the new ARMAG string) has larger + field lengths so that we cannot really share any code. Also we have + to take care that we are not generating the new form of archives + on AIX 4.2 or earlier systems. */ + +/* XCOFF archives use this as a magic string. Note that both strings + have the same length. */ + +#define XCOFFARMAG "\012" +#define XCOFFARMAGBIG "\012" +#define SXCOFFARMAG 8 /* This terminates an XCOFF archive member name. */ @@ -628,6 +696,38 @@ struct xcoff_ar_file_hdr #define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG) +/* This is the equivalent data structure for the big archive format. */ + +struct xcoff_ar_file_hdr_big +{ + /* Magic string. */ + char magic[SXCOFFARMAG]; + + /* Offset of the member table (decimal ASCII string). */ + char memoff[20]; + + /* Offset of the global symbol table for 32-bit objects (decimal ASCII + string). */ + char symoff[20]; + + /* Offset of the global symbol table for 64-bit objects (decimal ASCII + string). */ + char symoff64[20]; + + /* Offset of the first member in the archive (decimal ASCII string). */ + char firstmemoff[20]; + + /* Offset of the last member in the archive (decimal ASCII string). */ + char lastmemoff[20]; + + /* Offset of the first member on the free list (decimal ASCII + string). */ + char freeoff[20]; +}; + +#define SIZEOF_AR_FILE_HDR_BIG (6 * 20 + SXCOFFARMAG) + + /* Each XCOFF archive member starts with this (printable) structure. */ struct xcoff_ar_hdr @@ -666,16 +766,65 @@ struct xcoff_ar_hdr #define SIZEOF_AR_HDR (7 * 12 + 4) +/* The equivalent for the big archive format. */ + +struct xcoff_ar_hdr_big +{ + /* File size not including the header (decimal ASCII string). */ + char size[20]; + + /* File offset of next archive member (decimal ASCII string). */ + char nextoff[20]; + + /* File offset of previous archive member (decimal ASCII string). */ + char prevoff[20]; + + /* 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_BIG (3 * 20 + 4 * 12 + 4) + + +/* We often have to distinguish between the old and big file format. + Make it a bit cleaner. We can use `xcoff_ardata' here because the + `hdr' member has the same size and position in both formats. */ +#define xcoff_big_format_p(abfd) \ + (xcoff_ardata (abfd)->magic[1] == 'b') + /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the - artdata structure. */ + artdata structure. Similar for the big archive. */ #define xcoff_ardata(abfd) \ ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata) +#define xcoff_ardata_big(abfd) \ + ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata) /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an - archive element. */ + archive element. Similar for the big archive. */ #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) #define arch_xhdr(bfd) \ ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header) +#define arch_xhdr_big(bfd) \ + ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header) /* XCOFF archives do not have anything which corresponds to an extended name table. */ @@ -701,7 +850,6 @@ 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; @@ -715,27 +863,64 @@ xcoff_slurp_armap (abfd) return true; } - off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10); - if (off == 0) + if (! xcoff_big_format_p (abfd)) { - bfd_has_map (abfd) = false; - return true; + /* This is for the old format. */ + struct xcoff_ar_hdr hdr; + + 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; + + sz = strtol (hdr.size, (char **) NULL, 10); } + else + { + /* This is for the new format. */ + struct xcoff_ar_hdr_big hdr; - if (bfd_seek (abfd, off, SEEK_SET) != 0) - return false; + off = strtol (xcoff_ardata_big (abfd)->symoff, (char **) NULL, 10); + if (off == 0) + { + bfd_has_map (abfd) = false; + return true; + } - /* The symbol table starts with a normal archive header. */ - if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR) - return false; + if (bfd_seek (abfd, off, SEEK_SET) != 0) + 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; + /* The symbol table starts with a normal archive header. */ + if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) + != SIZEOF_AR_HDR_BIG) + 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; + + /* XXX This actually has to be a call to strtoll (at least on 32-bit + machines) since the field width is 20 and there numbers with more + than 32 bits can be represented. */ + sz = strtol (hdr.size, (char **) NULL, 10); + } /* 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; @@ -788,17 +973,17 @@ static const bfd_target * xcoff_archive_p (abfd) bfd *abfd; { - struct xcoff_ar_file_hdr hdr; + char magic[SXCOFFARMAG]; - if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd) - != SIZEOF_AR_FILE_HDR) + if (bfd_read ((PTR) magic, SXCOFFARMAG, 1, abfd) != SXCOFFARMAG) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); return NULL; } - if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0) + if (strncmp (magic, XCOFFARMAG, SXCOFFARMAG) != 0 + && strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0) { bfd_set_error (bfd_error_wrong_format); return NULL; @@ -813,18 +998,67 @@ xcoff_archive_p (abfd) 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; + /* Now handle the two formats. */ + if (magic[1] != 'b') + { + /* This is the old format. */ + struct xcoff_ar_file_hdr hdr; + + /* Copy over the magic string. */ + memcpy (hdr.magic, magic, SXCOFFARMAG); + + /* Now read the rest of the file header. */ + if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR - SXCOFFARMAG, 1, + abfd) != SIZEOF_AR_FILE_HDR - SXCOFFARMAG) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } + + bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, + (char **) NULL, 10); + + 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); + } + else + { + /* This is the new format. */ + struct xcoff_ar_file_hdr_big hdr; + + /* Copy over the magic string. */ + memcpy (hdr.magic, magic, SXCOFFARMAG); + + /* Now read the rest of the file header. */ + if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, 1, + abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } - memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR); + /* XXX This actually has to be a call to strtoll (at least on 32-bit + machines) since the field width is 20 and there numbers with more + than 32 bits can be represented. */ + bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff, + (char **) NULL, 10); + + bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR_BIG); + if (bfd_ardata (abfd)->tdata == NULL) + return NULL; + + memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG); + } if (! xcoff_slurp_armap (abfd)) { @@ -842,29 +1076,80 @@ 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; + + if (! xcoff_big_format_p (abfd)) + { + struct xcoff_ar_hdr hdr; + struct xcoff_ar_hdr *hdrp; + + if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR) + { + free (ret); + 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) + { + free (ret); + return NULL; + } + memcpy (hdrp, &hdr, SIZEOF_AR_HDR); + if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen) + { + free (ret); + return NULL; + } + ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0'; + + ret->arch_header = (char *) hdrp; + ret->parsed_size = strtol (hdr.size, (char **) NULL, 10); + ret->filename = (char *) hdrp + SIZEOF_AR_HDR; + } + else + { + struct xcoff_ar_hdr_big hdr; + struct xcoff_ar_hdr_big *hdrp; + + if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) + != SIZEOF_AR_HDR_BIG) + { + free (ret); + return NULL; + } + + namlen = strtol (hdr.namlen, (char **) NULL, 10); + hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, + SIZEOF_AR_HDR_BIG + + namlen + 1); + if (hdrp == NULL) + { + free (ret); + return NULL; + } + memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG); + if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR_BIG, 1, namlen, abfd) != namlen) + { + free (ret); + return NULL; + } + ((char *) hdrp)[SIZEOF_AR_HDR_BIG + namlen] = '\0'; + + ret->arch_header = (char *) hdrp; + /* XXX This actually has to be a call to strtoll (at least on 32-bit + machines) since the field width is 20 and there numbers with more + than 32 bits can be represented. */ + ret->parsed_size = strtol (hdr.size, (char **) NULL, 10); + ret->filename = (char *) hdrp + SIZEOF_AR_HDR_BIG; + } /* Skip over the XCOFFARFMAG at the end of the file name. */ if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0) @@ -888,19 +1173,47 @@ xcoff_openr_next_archived_file (archive, last_file) return NULL; } - if (last_file == NULL) - filestart = bfd_ardata (archive)->first_file_filepos; + if (! xcoff_big_format_p (archive)) + { + 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; + } + } 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; + if (last_file == NULL) + filestart = bfd_ardata (archive)->first_file_filepos; + else + /* XXX These actually have to be a calls to strtoll (at least + on 32-bit machines) since the fields's width is 20 and + there numbers with more than 32 bits can be represented. */ + filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL, + 10); + + /* XXX These actually have to be calls to strtoll (at least on 32-bit + machines) since the fields's width is 20 and there numbers with more + than 32 bits can be represented. */ + if (filestart == 0 + || filestart == strtol (xcoff_ardata_big (archive)->memoff, + (char **) NULL, 10) + || filestart == strtol (xcoff_ardata_big (archive)->symoff, + (char **) NULL, 10)) + { + bfd_set_error (bfd_error_no_more_archived_files); + return NULL; + } } return _bfd_get_elt_at_filepos (archive, filestart); @@ -913,21 +1226,32 @@ 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); + if (! xcoff_big_format_p (abfd)) + { + struct xcoff_ar_hdr *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; + } + else + { + struct xcoff_ar_hdr_big *hdrp = arch_xhdr_big (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; + 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; } @@ -954,9 +1278,9 @@ normalize_filename (abfd) /*ARGSUSED*/ static boolean -xcoff_write_armap (abfd, elength, map, orl_count, stridx) +xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) bfd *abfd; - unsigned int elength; + unsigned int elength ATTRIBUTE_UNUSED; struct orl *map; unsigned int orl_count; int stridx; @@ -986,7 +1310,7 @@ xcoff_write_armap (abfd, elength, map, orl_count, stridx) 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; @@ -1038,51 +1362,155 @@ xcoff_write_armap (abfd, elength, map, orl_count, stridx) return true; } -/* Write out an XCOFF archive. We always write an entire archive, - rather than fussing with the freelist and so forth. */ - +/*ARGSUSED*/ static boolean -xcoff_write_archive_contents (abfd) +xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) bfd *abfd; + unsigned int elength ATTRIBUTE_UNUSED; + struct orl *map; + unsigned int orl_count; + int stridx; { - struct xcoff_ar_file_hdr fhdr; - size_t count; - size_t total_namlen; - file_ptr *offsets; - boolean makemap; - boolean hasobjects; - file_ptr prevoff, nextoff; + struct xcoff_ar_hdr_big hdr; + char *p; + unsigned char buf[4]; bfd *sub; + file_ptr fileoff; 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); + memset (&hdr, 0, sizeof hdr); + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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); - 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) + /* We need spaces, not null bytes, in the header. */ + for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR_BIG; p++) + if (*p == '\0') + *p = ' '; + + if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) != SIZEOF_AR_HDR_BIG + || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG) return false; - if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0) + bfd_h_put_32 (abfd, orl_count, buf); + if (bfd_write (buf, 1, 4, abfd) != 4) 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++) + sub = abfd->archive_head; + fileoff = SIZEOF_AR_FILE_HDR_BIG; + 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_BIG + + 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; +} + +/*ARGSUSED*/ +static boolean +xcoff_write_armap (abfd, elength, map, orl_count, stridx) + bfd *abfd; + unsigned int elength ATTRIBUTE_UNUSED; + struct orl *map; + unsigned int orl_count; + int stridx; +{ + if (! xcoff_big_format_p (abfd)) + return xcoff_write_armap_old (abfd, elength, map, orl_count, stridx); + else + return xcoff_write_armap_big (abfd, elength, map, orl_count, stridx); +} + +/* 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_old (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; @@ -1285,6 +1713,285 @@ xcoff_write_archive_contents (abfd) return true; } + +static boolean +xcoff_write_archive_contents_big (abfd) + bfd *abfd; +{ + struct xcoff_ar_file_hdr_big 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_big ahdr; + bfd_size_type size; + char *p; + char decbuf[13]; + + memset (&fhdr, 0, sizeof fhdr); + strncpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG); + sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR_BIG); + 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_BIG, SEEK_SET) != 0) + return false; + + makemap = bfd_has_map (abfd); + hasobjects = false; + prevoff = 0; + nextoff = SIZEOF_AR_FILE_HDR_BIG; + for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++) + { + const char *name; + size_t namlen; + struct xcoff_ar_hdr_big *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_big (sub); + else + ahdrp = NULL; + + if (ahdrp == NULL) + { + struct stat s; + + memset (&ahdr, 0, sizeof ahdr); + ahdrp = &ahdr; + /* XXX This should actually be a call to stat64 (at least on + 32-bit machines). */ + if (stat (bfd_get_filename (sub), &s) != 0) + { + bfd_set_error (bfd_error_system_call); + return false; + } + + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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; + } + + /* XXX These calls actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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_BIG + + 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_BIG; p++) + if (*p == '\0') + *p = ' '; + + if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR_BIG, abfd) + != SIZEOF_AR_HDR_BIG + || 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; + } + } + + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + sprintf (fhdr.lastmemoff, "%ld", (long) prevoff); + + /* Write out the member table. */ + + BFD_ASSERT (nextoff == bfd_tell (abfd)); + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + sprintf (fhdr.memoff, "%ld", (long) nextoff); + + memset (&ahdr, 0, sizeof ahdr); + /* XXX The next two calls actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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_BIG + + 12 + + count * 12 + + total_namlen + + SXCOFFARFMAG); + + prevoff = nextoff; + nextoff += size + (size & 1); + + if (makemap && hasobjects) + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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_BIG; p++) + if (*p == '\0') + *p = ' '; + + if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG + || (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)); + /* XXX This call actually should use %lld (at least on 32-bit + machines) since the fields's width is 20 and there numbers with + more than 32 bits can be represented. */ + 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_BIG; p++) + if (*p == '\0') + *p = ' '; + + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR_BIG, 1, abfd) != + SIZEOF_AR_FILE_HDR_BIG)) + return false; + + return true; +} + +static boolean +xcoff_write_archive_contents (abfd) + bfd *abfd; +{ + if (! xcoff_big_format_p (abfd)) + return xcoff_write_archive_contents_old (abfd); + else + return xcoff_write_archive_contents_big (abfd); +} /* We can't use the usual coff_sizeof_headers routine, because AIX always uses an a.out header. */ @@ -1293,7 +2000,7 @@ xcoff_write_archive_contents (abfd) static int _bfd_xcoff_sizeof_headers (abfd, reloc) bfd *abfd; - boolean reloc; + boolean reloc ATTRIBUTE_UNUSED; { int size; @@ -1377,7 +2084,7 @@ const bfd_target #else "aixcoff-rs6000", /* name */ #endif - bfd_target_coff_flavour, + bfd_target_coff_flavour, BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ @@ -1414,5 +2121,7 @@ const bfd_target BFD_JUMP_TABLE_LINK (_bfd_xcoff), BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff), - COFF_SWAP_TABLE, + NULL, + + COFF_SWAP_TABLE }; diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index e3d6eec..821fecd 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -1,5 +1,5 @@ /* BFD back-end for Hitachi Super-H COFF binaries. - Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . Relaxing code written by Ian Lance Taylor, . @@ -26,18 +26,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfdlink.h" #include "coff/sh.h" #include "coff/internal.h" + +#ifdef COFF_WITH_PE +#include "coff/pe.h" + +#ifndef COFF_IMAGE_WITH_PE +static boolean 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 *)); + +#define _bfd_sh_align_load_span sh_align_load_span +#endif +#endif + #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)); +#ifndef COFF_IMAGE_WITH_PE static const struct sh_opcode *sh_insn_info PARAMS ((unsigned int)); +#endif static boolean sh_align_loads PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *, boolean *)); static boolean sh_swap_insns @@ -49,26 +64,64 @@ static bfd_byte *sh_coff_get_relocated_section_contents PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, boolean, asymbol **)); +#ifdef COFF_WITH_PE +/* Can't build import tables with 2**4 alignment. */ +#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2 +#else /* Default section alignment to 2**4. */ -#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (4) +#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 4 +#endif + +#ifdef COFF_IMAGE_WITH_PE +/* Align PE executables. */ +#define COFF_PAGE_SIZE 0x1000 +#endif /* Generate long file names. */ #define COFF_LONG_FILENAMES +#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 ATTRIBUTE_UNUSED; + reloc_howto_type * howto; +{ + return ! howto->pc_relative && howto->type != R_SH_IMAGEBASE; +} +#endif + /* 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 */ + EMPTY_HOWTO (0), + EMPTY_HOWTO (1), +#ifdef COFF_WITH_PE + /* Windows CE */ + HOWTO (R_SH_IMM32CE, /* 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_imm32ce", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ +#else + EMPTY_HOWTO (2), +#endif + EMPTY_HOWTO (3), /* R_SH_PCREL8 */ + EMPTY_HOWTO (4), /* R_SH_PCREL16 */ + EMPTY_HOWTO (5), /* R_SH_HIGH8 */ + EMPTY_HOWTO (6), /* R_SH_IMM24 */ + EMPTY_HOWTO (7), /* R_SH_LOW16 */ + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), /* R_SH_PCDISP8BY4 */ HOWTO (R_SH_PCDISP8BY2, /* type */ 1, /* rightshift */ @@ -84,7 +137,7 @@ static reloc_howto_type sh_coff_howtos[] = 0xff, /* dst_mask */ true), /* pcrel_offset */ - { 11 }, /* R_SH_PCDISP8 */ + EMPTY_HOWTO (11), /* R_SH_PCDISP8 */ HOWTO (R_SH_PCDISP, /* type */ 1, /* rightshift */ @@ -100,7 +153,7 @@ static reloc_howto_type sh_coff_howtos[] = 0xfff, /* dst_mask */ true), /* pcrel_offset */ - { 13 }, + EMPTY_HOWTO (13), HOWTO (R_SH_IMM32, /* type */ 0, /* rightshift */ @@ -116,13 +169,29 @@ static reloc_howto_type sh_coff_howtos[] = 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 */ + EMPTY_HOWTO (15), +#ifdef COFF_WITH_PE + HOWTO (R_SH_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 */ + sh_reloc, /* special_function */ + "rva32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ +#else + EMPTY_HOWTO (16), /* R_SH_IMM8 */ +#endif + EMPTY_HOWTO (17), /* R_SH_IMM8BY2 */ + EMPTY_HOWTO (18), /* R_SH_IMM8BY4 */ + EMPTY_HOWTO (19), /* R_SH_IMM4 */ + EMPTY_HOWTO (20), /* R_SH_IMM4BY2 */ + EMPTY_HOWTO (21), /* R_SH_IMM4BY4 */ HOWTO (R_SH_PCRELIMM8BY2, /* type */ 1, /* rightshift */ @@ -304,6 +373,7 @@ static reloc_howto_type sh_coff_howtos[] = /* FIXME: This should not be set here. */ #define __A_MAGIC_SET__ +#ifndef COFF_WITH_PE /* 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 @@ -316,6 +386,7 @@ static reloc_howto_type sh_coff_howtos[] = dst->r_stuff[1] = 'C'; \ } \ while (0) +#endif /* Get the value of a symbol, when performing a relocation. */ @@ -335,6 +406,96 @@ get_symbol_value (symbol) return relocation; } +#ifdef COFF_WITH_PE +/* Convert an rtype to howto for the COFF backend linker. + Copied from coff-i386. */ +#define coff_rtype_to_howto coff_sh_rtype_to_howto + +static reloc_howto_type * +coff_sh_rtype_to_howto (abfd, sec, rel, h, sym, addendp) + bfd * abfd ATTRIBUTE_UNUSED; + asection * sec; + struct internal_reloc * rel; + struct coff_link_hash_entry * h; + struct internal_syment * sym; + bfd_vma * addendp; +{ + reloc_howto_type * howto; + + howto = sh_coff_howtos + rel->r_type; + + *addendp = 0; + + 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); + } + + 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_SH_IMAGEBASE) + *addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase; + + return howto; +} + +/* This structure is used to map BFD reloc codes to SH PE relocs. */ +struct shcoff_reloc_map +{ + unsigned char bfd_reloc_val; + unsigned char shcoff_reloc_val; +}; + +/* An array mapping BFD reloc codes to SH PE relocs. */ +static const struct shcoff_reloc_map sh_reloc_map[] = +{ + { BFD_RELOC_32, R_SH_IMM32CE }, + { BFD_RELOC_RVA, R_SH_IMAGEBASE }, + { BFD_RELOC_CTOR, R_SH_IMM32CE }, +}; + +/* Given a BFD reloc code, return the howto structure for the + corresponding SH PE reloc. */ +#define coff_bfd_reloc_type_lookup sh_coff_reloc_type_lookup + +static reloc_howto_type * +sh_coff_reloc_type_lookup (abfd, code) + bfd * abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; i < sizeof (sh_reloc_map) / sizeof (struct shcoff_reloc_map); i++) + { + if (sh_reloc_map[i].bfd_reloc_val == code) + return &sh_coff_howtos[(int) sh_reloc_map[i].shcoff_reloc_val]; + } + + fprintf (stderr, "SH Error: unknown reloc type %d\n", code); + return NULL; +} +#endif /* COFF_WITH_PE */ + /* This macro is used in coffcode.h to get the howto corresponding to an internal reloc. */ @@ -382,7 +543,7 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { unsigned long insn; bfd_vma sym_value; @@ -402,6 +563,10 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, /* 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 +#ifdef COFF_WITH_PE + && r_type != R_SH_IMM32CE + && r_type != R_SH_IMAGEBASE +#endif && (r_type != R_SH_PCDISP || (symbol_in->flags & BSF_LOCAL) != 0)) return bfd_reloc_ok; @@ -415,10 +580,21 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, switch (r_type) { case R_SH_IMM32: +#ifdef COFF_WITH_PE + case R_SH_IMM32CE: +#endif insn = bfd_get_32 (abfd, hit_data); insn += sym_value + reloc_entry->addend; bfd_put_32 (abfd, insn, hit_data); break; +#ifdef COFF_WITH_PE + case R_SH_IMAGEBASE: + insn = bfd_get_32 (abfd, hit_data); + insn += (sym_value + reloc_entry->addend + - pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase); + bfd_put_32 (abfd, insn, hit_data); + break; +#endif case R_SH_PCDISP: insn = bfd_get_16 (abfd, hit_data); sym_value += reloc_entry->addend; @@ -442,31 +618,7 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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 +#define coff_bfd_merge_private_bfd_data _bfd_generic_verify_endian_match /* We can do relaxing. */ #define coff_bfd_relax_section sh_relax_section @@ -643,7 +795,14 @@ sh_relax_section (abfd, sec, link_info, again) paddr += sec->vma; for (irelfn = internal_relocs; irelfn < irelend; irelfn++) if (irelfn->r_vaddr == paddr +#ifdef COFF_WITH_PE + && (irelfn->r_type == R_SH_IMM32 + || irelfn->r_type == R_SH_IMM32CE + || irelfn->r_type == R_SH_IMAGEBASE)) + +#else && irelfn->r_type == R_SH_IMM32) +#endif break; if (irelfn >= irelend) { @@ -1021,6 +1180,10 @@ sh_relax_delete_bytes (abfd, sec, addr, count) break; case R_SH_IMM32: +#ifdef COFF_WITH_PE + case R_SH_IMM32CE: + case R_SH_IMAGEBASE: +#endif /* 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 @@ -1237,7 +1400,13 @@ sh_relax_delete_bytes (abfd, sec, addr, count) { struct internal_syment sym; +#ifdef COFF_WITH_PE + if (irelscan->r_type != R_SH_IMM32 + && irelscan->r_type != R_SH_IMAGEBASE + && irelscan->r_type != R_SH_IMM32CE) +#else if (irelscan->r_type != R_SH_IMM32) +#endif continue; bfd_coff_swap_sym_in (abfd, @@ -1389,7 +1558,7 @@ struct sh_opcode mask value in the sh_major_opcode structure. */ unsigned short opcode; /* Flags for this instruction. */ - unsigned short flags; + unsigned long flags; }; /* Flag which appear in the sh_opcode structure. */ @@ -1409,10 +1578,12 @@ struct sh_opcode /* This instruction uses the value in the register in the field at mask 0x0f00 of the instruction. */ #define USES1 (0x10) +#define USES1_REG(x) ((x & 0x0f00) >> 8) /* This instruction uses the value in the register in the field at mask 0x00f0 of the instruction. */ #define USES2 (0x20) +#define USES2_REG(x) ((x & 0x00f0) >> 4) /* This instruction uses the value in register 0. */ #define USESR0 (0x40) @@ -1420,10 +1591,12 @@ struct sh_opcode /* This instruction sets the value in the register in the field at mask 0x0f00 of the instruction. */ #define SETS1 (0x80) +#define SETS1_REG(x) ((x & 0x0f00) >> 8) /* This instruction sets the value in the register in the field at mask 0x00f0 of the instruction. */ #define SETS2 (0x100) +#define SETS2_REG(x) ((x & 0x00f0) >> 4) /* This instruction sets register 0. */ #define SETSR0 (0x200) @@ -1437,10 +1610,12 @@ struct sh_opcode /* This instruction uses the floating point register in the field at mask 0x0f00 of the instruction. */ #define USESF1 (0x1000) +#define USESF1_REG(x) ((x & 0x0f00) >> 8) /* This instruction uses the floating point register in the field at mask 0x00f0 of the instruction. */ #define USESF2 (0x2000) +#define USESF2_REG(x) ((x & 0x00f0) >> 4) /* This instruction uses floating point register 0. */ #define USESF0 (0x4000) @@ -1448,18 +1623,34 @@ struct sh_opcode /* This instruction sets the floating point register in the field at mask 0x0f00 of the instruction. */ #define SETSF1 (0x8000) +#define SETSF1_REG(x) ((x & 0x0f00) >> 8) + +#define USESAS (0x10000) +#define USESAS_REG(x) (((((x) >> 8) - 2) & 3) + 2) +#define USESR8 (0x20000) +#define SETSAS (0x40000) +#define SETSAS_REG(x) USESAS_REG (x) +#ifndef COFF_IMAGE_WITH_PE static boolean sh_insn_uses_reg PARAMS ((unsigned int, const struct sh_opcode *, unsigned int)); +static boolean sh_insn_sets_reg + PARAMS ((unsigned int, const struct sh_opcode *, unsigned int)); +static boolean sh_insn_uses_or_sets_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_insn_sets_freg + PARAMS ((unsigned int, const struct sh_opcode *, unsigned int)); +static boolean sh_insn_uses_or_sets_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 *)); - +#endif /* The opcode maps. */ #define MAP(a) a, sizeof a / sizeof a[0] @@ -1481,21 +1672,33 @@ static const struct sh_opcode sh_opcode00[] = 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 */ + { 0x005a, SETS1 | USESSP }, /* sts fpul,rn */ + { 0x006a, SETS1 | USESSP }, /* sts fpscr,rn / sts dsr,rn */ + { 0x0083, LOAD | USES1 }, /* pref @rn */ + { 0x007a, SETS1 | USESSP }, /* sts a0,rn */ + { 0x008a, SETS1 | USESSP }, /* sts x0,rn */ + { 0x009a, SETS1 | USESSP }, /* sts x1,rn */ + { 0x00aa, SETS1 | USESSP }, /* sts y0,rn */ + { 0x00ba, SETS1 | USESSP } /* sts y1,rn */ +}; + +/* These sixteen instructions can be handled with one table entry below. */ +#if 0 + { 0x0002, SETS1 | USESSP }, /* stc sr,rn */ + { 0x0012, SETS1 | USESSP }, /* stc gbr,rn */ + { 0x0022, SETS1 | USESSP }, /* stc vbr,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 */ + { 0x0052, SETS1 | USESSP }, /* stc mod,rn */ + { 0x0062, SETS1 | USESSP }, /* stc rs,rn */ + { 0x0072, SETS1 | USESSP }, /* stc re,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 */ @@ -1503,10 +1706,11 @@ static const struct sh_opcode sh_opcode01[] = { 0x00d2, SETS1 | USESSP }, /* stc r5_bank,rn */ { 0x00e2, SETS1 | USESSP }, /* stc r6_bank,rn */ { 0x00f2, SETS1 | USESSP } /* stc r7_bank,rn */ -}; +#endif static const struct sh_opcode sh_opcode02[] = { + { 0x0002, SETS1 | USESSP }, /* stc ,rn */ { 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) */ @@ -1586,74 +1790,108 @@ 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 */ + { 0x4014, SETSSP | USES1 }, /* setrc rm */ { 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 */ + { 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 / dsr,@-rn */ + { 0x4066, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,fpscr / dsr */ + { 0x406a, SETSSP | USES1 }, /* lds rm,fpscr / lds rm,dsr */ + { 0x4072, STORE | SETS1 | USES1 | USESSP }, /* sts.l a0,@-rn */ + { 0x4076, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,a0 */ + { 0x407a, SETSSP | USES1 }, /* lds.l rm,a0 */ + { 0x4082, STORE | SETS1 | USES1 | USESSP }, /* sts.l x0,@-rn */ + { 0x4086, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,x0 */ + { 0x408a, SETSSP | USES1 }, /* lds.l rm,x0 */ + { 0x4092, STORE | SETS1 | USES1 | USESSP }, /* sts.l x1,@-rn */ + { 0x4096, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,x1 */ + { 0x409a, SETSSP | USES1 }, /* lds.l rm,x1 */ + { 0x40a2, STORE | SETS1 | USES1 | USESSP }, /* sts.l y0,@-rn */ + { 0x40a6, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,y0 */ + { 0x40aa, SETSSP | USES1 }, /* lds.l rm,y0 */ + { 0x40b2, STORE | SETS1 | USES1 | USESSP }, /* sts.l y1,@-rn */ + { 0x40b6, LOAD | SETS1 | SETSSP | USES1 }, /* lds.l @rm+,y1 */ + { 0x40ba, SETSSP | USES1 } /* lds.l rm,y1 */ +#if 0 /* These groups sixteen insns can be + handled with one table entry each below. */ + { 0x4003, STORE | SETS1 | USES1 | USESSP }, /* stc.l sr,@-rn */ + { 0x4013, STORE | SETS1 | USES1 | USESSP }, /* stc.l gbr,@-rn */ + { 0x4023, STORE | SETS1 | USES1 | USESSP }, /* stc.l vbr,@-rn */ { 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 */ + { 0x4053, STORE | SETS1 | USES1 | USESSP }, /* stc.l mod,@-rn */ + { 0x4063, STORE | SETS1 | USES1 | USESSP }, /* stc.l rs,@-rn */ + { 0x4073, STORE | SETS1 | USES1 | USESSP }, /* stc.l re,@-rn */ + { 0x4083, STORE | SETS1 | USES1 | USESSP }, /* stc.l r0_bank,@-rn */ + .. + { 0x40f3, STORE | SETS1 | USES1 | USESSP }, /* stc.l r7_bank,@-rn */ + + { 0x4007, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,sr */ + { 0x4017, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,gbr */ + { 0x4027, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,vbr */ + { 0x4037, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,ssr */ { 0x4047, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,spc */ + { 0x4057, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,mod */ + { 0x4067, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,rs */ + { 0x4077, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,re */ + { 0x4087, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,r0_bank */ + .. + { 0x40f7, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+,r7_bank */ + + { 0x400e, SETSSP | USES1 }, /* ldc rm,sr */ + { 0x401e, SETSSP | USES1 }, /* ldc rm,gbr */ + { 0x402e, SETSSP | USES1 }, /* ldc rm,vbr */ + { 0x403e, SETSSP | USES1 }, /* ldc rm,ssr */ { 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 */ + { 0x405e, SETSSP | USES1 }, /* ldc rm,mod */ + { 0x406e, SETSSP | USES1 }, /* ldc rm,rs */ + { 0x407e, SETSSP | USES1 } /* ldc rm,re */ + { 0x408e, SETSSP | USES1 } /* ldc rm,r0_bank */ + .. + { 0x40fe, SETSSP | USES1 } /* ldc rm,r7_bank */ +#endif }; 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 */ + { 0x4003, STORE | SETS1 | USES1 | USESSP }, /* stc.l ,@-rn */ + { 0x4007, LOAD | SETS1 | SETSSP | USES1 }, /* ldc.l @rm+, */ + { 0x400c, SETS1 | USES1 | USES2 }, /* shad rm,rn */ + { 0x400d, SETS1 | USES1 | USES2 }, /* shld rm,rn */ + { 0x400e, SETSSP | USES1 }, /* ldc rm, */ { 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 } + { MAP (sh_opcode41), 0xf00f } }; static const struct sh_opcode sh_opcode50[] = @@ -1705,12 +1943,15 @@ 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) */ + { 0x8200, SETSSP }, /* setrc #imm */ { 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 */ + { 0x8c00, SETSSP }, /* ldrs @(disp,pc) */ { 0x8d00, BRANCH | DELAY | USESSP }, /* bt/s label */ + { 0x8e00, SETSSP }, /* ldre @(disp,pc) */ { 0x8f00, BRANCH | DELAY | USESSP } /* bf/s label */ }; @@ -1832,7 +2073,7 @@ static const struct sh_minor_opcode sh_opcodef[] = { MAP (sh_opcodef1), 0xf0ff } }; -static const struct sh_major_opcode sh_opcodes[] = +static struct sh_major_opcode sh_opcodes[] = { { MAP (sh_opcode0) }, { MAP (sh_opcode1) }, @@ -1852,6 +2093,27 @@ static const struct sh_major_opcode sh_opcodes[] = { MAP (sh_opcodef) } }; +/* The double data transfer / parallel processing insns are not + described here. This will cause sh_align_load_span to leave them alone. */ + +static const struct sh_opcode sh_dsp_opcodef0[] = +{ + { 0xf400, USESAS | SETSAS | LOAD | SETSSP }, /* movs.x @-as,ds */ + { 0xf401, USESAS | SETSAS | STORE | USESSP }, /* movs.x ds,@-as */ + { 0xf404, USESAS | LOAD | SETSSP }, /* movs.x @as,ds */ + { 0xf405, USESAS | STORE | USESSP }, /* movs.x ds,@as */ + { 0xf408, USESAS | SETSAS | LOAD | SETSSP }, /* movs.x @as+,ds */ + { 0xf409, USESAS | SETSAS | STORE | USESSP }, /* movs.x ds,@as+ */ + { 0xf40c, USESAS | SETSAS | LOAD | SETSSP | USESR8 }, /* movs.x @as+r8,ds */ + { 0xf40d, USESAS | SETSAS | STORE | USESSP | USESR8 } /* movs.x ds,@as+r8 */ +}; + +static const struct sh_minor_opcode sh_dsp_opcodef[] = +{ + { MAP (sh_dsp_opcodef0), 0xfc0d } +}; + +#ifndef COFF_IMAGE_WITH_PE /* Given an instruction, return a pointer to the corresponding sh_opcode structure. Return NULL if the instruction is not recognized. */ @@ -1885,6 +2147,20 @@ sh_insn_info (insn) return NULL; } +/* See whether an instruction uses or sets a general purpose register */ + +static boolean +sh_insn_uses_or_sets_reg (insn, op, reg) + unsigned int insn; + const struct sh_opcode *op; + unsigned int reg; +{ + if (sh_insn_uses_reg (insn, op, reg)) + return true; + + return sh_insn_sets_reg (insn, op, reg); +} + /* See whether an instruction uses a general purpose register. */ static boolean @@ -1898,18 +2174,63 @@ sh_insn_uses_reg (insn, op, reg) f = op->flags; if ((f & USES1) != 0 - && ((insn & 0x0f00) >> 8) == reg) + && USES1_REG (insn) == reg) return true; if ((f & USES2) != 0 - && ((insn & 0x00f0) >> 4) == reg) + && USES2_REG (insn) == reg) return true; if ((f & USESR0) != 0 && reg == 0) return true; + if ((f & USESAS) && reg == USESAS_REG (insn)) + return true; + if ((f & USESR8) && reg == 8) + return true; return false; } +/* See whether an instruction sets a general purpose register. */ + +static boolean +sh_insn_sets_reg (insn, op, reg) + unsigned int insn; + const struct sh_opcode *op; + unsigned int reg; +{ + unsigned int f; + + f = op->flags; + + if ((f & SETS1) != 0 + && SETS1_REG (insn) == reg) + return true; + if ((f & SETS2) != 0 + && SETS2_REG (insn) == reg) + return true; + if ((f & SETSR0) != 0 + && reg == 0) + return true; + if ((f & SETSAS) && reg == SETSAS_REG (insn)) + return true; + + return false; +} + +/* See whether an instruction uses or sets a floating point register */ + +static boolean +sh_insn_uses_or_sets_freg (insn, op, reg) + unsigned int insn; + const struct sh_opcode *op; + unsigned int reg; +{ + if (sh_insn_uses_freg (insn, op, reg)) + return true; + + return sh_insn_sets_freg (insn, op, reg); +} + /* See whether an instruction uses a floating point register. */ static boolean @@ -1932,10 +2253,10 @@ sh_insn_uses_freg (insn, op, freg) bit of the register number. */ if ((f & USESF1) != 0 - && ((insn & 0x0e00) >> 8) == (freg & 0xe)) + && (USESF1_REG (insn) & 0xe) == (freg & 0xe)) return true; if ((f & USESF2) != 0 - && ((insn & 0x00e0) >> 4) == (freg & 0xe)) + && (USESF2_REG (insn) & 0xe) == (freg & 0xe)) return true; if ((f & USESF0) != 0 && freg == 0) @@ -1944,6 +2265,34 @@ sh_insn_uses_freg (insn, op, freg) return false; } +/* See whether an instruction sets a floating point register. */ + +static boolean +sh_insn_sets_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 & SETSF1) != 0 + && (SETSF1_REG (insn) & 0xe) == (freg & 0xe)) + 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 @@ -1971,35 +2320,41 @@ sh_insns_conflict (i1, op1, i2, op2) || (f2 & (BRANCH | DELAY)) != 0) return true; - if ((f1 & SETSSP) != 0 && (f2 & USESSP) != 0) - return true; - if ((f2 & SETSSP) != 0 && (f1 & USESSP) != 0) + if (((f1 | f2) & SETSSP) + && (f1 & (SETSSP | USESSP)) + && (f2 & (SETSSP | USESSP))) return true; if ((f1 & SETS1) != 0 - && sh_insn_uses_reg (i2, op2, (i1 & 0x0f00) >> 8)) + && sh_insn_uses_or_sets_reg (i2, op2, SETS1_REG (i1))) return true; if ((f1 & SETS2) != 0 - && sh_insn_uses_reg (i2, op2, (i1 & 0x00f0) >> 4)) + && sh_insn_uses_or_sets_reg (i2, op2, SETS2_REG (i1))) return true; if ((f1 & SETSR0) != 0 - && sh_insn_uses_reg (i2, op2, 0)) + && sh_insn_uses_or_sets_reg (i2, op2, 0)) + return true; + if ((f1 & SETSAS) + && sh_insn_uses_or_sets_reg (i2, op2, SETSAS_REG (i1))) return true; if ((f1 & SETSF1) != 0 - && sh_insn_uses_freg (i2, op2, (i1 & 0x0f00) >> 8)) + && sh_insn_uses_or_sets_freg (i2, op2, SETSF1_REG (i1))) return true; if ((f2 & SETS1) != 0 - && sh_insn_uses_reg (i1, op1, (i2 & 0x0f00) >> 8)) + && sh_insn_uses_or_sets_reg (i1, op1, SETS1_REG (i2))) return true; if ((f2 & SETS2) != 0 - && sh_insn_uses_reg (i1, op1, (i2 & 0x00f0) >> 4)) + && sh_insn_uses_or_sets_reg (i1, op1, SETS2_REG (i2))) return true; if ((f2 & SETSR0) != 0 - && sh_insn_uses_reg (i1, op1, 0)) + && sh_insn_uses_or_sets_reg (i1, op1, 0)) + return true; + if ((f2 & SETSAS) + && sh_insn_uses_or_sets_reg (i1, op1, SETSAS_REG (i2))) return true; if ((f2 & SETSF1) != 0 - && sh_insn_uses_freg (i1, op1, (i2 & 0x0f00) >> 8)) + && sh_insn_uses_or_sets_freg (i1, op1, SETSF1_REG (i2))) return true; /* The instructions do not conflict. */ @@ -2052,6 +2407,9 @@ sh_load_use (i1, op1, i2, op2) STOP are the range of memory to examine. If a swap is made, *PSWAPPED is set to true. */ +#ifdef COFF_WITH_PE +static +#endif boolean _bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, plabel, label_end, start, stop, pswapped) @@ -2066,8 +2424,24 @@ _bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, bfd_vma stop; boolean *pswapped; { + int dsp = (abfd->arch_info->mach == bfd_mach_sh_dsp + || abfd->arch_info->mach == bfd_mach_sh3_dsp); bfd_vma i; + /* The SH4 has a Harvard architecture, hence aligning loads is not + desirable. In fact, it is counter-productive, since it interferes + with the schedules generated by the compiler. */ + if (abfd->arch_info->mach == bfd_mach_sh4) + return true; + + /* If we are linking sh[3]-dsp code, swap the FPU instructions for DSP + instructions. */ + if (dsp) + { + sh_opcodes[0xf].minor_opcodes = sh_dsp_opcodef; + sh_opcodes[0xf].count = sizeof sh_dsp_opcodef / sizeof sh_dsp_opcodef; + } + /* Instructions should be aligned on 2 byte boundaries. */ if ((start & 1) == 1) ++start; @@ -2097,7 +2471,28 @@ _bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, if (i > start) { prev_insn = bfd_get_16 (abfd, contents + i - 2); - prev_op = sh_insn_info (prev_insn); + /* If INSN is the field b of a parallel processing insn, it is not + a load / store after all. Note that the test here might mistake + the field_b of a pcopy insn for the starting code of a parallel + processing insn; this might miss a swapping opportunity, but at + least we're on the safe side. */ + if (dsp && (prev_insn & 0xfc00) == 0xf800) + continue; + + /* Check if prev_insn is actually the field b of a parallel + processing insn. Again, this can give a spurious match + after a pcopy. */ + if (dsp && i - 2 > start) + { + unsigned pprev_insn = bfd_get_16 (abfd, contents + i - 4); + + if ((pprev_insn & 0xfc00) == 0xf800) + prev_op = NULL; + else + prev_op = sh_insn_info (prev_insn); + } + else + prev_op = sh_insn_info (prev_insn); /* If the load/store instruction is in a delay slot, we can't swap. */ @@ -2224,6 +2619,7 @@ _bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, return true; } +#endif /* not COFF_IMAGE_WITH_PE */ /* Look for loads and stores which we can align to four byte boundaries. See the longer comment above sh_relax_section for why @@ -2437,7 +2833,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) static boolean sh_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, syms, sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -2464,6 +2860,10 @@ sh_relocate_section (output_bfd, info, input_bfd, input_section, contents, /* 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 +#ifdef COFF_WITH_PE + && rel->r_type != R_SH_IMM32CE + && rel->r_type != R_SH_IMAGEBASE +#endif && rel->r_type != R_SH_PCDISP) continue; @@ -2508,6 +2908,11 @@ sh_relocate_section (output_bfd, info, input_bfd, input_section, contents, return false; } +#ifdef COFF_WITH_PE + if (rel->r_type == R_SH_IMAGEBASE) + addend -= pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase; +#endif + val = 0; if (h == NULL) @@ -2548,7 +2953,7 @@ sh_relocate_section (output_bfd, info, input_bfd, input_section, contents, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -2704,90 +3109,29 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, /* 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}, +#ifndef TARGET_SHL_SYM +CREATE_BIG_COFF_TARGET_VEC (shcoff_vec, "coff-sh", BFD_IS_RELAXABLE, 0, '_', NULL) +#endif - 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), +#ifdef TARGET_SHL_SYM +#define TARGET_SYM TARGET_SHL_SYM +#else +#define TARGET_SYM shlcoff_vec +#endif + +#ifndef TARGET_SHL_NAME +#define TARGET_SHL_NAME "coff-shl" +#endif - COFF_SWAP_TABLE, -}; +#ifdef COFF_WITH_PE +CREATE_LITTLE_COFF_TARGET_VEC (TARGET_SYM, TARGET_SHL_NAME, BFD_IS_RELAXABLE, + SEC_CODE | SEC_DATA, '_', NULL); +#else +CREATE_LITTLE_COFF_TARGET_VEC (TARGET_SYM, TARGET_SHL_NAME, BFD_IS_RELAXABLE, + 0, '_', NULL) +#endif +#ifndef TARGET_SHL_SYM /* 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 @@ -2842,7 +3186,7 @@ static const bfd_coff_backend_data bfd_coff_small_swap_table = 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, + FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN, #ifdef COFF_LONG_FILENAMES true, #else @@ -2859,7 +3203,7 @@ static const bfd_coff_backend_data bfd_coff_small_swap_table = 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_classify_symbol, 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 @@ -2874,6 +3218,8 @@ static const bfd_coff_backend_data bfd_coff_small_swap_table = #define coff_small_get_section_contents_in_window \ coff_get_section_contents_in_window +extern const bfd_target shlcoff_small_vec; + const bfd_target shcoff_small_vec = { "coff-sh-small", /* name */ @@ -2913,6 +3259,8 @@ const bfd_target shcoff_small_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & shlcoff_small_vec, + (PTR) &bfd_coff_small_swap_table }; @@ -2955,5 +3303,8 @@ const bfd_target shlcoff_small_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + & shcoff_small_vec, + (PTR) &bfd_coff_small_swap_table }; +#endif diff --git a/bfd/coff-sparc.c b/bfd/coff-sparc.c index bc2cf15..5e919da 100644 --- a/bfd/coff-sparc.c +++ b/bfd/coff-sparc.c @@ -1,5 +1,6 @@ /* BFD back-end for Sparc COFF files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 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. @@ -77,13 +78,13 @@ bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, static bfd_reloc_status_type bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0) @@ -158,7 +159,7 @@ static CONST struct coff_reloc_map sparc_reloc_map[] = static reloc_howto_type * coff_sparc_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -202,55 +203,12 @@ rtype2howto (cache_ptr, dst) #include "coffcode.h" -const bfd_target -#ifdef TARGET_SYM - TARGET_SYM = -#else - sparccoff_vec = +#ifndef TARGET_SYM +#define TARGET_SYM 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), +#ifndef TARGET_NAME +#define TARGET_NAME "coff-sparc" +#endif - COFF_SWAP_TABLE, -}; +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL) diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index 21724fe..26dba40 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 COFF files (go32 variant with a stub). - Copyright 1997, 1998 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999 Free Software Foundation, Inc. Written by Robert Hoehne. This file is part of BFD, the Binary File Descriptor library. @@ -39,6 +39,14 @@ #define TARGET_NAME "coff-go32-exe" #define TARGET_UNDERSCORE '_' #define COFF_GO32_EXE +#define COFF_LONG_SECTION_NAMES +#define COFF_SUPPORT_GNU_LINKONCE + +#define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 } #include "bfd.h" @@ -103,58 +111,6 @@ static boolean 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' */ @@ -223,9 +179,9 @@ adjust_filehdr_out_pre (abfd, in, out) static void adjust_filehdr_out_post (abfd, in, out) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR in; - PTR out; + PTR out ATTRIBUTE_UNUSED; { struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; /* undo the above change */ @@ -234,8 +190,8 @@ adjust_filehdr_out_post (abfd, in, out) static void adjust_scnhdr_in_post (abfd, ext, in) - bfd *abfd; - PTR ext; + bfd *abfd ATTRIBUTE_UNUSED; + PTR ext ATTRIBUTE_UNUSED; PTR in; { struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; @@ -247,9 +203,9 @@ adjust_scnhdr_in_post (abfd, ext, in) static void adjust_scnhdr_out_pre (abfd, in, out) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR in; - PTR out; + PTR out ATTRIBUTE_UNUSED; { struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; @@ -260,9 +216,9 @@ adjust_scnhdr_out_pre (abfd, in, out) static void adjust_scnhdr_out_post (abfd, in, out) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR in; - PTR out; + PTR out ATTRIBUTE_UNUSED; { struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; @@ -273,12 +229,12 @@ adjust_scnhdr_out_post (abfd, in, out) static void adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1) - bfd *abfd; - PTR ext1; + bfd *abfd ATTRIBUTE_UNUSED; + PTR ext1 ATTRIBUTE_UNUSED; int type; int class; - int indx; - int numaux; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; PTR in1; { union internal_auxent *in = (union internal_auxent *) in1; @@ -291,13 +247,13 @@ adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1) static void adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR inp; int type; int class; - int indx; - int numaux; - PTR extp; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; + PTR extp ATTRIBUTE_UNUSED; { union internal_auxent *in = (union internal_auxent *) inp; @@ -309,13 +265,13 @@ adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp) static void adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR inp; int type; int class; - int indx; - int numaux; - PTR extp; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; + PTR extp ATTRIBUTE_UNUSED; { union internal_auxent *in = (union internal_auxent *) inp; diff --git a/bfd/coff-tic30.c b/bfd/coff-tic30.c index 3ff8c59..a971f76 100644 --- a/bfd/coff-tic30.c +++ b/bfd/coff-tic30.c @@ -1,5 +1,5 @@ /* BFD back-end for TMS320C30 coff binaries. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 1999 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. @@ -41,7 +41,7 @@ reloc_howto_type tic30_coff_howto_table[] = "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false), HOWTO (R_TIC30_PC16, 2, 1, 16, true, 0, complain_overflow_signed, NULL, "PCREL", false, 0x0000FFFF, 0x0000FFFF, false), - {-1} + EMPTY_HOWTO (-1) }; #ifndef coff_bfd_reloc_type_lookup @@ -52,7 +52,7 @@ reloc_howto_type tic30_coff_howto_table[] = and coff implementations. */ reloc_howto_type * tic30_coff_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -202,5 +202,7 @@ const bfd_target tic30_coff_vec = BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + COFF_SWAP_TABLE }; diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c index 043c8a0..a8ade33 100644 --- a/bfd/coff-tic80.c +++ b/bfd/coff-tic80.c @@ -1,5 +1,5 @@ /* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP). - Copyright 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Fred Fish (fnf@cygnus.com) @@ -359,13 +359,13 @@ static reloc_howto_type tic80_howto_table[] = 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol_in ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* FIXME. */ abort (); @@ -376,13 +376,13 @@ ppbase_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol_in ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* FIXME. */ abort (); @@ -393,13 +393,13 @@ glob15_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol_in ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* FIXME. */ abort (); @@ -410,13 +410,13 @@ glob16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol_in ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* FIXME. */ abort (); @@ -452,11 +452,11 @@ rtype2howto (cache_ptr, dst) static reloc_howto_type * coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; bfd_vma *addendp; { arelent genrel; @@ -576,7 +576,7 @@ coff_tic80_relocate_section (output_bfd, info, input_bfd, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } @@ -715,45 +715,4 @@ coff_tic80_relocate_section (output_bfd, info, input_bfd, #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 - }; +CREATE_LITTLE_COFF_TARGET_VEC (tic80coff_vec, "coff-tic80", D_PAGED, 0, '_', NULL) diff --git a/bfd/coff-w65.c b/bfd/coff-w65.c index 28d68c3..0379bfb 100644 --- a/bfd/coff-w65.c +++ b/bfd/coff-w65.c @@ -401,45 +401,4 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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, -}; +CREATE_LITTLE_COFF_TARGET_VEC (w65_vec, "coff-w95", BFD_IS_RELAXABLE, 0, '_', NULL) diff --git a/bfd/coff-we32k.c b/bfd/coff-we32k.c index 826bbe3..c559ad7 100644 --- a/bfd/coff-we32k.c +++ b/bfd/coff-we32k.c @@ -1,5 +1,5 @@ /* BFD back-end for we32k COFF files. - Copyright (C) 1992, 93, 94, 95, 1997 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 97, 1999 Free Software Foundation, Inc. Contributed by Brendan Kehoe (brendan@cs.widener.edu). This file is part of BFD, the Binary File Descriptor library. @@ -29,21 +29,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static reloc_howto_type howto_table[] = { - {0}, - {1}, - {2}, - {3}, - {4}, - {5}, + EMPTY_HOWTO (0), + EMPTY_HOWTO (1), + EMPTY_HOWTO (2), + EMPTY_HOWTO (3), + EMPTY_HOWTO (4), + EMPTY_HOWTO (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}, + EMPTY_HOWTO (7), + EMPTY_HOWTO (010), + EMPTY_HOWTO (011), + EMPTY_HOWTO (012), + EMPTY_HOWTO (013), + EMPTY_HOWTO (014), + EMPTY_HOWTO (015), + EMPTY_HOWTO (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), @@ -65,45 +65,4 @@ static reloc_howto_type howto_table[] = #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, -}; +CREATE_BIG_COFF_TARGET_VEC (we32kcoff_vec, "coff-we32k", 0, 0, 0, NULL) diff --git a/bfd/coff-z8k.c b/bfd/coff-z8k.c index 04049e8..21f29a8 100644 --- a/bfd/coff-z8k.c +++ b/bfd/coff-z8k.c @@ -237,44 +237,4 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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, -}; +CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL) diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 383719c..8193a21 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1,5 +1,5 @@ /* Support for the generic parts of most COFF variants, for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -131,7 +131,7 @@ SUBSUBSECTION 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 + and @code{coff_swap_lineno_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}, @@ -313,8 +313,12 @@ CODE_FRAGMENT #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 flagword styp_to_sec_flags + PARAMS ((bfd *, PTR, const char *, asection *)); static boolean coff_bad_format_hook PARAMS ((bfd *, PTR)); +static void coff_set_custom_section_alignment + PARAMS ((bfd *, asection *, const struct coff_section_alignment_entry *, + const unsigned int)); 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)); @@ -329,6 +333,8 @@ static boolean coff_set_section_contents 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 enum coff_symbol_classification coff_classify_symbol + PARAMS ((bfd *, struct internal_syment *)); static boolean coff_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **)); static long coff_canonicalize_reloc PARAMS ((bfd *, asection *, arelent **, asymbol **)); @@ -338,12 +344,13 @@ static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR)); /* 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(). - */ +/* 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 probably mirror the changes in styp_to_sec_flags(). */ + +#ifndef COFF_WITH_PE + static long sec_to_styp_flags (sec_name, sec_flags) CONST char *sec_name; @@ -393,12 +400,6 @@ sec_to_styp_flags (sec_name, sec_flags) { 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)) { @@ -440,25 +441,93 @@ sec_to_styp_flags (sec_name, sec_flags) 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; +} + +#else /* COFF_WITH_PE */ - return (styp_flags); +/* The PE version; see above for the general comments. The non-PE + case seems to be more guessing, and breaks PE format; specifically, + .rdata is readonly, but it sure ain't text. Really, all this + should be set up properly in gas (or whatever assembler is in use), + and honor whatever objcopy/strip, etc. sent us as input. */ + +static long +sec_to_styp_flags (sec_name, sec_flags) + const char *sec_name ATTRIBUTE_UNUSED; + flagword sec_flags; +{ + long styp_flags = 0; + + /* caution: there are at least three groups of symbols that have + very similar bits and meanings: IMAGE_SCN*, SEC_*, and STYP_*. + SEC_* are the BFD internal flags, used for generic BFD + information. STYP_* are the COFF section flags which appear in + COFF files. IMAGE_SCN_* are the PE section flags which appear in + PE files. The STYP_* flags and the IMAGE_SCN_* flags overlap, + but there are more IMAGE_SCN_* flags. */ + + /* skip LOAD */ + /* READONLY later */ + /* skip RELOC */ + if ((sec_flags & SEC_CODE) != 0) + styp_flags |= IMAGE_SCN_CNT_CODE; + if ((sec_flags & SEC_DATA) != 0) + styp_flags |= IMAGE_SCN_CNT_INITIALIZED_DATA; + if ((sec_flags & SEC_ALLOC) != 0 && (sec_flags & SEC_LOAD) == 0) + styp_flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA; /* ==STYP_BSS */ + /* skip ROM */ + /* skip CONSTRUCTOR */ + /* skip CONTENTS */ +#ifdef STYP_NOLOAD + if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0) + styp_flags |= STYP_NOLOAD; +#endif + if ((sec_flags & SEC_IS_COMMON) != 0) + styp_flags |= IMAGE_SCN_LNK_COMDAT; + if ((sec_flags & SEC_DEBUGGING) != 0) + styp_flags |= IMAGE_SCN_MEM_DISCARDABLE; + if ((sec_flags & SEC_EXCLUDE) != 0) + styp_flags |= IMAGE_SCN_LNK_REMOVE; + if ((sec_flags & SEC_NEVER_LOAD) != 0) + styp_flags |= IMAGE_SCN_LNK_REMOVE; + /* skip IN_MEMORY */ + /* skip SORT */ + if (sec_flags & SEC_LINK_ONCE) + styp_flags |= IMAGE_SCN_LNK_COMDAT; + /* skip LINK_DUPLICATES */ + /* skip LINKER_CREATED */ + + /* For now, the read/write bits are mapped onto SEC_READONLY, even + though the semantics don't quite match. The bits from the input + are retained in pei_section_data(abfd, section)->pe_flags */ + + styp_flags |= IMAGE_SCN_MEM_READ; /* always readable. */ + if ((sec_flags & SEC_READONLY) == 0) + styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write */ + if (sec_flags & SEC_CODE) + styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE */ + if (sec_flags & SEC_SHARED) + styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful */ + + 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(). - */ + +#endif /* COFF_WITH_PE */ + +/* 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 probably mirror the changes in sec_to_styp_flags(). */ + +#ifndef COFF_WITH_PE + static flagword -styp_to_sec_flags (abfd, hdr, name) - bfd *abfd; +styp_to_sec_flags (abfd, hdr, name, section) + bfd *abfd ATTRIBUTE_UNUSED; PTR hdr; const char *name; + asection *section ATTRIBUTE_UNUSED; { struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; long styp_flags = internal_s->s_flags; @@ -573,10 +642,99 @@ styp_to_sec_flags (abfd, hdr, name) } #endif /* STYP_SDATA */ -#ifdef COFF_WITH_PE +#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) + /* 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) + sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; +#endif + + return sec_flags; +} + +#else /* COFF_WITH_PE */ + +/* The PE version; see above for the general comments. + + Since to set the SEC_LINK_ONCE and associated flags, we have to + look at the symbol table anyway, we return the symbol table index + of the symbol being used as the COMDAT symbol. This is admittedly + ugly, but there's really nowhere else that we have access to the + required information. FIXME: Is the COMDAT symbol index used for + any purpose other than objdump? */ + +static flagword +styp_to_sec_flags (abfd, hdr, name, section) + bfd *abfd ATTRIBUTE_UNUSED; + PTR hdr; + const char *name; + asection *section; +{ + struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; + long styp_flags = internal_s->s_flags; + flagword sec_flags = 0; + + if (styp_flags & STYP_DSECT) + abort (); /* Don't know what to do */ +#ifdef SEC_NEVER_LOAD + if (styp_flags & STYP_NOLOAD) + sec_flags |= SEC_NEVER_LOAD; +#endif + if (styp_flags & STYP_GROUP) + abort (); /* Don't know what to do */ + /* skip IMAGE_SCN_TYPE_NO_PAD */ + if (styp_flags & STYP_COPY) + abort (); /* Don't know what to do */ + if (styp_flags & IMAGE_SCN_CNT_CODE) + sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; + if (styp_flags & IMAGE_SCN_CNT_INITIALIZED_DATA) + sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; + if (styp_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) + sec_flags |= SEC_ALLOC; + if (styp_flags & IMAGE_SCN_LNK_OTHER) + abort (); /* Don't know what to do */ + if (styp_flags & IMAGE_SCN_LNK_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. */ +#ifdef COFF_PAGE_SIZE + sec_flags |= SEC_DEBUGGING; +#endif + } + if (styp_flags & STYP_OVER) + abort (); /* Don't know what to do */ if (styp_flags & IMAGE_SCN_LNK_REMOVE) sec_flags |= SEC_EXCLUDE; + if (styp_flags & IMAGE_SCN_MEM_SHARED) + sec_flags |= SEC_SHARED; + /* COMDAT: see below */ + if (styp_flags & IMAGE_SCN_MEM_DISCARDABLE) + sec_flags |= SEC_DEBUGGING; + if (styp_flags & IMAGE_SCN_MEM_NOT_CACHED) + abort ();/* Don't know what to do */ + if (styp_flags & IMAGE_SCN_MEM_NOT_PAGED) + abort (); /* Don't know what to do */ + + /* We infer from the distinct read/write/execute bits the settings + of some of the bfd flags; the actual values, should we need them, + are also in pei_section_data (abfd, section)->pe_flags. */ + + if (styp_flags & IMAGE_SCN_MEM_EXECUTE) + sec_flags |= SEC_CODE; /* Probably redundant */ + /* IMAGE_SCN_MEM_READ is simply ignored, assuming it always to be true. */ + if ((styp_flags & IMAGE_SCN_MEM_WRITE) == 0) + sec_flags |= SEC_READONLY; + + /* COMDAT gets very special treatment. */ if (styp_flags & IMAGE_SCN_LNK_COMDAT) { sec_flags |= SEC_LINK_ONCE; @@ -588,16 +746,30 @@ styp_to_sec_flags (abfd, hdr, name) can't call slurp_symtab, because the linker doesn't want the swapped symbols. */ + /* COMDAT sections are special. The first symbol is the section + symbol, which tells what kind of COMDAT section it is. The + second symbol is the "comdat symbol" - the one with the + unique name. GNU uses the section symbol for the unique + name; MS uses ".text" for every comdat section. Sigh. - DJ */ + + /* This is not mirrored in sec_to_styp_flags(), but there + doesn't seem to be a need to, either, and it would at best be + rather messy. */ + if (_bfd_coff_get_external_symbols (abfd)) { - bfd_byte *esym, *esymend; + bfd_byte *esymstart, *esym, *esymend; + int seen_state = 0; + char *target_name = NULL; - esym = (bfd_byte *) obj_coff_external_syms (abfd); - esymend = esym + obj_raw_syment_count (abfd) * SYMESZ; + esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); + esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); while (esym < esymend) { struct internal_syment isym; + char buf[SYMNMLEN + 1]; + const char *symname; bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym); @@ -608,65 +780,223 @@ styp_to_sec_flags (abfd, hdr, name) abort (); } - if (isym.n_sclass == C_STAT - && isym.n_type == T_NULL - && isym.n_numaux == 1) + if (isym.n_scnum == section->target_index) { - char buf[SYMNMLEN + 1]; - const char *symname; - + /* According to the MSVC documentation, the first + TWO entries with the section # are both of + interest to us. The first one is the "section + symbol" (section name). The second is the comdat + symbol name. Here, we've found the first + qualifying entry; we distinguish it from the + second with a state flag. + + In the case of gas-generated (at least until that + is fixed) .o files, it isn't necessarily the + second one. It may be some other later symbol. + + Since gas also doesn't follow MS conventions and + emits the section similar to .text$, where + is the name we're looking for, we + distinguish the two as follows: + + If the section name is simply a section name (no + $) we presume it's MS-generated, and look at + precisely the second symbol for the comdat name. + If the section name has a $, we assume it's + gas-generated, and look for (whatever + follows the $) as the comdat symbol. */ + + /* All 3 branches use this */ symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); + if (symname == NULL) abort (); - if (strcmp (name, symname) == 0) + switch (seen_state) { - union internal_auxent aux; + case 0: + { + /* The first time we've seen the symbol. */ + union internal_auxent aux; + + seen_state = 1; + + /* If it isn't the stuff we're expecting, die; + The MS documentation is vague, but it + appears that the second entry serves BOTH + as the comdat symbol and the defining + symbol record (either C_STAT or C_EXT, + possibly with an aux entry with debug + information if it's a function.) It + appears the only way to find the second one + is to count. (On Intel, they appear to be + adjacent, but on Alpha, they have been + found separated.) + + Here, we think we've found the first one, + but there's some checking we can do to be + sure. */ + + if (! (isym.n_sclass == C_STAT + && isym.n_type == T_NULL + && isym.n_value == 0)) + abort (); + + /* FIXME LATER: MSVC generates section names + like .text for comdats. Gas generates + names like .text$foo__Fv (in the case of a + function). See comment above for more. */ + + if (strcmp (name, symname) != 0) + abort (); + + /* This is the section symbol. */ + + bfd_coff_swap_aux_in (abfd, (PTR) (esym + bfd_coff_symesz (abfd)), + isym.n_type, isym.n_sclass, + 0, isym.n_numaux, (PTR) &aux); + + target_name = strchr (name, '$'); + if (target_name != NULL) + { + /* Gas mode. */ + seen_state = 2; + /* Skip the `$'. */ + target_name += 1; + } + + /* FIXME: Microsoft uses NODUPLICATES and + ASSOCIATIVE, but gnu uses ANY and + SAME_SIZE. Unfortunately, gnu doesn't do + the comdat symbols right. So, until we can + fix it to do the right thing, we are + temporarily disabling comdats for the MS + types (they're used in DLLs and C++, but we + don't support *their* C++ libraries anyway + - DJ. */ + + /* Cygwin does not follow the MS style, and + uses ANY and SAME_SIZE where NODUPLICATES + and ASSOCIATIVE should be used. For + Interix, we just do the right thing up + front. */ + + switch (aux.x_scn.x_comdat) + { + case IMAGE_COMDAT_SELECT_NODUPLICATES: +#ifdef STRICT_PE_FORMAT + sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY; +#else + sec_flags &= ~SEC_LINK_ONCE; +#endif + break; + + 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: + /* Not yet fully implemented ??? */ + sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; + break; + + /* debug$S gets this case; other + implications ??? */ + + /* There may be no symbol... we'll search + the whole table... Is this the right + place to play this game? Or should we do + it when reading it in. */ + case IMAGE_COMDAT_SELECT_ASSOCIATIVE: +#ifdef STRICT_PE_FORMAT + /* FIXME: This is not currently implemented. */ + sec_flags |= SEC_LINK_DUPLICATES_DISCARD; +#else + sec_flags &= ~SEC_LINK_ONCE; +#endif + break; - /* This is the section symbol. */ + default: /* 0 means "no symbol" */ + /* debug$F gets this case; other + implications ??? */ + sec_flags |= SEC_LINK_DUPLICATES_DISCARD; + break; + } + } + break; - bfd_coff_swap_aux_in (abfd, (PTR) (esym + SYMESZ), - isym.n_type, isym.n_sclass, - 0, isym.n_numaux, (PTR) &aux); + case 2: + /* Gas mode: the first matching on partial name. */ - switch (aux.x_scn.x_comdat) +#ifndef TARGET_UNDERSCORE +#define TARGET_UNDERSCORE 0 +#endif + /* Is this the name we're looking for? */ + if (strcmp (target_name, + symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) { - 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; + /* Not the name we're looking for */ + esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd); + continue; } - - break; + /* Fall through. */ + case 1: + /* MSVC mode: the lexically second symbol (or + drop through from the above). */ + { + char *newname; + + /* This must the the second symbol with the + section #. It is the actual symbol name. + Intel puts the two adjacent, but Alpha (at + least) spreads them out. */ + + section->comdat = + bfd_alloc (abfd, sizeof (struct bfd_comdat_info)); + if (section->comdat == NULL) + abort (); + section->comdat->symbol = + (esym - esymstart) / bfd_coff_symesz (abfd); + + newname = bfd_alloc (abfd, strlen (symname) + 1); + if (newname == NULL) + abort (); + + strcpy (newname, symname); + section->comdat->name = newname; + + } + + goto breakloop; } } - esym += (isym.n_numaux + 1) * SYMESZ; + esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd); } + breakloop: } } + +#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) + /* 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) + sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; #endif - return (sec_flags); + return sec_flags; } +#endif /* COFF_WITH_PE */ + #define get_index(symbol) ((symbol)->udata.i) /* @@ -675,6 +1005,22 @@ INTERNAL_DEFINITION CODE_FRAGMENT +.{* COFF symbol classifications. *} +. +.enum coff_symbol_classification +.{ +. {* Global symbol. *} +. COFF_SYMBOL_GLOBAL, +. {* Common symbol. *} +. COFF_SYMBOL_COMMON, +. {* Undefined symbol. *} +. COFF_SYMBOL_UNDEFINED, +. {* Local symbol. *} +. COFF_SYMBOL_LOCAL, +. {* PE section symbol. *} +. COFF_SYMBOL_PE_SECTION +.}; +. Special entry points for gdb to swap in coff symbol table parts: .typedef struct .{ @@ -750,6 +1096,7 @@ dependent COFF routines: . unsigned int _bfd_auxesz; . unsigned int _bfd_relsz; . unsigned int _bfd_linesz; +. unsigned int _bfd_filnmlen; . boolean _bfd_coff_long_filenames; . boolean _bfd_coff_long_section_names; . unsigned int _bfd_coff_default_section_alignment_power; @@ -782,7 +1129,8 @@ dependent COFF routines: . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( . bfd *abfd, . PTR internal_scnhdr, -. const char *name)); +. const char *name, +. asection *section)); . void (*_bfd_set_alignment_hook) PARAMS (( . bfd *abfd, . asection *sec, @@ -819,7 +1167,7 @@ dependent COFF routines: . arelent *r, . unsigned int shrink, . struct bfd_link_info *link_info)); -. boolean (*_bfd_coff_sym_is_global) PARAMS (( +. enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS (( . bfd *abfd, . struct internal_syment *)); . boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( @@ -910,6 +1258,7 @@ dependent COFF routines: .#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_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen) .#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) @@ -935,8 +1284,9 @@ dependent COFF routines: .#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_styp_to_sec_flags_hook(abfd, scnhdr, name, section)\ +. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\ +. (abfd, scnhdr, name, section)) . .#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ . ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) @@ -959,8 +1309,8 @@ dependent COFF routines: . ((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)\ +.#define bfd_coff_classify_symbol(abfd, sym)\ +. ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\ . (abfd, sym)) . .#define bfd_coff_compute_section_file_positions(abfd)\ @@ -994,7 +1344,7 @@ dependent COFF routines: static boolean coff_bad_format_hook (abfd, filehdr) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; PTR filehdr; { struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; @@ -1012,22 +1362,80 @@ coff_bad_format_hook (abfd, filehdr) */ #if defined(M88) || defined(I960) - if (internal_f->f_opthdr != 0 && AOUTSZ != internal_f->f_opthdr) + if (internal_f->f_opthdr != 0 && bfd_coff_aoutsz (abfd) != internal_f->f_opthdr) return false; #endif return true; } -/* - initialize a section structure with information peculiar to this - particular implementation of coff -*/ +/* Check whether this section uses an alignment other than the + default. */ + +static void +coff_set_custom_section_alignment (abfd, section, alignment_table, table_size) + bfd *abfd ATTRIBUTE_UNUSED; + asection *section; + const struct coff_section_alignment_entry *alignment_table; + const unsigned int table_size; +{ + const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; + unsigned int i; + + for (i = 0; i < table_size; ++i) + { + const char *secname = bfd_get_section_name (abfd, section); + if (alignment_table[i].comparison_length == (unsigned int) -1 + ? strcmp (alignment_table[i].name, secname) == 0 + : strncmp (alignment_table[i].name, secname, + alignment_table[i].comparison_length) == 0) + break; + } + if (i >= table_size) + return; + + if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY + && default_alignment < alignment_table[i].default_alignment_min) + return; + + if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY + && default_alignment > alignment_table[i].default_alignment_max) + return; + + section->alignment_power = alignment_table[i].alignment_power; +} + +/* Custom section alignment records. */ + +static const struct coff_section_alignment_entry +coff_section_alignment_table[] = +{ +#ifdef COFF_SECTION_ALIGNMENT_ENTRIES + COFF_SECTION_ALIGNMENT_ENTRIES, +#endif + /* There must not be any gaps between .stabstr sections. */ + { COFF_SECTION_NAME_PARTIAL_MATCH (".stabstr"), + 1, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, + /* The .stab section must be aligned to 2**2 at most, to avoid gaps. */ + { COFF_SECTION_NAME_PARTIAL_MATCH (".stab"), + 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, + /* Similarly for the .ctors and .dtors sections. */ + { COFF_SECTION_NAME_EXACT_MATCH (".ctors"), + 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, + { COFF_SECTION_NAME_EXACT_MATCH (".dtors"), + 3, COFF_ALIGNMENT_FIELD_EMPTY, 2 } +}; + +static const unsigned int coff_section_alignment_table_size = + sizeof coff_section_alignment_table / sizeof coff_section_alignment_table[0]; + +/* 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; + bfd *abfd; + asection *section; { combined_entry_type *native; @@ -1063,22 +1471,9 @@ coff_new_section_hook (abfd, section) 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; + coff_set_custom_section_alignment (abfd, section, + coff_section_alignment_table, + coff_section_alignment_table_size); return true; } @@ -1091,7 +1486,7 @@ static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR)); static void coff_set_alignment_hook (abfd, section, scnhdr) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; asection * section; PTR scnhdr; { @@ -1131,7 +1526,7 @@ static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR)); static void coff_set_alignment_hook (abfd, section, scnhdr) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; asection * section; PTR scnhdr; { @@ -1145,66 +1540,34 @@ coff_set_alignment_hook (abfd, section, scnhdr) 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) + section, while the s_size field holds the raw size. We also keep + the original section flag value, since not every bit can be + mapped onto a generic BFD section bit. */ + if (coff_section_data (abfd, section) == NULL) { - 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) { - section->used_by_bfd = - (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)); - if (section->used_by_bfd == NULL) - { - /* FIXME: Return error. */ - abort (); - } + /* FIXME: Return error. */ + abort (); } - if (pei_section_data (abfd, section) == NULL) + } + 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) { - 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 (); - } + /* FIXME: Return error. */ + abort (); } - pei_section_data (abfd, section)->virt_size = hdr->s_paddr; } -#endif + pei_section_data (abfd, section)->virt_size = hdr->s_paddr; + pei_section_data (abfd, section)->pe_flags = hdr->s_flags; + section->lma = hdr->s_vaddr; } #undef ALIGN_SET #undef ELIFALIGN_SET @@ -1290,7 +1653,7 @@ static PTR coff_mkobject_hook (abfd, filehdr, aouthdr) bfd * abfd; PTR filehdr; - PTR aouthdr; + PTR aouthdr ATTRIBUTE_UNUSED; { struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; coff_data_type *coff; @@ -1309,9 +1672,11 @@ coff_mkobject_hook (abfd, filehdr, aouthdr) 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; + coff->local_symesz = bfd_coff_symesz (abfd); + coff->local_auxesz = bfd_coff_auxesz (abfd); + coff->local_linesz = bfd_coff_linesz (abfd); + + coff->timestamp = internal_f->f_timdat; obj_raw_syment_count (abfd) = obj_conv_table_size (abfd) = @@ -1320,7 +1685,7 @@ coff_mkobject_hook (abfd, filehdr, aouthdr) #ifdef RS6000COFF_C if ((internal_f->f_flags & F_SHROBJ) != 0) abfd->flags |= DYNAMIC; - if (aouthdr != NULL && internal_f->f_opthdr >= AOUTSZ) + if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) { struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr; @@ -1346,6 +1711,13 @@ coff_mkobject_hook (abfd, filehdr, aouthdr) coff->flags = 0; #endif +#ifdef COFF_WITH_PE + /* FIXME: I'm not sure this is ever executed, since peicode.h + defines coff_mkobject_hook. */ + if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) + abfd->flags |= HAS_DEBUG; +#endif + return (PTR) coff; } #endif @@ -1393,14 +1765,19 @@ coff_set_arch_mach_hook (abfd, filehdr) #endif #ifdef ARMMAGIC case ARMMAGIC: + case ARMPEMAGIC: + case THUMBPEMAGIC: 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; + case F_ARM_2: machine = bfd_mach_arm_2; break; + case F_ARM_2a: machine = bfd_mach_arm_2a; break; + case F_ARM_3: machine = bfd_mach_arm_3; break; + default: + case F_ARM_3M: machine = bfd_mach_arm_3M; break; + case F_ARM_4: machine = bfd_mach_arm_4; break; + case F_ARM_4T: machine = bfd_mach_arm_4T; break; + case F_ARM_5: machine = bfd_mach_arm_5; break; } break; #endif @@ -1505,17 +1882,23 @@ coff_set_arch_mach_hook (abfd, filehdr) cputype = 0; else { - bfd_byte buf[SYMESZ]; + bfd_byte *buf; struct internal_syment sym; + buf = (bfd_byte *) bfd_malloc (bfd_coff_symesz (abfd)); if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 - || bfd_read (buf, 1, SYMESZ, abfd) != SYMESZ) - return false; + || (bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd) + != bfd_coff_symesz (abfd))) + { + free (buf); + 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; + free (buf); } } @@ -1594,11 +1977,21 @@ coff_set_arch_mach_hook (abfd, filehdr) #ifdef SH_ARCH_MAGIC_BIG case SH_ARCH_MAGIC_BIG: case SH_ARCH_MAGIC_LITTLE: +#ifdef COFF_WITH_PE + case SH_ARCH_MAGIC_WINCE: +#endif arch = bfd_arch_sh; machine = 0; break; #endif +#ifdef MIPS_ARCH_MAGIC_WINCE + case MIPS_ARCH_MAGIC_WINCE: + arch = bfd_arch_mips; + machine = 0; + break; +#endif + #ifdef H8500MAGIC case H8500MAGIC: arch = bfd_arch_h8500; @@ -1649,7 +2042,7 @@ static boolean symname_in_debug_hook static boolean symname_in_debug_hook (abfd, sym) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; struct internal_syment *sym; { return SYMNAME_IN_DEBUG (sym) ? true : false; @@ -1673,7 +2066,7 @@ static boolean coff_pointerize_aux_hook /*ARGSUSED*/ static boolean coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; combined_entry_type *table_base; combined_entry_type *symbol; unsigned int indaux; @@ -1713,11 +2106,11 @@ static boolean coff_pointerize_aux_hook /*ARGSUSED*/ static boolean coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux) - bfd *abfd; - combined_entry_type *table_base; + bfd *abfd ATTRIBUTE_UNUSED; + combined_entry_type *table_base ATTRIBUTE_UNUSED; combined_entry_type *symbol; unsigned int indaux; - combined_entry_type *aux; + combined_entry_type *aux ATTRIBUTE_UNUSED; { /* 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. */ @@ -1742,12 +2135,12 @@ static boolean coff_print_aux 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; + bfd *abfd ATTRIBUTE_UNUSED; + FILE *file ATTRIBUTE_UNUSED; + combined_entry_type *table_base ATTRIBUTE_UNUSED; + combined_entry_type *symbol ATTRIBUTE_UNUSED; + combined_entry_type *aux ATTRIBUTE_UNUSED; + unsigned int indaux ATTRIBUTE_UNUSED; { #ifdef RS6000COFF_C if ((symbol->u.syment.n_sclass == C_EXT @@ -1893,7 +2286,11 @@ coff_write_relocs (abfd, first_undef) #endif if (q->sym_ptr_ptr) { +#ifdef SECTION_RELATIVE_ABSOLUTE_SYMBOL_P + if (SECTION_RELATIVE_ABSOLUTE_SYMBOL_P (q,s)) +#else if (q->sym_ptr_ptr == bfd_abs_section_ptr->symbol_ptr_ptr) +#endif /* This is a relocation relative to the absolute symbol. */ n.r_symndx = -1; else @@ -1918,7 +2315,8 @@ coff_write_relocs (abfd, first_undef) n.r_type = q->howto->type; #endif coff_swap_reloc_out (abfd, &n, &dst); - if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ) + if (bfd_write ((PTR) & dst, 1, bfd_coff_relsz (abfd), abfd) + != bfd_coff_relsz (abfd)) return false; } @@ -1937,8 +2335,8 @@ coff_write_relocs (abfd, first_undef) static boolean coff_set_flags (abfd, magicp, flagsp) bfd * abfd; - unsigned int *magicp; - unsigned short *flagsp; + unsigned int *magicp ATTRIBUTE_UNUSED; + unsigned short *flagsp ATTRIBUTE_UNUSED; { switch (bfd_get_arch (abfd)) { @@ -2016,7 +2414,11 @@ coff_set_flags (abfd, magicp, flagsp) #endif #ifdef ARMMAGIC case bfd_arch_arm: +#ifdef ARM_WINCE + * magicp = ARMPEMAGIC; +#else * magicp = ARMMAGIC; +#endif * flagsp = 0; if (APCS_SET (abfd)) { @@ -2027,7 +2429,7 @@ coff_set_flags (abfd, magicp, flagsp) * flagsp |= F_APCS_FLOAT; if (PIC_FLAG (abfd)) - * flagsp |= F_PIC_INT; + * flagsp |= F_PIC; } if (INTERWORK_SET (abfd) && INTERWORK_FLAG (abfd)) * flagsp |= F_INTERWORK; @@ -2039,6 +2441,8 @@ coff_set_flags (abfd, magicp, flagsp) 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; + case bfd_mach_arm_5: * flagsp |= F_ARM_5; break; + case bfd_mach_arm_5T: * flagsp |= F_ARM_5; break; /* XXX - we do not have an F_ARM_5T */ } return true; #endif @@ -2109,10 +2513,21 @@ coff_set_flags (abfd, magicp, flagsp) #ifdef SH_ARCH_MAGIC_BIG case bfd_arch_sh: +#ifdef COFF_IMAGE_WITH_PE + *magicp = SH_ARCH_MAGIC_WINCE; +#else if (bfd_big_endian (abfd)) *magicp = SH_ARCH_MAGIC_BIG; else *magicp = SH_ARCH_MAGIC_LITTLE; +#endif + return true; + break; +#endif + +#ifdef MIPS_ARCH_MAGIC_WINCE + case bfd_arch_mips: + *magicp = MIPS_ARCH_MAGIC_WINCE; return true; break; #endif @@ -2196,6 +2611,30 @@ coff_set_arch_mach (abfd, arch, machine) return true; /* We're easy ... */ } +#ifdef COFF_IMAGE_WITH_PE + +/* This is used to sort sections by VMA, as required by PE image + files. */ + +static int sort_by_secaddr PARAMS ((const PTR, const PTR)); + +static int +sort_by_secaddr (arg1, arg2) + const PTR arg1; + const PTR arg2; +{ + const asection *a = *(const asection **) arg1; + const asection *b = *(const asection **) arg2; + + if (a->vma < b->vma) + return -1; + else if (a->vma > b->vma) + return 1; + else + return 0; +} + +#endif /* COFF_IMAGE_WITH_PE */ /* Calculate the file position for each section. */ @@ -2212,9 +2651,8 @@ coff_compute_section_file_positions (abfd) { asection *current; asection *previous = (asection *) NULL; - file_ptr sofar = FILHSZ; + file_ptr sofar = bfd_coff_filhsz (abfd); boolean align_adjust; - unsigned int count; #ifdef ALIGN_SECTIONS_IN_FILE file_ptr old_sofar; #endif @@ -2280,48 +2718,132 @@ coff_compute_section_file_positions (abfd) } if (abfd->flags & EXEC_P) - sofar += AOUTSZ; + sofar += bfd_coff_aoutsz (abfd); #ifdef RS6000COFF_C else if (xcoff_data (abfd)->full_aouthdr) - sofar += AOUTSZ; + sofar += bfd_coff_aoutsz (abfd); else sofar += SMALL_AOUTSZ; #endif - sofar += abfd->section_count * SCNHSZ; + sofar += abfd->section_count * bfd_coff_scnhsz (abfd); #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; + sofar += bfd_coff_scnhsz (abfd); #endif +#ifdef COFF_IMAGE_WITH_PE + { + /* PE requires the sections to be in memory order when listed in + the section headers. It also does not like empty loadable + sections. The sections apparently do not have to be in the + right order in the image file itself, but we do need to get the + target_index values right. */ + + int count; + asection **section_list; + int i; + int target_index; + + count = 0; + for (current = abfd->sections; current != NULL; current = current->next) + ++count; + + /* We allocate an extra cell to simplify the final loop. */ + section_list = bfd_malloc (sizeof (struct asection *) * (count + 1)); + if (section_list == NULL) + return false; + + i = 0; + for (current = abfd->sections; current != NULL; current = current->next) + { + section_list[i] = current; + ++i; + } + section_list[i] = NULL; + + qsort (section_list, count, sizeof (asection *), sort_by_secaddr); + + /* Rethread the linked list into sorted order; at the same time, + assign target_index values. */ + target_index = 1; + abfd->sections = section_list[0]; + for (i = 0; i < count; i++) + { + current = section_list[i]; + current->next = section_list[i + 1]; + + /* Later, if the section has zero size, we'll be throwing it + away, so we don't want to number it now. Note that having + a zero size and having real contents are different + concepts: .bss has no contents, but (usually) non-zero + size. */ + if (current->_raw_size == 0) + { + /* Discard. However, it still might have (valid) symbols + in it, so arbitrarily set it to section 1 (indexing is + 1-based here; usually .text). __end__ and other + contents of .endsection really have this happen. + FIXME: This seems somewhat dubious. */ + current->target_index = 1; + } + else + current->target_index = target_index++; + } + + free (section_list); + } +#else /* ! COFF_IMAGE_WITH_PE */ + { + /* Set the target_index field. */ + int target_index; + + target_index = 1; + for (current = abfd->sections; current != NULL; current = current->next) + current->target_index = target_index++; + } +#endif /* ! COFF_IMAGE_WITH_PE */ + align_adjust = false; - for (current = abfd->sections, count = 1; + for (current = abfd->sections; current != (asection *) NULL; - current = current->next, ++count) + current = current->next) { #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) + /* 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) { - current->target_index = -1; - --count; - continue; + 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; #endif - current->target_index = count; - - /* Only deal with sections which have contents */ + /* Only deal with sections which have contents. */ if (!(current->flags & SEC_HAS_CONTENTS)) continue; +#ifdef COFF_IMAGE_WITH_PE + /* Make sure we skip empty sections in a PE image. */ + if (current->_raw_size == 0) + continue; +#endif + /* 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 @@ -2352,26 +2874,7 @@ coff_compute_section_file_positions (abfd) 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; - + /* Set the padded size. */ current->_raw_size = (current->_raw_size + page_size -1) & -page_size; #endif @@ -2528,6 +3031,7 @@ coff_write_object_contents (abfd) asection *current; boolean hasrelocs = false; boolean haslinno = false; + boolean hasdebug = false; file_ptr scn_base; file_ptr reloc_base; file_ptr lineno_base; @@ -2549,7 +3053,7 @@ coff_write_object_contents (abfd) /* 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; + lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd); if (abfd->output_has_begun == false) { @@ -2563,7 +3067,7 @@ coff_write_object_contents (abfd) for (current = abfd->sections; current != NULL; current = current->next) - reloc_size += current->reloc_count * RELSZ; + reloc_size += current->reloc_count * bfd_coff_relsz (abfd); lineno_base = reloc_base + reloc_size; sym_base = lineno_base + lnno_size; @@ -2576,7 +3080,7 @@ coff_write_object_contents (abfd) { current->line_filepos = lineno_base; current->moving_line_filepos = lineno_base; - lineno_base += current->lineno_count * LINESZ; + lineno_base += current->lineno_count * bfd_coff_linesz (abfd); } else { @@ -2585,7 +3089,7 @@ coff_write_object_contents (abfd) if (current->reloc_count) { current->rel_filepos = reloc_base; - reloc_base += current->reloc_count * RELSZ; + reloc_base += current->reloc_count * bfd_coff_relsz (abfd); } else { @@ -2597,13 +3101,13 @@ coff_write_object_contents (abfd) internal_f.f_nscns = 0; if ((abfd->flags & EXEC_P) != 0) - scn_base = FILHSZ + AOUTSZ; + scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); else { - scn_base = FILHSZ; + scn_base = bfd_coff_filhsz (abfd); #ifdef RS6000COFF_C if (xcoff_data (abfd)->full_aouthdr) - scn_base += AOUTSZ; + scn_base += bfd_coff_aoutsz (abfd); else scn_base += SMALL_AOUTSZ; #endif @@ -2618,25 +3122,24 @@ coff_write_object_contents (abfd) current = current->next) { struct internal_scnhdr section; - -#ifdef COFF_WITH_PE - /* If we've got a .reloc section, remember. */ + boolean is_reloc_section = false; #ifdef COFF_IMAGE_WITH_PE if (strcmp (current->name, ".reloc") == 0) { + is_reloc_section = true; + hasrelocs = true; 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. */ + with the code in coff_write_symbols and _bfd_coff_final_link. */ { size_t len; @@ -2691,10 +3194,16 @@ coff_write_object_contents (abfd) section.s_lnnoptr = current->line_filepos; section.s_nreloc = current->reloc_count; section.s_nlnno = current->lineno_count; +#ifndef COFF_IMAGE_WITH_PE + /* In PEI, relocs come in the .reloc section. */ if (current->reloc_count != 0) hasrelocs = true; +#endif if (current->lineno_count != 0) haslinno = true; + if ((current->flags & SEC_DEBUGGING) != 0 + && ! is_reloc_section) + hasdebug = true; #ifdef RS6000COFF_C /* Indicate the use of an XCOFF overflow section header. */ @@ -2731,10 +3240,11 @@ coff_write_object_contents (abfd) #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 */ + /* 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. See also coff_compute_section_file_positions. */ if (section.s_size == 0) internal_f.f_nscns--; else @@ -2742,7 +3252,8 @@ coff_write_object_contents (abfd) { SCNHDR buff; if (coff_swap_scnhdr_out (abfd, §ion, &buff) == 0 - || bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ) + || bfd_write ((PTR) (&buff), 1, bfd_coff_scnhsz (abfd), abfd) + != bfd_coff_scnhsz (abfd)) return false; } @@ -2863,7 +3374,8 @@ coff_write_object_contents (abfd) 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) + || bfd_write ((PTR) &buff, 1, bfd_coff_scnhsz (abfd), abfd) + != bfd_coff_scnhsz (abfd)) return false; } } @@ -2884,13 +3396,13 @@ coff_write_object_contents (abfd) internal_f.f_flags = 0; if (abfd->flags & EXEC_P) - internal_f.f_opthdr = AOUTSZ; + internal_f.f_opthdr = bfd_coff_aoutsz (abfd); else { internal_f.f_opthdr = 0; #ifdef RS6000COFF_C if (xcoff_data (abfd)->full_aouthdr) - internal_f.f_opthdr = AOUTSZ; + internal_f.f_opthdr = bfd_coff_aoutsz (abfd); else internal_f.f_opthdr = SMALL_AOUTSZ; #endif @@ -2902,12 +3414,17 @@ coff_write_object_contents (abfd) internal_f.f_flags |= F_LNNO; if (abfd->flags & EXEC_P) internal_f.f_flags |= F_EXEC; +#ifdef COFF_IMAGE_WITH_PE + if (! hasdebug) + internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED; +#endif - /* FIXME: this is wrong for PPC_PE! */ +#ifndef COFF_WITH_PE if (bfd_little_endian (abfd)) internal_f.f_flags |= F_AR32WR; else internal_f.f_flags |= F_AR32W; +#endif #ifdef TIC80_TARGET_ID internal_f.f_target_id = TIC80_TARGET_ID; @@ -3028,6 +3545,16 @@ coff_write_object_contents (abfd) RS6K_AOUTHDR_OMAGIC; #endif +#if defined(SH) && defined(COFF_WITH_PE) +#define __A_MAGIC_SET__ + internal_a.magic = SH_PE_MAGIC; +#endif + +#if defined(MIPS) && defined(COFF_WITH_PE) +#define __A_MAGIC_SET__ + internal_a.magic = MIPS_PE_MAGIC; +#endif + #ifndef __A_MAGIC_SET__ #include "Your aouthdr magic number is not being set!" #else @@ -3200,19 +3727,41 @@ coff_write_object_contents (abfd) /* now write them */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; + { - char buff[FILHSZ]; + char * buff; + bfd_size_type amount; + + buff = bfd_malloc (bfd_coff_filhsz (abfd)); + if (buff == NULL) + return false; + coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) buff); - if (bfd_write ((PTR) buff, 1, FILHSZ, abfd) != FILHSZ) + amount = bfd_write ((PTR) buff, 1, bfd_coff_filhsz (abfd), abfd); + + free (buff); + + if (amount != bfd_coff_filhsz (abfd)) 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]; + char * buff; + bfd_size_type amount; + + buff = bfd_malloc (bfd_coff_aoutsz (abfd)); + if (buff == NULL) + return false; + coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff); - if (bfd_write ((PTR) buff, 1, AOUTSZ, abfd) != AOUTSZ) + amount = bfd_write ((PTR) buff, 1, bfd_coff_aoutsz (abfd), abfd); + + free (buff); + + if (amount != bfd_coff_aoutsz (abfd)) return false; } #ifdef RS6000COFF_C @@ -3224,7 +3773,7 @@ coff_write_object_contents (abfd) /* 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; + size = bfd_coff_aoutsz (abfd); else size = SMALL_AOUTSZ; if (bfd_write ((PTR) &buff, 1, size, abfd) != size) @@ -3359,6 +3908,9 @@ SUBSUBSECTION base of the line number information for the table is stored in the symbol associated with the function. + Note: The PE format uses line number 0 for a flag indicating a + new source file. + The information is copied from the external to the internal table, and each symbol which marks a function is marked by pointing its... @@ -3380,7 +3932,7 @@ coff_slurp_line_table (abfd, asect) native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, SEEK_SET, - (size_t) (LINESZ * + (size_t) (bfd_coff_linesz (abfd) * asect->lineno_count)); lineno_cache = (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent))); @@ -3448,6 +4000,10 @@ coff_slurp_line_table (abfd, asect) return true; } +/* Slurp in the symbol table, converting it to generic form. Note + that if coff_relocate_section is defined, the linker will read + symbols via coff_link_add_symbols, rather than via this routine. */ + static boolean coff_slurp_symbol_table (abfd) bfd * abfd; @@ -3527,31 +4083,15 @@ coff_slurp_symbol_table (abfd) case C_SYSTEM: /* System Wide variable */ #endif #ifdef COFF_WITH_PE - /* PE uses storage class 0x68 to denote a section symbol */ + /* In PE, 0x68 (104) denotes a section symbol */ case C_SECTION: - /* PE uses storage class 0x69 for a weak external symbol. */ + /* In PE, 0x69 (105) denotes 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 + switch (coff_classify_symbol (abfd, &src->u.syment)) { - /* Base the value as an index from the base of the - section */ - + case COFF_SYMBOL_GLOBAL: 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. */ @@ -3560,19 +4100,45 @@ coff_slurp_symbol_table (abfd) 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; } + break; + + case COFF_SYMBOL_COMMON: + dst->symbol.section = bfd_com_section_ptr; + dst->symbol.value = src->u.syment.n_value; + break; + + case COFF_SYMBOL_UNDEFINED: + dst->symbol.section = bfd_und_section_ptr; + dst->symbol.value = 0; + break; + + case COFF_SYMBOL_PE_SECTION: + dst->symbol.flags |= BSF_EXPORT | BSF_SECTION_SYM; + dst->symbol.value = 0; + break; + + case COFF_SYMBOL_LOCAL: + 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 + dst->symbol.value = (src->u.syment.n_value + - dst->symbol.section->vma); +#endif + if (ISFCN ((src->u.syment.n_type))) + dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION; + break; } #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; @@ -3581,6 +4147,11 @@ coff_slurp_symbol_table (abfd) #ifdef COFF_WITH_PE if (src->u.syment.n_sclass == C_NT_WEAK) dst->symbol.flags = BSF_WEAK; + if (src->u.syment.n_sclass == C_SECTION + && src->u.syment.n_scnum > 0) + { + dst->symbol.flags = BSF_LOCAL; + } #endif if (src->u.syment.n_sclass == C_WEAKEXT) @@ -3598,7 +4169,7 @@ coff_slurp_symbol_table (abfd) case C_THUMBSTATFUNC:/* Thumb static function */ #endif case C_LABEL: /* label */ - if (src->u.syment.n_scnum == -2) + if (src->u.syment.n_scnum == N_DEBUG) dst->symbol.flags = BSF_DEBUGGING; else dst->symbol.flags = BSF_LOCAL; @@ -3680,7 +4251,7 @@ coff_slurp_symbol_table (abfd) 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) + + sec->lineno_count * bfd_coff_linesz (abfd)) > (file_ptr) src->u.syment.n_value)) break; if (sec == NULL) @@ -3690,7 +4261,7 @@ coff_slurp_symbol_table (abfd) dst->symbol.section = sec; dst->symbol.value = ((src->u.syment.n_value - sec->line_filepos) - / LINESZ); + / bfd_coff_linesz (abfd)); src->fix_line = 1; } } @@ -3710,22 +4281,37 @@ coff_slurp_symbol_table (abfd) #endif case C_BLOCK: /* ".bb" or ".eb" */ - case C_FCN: /* ".bf" or ".ef" */ + case C_FCN: /* ".bf" or ".ef" (or PE ".lf") */ 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; + if (strcmp (dst->symbol.name, ".bf") != 0) + { + /* PE uses funny values for .ef and .lf; don't + relocate them. */ + dst->symbol.flags = BSF_DEBUGGING; + } + else + dst->symbol.flags = BSF_DEBUGGING | BSF_DEBUGGING_RELOC; #else /* Base the value as an index from the base of the section. */ + dst->symbol.flags = BSF_LOCAL; dst->symbol.value = (src->u.syment.n_value - dst->symbol.section->vma); #endif break; case C_NULL: + /* PE DLLs sometimes have zeroed out symbols for some + reason. Just ignore them without a warning. */ + if (src->u.syment.n_type == 0 + && src->u.syment.n_value == 0 + && src->u.syment.n_scnum == 0) + break; + /* Fall through. */ case C_EXTDEF: /* external definition */ case C_ULABEL: /* undefined label */ case C_USTATIC: /* undefined static */ @@ -3783,46 +4369,106 @@ coff_slurp_symbol_table (abfd) 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 +/* Classify a COFF symbol. A couple of targets have globally visible + symbols which are not class C_EXT, and this handles those. It also + recognizes some special PE cases. */ +static enum coff_symbol_classification +coff_classify_symbol (abfd, syment) + bfd *abfd; + struct internal_syment *syment; +{ + /* FIXME: This partially duplicates the switch in + coff_slurp_symbol_table. */ + switch (syment->n_sclass) + { + case C_EXT: + case C_WEAKEXT: #ifdef I960 -#define OTHER_GLOBAL_CLASS C_LEAFEXT + case 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 +#ifdef ARM + case C_THUMBEXT: + case C_THUMBEXTFUNC: #endif +#ifdef C_SYSTEM + case C_SYSTEM: #endif +#ifdef COFF_WITH_PE + case C_NT_WEAK: +#endif + if (syment->n_scnum == 0) + { + if (syment->n_value == 0) + return COFF_SYMBOL_UNDEFINED; + else + return COFF_SYMBOL_COMMON; + } + return COFF_SYMBOL_GLOBAL; -#ifdef OTHER_GLOBAL_CLASS + default: + break; + } -static boolean coff_sym_is_global PARAMS ((bfd *, struct internal_syment *)); +#ifdef COFF_WITH_PE + if (syment->n_sclass == C_STAT) + { + if (syment->n_scnum == 0) + { + /* The Microsoft compiler sometimes generates these if a + small static function is inlined every time it is used. + The function is discarded, but the symbol table entry + remains. */ + return COFF_SYMBOL_LOCAL; + } -static boolean -coff_sym_is_global (abfd, syment) - bfd * abfd; - struct internal_syment * syment; -{ - return (syment->n_sclass == OTHER_GLOBAL_CLASS); -} +#ifdef STRICT_PE_FORMAT + /* This is correct for Microsoft generated objects, but it + breaks gas generated objects. */ + + if (syment->n_value == 0) + { + asection *sec; + char buf[SYMNMLEN + 1]; + + sec = coff_section_from_bfd_index (abfd, syment->n_scnum); + if (sec != NULL + && (strcmp (bfd_get_section_name (abfd, sec), + _bfd_coff_internal_syment_name (abfd, syment, buf)) + == 0)) + return COFF_SYMBOL_PE_SECTION; + } +#endif -#undef OTHER_GLOBAL_CLASS + return COFF_SYMBOL_LOCAL; + } -#else /* ! defined (OTHER_GLOBAL_CLASS) */ + if (syment->n_sclass == C_SECTION) + { + /* In some cases in a DLL generated by the Microsoft linker, the + n_value field will contain garbage. FIXME: This should + probably be handled by the swapping function instead. */ + syment->n_value = 0; + if (syment->n_scnum == 0) + return COFF_SYMBOL_UNDEFINED; + return COFF_SYMBOL_PE_SECTION; + } +#endif /* COFF_WITH_PE */ -/* sym_is_global should not be defined if it has nothing to do. */ + /* If it is not a global symbol, we presume it is a local symbol. */ -#define coff_sym_is_global 0 + if (syment->n_scnum == 0) + { + char buf[SYMNMLEN + 1]; -#endif /* ! defined (OTHER_GLOBAL_CLASS) */ + (*_bfd_error_handler) + (_("warning: %s: local symbol `%s' has no section"), + bfd_get_filename (abfd), + _bfd_coff_internal_syment_name (abfd, syment, buf)); + } + + return COFF_SYMBOL_LOCAL; +} /* SUBSUBSECTION @@ -3897,7 +4543,7 @@ coff_slurp_reloc_table (abfd, asect, symbols) (RELOC *) buy_and_read (abfd, asect->rel_filepos, SEEK_SET, - (size_t) (RELSZ * + (size_t) (bfd_coff_relsz (abfd) * asect->reloc_count)); reloc_cache = (arelent *) bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent))); @@ -3995,12 +4641,12 @@ static reloc_howto_type *coff_rtype_to_howto /*ARGSUSED*/ static reloc_howto_type * coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; - asection *sec; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; - bfd_vma *addendp; + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; + struct internal_syment *sym ATTRIBUTE_UNUSED; + bfd_vma *addendp ATTRIBUTE_UNUSED; { arelent genrel; @@ -4074,13 +4720,14 @@ static int dummy_reloc16_estimate 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + arelent *reloc ATTRIBUTE_UNUSED; + unsigned int shrink ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; { abort (); + return 0; } #endif @@ -4098,13 +4745,13 @@ static void dummy_reloc16_extra_cases 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; + struct bfd_link_order *link_order ATTRIBUTE_UNUSED; + arelent *reloc ATTRIBUTE_UNUSED; + bfd_byte *data ATTRIBUTE_UNUSED; + unsigned int *src_ptr ATTRIBUTE_UNUSED; + unsigned int *dst_ptr ATTRIBUTE_UNUSED; { abort (); } @@ -4155,7 +4802,7 @@ static boolean coff_link_output_has_begun static boolean coff_link_output_has_begun (abfd, info) bfd * abfd; - struct coff_final_link_info * info; + struct coff_final_link_info * info ATTRIBUTE_UNUSED; { return abfd->output_has_begun; } @@ -4168,8 +4815,8 @@ static boolean coff_final_link_postscript static boolean coff_final_link_postscript (abfd, pfinfo) - bfd * abfd; - struct coff_final_link_info * pfinfo; + bfd * abfd ATTRIBUTE_UNUSED; + struct coff_final_link_info * pfinfo ATTRIBUTE_UNUSED; { return true; } @@ -4218,16 +4865,14 @@ coff_final_link_postscript (abfd, pfinfo) #define coff_SWAP_scnhdr_in coff_swap_scnhdr_in #endif - - -static CONST bfd_coff_backend_data bfd_coff_std_swap_table = +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, + FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN, #ifdef COFF_LONG_FILENAMES true, #else @@ -4244,7 +4889,7 @@ static CONST bfd_coff_backend_data bfd_coff_std_swap_table = 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_classify_symbol, 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 @@ -4316,3 +4961,101 @@ static CONST bfd_coff_backend_data bfd_coff_std_swap_table = #ifndef coff_bfd_gc_sections #define coff_bfd_gc_sections bfd_generic_gc_sections #endif + +#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE) \ +const bfd_target VAR = \ +{ \ + NAME , \ + bfd_target_coff_flavour, \ + BFD_ENDIAN_BIG, /* data byte order is big */ \ + BFD_ENDIAN_BIG, /* header byte order is big */ \ + /* object flags */ \ + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | \ + HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS), \ + /* section flags */ \ + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\ + UNDER, /* leading symbol underscore */ \ + '/', /* ar_pad_char */ \ + 15, /* ar_max_namelen */ \ + \ + /* Data conversion functions. */ \ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ + bfd_getb32, bfd_getb_signed_32, bfd_putb32, \ + bfd_getb16, bfd_getb_signed_16, bfd_putb16, \ + \ + /* Header conversion functions. */ \ + 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 */ \ + { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p, \ + _bfd_dummy_target }, \ + /* bfd_set_format */ \ + { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false }, \ + /* bfd_write_contents */ \ + { 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), \ + \ + ALTERNATIVE, \ + \ + COFF_SWAP_TABLE \ +}; + +#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE) \ +const bfd_target VAR = \ +{ \ + NAME , \ + bfd_target_coff_flavour, \ + BFD_ENDIAN_LITTLE, /* data byte order is little */ \ + BFD_ENDIAN_LITTLE, /* header byte order is little */ \ + /* object flags */ \ + (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | \ + HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS), \ + /* section flags */ \ + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\ + UNDER, /* leading symbol underscore */ \ + '/', /* ar_pad_char */ \ + 15, /* ar_max_namelen */ \ + \ + /* Data conversion functions. */ \ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, \ + bfd_getl32, bfd_getl_signed_32, bfd_putl32, \ + bfd_getl16, bfd_getl_signed_16, bfd_putl16, \ + /* Header conversion functions. */ \ + 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 */ \ + { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p, \ + _bfd_dummy_target }, \ + /* bfd_set_format */ \ + { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false }, \ + /* bfd_write_contents */ \ + { 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), \ + \ + ALTERNATIVE, \ + \ + COFF_SWAP_TABLE \ +}; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index df41383..f2410d9 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1,5 +1,5 @@ /* Support for the generic parts of COFF, for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -140,9 +140,9 @@ make_a_section_from_file (abfd, hdr, target_index) 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; + return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, + return_section); /* At least on i386-coff, the line number count for a shared library section must be ignored. */ @@ -211,6 +211,11 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize) goto fail; + /* Set the arch/mach *before* swapping in sections; section header swapping + may depend on arch/mach info. */ + if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false) + goto fail; + /* Now copy data as required; construct all asections etc */ if (nscns != 0) { @@ -228,9 +233,6 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) /* make_abs_section (abfd); */ - if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false) - goto fail; - return abfd->xvec; fail: @@ -559,7 +561,7 @@ coff_count_linenumbers (abfd) /*ARGSUSED*/ coff_symbol_type * coff_symbol_from (ignore_abfd, symbol) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; { if (bfd_asymbol_flavour (symbol) != bfd_target_coff_flavour) @@ -585,7 +587,8 @@ fixup_symbol_value (abfd, coff_symbol_ptr, syment) syment->n_scnum = N_UNDEF; syment->n_value = coff_symbol_ptr->symbol.value; } - else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) + else if ((coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) != 0 + && (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING_RELOC) == 0) { syment->n_value = coff_symbol_ptr->symbol.value; } @@ -594,6 +597,7 @@ fixup_symbol_value (abfd, coff_symbol_ptr, syment) syment->n_scnum = N_UNDEF; syment->n_value = 0; } + /* FIXME: Do we need to handle the absolute section here? */ else { if (coff_symbol_ptr->symbol.section) @@ -810,14 +814,18 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, if (native->u.syment.n_sclass == C_FILE && native->u.syment.n_numaux > 0) { + unsigned int filnmlen; + strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN); auxent = &(native + 1)->u.auxent; + filnmlen = bfd_coff_filnmlen (abfd); + if (bfd_coff_long_filenames (abfd)) { - if (name_length <= FILNMLEN) + if (name_length <= filnmlen) { - strncpy (auxent->x_file.x_fname, name, FILNMLEN); + strncpy (auxent->x_file.x_fname, name, filnmlen); } else { @@ -828,11 +836,9 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, } else { - strncpy (auxent->x_file.x_fname, name, FILNMLEN); - if (name_length > FILNMLEN) - { - name[FILNMLEN] = '\0'; - } + strncpy (auxent->x_file.x_fname, name, filnmlen); + if (name_length > filnmlen) + name[filnmlen] = '\0'; } } else @@ -1246,7 +1252,7 @@ coff_write_symbols (abfd) } else if (c_symbol->native->u.syment.n_sclass == C_FILE && c_symbol->native->u.syment.n_numaux > 0) - maxlen = FILNMLEN; + maxlen = bfd_coff_filnmlen (abfd); else maxlen = SYMNMLEN; @@ -1351,7 +1357,7 @@ coff_write_linenumbers (abfd) /*ARGSUSED */ alent * coff_get_lineno (ignore_abfd, symbol) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; { return coffsymbol (symbol)->lineno; @@ -1746,10 +1752,26 @@ coff_get_normalized_symtab (abfd) } 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); + /* Ordinary short filename, put into memory anyway. The + Microsoft PE tools sometimes store a filename in + multiple AUX entries. */ + if (internal_ptr->u.syment.n_numaux > 1 + && coff_data (abfd)->pe) + { + internal_ptr->u.syment._n._n_n._n_offset = + ((long) + copy_name (abfd, + (internal_ptr + 1)->u.auxent.x_file.x_fname, + internal_ptr->u.syment.n_numaux * symesz)); + } + else + { + internal_ptr->u.syment._n._n_n._n_offset = + ((long) + copy_name (abfd, + (internal_ptr + 1)->u.auxent.x_file.x_fname, + bfd_coff_filnmlen (abfd))); + } } } else @@ -1847,8 +1869,8 @@ coff_make_empty_symbol (abfd) asymbol * coff_bfd_make_debug_symbol (abfd, ptr, sz) bfd *abfd; - PTR ptr; - unsigned long sz; + PTR ptr ATTRIBUTE_UNUSED; + unsigned long sz ATTRIBUTE_UNUSED; { coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type)); if (new == NULL) @@ -2046,8 +2068,23 @@ coff_print_symbol (abfd, filep, symbol, how) auxp->u.auxent.x_scn.x_comdat); break; } + /* else fall through */ + case C_EXT: + if (ISFCN (combined->u.syment.n_type)) + { + fprintf (file, + _("AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"), + tagndx, + auxp->u.auxent.x_sym.x_misc.x_fsize, + auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr, + (auxp->fix_end + ? ((long) + (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p + - root)) + : auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l)); + 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, @@ -2095,16 +2132,15 @@ coff_print_symbol (abfd, filep, symbol, how) boolean _bfd_coff_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; 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. */ - +/* Provided a BFD, a section and an offset (in bytes, not octets) 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, @@ -2190,9 +2226,11 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } } + /* We use <= MAXDIFF here so that if we get a zero length + file, we actually use the next file entry. */ if (p2 < pend && offset + sec_vma >= (bfd_vma) p2->u.syment.n_value - && offset + sec_vma - (bfd_vma) p2->u.syment.n_value < maxdiff) + && 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; @@ -2229,6 +2267,8 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (section->lineno != NULL) { + bfd_vma last_value = 0; + l = §ion->lineno[i]; for (; i < section->lineno_count; i++) @@ -2240,6 +2280,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (coff->symbol.value > offset) break; *functionname_ptr = coff->symbol.name; + last_value = coff->symbol.value; if (coff->native) { combined_entry_type *s = coff->native; @@ -2268,6 +2309,20 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } l++; } + + /* If we fell off the end of the loop, then assume that this + symbol has no line number info. Otherwise, symbols with no + line number info get reported with the line number of the + last line of the last symbol which does have line number + info. We use 0x100 as a slop to account for cases where the + last line has executable code. */ + if (i >= section->lineno_count + && last_value != 0 + && offset - last_value > 0x100) + { + *functionname_ptr = NULL; + *line_ptr = 0; + } } /* Cache the results for the next call. */ diff --git a/bfd/cofflink.c b/bfd/cofflink.c index cf56869..609f665 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1,5 +1,5 @@ /* COFF specific linker code. - Copyright 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -40,6 +40,16 @@ static int process_embedded_commands PARAMS ((bfd *, struct bfd_link_info *, bfd *)); static void mark_relocs PARAMS ((struct coff_final_link_info *, bfd *)); +/* Define macros so that the ISFCN, et. al., macros work correctly. + These macros are defined in include/coff/internal.h in terms of + N_TMASK, etc. These definitions require a user to define local + variables with the appropriate names, and with values from the + coff_data (abfd) structure. */ + +#define N_TMASK n_tmask +#define N_BTSHFT n_btshft +#define N_BTMASK n_btmask + /* Create an entry in a COFF linker hash table. */ struct bfd_hash_entry * @@ -225,32 +235,25 @@ coff_link_check_ar_symbols (abfd, info, pneeded) 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; + enum coff_symbol_classification classification; 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)) + classification = bfd_coff_classify_symbol (abfd, &sym); + if (classification == COFF_SYMBOL_GLOBAL + || classification == COFF_SYMBOL_COMMON) { const char *name; char buf[SYMNMLEN + 1]; @@ -292,7 +295,9 @@ coff_link_add_symbols (abfd, info) bfd *abfd; struct bfd_link_info *info; { - boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *)); + unsigned int n_tmask = coff_data (abfd)->local_n_tmask; + unsigned int n_btshft = coff_data (abfd)->local_n_btshft; + unsigned int n_btmask = coff_data (abfd)->local_n_btmask; boolean keep_syms; boolean default_copy; bfd_size_type symcount; @@ -306,8 +311,6 @@ coff_link_add_symbols (abfd, info) 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 @@ -334,23 +337,20 @@ coff_link_add_symbols (abfd, info) while (esym < esym_end) { struct internal_syment sym; + enum coff_symbol_classification classification; 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))) + classification = bfd_coff_classify_symbol (abfd, &sym); + if (classification != COFF_SYMBOL_LOCAL) { const char *name; char buf[SYMNMLEN + 1]; flagword flags; asection *section; bfd_vma value; + boolean addit; /* This symbol is externally visible. */ @@ -367,37 +367,119 @@ coff_link_add_symbols (abfd, info) 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 + switch (classification) { + default: + abort (); + + case COFF_SYMBOL_GLOBAL: flags = BSF_EXPORT | BSF_GLOBAL; section = coff_section_from_bfd_index (abfd, sym.n_scnum); if (! obj_pe (abfd)) value -= section->vma; + break; + + case COFF_SYMBOL_UNDEFINED: + flags = 0; + section = bfd_und_section_ptr; + break; + + case COFF_SYMBOL_COMMON: + flags = BSF_GLOBAL; + section = bfd_com_section_ptr; + break; + + case COFF_SYMBOL_PE_SECTION: + flags = BSF_SECTION_SYM | BSF_GLOBAL; + section = coff_section_from_bfd_index (abfd, sym.n_scnum); + break; } 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; + addit = true; + + /* In the PE format, section symbols actually refer to the + start of the output section. We handle them specially + here. */ + if (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0) + { + *sym_hash = coff_link_hash_lookup (coff_hash_table (info), + name, false, copy, false); + if (*sym_hash != NULL) + { + if (((*sym_hash)->coff_link_hash_flags + & COFF_LINK_HASH_PE_SECTION_SYMBOL) == 0 + && (*sym_hash)->root.type != bfd_link_hash_undefined + && (*sym_hash)->root.type != bfd_link_hash_undefweak) + (*_bfd_error_handler) + ("Warning: symbol `%s' is both section and non-section", + name); + + addit = false; + } + } + /* The Microsoft Visual C compiler does string pooling by + hashing the constants to an internal symbol name, and + relying on the the linker comdat support to discard + duplicate names. However, if one string is a literal and + one is a data initializer, one will end up in the .data + section and one will end up in the .rdata section. The + Microsoft linker will combine them into the .data + section, which seems to be wrong since it might cause the + literal to change. + + As long as there are no external references to the + symbols, which there shouldn't be, we can treat the .data + and .rdata instances as separate symbols. The comdat + code in the linker will do the appropriate merging. Here + we avoid getting a multiple definition error for one of + these special symbols. + + FIXME: I don't think this will work in the case where + there are two object files which use the constants as a + literal and two object files which use it as a data + initializer. One or the other of the second object files + is going to wind up with an inappropriate reference. */ + if (obj_pe (abfd) + && (classification == COFF_SYMBOL_GLOBAL + || classification == COFF_SYMBOL_PE_SECTION) + && section->comdat != NULL + && strncmp (name, "??_", 3) == 0 + && strcmp (name, section->comdat->name) == 0) + { + if (*sym_hash == NULL) + *sym_hash = coff_link_hash_lookup (coff_hash_table (info), + name, false, copy, false); + if (*sym_hash != NULL + && (*sym_hash)->root.type == bfd_link_hash_defined + && (*sym_hash)->root.u.def.section->comdat != NULL + && strcmp ((*sym_hash)->root.u.def.section->comdat->name, + section->comdat->name) == 0) + addit = false; + } + + if (addit) + { + 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 (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0) + (*sym_hash)->coff_link_hash_flags |= + COFF_LINK_HASH_PE_SECTION_SYMBOL; + + /* Limit the alignment of a common symbol to the possible + alignment of a section. There is no point to permitting + a higher alignment for a common symbol: we can not + guarantee it, and it may cause us to allocate extra space + in the common section. */ if (section == bfd_com_section_ptr && (*sym_hash)->root.type == bfd_link_hash_common && ((*sym_hash)->root.u.c.p->alignment_power @@ -407,25 +489,44 @@ coff_link_add_symbols (abfd, info) 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 we don't have any symbol information currently in + the hash table, or if we are looking at a symbol + definition, then update the symbol class and type in + the hash table. */ + 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) + { + /* We want to warn if the type changed, but not + if it changed from an unspecified type. + Testing the whole type byte may work, but the + change from (e.g.) a function of unspecified + type to function of known type also wants to + skip the warning. */ + if ((*sym_hash)->type != T_NULL + && (*sym_hash)->type != sym.n_type + && !(DTYPE ((*sym_hash)->type) == DTYPE (sym.n_type) + && (BTYPE ((*sym_hash)->type) == T_NULL + || BTYPE (sym.n_type) == T_NULL))) + (*_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)); + + /* We don't want to change from a meaningful + base type to a null one, but if we know + nothing, take what little we might now know. */ + if (BTYPE (sym.n_type) != T_NULL + || (*sym_hash)->type == T_NULL) + (*sym_hash)->type = sym.n_type; + } + (*sym_hash)->auxbfd = abfd; if (sym.n_numaux != 0) { union internal_auxent *alloc; @@ -450,6 +551,26 @@ coff_link_add_symbols (abfd, info) } } } + + if (classification == COFF_SYMBOL_PE_SECTION + && (*sym_hash)->numaux != 0) + { + /* Some PE sections (such as .bss) have a zero size in + the section header, but a non-zero size in the AUX + record. Correct that here. + + FIXME: This is not at all the right place to do this. + For example, it won't help objdump. This needs to be + done when we swap in the section header. */ + + BFD_ASSERT ((*sym_hash)->numaux == 1); + if (section->_raw_size == 0) + section->_raw_size = (*sym_hash)->aux[0].x_scn.x_scnlen; + + /* FIXME: We could test whether the section sizes + matches the size in the aux entry, but apparently + that sometimes fails unexpectedly. */ + } } esym += (sym.n_numaux + 1) * symesz; @@ -1069,7 +1190,7 @@ char **dst; static int process_embedded_commands (output_bfd, info, abfd) bfd *output_bfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; bfd *abfd; { asection *sec = bfd_get_section_by_name (abfd, ".drectve"); @@ -1212,15 +1333,17 @@ _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 *)); + unsigned int n_tmask = coff_data (input_bfd)->local_n_tmask; + unsigned int n_btshft = coff_data (input_bfd)->local_n_btshft; +#if 0 + unsigned int n_btmask = coff_data (input_bfd)->local_n_btmask; +#endif 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; @@ -1238,7 +1361,6 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) /* 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); @@ -1246,13 +1368,6 @@ _bfd_coff_link_input_bfd (finfo, input_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; @@ -1293,6 +1408,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) while (esym < esym_end) { struct internal_syment isym; + enum coff_symbol_classification classification; boolean skip; boolean global; boolean dont_skip_symbol; @@ -1306,14 +1422,22 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) the symbol. */ isym = *isymp; - if (isym.n_scnum != 0) - *secpp = coff_section_from_bfd_index (input_bfd, isym.n_scnum); - else + classification = bfd_coff_classify_symbol (input_bfd, &isym); + switch (classification) { - if (isym.n_value == 0) - *secpp = bfd_und_section_ptr; - else - *secpp = bfd_com_section_ptr; + default: + abort (); + case COFF_SYMBOL_GLOBAL: + case COFF_SYMBOL_PE_SECTION: + case COFF_SYMBOL_LOCAL: + *secpp = coff_section_from_bfd_index (input_bfd, isym.n_scnum); + break; + case COFF_SYMBOL_COMMON: + *secpp = bfd_com_section_ptr; + break; + case COFF_SYMBOL_UNDEFINED: + *secpp = bfd_und_section_ptr; + break; } /* Extract the flag indicating if this symbol is used by a @@ -1337,28 +1461,34 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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))) + switch (classification) { + default: + abort (); + case COFF_SYMBOL_GLOBAL: + case COFF_SYMBOL_COMMON: + case COFF_SYMBOL_PE_SECTION: /* 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) + if (! ISFCN (isym.n_type)) skip = true; - } - else - { + break; + + case COFF_SYMBOL_UNDEFINED: + /* Undefined symbols are left for the end. */ + global = true; + skip = true; + break; + + case COFF_SYMBOL_LOCAL: /* This is a local symbol. Skip it if we are discarding local symbols. */ if (finfo->info->discard == discard_all && ! dont_skip_symbol) skip = true; + break; } } @@ -1466,7 +1596,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) { const char *elename; char elebuf[SYMNMLEN + 1]; - char *copy; + char *name_copy; bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp); @@ -1481,12 +1611,13 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) if (elename == NULL) return false; - copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1); - if (copy == NULL) + name_copy = (char *) bfd_alloc (input_bfd, + strlen (elename) + 1); + if (name_copy == NULL) return false; - strcpy (copy, elename); + strcpy (name_copy, elename); - (*epp)->name = copy; + (*epp)->name = name_copy; (*epp)->type = islp->n_type; (*epp)->tagndx = 0; if (islp->n_numaux >= 1 @@ -1598,31 +1729,76 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; } - if (isym.n_scnum > 0) + switch (isym.n_sclass) { - 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; - } + case C_AUTO: + case C_MOS: + case C_EOS: + case C_MOE: + case C_MOU: + case C_UNTAG: + case C_STRTAG: + case C_ENTAG: + case C_TPDEF: + case C_ARG: + case C_USTATIC: + case C_REG: + case C_REGPARM: + case C_FIELD: + /* The symbol value should not be modified. */ + break; + + case C_FCN: + if (obj_pe (input_bfd) + && strcmp (isym.n_name, ".bf") != 0 + && isym.n_scnum > 0) + { + /* For PE, .lf and .ef get their value left alone, + while .bf gets relocated. However, they all have + "real" section numbers, and need to be moved into + the new section. */ + isym.n_scnum = (*secpp)->output_section->target_index; + break; + } + /* Fall through. */ + default: + case C_LABEL: /* Not completely sure about these 2 */ + case C_EXTDEF: + case C_BLOCK: + case C_EFCN: + case C_NULL: + case C_EXT: + case C_STAT: + case C_SECTION: + case C_NT_WEAK: + /* Compute new symbol location. */ + 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; + } + break; + + case C_FILE: + /* 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. */ - /* 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. */ + /* 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) { @@ -1654,6 +1830,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) finfo->last_file_index = output_index; finfo->last_file = isym; + break; } /* If doing task linking, convert normal global function symbols to @@ -1934,6 +2111,8 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) bfd_vma offset; bfd_byte *eline; bfd_byte *elineend; + bfd_byte *oeline; + boolean skipping; /* FIXME: If SEC_HAS_CONTENTS is not for the section, then build_link_order in ldwrite.c will not have created a @@ -1955,7 +2134,9 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) offset = o->output_section->vma + o->output_offset - o->vma; eline = finfo->linenos; + oeline = finfo->linenos; elineend = eline + linesz * o->lineno_count; + skipping = false; for (; eline < elineend; eline += linesz) { struct internal_lineno iline; @@ -1975,11 +2156,13 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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; + which we are stripping. We must discard the + line numbers because reading them back with + no associated symbol (or associating them all + with symbol #0) will fail. We can't regain + the space in the output file, but at least + they're dense. */ + skipping = true; } else { @@ -2018,23 +2201,32 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) is.n_type, is.n_sclass, 0, is.n_numaux, auxptr); } + + skipping = false; } iline.l_addr.l_symndx = indx; } - bfd_coff_swap_lineno_out (output_bfd, (PTR) &iline, (PTR) eline); + if (!skipping) + { + bfd_coff_swap_lineno_out (output_bfd, (PTR) &iline, + (PTR) oeline); + oeline += linesz; + } } 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) + || (bfd_write (finfo->linenos, 1, oeline - finfo->linenos, + output_bfd) + != (bfd_size_type) (oeline - finfo->linenos))) return false; - o->output_section->lineno_count += o->lineno_count; + o->output_section->lineno_count += + (oeline - finfo->linenos) / linesz; } } @@ -2233,7 +2425,10 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) if (secdata == NULL || secdata->stab_info == NULL) { if (! bfd_set_section_contents (output_bfd, o->output_section, - contents, o->output_offset, + contents, + (file_ptr) + (o->output_offset * + bfd_octets_per_byte (output_bfd)), (o->_cooked_size != 0 ? o->_cooked_size : o->_raw_size))) @@ -2386,11 +2581,64 @@ _bfd_coff_write_global_sym (h, data) ++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. */ + /* Write out any associated aux entries. Most of the aux entries + will have been modified in _bfd_coff_link_input_bfd. We have to + handle section aux entries here, now that we have the final + relocation and line number counts. */ for (i = 0; i < isym.n_numaux; i++) { - bfd_coff_swap_aux_out (output_bfd, (PTR) (h->aux + i), isym.n_type, + union internal_auxent *auxp; + + auxp = h->aux + i; + + /* Look for a section aux entry here using the same tests that + coff_swap_aux_out uses. */ + if (i == 0 + && (isym.n_sclass == C_STAT + || isym.n_sclass == C_HIDDEN) + && isym.n_type == T_NULL + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak)) + { + asection *sec; + + sec = h->root.u.def.section->output_section; + if (sec != NULL) + { + auxp->x_scn.x_scnlen = (sec->_cooked_size != 0 + ? sec->_cooked_size + : sec->_raw_size); + + /* For PE, an overflow on the final link reportedly does + not matter. FIXME: Why not? */ + + if (sec->reloc_count > 0xffff + && (! obj_pe (output_bfd) + || finfo->info->relocateable)) + (*_bfd_error_handler) + (_("%s: %s: reloc overflow: 0x%lx > 0xffff"), + bfd_get_filename (output_bfd), + bfd_get_section_name (output_bfd, sec), + sec->reloc_count); + + if (sec->lineno_count > 0xffff + && (! obj_pe (output_bfd) + || finfo->info->relocateable)) + (*_bfd_error_handler) + (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"), + bfd_get_filename (output_bfd), + bfd_get_section_name (output_bfd, sec), + sec->lineno_count); + + auxp->x_scn.x_nreloc = sec->reloc_count; + auxp->x_scn.x_nlinno = sec->lineno_count; + auxp->x_scn.x_checksum = 0; + auxp->x_scn.x_associated = 0; + auxp->x_scn.x_comdat = 0; + } + } + + bfd_coff_swap_aux_out (output_bfd, (PTR) auxp, isym.n_type, isym.n_sclass, i, isym.n_numaux, (PTR) finfo->outsyms); if (bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz) @@ -2492,7 +2740,9 @@ _bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order) break; } ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf, - (file_ptr) link_order->offset, size); + (file_ptr) + (link_order->offset * + bfd_octets_per_byte (output_bfd)), size); free (buf); if (! ok) return false; @@ -2603,6 +2853,14 @@ _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, 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); + return false; + } else { h = obj_coff_sym_hashes (input_bfd)[symndx]; @@ -2675,7 +2933,7 @@ _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; } } diff --git a/bfd/coffswap.h b/bfd/coffswap.h index ae30a5d..d7d090f 100644 --- a/bfd/coffswap.h +++ b/bfd/coffswap.h @@ -1,5 +1,6 @@ /* Generic COFF swapping routines, for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 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. @@ -26,10 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -264,7 +261,7 @@ coff_swap_reloc_out (abfd, src, dst) SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst); #endif - return RELSZ; + return bfd_coff_relsz (abfd); } #endif /* NO_COFF_RELOCS */ @@ -324,7 +321,7 @@ coff_swap_filehdr_out (abfd, in, out) #ifdef COFF_ADJUST_FILEHDR_OUT_POST COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out); #endif - return FILHSZ; + return bfd_coff_filhsz (abfd); } @@ -360,6 +357,9 @@ coff_swap_sym_in (abfd, ext1, in1) } in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass); in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux); +#ifdef COFF_ADJUST_SYM_IN_POST + COFF_ADJUST_SYM_IN_POST (abfd, ext1, in1); +#endif } static unsigned int @@ -393,6 +393,9 @@ coff_swap_sym_out (abfd, inp, extp) } bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass); bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux); +#ifdef COFF_ADJUST_SYM_OUT_POST + COFF_ADJUST_SYM_OUT_POST (abfd, inp, extp); +#endif return SYMESZ; } @@ -422,7 +425,16 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) #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); + if (numaux > 1) + { + if (indx == 0) + memcpy (in->x_file.x_fname, ext->x_file.x_fname, + numaux * sizeof (AUXENT)); + } + else + { + memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); + } #endif } goto end; @@ -518,8 +530,8 @@ coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) PTR inp; int type; int class; - int indx; - int numaux; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; PTR extp; { union internal_auxent *in = (union internal_auxent *)inp; @@ -839,7 +851,7 @@ coff_swap_scnhdr_out (abfd, in, out) { struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in; SCNHDR *scnhdr_ext = (SCNHDR *)out; - unsigned int ret = SCNHSZ; + unsigned int ret = bfd_coff_scnhsz (abfd); #ifdef COFF_ADJUST_SCNHDR_OUT_PRE COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out); diff --git a/bfd/config.bfd b/bfd/config.bfd index 449ae91..d8f91d2 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -35,9 +35,11 @@ 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 ;; +i370) targ_archs=bfd_i370_arch ;; m68*) targ_archs=bfd_m68k_arch ;; m88*) targ_archs=bfd_m88k_arch ;; mips*) targ_archs=bfd_mips_arch ;; +pj*) targ_archs="bfd_pj_arch bfd_i386_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 ;; @@ -55,7 +57,7 @@ esac case "${targ}" in # START OF targmatch.h #ifdef BFD64 - alpha*-*-netbsd*) + alpha*-*-netbsd* | alpha*-*-freebsd*) targ_defvec=bfd_elf64_alpha_vec targ_selvecs=ecoffalpha_little_vec ;; @@ -84,6 +86,10 @@ case "${targ}" in targ_selvecs=bfd_elf32_bigarc_vec ;; + arm-*-netbsd*) + targ_defvec=armnetbsd_vec + targ_underscore=yes + ;; arm-*-riscix*) targ_defvec=riscix_vec ;; @@ -92,6 +98,12 @@ case "${targ}" in 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-wince-pe | arm-*-wince) + targ_defvec=armpe_little_vec + targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec" + targ_underscore=no + targ_cflags=-DARM_WINCE + ;; arm-*-pe*) targ_defvec=armpe_little_vec targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec" @@ -110,7 +122,7 @@ case "${targ}" in targ_selvecs=armcoff_big_vec targ_underscore=yes ;; - arm-*-elf | arm*-*-linux-gnu) + arm-*-elf | arm*-*-linux-gnu* | arm*-*-conix*) targ_defvec=bfd_elf32_littlearm_vec targ_selvecs=bfd_elf32_bigarm_vec ;; @@ -163,6 +175,10 @@ case "${targ}" in targ_underscore=yes ;; + avr-*-*) + targ_defvec=bfd_elf32_avr_vec + ;; + c30-*-*aout* | tic30-*-*aout*) targ_defvec=tic30_aout_vec ;; @@ -193,42 +209,60 @@ case "${targ}" in targ_underscore=yes ;; - hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*) +#if 0 /* HPPA ELF does not work currently. */ + hppa*-*-*elf* | hppa*-*-linux-gnu* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*) targ_defvec=bfd_elf32_hppa_vec ;; +#endif #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined (HOST_HPPAMPEIX) +#if 0 /* HPPA ELF does not work currently. */ hppa*-*-bsd*) targ_defvec=som_vec targ_selvecs=bfd_elf32_hppa_vec ;; +#endif hppa*-*-hpux* | hppa*-*-hiux* | hppa*-*-mpeix*) targ_defvec=som_vec ;; +#if 0 /* HPPA ELF does not work currently. */ hppa*-*-osf*) targ_defvec=som_vec targ_selvecs=bfd_elf32_hppa_vec ;; +#endif #endif /* defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) */ + i370-*-*) + targ_defvec=bfd_elf32_i370_vec + targ_selvecs="bfd_elf32_i370_vec" + ;; 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-*-sysv4* | i[3456]86-*-unixware* | i[3456]86-*-solaris2* | \ + i[3456]86-*-elf | i[3456]86-*-sco3.2v5* | \ i[3456]86-*-dgux* | i[3456]86-*-sysv5*) targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386coff_vec ;; + i[3456]86-*-rtemself*) + targ_defvec=bfd_elf32_i386_vec + targ_selvecs="i386coff_vec i386aout_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*) + i[3456]86-*-aix*) + targ_defvec=i386coff_vec + ;; + i[3456]86*-*-rtems*) targ_defvec=i386coff_vec + targ_selvecs="bfd_elf32_i386_vec i386aout_vec" ;; - i[3456]86-sequent-bsd*) + i[3456]86-sequent-bsd*) targ_defvec=i386dynix_vec targ_underscore=yes ;; @@ -236,11 +270,16 @@ case "${targ}" in targ_defvec=i386bsd_vec targ_underscore=yes ;; - i[3456]86-*-freebsd*) + i[3456]86-*-freebsdaout* | i[3456]86-*-freebsd[12].* | \ + i[3456]86-*-freebsd[12]) targ_defvec=i386freebsd_vec targ_selvecs=i386bsd_vec targ_underscore=yes ;; + i[3456]86-*-freebsd*) + targ_defvec=bfd_elf32_i386_vec + targ_selvecs=i386coff_vec + ;; i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) targ_defvec=i386netbsd_vec targ_selvecs=i386bsd_vec @@ -290,9 +329,15 @@ case "${targ}" in targ_defvec=bfd_elf32_i386_vec targ_selvecs="i386pe_vec i386pei_vec" ;; + i[3456]86-*-interix*) + targ_defvec=i386pei_vec + targ_selvecs="i386pe_vec" + # FIXME: This should eventually be checked at runtime. + targ_cflags=-DSTRICT_PE_FORMAT + ;; 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" + targ_selvecs="i386pe_vec i386pei_vec bfd_elf32_i386_vec" ;; i[3456]86-none-*) targ_defvec=i386coff_vec @@ -300,6 +345,10 @@ case "${targ}" in i[3456]86-*-aout* | i[3456]86*-*-vsta*) targ_defvec=i386aout_vec ;; + i[3456]86-*-vxworks*) + targ_defvec=i386aout_vec + targ_underscore=yes + ;; i860-*-mach3* | i860-*-osf1* | i860-*-coff*) targ_defvec=i860coff_vec @@ -323,6 +372,10 @@ case "${targ}" in targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec ieee_vec" targ_underscore=yes ;; + i960-*-elf*) + targ_defvec=bfd_elf32_i960_vec + targ_selvecs="icoff_little_vec icoff_big_vec" + ;; m32r-*-*) targ_defvec=bfd_elf32_m32r_vec @@ -344,17 +397,21 @@ case "${targ}" in ;; m68*-*-aout*) targ_defvec=aout0_big_vec - # We include cisco_core_vec here, rather than making a separate cisco + # We include cisco_core_big_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_selvecs="cisco_core_big_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*) + m68*-*-rtems*) + targ_defvec=m68kcoff_vec + targ_selvecs="m68kcoff_vec versados_vec ieee_vec aout0_big_vec" + ;; + m68*-*-coff* | m68*-*-sysv*) targ_defvec=m68kcoff_vec targ_selvecs="m68kcoff_vec versados_vec ieee_vec" ;; @@ -483,6 +540,11 @@ case "${targ}" in targ_defvec=aout_mips_little_vec targ_cflags=-DSTAT_FOR_EXEC ;; + mips*-*-pe*) + targ_defvec=mipslpe_vec + targ_selvecs="mipslpei_vec mipslpei_vec ecoff_little_vec ecoff_big_vec" + targ_underscore=yes + ;; mips*-*-sysv4*) targ_defvec=bfd_elf32_bigmips_vec targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec" @@ -491,7 +553,7 @@ case "${targ}" in targ_defvec=ecoff_big_vec targ_selvecs=ecoff_little_vec ;; - mips*el-*-elf* | mips*el-*-vxworks*) + mips*el-*-elf* | mips*el-*-rtems* | mips*el-*-vxworks*) targ_defvec=bfd_elf32_littlemips_vec targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" ;; @@ -529,6 +591,16 @@ case "${targ}" in targ_underscore=yes ;; + pj-*-*) + targ_defvec=bfd_elf32_pj_vec + targ_selvecs="bfd_elf32_pj_vec bfd_elf32_pjl_vec" + ;; + + pjl-*-*) + targ_defvec=bfd_elf32_pjl_vec + targ_selvecs="bfd_elf32_pjl_vec bfd_elf32_pj_vec bfd_elf32_i386_vec" + ;; + powerpc-*-aix* | powerpc-*-beos*) targ_defvec=rs6000coff_vec ;; @@ -546,7 +618,8 @@ case "${targ}" in targ_selvecs="nlm32_powerpc_vec rs6000coff_vec" ;; powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \ - powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks*) + powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\ + powerpcle-*-rtems*) targ_defvec=bfd_elf32_powerpcle_vec targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec" ;; @@ -560,11 +633,16 @@ case "${targ}" in targ_defvec=rs6000coff_vec ;; - sh-*-elf*) + sh-*-elf* | sh-*-rtemself*) 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-*-pe) + targ_defvec=shlpe_vec + targ_selvecs="shlpe_vec shlpei_vec" + targ_underscore=yes + ;; sh-*-* | sh-*-rtems*) targ_defvec=shcoff_vec targ_selvecs="shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec" @@ -590,20 +668,35 @@ case "${targ}" in ;; sparc-*-linux-gnu*) targ_defvec=bfd_elf32_sparc_vec - targ_selvecs="sparclinux_vec sunos_big_vec" + targ_selvecs="sparclinux_vec bfd_elf64_sparc_vec sunos_big_vec" ;; sparc-*-lynxos*) targ_defvec=sparclynx_coff_vec targ_selvecs=sparclynx_aout_vec ;; - sparc-*-netbsd* | sparc-*-openbsd*) + sparc-*-netbsdelf*) + targ_defvec=bfd_elf32_sparc_vec + targ_selvecs=sparcnetbsd_vec + ;; + sparc-*-netbsdaout* | sparc-*-netbsd*) targ_defvec=sparcnetbsd_vec + targ_selvecs=bfd_elf32_sparc_vec targ_underscore=yes ;; - sparc-*-elf* | sparc-*-solaris2*) + sparc-*-openbsd*) + targ_defvec=sparcnetbsd_vec + targ_underscore=yes + ;; + sparc-*-elf* | sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*) targ_defvec=bfd_elf32_sparc_vec targ_selvecs=sunos_big_vec ;; +#ifdef BFD64 + sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*) + targ_defvec=bfd_elf32_sparc_vec + targ_selvecs="bfd_elf64_sparc_vec sunos_big_vec" + ;; +#endif sparc-*-sysv4*) targ_defvec=bfd_elf32_sparc_vec ;; diff --git a/bfd/config.in b/bfd/config.in index 51fa45b..7383656 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -67,9 +67,15 @@ /* Define if you have the getcwd function. */ #undef HAVE_GETCWD +/* Define if you have the getgid function. */ +#undef HAVE_GETGID + /* Define if you have the getpagesize function. */ #undef HAVE_GETPAGESIZE +/* Define if you have the getuid function. */ +#undef HAVE_GETUID + /* Define if you have the madvise function. */ #undef HAVE_MADVISE @@ -226,6 +232,9 @@ /* Define if has lwpstatus_t.pr_reg. */ #undef HAVE_LWPSTATUS_T_PR_REG +/* Define if has win32_pstatus_t. */ +#undef HAVE_WIN32_PSTATUS_T + /* Name of host specific header file to include in trad-core.c. */ #undef TRAD_HEADER diff --git a/bfd/configure b/bfd/configure index f6ca66f..fecd4a9 100755 --- a/bfd/configure +++ b/bfd/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 +# Generated automatically using autoconf version 2.13.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -16,8 +16,12 @@ ac_help="$ac_help 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 avoid locking (might break parallel builds)" +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" @@ -354,7 +358,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" + echo "configure generated by autoconf version 2.13.1" exit 0 ;; -with-* | --with-*) @@ -514,7 +518,7 @@ done if test -r "$cache_file"; then echo "loading cache $cache_file" - . $cache_file + test -f "$cache_file" && . $cache_file else echo "creating cache $cache_file" > $cache_file @@ -558,9 +562,130 @@ 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. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:572: checking host system type" >&5 +if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_host_alias=$host + case "$ac_cv_host_alias" in + NONE) + case $nonopt in + NONE) + if ac_cv_host_alias=`$ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) ac_cv_host_alias=$nonopt ;; + esac ;; + esac + + ac_cv_host=`$ac_config_sub $ac_cv_host_alias` + ac_cv_host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_host" 1>&6 + +host=$ac_cv_host +host_alias=$ac_cv_host_alias +host_cpu=$ac_cv_host_cpu +host_vendor=$ac_cv_host_vendor +host_os=$ac_cv_host_os + + + + + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:613: checking target system type" >&5 +if test "x$ac_cv_target" = "x" || (test "x$target" != "xNONE" && test "x$target" != "x$ac_cv_target_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_target_alias=$target + case "$ac_cv_target_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_target_alias=$host_alias ;; + + *) ac_cv_target_alias=$nonopt ;; + esac ;; + esac + + ac_cv_target=`$ac_config_sub $ac_cv_target_alias` + ac_cv_target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_target" 1>&6 + +target=$ac_cv_target +target_alias=$ac_cv_target_alias +target_cpu=$ac_cv_target_cpu +target_vendor=$ac_cv_target_vendor +target_os=$ac_cv_target_os + + + + + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:653: checking build system type" >&5 +if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_build_alias=$build + case "$ac_cv_build_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_build_alias=$host_alias ;; + + *) ac_cv_build_alias=$nonopt ;; + esac ;; + esac + + ac_cv_build=`$ac_config_sub $ac_cv_build_alias` + ac_cv_build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_build" 1>&6 + +build=$ac_cv_build +build_alias=$ac_cv_build_alias +build_cpu=$ac_cv_build_cpu +build_vendor=$ac_cv_build_vendor +build_os=$ac_cv_build_os + + + # Do some error checking and defaulting for the host and target type. @@ -583,69 +708,6 @@ 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, && @@ -654,8 +716,8 @@ test "$host_alias" != "$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 "configure:720: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -684,8 +746,8 @@ 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 "configure:750: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -731,12 +793,12 @@ fi if test -z "$CC"; then case "`uname -s`" in - *win32* | *WIN32*) + *win32* | *WIN32* | *CYGWIN*) # 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 "configure:801: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -766,8 +828,8 @@ 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 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:833: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -778,12 +840,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 782 "configure" +#line 844 "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 +if { (eval echo configure:849: \"$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 @@ -808,14 +870,14 @@ 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_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:875: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $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 "configure:880: checking whether we are using GNU C" >&5 +if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:889: \"$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 @@ -842,8 +904,8 @@ 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 "configure:908: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c @@ -874,7 +936,7 @@ else fi echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:878: checking for POSIXized ISC" >&5 +echo "configure:940: 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 @@ -907,9 +969,9 @@ fi # 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 +echo "configure:973: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then +if eval "test \"\${ac_cv_path_install+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" @@ -927,6 +989,10 @@ else grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : + elif test $ac_prog = install && + grep pwplus $ac_dir/$ac_prog >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 @@ -955,12 +1021,12 @@ echo "$ac_t""$INSTALL" 1>&6 # 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_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' 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 +echo "configure:1030: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -1008,18 +1074,18 @@ EOF_SED rm -f conftestsed fi test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" + 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" + 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 +echo "configure:1087: 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 +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF @@ -1046,7 +1112,7 @@ fi PACKAGE=bfd -VERSION=2.9.4 +VERSION=2.9.5 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; } @@ -1063,7 +1129,7 @@ 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 +echo "configure:1133: 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. @@ -1076,7 +1142,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1080: checking for working autoconf" >&5 +echo "configure:1146: 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. @@ -1089,7 +1155,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1093: checking for working automake" >&5 +echo "configure:1159: 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. @@ -1102,7 +1168,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1106: checking for working autoheader" >&5 +echo "configure:1172: 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. @@ -1115,7 +1181,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1119: checking for working makeinfo" >&5 +echo "configure:1185: 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. @@ -1138,8 +1204,8 @@ 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 "configure:1208: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_AR+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$AR"; then @@ -1170,8 +1236,8 @@ 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 "configure:1240: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then @@ -1202,8 +1268,8 @@ 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 "configure:1272: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then @@ -1282,11 +1348,34 @@ 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:1289: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then +echo "configure:1378: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then @@ -1320,18 +1409,23 @@ 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 +echo "configure:1417: 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" - ;; + # 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 @@ -1343,19 +1437,19 @@ echo "configure:1329: checking for ld used by GCC" >&5 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 +echo "configure:1441: 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 +echo "configure:1444: checking for non-GNU ld" >&5 fi -if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then +if eval "test \"\${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}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -1363,7 +1457,7 @@ else 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 + test "$with_gnu_ld" != yes && break fi fi done @@ -1380,10 +1474,9 @@ 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 "configure:1479: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"\${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. @@ -1398,29 +1491,31 @@ 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 "configure:1495: checking for BSD-compatible nm" >&5 +if eval "test \"\${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 + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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" + 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" + ac_cv_path_NM="$ac_dir/nm -p" + break else - ac_cv_path_NM="$ac_dir/nm" + 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 - break fi done IFS="$ac_save_ifs" @@ -1431,10 +1526,9 @@ 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 "configure:1531: checking whether ln -s works" >&5 +if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftestdata @@ -1453,24 +1547,37 @@ else echo "$ac_t""no" 1>&6 fi -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac # Check for any special flags to pass to ltconfig. -libtool_flags= +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 "$silent" = yes && libtool_flags="$libtool_flags --silent" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" 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" + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" 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 + echo '#line 1580 "configure"' > conftest.$ac_ext + if { (eval echo configure:1581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -1488,157 +1595,118 @@ case "$host" in *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" 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 "checking whether the C compiler needs -belf""... $ac_c" 1>&6 +echo "configure:1602: checking whether the C compiler needs -belf" >&5 +if eval "test \"\${lt_cv_cc_needs_belf+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 + cat > conftest.$ac_ext <&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. +; return 0; } +EOF +if { (eval echo configure:1614: \"$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 - 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 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_needs_belf=no fi -DLLTOOL="$ac_cv_prog_DLLTOOL" -if test -n "$DLLTOOL"; then - echo "$ac_t""$DLLTOOL" 1>&6 -else - echo "$ac_t""no" 1>&6 +rm -f conftest* fi -else - DLLTOOL="false" -fi -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 + ;; -# 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 +esac -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 +# 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 - AS="false" -fi + 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 - ;; - -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" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ || { 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" + test -f "$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 @@ -1704,17 +1772,17 @@ EOF_SED rm -f conftestsed fi test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" + 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" + 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 +echo "configure:1786: 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" @@ -1737,12 +1805,12 @@ fi 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 "configure:1809: checking for Cygwin environment" >&5 +if eval "test \"\${ac_cv_cygwin+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1825: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1763,26 +1831,25 @@ else 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 "configure:1841: checking for mingw32 environment" >&5 +if eval "test \"\${ac_cv_mingw32+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1853: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1792,29 +1859,57 @@ else 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 EMX OS/2 environment""... $ac_c" 1>&6 +echo "configure:1869: checking for EMX OS/2 environment" >&5 +if eval "test \"\${ac_cv_emxos2+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_emxos2=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_emxos2=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_emxos2" 1>&6 +EMXOS2= +test "$ac_cv_emxos2" = yes && EMXOS2=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 "configure:1900: checking for executable suffix" >&5 +if eval "test \"\${ac_cv_exeext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - if test "$CYGWIN" = yes || test "$MINGW32" = yes; then + if test "$CYGWIN" = yes || test "$MINGW32" = yes || test "$EMXOS2" = 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 + if { (eval echo configure:1910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *.c | *.C | *.o | *.obj | *.xcoff) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -1840,8 +1935,8 @@ target64=false # 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 "configure:1939: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -1870,8 +1965,8 @@ 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 "configure:1969: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -1917,12 +2012,12 @@ fi if test -z "$CC"; then case "`uname -s`" in - *win32* | *WIN32*) + *win32* | *WIN32* | *CYGWIN*) # 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 "configure:2020: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -1952,8 +2047,8 @@ 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 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:2052: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1964,12 +2059,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1968 "configure" +#line 2063 "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 +if { (eval echo configure:2068: \"$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 @@ -1994,14 +2089,14 @@ 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_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:2094: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $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 "configure:2099: checking whether we are using GNU C" >&5 +if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2108: \"$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 @@ -2028,8 +2123,8 @@ 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 "configure:2127: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c @@ -2062,13 +2157,13 @@ 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 +echo "configure:2161: 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 +if eval "test \"\${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 @@ -2077,13 +2172,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < 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; } +{ (eval echo configure:2182: \"$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 : @@ -2094,13 +2189,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < 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; } +{ (eval echo configure:2199: \"$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 : @@ -2111,13 +2206,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < 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; } +{ (eval echo configure:2216: \"$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 : @@ -2142,12 +2237,12 @@ 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 "configure:2241: checking for ANSI C header files" >&5 +if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2155,7 +2250,7 @@ else #include 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; } +{ (eval echo configure:2254: \"$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* @@ -2172,7 +2267,7 @@ 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 @@ -2190,7 +2285,7 @@ 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 @@ -2211,7 +2306,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2222,7 +2317,7 @@ 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 +if { (eval echo configure:2321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2246,12 +2341,12 @@ 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 "configure:2345: checking for working const" >&5 +if eval "test \"\${ac_cv_c_const+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2321,21 +2416,21 @@ 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 "configure:2420: checking for inline" >&5 +if eval "test \"\${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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2434: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2361,12 +2456,12 @@ 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 "configure:2460: checking for off_t" >&5 +if eval "test \"\${ac_cv_type_off_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2377,29 +2472,31 @@ 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 + eval "ac_cv_type_off_t=yes" else rm -rf conftest* - ac_cv_type_off_t=no + eval "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 +if eval "test \"`echo '$ac_cv_type_'off_t`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <&6 -echo "configure:2398: checking for size_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then +echo "configure:2495: checking for size_t" >&5 +if eval "test \"\${ac_cv_type_size_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2410,17 +2507,19 @@ 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 + eval "ac_cv_type_size_t=yes" else rm -rf conftest* - ac_cv_type_size_t=no + eval "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 +if eval "test \"`echo '$ac_cv_type_'size_t`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <&6 -echo "configure:2433: checking for working alloca.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then +echo "configure:2532: checking for working alloca.h" >&5 +if eval "test \"\${ac_cv_header_alloca_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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 +if { (eval echo configure:2544: \"$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 @@ -2462,12 +2561,12 @@ 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 "configure:2565: checking for alloca" >&5 +if eval "test \"\${ac_cv_func_alloca_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2598: \"$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 @@ -2527,12 +2626,12 @@ 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 "configure:2630: checking whether alloca needs Cray hooks" >&5 +if eval "test \"\${ac_cv_os_cray+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&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 "configure:2660: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2689: \"$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 @@ -2612,15 +2712,15 @@ 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 "configure:2716: checking stack direction for C alloca" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2743: \"$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 @@ -2664,17 +2764,17 @@ 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 "configure:2768: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:2778: \"$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* @@ -2703,12 +2803,12 @@ 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 "configure:2807: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2836: \"$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 @@ -2756,15 +2857,15 @@ 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 "configure:2861: checking for working mmap" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3009: \"$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 @@ -2932,17 +3033,17 @@ 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 "configure:3037: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:3047: \"$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* @@ -2972,12 +3073,12 @@ done __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 "configure:3077: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3106: \"$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 @@ -3029,12 +3131,12 @@ done 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 "configure:3135: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3164: \"$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 @@ -3091,19 +3194,19 @@ EOF 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 "configure:3198: checking for LC_MESSAGES" >&5 +if eval "test \"\${am_cv_val_LC_MESSAGES+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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 +if { (eval echo configure:3210: \"$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 @@ -3124,7 +3227,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:3128: checking whether NLS is requested" >&5 +echo "configure:3231: 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" @@ -3144,7 +3247,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:3148: checking whether included gettext is requested" >&5 +echo "configure:3251: 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" @@ -3163,17 +3266,17 @@ fi 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 "configure:3270: checking for libintl.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:3280: \"$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* @@ -3190,19 +3293,19 @@ 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 "configure:3297: checking for gettext in libc" >&5 +if eval "test \"\${gt_cv_func_gettext_libc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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 +if { (eval echo configure:3309: \"$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 @@ -3218,15 +3321,15 @@ 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 "configure:3325: checking for bindtextdomain in -lintl" >&5 +ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-:%__p__%'` +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3344: \"$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 @@ -3253,19 +3356,19 @@ 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 "configure:3360: checking for gettext in libintl" >&5 +if eval "test \"\${gt_cv_func_gettext_libintl+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3372: \"$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 @@ -3293,8 +3396,8 @@ 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 "configure:3400: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_MSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$MSGFMT" in @@ -3327,12 +3430,12 @@ fi 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 "configure:3434: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3463: \"$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 @@ -3382,8 +3486,8 @@ 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 "configure:3490: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_GMSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$GMSGFMT" in @@ -3418,8 +3522,8 @@ 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 "configure:3526: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_XGETTEXT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$XGETTEXT" in @@ -3450,7 +3554,7 @@ else fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -3490,8 +3594,8 @@ fi # 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 "configure:3598: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_MSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$MSGFMT" in @@ -3524,8 +3628,8 @@ 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 "configure:3632: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_GMSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$GMSGFMT" in @@ -3560,8 +3664,8 @@ 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 "configure:3668: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_XGETTEXT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$XGETTEXT" in @@ -3650,7 +3754,7 @@ fi 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 +echo "configure:3758: checking for catalogs to be installed" >&5 NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in @@ -3678,17 +3782,17 @@ echo "configure:3654: checking for catalogs to be installed" >&5 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 "configure:3786: checking for linux/version.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:3796: \"$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* @@ -3766,9 +3870,9 @@ fi # 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 +echo "configure:3874: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then +if eval "test \"\${ac_cv_path_install+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" @@ -3786,6 +3890,10 @@ else grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : + elif test $ac_prog = install && + grep pwplus $ac_dir/$ac_prog >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 @@ -3814,7 +3922,7 @@ echo "$ac_t""$INSTALL" 1>&6 # 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_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' @@ -3849,19 +3957,22 @@ 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 "configure:3961: checking for build system executable suffix" >&5 +if eval "test \"\${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 + rm -f conftest* + echo 'int main () { return 0; }' > conftest.c + bfd_cv_build_exeext= + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5 + for file in conftest.*; do + case $file in + *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + rm -f conftest* + test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no fi echo "$ac_t""$bfd_cv_build_exeext" 1>&6 @@ -3874,17 +3985,17 @@ 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 "configure:3989: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:3999: \"$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* @@ -3914,17 +4025,17 @@ 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 "configure:4029: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:4039: \"$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* @@ -3951,12 +4062,12 @@ 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 "configure:4066: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"\${ac_cv_header_time+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -3965,7 +4076,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:3969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -3990,12 +4101,12 @@ 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 "configure:4105: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"\${ac_cv_header_dirent_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -4003,7 +4114,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:4007: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4118: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -4028,15 +4139,15 @@ 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 "configure:4143: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-:%__p__%'` +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4162: \"$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 @@ -4069,15 +4180,15 @@ 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 "configure:4184: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-:%__p__%'` +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4203: \"$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 @@ -4110,15 +4221,15 @@ fi fi -for ac_func in fcntl getpagesize setitimer sysconf fdopen +for ac_func in fcntl getpagesize setitimer sysconf fdopen getuid getgid 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 "configure:4228: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4257: \"$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 @@ -4168,7 +4280,7 @@ done case "${host}" in -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows) +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) cat >> confdefs.h <<\EOF #define USE_BINARY_FOPEN 1 EOF @@ -4176,12 +4288,12 @@ 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 "configure:4292: checking whether strstr must be declared" >&5 +if eval "test \"\${bfd_cv_decl_needed_strstr+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4202,7 +4314,7 @@ int main() { char *(*pfn) = (char *(*)) strstr ; return 0; } EOF -if { (eval echo configure:4206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_strstr=no else @@ -4223,12 +4335,12 @@ 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 "configure:4339: checking whether malloc must be declared" >&5 +if eval "test \"\${bfd_cv_decl_needed_malloc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4249,7 +4361,7 @@ int main() { char *(*pfn) = (char *(*)) malloc ; return 0; } EOF -if { (eval echo configure:4253: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4365: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_malloc=no else @@ -4270,12 +4382,12 @@ 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 "configure:4386: checking whether realloc must be declared" >&5 +if eval "test \"\${bfd_cv_decl_needed_realloc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4296,7 +4408,7 @@ int main() { char *(*pfn) = (char *(*)) realloc ; return 0; } EOF -if { (eval echo configure:4300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_realloc=no else @@ -4317,12 +4429,12 @@ 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 "configure:4433: checking whether free must be declared" >&5 +if eval "test \"\${bfd_cv_decl_needed_free+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4343,7 +4455,7 @@ int main() { char *(*pfn) = (char *(*)) free ; return 0; } EOF -if { (eval echo configure:4347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_free=no else @@ -4364,12 +4476,12 @@ 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 "configure:4480: checking whether getenv must be declared" >&5 +if eval "test \"\${bfd_cv_decl_needed_getenv+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4390,7 +4502,7 @@ int main() { char *(*pfn) = (char *(*)) getenv ; return 0; } EOF -if { (eval echo configure:4394: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_getenv=no else @@ -4429,8 +4541,13 @@ if test "${target}" = "${host}"; then hppa*-*-mpeix*) COREFILE=hpux-core.lo ;; hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo" COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;; + i370-*-*) + COREFILE=trad-core.lo + TRAD_HEADER='"hosts/i370linux.h"' + ;; + i[3456]86-sequent-bsd*) - COREFILE=trad-core.lo; + COREFILE=trad-core.lo TRAD_HEADER='"hosts/symmetry.h"' ;; i[3456]86-sequent-sysv4*) ;; @@ -4591,17 +4708,17 @@ if test "${target}" = "${host}"; then 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 "configure:4712: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:4722: \"$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* @@ -4629,19 +4746,19 @@ 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 "configure:4750: checking for prstatus_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_prstatus_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { prstatus_t avar ; return 0; } EOF -if { (eval echo configure:4645: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prstatus_t=yes else @@ -4663,19 +4780,19 @@ EOF 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 "configure:4784: checking for prstatus_t.pr_who in sys/procfs.h" >&5 + if eval "test \"\${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 < 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 +if { (eval echo configure:4796: \"$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 @@ -4697,19 +4814,19 @@ EOF 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 "configure:4818: checking for pstatus_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_pstatus_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { pstatus_t avar ; return 0; } EOF -if { (eval echo configure:4713: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_pstatus_t=yes else @@ -4731,19 +4848,19 @@ EOF 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 "configure:4852: checking for prpsinfo_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_prpsinfo_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { prpsinfo_t avar ; return 0; } EOF -if { (eval echo configure:4747: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4864: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prpsinfo_t=yes else @@ -4765,19 +4882,19 @@ EOF 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 "configure:4886: checking for psinfo_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_psinfo_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { psinfo_t avar ; return 0; } EOF -if { (eval echo configure:4781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4898: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_psinfo_t=yes else @@ -4799,19 +4916,19 @@ EOF 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 "configure:4920: checking for lwpstatus_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_lwpstatus_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { lwpstatus_t avar ; return 0; } EOF -if { (eval echo configure:4815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4932: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_lwpstatus_t=yes else @@ -4833,19 +4950,19 @@ EOF 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 "configure:4954: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5 + if eval "test \"\${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 < 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 +if { (eval echo configure:4966: \"$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 @@ -4867,19 +4984,19 @@ EOF 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 "configure:4988: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5 + if eval "test \"\${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 < 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 +if { (eval echo configure:5000: \"$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 @@ -4900,6 +5017,40 @@ EOF fi echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg" 1>&6 + echo $ac_n "checking for win32_pstatus_t in sys/procfs.h""... $ac_c" 1>&6 +echo "configure:5022: checking for win32_pstatus_t in sys/procfs.h" >&5 + if eval "test \"\${bfd_cv_have_sys_procfs_type_win32_pstatus_t+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +win32_pstatus_t avar +; return 0; } +EOF +if { (eval echo configure:5034: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_have_sys_procfs_type_win32_pstatus_t=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_have_sys_procfs_type_win32_pstatus_t=no + +fi +rm -f conftest* +fi + + if test $bfd_cv_have_sys_procfs_type_win32_pstatus_t = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_WIN32_PSTATUS_T 1 +EOF + + fi + echo "$ac_t""$bfd_cv_have_sys_procfs_type_win32_pstatus_t" 1>&6 + fi fi @@ -4929,7 +5080,7 @@ esac 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` + result=`$ac_config_sub $targ 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" else @@ -4964,7 +5115,7 @@ done # 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 +# no "--with-64-bit-bfd" option is given, even if "--enable-targets=all" is # used. # uniq the default and selected vectors in all the configured targets. @@ -5002,14 +5153,15 @@ do 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 " ;; + armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;; + armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;; + armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;; + armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;; + armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.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" ;; @@ -5020,6 +5172,7 @@ do 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_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;; 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" ;; @@ -5034,8 +5187,10 @@ do 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_i370_vec) tb="$tb elf32-i370.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_i960_vec) tb="$tb elf32-i960.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" @@ -5047,6 +5202,8 @@ do 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_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; + bfd_elf32_pjl_vec) tb="$tb elf32-pj.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" ;; @@ -5059,7 +5216,8 @@ do target64=true ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf" target64=true ;; - cisco_core_vec) tb="$tb cisco-core.lo" ;; + cisco_core_big_vec) tb="$tb cisco-core.lo" ;; + cisco_core_little_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" ;; @@ -5080,8 +5238,8 @@ do 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" ;; + i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;; + i386pei_vec) tb="$tb pei-i386.lo peigen.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" ;; @@ -5102,10 +5260,12 @@ do 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" ;; + mipslpe_vec) tb="$tb pe-mips.lo cofflink.lo" ;; + mipslpei_vec) tb="$tb pei-mips.lo cofflink.lo" ;; + mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pei_little_vec) tb="$tb pei-mcore.lo peigen.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" ;; @@ -5117,15 +5277,17 @@ do 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" ;; + bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.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" ;; + shlpe_vec) tb="$tb pe-sh.lo coff-sh.lo cofflink.lo" ;; + shlpei_vec) tb="$tb pei-sh.lo 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" ;; @@ -5228,17 +5390,17 @@ 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 "configure:5394: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < 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; } +{ (eval echo configure:5404: \"$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* @@ -5267,12 +5429,12 @@ 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 "configure:5433: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5462: \"$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 @@ -5320,15 +5483,15 @@ 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 "configure:5487: checking for working mmap" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5635: \"$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 @@ -5493,12 +5656,12 @@ 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 "configure:5660: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5689: \"$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 @@ -5643,7 +5807,7 @@ do 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" + echo "$CONFIG_STATUS generated by autoconf version 2.13.1" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -5715,12 +5879,8 @@ 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 @@ -5983,5 +6143,5 @@ 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 +test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 diff --git a/bfd/configure.bat b/bfd/configure.bat deleted file mode 100644 index 78fe79e..0000000 --- a/bfd/configure.bat +++ /dev/null @@ -1,18 +0,0 @@ -@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.host b/bfd/configure.host index ef7048b..e24cd60 100644 --- a/bfd/configure.host +++ b/bfd/configure.host @@ -63,6 +63,8 @@ m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;; ac_cv_func_getpagesize=no ac_cv_func_madvise=no ac_cv_func_mprotect=no + ac_cv_func_getuid=no + ac_cv_func_getgid=no ac_cv_header_sys_file_h=no ac_cv_header_sys_time_h=no ac_cv_header_unistd_h=no diff --git a/bfd/configure.in b/bfd/configure.in index 3a3e36f..df2b613 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -7,7 +7,7 @@ AC_INIT(libbfd.c) AC_CANONICAL_SYSTEM AC_ISC_POSIX -AM_INIT_AUTOMAKE(bfd, 2.9.4) +AM_INIT_AUTOMAKE(bfd, 2.9.5) dnl These must be called before AM_PROG_LIBTOOL, because it may want dnl to call AC_CHECK_PROG. @@ -98,7 +98,7 @@ 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) +AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid) BFD_BINARY_FOPEN @@ -126,10 +126,15 @@ if test "${target}" = "${host}"; then hppa*-*-mpeix*) COREFILE=hpux-core.lo ;; hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo" COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;; + i370-*-*) + COREFILE=trad-core.lo + TRAD_HEADER='"hosts/i370linux.h"' + ;; + changequote(,)dnl i[3456]86-sequent-bsd*) changequote([,])dnl - COREFILE=trad-core.lo; + COREFILE=trad-core.lo TRAD_HEADER='"hosts/symmetry.h"' ;; changequote(,)dnl @@ -314,6 +319,7 @@ changequote([,])dnl 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) + BFD_HAVE_SYS_PROCFS_TYPE(win32_pstatus_t) fi fi AC_SUBST(COREFILE) @@ -341,7 +347,7 @@ AC_SUBST(WIN32LIBADD) 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` + result=`$ac_config_sub $targ 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" else @@ -376,7 +382,7 @@ AC_SUBST(TDEFINES) # 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 +# no "--with-64-bit-bfd" option is given, even if "--enable-targets=all" is # used. # uniq the default and selected vectors in all the configured targets. @@ -414,14 +420,15 @@ do 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 " ;; + armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;; + armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;; + armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;; + armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;; + armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;; + arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.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" ;; @@ -432,6 +439,7 @@ do 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_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;; 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" ;; @@ -446,8 +454,10 @@ do 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_i370_vec) tb="$tb elf32-i370.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_i960_vec) tb="$tb elf32-i960.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" @@ -459,6 +469,8 @@ do 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_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; + bfd_elf32_pjl_vec) tb="$tb elf32-pj.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" ;; @@ -471,7 +483,8 @@ do target64=true ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf" target64=true ;; - cisco_core_vec) tb="$tb cisco-core.lo" ;; + cisco_core_big_vec) tb="$tb cisco-core.lo" ;; + cisco_core_little_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" ;; @@ -492,8 +505,8 @@ do 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" ;; + i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;; + i386pei_vec) tb="$tb pei-i386.lo peigen.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" ;; @@ -514,10 +527,12 @@ do 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" ;; + mipslpe_vec) tb="$tb pe-mips.lo cofflink.lo" ;; + mipslpei_vec) tb="$tb pei-mips.lo cofflink.lo" ;; + mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;; + mcore_pei_little_vec) tb="$tb pei-mcore.lo peigen.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" ;; @@ -529,15 +544,17 @@ do 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" ;; + bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; + bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.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" ;; + shlpe_vec) tb="$tb pe-sh.lo coff-sh.lo cofflink.lo" ;; + shlpei_vec) tb="$tb pei-sh.lo 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" ;; diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c index d999c0f..bda9c44 100644 --- a/bfd/cpu-arm.c +++ b/bfd/cpu-arm.c @@ -1,5 +1,5 @@ /* BFD support for the ARM processor - Copyright 1994, 95, 1997 Free Software Foundation, Inc. + Copyright 1994, 95, 97, 1999 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -82,10 +82,17 @@ processors[] = { bfd_mach_arm_3, "arm7di" }, { bfd_mach_arm_3M, "arm7dm" }, { bfd_mach_arm_3M, "arm7dmi" }, + { bfd_mach_arm_4T, "arm7tdmi" }, { bfd_mach_arm_4, "arm8" }, { bfd_mach_arm_4, "arm810" }, + { bfd_mach_arm_4, "arm9" }, + { bfd_mach_arm_4, "arm920" }, + { bfd_mach_arm_4T, "arm920t" }, + { bfd_mach_arm_4T, "arm9tdmi" }, { bfd_mach_arm_4, "sa1" }, - { bfd_mach_arm_4T, "arm7tdmi" } + { bfd_mach_arm_4, "strongarm"}, + { bfd_mach_arm_4, "strongarm110" }, + { bfd_mach_arm_4, "strongarm1100" }, }; static boolean @@ -127,7 +134,9 @@ static const bfd_arch_info_type arch_info_struct[] = 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 ) + N( bfd_mach_arm_4T, "armv4t", false, & arch_info_struct[6] ), + N( bfd_mach_arm_5, "armv5", false, & arch_info_struct[7] ), + N( bfd_mach_arm_5T, "armv5t", false, NULL ) }; const bfd_arch_info_type bfd_arm_arch = diff --git a/bfd/cpu-avr.c b/bfd/cpu-avr.c new file mode 100644 index 0000000..637b13f --- /dev/null +++ b/bfd/cpu-avr.c @@ -0,0 +1,89 @@ +/* BFD library support routines for the AVR architecture. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Contributed by Denis Chertykov + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public 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 *)); + + +#define N(addr_bits, machine, print, default, next) \ +{ \ + 8, /* 8 bits in a word */ \ + addr_bits, /* bits in an address */ \ + 8, /* 8 bits in a byte */ \ + bfd_arch_avr, \ + machine, /* machine */ \ + "avr", /* arch_name */ \ + print, /* printable name */ \ + 1, /* section align power */ \ + default, /* the default machine */ \ + compatible, \ + bfd_default_scan, \ + next \ +} + +static const bfd_arch_info_type arch_info_struct[] = +{ + /* AT90S1200 */ + N (16, bfd_mach_avr1, "avr:1", false, & arch_info_struct[1]), + + /* AT90S2xxx, AT90S4xxx, AT90S81xx, ATtiny22 */ + N (16, bfd_mach_avr2, "avr:2", false, & arch_info_struct[2]), + + /* ATmega103, ATmega603 */ + N (22, bfd_mach_avr3, "avr:3", false, & arch_info_struct[3]), + + /* ATmega161 */ + N (16, bfd_mach_avr4, "avr:4", false, NULL) +}; + +const bfd_arch_info_type bfd_avr_arch = + N (16, bfd_mach_avr2, "avr", true, & arch_info_struct[0]); + +/* This routine is provided two arch_infos and works out which AVR + 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 architectures we can do nothing. */ + if (a->arch != b->arch) + return NULL; + + /* Special case for ATmega[16]03 (avr:3) and ATmega161 (avr:4). */ + if ((a->mach == 3 && b->mach == 4) + || (a->mach == 4 && b->mach == 3)) + return NULL; + + /* So far all newer AVR architecture cores are supersets of previous + cores. */ + if (a->mach <= b->mach) + return b; + + /* Never reached! */ + return NULL; +} diff --git a/bfd/cpu-d10v.c b/bfd/cpu-d10v.c index a1ff088..e16c3b7 100644 --- a/bfd/cpu-d10v.c +++ b/bfd/cpu-d10v.c @@ -1,5 +1,5 @@ /* BFD support for the D10V processor - Copyright 1996 Free Software Foundation, Inc. + Copyright 1996, 1999 Free Software Foundation, Inc. Contributed by Martin Hunt (hunt@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -22,19 +22,50 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include "libbfd.h" -const bfd_arch_info_type bfd_d10v_arch = +static const bfd_arch_info_type d10v_ts3_info = { - 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, + 16, /* 16 bits in a word */ + 16, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_d10v, + bfd_mach_d10v_ts3, + "d10v", + "d10v:ts3", + 4, /* section alignment power */ + false, + bfd_default_compatible, + bfd_default_scan, + 0, +}; + +static const bfd_arch_info_type d10v_ts2_info = +{ + 16, /* 16 bits in a word */ + 16, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_d10v, + bfd_mach_d10v_ts2, + "d10v", + "d10v:ts2", + 4, /* section alignment power */ + false, + bfd_default_compatible, + bfd_default_scan, + &d10v_ts3_info, }; +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, + bfd_mach_d10v, + "d10v", + "d10v", + 4, /* section alignment power */ + true, + bfd_default_compatible, + bfd_default_scan, + &d10v_ts2_info, +}; diff --git a/bfd/cpu-h8500.c b/bfd/cpu-h8500.c index e4abfd1..eae42e3 100644 --- a/bfd/cpu-h8500.c +++ b/bfd/cpu-h8500.c @@ -1,5 +1,5 @@ /* BFD library support routines for the H8/500 architecture. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1999 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -156,7 +156,7 @@ int bfd_default_scan_num_mach(); static boolean scan_mach (info, string) - const struct bfd_arch_info *info; + const struct bfd_arch_info *info ATTRIBUTE_UNUSED; const char *string; { if (strcmp(string,"h8/500") == 0) return true; diff --git a/bfd/cpu-hppa.c b/bfd/cpu-hppa.c index 5d26a92..5c17743 100644 --- a/bfd/cpu-hppa.c +++ b/bfd/cpu-hppa.c @@ -54,6 +54,23 @@ static const bfd_arch_info_type bfd_hppa20_arch = &bfd_hppa10_arch, }; +/* PA2.0 in wide mode */ +static const bfd_arch_info_type bfd_hppa20w_arch = +{ + 64, /* 32 bits in a word */ + 64, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_hppa, + 25, /* ??? How best to describe wide mode here? */ + "hppa", + "hppa2.0w", + 3, + false, /* Unless we use 1.1 specific features */ + bfd_default_compatible, + bfd_default_scan , + &bfd_hppa20_arch, +}; + const bfd_arch_info_type bfd_hppa_arch = { 32, /* 32 bits in a word */ @@ -67,5 +84,5 @@ const bfd_arch_info_type bfd_hppa_arch = false, /* 1.1 specific features used */ bfd_default_compatible, bfd_default_scan , - &bfd_hppa20_arch, + &bfd_hppa20w_arch, }; diff --git a/bfd/cpu-i370.c b/bfd/cpu-i370.c new file mode 100644 index 0000000..2331eef --- /dev/null +++ b/bfd/cpu-i370.c @@ -0,0 +1,94 @@ +/* BFD i370 CPU definition + Copyright (C) 1994, 95, 96, 98, 99, 2000 Free Software Foundation, Inc. + Contributed by Ian Lance Taylor, Cygnus Support. + Hacked by Linas Vepstas in 1998, 1999 + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public 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 i360/370 architecture comes in many forms */ + +static const bfd_arch_info_type *i370_compatible + PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *)); + +static const bfd_arch_info_type * +i370_compatible (a, b) + const bfd_arch_info_type *a; + const bfd_arch_info_type *b; +{ + BFD_ASSERT (a->arch == bfd_arch_i370); + switch (b->arch) + { + default: + return NULL; + case bfd_arch_i370: + return bfd_default_compatible (a, b); + } + /*NOTREACHED*/ +} + +static const bfd_arch_info_type arch_info_struct[] = +{ + /* hack alert: old old machines are really 16 and 24 bit arch ... */ + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_i370, + 360, /* for the 360 */ + "i370", + "i370:360", + 3, + false, /* not the default */ + i370_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_i370, + 370, /* for the 370 */ + "i370", + "i370:370", + 3, + false, /* not the default */ + i370_compatible, + bfd_default_scan, + 0 + }, +}; + +const bfd_arch_info_type bfd_i370_arch = + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_i370, + 0, /* for the 360/370 common architecture */ + "i370", + "i370:common", + 3, + true, /* the default */ + i370_compatible, + bfd_default_scan, + &arch_info_struct[0] + }; diff --git a/bfd/cpu-m10300.c b/bfd/cpu-m10300.c index 5aa0bfe..c14428e 100644 --- a/bfd/cpu-m10300.c +++ b/bfd/cpu-m10300.c @@ -1,5 +1,5 @@ /* BFD support for the Matsushita 10300 processor - Copyright 1996, 1997 Free Software Foundation, Inc. + Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -21,12 +21,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include "libbfd.h" -#define NEXT NULL +const bfd_arch_info_type bfd_am33_arch = + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_mn10300, + 330, + "am33", + "am33", + 2, + false, + bfd_default_compatible, + bfd_default_scan, + 0, + }; const bfd_arch_info_type bfd_mn10300_arch = { - 32, /* 16 bits in a word */ - 32, /* 16 bits in an address */ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_mn10300, 300, @@ -35,7 +49,6 @@ const bfd_arch_info_type bfd_mn10300_arch = 2, true, /* the one and only */ bfd_default_compatible, - bfd_default_scan , - NEXT, + bfd_default_scan, + &bfd_am33_arch, }; - diff --git a/bfd/cpu-m32r.c b/bfd/cpu-m32r.c index bd3cc31..895ad41 100644 --- a/bfd/cpu-m32r.c +++ b/bfd/cpu-m32r.c @@ -27,6 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define NEXT NULL +static const bfd_arch_info_type arch_info_struct[] = +{ + N (bfd_mach_m32rx, "m32rx", false, NULL) +}; + +#undef NEXT +#define NEXT &arch_info_struct[0] const bfd_arch_info_type bfd_m32r_arch = N (bfd_mach_m32r, "m32r", true, NEXT); diff --git a/bfd/cpu-mcore.c b/bfd/cpu-mcore.c index 7dbfe1b..760bcde 100644 --- a/bfd/cpu-mcore.c +++ b/bfd/cpu-mcore.c @@ -1,4 +1,4 @@ -/* BFD library support routines for Motorolla's MCore architecture +/* BFD library support routines for Motorola's MCore architecture Copyright (C) 1993, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -15,7 +15,7 @@ GNU General Public License for more details. You 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. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c index 1b0a18d..f74e25b 100644 --- a/bfd/cpu-ns32k.c +++ b/bfd/cpu-ns32k.c @@ -1,5 +1,5 @@ /* BFD support for the ns32k architecture. - Copyright (C) 1990, 91, 94, 95, 96, 1998 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 94, 95, 96, 98, 1999 Free Software Foundation, Inc. Almost totally rewritten by Ian Dall from initial work by Andrew Cagney. @@ -173,7 +173,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; long (*get_data)(); int (*put_data)(); { @@ -596,7 +596,7 @@ 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 *input_bfd ATTRIBUTE_UNUSED; bfd_vma relocation; bfd_byte *location; long (*get_data)(); diff --git a/bfd/cpu-pj.c b/bfd/cpu-pj.c new file mode 100644 index 0000000..44ddd33 --- /dev/null +++ b/bfd/cpu-pj.c @@ -0,0 +1,85 @@ +/* BFD library support routines for the Pico Java architecture. + Copyright (C) 1999 Free Software Foundation, Inc. + Hacked by Steve Chamberlain of Transmeta. sac@pobox.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" + + +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 + + +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_pj, + 0, + "pj", /* arch_name */ + "pj", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + 0, + }, +}; + +const bfd_arch_info_type bfd_pj_arch = +{ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_pj, + 0, + "pj", /* arch_name */ + "pj", /* printable name */ + 1, + true, /* the default machine */ + bfd_default_compatible, + scan_mach, + &arch_info_struct [0] +}; diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c index 44adf92..cb54e7d 100644 --- a/bfd/cpu-sh.c +++ b/bfd/cpu-sh.c @@ -1,5 +1,5 @@ /* BFD library support routines for the Hitachi-SH architecture. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 97, 1998, 2000 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -50,8 +50,12 @@ compatible (a,b) #endif #define SH_NEXT &arch_info_struct[0] -#define SH3_NEXT &arch_info_struct[1] -#define SH3E_NEXT NULL +#define SH2_NEXT &arch_info_struct[1] +#define SH_DSP_NEXT &arch_info_struct[2] +#define SH3_NEXT &arch_info_struct[3] +#define SH3_DSP_NEXT &arch_info_struct[4] +#define SH3E_NEXT &arch_info_struct[5] +#define SH4_NEXT NULL static const bfd_arch_info_type arch_info_struct[] = { @@ -60,6 +64,34 @@ static const bfd_arch_info_type arch_info_struct[] = 32, /* 32 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_sh, + bfd_mach_sh2, + "sh", /* arch_name */ + "sh2", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + SH2_NEXT + }, + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_sh, + bfd_mach_sh_dsp, + "sh", /* arch_name */ + "sh-dsp", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + SH_DSP_NEXT + }, + { + 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 */ @@ -74,6 +106,20 @@ static const bfd_arch_info_type arch_info_struct[] = 32, /* 32 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_sh, + bfd_mach_sh3_dsp, + "sh", /* arch_name */ + "sh3-dsp", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + SH3_DSP_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 */ @@ -83,6 +129,20 @@ static const bfd_arch_info_type arch_info_struct[] = scan_mach, SH3E_NEXT }, + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_sh, + bfd_mach_sh4, + "sh", /* arch_name */ + "sh4", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + SH4_NEXT + }, }; const bfd_arch_info_type bfd_sh_arch = diff --git a/bfd/cpu-w65.c b/bfd/cpu-w65.c index c0bbf04..13f68b3 100644 --- a/bfd/cpu-w65.c +++ b/bfd/cpu-w65.c @@ -1,5 +1,5 @@ /* BFD library support routines for the WDC 65816 architecture. - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1999 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -27,7 +27,7 @@ int bfd_default_scan_num_mach(); static boolean scan_mach (info, string) - const struct bfd_arch_info *info; + const struct bfd_arch_info *info ATTRIBUTE_UNUSED; const char *string; { if (strcmp(string,"w65") == 0) return true; diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in index 6295c10..343cab1 100644 --- a/bfd/doc/Makefile.in +++ b/bfd/doc/Makefile.in @@ -89,14 +89,13 @@ 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@ +OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ POFILES = @POFILES@ POSUB = @POSUB@ @@ -104,7 +103,6 @@ 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@ @@ -189,7 +187,7 @@ DIST_COMMON = ChangeLog Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: @@ -324,7 +322,7 @@ 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; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c index cbcc26b..da184cc 100644 --- a/bfd/dwarf1.c +++ b/bfd/dwarf1.c @@ -1,5 +1,5 @@ /* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line). - Copyright 1998 Free Software Foundation, Inc. + Copyright 1998, 1999 Free Software Foundation, Inc. Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com). @@ -140,8 +140,8 @@ alloc_dwarf1_unit (stash) struct dwarf1_debug* stash; { struct dwarf1_unit* x = - (struct dwarf1_unit*) bfd_alloc (stash->abfd, - sizeof (struct dwarf1_unit)); + (struct dwarf1_unit*) bfd_zalloc (stash->abfd, + sizeof (struct dwarf1_unit)); x->prev = stash->lastUnit; stash->lastUnit = x; @@ -157,8 +157,8 @@ alloc_dwarf1_func (stash, aUnit) struct dwarf1_unit* aUnit; { struct dwarf1_func* x = - (struct dwarf1_func*) bfd_alloc (stash->abfd, - sizeof (struct dwarf1_func)); + (struct dwarf1_func*) bfd_zalloc (stash->abfd, + sizeof (struct dwarf1_func)); x->prev = aUnit->func_list; aUnit->func_list = x; @@ -186,6 +186,8 @@ parse_die (abfd, aDieInfo, aDiePtr) /* First comes the length. */ aDieInfo->length = bfd_get_32 (abfd, xptr); xptr += 4; + if (aDieInfo->length == 0) + return false; if (aDieInfo->length < 6) { /* Just padding bytes. */ @@ -291,7 +293,7 @@ parse_line_table (stash, aUnit) xptr = stash->line_section + aUnit->stmt_list_offset; if (xptr < stash->line_section_end) { - int eachLine; + unsigned long eachLine; char* tblend; unsigned long base; @@ -398,7 +400,7 @@ dwarf1_unit_find_nearest_line (stash, aUnit, addr, { if (aUnit->has_stmt_list) { - int i; + unsigned long i; struct dwarf1_func* eachFunc; if (! aUnit->linenumber_table) @@ -454,7 +456,7 @@ _bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, linenumber_ptr) bfd *abfd; asection *section; - asymbol **symbols; + asymbol **symbols ATTRIBUTE_UNUSED; bfd_vma offset; const char **filename_ptr; const char **functionname_ptr; diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 385bf82..5710d1a 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -1,5 +1,5 @@ /* DWARF 2 support. - Copyright 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions (gavin@cygnus.com). @@ -99,8 +99,16 @@ struct dwarf2_debug { /* Length of the loaded .debug_abbrev section. */ unsigned long dwarf_abbrev_size; + + /* Buffer for decode_line_info. */ + char *dwarf_line_buffer; }; +struct arange { + struct arange *next; + bfd_vma low; + bfd_vma high; +}; /* A minimal decoding of DWARF2 compilation units. We only decode @@ -116,8 +124,7 @@ struct comp_unit { /* The lowest and higest addresses contained in this compilation unit as specified in the compilation unit header. */ - bfd_vma low; - bfd_vma high; + struct arange arange; /* The DW_AT_name attribute (for error messages). */ char* name; @@ -163,7 +170,7 @@ struct comp_unit { static unsigned int read_1_byte (abfd, buf) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; char *buf; { return bfd_get_8 (abfd, (bfd_byte *) buf); @@ -171,7 +178,7 @@ read_1_byte (abfd, buf) static int read_1_signed_byte (abfd, buf) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; char *buf; { return bfd_get_signed_8 (abfd, (bfd_byte *) buf); @@ -231,9 +238,9 @@ read_8_bytes (abfd, buf) static char * read_n_bytes (abfd, buf, size) - bfd * abfd; + bfd *abfd ATTRIBUTE_UNUSED; char *buf; - unsigned int size; + unsigned int size ATTRIBUTE_UNUSED; { /* 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 @@ -243,7 +250,7 @@ read_n_bytes (abfd, buf, size) static char * read_string (abfd, buf, bytes_read_ptr) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; char *buf; unsigned int *bytes_read_ptr; { @@ -261,7 +268,7 @@ read_string (abfd, buf, bytes_read_ptr) static unsigned int read_unsigned_leb128 (abfd, buf, bytes_read_ptr) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; char *buf; unsigned int *bytes_read_ptr; { @@ -291,8 +298,8 @@ read_unsigned_leb128 (abfd, buf, bytes_read_ptr) static int read_signed_leb128 (abfd, buf, bytes_read_ptr) - bfd * abfd; - char * buf; + bfd *abfd ATTRIBUTE_UNUSED; + char *buf; unsigned int * bytes_read_ptr; { int result; @@ -329,15 +336,17 @@ read_address (unit, buf) struct comp_unit* unit; char *buf; { - bfd_vma retval = 0; - - if (unit->addr_size == 4) + switch (unit->addr_size) { - retval = bfd_get_32 (unit->abfd, (bfd_byte *) buf); - } else { - retval = bfd_get_64 (unit->abfd, (bfd_byte *) buf); + case 8: + return bfd_get_64 (unit->abfd, (bfd_byte *) buf); + case 4: + return bfd_get_32 (unit->abfd, (bfd_byte *) buf); + case 2: + return bfd_get_16 (unit->abfd, (bfd_byte *) buf); + default: + abort (); } - return retval; } @@ -422,8 +431,8 @@ read_abbrevs (abfd, offset) 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); + stash->dwarf_abbrev_size = msec->_raw_size; + stash->dwarf_abbrev_buffer = (char*) bfd_alloc (abfd, stash->dwarf_abbrev_size); if (! stash->dwarf_abbrev_buffer) return 0; @@ -604,6 +613,10 @@ read_attribute (attr, abbrev, unit, info_ptr) DW_UNSND (attr) = read_4_bytes (abfd, info_ptr); info_ptr += 4; break; + case DW_FORM_ref8: + DW_UNSND (attr) = read_8_bytes (abfd, info_ptr); + info_ptr += 8; + break; case DW_FORM_ref_udata: DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); info_ptr += bytes_read; @@ -631,6 +644,7 @@ struct line_info { char* filename; unsigned int line; unsigned int column; + int end_sequence; /* end of (sequential) code sequence */ }; struct fileinfo { @@ -653,12 +667,13 @@ struct line_info_table { }; static void -add_line_info (table, address, filename, line, column) +add_line_info (table, address, filename, line, column, end_sequence) struct line_info_table* table; bfd_vma address; char* filename; unsigned int line; unsigned int column; + int end_sequence; { struct line_info* info = (struct line_info*) bfd_alloc (table->abfd, sizeof (struct line_info)); @@ -670,6 +685,7 @@ add_line_info (table, address, filename, line, column) info->filename = filename; info->line = line; info->column = column; + info->end_sequence = end_sequence; } static char* @@ -677,7 +693,16 @@ concat_filename (table, file) struct line_info_table* table; unsigned int file; { - char* filename = table->files[file - 1].name; + char* filename; + + if (file - 1 >= table->num_files) + { + (*_bfd_error_handler) (_("Dwarf Error: mangled line number " + "section (bad file number).")); + return ""; + } + + filename = table->files[file - 1].name; if (*filename == '/') return filename; @@ -690,6 +715,50 @@ concat_filename (table, file) } } +static void +arange_add (unit, low_pc, high_pc) + struct comp_unit *unit; + bfd_vma low_pc; + bfd_vma high_pc; +{ + struct arange *arange; + + /* first see if we can cheaply extend an existing range: */ + arange = &unit->arange; + do + { + if (low_pc == arange->high) + { + arange->high = high_pc; + return; + } + if (high_pc == arange->low) + { + arange->low = low_pc; + return; + } + arange = arange->next; + } + while (arange); + + if (unit->arange.high == 0) + { + /* this is the first address range: store it in unit->arange: */ + unit->arange.next = 0; + unit->arange.low = low_pc; + unit->arange.high = high_pc; + return; + } + + /* need to allocate a new arange and insert it into the arange list: */ + arange = bfd_zalloc (unit->abfd, sizeof (*arange)); + arange->low = low_pc; + arange->high = high_pc; + + arange->next = unit->arange.next; + unit->arange.next = arange; +} + /* Decode the line number information for UNIT. */ static struct line_info_table* @@ -698,7 +767,7 @@ decode_line_info (unit) { bfd *abfd = unit->abfd; - static char* dwarf_line_buffer = 0; + struct dwarf2_debug *stash; struct line_info_table* table; @@ -709,7 +778,9 @@ decode_line_info (unit) char *cur_file, *cur_dir; unsigned char op_code, extended_op, adj_opcode; - if (! dwarf_line_buffer) + stash = elf_tdata (abfd)->dwarf2_find_line_info; + + if (! stash->dwarf_line_buffer) { asection *msec; unsigned long size; @@ -722,13 +793,13 @@ decode_line_info (unit) return 0; } - size = bfd_get_section_size_before_reloc (msec); - dwarf_line_buffer = (unsigned char*) bfd_alloc (abfd, size); - if (! dwarf_line_buffer) + size = msec->_raw_size; + stash->dwarf_line_buffer = (char *) bfd_alloc (abfd, size); + if (! stash->dwarf_line_buffer) return 0; if (! bfd_get_section_contents (abfd, msec, - dwarf_line_buffer, 0, + stash->dwarf_line_buffer, 0, size)) return 0; @@ -747,7 +818,10 @@ decode_line_info (unit) table->num_dirs = 0; table->dirs = NULL; - line_ptr = dwarf_line_buffer + unit->line_offset; + table->files = NULL; + table->last_line = NULL; + + line_ptr = stash->dwarf_line_buffer + unit->line_offset; /* read in the prologue */ lh.total_length = read_4_bytes (abfd, line_ptr); @@ -830,7 +904,8 @@ decode_line_info (unit) unsigned int column = 0; int is_stmt = lh.default_is_stmt; int basic_block = 0; - int end_sequence = 0; + int end_sequence = 0, need_low_pc = 1; + bfd_vma low_pc = 0; /* Decode the table. */ while (! end_sequence) @@ -847,7 +922,14 @@ decode_line_info (unit) { case DW_LNE_end_sequence: end_sequence = 1; - add_line_info (table, address, filename, line, column); + add_line_info (table, address, filename, line, column, + end_sequence); + if (need_low_pc) + { + need_low_pc = 0; + low_pc = address; + } + arange_add (unit, low_pc, address); break; case DW_LNE_set_address: address = read_address (unit, line_ptr); @@ -884,8 +966,13 @@ decode_line_info (unit) } break; case DW_LNS_copy: - add_line_info (table, address, filename, line, column); + add_line_info (table, address, filename, line, column, 0); basic_block = 0; + if (need_low_pc) + { + need_low_pc = 0; + low_pc = address; + } break; case DW_LNS_advance_pc: address += lh.minimum_instruction_length @@ -918,7 +1005,8 @@ decode_line_info (unit) basic_block = 1; break; case DW_LNS_const_add_pc: - address += (255 - lh.opcode_base) / lh.line_range; + address += lh.minimum_instruction_length + * ((255 - lh.opcode_base) / lh.line_range); break; case DW_LNS_fixed_advance_pc: address += read_2_bytes (abfd, line_ptr); @@ -930,8 +1018,13 @@ decode_line_info (unit) * 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); + add_line_info (table, address, filename, line, column, 0); basic_block = 1; + if (need_low_pc) + { + need_low_pc = 0; + low_pc = address; + } } } } @@ -954,21 +1047,25 @@ lookup_address_in_line_info_table (table, const char **filename_ptr; unsigned int *linenumber_ptr; { + struct line_info* next_line = table->last_line; 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 (!next_line) + return false; + + each_line = next_line->prev_line; + + while (each_line && next_line) { - if (addr >= each_line->address - && (next_line == 0 - || addr < next_line->address)) + if (!each_line->end_sequence + && addr >= each_line->address && addr < next_line->address) { *filename_ptr = each_line->filename; *linenumber_ptr = each_line->line; return true; } + next_line = each_line; + each_line = each_line->prev_line; } return false; @@ -1125,24 +1222,27 @@ scan_unit_for_functions (unit) -/* 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. +/* 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. + If ABBREV_LENGTH is 0, then the length of the abbreviation offset + is assumed to be four bytes. Otherwise, it it is the size given. 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) +parse_comp_unit (abfd, info_ptr, end_ptr, abbrev_length) bfd* abfd; char* info_ptr; char* end_ptr; + unsigned int abbrev_length; { struct comp_unit* unit; unsigned short version; - unsigned int abbrev_offset; + unsigned int abbrev_offset = 0; unsigned char addr_size; struct abbrev_info** abbrevs; @@ -1152,8 +1252,14 @@ parse_comp_unit (abfd, info_ptr, end_ptr) version = read_2_bytes (abfd, info_ptr); info_ptr += 2; - abbrev_offset = read_4_bytes (abfd, info_ptr); - info_ptr += 4; + BFD_ASSERT (abbrev_length == 0 + || abbrev_length == 4 + || abbrev_length == 8); + if (abbrev_length == 0 || abbrev_length == 4) + abbrev_offset = read_4_bytes (abfd, info_ptr); + else if (abbrev_length == 8) + abbrev_offset = read_8_bytes (abfd, info_ptr); + info_ptr += abbrev_length; addr_size = read_1_byte (abfd, info_ptr); info_ptr += 1; @@ -1173,9 +1279,9 @@ parse_comp_unit (abfd, info_ptr, end_ptr) return 0; } - if (addr_size != 4 && addr_size != 8) + if (addr_size != 2 && 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_error_handler) ("Dwarf Error: found address size '%u', this reader can only handle address sizes '2', '4' and '8'.", addr_size ); bfd_set_error (bfd_error_bad_value); return 0; } @@ -1228,11 +1334,11 @@ parse_comp_unit (abfd, info_ptr, end_ptr) break; case DW_AT_low_pc: - unit->low = DW_ADDR (&attr); + unit->arange.low = DW_ADDR (&attr); break; case DW_AT_high_pc: - unit->high = DW_ADDR (&attr); + unit->arange.high = DW_ADDR (&attr); break; case DW_AT_comp_dir: @@ -1271,8 +1377,20 @@ comp_unit_contains_address (unit, addr) struct comp_unit* unit; bfd_vma addr; { - return ! unit->error - && (addr >= unit->low && addr <= unit->high); + struct arange *arange; + + if (unit->error) + return 0; + + arange = &unit->arange; + do + { + if (addr >= arange->low && addr < arange->high) + return 1; + arange = arange->next; + } + while (arange); + return 0; } @@ -1332,19 +1450,25 @@ comp_unit_find_nearest_line (unit, addr, return line_p || func_p; } -/* The DWARF2 version of find_nearest line. - Return true if the line is found without error. */ +/* The DWARF2 version of find_nearest line. Return true if the line + is found without error. ADDR_SIZE is the number of bytes in the + initial .debug_info length field and in the abbreviation offset. + You may use zero to indicate that the default value should be + used. */ boolean _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, - filename_ptr, functionname_ptr, linenumber_ptr) + filename_ptr, functionname_ptr, + linenumber_ptr, + addr_size) bfd *abfd; asection *section; - asymbol **symbols; + asymbol **symbols ATTRIBUTE_UNUSED; bfd_vma offset; const char **filename_ptr; const char **functionname_ptr; unsigned int *linenumber_ptr; + unsigned int addr_size; { /* Read each compilation unit from the section .debug_info, and check to see if it contains the address we are searching for. If yes, @@ -1367,6 +1491,13 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, *functionname_ptr = NULL; *linenumber_ptr = 0; + /* The DWARF2 spec says that the initial length field, and the + offset of the abbreviation table, should both be 4-byte values. + However, some compilers do things differently. */ + if (addr_size == 0) + addr_size = 4; + BFD_ASSERT (addr_size == 4 || addr_size == 8); + if (! stash) { asection *msec; @@ -1387,7 +1518,7 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, return false; } - size = bfd_get_section_size_before_reloc (msec); + size = msec->_raw_size; if (size == 0) return false; @@ -1404,14 +1535,20 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, 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. + /* 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 (e.g., there may be relocs + against the operand of the DW_LNE_set_address operator). - Unfortunately getting hold of the reloc information is hard... */ + Unfortunately getting hold of the reloc information is hard... + + For now, this means that disassembling object files (as + opposed to fully executables) does not always work as well as + we would like. */ } /* A null info_ptr indicates that there is no dwarf2 info @@ -1423,27 +1560,28 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, /* 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); - } + 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; + bfd_vma length; + boolean found; - length = read_4_bytes (abfd, stash->info_ptr); - stash->info_ptr += 4; + if (addr_size == 4) + length = read_4_bytes (abfd, stash->info_ptr); + else + length = read_8_bytes (abfd, stash->info_ptr); + stash->info_ptr += addr_size; if (length > 0) { each = parse_comp_unit (abfd, stash->info_ptr, - stash->info_ptr + length); + stash->info_ptr + length, + addr_size); stash->info_ptr += length; if (each) @@ -1451,11 +1589,28 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, 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); + /* DW_AT_low_pc and DW_AT_high_pc are optional for + compilation units. If we don't have them (i.e., + unit->high == 0), we need to consult the line info + table to see if a compilation unit contains the given + address. */ + if (each->arange.high > 0) + { + if (comp_unit_contains_address (each, addr)) + return comp_unit_find_nearest_line (each, addr, + filename_ptr, + functionname_ptr, + linenumber_ptr); + } + else + { + found = comp_unit_find_nearest_line (each, addr, + filename_ptr, + functionname_ptr, + linenumber_ptr); + if (found) + return true; + } } } } diff --git a/bfd/ecoff.c b/bfd/ecoff.c index d5c6f85..4b136ee 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -1,5 +1,5 @@ /* Generic ECOFF (Extended-COFF) routines. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -72,7 +72,23 @@ static unsigned int ecoff_armap_hash PARAMS ((CONST char *s, /* This stuff is somewhat copied from coffcode.h. */ -static asection bfd_debug_section = { "*DEBUG*" }; +static asection bfd_debug_section = +{ + /* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ + "*DEBUG*", 0, 0, 0, 0, 0, 0, 0, + /* vma, lma, _cooked_size, _raw_size, output_offset, output_section, */ + 0, 0, 0, 0, 0, NULL, + /* alig, reloc..., orel..., reloc_count, filepos, rel_..., line_... */ + 0, 0, 0, 0, 0, 0, 0, + /* userdata, contents, lineno, lineno_count */ + 0, 0, 0, 0, + /* comdat_info, moving_line_filepos, target_index, used_by_bfd, */ + NULL, 0, 0, 0, + /* cons, owner, symbol */ + 0, 0, (struct symbol_cache_entry *) NULL, + /* symbol_ptr_ptr, link_order_head, ..._tail */ + (struct symbol_cache_entry **) NULL, NULL, NULL +}; /* Create an ECOFF object. */ @@ -138,7 +154,7 @@ _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr) boolean _bfd_ecoff_new_section_hook (abfd, section) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *section; { section->alignment_power = 4; @@ -349,10 +365,11 @@ ecoff_sec_to_styp_flags (name, flags) /*ARGSUSED*/ flagword -_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name) - bfd *abfd; +_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name, section) + bfd *abfd ATTRIBUTE_UNUSED; PTR hdr; - const char *name; + const char *name ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; { struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; long styp_flags = internal_s->s_flags; @@ -496,7 +513,7 @@ ecoff_slurp_symbolic_header (abfd) boolean _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) bfd *abfd; - asection *ignore; + asection *ignore ATTRIBUTE_UNUSED; struct ecoff_debug_info *debug; { const struct ecoff_backend_data * const backend = ecoff_backend (abfd); @@ -1433,7 +1450,7 @@ ecoff_type_to_string (abfd, fdr, indx) /*ARGSUSED*/ void _bfd_ecoff_get_symbol_info (abfd, symbol, ret) - bfd *abfd; /* Ignored. */ + bfd *abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -1445,7 +1462,7 @@ _bfd_ecoff_get_symbol_info (abfd, symbol, ret) /*ARGSUSED*/ boolean _bfd_ecoff_bfd_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *name; { return name[0] == '$'; @@ -1801,7 +1818,7 @@ _bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset, filename_ptr, functionname_ptr, retline_ptr) bfd *abfd; asection *section; - asymbol **ignore_symbols; + asymbol **ignore_symbols ATTRIBUTE_UNUSED; bfd_vma offset; CONST char **filename_ptr; CONST char **functionname_ptr; @@ -1971,7 +1988,7 @@ _bfd_ecoff_set_arch_mach (abfd, arch, machine) int _bfd_ecoff_sizeof_headers (abfd, reloc) bfd *abfd; - boolean reloc; + boolean reloc ATTRIBUTE_UNUSED; { asection *current; int c; @@ -3181,7 +3198,14 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) armap. */ hdr.ar_uid[0] = '0'; hdr.ar_gid[0] = '0'; +#if 0 hdr.ar_mode[0] = '0'; +#else + /* Building gcc ends up extracting the armap as a file - twice. */ + hdr.ar_mode[0] = '6'; + hdr.ar_mode[1] = '4'; + hdr.ar_mode[2] = '4'; +#endif sprintf (hdr.ar_size, "%-10d", (int) mapsize); diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index a120a2b..25fc966 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1,5 +1,5 @@ /* Routines to link ECOFF debugging information. - Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 97, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, . This file is part of BFD, the Binary File Descriptor library. @@ -491,9 +491,9 @@ add_memory_shuffle (ainfo, head, tail, data, size) /*ARGSUSED*/ PTR bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct ecoff_debug_info *output_debug; - const struct ecoff_debug_swap *output_swap; + const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED; struct bfd_link_info *info; { struct accumulate *ainfo; @@ -551,9 +551,9 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) 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; + bfd *output_bfd ATTRIBUTE_UNUSED; + struct ecoff_debug_info *output_debug ATTRIBUTE_UNUSED; + const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED; struct bfd_link_info *info; { struct accumulate *ainfo = (struct accumulate *) handle; @@ -1412,7 +1412,7 @@ bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym) /*ARGSUSED*/ static void ecoff_align_debug (abfd, debug, swap) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct ecoff_debug_info *debug; const struct ecoff_debug_swap *swap; { diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 82ffe2a..0dcecdf 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1,5 +1,6 @@ /* BFD back-end data structures for ELF files. - Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000 Free Software + Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -85,6 +86,16 @@ struct elf_link_hash_entry /* Symbol index as a dynamic symbol. Initialized to -1, and remains -1 if this is not a dynamic symbol. */ + /* ??? Note that this is consistently used as a synonym for tests + against whether we can perform various simplifying transformations + to the code. (E.g. changing a pc-relative jump to a PLT entry + into a pc-relative jump to the target function.) That test, which + is often relatively complex, and someplaces wrong or incomplete, + should really be replaced by a predicate in elflink.c. + + End result: this field -1 does not indicate that the symbol is + not in the dynamic symbol table, but rather that the symbol is + not visible outside this DSO. */ long dynindx; /* String table index in .dynstr if this is a dynamic symbol. */ @@ -146,7 +157,7 @@ struct elf_link_hash_entry /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */ char type; - /* Symbol st_other value. */ + /* Symbol st_other value, symbol visibility. */ unsigned char other; /* Hash value of the name computed using the ELF hash function. */ @@ -178,6 +189,28 @@ struct elf_link_hash_entry #define ELF_LINK_FORCED_LOCAL 02000 /* Symbol was marked during garbage collection. */ #define ELF_LINK_HASH_MARK 04000 + /* Symbol is referenced by a non-GOT/non-PLT relocation. This is + not currently set by all the backends. */ +#define ELF_LINK_NON_GOT_REF 010000 +}; + +/* Records local symbols to be emitted in the dynamic symbol table. */ + +struct elf_link_local_dynamic_entry +{ + struct elf_link_local_dynamic_entry *next; + + /* The input bfd this symbol came from. */ + bfd *input_bfd; + + /* The index of the local symbol being copied. */ + long input_indx; + + /* The index in the outgoing dynamic symbol table. */ + long dynindx; + + /* A copy of the input symbol. */ + Elf_Internal_Sym isym; }; /* ELF linker hash table. */ @@ -208,6 +241,8 @@ struct elf_link_hash_table struct elf_link_hash_entry *hgot; /* A pointer to information used to link stabs in sections. */ PTR stab_info; + /* A linked list of local symbols to be added to .dynsym. */ + struct elf_link_local_dynamic_entry *dynlocal; }; /* Look up an entry in an ELF linker hash table. */ @@ -235,6 +270,13 @@ struct elf_size_info { unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr; unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note; + /* The size of entries in the .hash section. */ + unsigned char sizeof_hash_entry; + + /* The number of internal relocations to allocate per external + relocation entry. */ + unsigned char int_rels_per_ext_rel; + unsigned char arch_size, file_align; unsigned char elfclass, ev_current; int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int)); @@ -245,6 +287,32 @@ struct elf_size_info { PARAMS ((bfd *, asection *, asymbol **, boolean)); long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean)); void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *)); + void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR)); + + /* This function, if defined, is called to swap in a REL + relocation. If an external relocation corresponds to more than + one internal relocation, then all relocations are swapped in at + once. */ + void (*swap_reloc_in) + PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *)); + + /* This function, if defined, is called to swap out a REL + relocation. */ + void (*swap_reloc_out) + PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *)); + + /* This function, if defined, is called to swap in a RELA + relocation. If an external relocation corresponds to more than + one internal relocation, then all relocations are swapped in at + once. */ + void (*swap_reloca_in) + PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *)); + + /* This function, if defined, is called to swap out a RELA + relocation. */ + void (*swap_reloca_out) + PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *)); + }; #define elf_symbol_from(ABFD,S) \ @@ -255,11 +323,6 @@ struct elf_size_info { 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; @@ -269,18 +332,6 @@ struct elf_backend_data /* 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 *, @@ -337,6 +388,12 @@ struct elf_backend_data Elf32_Internal_Shdr *, char *)); + /* A function to handle unusual program segment types when creating BFD + sections from ELF program segments. */ + boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *, + Elf32_Internal_Phdr *, + int)); + /* 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. */ @@ -515,6 +572,37 @@ struct elf_backend_data PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o, const Elf_Internal_Rela *relocs)); + /* This function, if defined, is called after the ELF headers have + been created. This allows for things like the OS and ABI versions + to be changed. */ + void (*elf_backend_post_process_headers) + PARAMS ((bfd *, struct bfd_link_info *)); + + /* This function, if defined, prints a symbol to file and returns the + name of the symbol to be printed. It should return NULL to fall + back to default symbol printing. */ + const char *(*elf_backend_print_symbol_all) + PARAMS ((bfd *, PTR, asymbol *)); + + /* This function, if defined, is called after all local symbols and + global symbols converted to locals are emited into the symtab + section. It allows the backend to emit special global symbols + not handled in the hash table. */ + boolean (*elf_backend_output_arch_syms) + PARAMS ((bfd *, struct bfd_link_info *, PTR, + boolean (*) PARAMS ((PTR, const char *, + Elf_Internal_Sym *, asection *)))); + + /* Copy any information related to dynamic linking from a pre-existing + symbol IND to a newly created symbol DIR. */ + void (*elf_backend_copy_indirect_symbol) + PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); + + /* Modify any information related to dynamic linking such that the + symbol is not exported. */ + void (*elf_backend_hide_symbol) + PARAMS ((struct elf_link_hash_entry *)); + /* 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; @@ -534,12 +622,46 @@ struct elf_backend_data bfd_vma got_header_size; bfd_vma plt_header_size; + /* 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. */ + unsigned collect : 1; + + /* 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. */ + unsigned type_change_ok : 1; + + /* Whether the backend may use REL relocations. (Some backends use + both REL and RELA relocations, and this flag is set for those + backends.) */ + unsigned may_use_rel_p : 1; + + /* Whether the backend may use RELA relocations. (Some backends use + both REL and RELA relocations, and this flag is set for those + backends.) */ + unsigned may_use_rela_p : 1; + + /* Whether the default relocation type is RELA. If a backend with + this flag set wants REL relocations for a particular section, + it must note that explicitly. Similarly, if this flag is clear, + and the backend wants RELA relocations for a particular + section. */ + unsigned default_use_rela_p : 1; + + /* True if addresses "naturally" sign extend. This is used when + swapping in from Elf32 when BFD64. */ + unsigned sign_extend_vma : 1; + 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; + unsigned want_dynbss : 1; }; /* Information stored for each BFD section in an ELF file. This @@ -555,12 +677,19 @@ struct bfd_elf_section_data /* 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 number of relocations currently assigned to REL_HDR. */ + unsigned int rel_count; + /* The number of relocations currently assigned to REL_HDR2. */ + unsigned int rel_count2; /* 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. */ + /* The ELF section number of the reloc section indicated by + REL_HDR if any. Only used for an output file. */ int rel_idx; + /* The ELF section number of the reloc section indicated by + REL_HDR2 if any. Only used for an output file. */ + int rel_idx2; /* 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; @@ -570,12 +699,15 @@ struct bfd_elf_section_data 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. */ + corresponding to this section. A value of 0 means that there is + no dynamic symbol for 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; + /* Nonzero if this section uses RELA relocations, rather than REL. */ + unsigned int use_rela_p:1; }; #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd) @@ -815,7 +947,7 @@ extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *, #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 unsigned long bfd_elf_hash PARAMS ((const char *)); extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *, arelent *, @@ -829,10 +961,16 @@ 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 boolean _bfd_elf_make_section_from_phdr + PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename)); 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 void _bfd_elf_link_hash_copy_indirect + PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); +extern void _bfd_elf_link_hash_hide_symbol + PARAMS ((struct elf_link_hash_entry *)); extern boolean _bfd_elf_link_hash_table_init PARAMS ((struct elf_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, @@ -875,6 +1013,8 @@ extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *, #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 *)); +extern boolean _bfd_elf_init_reloc_shdr + PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean)); /* If the target doesn't have reloc handling written yet: */ extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *, @@ -892,6 +1032,9 @@ 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 *)); +long +_bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *, + bfd *, long)); boolean _bfd_elf_compute_section_file_positions PARAMS ((bfd *, struct bfd_link_info *)); @@ -906,6 +1049,8 @@ boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); boolean _bfd_elf_create_got_section PARAMS ((bfd *, struct bfd_link_info *)); +unsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *, + struct bfd_link_info *)); elf_linker_section_t *_bfd_elf_create_linker_section PARAMS ((bfd *abfd, @@ -991,7 +1136,7 @@ extern void bfd_elf32_swap_phdr_out 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 *)); + PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR)); extern long bfd_elf32_slurp_symbol_table PARAMS ((bfd *, asymbol **, boolean)); extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *)); @@ -1034,7 +1179,7 @@ extern void bfd_elf64_swap_phdr_out 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 *)); + PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR)); extern long bfd_elf64_slurp_symbol_table PARAMS ((bfd *, asymbol **, boolean)); extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *)); @@ -1047,8 +1192,15 @@ extern boolean bfd_elf64_link_create_dynamic_sections 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 +#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 + +boolean _bfd_elf32_link_record_local_dynamic_symbol + PARAMS ((struct bfd_link_info *, bfd *, long)); +boolean _bfd_elf64_link_record_local_dynamic_symbol + PARAMS ((struct bfd_link_info *, bfd *, long)); extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *)); extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn @@ -1081,7 +1233,7 @@ boolean _bfd_elf64_gc_record_vtentry extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *)); extern boolean _bfd_mips_elf_section_from_shdr - PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); + PARAMS ((bfd *, Elf_Internal_Shdr *, char *)); extern boolean _bfd_mips_elf_fake_sections PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); extern boolean _bfd_mips_elf_section_from_bfd_section @@ -1110,5 +1262,48 @@ extern boolean _bfd_mips_elf_find_nearest_line const char **, unsigned int *)); extern boolean _bfd_mips_elf_set_section_contents PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); +extern boolean _bfd_mips_elf_create_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean _bfd_mips_elf_add_symbol_hook + PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + const char **, flagword *, asection **, bfd_vma *)); +extern boolean _bfd_mips_elf_adjust_dynamic_symbol + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); +extern boolean _bfd_mips_elf_finish_dynamic_symbol + PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, + Elf_Internal_Sym *)); +extern boolean _bfd_mips_elf_finish_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern asection * _bfd_mips_elf_gc_mark_hook + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + struct elf_link_hash_entry *, Elf_Internal_Sym *)); +extern boolean _bfd_mips_elf_gc_sweep_hook + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +extern boolean _bfd_mips_elf_always_size_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean _bfd_mips_elf_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean _bfd_mips_elf_check_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create + PARAMS ((bfd *)); +extern boolean _bfd_mips_elf_print_private_bfd_data + PARAMS ((bfd *, PTR)); +extern boolean _bfd_mips_elf_link_output_symbol_hook + PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *, + asection *)); +extern boolean _bfd_mips_elf_final_link + PARAMS ((bfd *, struct bfd_link_info *)); +extern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *)); +extern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *)); +extern boolean _bfd_mips_elf_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); + +/* SH ELF specific routine. */ + +extern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *)); #endif /* _LIBELF_H_ */ diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h new file mode 100644 index 0000000..b55e1c4 --- /dev/null +++ b/bfd/elf-hppa.h @@ -0,0 +1,1884 @@ +/* Common code for PA ELF implementations. + 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. */ + +#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1 + +/* This file is included by multiple PA ELF BFD backends with different + sizes. + + Most of the routines are written to be size independent, but sometimes + external constraints require 32 or 64 bit specific code. We remap + the definitions/functions as necessary here. */ +#if ARCH_SIZE == 64 +#define ELF_R_TYPE(X) ELF64_R_TYPE(X) +#define ELF_R_SYM(X) ELF64_R_SYM(X) +#define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type +#define elf_hppa_relocate_section elf64_hppa_relocate_section +#define bfd_elf_bfd_final_link bfd_elf64_bfd_final_link +#define elf_hppa_final_link elf64_hppa_final_link +#endif +#if ARCH_SIZE == 32 +#define ELF_R_TYPE(X) ELF32_R_TYPE(X) +#define ELF_R_SYM(X) ELF32_R_SYM(X) +#define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type +#define elf_hppa_relocate_section elf32_hppa_relocate_section +#define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link +#define elf_hppa_final_link elf32_hppa_final_link +#endif + +static boolean +elf_hppa_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, + bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); + +static bfd_reloc_status_type elf_hppa_final_link_relocate + PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *, + bfd_byte *, bfd_vma, struct bfd_link_info *, + asection *, struct elf_link_hash_entry *, + struct elf64_hppa_dyn_hash_entry *)); + +static unsigned long elf_hppa_relocate_insn + PARAMS ((unsigned long, long, unsigned long)); + +static boolean elf_hppa_add_symbol_hook + PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + const char **, flagword *, asection **, bfd_vma *)); + +static boolean elf_hppa_final_link + PARAMS ((bfd *, struct bfd_link_info *)); + +static boolean elf_hppa_unmark_useless_dynamic_symbols + PARAMS ((struct elf_link_hash_entry *, PTR)); + +static boolean elf_hppa_remark_useless_dynamic_symbols + PARAMS ((struct elf_link_hash_entry *, PTR)); + +static void elf_hppa_record_segment_addrs + PARAMS ((bfd *, asection *, PTR)); + +/* 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, bfd_elf_generic_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, bfd_elf_generic_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false}, + {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR21L"}, + {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17R"}, + {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14R"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_PCREL32, 0, 0, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL32"}, + + {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL21L"}, + {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17R"}, + {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17F"}, + {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17C"}, + {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14R"}, + {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL21L"}, + {R_PARISC_DPREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14WR"}, + + {R_PARISC_DPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14DR"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14R"}, + {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14R"}, + {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14R"}, + {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14F"}, + + {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SETBASE"}, + {R_PARISC_SECREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SECREL32"}, + {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL21L"}, + {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17R"}, + {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14R"}, + {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14F"}, + {R_PARISC_SEGBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGBASE"}, + {R_PARISC_SEGREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL32"}, + + {R_PARISC_PLTOFF21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_PLTOFF14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R"}, + {R_PARISC_PLTOFF14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_FPTR32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32"}, + {R_PARISC_LTOFF_FPTR21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_FPTR14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_FPTR64"}, + {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL32"}, + {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL14R"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_PCREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL64"}, + {R_PARISC_PCREL22C, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22C"}, + {R_PARISC_PCREL22F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22F"}, + {R_PARISC_PCREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14WR"}, + {R_PARISC_PCREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14DR"}, + {R_PARISC_PCREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16F"}, + {R_PARISC_PCREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16WF"}, + {R_PARISC_PCREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16DF"}, + + {R_PARISC_DIR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR64"}, + {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"}, + {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"}, + {R_PARISC_DIR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14WR"}, + {R_PARISC_DIR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14DR"}, + {R_PARISC_DIR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16F"}, + {R_PARISC_DIR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16WF"}, + {R_PARISC_DIR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16DF"}, + {R_PARISC_GPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL64"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DLTREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR"}, + {R_PARISC_DLTREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR"}, + {R_PARISC_GPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16F"}, + {R_PARISC_GPREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16WF"}, + {R_PARISC_GPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16DF"}, + {R_PARISC_LTOFF64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF64"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_DLTIND14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR"}, + + {R_PARISC_DLTIND14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR"}, + {R_PARISC_LTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16F"}, + {R_PARISC_LTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"}, + {R_PARISC_LTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_BASEREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BSEREL14WR"}, + {R_PARISC_BASEREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_SEGREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL64"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_PLTOFF14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR"}, + {R_PARISC_PLTOFF14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR"}, + {R_PARISC_PLTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F"}, + {R_PARISC_PLTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF"}, + {R_PARISC_PLTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF"}, + + {R_PARISC_LTOFF_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_FPTR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR"}, + {R_PARISC_LTOFF_FPTR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR"}, + {R_PARISC_LTOFF_FPTR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F"}, + {R_PARISC_LTOFF_FPTR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF"}, + {R_PARISC_LTOFF_FPTR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_COPY"}, + {R_PARISC_IPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_IPLT"}, + + {R_PARISC_EPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_EPLT"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_TPREL32, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL32"}, + {R_PARISC_TPREL21L, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_TPREL14R, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14R"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_TP21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_TP14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_TP14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_TPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL64"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_TPREL14WR, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14WR"}, + + {R_PARISC_TPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL14DR"}, + {R_PARISC_TPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16F"}, + {R_PARISC_TPREL16WF, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL16WF"}, + {R_PARISC_TPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16DF"}, + {R_PARISC_LTOFF_TP64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"}, + {R_PARISC_LTOFF_TP14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR"}, + {R_PARISC_LTOFF_TP14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR"}, + {R_PARISC_LTOFF_TP16F, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_LTOFF_TP16F"}, + + {R_PARISC_LTOFF_TP16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF"}, + {R_PARISC_LTOFF_TP16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF"}, +}; + +#define OFFSET_14R_FROM_21L 4 +#define OFFSET_14F_FROM_21L 5 + +/* Return one (or more) BFD relocations which implement the base + relocation with modifications based on format and field. */ + +elf_hppa_reloc_type ** +_bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym) + bfd *abfd; + elf_hppa_reloc_type base_type; + int format; + int field; + int ignore; + asymbol *sym; +{ + elf_hppa_reloc_type *finaltype; + elf_hppa_reloc_type **final_types; + + /* Allocate slots for the BFD relocation. */ + final_types = ((elf_hppa_reloc_type **) + bfd_alloc (abfd, sizeof (elf_hppa_reloc_type *) * 2)); + if (final_types == NULL) + return NULL; + + /* Allocate space for the relocation itself. */ + finaltype = ((elf_hppa_reloc_type *) + bfd_alloc (abfd, sizeof (elf_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) + { + /* We have been using generic relocation types. However, that may not + really make sense. Anyway, we need to support both R_PARISC_DIR64 + and R_PARISC_DIR32 here. */ + case R_PARISC_DIR32: + case R_PARISC_DIR64: + 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_DLTIND14R; + break; + case e_rtpsel: + final_type = R_PARISC_LTOFF_FPTR14DR; + break; + case e_tsel: + final_type = R_PARISC_DLTIND14F; + 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_DLTIND21L; + break; + case e_ltpsel: + final_type = R_PARISC_LTOFF_FPTR21L; + 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; + /* When in 64bit mode, a 32bit relocation is supposed to + be a section relative relocation. Dwarf2 (for example) + uses 32bit section relative relocations. */ + if (bfd_get_arch_info (abfd)->bits_per_address != 32) + final_type = R_PARISC_SECREL32; + break; + case e_psel: + final_type = R_PARISC_PLABEL32; + break; + default: + return NULL; + } + break; + + case 64: + switch (field) + { + case e_fsel: + final_type = R_PARISC_DIR64; + break; + case e_psel: + final_type = R_PARISC_FPTR64; + 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 = base_type + OFFSET_14R_FROM_21L; + break; + case e_fsel: + final_type = base_type + OFFSET_14F_FROM_21L; + break; + default: + return NULL; + } + break; + + case 21: + switch (field) + { + case e_lrsel: + case e_lsel: + final_type = base_type; + 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 22: + switch (field) + { + case e_fsel: + final_type = R_PARISC_PCREL22F; + 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; + + case R_PARISC_SEGREL32: + case R_PARISC_SEGBASE: + /* The defaults are fine for these cases. */ + break; + + default: + return NULL; + } + + return final_types; +} + +/* Translate from an elf into field into a howto relocation pointer. */ + +static void +elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc) + bfd *abfd; + arelent *bfd_reloc; + Elf_Internal_Rela *elf_reloc; +{ + BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info) + < (unsigned int) R_PARISC_UNIMPLEMENTED); + bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)]; +} + +/* Translate from an elf into field into a howto relocation pointer. */ + +static void +elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) + bfd *abfd; + arelent *bfd_reloc; + Elf_Internal_Rel *elf_reloc; +{ + BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info) + < (unsigned int) R_PARISC_UNIMPLEMENTED); + bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)]; +} + +/* 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; +} + +static void +elf_hppa_final_write_processing (abfd, linker) + bfd *abfd; + boolean linker; +{ + int mach = bfd_get_mach (abfd); + + elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL + | EF_PARISC_EXT | EF_PARISC_LSB + | EF_PARISC_WIDE | EF_PARISC_NO_KABP + | EF_PARISC_LAZYSWAP); + + if (mach == 10) + elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0; + else if (mach == 11) + elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1; + else if (mach == 20) + elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0; + else if (mach == 25) + elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE + | EFA_PARISC_2_0 + /* The GNU tools have trapped without + option since 1993, so need to take + a step backwards with the ELF + based toolchains. */ + | EF_PARISC_TRAPNIL); +} + +/* Return true if SYM represents a local label symbol. */ + +static boolean +elf_hppa_is_local_label_name (abfd, name) + bfd *abfd ATTRIBUTE_UNUSED; + const char *name; +{ + return (name[0] == 'L' && name[1] == '$'); +} + +/* Set the correct type for an ELF section. We do this by the + section name, which is a hack, but ought to work. */ + +static boolean +elf_hppa_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, ".PARISC.unwind") == 0) + { + int indx; + asection *sec; + hdr->sh_type = SHT_LOPROC + 1; + /* ?!? How are unwinds supposed to work for symbols in arbitrary + sections? Or what if we have multiple .text sections in a single + .o file? HP really messed up on this one. + + Ugh. We can not use elf_section_data (sec)->this_idx at this + point because it is not initialized yet. + + So we (gasp) recompute it here. Hopefully nobody ever changes the + way sections are numbered in elf.c! */ + for (sec = abfd->sections, indx = 1; sec; sec = sec->next, indx++) + { + if (sec->name && strcmp (sec->name, ".text") == 0) + { + hdr->sh_info = indx; + break; + } + } + + /* I have no idea if this is really necessary or what it means. */ + hdr->sh_entsize = 4; + } + return true; +} + +/* Hook called by the linker routine which adds symbols from an object + file. HP's libraries define symbols with HP specific section + indices, which we have to handle. */ + +static boolean +elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) + bfd *abfd; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + const Elf_Internal_Sym *sym; + const char **namep ATTRIBUTE_UNUSED; + flagword *flagsp ATTRIBUTE_UNUSED; + asection **secp; + bfd_vma *valp; +{ + int index = sym->st_shndx; + + switch (index) + { + case SHN_PARISC_ANSI_COMMON: + *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common"); + (*secp)->flags |= SEC_IS_COMMON; + *valp = sym->st_size; + break; + + case SHN_PARISC_HUGE_COMMON: + *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common"); + (*secp)->flags |= SEC_IS_COMMON; + *valp = sym->st_size; + break; + } + + return true; +} + +static boolean +elf_hppa_unmark_useless_dynamic_symbols (h, data) + struct elf_link_hash_entry *h; + PTR data; +{ + struct bfd_link_info *info = (struct bfd_link_info *)data; + + /* If we are not creating a shared library, and this symbol is + referenced by a shared library but is not defined anywhere, then + the generic code will warn that it is undefined. + + This behavior is undesirable on HPs since the standard shared + libraries contain reerences to undefined symbols. + + So we twiddle the flags associated with such symbols so that they + will not trigger the warning. ?!? FIXME. This is horribly fraglie. + + Ultimately we should have better controls over the generic ELF BFD + linker code. */ + if (! info->relocateable + && ! (info->shared + && !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) + { + h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC; + h->elf_link_hash_flags |= 0x8000; + } + + return true; +} + + +static boolean +elf_hppa_remark_useless_dynamic_symbols (h, data) + struct elf_link_hash_entry *h; + PTR data; +{ + struct bfd_link_info *info = (struct bfd_link_info *)data; + + /* If we are not creating a shared library, and this symbol is + referenced by a shared library but is not defined anywhere, then + the generic code will warn that it is undefined. + + This behavior is undesirable on HPs since the standard shared + libraries contain reerences to undefined symbols. + + So we twiddle the flags associated with such symbols so that they + will not trigger the warning. ?!? FIXME. This is horribly fragile. + + Ultimately we should have better controls over the generic ELF BFD + linker code. */ + if (! info->relocateable + && ! (info->shared + && !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 + && (h->elf_link_hash_flags & 0x8000) != 0) + { + h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC; + h->elf_link_hash_flags &= ~0x8000; + } + + return true; +} + +/* Record the lowest address for the data and text segments. */ +static void +elf_hppa_record_segment_addrs (abfd, section, data) + bfd *abfd ATTRIBUTE_UNUSED; + asection *section; + PTR data; +{ + struct elf64_hppa_link_hash_table *hppa_info; + bfd_vma value; + + hppa_info = (struct elf64_hppa_link_hash_table *)data; + + value = section->vma - section->filepos; + + if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY) + == (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) + && value < hppa_info->text_segment_base) + hppa_info->text_segment_base = value; + else if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY) + == (SEC_ALLOC | SEC_LOAD)) + && value < hppa_info->data_segment_base) + hppa_info->data_segment_base = value; +} + +/* Called after we have seen all the input files/sections, but before + final symbol resolution and section placement has been determined. + + We use this hook to (possibly) provide a value for __gp, then we + fall back to the generic ELF final link routine. */ + +static boolean +elf_hppa_final_link (abfd, info) + bfd *abfd; + struct bfd_link_info *info; +{ + boolean retval; + + if (! info->relocateable) + { + struct elf_link_hash_entry *gp; + bfd_vma gp_val; + struct elf64_hppa_link_hash_table *hppa_info; + + hppa_info = elf64_hppa_hash_table (info); + + /* The linker script defines a value for __gp iff it was referenced + by one of the objects being linked. First try to find the symbol + in the hash table. If that fails, just compute the value __gp + should have had. */ + gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false, + false, false); + + if (gp) + { + + /* Adjust the value of __gp as we may want to slide it into the + .plt section so that the stubs can access PLT entries without + using an addil sequence. */ + gp->root.u.def.value += elf64_hppa_hash_table (info)->gp_offset; + + gp_val = (gp->root.u.def.section->output_section->vma + + gp->root.u.def.section->output_offset + + gp->root.u.def.value); + } + else + { + asection *sec; + + + /* First look for a .plt section. If found, then __gp is the + address of the .plt + gp_offset. + + If no .plt is found, then look for .dlt, .opd and .data (in + that order) and set __gp to the base address of whichever section + is found first. */ + + sec = hppa_info->plt_sec; + if (sec) + gp_val = (sec->output_offset + + sec->output_section->vma + + hppa_info->gp_offset); + else + { + sec = hppa_info->dlt_sec; + if (!sec) + sec = hppa_info->opd_sec; + if (!sec) + sec = bfd_get_section_by_name (abfd, ".data"); + if (!sec) + return false; + + gp_val = sec->output_offset + sec->output_section->vma; + } + } + + /* Install whatever value we found/computed for __gp. */ + _bfd_set_gp_value (abfd, gp_val); + } + + /* We need to know the base of the text and data segments so that we + can perform SEGREL relocations. We will recore the base addresses + when we encounter the first SEGREL relocation. */ + elf64_hppa_hash_table (info)->text_segment_base = (bfd_vma)-1; + elf64_hppa_hash_table (info)->data_segment_base = (bfd_vma)-1; + + /* HP's shared libraries have references to symbols that are not + defined anywhere. The generic ELF BFD linker code will complaim + about such symbols. + + So we detect the losing case and arrange for the flags on the symbol + to indicate that it was never referenced. This keeps the generic + ELF BFD link code happy and appears to not create any secondary + problems. Ultimately we need a way to control the behavior of the + generic ELF BFD link code better. */ + elf_link_hash_traverse (elf_hash_table (info), + elf_hppa_unmark_useless_dynamic_symbols, + info); + + /* Invoke the regular ELF backend linker to do all the work. */ + retval = bfd_elf_bfd_final_link (abfd, info); + + elf_link_hash_traverse (elf_hash_table (info), + elf_hppa_remark_useless_dynamic_symbols, + info); + + return retval; +} + +/* Relocate an HPPA ELF section. */ + +static boolean +elf_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; + struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info); + + 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 = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info); + 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; + char *dyn_name; + char *dynh_buf = NULL; + size_t dynh_buflen = 0; + struct elf64_hppa_dyn_hash_entry *dyn_h = NULL; + + r_type = ELF_R_TYPE (rel->r_info); + if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED) + { + bfd_set_error (bfd_error_bad_value); + return false; + } + + r_symndx = ELF_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) + { + /* This is a local symbol. */ + 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); + + /* If this symbol has an entry in the PA64 dynamic hash + table, then get it. */ + dyn_name = get_dyn_name (input_bfd, h, rel, + &dynh_buf, &dynh_buflen); + dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, + dyn_name, false, false); + + } + else + { + /* This is not a local symbol. */ + 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; + + /* If this symbol has an entry in the PA64 dynamic hash + table, then get it. */ + dyn_name = get_dyn_name (input_bfd, h, rel, + &dynh_buf, &dynh_buflen); + dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, + dyn_name, false, false); + + /* If we have a relocation against a symbol defined in a + shared library and we have not created an entry in the + PA64 dynamic symbol hash table for it, then we lose. */ + if (sym_sec->output_section == NULL && dyn_h == 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 (sym_sec->output_section) + relocation = (h->root.u.def.value + + sym_sec->output_offset + + sym_sec->output_section->vma); + /* Value will be provided via one of the offsets in the + dyn_h hash table entry. */ + else + relocation = 0; + } + /* Allow undefined symbols in shared libraries. */ + else if (info->shared && !info->no_undefined) + { + if (info->symbolic) + (*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset, false); + + /* If this symbol has an entry in the PA64 dynamic hash + table, then get it. */ + dyn_name = get_dyn_name (input_bfd, h, rel, + &dynh_buf, &dynh_buflen); + dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, + dyn_name, false, false); + + if (dyn_h == 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; + } + 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, true))) + 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); + } + + r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, + input_section, contents, + relocation, info, sym_sec, + h, dyn_h); + + if (r != bfd_reloc_ok) + { + switch (r) + { + default: + abort (); + 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; +} + + +/* Compute the value for a relocation (REL) during a final link stage, + then insert the value into the proper location in CONTENTS. + + VALUE is a tentative value for the relocation and may be overridden + and modified here based on the specific relocation to be performed. + + For example we do conversions for PC-relative branches in this routine + or redirection of calls to external routines to stubs. + + The work of actually applying the relocation is left to a helper + routine in an attempt to reduce the complexity and size of this + function. */ + +static bfd_reloc_status_type +elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, + input_section, contents, value, + info, sym_sec, h, dyn_h) + Elf_Internal_Rela *rel; + bfd *input_bfd; + bfd *output_bfd; + asection *input_section; + bfd_byte *contents; + bfd_vma value; + struct bfd_link_info *info; + asection *sym_sec; + struct elf_link_hash_entry *h; + struct elf64_hppa_dyn_hash_entry *dyn_h; +{ + unsigned long insn; + bfd_vma offset = rel->r_offset; + bfd_vma addend = rel->r_addend; + reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info); + unsigned long r_type = howto->type; + unsigned long r_field = e_fsel; + bfd_byte *hit_data = contents + offset; + struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info); + + insn = bfd_get_32 (input_bfd, hit_data); + + switch (r_type) + { + case R_PARISC_NONE: + break; + + /* Random PC relative relocs. */ + case R_PARISC_PCREL21L: + case R_PARISC_PCREL14R: + case R_PARISC_PCREL14F: + case R_PARISC_PCREL14WR: + case R_PARISC_PCREL14DR: + case R_PARISC_PCREL16F: + case R_PARISC_PCREL16WF: + case R_PARISC_PCREL16DF: + { + if (r_type == R_PARISC_PCREL21L) + r_field = e_lsel; + else if (r_type == R_PARISC_PCREL14F + || r_type == R_PARISC_PCREL16F + || r_type == R_PARISC_PCREL16WF + || r_type == R_PARISC_PCREL16DF) + r_field = e_fsel; + else + r_field = e_rsel; + + /* If this is a call to a function defined in another dynamic + library, then redirect the call to the local stub for this + function. */ + if (sym_sec == NULL || sym_sec->output_section == NULL) + value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset + + hppa_info->stub_sec->output_section->vma); + + /* Turn VALUE into a proper PC relative address. */ + value -= (offset + input_section->output_offset + + input_section->output_section->vma); + + /* Adjust for any field selectors. */ + value = hppa_field_adjust (value, -8 + addend, r_field); + + /* Apply the relocation to the given instruction. */ + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + /* Basic function call support. I'm not entirely sure if PCREL14F is + actually needed or even handled correctly. + + Note for a call to a function defined in another dynamic library + we want to redirect the call to a stub. */ + case R_PARISC_PCREL22F: + case R_PARISC_PCREL17F: + case R_PARISC_PCREL22C: + case R_PARISC_PCREL17C: + case R_PARISC_PCREL17R: + { + if (r_type == R_PARISC_PCREL17R) + r_field = e_rsel; + else + r_field = e_fsel; + + /* If this is a call to a function defined in another dynamic + library, then redirect the call to the local stub for this + function. */ + if (sym_sec == NULL || sym_sec->output_section == NULL) + value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset + + hppa_info->stub_sec->output_section->vma); + + /* Turn VALUE into a proper PC relative address. */ + value -= (offset + input_section->output_offset + + input_section->output_section->vma); + + /* Adjust for any field selectors. */ + value = hppa_field_adjust (value, -8 + addend, e_fsel); + + /* All branches are implicitly shifted by 2 places. */ + value >>= 2; + + /* Apply the relocation to the given instruction. */ + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + /* Indirect references to data through the DLT. */ + case R_PARISC_DLTIND14R: + case R_PARISC_DLTIND14F: + case R_PARISC_DLTIND14DR: + case R_PARISC_DLTIND14WR: + case R_PARISC_DLTIND21L: + case R_PARISC_LTOFF_FPTR14R: + case R_PARISC_LTOFF_FPTR14DR: + case R_PARISC_LTOFF_FPTR14WR: + case R_PARISC_LTOFF_FPTR21L: + case R_PARISC_LTOFF_FPTR16F: + case R_PARISC_LTOFF_FPTR16WF: + case R_PARISC_LTOFF_FPTR16DF: + case R_PARISC_LTOFF_TP21L: + case R_PARISC_LTOFF_TP14R: + case R_PARISC_LTOFF_TP14F: + case R_PARISC_LTOFF_TP14WR: + case R_PARISC_LTOFF_TP14DR: + case R_PARISC_LTOFF_TP16F: + case R_PARISC_LTOFF_TP16WF: + case R_PARISC_LTOFF_TP16DF: + case R_PARISC_LTOFF16F: + case R_PARISC_LTOFF16WF: + case R_PARISC_LTOFF16DF: + { + /* If this relocation was against a local symbol, then we still + have not set up the DLT entry (it's not convienent to do so + in the "finalize_dlt" routine because it is difficult to get + to the local symbol's value). + + So, if this is a local symbol (h == NULL), then we need to + fill in its DLT entry. + + Similarly we may still need to set up an entry in .opd for + a local function which had its address taken. */ + if (dyn_h->h == NULL) + { + bfd_put_64 (hppa_info->dlt_sec->owner, + value, + hppa_info->dlt_sec->contents + dyn_h->dlt_offset); + + /* Now handle .opd creation if needed. */ + if (r_type == R_PARISC_LTOFF_FPTR14R + || r_type == R_PARISC_LTOFF_FPTR14DR + || r_type == R_PARISC_LTOFF_FPTR14WR + || r_type == R_PARISC_LTOFF_FPTR21L + || r_type == R_PARISC_LTOFF_FPTR16F + || r_type == R_PARISC_LTOFF_FPTR16WF + || r_type == R_PARISC_LTOFF_FPTR16DF) + { + /* The first two words of an .opd entry are zero. */ + memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, + 0, 16); + + /* The next word is the address of the function. */ + bfd_put_64 (hppa_info->opd_sec->owner, value, + (hppa_info->opd_sec->contents + + dyn_h->opd_offset + 16)); + + /* The last word is our local __gp value. */ + value = _bfd_get_gp_value + (hppa_info->opd_sec->output_section->owner); + bfd_put_64 (hppa_info->opd_sec->owner, value, + (hppa_info->opd_sec->contents + + dyn_h->opd_offset + 24)); + } + } + + /* We want the value of the DLT offset for this symbol, not + the symbol's actual address. Note that __gp may not point + to the start of the DLT, so we have to compute the absolute + address, then subtract out the value of __gp. */ + value = (dyn_h->dlt_offset + + hppa_info->dlt_sec->output_offset + + hppa_info->dlt_sec->output_section->vma); + value -= _bfd_get_gp_value (output_bfd); + + + /* All DLTIND relocations are basically the same at this point, + except that we need different field selectors for the 21bit + version vs the 14bit versions. */ + if (r_type == R_PARISC_DLTIND21L + || r_type == R_PARISC_LTOFF_FPTR21L + || r_type == R_PARISC_LTOFF_TP21L) + value = hppa_field_adjust (value, addend, e_lrsel); + else if (r_type == R_PARISC_DLTIND14F + || r_type == R_PARISC_LTOFF_FPTR16F + || r_type == R_PARISC_LTOFF_FPTR16WF + || r_type == R_PARISC_LTOFF_FPTR16DF + || r_type == R_PARISC_LTOFF16F + || r_type == R_PARISC_LTOFF16DF + || r_type == R_PARISC_LTOFF16WF + || r_type == R_PARISC_LTOFF_TP16F + || r_type == R_PARISC_LTOFF_TP16WF + || r_type == R_PARISC_LTOFF_TP16DF) + value = hppa_field_adjust (value, addend, e_fsel); + else + value = hppa_field_adjust (value, addend, e_rrsel); + + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + case R_PARISC_DLTREL14R: + case R_PARISC_DLTREL14F: + case R_PARISC_DLTREL14DR: + case R_PARISC_DLTREL14WR: + case R_PARISC_DLTREL21L: + case R_PARISC_DPREL21L: + case R_PARISC_DPREL14WR: + case R_PARISC_DPREL14DR: + case R_PARISC_DPREL14R: + case R_PARISC_DPREL14F: + case R_PARISC_GPREL16F: + case R_PARISC_GPREL16WF: + case R_PARISC_GPREL16DF: + { + /* Subtract out the global pointer value to make value a DLT + relative address. */ + value -= _bfd_get_gp_value (output_bfd); + + /* All DLTREL relocations are basically the same at this point, + except that we need different field selectors for the 21bit + version vs the 14bit versions. */ + if (r_type == R_PARISC_DLTREL21L + || r_type == R_PARISC_DPREL21L) + value = hppa_field_adjust (value, addend, e_lrsel); + else if (r_type == R_PARISC_DLTREL14F + || r_type == R_PARISC_DPREL14F + || r_type == R_PARISC_GPREL16F + || r_type == R_PARISC_GPREL16WF + || r_type == R_PARISC_GPREL16DF) + value = hppa_field_adjust (value, addend, e_fsel); + else + value = hppa_field_adjust (value, addend, e_rrsel); + + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + case R_PARISC_DIR21L: + case R_PARISC_DIR17R: + case R_PARISC_DIR17F: + case R_PARISC_DIR14R: + case R_PARISC_DIR14WR: + case R_PARISC_DIR14DR: + case R_PARISC_DIR16F: + case R_PARISC_DIR16WF: + case R_PARISC_DIR16DF: + { + /* All DIR relocations are basically the same at this point, + except that we need different field selectors for the 21bit + version vs the 14bit versions. */ + if (r_type == R_PARISC_DIR21L) + value = hppa_field_adjust (value, addend, e_lrsel); + else if (r_type == R_PARISC_DIR17F + || r_type == R_PARISC_DIR16F + || r_type == R_PARISC_DIR16WF + || r_type == R_PARISC_DIR16DF) + value = hppa_field_adjust (value, addend, e_fsel); + else + value = hppa_field_adjust (value, addend, e_rrsel); + + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + case R_PARISC_PLTOFF21L: + case R_PARISC_PLTOFF14R: + case R_PARISC_PLTOFF14F: + case R_PARISC_PLTOFF14WR: + case R_PARISC_PLTOFF14DR: + case R_PARISC_PLTOFF16F: + case R_PARISC_PLTOFF16WF: + case R_PARISC_PLTOFF16DF: + { + /* We want the value of the PLT offset for this symbol, not + the symbol's actual address. Note that __gp may not point + to the start of the DLT, so we have to compute the absolute + address, then subtract out the value of __gp. */ + value = (dyn_h->plt_offset + + hppa_info->plt_sec->output_offset + + hppa_info->plt_sec->output_section->vma); + value -= _bfd_get_gp_value (output_bfd); + + /* All PLTOFF relocations are basically the same at this point, + except that we need different field selectors for the 21bit + version vs the 14bit versions. */ + if (r_type == R_PARISC_PLTOFF21L) + value = hppa_field_adjust (value, addend, e_lrsel); + else if (r_type == R_PARISC_PLTOFF14F + || r_type == R_PARISC_PLTOFF16F + || r_type == R_PARISC_PLTOFF16WF + || r_type == R_PARISC_PLTOFF16DF) + value = hppa_field_adjust (value, addend, e_fsel); + else + value = hppa_field_adjust (value, addend, e_rrsel); + + insn = elf_hppa_relocate_insn (insn, value, r_type); + break; + } + + case R_PARISC_LTOFF_FPTR32: + { + /* We may still need to create the FPTR itself if it was for + a local symbol. */ + if (dyn_h->h == NULL) + { + /* The first two words of an .opd entry are zero. */ + memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16); + + /* The next word is the address of the function. */ + bfd_put_64 (hppa_info->opd_sec->owner, value, + (hppa_info->opd_sec->contents + + dyn_h->opd_offset + 16)); + + /* The last word is our local __gp value. */ + value = _bfd_get_gp_value + (hppa_info->opd_sec->output_section->owner); + bfd_put_64 (hppa_info->opd_sec->owner, value, + hppa_info->opd_sec->contents + dyn_h->opd_offset + 24); + } + + /* We want the value of the DLT offset for this symbol, not + the symbol's actual address. Note that __gp may not point + to the start of the DLT, so we have to compute the absolute + address, then subtract out the value of __gp. */ + value = (dyn_h->dlt_offset + + hppa_info->dlt_sec->output_offset + + hppa_info->dlt_sec->output_section->vma); + value -= _bfd_get_gp_value (output_bfd); + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + } + + case R_PARISC_LTOFF_FPTR64: + case R_PARISC_LTOFF_TP64: + { + /* We may still need to create the FPTR itself if it was for + a local symbol. */ + if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64) + { + /* The first two words of an .opd entry are zero. */ + memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16); + + /* The next word is the address of the function. */ + bfd_put_64 (hppa_info->opd_sec->owner, value, + (hppa_info->opd_sec->contents + + dyn_h->opd_offset + 16)); + + /* The last word is our local __gp value. */ + value = _bfd_get_gp_value + (hppa_info->opd_sec->output_section->owner); + bfd_put_64 (hppa_info->opd_sec->owner, value, + hppa_info->opd_sec->contents + dyn_h->opd_offset + 24); + } + + /* We want the value of the DLT offset for this symbol, not + the symbol's actual address. Note that __gp may not point + to the start of the DLT, so we have to compute the absolute + address, then subtract out the value of __gp. */ + value = (dyn_h->dlt_offset + + hppa_info->dlt_sec->output_offset + + hppa_info->dlt_sec->output_section->vma); + value -= _bfd_get_gp_value (output_bfd); + bfd_put_64 (input_bfd, value, hit_data); + return bfd_reloc_ok; + } + + case R_PARISC_DIR32: + bfd_put_32 (input_bfd, value + addend, hit_data); + return bfd_reloc_ok; + + case R_PARISC_DIR64: + bfd_put_64 (input_bfd, value + addend, hit_data); + return bfd_reloc_ok; + + case R_PARISC_GPREL64: + /* Subtract out the global pointer value to make value a DLT + relative address. */ + value -= _bfd_get_gp_value (output_bfd); + value += addend; + + bfd_put_64 (input_bfd, value + addend, hit_data); + return bfd_reloc_ok; + + case R_PARISC_LTOFF64: + /* We want the value of the DLT offset for this symbol, not + the symbol's actual address. Note that __gp may not point + to the start of the DLT, so we have to compute the absolute + address, then subtract out the value of __gp. */ + value = (dyn_h->dlt_offset + + hppa_info->dlt_sec->output_offset + + hppa_info->dlt_sec->output_section->vma); + value -= _bfd_get_gp_value (output_bfd); + + bfd_put_64 (input_bfd, value + addend, hit_data); + return bfd_reloc_ok; + + case R_PARISC_PCREL32: + { + /* If this is a call to a function defined in another dynamic + library, then redirect the call to the local stub for this + function. */ + if (sym_sec == NULL || sym_sec->output_section == NULL) + value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset + + hppa_info->stub_sec->output_section->vma); + + /* Turn VALUE into a proper PC relative address. */ + value -= (offset + input_section->output_offset + + input_section->output_section->vma); + + value += addend; + value -= 8; + bfd_put_64 (input_bfd, value, hit_data); + return bfd_reloc_ok; + } + + case R_PARISC_PCREL64: + { + /* If this is a call to a function defined in another dynamic + library, then redirect the call to the local stub for this + function. */ + if (sym_sec == NULL || sym_sec->output_section == NULL) + value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset + + hppa_info->stub_sec->output_section->vma); + + + /* Turn VALUE into a proper PC relative address. */ + value -= (offset + input_section->output_offset + + input_section->output_section->vma); + + value += addend; + value -= 8; + bfd_put_64 (input_bfd, value, hit_data); + return bfd_reloc_ok; + } + + + case R_PARISC_FPTR64: + { + /* We may still need to create the FPTR itself if it was for + a local symbol. */ + if (dyn_h->h == NULL) + { + /* The first two words of an .opd entry are zero. */ + memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16); + + /* The next word is the address of the function. */ + bfd_put_64 (hppa_info->opd_sec->owner, value, + (hppa_info->opd_sec->contents + + dyn_h->opd_offset + 16)); + + /* The last word is our local __gp value. */ + value = _bfd_get_gp_value + (hppa_info->opd_sec->output_section->owner); + bfd_put_64 (hppa_info->opd_sec->owner, value, + hppa_info->opd_sec->contents + dyn_h->opd_offset + 24); + } + + /* We want the value of the OPD offset for this symbol, not + the symbol's actual address. */ + value = (dyn_h->opd_offset + + hppa_info->opd_sec->output_offset + + hppa_info->opd_sec->output_section->vma); + + bfd_put_64 (input_bfd, value + addend, hit_data); + return bfd_reloc_ok; + } + + case R_PARISC_SECREL32: + bfd_put_32 (input_bfd, + (value + addend + - sym_sec->output_section->vma), + hit_data); + return bfd_reloc_ok; + + case R_PARISC_SEGREL32: + case R_PARISC_SEGREL64: + { + /* If this is the first SEGREL relocation, then initialize + the segment base values. */ + if (hppa_info->text_segment_base == (bfd_vma) -1) + bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs, + elf64_hppa_hash_table (info)); + + /* VALUE holds the absolute address. We want to include the + addend, then turn it into a segment relative address. + + The segment is derived from SYM_SEC. We assume that there are + only two segments of note in the resulting executable/shlib. + A readonly segment (.text) and a readwrite segment (.data). */ + value += addend; + + if (sym_sec->flags & SEC_CODE) + value -= hppa_info->text_segment_base; + else + value -= hppa_info->data_segment_base; + + if (r_type == R_PARISC_SEGREL32) + bfd_put_32 (input_bfd, value, hit_data); + else + bfd_put_64 (input_bfd, value, hit_data); + return bfd_reloc_ok; + } + + + /* 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); +} + +/* Relocate the given INSN. VALUE should be the actual value we want + to insert into the instruction, ie by this point we should not be + concerned with computing an offset relative to the DLT, PC, etc. + Instead this routine is meant to handle the bit manipulations needed + to insert the relocation into the given instruction. */ + +static unsigned long +elf_hppa_relocate_insn (insn, sym_value, r_type) + unsigned long insn; + long sym_value; + unsigned long r_type; +{ + switch (r_type) + { + /* This is any 22bit branch. In PA2.0 syntax it corresponds to + the "B" instruction. */ + case R_PARISC_PCREL22F: + case R_PARISC_PCREL22C: + { + unsigned int w3, w2, w1, w; + + /* These are 22 bit branches. Mask off bits we do not care + about. */ + sym_value &= 0x3fffff; + + /* Now extract the W1, W2, W3 and W fields from the value. */ + dis_assemble_22 (sym_value, &w3, &w1, &w2, &w); + + /* Mask out bits for the value in the instruction. */ + insn &= 0xfc00e002; + + /* Insert the bits for the W1, W2 and W fields into the + instruction. */ + insn |= (w3 << 21) | (w2 << 2) | (w1 << 16) | w; + return insn; + } + + /* This is any 17bit branch. In PA2.0 syntax it also corresponds to + the "B" instruction as well as BE. */ + case R_PARISC_PCREL17F: + case R_PARISC_DIR17F: + case R_PARISC_DIR17R: + case R_PARISC_PCREL17C: + case R_PARISC_PCREL17R: + { + unsigned int w2, w1, w; + + /* These are 17 bit branches. Mask off bits we do not care + about. */ + sym_value &= 0x1ffff; + + /* Now extract the W1, W2 and W fields from the value. */ + dis_assemble_17 (sym_value, &w1, &w2, &w); + + /* Mask out bits for the value in the instruction. */ + insn &= 0xffe0e002; + + /* Insert the bits for the W1, W2 and W fields into the + instruction. */ + insn |= (w2 << 2) | (w1 << 16) | w; + return insn; + } + + /* ADDIL or LDIL instructions. */ + case R_PARISC_DLTREL21L: + case R_PARISC_DLTIND21L: + case R_PARISC_LTOFF_FPTR21L: + case R_PARISC_PCREL21L: + case R_PARISC_LTOFF_TP21L: + case R_PARISC_DPREL21L: + case R_PARISC_PLTOFF21L: + case R_PARISC_DIR21L: + { + int w; + + /* Mask off bits in INSN we do not want. */ + insn &= 0xffe00000; + + /* Turn the 21bit value into the proper format. */ + dis_assemble_21 (sym_value, &w); + + /* And insert the proper bits into INSN. */ + return insn | w; + } + + /* LDO and integer loads/stores with 14bit displacements. */ + case R_PARISC_DLTREL14R: + case R_PARISC_DLTREL14F: + case R_PARISC_DLTIND14R: + case R_PARISC_DLTIND14F: + case R_PARISC_LTOFF_FPTR14R: + case R_PARISC_LTOFF_FPTR16F: + case R_PARISC_PCREL14R: + case R_PARISC_PCREL14F: + case R_PARISC_PCREL16F: + case R_PARISC_LTOFF_TP14R: + case R_PARISC_LTOFF_TP14F: + case R_PARISC_LTOFF_TP16F: + case R_PARISC_DPREL14R: + case R_PARISC_DPREL14F: + case R_PARISC_GPREL16F: + case R_PARISC_PLTOFF14R: + case R_PARISC_PLTOFF14F: + case R_PARISC_PLTOFF16F: + case R_PARISC_DIR14R: + case R_PARISC_DIR16F: + case R_PARISC_LTOFF16F: + { + int w; + + /* Mask off bits in INSN we do not want. */ + insn &= 0xffffc000; + + /* Turn the 14bit value into the proper format. */ + low_sign_unext (sym_value, 14, &w); + + /* And insert the proper bits into INSN. */ + return insn | w; + } + + /* Doubleword loads and stores with a 14bit displacement. */ + case R_PARISC_DLTREL14DR: + case R_PARISC_DLTIND14DR: + case R_PARISC_LTOFF_FPTR14DR: + case R_PARISC_LTOFF_FPTR16DF: + case R_PARISC_PCREL14DR: + case R_PARISC_PCREL16DF: + case R_PARISC_LTOFF_TP14DR: + case R_PARISC_LTOFF_TP16DF: + case R_PARISC_DPREL14DR: + case R_PARISC_GPREL16DF: + case R_PARISC_PLTOFF14DR: + case R_PARISC_PLTOFF16DF: + case R_PARISC_DIR14DR: + case R_PARISC_DIR16DF: + case R_PARISC_LTOFF16DF: + { + /* Mask off bits in INSN we do not want. */ + insn &= 0xffffc00e; + + /* The sign bit at 14 moves into bit zero in the destination. */ + insn |= ((sym_value & 0x2000) >> 13); + + /* Turn off the bits in sym_value we do not care about. */ + sym_value &= 0x1ff8; + + /* Now shift it one bit position left so that it lines up with the + destination field in INSN. */ + sym_value <<= 1; + + return insn | sym_value; + } + + /* Floating point single word load/store instructions. */ + case R_PARISC_DLTREL14WR: + case R_PARISC_DLTIND14WR: + case R_PARISC_LTOFF_FPTR14WR: + case R_PARISC_LTOFF_FPTR16WF: + case R_PARISC_PCREL14WR: + case R_PARISC_PCREL16WF: + case R_PARISC_LTOFF_TP14WR: + case R_PARISC_LTOFF_TP16WF: + case R_PARISC_DPREL14WR: + case R_PARISC_GPREL16WF: + case R_PARISC_PLTOFF14WR: + case R_PARISC_PLTOFF16WF: + case R_PARISC_DIR16WF: + case R_PARISC_DIR14WR: + case R_PARISC_LTOFF16WF: + { + /* Mask off bits in INSN we do not want. */ + insn &= 0xffffc006; + + /* The sign bit at 14 moves into bit zero in the destination. */ + insn |= ((sym_value & 0x2000) >> 13); + + /* Turn off the bits in sym_value we do not care about. */ + sym_value &= 0x1ffc; + + /* Now shift it one bit position left so that it lines up with the + destination field in INSN. */ + sym_value <<= 1; + + return insn | sym_value; + } + + default: + return insn; + } +} diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index 53d193d..1939635 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -1,5 +1,5 @@ /* Matsushita 10200 specific support for 32-bit ELF - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -185,7 +185,7 @@ static const struct mn10200_reloc_map mn10200_reloc_map[] = static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -205,7 +205,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void mn10200_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rela *dst; { @@ -223,15 +223,15 @@ mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd, addend, info, sym_sec, is_local) reloc_howto_type *howto; bfd *input_bfd; - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; 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; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sym_sec ATTRIBUTE_UNUSED; + int is_local ATTRIBUTE_UNUSED; { unsigned long r_type = howto->type; bfd_byte *hit_data = contents + offset; @@ -408,7 +408,7 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; relocation = 0; } @@ -447,7 +447,7 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: if (! ((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - rel->r_offset))) + rel->r_offset, true))) return false; break; diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 9ba09a8..498f538 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -1,5 +1,5 @@ /* Matsushita 10300 specific support for 32-bit ELF - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -290,7 +290,7 @@ static const struct mn10300_reloc_map mn10300_reloc_map[] = static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -310,7 +310,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void mn10300_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rela *dst; { @@ -385,7 +385,7 @@ mn10300_elf_check_relocs (abfd, info, sec, relocs) static asection * mn10300_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -407,6 +407,9 @@ mn10300_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -431,15 +434,15 @@ mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd, addend, info, sym_sec, is_local) reloc_howto_type *howto; bfd *input_bfd; - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; 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; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sym_sec ATTRIBUTE_UNUSED; + int is_local ATTRIBUTE_UNUSED; { unsigned long r_type = howto->type; bfd_byte *hit_data = contents + offset; @@ -620,7 +623,7 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; relocation = 0; } @@ -659,7 +662,7 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: if (! ((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - rel->r_offset))) + rel->r_offset, true))) return false; break; @@ -696,7 +699,7 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, static boolean elf32_mn10300_finish_hash_table_entry (gen_entry, in_args) struct bfd_hash_entry *gen_entry; - PTR in_args; + PTR in_args ATTRIBUTE_UNUSED; { struct elf32_mn10300_link_hash_entry *entry; unsigned int byte_count = 0; @@ -846,10 +849,9 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) { struct elf32_mn10300_link_hash_entry *hash; Elf_Internal_Sym *sym; - asection *sym_sec; + asection *sym_sec = NULL; 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) @@ -928,7 +930,7 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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); @@ -1191,9 +1193,8 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) { Elf_Internal_Sym isym; struct elf32_mn10300_link_hash_entry *sym_hash; - asection *sym_sec; + asection *sym_sec = NULL; const char *sym_name; - Elf_Internal_Shdr *hdr; char *new_name; bfd_elf32_swap_symbol_in (input_bfd, esym, &isym); @@ -1210,7 +1211,9 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) sym_sec = bfd_abs_section_ptr; else if (isym.st_shndx == SHN_COMMON) sym_sec = bfd_com_section_ptr; - + else + abort (); + sym_name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, isym.st_name); @@ -1460,8 +1463,7 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info) { Elf_Internal_Sym isym; - asection *sym_sec; - Elf_Internal_Shdr *hdr; + asection *sym_sec = NULL; const char *sym_name; char *new_name; @@ -1478,7 +1480,9 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) sym_sec = bfd_abs_section_ptr; else if (isym.st_shndx == SHN_COMMON) sym_sec = bfd_com_section_ptr; - + else + abort (); + symval = (isym.st_value + sym_sec->output_section->vma + sym_sec->output_offset); @@ -1903,6 +1907,79 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) *again = true; } + /* Try to turn a 24 immediate, displacement or absolute address + into a 8 immediate, displacement or absolute address. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_24) + { + bfd_vma value = symval; + value += irel->r_addend; + + /* See if the value will fit in 8 bits. */ + if ((long)value < 0x7f && (long)value > -0x80) + { + unsigned char code; + + /* AM33 insns which have 24 operands are 6 bytes long and + will have 0xfd as the first byte. */ + + /* Get the first opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 3); + + if (code == 0xfd) + { + /* Get the second opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 2); + + /* We can not relax 0x6b, 0x7b, 0x8b, 0x9b as no 24bit + equivalent instructions exists. */ + if (code != 0x6b && code != 0x7b + && code != 0x8b && code != 0x9b + && ((code & 0x0f) == 0x09 || (code & 0x0f) == 0x08 + || (code & 0x0f) == 0x0a || (code & 0x0f) == 0x0b + || (code & 0x0f) == 0x0e)) + { + /* 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 8bit value. This is currently over + conservative. */ + if ((value & 0x80) == 0) + { + /* 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, 0xfb, contents + irel->r_offset - 3); + 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_8); + + /* 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; + break; + } + } + + } + } + } /* Try to turn a 32bit immediate, displacement or absolute address into a 16bit immediate, displacement or absolute address. */ @@ -1911,6 +1988,74 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) bfd_vma value = symval; value += irel->r_addend; + /* See if the value will fit in 24 bits. + We allow any 16bit match here. We prune those we can't + handle below. */ + if ((long)value < 0x7fffff && (long)value > -0x800000) + { + unsigned char code; + + /* AM33 insns which have 32bit operands are 7 bytes long and + will have 0xfe as the first byte. */ + + /* Get the first opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 3); + + if (code == 0xfe) + { + /* Get the second opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 2); + + /* All the am33 32 -> 24 relaxing possibilities. */ + /* We can not relax 0x6b, 0x7b, 0x8b, 0x9b as no 24bit + equivalent instructions exists. */ + if (code != 0x6b && code != 0x7b + && code != 0x8b && code != 0x9b + && ((code & 0x0f) == 0x09 || (code & 0x0f) == 0x08 + || (code & 0x0f) == 0x0a || (code & 0x0f) == 0x0b + || (code & 0x0f) == 0x0e)) + { + /* 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. This is currently over + conservative. */ + if ((value & 0x8000) == 0) + { + /* 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, 0xfd, contents + irel->r_offset - 3); + 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_24); + + /* 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; + break; + } + } + + } + } /* See if the value will fit in 16 bits. We allow any 16bit match here. We prune those we can't @@ -2333,6 +2478,20 @@ compute_function_info (abfd, hash, addr, contents) if (hash->movm_args & 0x08) hash->movm_stack_size += 8 * 4; + if (bfd_get_mach (abfd) == bfd_mach_am33) + { + /* "exother" space. e0, e1, mdrq, mcrh, mcrl, mcvf */ + if (hash->movm_args & 0x1) + hash->movm_stack_size += 6 * 4; + + /* exreg1 space. e4, e5, e6, e7 */ + if (hash->movm_args & 0x2) + hash->movm_stack_size += 4 * 4; + + /* exreg0 space. e2, e3 */ + if (hash->movm_args & 0x4) + hash->movm_stack_size += 2 * 4; + } } /* Now look for the two stack adjustment variants. */ @@ -2724,6 +2883,8 @@ elf_mn10300_mach (flags) default: return bfd_mach_mn10300; + case E_MN10300_MACH_AM33: + return bfd_mach_am33; } } @@ -2735,13 +2896,9 @@ elf_mn10300_mach (flags) void _bfd_mn10300_elf_final_write_processing (abfd, linker) bfd *abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { unsigned long val; - unsigned int i; - Elf_Internal_Shdr **hdrpp; - const char *name; - asection *sec; switch (bfd_get_mach (abfd)) { @@ -2750,6 +2907,9 @@ _bfd_mn10300_elf_final_write_processing (abfd, linker) val = E_MN10300_MACH_MN10300; break; + case bfd_mach_am33: + val = E_MN10300_MACH_AM33; + break; } elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH); diff --git a/bfd/elf.c b/bfd/elf.c index ab010d4..8830ff0 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1,5 +1,5 @@ /* ELF executable support for BFD. - Copyright 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -53,6 +53,7 @@ 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 *)); +static boolean elfcore_read_notes PARAMS ((bfd *, bfd_vma, bfd_vma)); /* Swap version information in and out. The version information is currently size independent. If that ever changes, this code will @@ -200,10 +201,12 @@ _bfd_elf_swap_versym_out (abfd, src, dst) /* 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; +bfd_elf_hash (namearg) + const char *namearg; { + const unsigned char *name = (const unsigned char *) namearg; unsigned long h = 0; unsigned long g; int ch; @@ -503,13 +506,13 @@ bfd_elf_generic_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -756,8 +759,22 @@ bfd_elf_print_symbol (abfd, filep, symbol, how) case bfd_print_symbol_all: { CONST char *section_name; + CONST char *name = NULL; + struct elf_backend_data *bed; + unsigned char st_other; + section_name = symbol->section ? symbol->section->name : "(*none*)"; - bfd_print_symbol_vandf ((PTR) file, symbol); + + bed = get_elf_backend_data (abfd); + if (bed->elf_backend_print_symbol_all) + name = (*bed->elf_backend_print_symbol_all) (abfd, filep, symbol); + + if (name == NULL) + { + name = symbol->name; + 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. @@ -820,12 +837,21 @@ bfd_elf_print_symbol (abfd, filep, symbol, how) } /* 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)); + st_other = ((elf_symbol_type *) symbol)->internal_elf_sym.st_other; + + switch (st_other) + { + case 0: break; + case STV_INTERNAL: fprintf (file, " .internal"); break; + case STV_HIDDEN: fprintf (file, " .hidden"); break; + case STV_PROTECTED: fprintf (file, " .protected"); break; + default: + /* Some other non-defined flags are also present, so print + everything hex. */ + fprintf (file, " 0x%02x", (unsigned int) st_other); + } - fprintf (file, " %s", symbol->name); + fprintf (file, " %s", name); } break; } @@ -880,6 +906,58 @@ _bfd_elf_link_hash_newfunc (entry, table, string) return (struct bfd_hash_entry *) ret; } +/* Copy data from an indirect symbol to its direct symbol, hiding the + old indirect symbol. */ + +void +_bfd_elf_link_hash_copy_indirect (dir, ind) + struct elf_link_hash_entry *dir, *ind; +{ + /* Copy down any references that we may have already seen to the + symbol which just became indirect. */ + + dir->elf_link_hash_flags |= + (ind->elf_link_hash_flags + & (ELF_LINK_HASH_REF_DYNAMIC + | ELF_LINK_HASH_REF_REGULAR + | ELF_LINK_HASH_REF_REGULAR_NONWEAK + | ELF_LINK_NON_GOT_REF)); + + /* Copy over the global and procedure linkage table offset entries. + These may have been already set up by a check_relocs routine. */ + if (dir->got.offset == (bfd_vma) -1) + { + dir->got.offset = ind->got.offset; + ind->got.offset = (bfd_vma) -1; + } + BFD_ASSERT (ind->got.offset == (bfd_vma) -1); + + if (dir->plt.offset == (bfd_vma) -1) + { + dir->plt.offset = ind->plt.offset; + ind->plt.offset = (bfd_vma) -1; + } + BFD_ASSERT (ind->plt.offset == (bfd_vma) -1); + + if (dir->dynindx == -1) + { + dir->dynindx = ind->dynindx; + dir->dynstr_index = ind->dynstr_index; + ind->dynindx = -1; + ind->dynstr_index = 0; + } + BFD_ASSERT (ind->dynindx == -1); +} + +void +_bfd_elf_link_hash_hide_symbol(h) + struct elf_link_hash_entry *h; +{ + h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + h->dynindx = -1; + h->plt.offset = (bfd_vma) -1; +} + /* Initialize an ELF linker hash table. */ boolean @@ -944,7 +1022,7 @@ bfd_elf_set_dt_needed_name (abfd, name) struct bfd_link_needed_list * bfd_elf_get_needed_list (abfd, info) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; { if (info->hash->creator->flavour != bfd_target_elf_flavour) @@ -1201,6 +1279,15 @@ bfd_section_from_shdr (abfd, shindex) asection *target_sect; Elf_Internal_Shdr *hdr2; + /* Check for a bogus link to avoid crashing. */ + if (hdr->sh_link >= ehdr->e_shnum) + { + ((*_bfd_error_handler) + (_("%s: invalid link %lu for reloc section %s (index %u)"), + bfd_get_filename (abfd), hdr->sh_link, name, shindex)); + return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + } + /* 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 @@ -1265,6 +1352,10 @@ bfd_section_from_shdr (abfd, shindex) target_sect->flags |= SEC_RELOC; target_sect->relocation = NULL; target_sect->rel_filepos = hdr->sh_offset; + /* In the section to which the relocations apply, mark whether + its relocations are of the REL or RELA variety. */ + elf_section_data (target_sect)->use_rela_p + = (hdr->sh_type == SHT_RELA); abfd->flags |= HAS_RELOC; return true; } @@ -1324,11 +1415,15 @@ _bfd_elf_new_section_hook (abfd, sec) { struct bfd_elf_section_data *sdata; - sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata)); + sdata = (struct bfd_elf_section_data *) bfd_zalloc (abfd, sizeof (*sdata)); if (!sdata) return false; sec->used_by_bfd = (PTR) sdata; - memset (sdata, 0, sizeof (*sdata)); + + /* Indicate whether or not this section should use RELA relocations. */ + sdata->use_rela_p + = get_elf_backend_data (abfd)->default_use_rela_p; + return true; } @@ -1355,10 +1450,11 @@ _bfd_elf_new_section_hook (abfd, sec) */ boolean -bfd_section_from_phdr (abfd, hdr, index) +_bfd_elf_make_section_from_phdr (abfd, hdr, index, typename) bfd *abfd; Elf_Internal_Phdr *hdr; int index; + const char *typename; { asection *newsect; char *name; @@ -1368,7 +1464,7 @@ bfd_section_from_phdr (abfd, hdr, index) split = ((hdr->p_memsz > 0) && (hdr->p_filesz > 0) && (hdr->p_memsz > hdr->p_filesz)); - sprintf (namebuf, split ? "segment%da" : "segment%d", index); + sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : ""); name = bfd_alloc (abfd, strlen (namebuf) + 1); if (!name) return false; @@ -1399,7 +1495,7 @@ bfd_section_from_phdr (abfd, hdr, index) if (split) { - sprintf (namebuf, "segment%db", index); + sprintf (namebuf, "%s%db", typename, index); name = bfd_alloc (abfd, strlen (namebuf) + 1); if (!name) return false; @@ -1423,6 +1519,89 @@ bfd_section_from_phdr (abfd, hdr, index) return true; } +boolean +bfd_section_from_phdr (abfd, hdr, index) + bfd *abfd; + Elf_Internal_Phdr *hdr; + int index; +{ + struct elf_backend_data *bed; + + switch (hdr->p_type) + { + case PT_NULL: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "null"); + + case PT_LOAD: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "load"); + + case PT_DYNAMIC: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "dynamic"); + + case PT_INTERP: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "interp"); + + case PT_NOTE: + if (! _bfd_elf_make_section_from_phdr (abfd, hdr, index, "note")) + return false; + if (! elfcore_read_notes (abfd, hdr->p_offset, hdr->p_filesz)) + return false; + return true; + + case PT_SHLIB: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "shlib"); + + case PT_PHDR: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "phdr"); + + default: + /* Check for any processor-specific program segment types. + If no handler for them, default to making "segment" sections. */ + bed = get_elf_backend_data (abfd); + if (bed->elf_backend_section_from_phdr) + return (*bed->elf_backend_section_from_phdr) (abfd, hdr, index); + else + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "segment"); + } +} + +/* Initialize REL_HDR, the section-header for new section, containing + relocations against ASECT. If USE_RELA_P is true, we use RELA + relocations; otherwise, we use REL relocations. */ + +boolean +_bfd_elf_init_reloc_shdr (abfd, rel_hdr, asect, use_rela_p) + bfd *abfd; + Elf_Internal_Shdr *rel_hdr; + asection *asect; + boolean use_rela_p; +{ + char *name; + struct elf_backend_data *bed; + + bed = get_elf_backend_data (abfd); + name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name)); + if (name == NULL) + return false; + sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name); + rel_hdr->sh_name = + (unsigned int) _bfd_stringtab_add (elf_shstrtab (abfd), name, + true, false); + if (rel_hdr->sh_name == (unsigned int) -1) + return false; + rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL; + rel_hdr->sh_entsize = (use_rela_p + ? bed->s->sizeof_rela + : bed->s->sizeof_rel); + rel_hdr->sh_addralign = bed->s->file_align; + rel_hdr->sh_flags = 0; + rel_hdr->sh_addr = 0; + rel_hdr->sh_size = 0; + rel_hdr->sh_offset = 0; + + return true; +} + /* Set up an ELF internal section header for a section. */ /*ARGSUSED*/ @@ -1478,7 +1657,7 @@ elf_fake_sections (abfd, asect, failedptrarg) else if (strcmp (asect->name, ".hash") == 0) { this_hdr->sh_type = SHT_HASH; - this_hdr->sh_entsize = bed->s->arch_size / 8; + this_hdr->sh_entsize = bed->s->sizeof_hash_entry; } else if (strcmp (asect->name, ".dynsym") == 0) { @@ -1491,13 +1670,13 @@ elf_fake_sections (abfd, asect, failedptrarg) this_hdr->sh_entsize = bed->s->sizeof_dyn; } else if (strncmp (asect->name, ".rela", 5) == 0 - && get_elf_backend_data (abfd)->use_rela_p) + && get_elf_backend_data (abfd)->may_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) + && get_elf_backend_data (abfd)->may_use_rel_p) { this_hdr->sh_type = SHT_REL; this_hdr->sh_entsize = bed->s->sizeof_rel; @@ -1558,47 +1737,19 @@ elf_fake_sections (abfd, asect, failedptrarg) 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 (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; - } + SHT_REL[A] section. If two relocation sections are required for + this section, it is up to the processor-specific back-end to + create the other. */ + if ((asect->flags & SEC_RELOC) != 0 + && !_bfd_elf_init_reloc_shdr (abfd, + &elf_section_data (asect)->rel_hdr, + asect, + elf_section_data (asect)->use_rela_p)) + *failedptr = true; } /* Assign all ELF section numbers. The dummy first section is handled here @@ -1626,6 +1777,11 @@ assign_section_numbers (abfd) d->rel_idx = 0; else d->rel_idx = section_number++; + + if (d->rel_hdr2) + d->rel_idx2 = section_number++; + else + d->rel_idx2 = 0; } t->shstrtab_section = section_number++; @@ -1674,6 +1830,8 @@ assign_section_numbers (abfd) i_shdrp[d->this_idx] = &d->this_hdr; if (d->rel_idx != 0) i_shdrp[d->rel_idx] = &d->rel_hdr; + if (d->rel_idx2 != 0) + i_shdrp[d->rel_idx2] = d->rel_hdr2; /* Fill in the sh_link and sh_info fields while we're at it. */ @@ -1685,6 +1843,11 @@ assign_section_numbers (abfd) d->rel_hdr.sh_link = t->symtab_section; d->rel_hdr.sh_info = d->this_idx; } + if (d->rel_idx2 != 0) + { + d->rel_hdr2->sh_link = t->symtab_section; + d->rel_hdr2->sh_info = d->this_idx; + } switch (d->this_hdr.sh_type) { @@ -2011,6 +2174,10 @@ _bfd_elf_compute_section_file_positions (abfd, link_info) if (! prep_headers (abfd)) return false; + /* Post process the headers if necessary. */ + if (bed->elf_backend_post_process_headers) + (*bed->elf_backend_post_process_headers) (abfd, link_info); + failed = false; bfd_map_over_sections (abfd, elf_fake_sections, &failed); if (failed) @@ -2514,11 +2681,7 @@ assign_file_positions_for_segments (abfd) 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; + p->p_flags = m->p_flags; if (p->p_type == PT_LOAD && m->count > 0 @@ -3042,6 +3205,9 @@ prep_headers (abfd) bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB; i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current; + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_SYSV; + i_ehdrp->e_ident[EI_ABIVERSION] = 0; + for (count = EI_PAD; count < EI_NIDENT; count++) i_ehdrp->e_ident[count] = 0; @@ -3065,6 +3231,9 @@ prep_headers (abfd) else i_ehdrp->e_machine = EM_SPARC; break; + case bfd_arch_i370: + i_ehdrp->e_machine = EM_S370; + break; case bfd_arch_i386: i_ehdrp->e_machine = EM_386; break; @@ -3077,6 +3246,9 @@ prep_headers (abfd) case bfd_arch_i860: i_ehdrp->e_machine = EM_860; break; + case bfd_arch_i960: + i_ehdrp->e_machine = EM_960; + break; case bfd_arch_mips: /* MIPS Rxxxx */ i_ehdrp->e_machine = EM_MIPS; /* only MIPS R3000 */ break; @@ -3104,6 +3276,9 @@ prep_headers (abfd) case bfd_arch_mcore: i_ehdrp->e_machine = EM_MCORE; break; + case bfd_arch_avr: + i_ehdrp->e_machine = EM_AVR; + break; case bfd_arch_v850: switch (bfd_get_mach (abfd)) { @@ -3126,6 +3301,9 @@ prep_headers (abfd) case bfd_arch_mn10300: i_ehdrp->e_machine = EM_CYGNUS_MN10300; break; + case bfd_arch_pj: + i_ehdrp->e_machine = EM_PJ; + break; /* also note that EM_M32, AT&T WE32100 is unknown to bfd */ default: i_ehdrp->e_machine = EM_NONE; @@ -3827,6 +4005,9 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec) || ihdr->sh_type == SHT_GNU_verdef) ohdr->sh_info = ihdr->sh_info; + elf_section_data (osec)->use_rela_p + = elf_section_data (isec)->use_rela_p; + return true; } @@ -4046,7 +4227,8 @@ swap_out_syms (abfd, sttp, relocatable_p) type = STT_NOTYPE; /* Processor-specific types */ - if (bed->elf_backend_get_symbol_type) + if (type_ptr != NULL + && bed->elf_backend_get_symbol_type) type = (*bed->elf_backend_get_symbol_type) (&type_ptr->internal_elf_sym, type); if (flags & BSF_SECTION_SYM) @@ -4140,7 +4322,7 @@ _bfd_elf_get_dynamic_symtab_upper_bound (abfd) long _bfd_elf_get_reloc_upper_bound (abfd, asect) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; sec_ptr asect; { return (asect->reloc_count + 1) * sizeof (arelent *); @@ -4471,7 +4653,7 @@ _bfd_elf_make_empty_symbol (abfd) void _bfd_elf_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -4484,7 +4666,7 @@ _bfd_elf_get_symbol_info (ignore_abfd, symbol, ret) boolean _bfd_elf_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *name; { /* Normal local symbols start with ``.L''. */ @@ -4510,8 +4692,8 @@ _bfd_elf_is_local_label_name (abfd, name) alent * _bfd_elf_get_lineno (ignore_abfd, symbol) - bfd *ignore_abfd; - asymbol *symbol; + bfd *ignore_abfd ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; { abort (); return NULL; @@ -4565,7 +4747,7 @@ _bfd_elf_find_nearest_line (abfd, if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, - line_ptr)) + line_ptr, 0)) return true; if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, @@ -4661,9 +4843,9 @@ _bfd_elf_set_section_contents (abfd, section, location, offset, count) void _bfd_elf_no_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; - arelent *cache_ptr; - Elf_Internal_Rela *dst; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr ATTRIBUTE_UNUSED; + Elf_Internal_Rela *dst ATTRIBUTE_UNUSED; { abort (); } @@ -4797,13 +4979,13 @@ _bfd_elf_close_and_cleanup (abfd) 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *re ATTRIBUTE_UNUSED; + struct symbol_cache_entry *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *is ATTRIBUTE_UNUSED; + bfd *obfd ATTRIBUTE_UNUSED; + char **errmsg ATTRIBUTE_UNUSED; { return bfd_reloc_ok; } @@ -4924,28 +5106,33 @@ elfcore_grok_prstatus (abfd, note) #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. */ +/* Create a pseudosection containing the exact contents of NOTE. This + actually creates up to two pseudosections: + - For the single-threaded case, a section named NAME, unless + such a section already exists. + - For the multi-threaded case, a section named "NAME/PID", where + PID is elfcore_make_pid (abfd). + Both pseudosections have identical contents: the contents of NOTE. */ static boolean -elfcore_grok_prfpreg (abfd, note) +elfcore_make_note_pseudosection (abfd, name, note) bfd* abfd; + char *name; Elf_Internal_Note* note; { char buf[100]; - char* name; + char *threaded_name; asection* sect; - /* Make a ".reg2/999" section. */ + /* Build the section name. */ - sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd)); - name = bfd_alloc (abfd, strlen (buf) + 1); - if (name == NULL) + sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd)); + threaded_name = bfd_alloc (abfd, strlen (buf) + 1); + if (threaded_name == NULL) return false; - strcpy (name, buf); + strcpy (threaded_name, buf); - sect = bfd_make_section (abfd, name); + sect = bfd_make_section (abfd, threaded_name); if (sect == NULL) return false; sect->_raw_size = note->descsz; @@ -4953,12 +5140,37 @@ elfcore_grok_prfpreg (abfd, note) sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 2; - if (! elfcore_maybe_make_sect (abfd, ".reg2", sect)) + if (! elfcore_maybe_make_sect (abfd, name, sect)) return false; return true; } + +/* 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; +{ + return elfcore_make_note_pseudosection (abfd, ".reg2", note); +} + + +/* Linux dumps the Intel SSE regs in a note named "LINUX" with a note + type of 5 (NT_PRXFPREG). Just include the whole note's contents + literally. */ +static boolean +elfcore_grok_prxfpreg (abfd, note) + bfd* abfd; + Elf_Internal_Note* note; +{ + return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note); +} + + #if defined (HAVE_PRPSINFO_T) # define elfcore_psinfo_t prpsinfo_t #endif @@ -5139,7 +5351,83 @@ elfcore_grok_lwpstatus (abfd, note) } #endif /* defined (HAVE_LWPSTATUS_T) */ +#if defined (HAVE_WIN32_PSTATUS_T) +static boolean +elfcore_grok_win32pstatus (abfd, note) + bfd * abfd; + Elf_Internal_Note * note; +{ + char buf[30]; + char * name; + asection * sect; + win32_pstatus_t pstatus; + + if (note->descsz < sizeof (pstatus)) + return true; + + memcpy (& pstatus, note->descdata, note->descsz); + + switch (pstatus.data_type) + { + case NOTE_INFO_PROCESS: + /* FIXME: need to add ->core_command. */ + elf_tdata (abfd)->core_signal = pstatus.data.process_info.signal; + elf_tdata (abfd)->core_pid = pstatus.data.process_info.pid; + break ; + + case NOTE_INFO_THREAD: + /* Make a ".reg/999" section. */ + sprintf (buf, ".reg/%d", pstatus.data.thread_info.tid); + + 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 (pstatus.data.thread_info.thread_context); + sect->filepos = note->descpos + offsetof (struct win32_pstatus, + data.thread_info.thread_context); + sect->flags = SEC_HAS_CONTENTS; + sect->alignment_power = 2; + + if (pstatus.data.thread_info.is_active_thread) + if (! elfcore_maybe_make_sect (abfd, ".reg", sect)) + return false; + break; + + case NOTE_INFO_MODULE: + /* Make a ".module/xxxxxxxx" section. */ + sprintf (buf, ".module/%08x" , pstatus.data.module_info.base_address); + + 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; + break; + + default: + return true; + } + return true; +} +#endif /* HAVE_WIN32_PSTATUS_T */ static boolean elfcore_grok_note (abfd, note) @@ -5169,6 +5457,18 @@ elfcore_grok_note (abfd, note) case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG */ return elfcore_grok_prfpreg (abfd, note); +#if defined (HAVE_WIN32_PSTATUS_T) + case NT_WIN32PSTATUS: + return elfcore_grok_win32pstatus (abfd, note); +#endif + + case NT_PRXFPREG: /* Linux SSE extension */ + if (note->namesz == 5 + && ! strcmp (note->namedata, "LINUX")) + return elfcore_grok_prxfpreg (abfd, note); + else + return true; + #if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) case NT_PRPSINFO: case NT_PSINFO: @@ -5231,6 +5531,8 @@ elfcore_read_notes (abfd, offset, size) } +/* FIXME: This function is now unnecessary. Callers can just call + bfd_section_from_phdr directly. */ boolean _bfd_elfcore_section_from_phdr (abfd, phdr, sec_num) @@ -5241,10 +5543,54 @@ _bfd_elfcore_section_from_phdr (abfd, phdr, 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; } + + +/* Providing external access to the ELF program header table. */ + +/* Return an upper bound on the number of bytes required to store a + copy of ABFD's program header table entries. Return -1 if an error + occurs; bfd_get_error will return an appropriate code. */ +long +bfd_get_elf_phdr_upper_bound (abfd) + bfd *abfd; +{ + if (abfd->xvec->flavour != bfd_target_elf_flavour) + { + bfd_set_error (bfd_error_wrong_format); + return -1; + } + + return (elf_elfheader (abfd)->e_phnum + * sizeof (Elf_Internal_Phdr)); +} + + +/* Copy ABFD's program header table entries to *PHDRS. The entries + will be stored as an array of Elf_Internal_Phdr structures, as + defined in include/elf/internal.h. To find out how large the + buffer needs to be, call bfd_get_elf_phdr_upper_bound. + + Return the number of program header table entries read, or -1 if an + error occurs; bfd_get_error will return an appropriate code. */ +int +bfd_get_elf_phdrs (abfd, phdrs) + bfd *abfd; + void *phdrs; +{ + int num_phdrs; + + if (abfd->xvec->flavour != bfd_target_elf_flavour) + { + bfd_set_error (bfd_error_wrong_format); + return -1; + } + + num_phdrs = elf_elfheader (abfd)->e_phnum; + memcpy (phdrs, elf_tdata (abfd)->phdr, + num_phdrs * sizeof (Elf_Internal_Phdr)); + + return num_phdrs; +} diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index a490a24..318dc70 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1,5 +1,5 @@ /* ARC-specific support for 32-bit ELF - Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1997, 1999 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -118,7 +118,7 @@ static const struct arc_reloc_map arc_reloc_map[] = static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -138,7 +138,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void arc_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rel *dst; { @@ -178,7 +178,7 @@ arc_elf_object_p (abfd) static void arc_elf_final_write_processing (abfd, linker) bfd *abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { int mach; unsigned long val; diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index d4e97d6..eaaf976 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -29,12 +29,14 @@ 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 +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)); + PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, bfd_vma, struct bfd_link_info *, asection *, + const char *, unsigned char, struct elf_link_hash_entry *)); static insn32 insert_thumb_branch PARAMS ((insn32, int)); @@ -46,6 +48,14 @@ 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 *)); +static void elf32_arm_post_process_headers + PARAMS ((bfd *, struct bfd_link_info *)); +static int elf32_arm_to_thumb_stub + PARAMS ((struct bfd_link_info *, const char *, bfd *, bfd *, asection *, + bfd_byte *, asection *, bfd_vma, bfd_signed_vma, bfd_vma)); +static int elf32_thumb_to_arm_stub + PARAMS ((struct bfd_link_info *, const char *, bfd *, bfd *, asection *, + bfd_byte *, asection *, bfd_vma, bfd_signed_vma, bfd_vma)); /* The linker script knows the section names for placement. The entry_names are used to do simple name mangling on the stubs. @@ -71,7 +81,7 @@ static void record_thumb_to_arm_glue /* 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 + called before the relocation has been set up calls the dynamic linker first */ static const bfd_byte elf32_arm_plt0_entry [PLT_ENTRY_SIZE] = @@ -79,7 +89,7 @@ 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] */ + 0x08, 0xf0, 0xbe, 0xe5 /* ldr pc, [lr, #8]! */ }; /* Subsequent entries in a procedure linkage table look like @@ -113,7 +123,7 @@ struct elf32_arm_pcrel_relocs_copied bfd_size_type count; }; -/* arm ELF linker hash entry. */ +/* Arm ELF linker hash entry. */ struct elf32_arm_link_hash_entry { @@ -154,9 +164,43 @@ struct elf32_arm_link_hash_table /* An arbitary input BFD chosen to hold the glue sections. */ bfd * bfd_of_glue_owner; + + /* A boolean indicating whether knowledge of the ARM's pipeline + length should be applied by the linker. */ + int no_pipeline_knowledge; }; +/* Create an entry in an ARM ELF linker hash table. */ + +static struct bfd_hash_entry * +elf32_arm_link_hash_newfunc (entry, table, string) + struct bfd_hash_entry * entry; + struct bfd_hash_table * table; + const char * string; +{ + struct elf32_arm_link_hash_entry * ret = + (struct elf32_arm_link_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == (struct elf32_arm_link_hash_entry *) NULL) + ret = ((struct elf32_arm_link_hash_entry *) + bfd_hash_allocate (table, + sizeof (struct elf32_arm_link_hash_entry))); + if (ret == (struct elf32_arm_link_hash_entry *) NULL) + return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ + ret = ((struct elf32_arm_link_hash_entry *) + _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, + table, string)); + if (ret != (struct elf32_arm_link_hash_entry *) NULL) + ret->pcrel_relocs_copied = NULL; + + return (struct bfd_hash_entry *) ret; +} + /* Create an ARM elf linker hash table */ static struct bfd_link_hash_table * @@ -171,7 +215,7 @@ elf32_arm_link_hash_table_create (abfd) return NULL; if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, - _bfd_elf_link_hash_newfunc)) + elf32_arm_link_hash_newfunc)) { bfd_release (abfd, ret); return NULL; @@ -180,6 +224,7 @@ elf32_arm_link_hash_table_create (abfd) ret->thumb_glue_size = 0; ret->arm_glue_size = 0; ret->bfd_of_glue_owner = NULL; + ret->no_pipeline_knowledge = 0; return &ret->root.root; } @@ -282,7 +327,7 @@ static const insn32 a2t3_func_addr_insn = 0x00000001; ldmia r13! {r6, lr} bx lr __func_addr: - .word func + .word func */ #define THUMB2ARM_GLUE_SIZE 8 @@ -500,7 +545,10 @@ bfd_elf32_arm_get_bfd_for_interworking (abfd, info) if (sec == NULL) { - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; + /* Note: we do not include the flag SEC_LINKER_CREATED, as this + will prevent elf_link_input_bfd() from processing the contents + of this section. */ + flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME); @@ -508,13 +556,17 @@ bfd_elf32_arm_get_bfd_for_interworking (abfd, info) || !bfd_set_section_flags (abfd, sec, flags) || !bfd_set_section_alignment (abfd, sec, 2)) return false; + + /* Set the gc mark to prevent the section from being removed by garbage + collection, despite the fact that no relocs refer to this section. */ + sec->gc_mark = 1; } 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; + flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME); @@ -522,6 +574,8 @@ bfd_elf32_arm_get_bfd_for_interworking (abfd, info) || !bfd_set_section_flags (abfd, sec, flags) || !bfd_set_section_alignment (abfd, sec, 2)) return false; + + sec->gc_mark = 1; } /* Save the bfd for later use. */ @@ -531,9 +585,10 @@ bfd_elf32_arm_get_bfd_for_interworking (abfd, info) } boolean -bfd_elf32_arm_process_before_allocation (abfd, link_info) +bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) bfd *abfd; struct bfd_link_info *link_info; + int no_pipeline_knowledge; { Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Rela *free_relocs = NULL; @@ -559,6 +614,8 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) BFD_ASSERT (globals != NULL); BFD_ASSERT (globals->bfd_of_glue_owner != NULL); + globals->no_pipeline_knowledge = no_pipeline_knowledge; + /* Rummage around all the relocs and map the glue vectors. */ sec = abfd->sections; @@ -583,7 +640,6 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) { long r_type; unsigned long r_index; - unsigned char code; struct elf_link_hash_entry *h; @@ -591,7 +647,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) r_index = ELF32_R_SYM (irel->r_info); /* These are the only relocation types we care about */ - if (r_type != R_ARM_PC24 + if ( r_type != R_ARM_PC24 && r_type != R_ARM_THM_PC22) continue; @@ -658,7 +714,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) { 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 + the target of the call. If it is a thumb target, we insert glue. */ if (ELF_ST_TYPE(h->type) == STT_ARM_TFUNC) @@ -666,9 +722,9 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) 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. */ + /* 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); @@ -681,6 +737,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info) } return true; + error_return: if (free_relocs != NULL) free (free_relocs); @@ -688,22 +745,22 @@ error_return: 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 + 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. + instruction. - It takes two thumb instructions to encode the target address. Each has + 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). + 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 + Combine together and shifted left by 1 (it's a half word address) and there you have it. Op: 1111 = F, @@ -711,7 +768,7 @@ error_return: Op: 1111 = F, H-1, lower address-0 = 800 - They can be ordered either way, but the arm tools I've seen always put + 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) @@ -754,23 +811,23 @@ insert_thumb_branch (br_insn, rel_off) 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; + struct bfd_link_info * info; + const char * name; + bfd * input_bfd; + bfd * output_bfd; + asection * input_section; + bfd_byte * hit_data; + asection * sym_sec; + bfd_vma offset; + bfd_signed_vma addend; + bfd_vma val; { - asection *s = 0; + 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; + struct elf_link_hash_entry * myh; + struct elf32_arm_link_hash_table * globals; myh = find_thumb_glue (info, name, input_bfd); if (myh == NULL) @@ -838,7 +895,7 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, + my_offset - (input_section->output_offset + offset + addend) - - 4; + - 8; tmp = bfd_get_32 (input_bfd, hit_data - input_section->vma); @@ -854,24 +911,23 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, 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; + struct bfd_link_info * info; + const char * name; + bfd * input_bfd; + bfd * output_bfd; + asection * input_section; + bfd_byte * hit_data; + asection * sym_sec; + bfd_vma offset; + bfd_signed_vma addend; + bfd_vma val; { unsigned long int tmp; long int my_offset; - asection *s; + asection * s; long int ret_offset; - struct elf_link_hash_entry *myh; - struct elf32_arm_link_hash_table *globals; + struct elf_link_hash_entry * myh; + struct elf32_arm_link_hash_table * globals; myh = find_arm_glue (info, name, input_bfd); if (myh == NULL) @@ -929,13 +985,12 @@ elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section, + 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; } @@ -943,7 +998,7 @@ elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section, 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) + info, sym_sec, sym_name, sym_flags, h) reloc_howto_type * howto; bfd * input_bfd; bfd * output_bfd; @@ -955,6 +1010,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, asection * sym_sec; const char * sym_name; unsigned char sym_flags; + struct elf_link_hash_entry * h; { unsigned long r_type = howto->type; unsigned long r_symndx; @@ -966,9 +1022,12 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, asection * sgot = NULL; asection * splt = NULL; asection * sreloc = NULL; - struct elf_link_hash_entry * h = NULL; bfd_vma addend; - + bfd_signed_vma signed_addend; + struct elf32_arm_link_hash_table * globals; + + globals = elf32_arm_hash_table (info); + dynobj = elf_hash_table (info)->dynobj; if (dynobj) { @@ -981,11 +1040,20 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, r_symndx = ELF32_R_SYM (rel->r_info); #ifdef USE_REL - addend = (bfd_get_32 (input_bfd, hit_data) & howto->src_mask); + addend = bfd_get_32 (input_bfd, hit_data) & howto->src_mask; + + if (addend & ((howto->src_mask + 1) >> 1)) + { + signed_addend = -1; + signed_addend &= ~ howto->src_mask; + signed_addend |= addend; + } + else + signed_addend = addend; #else - addend = rel->r_addend; + addend = signed_addend = rel->r_addend; #endif - + switch (r_type) { case R_ARM_NONE: @@ -996,7 +1064,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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 @@ -1007,35 +1075,35 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, { 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, @@ -1045,10 +1113,10 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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); @@ -1083,20 +1151,21 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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 + /* 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, + return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, (bfd_vma) 0); } @@ -1104,38 +1173,103 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, { 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); + input_section, hit_data, sym_sec, rel->r_offset, + signed_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); + + if ( strcmp (bfd_get_target (input_bfd), "elf32-littlearm-oabi") == 0 + || strcmp (bfd_get_target (input_bfd), "elf32-bigarm-oabi") == 0) + { + /* The old way of doing things. Trearing the addend as a + byte sized field and adding in the pipeline offset. */ + + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= rel->r_offset; + value += addend; + + if (! globals->no_pipeline_knowledge) + value -= 8; + } + else + { + /* The ARM ELF ABI says that this reloc is computed as: S - P + A + where: + S is the address of the symbol in the relocation. + P is address of the instruction being relocated. + A is the addend (extracted from the instruction) in bytes. + + S is held in 'value'. + P is the base address of the section containing the instruction + plus the offset of the reloc into that section, ie: + (input_section->output_section->vma + + input_section->output_offset + + rel->r_offset). + A is the addend, converted into bytes, ie: + (signed_addend * 4) + + Note: None of these operations have knowledge of the pipeline + size of the processor, thus it is up to the assembler to encode + this information into the addend. */ + + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= rel->r_offset; + value += (signed_addend << howto->size); + + /* Previous versions of this code also used to add in the pipeline + offset here. This is wrong because the linker is not supposed + to know about such things, and one day it might change. In order + to support old binaries that need the old behaviour however, so + we attempt to detect which ABI was used to create the reloc. */ + if (! globals->no_pipeline_knowledge) + { + Elf_Internal_Ehdr * i_ehdrp; /* Elf file header, internal form */ + + i_ehdrp = elf_elfheader (input_bfd); + + if (i_ehdrp->e_ident[EI_OSABI] == 0) + value -= 8; + } + } + + /* It is not an error for an undefined weak reference to be + out of range. Any program that branches to such a symbol + is going to crash anyway, so there is no point worrying + about getting the destination exactly right. */ + if (! h || h->root.type != bfd_link_hash_undefweak) + { + /* Perform a signed range check. */ + signed_addend = value; + signed_addend >>= howto->rightshift; + if (signed_addend > ((bfd_signed_vma)(howto->dst_mask >> 1)) + || signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1))) + return bfd_reloc_overflow; + } + + value = (signed_addend & howto->dst_mask) + | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); 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; @@ -1190,45 +1324,62 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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_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_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 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; + bfd_vma upper = upper_insn & 0x7ff; + bfd_vma lower = lower_insn & 0x7ff; upper = (upper ^ 0x400) - 0x400; /* sign extend */ addend = (upper << 12) | (lower << 1); + signed_addend = addend; } #endif - /* If it's not a call to thumb, assume call to arm */ - if (sym_flags != STT_ARM_TFUNC) + /* If it is not a call to thumb, assume call to arm. + If it is a call relative to a section name, then it is not a + function call at all, but rather a long jump. */ + if (sym_flags != STT_ARM_TFUNC && sym_flags != STT_SECTION) { if (elf32_thumb_to_arm_stub (info, sym_name, input_bfd, output_bfd, input_section, - hit_data, sym_sec, rel->r_offset, addend, value)) + hit_data, sym_sec, rel->r_offset, signed_addend, value)) return bfd_reloc_ok; else return bfd_reloc_dangerous; } - /* +4: pc is offset by 4 */ - relocation = value + addend + 4; + relocation = value + signed_addend; + relocation -= (input_section->output_section->vma - + input_section->output_offset); - relocation -= rel->r_offset; + + input_section->output_offset + + rel->r_offset); + + if (! globals->no_pipeline_knowledge) + { + Elf_Internal_Ehdr * i_ehdrp; /* Elf file header, internal form */ + + i_ehdrp = elf_elfheader (input_bfd); + + /* Previous versions of this code also used to add in the pipline + offset here. This is wrong because the linker is not supposed + to know about such things, and one day it might change. In order + to support old binaries that need the old behaviour however, so + we attempt to detect which ABI was used to create the reloc. */ + if ( strcmp (bfd_get_target (input_bfd), "elf32-littlearm-oabi") == 0 + || strcmp (bfd_get_target (input_bfd), "elf32-bigarm-oabi") == 0 + || i_ehdrp->e_ident[EI_OSABI] == 0) + relocation += 4; + } check = relocation >> howto->rightshift; @@ -1239,17 +1390,8 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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) + if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) overflow = true; /* Put RELOCATION back into the insn. */ @@ -1287,15 +1429,15 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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, + return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, (bfd_vma) 0); @@ -1303,28 +1445,28 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, /* 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, + 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))) @@ -1334,11 +1476,11 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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 + entry to initialize the value. This is done in the finish_dynamic_symbol routine. */ - + if ((off & 1) != 0) off &= ~1; else @@ -1347,18 +1489,18 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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. */ @@ -1367,17 +1509,17 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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 + + sgot->output_offset + off); outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); bfd_elf32_swap_reloc_out (output_bfd, &outrel, @@ -1386,17 +1528,17 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, + 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, + 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. */ @@ -1426,7 +1568,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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; @@ -1456,6 +1598,55 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, } } +#ifdef USE_REL +/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */ +static void +arm_add_to_rel (abfd, address, howto, increment) + bfd * abfd; + bfd_byte * address; + reloc_howto_type * howto; + bfd_signed_vma increment; +{ + bfd_vma contents; + bfd_signed_vma addend; + + contents = bfd_get_32 (abfd, address); + + /* Get the (signed) value from the instruction. */ + addend = contents & howto->src_mask; + if (addend & ((howto->src_mask + 1) >> 1)) + { + bfd_signed_vma mask; + + mask = -1; + mask &= ~ howto->src_mask; + addend |= mask; + } + + /* Add in the increment, (which is a byte value). */ + switch (howto->type) + { + case R_ARM_THM_PC22: + default: + addend += increment; + break; + + case R_ARM_PC24: + addend <<= howto->size; + addend += increment; + + /* Should we check for overflow here ? */ + + /* Drop any undesired bits. */ + addend >>= howto->rightshift; + break; + } + + contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask); + + bfd_put_32 (abfd, contents, address); +} +#endif /* USE_REL */ /* Relocate an ARM ELF section. */ static boolean @@ -1483,25 +1674,25 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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; + 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; + bfd_vma relocation; + bfd_reloc_status_type r; + arelent bfd_reloc; r_symndx = ELF32_R_SYM (rel->r_info); - r_type = ELF32_R_TYPE (rel->r_info); + r_type = ELF32_R_TYPE (rel->r_info); - if (r_type == R_ARM_GNU_VTENTRY - || r_type == R_ARM_GNU_VTINHERIT ) + 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; + elf32_arm_info_to_howto (input_bfd, & bfd_reloc, rel); + howto = bfd_reloc.howto; if (info->relocateable) { @@ -1516,12 +1707,8 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_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); - } + arm_add_to_rel (input_bfd, contents + rel->r_offset, + howto, sec->output_offset + sym->st_value); #else rel->r_addend += (sec->output_offset + sym->st_value) >> howto->rightshift; @@ -1553,14 +1740,12 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) { + int relocation_needed = 1; + 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 + We check specially because in some obscure cases sec->output_section will be NULL. */ switch (r_type) { @@ -1569,17 +1754,17 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, if (info->shared && ( (!info->symbolic && h->dynindx != -1) - || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR == 0) + || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 ) && ((input_section->flags & SEC_ALLOC) != 0) ) - relocation = 0; + relocation_needed = 0; break; - + case R_ARM_GOTPC: - relocation = 0; + relocation_needed = 0; break; - + case R_ARM_GOT32: if (elf_hash_table(info)->dynamic_sections_created && (!info->shared @@ -1587,14 +1772,14 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 ) ) - relocation = 0; + relocation_needed = 0; break; - + case R_ARM_PLT32: if (h->plt.offset != (bfd_vma)-1) - relocation = 0; + relocation_needed = 0; break; - + default: if (sec->output_section == NULL) { @@ -1602,17 +1787,27 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, (_("%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; + relocation_needed = 0; } } + + if (relocation_needed) + relocation = h->root.u.def.value + + sec->output_section->vma + + sec->output_offset; + else + relocation = 0; } 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))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } @@ -1627,12 +1822,12 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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))); + ELF_ST_TYPE (sym->st_info)), h); if (r != bfd_reloc_ok) { @@ -1650,7 +1845,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: if (!((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - rel->r_offset))) + rel->r_offset, true))) return false; break; @@ -1910,16 +2105,28 @@ 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; + switch (ELF_ST_TYPE (elf_sym->st_info)) + { + case STT_ARM_TFUNC: + return ELF_ST_TYPE (elf_sym->st_info); + break; + case STT_ARM_16BIT: + /* If the symbol is not an object, return the STT_ARM_16BIT flag. + This allows us to distinguish between data used by Thumb instructions + and non-data (which is probably code) inside Thumb regions of an + executable. */ + if (type != STT_OBJECT) + return ELF_ST_TYPE (elf_sym->st_info); + break; + } + + return type; } - + static asection * elf32_arm_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -1941,6 +2148,9 @@ elf32_arm_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -1957,21 +2167,21 @@ elf32_arm_gc_mark_hook (abfd, info, rel, h, sym) return NULL; } +/* Update the got entry reference counts for the section being removed. */ + 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { - /* we don't use got and plt entries for armelf */ + /* We don't support garbage collection of GOT and PLT relocs yet. */ 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. */ - +/* Look through the relocs for a section during the first phase. */ + static boolean elf32_arm_check_relocs (abfd, info, sec, relocs) bfd * abfd; @@ -1987,33 +2197,33 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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) { @@ -2047,7 +2257,7 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) && (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) { @@ -2070,7 +2280,7 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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. */ @@ -2097,7 +2307,7 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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; @@ -2212,7 +2422,7 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) { p = ((struct elf32_arm_pcrel_relocs_copied *) bfd_alloc (dynobj, sizeof * p)); - + if (p == NULL) return false; p->next = eh->pcrel_relocs_copied; @@ -2232,20 +2442,20 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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)) + if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset)) 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. */ @@ -2268,8 +2478,8 @@ elf32_arm_find_nearest_line asymbol ** p; if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, - filename_ptr, functionname_ptr, - line_ptr)) + filename_ptr, functionname_ptr, + line_ptr, 0)) return true; if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, @@ -2277,7 +2487,7 @@ elf32_arm_find_nearest_line functionname_ptr, line_ptr, &elf_tdata (abfd)->line_info)) return false; - + if (found) return true; @@ -2324,7 +2534,7 @@ elf32_arm_find_nearest_line *filename_ptr = filename; *functionname_ptr = bfd_asymbol_name (func); *line_ptr = 0; - + return true; } @@ -2614,6 +2824,7 @@ elf32_arm_size_dynamic_sections (output_bfd, info) 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) @@ -2702,7 +2913,7 @@ elf32_arm_size_dynamic_sections (output_bfd, info) static boolean elf32_arm_discard_copies (h, ignore) struct elf32_arm_link_hash_entry * h; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { struct elf32_arm_pcrel_relocs_copied * s; @@ -2767,7 +2978,7 @@ elf32_arm_finish_dynamic_symbol (output_bfd, info, h, sym) bfd_put_32 (output_bfd, (sgot->output_section->vma + sgot->output_offset - + got_offset + + got_offset - splt->output_section->vma - splt->output_offset - h->plt.offset - 12), @@ -2804,7 +3015,7 @@ elf32_arm_finish_dynamic_symbol (output_bfd, info, h, sym) /* 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); @@ -2978,9 +3189,23 @@ elf32_arm_finish_dynamic_sections (output_bfd, info) return true; } +static void +elf32_arm_post_process_headers (abfd, link_info) + bfd * abfd; + struct bfd_link_info * link_info ATTRIBUTE_UNUSED; +{ + Elf_Internal_Ehdr * i_ehdrp; /* Elf file header, internal form */ + + i_ehdrp = elf_elfheader (abfd); + + i_ehdrp->e_ident[EI_OSABI] = ARM_ELF_OS_ABI_VERSION; + i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION; +} + + #define ELF_ARCH bfd_arch_arm #define ELF_MACHINE_CODE EM_ARM -#define ELF_MAXPAGE_SIZE 0x8000 +#define ELF_MAXPAGESIZE 0x8000 #define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data @@ -3001,10 +3226,14 @@ elf32_arm_finish_dynamic_sections (output_bfd, info) #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_post_process_headers elf32_arm_post_process_headers #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 +#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-avr.c b/bfd/elf32-avr.c new file mode 100644 index 0000000..c64ab28 --- /dev/null +++ b/bfd/elf32-avr.c @@ -0,0 +1,963 @@ +/* AVR-specific support for 32-bit ELF + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Contributed by Denis Chertykov + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public 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/avr.h" + +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); +static void avr_info_to_howto_rela + PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); +static asection *elf32_avr_gc_mark_hook + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + struct elf_link_hash_entry *, Elf_Internal_Sym *)); +static boolean elf32_avr_gc_sweep_hook + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static boolean elf32_avr_check_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static bfd_reloc_status_type avr_final_link_relocate + PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, bfd_vma)); +static boolean elf32_avr_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); +static void bfd_elf_avr_final_write_processing PARAMS ((bfd *, boolean)); +static boolean elf32_avr_object_p PARAMS ((bfd *)); + + +/* Use RELA instead of REL */ +#undef USE_REL + +static reloc_howto_type elf_avr_howto_table[] = +{ + HOWTO (R_AVR_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_AVR_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + HOWTO (R_AVR_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_AVR_32", /* name */ + false, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 7 bit PC relative relocation. */ + HOWTO (R_AVR_7_PCREL, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 7, /* bitsize */ + true, /* pc_relative */ + 3, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_AVR_7_PCREL", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A 13 bit PC relative relocation. */ + HOWTO (R_AVR_13_PCREL, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 13, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_AVR_13_PCREL", /* name */ + false, /* partial_inplace */ + 0xfff, /* src_mask */ + 0xfff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A 16 bit absolute relocation. */ + HOWTO (R_AVR_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_AVR_16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 16 bit absolute relocation for command address. */ + HOWTO (R_AVR_16_PM, /* type */ + 1, /* 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_AVR_16_PM", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A low 8 bit absolute relocation of 16 bit address. + For LDI command. */ + HOWTO (R_AVR_LO8_LDI, /* type */ + 0, /* rightshift */ + 1, /* 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_AVR_LO8_LDI", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 8 bit absolute relocation of 16 bit address. + For LDI command. */ + HOWTO (R_AVR_HI8_LDI, /* type */ + 8, /* rightshift */ + 1, /* 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_AVR_HI8_LDI", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 6 bit absolute relocation of 22 bit address. + For LDI command. */ + HOWTO (R_AVR_HH8_LDI, /* type */ + 16, /* rightshift */ + 1, /* 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_AVR_HH8_LDI", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A negative low 8 bit absolute relocation of 16 bit address. + For LDI command. */ + HOWTO (R_AVR_LO8_LDI_NEG, /* type */ + 0, /* rightshift */ + 1, /* 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_AVR_LO8_LDI_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A hegative high 8 bit absolute relocation of 16 bit address. + For LDI command. */ + HOWTO (R_AVR_HI8_LDI_NEG, /* type */ + 8, /* rightshift */ + 1, /* 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_AVR_HI8_LDI_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A hegative high 6 bit absolute relocation of 22 bit address. + For LDI command. */ + HOWTO (R_AVR_HH8_LDI_NEG, /* type */ + 16, /* rightshift */ + 1, /* 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_AVR_HH8_LDI_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A low 8 bit absolute relocation of 24 bit program memory address. + For LDI command. */ + HOWTO (R_AVR_LO8_LDI_PM, /* type */ + 1, /* rightshift */ + 1, /* 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_AVR_LO8_LDI_PM", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 8 bit absolute relocation of 16 bit program memory address. + For LDI command. */ + HOWTO (R_AVR_HI8_LDI_PM, /* type */ + 9, /* rightshift */ + 1, /* 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_AVR_HI8_LDI_PM", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 8 bit absolute relocation of 24 bit program memory address. + For LDI command. */ + HOWTO (R_AVR_HH8_LDI_PM, /* type */ + 17, /* rightshift */ + 1, /* 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_AVR_HH8_LDI_PM", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A low 8 bit absolute relocation of a negative 24 bit + program memory address. For LDI command. */ + HOWTO (R_AVR_LO8_LDI_PM_NEG, /* type */ + 1, /* rightshift */ + 1, /* 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_AVR_LO8_LDI_PM_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 8 bit absolute relocation of a negative 16 bit + program memory address. For LDI command. */ + HOWTO (R_AVR_HI8_LDI_PM_NEG, /* type */ + 9, /* rightshift */ + 1, /* 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_AVR_HI8_LDI_PM_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* A high 8 bit absolute relocation of a negative 24 bit + program memory address. For LDI command. */ + HOWTO (R_AVR_HH8_LDI_PM_NEG, /* type */ + 17, /* rightshift */ + 1, /* 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_AVR_HH8_LDI_PM_NEG", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + /* Relocation for CALL command in ATmega. */ + HOWTO (R_AVR_CALL, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 23, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_AVR_CALL", /* name */ + false, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false) /* pcrel_offset */ +}; + +/* Map BFD reloc types to AVR ELF reloc types. */ + +struct avr_reloc_map +{ + bfd_reloc_code_real_type bfd_reloc_val; + unsigned int elf_reloc_val; +}; + + static const struct avr_reloc_map avr_reloc_map[] = +{ + { BFD_RELOC_NONE, R_AVR_NONE }, + { BFD_RELOC_32, R_AVR_32 }, + { BFD_RELOC_AVR_7_PCREL, R_AVR_7_PCREL }, + { BFD_RELOC_AVR_13_PCREL, R_AVR_13_PCREL }, + { BFD_RELOC_16, R_AVR_16 }, + { BFD_RELOC_AVR_16_PM, R_AVR_16_PM }, + { BFD_RELOC_AVR_LO8_LDI, R_AVR_LO8_LDI}, + { BFD_RELOC_AVR_HI8_LDI, R_AVR_HI8_LDI }, + { BFD_RELOC_AVR_HH8_LDI, R_AVR_HH8_LDI }, + { BFD_RELOC_AVR_LO8_LDI_NEG, R_AVR_LO8_LDI_NEG }, + { BFD_RELOC_AVR_HI8_LDI_NEG, R_AVR_HI8_LDI_NEG }, + { BFD_RELOC_AVR_HH8_LDI_NEG, R_AVR_HH8_LDI_NEG }, + { BFD_RELOC_AVR_LO8_LDI_PM, R_AVR_LO8_LDI_PM }, + { BFD_RELOC_AVR_HI8_LDI_PM, R_AVR_HI8_LDI_PM }, + { BFD_RELOC_AVR_HH8_LDI_PM, R_AVR_HH8_LDI_PM }, + { BFD_RELOC_AVR_LO8_LDI_PM_NEG, R_AVR_LO8_LDI_PM_NEG }, + { BFD_RELOC_AVR_HI8_LDI_PM_NEG, R_AVR_HI8_LDI_PM_NEG }, + { BFD_RELOC_AVR_HH8_LDI_PM_NEG, R_AVR_HH8_LDI_PM_NEG }, + { BFD_RELOC_AVR_CALL, R_AVR_CALL } +}; + +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 (avr_reloc_map) / sizeof (struct avr_reloc_map); + i++) + { + if (avr_reloc_map[i].bfd_reloc_val == code) + return &elf_avr_howto_table[avr_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Set the howto pointer for an AVR ELF reloc. */ + +static void +avr_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_AVR_max); + cache_ptr->howto = &elf_avr_howto_table[r_type]; +} + +static asection * +elf32_avr_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)) + { + 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; +} + +static boolean +elf32_avr_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 avr. */ + 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_avr_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]; + } + + return true; +} + +/* 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 +avr_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_AVR_7_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 << 7) - 1) || (srel < - (1 << 7))) + return bfd_reloc_overflow; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xfc07) | (((srel >> 1) << 3) & 0x3f8); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_13_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; + + /* AVR addresses commands as words. */ + srel >>= 1; + + /* Check for overflow. */ + if (srel < -2048 || srel > 2047) + { + /* Apply WRAPAROUND if possible. */ + if (bfd_get_mach (input_bfd) == bfd_mach_avr2) + { + if (srel > 2047) + srel -= 4096; + else + srel += 4096; + } + else + return bfd_reloc_overflow; + } + + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf000) | (srel & 0xfff); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_LO8_LDI: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HI8_LDI: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = (srel >> 8) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HH8_LDI: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = (srel >> 16) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_LO8_LDI_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HI8_LDI_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + srel = (srel >> 8) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HH8_LDI_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + srel = (srel >> 16) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_LO8_LDI_PM: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HI8_LDI_PM: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + srel = (srel >> 8) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HH8_LDI_PM: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + srel = (srel >> 16) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_LO8_LDI_PM_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HI8_LDI_PM_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + srel = (srel >> 8) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_HH8_LDI_PM_NEG: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + srel = -srel; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + srel = (srel >> 16) & 0xff; + x = bfd_get_16 (input_bfd, contents); + x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00); + bfd_put_16 (input_bfd, x, contents); + break; + + case R_AVR_CALL: + contents += rel->r_offset; + srel = (bfd_signed_vma) relocation + rel->r_addend; + if (srel & 1) + return bfd_reloc_outofrange; + srel = srel >> 1; + x = bfd_get_16 (input_bfd, contents); + x |= ((srel & 0x10000) | ((srel << 3) & 0x1f00000)) >> 16; + bfd_put_16 (input_bfd, x, contents); + bfd_put_16 (input_bfd, srel & 0xffff, contents+2); + break; + + default: + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + } + + return r; +} + +/* Relocate an AVR ELF section. */ +static boolean +elf32_avr_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); + 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 = elf_avr_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; + } + 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); + } + 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, true))) + return false; + relocation = 0; + } + } + + r = avr_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, true); + 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; +} + +/* The final processing done just before writing out a AVR ELF object + file. This gets the AVR architecture right based on the machine + number. */ + +static void +bfd_elf_avr_final_write_processing (abfd, linker) + bfd *abfd; + boolean linker ATTRIBUTE_UNUSED; +{ + unsigned long val; + + switch (bfd_get_mach (abfd)) + { + default: + case bfd_mach_avr2: + val = E_AVR_MACH_AVR2; + break; + + case bfd_mach_avr1: + val = E_AVR_MACH_AVR1; + break; + + case bfd_mach_avr3: + val = E_AVR_MACH_AVR3; + break; + + case bfd_mach_avr4: + val = E_AVR_MACH_AVR4; + break; + + } + + elf_elfheader (abfd)->e_machine = EM_AVR; + elf_elfheader (abfd)->e_flags &= ~ EF_AVR_MACH; + elf_elfheader (abfd)->e_flags |= val; +} + +/* Set the right machine number. */ + +static boolean +elf32_avr_object_p (abfd) + bfd *abfd; +{ + int e_set = bfd_mach_avr2; + if (elf_elfheader (abfd)->e_machine == EM_AVR) + { + int e_mach = elf_elfheader (abfd)->e_flags & EF_AVR_MACH; + switch (e_mach) + { + default: + case E_AVR_MACH_AVR2: + e_set = bfd_mach_avr2; + break; + + case E_AVR_MACH_AVR1: + e_set = bfd_mach_avr1; + break; + + case E_AVR_MACH_AVR3: + e_set = bfd_mach_avr3; + break; + + case E_AVR_MACH_AVR4: + e_set = bfd_mach_avr4; + break; + } + } + return bfd_default_set_arch_mach (abfd, bfd_arch_avr, + e_set); +} + + +#define ELF_ARCH bfd_arch_avr +#define ELF_MACHINE_CODE EM_AVR +#define ELF_MAXPAGESIZE 1 + +#define TARGET_LITTLE_SYM bfd_elf32_avr_vec +#define TARGET_LITTLE_NAME "elf32-avr" + +#define elf_info_to_howto avr_info_to_howto_rela +#define elf_info_to_howto_rel NULL +#define elf_backend_relocate_section elf32_avr_relocate_section +#define elf_backend_gc_mark_hook elf32_avr_gc_mark_hook +#define elf_backend_gc_sweep_hook elf32_avr_gc_sweep_hook +#define elf_backend_check_relocs elf32_avr_check_relocs +#define elf_backend_can_gc_sections 1 +#define elf_backend_final_write_processing \ + bfd_elf_avr_final_write_processing +#define elf_backend_object_p elf32_avr_object_p + + +#include "elf32-target.h" diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c index be80bae..dd2e892 100644 --- a/bfd/elf32-d10v.c +++ b/bfd/elf32-d10v.c @@ -1,5 +1,5 @@ /* D10V-specific support for 32-bit ELF - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. Contributed by Martin Hunt (hunt@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -211,7 +211,7 @@ struct d10v_reloc_map static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -231,7 +231,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void d10v_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rel *dst; { @@ -245,7 +245,7 @@ d10v_info_to_howto_rel (abfd, cache_ptr, dst) static asection * elf32_d10v_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -267,6 +267,9 @@ elf32_d10v_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -285,10 +288,10 @@ elf32_d10v_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { /* we don't use got and plt entries for d10v */ return true; @@ -356,7 +359,7 @@ elf32_d10v_check_relocs (abfd, info, sec, relocs) static boolean elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -446,7 +449,7 @@ elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section, { if (!((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; relocation = 0; } @@ -482,7 +485,7 @@ elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: if (!((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - rel->r_offset))) + rel->r_offset, true))) return false; break; diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c index 0b0e9e9..263b5c0 100644 --- a/bfd/elf32-d30v.c +++ b/bfd/elf32-d30v.c @@ -1,5 +1,5 @@ /* D30V-specific support for 32-bit ELF - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. Contributed by Martin Hunt (hunt@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -540,7 +540,7 @@ static const struct d30v_reloc_map d30v_reloc_map[] = static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -560,7 +560,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void d30v_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rel *dst; { @@ -575,7 +575,7 @@ d30v_info_to_howto_rel (abfd, cache_ptr, dst) static void d30v_info_to_howto_rela (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rela *dst; { diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index 7c8725f..6b295d3 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -1,5 +1,5 @@ /* FR30-specific support for 32-bit ELF. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -250,7 +250,7 @@ fr30_elf_i20_reloc (abfd, reloc_entry, symbol, data, PTR data; asection * input_section; bfd * output_bfd; - char ** error_message; + char ** error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; unsigned long x; @@ -297,7 +297,7 @@ fr30_elf_i32_reloc (abfd, reloc_entry, symbol, data, PTR data; asection * input_section; bfd * output_bfd; - char ** error_message; + char ** error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; @@ -353,7 +353,7 @@ static const struct fr30_reloc_map fr30_reloc_map [] = static reloc_howto_type * fr30_reloc_type_lookup (abfd, code) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -370,7 +370,7 @@ fr30_reloc_type_lookup (abfd, code) static void fr30_info_to_howto_rela (abfd, cache_ptr, dst) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; arelent * cache_ptr; Elf32_Internal_Rela * dst; { @@ -499,7 +499,7 @@ fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel, reloca static boolean fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections) - bfd * output_bfd; + bfd * output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info * info; bfd * input_bfd; asection * input_section; @@ -617,7 +617,7 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; #if 0 fprintf (stderr, "unknown: name: %s\n", name); @@ -643,7 +643,8 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: r = info->callbacks->undefined_symbol - (info, name, input_bfd, input_section, rel->r_offset); + (info, name, input_bfd, input_section, rel->r_offset, + true); break; case bfd_reloc_outofrange: @@ -681,7 +682,7 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, static asection * fr30_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd * abfd; - struct bfd_link_info * info; + struct bfd_link_info * info ATTRIBUTE_UNUSED; Elf_Internal_Rela * rel; struct elf_link_hash_entry * h; Elf_Internal_Sym * sym; @@ -703,6 +704,9 @@ fr30_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -724,10 +728,10 @@ fr30_elf_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd * abfd ATTRIBUTE_UNUSED; + struct bfd_link_info * info ATTRIBUTE_UNUSED; + asection * sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED; { return true; } diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c index a4d3cac..47da53b 100644 --- a/bfd/elf32-gen.c +++ b/bfd/elf32-gen.c @@ -1,5 +1,5 @@ /* Generic support for 32-bit ELF - Copyright 1993, 1995, 1998 Free Software Foundation, Inc. + Copyright 1993, 1995, 1998, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -42,18 +42,18 @@ static reloc_howto_type dummy = static void elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *bfd_reloc; - Elf32_Internal_Rela *elf_reloc; + Elf32_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED; { bfd_reloc->howto = &dummy; } static void elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *bfd_reloc; - Elf32_Internal_Rel *elf_reloc; + Elf32_Internal_Rel *elf_reloc ATTRIBUTE_UNUSED; { bfd_reloc->howto = &dummy; } @@ -64,6 +64,7 @@ elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) #define TARGET_BIG_NAME "elf32-big" #define ELF_ARCH bfd_arch_unknown #define ELF_MACHINE_CODE EM_NONE +#define ELF_MAXPAGESIZE 0x1 #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 diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 6bd7f67..683a308 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1,5 +1,5 @@ /* BFD back-end for HP PA-RISC ELF files. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by @@ -26,53 +26,14 @@ 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/hppa.h" +#include "libhppa.h" +#include "elf32-hppa.h" +#define ARCH_SIZE 32 +#include "elf-hppa.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. @@ -83,11 +44,7 @@ typedef struct symext_chain symext_chainS; 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. */ + necessary to build the linker stubs during a link. */ /* Hash table for linker stubs. */ @@ -123,23 +80,6 @@ struct elf32_hppa_stub_hash_table }; -/* 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; @@ -153,9 +93,6 @@ struct elf32_hppa_link_hash_table /* 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; @@ -164,32 +101,6 @@ struct elf32_hppa_link_hash_table 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 @@ -199,43 +110,10 @@ typedef enum #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 *)); @@ -252,10 +130,6 @@ 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 *, @@ -271,238 +145,11 @@ elf32_hppa_stub_hash_table_init 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 [])); + PARAMS ((bfd_vma, bfd_vma, const char *)); 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; - + PARAMS ((bfd_vma, bfd_vma, char *)); /* For linker stub hash tables. */ #define elf32_hppa_stub_hash_lookup(table, string, create, copy) \ @@ -515,24 +162,6 @@ static bfd_byte *symextn_contents; (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)\ @@ -552,10 +181,6 @@ static bfd_byte *symextn_contents; ((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. */ @@ -610,38 +235,6 @@ elf32_hppa_stub_hash_table_init (table, stub_bfd, newfunc) 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). */ @@ -663,7 +256,6 @@ elf32_hppa_link_hash_table_create (abfd) 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; @@ -851,7 +443,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, { if (!((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; break; } @@ -870,13 +462,6 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -894,7 +479,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_notsupported: if (!((*info->callbacks->undefined_symbol) (info, "$global$", input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; return false; case bfd_reloc_dangerous: @@ -937,286 +522,6 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, 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. */ @@ -1226,7 +531,7 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, addend, info, sym_sec, sym_name, is_local) reloc_howto_type *howto; bfd *input_bfd; - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; asection *input_section; bfd_byte *contents; bfd_vma offset; @@ -1329,10 +634,7 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, 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; + unsigned int len; char *new_name, *stub_name; /* Get the field selector right. We'll need it in a minute. */ @@ -1349,8 +651,6 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, 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; @@ -1363,32 +663,9 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, 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)) + || ((int)(value - location) < (int)0xfffc0000)) { struct elf32_hppa_stub_hash_table *stub_hash_table; struct elf32_hppa_stub_hash_entry *stub_hash; @@ -1401,8 +678,7 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, 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); + elf32_hppa_name_of_stub (location, value, stub_name); strcat (stub_name, new_name); free (new_name); @@ -1420,7 +696,6 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, if (stub_hash != NULL) { - if (r_type == R_PARISC_PCREL17F) { unsigned long delay_insn; @@ -1492,28 +767,9 @@ elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, 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; + else + return bfd_reloc_notsupported; + } } goto do_basic_type_1; } @@ -1534,712 +790,51 @@ do_basic_type_1: return (bfd_reloc_ok); } -/* Return the address of the howto table entry to perform the CODE - relocation for an ARCH machine. */ +/* Undo the generic ELF code's subtraction of section->vma from the + value of each external symbol. */ -static reloc_howto_type * -elf_hppa_reloc_type_lookup (abfd, code) - bfd *abfd; - bfd_reloc_code_real_type code; +static boolean +elf32_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + const Elf_Internal_Sym *sym ATTRIBUTE_UNUSED; + const char **namep ATTRIBUTE_UNUSED; + flagword *flagsp ATTRIBUTE_UNUSED; + asection **secp; + bfd_vma *valp; { - 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; + *valp += (*secp)->vma; + return true; } -/* Return true if SYM represents a local label symbol. */ +/* 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 boolean -hppa_elf_is_local_label_name (abfd, name) - bfd *abfd; - const char *name; +static void +elf32_hppa_name_of_stub (location, destination, stub_name) + bfd_vma location ATTRIBUTE_UNUSED; + bfd_vma destination ATTRIBUTE_UNUSED; + char *stub_name; { - return (name[0] == 'L' && name[1] == '$'); + strcpy (stub_name, "_____long_branch_stub_"); } -/* 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. */ +/* 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; +elf32_hppa_size_of_stub (location, destination, sym_name) 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. */ + /* Determine if a long branch stub is needed. */ if (!(((int)(location - destination) > 0x3ffff) - || ((int)(location - destination) < (int)0xfffc0000) - || elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types))) + || ((int)(location - destination) < (int)0xfffc0000))) 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) + if (!strncmp ("$$", sym_name, 2) && strcmp ("$$dyncall", sym_name)) return 12; else @@ -2280,131 +875,7 @@ elf32_hppa_build_one_stub (gen_entry, in_args) + 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 + if (1) { /* Create one of two variant long branch stubs. One for $$dyncall and normal calls, the other for calls to millicode. */ @@ -2498,17 +969,15 @@ elf32_hppa_build_stubs (stub_bfd, info) boolean elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) bfd *stub_bfd; - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; 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; + Elf_Internal_Sym *local_syms, **all_local_syms; 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 *) @@ -2520,19 +989,8 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) 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; @@ -2540,88 +998,6 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) 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; @@ -2721,11 +1097,10 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) irelaend = irela + section->reloc_count; for (; irela < irelaend; irela++) { - long r_type, callee_args, caller_args, size_of_stub; + long r_type, 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; @@ -2821,24 +1196,6 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) } } - 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 @@ -2851,9 +1208,7 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) /* 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, + size_of_stub = elf32_hppa_size_of_stub (location, destination, sym_name); if (size_of_stub != 0) @@ -2880,8 +1235,7 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) free (all_local_syms); goto error_return; } - elf32_hppa_name_of_stub (caller_args, callee_args, - location, destination, stub_name); + elf32_hppa_name_of_stub (location, destination, stub_name); strcat (stub_name + 22, sym_name); /* Because sym_name was malloced above for local symbols. */ @@ -2945,11 +1299,6 @@ error_return: 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. */ @@ -2959,25 +1308,17 @@ error_return: /* 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 +#define bfd_elf32_bfd_is_local_label_name elf_hppa_is_local_label_name +#define elf_info_to_howto elf_hppa_info_to_howto +#define elf_info_to_howto_rel elf_hppa_info_to_howto_rel /* 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 elf_backend_fake_sections elf_hppa_fake_sections + #define TARGET_BIG_SYM bfd_elf32_hppa_vec #define TARGET_BIG_NAME "elf32-hppa" diff --git a/bfd/elf32-hppa.h b/bfd/elf32-hppa.h index b233920..915fc13 100644 --- a/bfd/elf32-hppa.h +++ b/bfd/elf32-hppa.h @@ -35,32 +35,29 @@ #include "libhppa.h" #include "elf/hppa.h" -#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1 -#define N_PARISC_RELOCS R_PARISC_UNIMPLEMENTED + 1 +boolean elf32_hppa_size_stubs + PARAMS ((bfd *, bfd *, struct bfd_link_info *)); + +boolean elf32_hppa_build_stubs + PARAMS ((bfd *, struct bfd_link_info *)); + +extern elf_hppa_reloc_type ** _bfd_elf32_hppa_gen_reloc_type + PARAMS ((bfd *, elf_hppa_reloc_type, int, int, int, asymbol *)); /* 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. + 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 + 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 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-i370.c b/bfd/elf32-i370.c new file mode 100644 index 0000000..c8bf943 --- /dev/null +++ b/bfd/elf32-i370.c @@ -0,0 +1,1742 @@ +/* i370-specific support for 32-bit ELF + Copyright 1994, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + Hacked by Linas Vepstas for i370 linas@linas.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. */ + + + +/* This file is based on a preliminary PowerPC ELF ABI. + But its been hacked on for the IBM 360/370 architectures. + Basically, the 31bit relocation works, and just about everything + else is a wild card. In particular, don't expect shared libs or + dynamic loading to work ... its never been tested ... +*/ + + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libbfd.h" +#include "elf-bfd.h" +#include "elf/i370.h" + +#define USE_RELA /* we want RELA relocations, not REL */ + +/* i370 relocations */ +/* Note that there is really just one relocation that we currently + * support (and only one that we seem to need, at the moment), and + * that is the 31-bit address relocation. Note that the 370/390 + * only supports a 31-bit (2GB) address space. + */ +enum i370_reloc_type +{ + R_I370_NONE = 0, + R_I370_ADDR31 = 1, + R_I370_ADDR32 = 2, + R_I370_ADDR16 = 3, + R_I370_REL31 = 4, + R_I370_REL32 = 5, + R_I370_ADDR12 = 6, + R_I370_REL12 = 7, + R_I370_ADDR8 = 8, + R_I370_REL8 = 9, + R_I370_COPY = 10, + R_I370_RELATIVE = 11, + + R_I370_max +}; + + +static reloc_howto_type *i370_elf_howto_table[ (int)R_I370_max ]; + +static reloc_howto_type i370_elf_howto_raw[] = +{ + /* This reloc does nothing. */ + HOWTO (R_I370_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_I370_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* A standard 31 bit relocation. */ + HOWTO (R_I370_ADDR31, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 31, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_I370_ADDR31", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x7fffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A standard 32 bit relocation. */ + HOWTO (R_I370_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_I370_ADDR32", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A standard 16 bit relocation. */ + HOWTO (R_I370_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_I370_ADDR16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 31-bit PC relative */ + HOWTO (R_I370_REL31, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 31, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_I370_REL31", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x7fffffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* 32-bit PC relative */ + HOWTO (R_I370_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_I370_REL32", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A standard 12 bit relocation. */ + HOWTO (R_I370_ADDR12, /* type */ + 0, /* rightshift */ + 1, /* 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_I370_ADDR12", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xfff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 12-bit PC relative */ + HOWTO (R_I370_REL12, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_I370_REL12", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xfff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A standard 8 bit relocation. */ + HOWTO (R_I370_ADDR8, /* 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_I370_ADDR8", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 8-bit PC relative */ + HOWTO (R_I370_REL8, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 8, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_I370_REL8", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xff, /* 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_I370_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_I370_COPY", /* 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_I370_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_I370_RELATIVE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + +}; + + +static void i370_elf_howto_init PARAMS ((void)); +static void i370_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr, + Elf32_Internal_Rela *dst)); +static boolean i370_elf_set_private_flags PARAMS ((bfd *, flagword)); + + +/* Initialize the i370_elf_howto_table, so that linear accesses can be done. */ + +static void +i370_elf_howto_init () +{ + unsigned int i, type; + + for (i = 0; i < sizeof (i370_elf_howto_raw) / sizeof (i370_elf_howto_raw[0]); i++) + { + type = i370_elf_howto_raw[i].type; + BFD_ASSERT (type < sizeof(i370_elf_howto_table) / sizeof(i370_elf_howto_table[0])); + i370_elf_howto_table[type] = &i370_elf_howto_raw[i]; + } +} + + +static reloc_howto_type * +i370_elf_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + enum i370_reloc_type i370_reloc = R_I370_NONE; + + if (!i370_elf_howto_table[ R_I370_ADDR31 ]) /* Initialize howto table if needed */ + i370_elf_howto_init (); + + switch ((int)code) + { + default: + return (reloc_howto_type *)NULL; + + case BFD_RELOC_NONE: i370_reloc = R_I370_NONE; break; + case BFD_RELOC_32: i370_reloc = R_I370_ADDR31; break; + case BFD_RELOC_16: i370_reloc = R_I370_ADDR16; break; + case BFD_RELOC_32_PCREL: i370_reloc = R_I370_REL31; break; + case BFD_RELOC_CTOR: i370_reloc = R_I370_ADDR31; break; + case BFD_RELOC_I370_D12: i370_reloc = R_I370_ADDR12; break; + } + + return i370_elf_howto_table[ (int)i370_reloc ]; +}; + +static boolean i370_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *)); +static boolean i370_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); + +static boolean i370_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 i370_elf_create_dynamic_sections PARAMS ((bfd *, + struct bfd_link_info *)); + +static boolean i370_elf_section_from_shdr PARAMS ((bfd *, + Elf32_Internal_Shdr *, + char *)); +static boolean i370_elf_fake_sections PARAMS ((bfd *, + Elf32_Internal_Shdr *, + asection *)); +#if 0 +static elf_linker_section_t *i370_elf_create_linker_section + PARAMS ((bfd *abfd, + struct bfd_link_info *info, + enum elf_linker_section_enum)); +#endif +static boolean i370_elf_check_relocs PARAMS ((bfd *, + struct bfd_link_info *, + asection *, + const Elf_Internal_Rela *)); + +static boolean i370_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *, + struct elf_link_hash_entry *)); + +static boolean i370_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR)); + +static boolean i370_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); + +static boolean i370_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); + +/* The name of the dynamic interpreter. This is put in the .interp + section. */ + +#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so" + + +/* Set the howto pointer for an i370 ELF reloc. */ + +static void +i370_elf_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr; + Elf32_Internal_Rela *dst; +{ + if (!i370_elf_howto_table[ R_I370_ADDR31 ]) /* Initialize howto table */ + i370_elf_howto_init (); + + BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_I370_max); + cache_ptr->howto = i370_elf_howto_table[ELF32_R_TYPE (dst->r_info)]; +} + +/* hack alert -- the following several routines look generic to me ... + * why are we bothering with them ??? + */ +/* Function to set whether a module needs the -mrelocatable bit set. */ +static boolean +i370_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 +i370_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 +i370_elf_merge_private_bfd_data (ibfd, obfd) + bfd *ibfd; + bfd *obfd; +{ + flagword old_flags; + flagword new_flags; + + 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 */ + { + (*_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); + + bfd_set_error (bfd_error_bad_value); + return false; + } + + return true; +} + + +/* Handle an i370 specific section when reading an object file. This + is called when elfcode.h finds a section with an unknown type. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + + +static boolean +i370_elf_fake_sections (abfd, shdr, asect) + bfd *abfd ATTRIBUTE_UNUSED; + 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; +} + + +#if 0 +/* Create a special linker section */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static elf_linker_section_t * +i370_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; +} +#endif + +/* 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). */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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; + } + + /* xxx beats me, seem to need a rela.text ... */ + s = bfd_make_section (abfd, ".rela.text"); + 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. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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; + +#ifdef DEBUG + fprintf (stderr, "i370_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))); + + + s = bfd_get_section_by_name (dynobj, ".rela.text"); + BFD_ASSERT (s != NULL); + s->_raw_size += sizeof (Elf32_External_Rela); + + /* 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_I370_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. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_elf_adjust_dynindx (h, cparg) + struct elf_link_hash_entry *h; + PTR cparg; +{ + int *cp = (int *) cparg; + +#ifdef DEBUG + fprintf (stderr, + "i370_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. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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, "i370_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) + { + 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 i370_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), + i370_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. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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; + const Elf_Internal_Rela *rel; + const Elf_Internal_Rela *rel_end; + bfd_vma *local_got_offsets; + asection *sreloc; + + if (info->relocateable) + return true; + +#ifdef DEBUG + fprintf (stderr, "i370_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); + local_got_offsets = elf_local_got_offsets (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]; + + if (info->shared) + { +#ifdef DEBUG + fprintf (stderr, + "i370_elf_check_relocs needs to create relocation for %s\n", + (h && h->root.root.string) + ? h->root.root.string : ""); +#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. */ + } + } + + return true; +} + + +/* Finish up the dynamic sections. */ +/* XXX hack alert bogus This routine is mostly all junk and almost + * certainly does the wrong thing. Its here simply because it does + * just enough to allow glibc-2.1 ld.so to compile & link. + */ + +static boolean +i370_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, "i370_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_. */ +/* XXX this is clearly very wrong for the 370 arch */ + 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 +i370_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_Internal_Rela *rel = relocs; + Elf_Internal_Rela *relend = relocs + input_section->reloc_count; + asection *sreloc = NULL; + bfd_vma *local_got_offsets; + boolean ret = true; + +#ifdef DEBUG + fprintf (stderr, "i370_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 (!i370_elf_howto_table[ R_I370_ADDR31 ]) /* Initialize howto table if needed */ + i370_elf_howto_init (); + + local_got_offsets = elf_local_got_offsets (input_bfd); + + for (; rel < relend; rel++) + { + enum i370_reloc_type r_type = (enum i370_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_I370_max + || !i370_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 = i370_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 = ""; + + 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 (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_I370_ADDR31 + || r_type == R_I370_COPY + || r_type == R_I370_ADDR16 + || r_type == R_I370_RELATIVE)) + { + /* 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) + relocation = 0; + else + { + (*info->callbacks->undefined_symbol)(info, + h->root.root.string, + input_bfd, + input_section, + rel->r_offset, + true); + 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 may need to be propagated if this is a shared + object. */ + case (int)R_I370_REL31: + /* 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_I370_NONE: + case (int)R_I370_ADDR31: + case (int)R_I370_ADDR16: + if (info->shared) + { + Elf_Internal_Rela outrel; + boolean skip; + +#ifdef DEBUG + fprintf (stderr, + "i370_elf_relocate_section needs to create relocation for %s\n", + (h && h->root.root.string) ? h->root.root.string : ""); +#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_I370_ADDR31) + { + outrel.r_info = ELF32_R_INFO (0, R_I370_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_I370_RELATIVE) + continue; + } + break; + + case (int)R_I370_COPY: + case (int)R_I370_RELATIVE: + (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.", + bfd_get_filename (input_bfd), + i370_elf_howto_table[ (int)r_type ]->name, + sym_name); + + bfd_set_error (bfd_error_invalid_operation); + ret = false; + 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; +} + +static void +i370_elf_post_process_headers (abfd, link_info) + bfd * abfd; + struct bfd_link_info * link_info ATTRIBUTE_UNUSED; +{ + Elf_Internal_Ehdr * i_ehdrp; /* Elf file header, internal form */ + + i_ehdrp = elf_elfheader (abfd); + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX; +} + +#define TARGET_BIG_SYM bfd_elf32_i370_vec +#define TARGET_BIG_NAME "elf32-i370" +#define ELF_ARCH bfd_arch_i370 +#define ELF_MACHINE_CODE EM_S370 +#ifdef EM_I370_OLD +#define ELF_MACHINE_ALT1 EM_I370_OLD +#endif +#define ELF_MAXPAGESIZE 0x1000 +#define elf_info_to_howto i370_elf_info_to_howto + + + +#define elf_backend_plt_not_loaded 1 +#define elf_backend_got_symbol_offset 4 + +#define bfd_elf32_bfd_reloc_type_lookup i370_elf_reloc_type_lookup +#define bfd_elf32_bfd_set_private_flags i370_elf_set_private_flags +#define bfd_elf32_bfd_copy_private_bfd_data i370_elf_copy_private_bfd_data +#define bfd_elf32_bfd_merge_private_bfd_data i370_elf_merge_private_bfd_data +#define elf_backend_relocate_section i370_elf_relocate_section + +/* dynamic loader support is mostly broken; just enough here to be able to + * link glibc's ld.so without errors. + */ +#define elf_backend_create_dynamic_sections i370_elf_create_dynamic_sections +#define elf_backend_size_dynamic_sections i370_elf_size_dynamic_sections +#define elf_backend_finish_dynamic_sections i370_elf_finish_dynamic_sections +#define elf_backend_fake_sections i370_elf_fake_sections +#define elf_backend_section_from_shdr i370_elf_section_from_shdr +#define elf_backend_adjust_dynamic_symbol i370_elf_adjust_dynamic_symbol +#define elf_backend_check_relocs i370_elf_check_relocs + +/* +#define elf_backend_add_symbol_hook i370_elf_add_symbol_hook +#define elf_backend_finish_dynamic_symbol i370_elf_finish_dynamic_symbol +#define elf_backend_additional_program_headers i370_elf_additional_program_headers +#define elf_backend_modify_segment_map i370_elf_modify_segment_map +*/ + +#define elf_backend_post_process_headers i370_elf_post_process_headers + +int i370_noop() +{ + return 1; +} + +/* we need to define these at least as no-ops to link glibc ld.so */ + +#define elf_backend_add_symbol_hook \ + (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \ + const Elf_Internal_Sym *, const char **, flagword *, \ + asection **, bfd_vma *))) i370_noop +#define elf_backend_finish_dynamic_symbol \ + (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \ + struct elf_link_hash_entry *, \ + Elf_Internal_Sym *))) i370_noop +#define elf_backend_additional_program_headers \ + (int (*) PARAMS ((bfd *))) i370_noop +#define elf_backend_modify_segment_map \ + (boolean (*) PARAMS ((bfd *))) i370_noop + +#include "elf32-target.h" diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 830c680..90efba8 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1,5 +1,5 @@ /* Intel 80386/80486-specific support for 32-bit ELF - Copyright 1993-1998, 1999 Free Software Foundation, Inc. + Copyright 1993, 94-98, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -67,20 +67,20 @@ static reloc_howto_type elf_howto_table[]= 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 }, + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + EMPTY_HOWTO (13), + EMPTY_HOWTO (14), + EMPTY_HOWTO (15), + EMPTY_HOWTO (16), + EMPTY_HOWTO (17), + EMPTY_HOWTO (18), + EMPTY_HOWTO (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), + HOWTO(R_386_PC8, 0,0,8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc,"R_386_PC8", true,0xff,0xff,true), }; /* GNU extension to record C++ vtable hierarchy. */ @@ -123,7 +123,7 @@ static reloc_howto_type elf32_i386_vtentry_howto = static reloc_howto_type * elf_i386_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { switch (code) @@ -211,16 +211,16 @@ elf_i386_reloc_type_lookup (abfd, code) static void elf_i386_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; - arelent *cache_ptr; - Elf32_Internal_Rela *dst; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr ATTRIBUTE_UNUSED; + Elf32_Internal_Rela *dst ATTRIBUTE_UNUSED; { abort (); } static void elf_i386_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rel *dst; { @@ -231,11 +231,14 @@ elf_i386_info_to_howto_rel (abfd, cache_ptr, dst) cache_ptr->howto = &elf32_i386_vtinherit_howto; else if (type == R_386_GNU_VTENTRY) cache_ptr->howto = &elf32_i386_vtentry_howto; + else if (type < R_386_max + && (type < FIRST_INVALID_RELOC || type > LAST_INVALID_RELOC)) + cache_ptr->howto = &elf_howto_table[(int) type]; 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]; + (*_bfd_error_handler) (_("%s: invalid relocation type %d"), + bfd_get_filename (abfd), (int) type); + cache_ptr->howto = &elf_howto_table[(int) R_386_NONE]; } } @@ -591,6 +594,9 @@ elf_i386_check_relocs (abfd, info, sec, relocs) case R_386_32: case R_386_PC32: + if (h != NULL) + h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + /* 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 @@ -714,7 +720,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs) static asection * elf_i386_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -760,10 +766,10 @@ elf_i386_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { /* ??? It would seem that the existing i386 code does no sort of reference counting or whatnot on its GOT and PLT entries, @@ -889,6 +895,11 @@ elf_i386_adjust_dynamic_symbol (info, h) if (info->shared) return true; + /* If there are no references to this symbol that do not use the + GOT, we don't need to generate a copy reloc. */ + if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) + 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 @@ -1077,7 +1088,7 @@ elf_i386_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } @@ -1139,7 +1150,7 @@ elf_i386_size_dynamic_sections (output_bfd, info) static boolean elf_i386_discard_copies (h, ignore) struct elf_i386_link_hash_entry *h; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { struct elf_i386_pcrel_relocs_copied *s; @@ -1308,7 +1319,8 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index a8537a7..6a2d2d9 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -25,9 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 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 +#define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */ #include "elf32-target.h" diff --git a/bfd/elf32-i960.c b/bfd/elf32-i960.c new file mode 100644 index 0000000..839fc3d --- /dev/null +++ b/bfd/elf32-i960.c @@ -0,0 +1,168 @@ +/* Intel 860 specific support for 32-bit ELF + 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" +#include "libbfd.h" +#include "elf-bfd.h" +#include "elf/i960.h" + +static bfd_reloc_status_type elf32_i960_relocate + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *elf32_i960_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); + +#define USE_REL 1 + +#define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup +#define elf_info_to_howto elf32_i960_info_to_howto +#define elf_info_to_howto_rel elf32_i960_info_to_howto_rel + +static reloc_howto_type elf_howto_table[]= +{ + HOWTO(R_960_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, + elf32_i960_relocate, "R_960_NONE", true, + 0x00000000, 0x00000000, false), + EMPTY_HOWTO (1), + HOWTO (R_960_32, 0, 2, 32, false, 0, complain_overflow_bitfield, + elf32_i960_relocate, "R_960_32", true, + 0xffffffff, 0xffffffff, false), + HOWTO (R_960_IP24, 0, 2, 24, true, 0, complain_overflow_signed, + elf32_i960_relocate, "R_960_IP24 ", true, + 0x00ffffff, 0x00ffffff, false), + EMPTY_HOWTO (4), + EMPTY_HOWTO (5), + EMPTY_HOWTO (6), + EMPTY_HOWTO (7) +}; + +static enum elf_i960_reloc_type +elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code) +{ + switch (code) + { + default: + return R_960_NONE; + case BFD_RELOC_I960_CALLJ: + return R_960_OPTCALL; + case BFD_RELOC_32: + case BFD_RELOC_CTOR: + return R_960_32; + case BFD_RELOC_24_PCREL: + return R_960_IP24; + } +} + +static void +elf32_i960_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr ATTRIBUTE_UNUSED; + Elf32_Internal_Rela *dst ATTRIBUTE_UNUSED; +{ + abort (); +} + +static void +elf32_i960_info_to_howto_rel (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr; + Elf32_Internal_Rel *dst; +{ + enum elf_i960_reloc_type type; + + type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (type < R_960_max); + + cache_ptr->howto = &elf_howto_table[(int) type]; +} + +/* 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 +elf32_i960_relocate (abfd, + reloc_entry, + symbol, + data, + input_section, + output_bfd, + error_message) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry; + asymbol *symbol; + PTR data ATTRIBUTE_UNUSED; + asection *input_section; + bfd *output_bfd; + char **error_message ATTRIBUTE_UNUSED; +{ + /* HACK: I think this first condition is necessary when producing + relocatable output. After the end of HACK, the code is identical + to bfd_elf_generic_reloc(). I would _guess_ the first change + belongs there rather than here. martindo 1998-10-23. */ + if (output_bfd != (bfd *) NULL + && reloc_entry->howto->pc_relative + && !reloc_entry->howto->pcrel_offset) + { + reloc_entry->addend -= symbol->value; + } + /* This is more dubious. */ + else if (output_bfd != (bfd *) NULL + && (symbol->flags & BSF_SECTION_SYM) != 0) + { + reloc_entry->addend -= symbol->section->output_section->vma; + } + else + { + /* end of HACK */ + 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; +} + +static reloc_howto_type * +elf32_i960_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + return elf_howto_table + elf32_i960_bfd_to_reloc_type (code); +} + +#define TARGET_LITTLE_SYM bfd_elf32_i960_vec +#define TARGET_LITTLE_NAME "elf32-i960" +#define ELF_ARCH bfd_arch_i960 +#define ELF_MACHINE_CODE EM_960 +#define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */ + +#include "elf32-target.h" diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index b2f8523..efb6555 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1,5 +1,5 @@ /* M32R-specific support for 32-bit ELF. - Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -35,6 +35,8 @@ static void m32r_elf_relocate_hi16 bfd_byte *, bfd_vma)); bfd_reloc_status_type m32r_elf_lo16_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +bfd_reloc_status_type m32r_elf_generic_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 @@ -105,7 +107,7 @@ static reloc_howto_type m32r_elf_howto_table[] = false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + m32r_elf_generic_reloc,/* special_function */ "R_M32R_16", /* name */ true, /* partial_inplace */ 0xffff, /* src_mask */ @@ -120,7 +122,7 @@ static reloc_howto_type m32r_elf_howto_table[] = false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + m32r_elf_generic_reloc,/* special_function */ "R_M32R_32", /* name */ true, /* partial_inplace */ 0xffffffff, /* src_mask */ @@ -135,7 +137,7 @@ static reloc_howto_type m32r_elf_howto_table[] = false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + m32r_elf_generic_reloc,/* special_function */ "R_M32R_24", /* name */ true, /* partial_inplace */ 0xffffff, /* src_mask */ @@ -301,7 +303,7 @@ m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data, PTR data; asection * input_section; bfd * output_bfd; - char ** error_message; + char ** error_message ATTRIBUTE_UNUSED; { /* This part is from bfd_elf_generic_reloc. */ if (output_bfd != (bfd *) NULL @@ -339,7 +341,7 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, asection *input_section; bfd_byte *data; bfd_vma offset; - asection *symbol_section; + asection *symbol_section ATTRIBUTE_UNUSED; bfd_vma symbol_value; bfd_vma addend; { @@ -403,13 +405,13 @@ 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; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_reloc_status_type ret; bfd_vma relocation; @@ -498,9 +500,9 @@ m32r_elf_relocate_hi16 (input_bfd, type, relhi, rello, contents, addend) R_M32R_HI16_[SU]LO relocation described above. */ bfd_reloc_status_type -m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, +m32r_elf_lo16_reloc (input_bfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *input_bfd; arelent *reloc_entry; asymbol *symbol; PTR data; @@ -508,6 +510,17 @@ m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, bfd *output_bfd; char **error_message; { + /* 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; + } + if (m32r_hi16_list != NULL) { struct m32r_hi16 *l; @@ -523,8 +536,8 @@ m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, /* 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) + insn = bfd_get_32 (input_bfd, l->addr); + vallo = ((bfd_get_32 (input_bfd, (bfd_byte *) data + reloc_entry->address) & 0xffff) ^ 0x8000) - 0x8000; val = ((insn & 0xffff) << 16) + vallo; val += l->addend; @@ -534,7 +547,7 @@ m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, val += 0x10000; insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); - bfd_put_32 (abfd, insn, l->addr); + bfd_put_32 (input_bfd, insn, l->addr); next = l->next; free (l); @@ -544,11 +557,106 @@ m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, m32r_hi16_list = NULL; } - /* Now do the LO16 reloc in the usual way. */ - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + /* Now do the LO16 reloc in the usual way. + ??? It would be nice to call bfd_elf_generic_reloc here, + but we have partial_inplace == TRUE. bfd_elf_generic_reloc will + pass the handling back to bfd_install_relocation which will install + a section relative addend which is wrong. */ + return m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); } +/* Do generic partial_inplace relocation. + This is a local replacement for bfd_elf_generic_reloc. */ + +bfd_reloc_status_type +m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *input_bfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_reloc_status_type ret; + bfd_vma relocation; + bfd_byte *inplace_address; + + /* 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; + } + + /* Now do the the reloc in the usual way. + ??? It would be nice to call bfd_elf_generic_reloc here, + but we have partial_inplace == TRUE. bfd_elf_generic_reloc will + pass the handling back to bfd_install_relocation which will install + a section relative addend which is wrong. */ + + /* 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) + || output_bfd != (bfd *) NULL) + relocation = 0; + else + relocation = symbol->value; + + /* Only do this for a final link. */ + if (output_bfd == (bfd *) NULL) + { + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + } + + relocation += reloc_entry->addend; + inplace_address = data + reloc_entry->address; + +#define DOIT(x) \ + x = ( (x & ~reloc_entry->howto->dst_mask) | \ + (((x & reloc_entry->howto->src_mask) + relocation) & \ + reloc_entry->howto->dst_mask)) + + switch (reloc_entry->howto->size) + { + case 1: + { + short x = bfd_get_16 (input_bfd, inplace_address); + DOIT (x); + bfd_put_16 (input_bfd, x, inplace_address); + } + break; + case 2: + { + unsigned long x = bfd_get_32 (input_bfd, inplace_address); + DOIT (x); + bfd_put_32 (input_bfd, x, inplace_address); + } + break; + default: + BFD_ASSERT (0); + } + + if (output_bfd != (bfd *) NULL) + reloc_entry->address += input_section->output_offset; + + return ret; +} + /* 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. @@ -558,13 +666,13 @@ m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, static bfd_reloc_status_type m32r_elf_sda16_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { /* This part is from bfd_elf_generic_reloc. */ if (output_bfd != (bfd *) NULL @@ -614,7 +722,7 @@ static const struct m32r_reloc_map m32r_reloc_map[] = static reloc_howto_type * bfd_elf32_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -634,7 +742,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) static void m32r_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rel *dst; { @@ -650,8 +758,8 @@ m32r_info_to_howto_rel (abfd, cache_ptr, dst) boolean _bfd_m32r_elf_section_from_bfd_section (abfd, hdr, sec, retval) - bfd *abfd; - Elf32_Internal_Shdr *hdr; + bfd *abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; asection *sec; int *retval; { @@ -677,7 +785,7 @@ static asymbol *m32r_elf_scom_symbol_ptr; void _bfd_m32r_elf_symbol_processing (abfd, asym) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asymbol *asym; { elf_symbol_type *elfsym; @@ -717,7 +825,7 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) struct bfd_link_info *info; const Elf_Internal_Sym *sym; const char **namep; - flagword *flagsp; + flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; bfd_vma *valp; { @@ -850,7 +958,7 @@ m32r_elf_final_sda_base (output_bfd, info, error_message, psb) static boolean m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -1018,7 +1126,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, offset))) + input_section, offset, true))) return false; relocation = 0; } @@ -1149,7 +1257,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, case bfd_reloc_undefined: if (! ((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - offset))) + offset, true))) return false; break; @@ -1793,6 +1901,7 @@ m32r_elf_object_p (abfd) { default: case E_M32R_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_m32r, bfd_mach_m32r); break; + case E_M32RX_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_m32r, bfd_mach_m32rx); break; } return true; } @@ -1801,7 +1910,7 @@ m32r_elf_object_p (abfd) static void m32r_elf_final_write_processing (abfd, linker) bfd * abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { unsigned long val; @@ -1809,6 +1918,7 @@ m32r_elf_final_write_processing (abfd, linker) { default: case bfd_mach_m32r: val = E_M32R_ARCH; break; + case bfd_mach_m32rx: val = E_M32RX_ARCH; break; } elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH; @@ -1926,6 +2036,7 @@ m32r_elf_print_private_bfd_data (abfd, ptr) { default: case E_M32R_ARCH: fprintf (file, _(": m32r instructions")); break; + case E_M32RX_ARCH: fprintf (file, _(": m32rx instructions")); break; } fputc ('\n', file); @@ -1936,7 +2047,7 @@ m32r_elf_print_private_bfd_data (abfd, ptr) asection * m32r_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -1958,6 +2069,9 @@ m32r_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -1976,10 +2090,10 @@ m32r_elf_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { /* we don't use got and plt entries for m32r */ return true; @@ -2049,7 +2163,7 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) #define ELF_ARCH bfd_arch_m32r #define ELF_MACHINE_CODE EM_CYGNUS_M32R -#define ELF_MAXPAGESIZE 0x1000 +#define ELF_MAXPAGESIZE 0x1 /* Explicitly requested by Mitsubishi. */ #define TARGET_BIG_SYM bfd_elf32_m32r_vec #define TARGET_BIG_NAME "elf32-m32r" diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 2d0aba2..cc62230 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -43,8 +43,6 @@ static boolean elf_m68k_gc_sweep_hook 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 @@ -56,6 +54,15 @@ static boolean elf_m68k_finish_dynamic_symbol static boolean elf_m68k_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +static boolean elf32_m68k_set_private_flags + PARAMS ((bfd *, flagword)); +static boolean elf32_m68k_copy_private_bfd_data + PARAMS ((bfd *, bfd *)); +static boolean elf32_m68k_merge_private_bfd_data + PARAMS ((bfd *, bfd *)); +static boolean elf32_m68k_print_private_bfd_data + PARAMS ((bfd *, PTR)); + 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), @@ -112,7 +119,7 @@ static reloc_howto_type howto_table[] = { static void rtype_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf_Internal_Rela *dst; { @@ -157,7 +164,7 @@ static const struct static reloc_howto_type * reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -211,6 +218,33 @@ static const bfd_byte elf_m68k_plt_entry[PLT_ENTRY_SIZE] = 0, 0, 0, 0 /* replaced with offset to start of .plt. */ }; +#define CPU32_FLAG(abfd) (elf_elfheader (abfd)->e_flags & EF_CPU32) + +#define PLT_CPU32_ENTRY_SIZE 24 +/* Procedure linkage table entries for the cpu32 */ +static const bfd_byte elf_cpu32_plt0_entry[PLT_CPU32_ENTRY_SIZE] = +{ + 0x22, 0x7b, 0x01, 0x70, /* moveal %pc@(0xc), %a1 */ + 0, 0, 0, 0, /* replaced with offset to .got + 4. */ + 0x4e, 0xd1, /* jmp %a1@ */ + 0, 0, 0, 0, /* replace with offset to .got +8. */ + 0, 0, 0, 0, /* pad out to 24 bytes. */ + 0, 0, 0, 0, /* pad out to 24 bytes. */ + 0, 0 +}; + +static const bfd_byte elf_cpu32_plt_entry[PLT_CPU32_ENTRY_SIZE] = +{ + 0x22, 0x7b, 0x01, 0x70, /* moveal %pc@(0xc), %a1 */ + 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */ + 0x4e, 0xd1, /* jmp %a1@ */ + 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. */ + 0, 0 +}; + /* 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 @@ -320,6 +354,88 @@ elf_m68k_link_hash_table_create (abfd) return &ret->root.root; } +/* Keep m68k-specific flags in the ELF header */ +static boolean +elf32_m68k_set_private_flags (abfd, flags) + bfd *abfd; + flagword flags; +{ + elf_elfheader (abfd)->e_flags = flags; + elf_flags_init (abfd) = true; + return true; +} + +/* Copy m68k-specific data from one module to another */ +static boolean +elf32_m68k_copy_private_bfd_data (ibfd, obfd) + bfd *ibfd; + bfd *obfd; +{ + 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; + + 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_m68k_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)) + { + elf_flags_init (obfd) = true; + elf_elfheader (obfd)->e_flags = in_flags; + } + + return true; +} + +/* Display the flags field */ +static boolean +elf32_m68k_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_CPU32) + fprintf (file, _ (" [cpu32]")); + + fputc ('\n', file); + + 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. */ @@ -673,7 +789,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) static asection * elf_m68k_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -731,8 +847,8 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, relocs) unsigned long r_symndx; struct elf_link_hash_entry *h; bfd *dynobj; - asection *sgot; - asection *srelgot; + asection *sgot = NULL; + asection *srelgot = NULL; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); @@ -890,7 +1006,12 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* 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 (CPU32_FLAG (dynobj)) + s->_raw_size += PLT_CPU32_ENTRY_SIZE; + else + 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 @@ -907,7 +1028,10 @@ elf_m68k_adjust_dynamic_symbol (info, h) h->plt.offset = s->_raw_size; /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + if (CPU32_FLAG (dynobj)) + s->_raw_size += PLT_CPU32_ENTRY_SIZE; + else + 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. */ @@ -1138,7 +1262,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } @@ -1186,51 +1310,6 @@ elf_m68k_size_dynamic_sections (output_bfd, info) } } - /* 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; } @@ -1244,7 +1323,7 @@ elf_m68k_adjust_dynindx (h, cparg) static boolean elf_m68k_discard_copies (h, ignore) struct elf_m68k_link_hash_entry *h; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { struct elf_m68k_pcrel_relocs_copied *s; @@ -1406,7 +1485,8 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, { if (!(info->callbacks->undefined_symbol (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } @@ -1776,6 +1856,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym) Elf_Internal_Sym *sym; { bfd *dynobj; + int plt_off1, plt_off2, plt_off3; dynobj = elf_hash_table (info)->dynobj; @@ -1802,16 +1883,35 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym) 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; + if ( CPU32_FLAG (output_bfd)) + plt_index = h->plt.offset / PLT_CPU32_ENTRY_SIZE - 1; + else + 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); + if ( CPU32_FLAG (output_bfd)) + { + /* Fill in the entry in the procedure linkage table. */ + memcpy (splt->contents + h->plt.offset, elf_cpu32_plt_entry, + PLT_CPU32_ENTRY_SIZE); + plt_off1 = 4; + plt_off2 = 12; + plt_off3 = 18; + } + else + { + /* Fill in the entry in the procedure linkage table. */ + memcpy (splt->contents + h->plt.offset, elf_m68k_plt_entry, + PLT_ENTRY_SIZE); + plt_off1 = 4; + plt_off2 = 10; + plt_off3 = 16; + } + /* The offset is relative to the first extension word. */ bfd_put_32 (output_bfd, (sgot->output_section->vma @@ -1819,12 +1919,12 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym) + got_offset - (splt->output_section->vma + h->plt.offset + 2)), - splt->contents + h->plt.offset + 4); + splt->contents + h->plt.offset + plt_off1); 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); + splt->contents + h->plt.offset + plt_off2); + bfd_put_32 (output_bfd, - (h->plt.offset + plt_off3), + splt->contents + h->plt.offset + plt_off3); /* Fill in the entry in the global offset table. */ bfd_put_32 (output_bfd, @@ -2017,21 +2117,39 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) /* 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); + if (!CPU32_FLAG (output_bfd)) + { + 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; + } + else /* cpu32 */ + { + memcpy (splt->contents, elf_cpu32_plt0_entry, PLT_CPU32_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 + 10); + elf_section_data (splt->output_section)->this_hdr.sh_entsize + = PLT_CPU32_ENTRY_SIZE; + } } - - elf_section_data (splt->output_section)->this_hdr.sh_entsize - = PLT_ENTRY_SIZE; } /* Fill in the first three entries in the global offset table. */ @@ -2049,50 +2167,6 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) 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; } @@ -2118,11 +2192,19 @@ elf_m68k_finish_dynamic_sections (output_bfd, info) 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 bfd_elf32_bfd_copy_private_bfd_data \ + elf32_m68k_copy_private_bfd_data +#define bfd_elf32_bfd_merge_private_bfd_data \ + elf32_m68k_merge_private_bfd_data +#define bfd_elf32_bfd_set_private_flags \ + elf32_m68k_set_private_flags +#define bfd_elf32_bfd_print_private_bfd_data \ + elf32_m68k_print_private_bfd_data + #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 index f3c535e..20de22a 100644 --- a/bfd/elf32-m88k.c +++ b/bfd/elf32-m88k.c @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_BIG_NAME "elf32-m88k" #define ELF_ARCH bfd_arch_m88k #define ELF_MACHINE_CODE EM_88K +#define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */ #define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup #define elf_info_to_howto _bfd_elf_no_info_to_howto diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index ef3a39f..5963a9e 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -1,4 +1,4 @@ -/* Motorolla MCore specific support for 32-bit ELF +/* Motorola 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. @@ -57,16 +57,16 @@ static reloc_howto_type mcore_elf_howto_raw[] = HOWTO (R_MCORE_NONE, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ - 1, /* bitsize */ - true, /* pc_relative */ + 32, /* bitsize */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - mcore_elf_unsupported_reloc, /* special_function */ + NULL, /* special_function */ "R_MCORE_NONE", /* name */ false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - true), /* pcrel_offset */ + false), /* pcrel_offset */ /* A standard 32 bit relocation. */ HOWTO (R_MCORE_ADDR32, /* type */ @@ -196,6 +196,20 @@ static reloc_howto_type mcore_elf_howto_raw[] = 0, /* src_mask */ 0, /* dst_mask */ false), /* pcrel_offset */ + + HOWTO (R_MCORE_RELATIVE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + NULL, /* special_function */ + "R_MCORE_RELATIVE", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false) /* pcrel_offset */ }; #ifndef NUM_ELEM @@ -223,7 +237,7 @@ mcore_elf_howto_init () static reloc_howto_type * mcore_elf_reloc_type_lookup (abfd, code) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { enum elf_mcore_reloc_type mcore_reloc = R_MCORE_NONE; @@ -239,6 +253,7 @@ mcore_elf_reloc_type_lookup (abfd, code) 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; + case BFD_RELOC_RVA: mcore_reloc = R_MCORE_RELATIVE; break; default: return (reloc_howto_type *)NULL; } @@ -252,7 +267,7 @@ mcore_elf_reloc_type_lookup (abfd, code) /* Set the howto pointer for a RCE ELF reloc. */ static void mcore_elf_info_to_howto (abfd, cache_ptr, dst) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; arelent * cache_ptr; Elf32_Internal_Rela * dst; { @@ -305,7 +320,6 @@ mcore_elf_merge_private_bfd_data (ibfd, obfd) { flagword old_flags; flagword new_flags; - boolean error; /* Check if we have the same endianess */ if ( ibfd->xvec->byteorder != obfd->xvec->byteorder @@ -335,7 +349,11 @@ mcore_elf_merge_private_bfd_data (ibfd, obfd) } else if (new_flags == old_flags) /* Compatible flags are ok */ ; - + else + { + /* FIXME */ + } + return true; } @@ -348,11 +366,11 @@ 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; + asymbol * symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection * input_section ATTRIBUTE_UNUSED; + bfd * output_bfd ATTRIBUTE_UNUSED; + char ** error_message ATTRIBUTE_UNUSED; { BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0); @@ -397,7 +415,7 @@ mcore_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section, static boolean mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections) - bfd * output_bfd; + bfd * output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info * info; bfd * input_bfd; asection * input_section; @@ -411,7 +429,6 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela * rel = relocs; Elf_Internal_Rela * relend = relocs + input_section->reloc_count; boolean ret = true; - long insn; #ifdef DEBUG fprintf (stderr, @@ -437,7 +454,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; + unsigned short oldinst = 0; /* Unknown relocation handling */ if ((unsigned) r_type >= (unsigned) R_MCORE_max @@ -521,7 +538,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; ret = false; @@ -532,9 +549,6 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, switch (r_type) { default: - case R_MCORE_PCRELIMM8BY4: - case R_MCORE_PCRELIMM11BY2: - case R_MCORE_PCRELIMM4BY2: break; case R_MCORE_PCRELJSR_IMM11BY2: @@ -609,7 +623,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, static asection * mcore_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd * abfd; - struct bfd_link_info * info; + struct bfd_link_info * info ATTRIBUTE_UNUSED; Elf_Internal_Rela * rel; struct elf_link_hash_entry * h; Elf_Internal_Sym * sym; @@ -631,6 +645,9 @@ mcore_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -652,10 +669,10 @@ mcore_elf_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd * abfd ATTRIBUTE_UNUSED; + struct bfd_link_info * info ATTRIBUTE_UNUSED; + asection * sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED; { return true; } diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 9f03262..d91bab9 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -3,6 +3,8 @@ Most of the information added by Ian Lance Taylor, Cygnus Support, . + N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC. + This file is part of BFD, the Binary File Descriptor library. @@ -41,106 +43,248 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define ECOFF_32 #include "ecoffswap.h" +/* 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 global symbol in the GOT with the lowest index in the dynamic + symbol table. */ + struct elf_link_hash_entry *global_gotsym; + /* The number of global .got entries. */ + unsigned int global_gotno; + /* The number of local .got entries. */ + unsigned int local_gotno; + /* The number of local .got entries we have used. */ + unsigned int assigned_gotno; +}; + +/* 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 R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 relocs against + this symbol. */ + unsigned int possibly_dynamic_relocs; + + /* The index of the first dynamic relocation (in the .rel.dyn + section) against this symbol. */ + unsigned int min_dyn_reloc_index; + + /* 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; +}; + 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 reloc_howto_type *mips_rtype_to_howto + PARAMS ((unsigned int)); static void mips_info_to_howto_rel PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); +static void mips_info_to_howto_rela + PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); 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 *)); +#if 0 +static void bfd_mips_elf_swap_msym_in + PARAMS ((bfd *, const Elf32_External_Msym *, Elf32_Internal_Msym *)); +#endif +static void bfd_mips_elf_swap_msym_out + PARAMS ((bfd *, const Elf32_Internal_Msym *, Elf32_External_Msym *)); 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 INLINE char* elf_mips_abi_name PARAMS ((bfd *)); 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; -}; +static asection *mips_elf_create_msym_section + PARAMS ((bfd *)); +static void mips_elf_irix6_finish_dynamic_symbol + PARAMS ((bfd *, const char *, Elf_Internal_Sym *)); +static bfd_vma mips_elf_sign_extend PARAMS ((bfd_vma, int)); +static boolean mips_elf_overflow_p PARAMS ((bfd_vma, int)); +static bfd_vma mips_elf_high PARAMS ((bfd_vma)); +static bfd_vma mips_elf_higher PARAMS ((bfd_vma)); +static bfd_vma mips_elf_highest PARAMS ((bfd_vma)); +static bfd_vma mips_elf_global_got_index + PARAMS ((bfd *, struct elf_link_hash_entry *)); +static bfd_vma mips_elf_local_got_index + PARAMS ((bfd *, struct bfd_link_info *, bfd_vma)); +static bfd_vma mips_elf_got_offset_from_index + PARAMS ((bfd *, bfd *, bfd_vma)); +static boolean mips_elf_record_global_got_symbol + PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *, + struct mips_got_info *)); +static bfd_vma mips_elf_got_page + PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, bfd_vma *)); +static const Elf_Internal_Rela *mips_elf_next_relocation + PARAMS ((unsigned int, const Elf_Internal_Rela *, + const Elf_Internal_Rela *)); +static bfd_reloc_status_type mips_elf_calculate_relocation + PARAMS ((bfd *, bfd *, asection *, struct bfd_link_info *, + const Elf_Internal_Rela *, bfd_vma, reloc_howto_type *, + Elf_Internal_Sym *, asection **, bfd_vma *, const char **, + boolean *)); +static bfd_vma mips_elf_obtain_contents + PARAMS ((reloc_howto_type *, const Elf_Internal_Rela *, bfd *, bfd_byte *)); +static boolean mips_elf_perform_relocation + PARAMS ((struct bfd_link_info *, reloc_howto_type *, + const Elf_Internal_Rela *, bfd_vma, + bfd *, asection *, bfd_byte *, boolean)); +static boolean mips_elf_assign_gp PARAMS ((bfd *, bfd_vma *)); +static boolean mips_elf_sort_hash_table_f + PARAMS ((struct mips_elf_link_hash_entry *, PTR)); +static boolean mips_elf_sort_hash_table + PARAMS ((struct bfd_link_info *, unsigned long)); +static asection * mips_elf_got_section PARAMS ((bfd *)); +static struct mips_got_info *mips_elf_got_info + PARAMS ((bfd *, asection **)); +static boolean mips_elf_local_relocation_p + PARAMS ((bfd *, const Elf_Internal_Rela *, asection **)); +static bfd_vma mips_elf_create_local_got_entry + PARAMS ((bfd *, struct mips_got_info *, asection *, bfd_vma)); +static bfd_vma mips_elf_got16_entry + PARAMS ((bfd *, struct bfd_link_info *, bfd_vma)); +static boolean mips_elf_create_dynamic_relocation + PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Rela *, + struct mips_elf_link_hash_entry *, asection *, + bfd_vma, bfd_vma *, asection *)); +static void mips_elf_allocate_dynamic_relocations + PARAMS ((bfd *, unsigned int)); +static boolean mips_elf_stub_section_p + PARAMS ((bfd *, asection *)); + +/* The level of IRIX compatibility we're striving for. */ + +typedef enum { + ict_none, + ict_irix5, + ict_irix6 +} irix_compat_t; + +/* Nonzero if ABFD is using the N32 ABI. */ + +#define ABI_N32_P(abfd) \ + ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0) + +/* Nonzero if ABFD is using the 64-bit ABI. FIXME: This is never + true, yet. */ +#define ABI_64_P(abfd) \ + ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0) + +/* What version of Irix we are trying to be compatible with. FIXME: + At the moment, we never generate "normal" MIPS ELF ABI executables; + we always use some version of Irix. */ + +#define IRIX_COMPAT(abfd) \ + ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5) + +/* Whether we are trying to be compatible with IRIX at all. */ + +#define SGI_COMPAT(abfd) \ + (IRIX_COMPAT (abfd) != ict_none) + +/* The name of the msym section. */ +#define MIPS_ELF_MSYM_SECTION_NAME(abfd) ".msym" + +/* The name of the srdata section. */ +#define MIPS_ELF_SRDATA_SECTION_NAME(abfd) ".srdata" + +/* The name of the options section. */ +#define MIPS_ELF_OPTIONS_SECTION_NAME(abfd) \ + (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.options" : ".options") + +/* The name of the stub section. */ +#define MIPS_ELF_STUB_SECTION_NAME(abfd) \ + (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.stubs" : ".stub") + +/* The name of the dynamic relocation section. */ +#define MIPS_ELF_REL_DYN_SECTION_NAME(abfd) ".rel.dyn" + +/* The size of an external REL relocation. */ +#define MIPS_ELF_REL_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->sizeof_rel) + +/* The size of an external dynamic table entry. */ +#define MIPS_ELF_DYN_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->sizeof_dyn) + +/* The size of a GOT entry. */ +#define MIPS_ELF_GOT_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->arch_size / 8) + +/* The size of a symbol-table entry. */ +#define MIPS_ELF_SYM_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->sizeof_sym) + +/* The default alignment for sections, as a power of two. */ +#define MIPS_ELF_LOG_FILE_ALIGN(abfd) \ + (get_elf_backend_data (abfd)->s->file_align == 8 ? 3 : 2) + +/* Get word-sized data. */ +#define MIPS_ELF_GET_WORD(abfd, ptr) \ + (ABI_64_P (abfd) ? bfd_get_64 (abfd, ptr) : bfd_get_32 (abfd, ptr)) + +/* Put out word-sized data. */ +#define MIPS_ELF_PUT_WORD(abfd, val, ptr) \ + (ABI_64_P (abfd) \ + ? bfd_put_64 (abfd, val, ptr) \ + : bfd_put_32 (abfd, val, ptr)) + +/* Add a dynamic symbol table-entry. */ +#ifdef BFD64 +#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \ + (ABI_64_P (elf_hash_table (info)->dynobj) \ + ? bfd_elf64_add_dynamic_entry (info, tag, val) \ + : bfd_elf32_add_dynamic_entry (info, tag, val)) +#else +#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \ + (ABI_64_P (elf_hash_table (info)->dynobj) \ + ? (abort (), false) \ + : bfd_elf32_add_dynamic_entry (info, tag, val)) +#endif /* The number of local .got entries we reserve. */ #define MIPS_RESERVED_GOTNO (2) @@ -148,9 +292,11 @@ struct mips_got_info /* 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) */ \ +#define STUB_LW(abfd) \ + (SGI_COMPAT (abfd) \ + ? (ABI_64_P (abfd) \ + ? 0xdf998010 /* ld t9,0x8010(gp) */ \ + : 0x8f998010) /* lw t9,0x8010(gp) */ \ : 0x8f998000) /* lw t9,0x8000(gp) */ #define STUB_MOVE 0x03e07825 /* move t7,ra */ #define STUB_JALR 0x0320f809 /* jal t9 */ @@ -297,6 +443,10 @@ static void bfd_elf32_swap_crinfo_out #define USE_REL 1 /* MIPS uses REL relocations instead of RELA */ +/* 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 elf_mips_howto_table[] = { /* No relocation. */ @@ -448,7 +598,7 @@ static reloc_howto_type elf_mips_howto_table[] = _bfd_mips_elf_got16_reloc, /* special_function */ "R_MIPS_GOT16", /* name */ false, /* partial_inplace */ - 0, /* src_mask */ + 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -465,10 +615,9 @@ static reloc_howto_type elf_mips_howto_table[] = true, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - false), /* pcrel_offset */ + true), /* 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) */ @@ -479,7 +628,7 @@ static reloc_howto_type elf_mips_howto_table[] = bfd_elf_generic_reloc, /* special_function */ "R_MIPS_CALL16", /* name */ false, /* partial_inplace */ - 0, /* src_mask */ + 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -500,9 +649,9 @@ static reloc_howto_type elf_mips_howto_table[] = /* The remaining relocs are defined on Irix 5, although they are not defined by the ABI. */ - { 13 }, - { 14 }, - { 15 }, + EMPTY_HOWTO (13), + EMPTY_HOWTO (14), + EMPTY_HOWTO (15), /* A 5 bit shift field. */ HOWTO (R_MIPS_SHIFT5, /* type */ @@ -536,26 +685,22 @@ static reloc_howto_type elf_mips_howto_table[] = 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. */ + /* A 64 bit relocation. */ HOWTO (R_MIPS_64, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ + 4, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* 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 */ + 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) */ @@ -571,7 +716,6 @@ static reloc_howto_type elf_mips_howto_table[] = 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) */ @@ -587,7 +731,6 @@ static reloc_howto_type elf_mips_howto_table[] = 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) */ @@ -603,7 +746,6 @@ static reloc_howto_type elf_mips_howto_table[] = 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) */ @@ -619,7 +761,6 @@ static reloc_howto_type elf_mips_howto_table[] = 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) */ @@ -634,21 +775,57 @@ static reloc_howto_type elf_mips_howto_table[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - /* 64 bit subtraction. Presumably not used in 32 bit ELF. */ - { R_MIPS_SUB }, + /* 64 bit subtraction. Used in the N32 ABI. */ + 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 */ /* Used to cause the linker to insert and delete instructions? */ - { R_MIPS_INSERT_A }, - { R_MIPS_INSERT_B }, - { R_MIPS_DELETE }, + EMPTY_HOWTO (R_MIPS_INSERT_A), + EMPTY_HOWTO (R_MIPS_INSERT_B), + EMPTY_HOWTO (R_MIPS_DELETE), + + /* Get the higher value of a 64 bit addend. */ + 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 higher values of a 64 bit addend. Presumably not used in - 32 bit ELF. */ - { R_MIPS_HIGHER }, - { R_MIPS_HIGHEST }, + /* Get the highest value of a 64 bit addend. */ + 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) */ @@ -664,7 +841,6 @@ static reloc_howto_type elf_mips_howto_table[] = 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) */ @@ -679,11 +855,41 @@ static reloc_howto_type elf_mips_howto_table[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - { R_MIPS_SCN_DISP }, - { R_MIPS_REL16 }, - { R_MIPS_ADD_IMMEDIATE }, - { R_MIPS_PJUMP }, - { R_MIPS_RELGOT } + /* Section displacement. */ + HOWTO (R_MIPS_SCN_DISP, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* 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 */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + EMPTY_HOWTO (R_MIPS_REL16), + EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE), + EMPTY_HOWTO (R_MIPS_PJUMP), + EMPTY_HOWTO (R_MIPS_RELGOT), + + /* Protected jump conversion. This is an optimization hint. No + relocation is required for correctness. */ + HOWTO (R_MIPS_JALR, /* 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_JALR", /* name */ + false, /* partial_inplace */ + 0x00000000, /* src_mask */ + 0x00000000, /* dst_mask */ + false), /* pcrel_offset */ }; /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This @@ -722,10 +928,7 @@ static reloc_howto_type elf_mips16_jump_howto = 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. */ +/* The reloc used for the mips16 gprel instruction. */ static reloc_howto_type elf_mips16_gprel_howto = HOWTO (R_MIPS16_GPREL, /* type */ 0, /* rightshift */ @@ -737,10 +940,91 @@ static reloc_howto_type elf_mips16_gprel_howto = mips16_gprel_reloc, /* special_function */ "R_MIPS16_GPREL", /* name */ true, /* partial_inplace */ + 0x07ff001f, /* src_mask */ + 0x07ff001f, /* dst_mask */ + false); /* pcrel_offset */ + + +/* GNU extensions for embedded-pic. */ +/* High 16 bits of symbol value, pc-relative. */ +static reloc_howto_type elf_mips_gnu_rel_hi16 = + HOWTO (R_MIPS_GNU_REL_HI16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_hi16_reloc, /* special_function */ + "R_MIPS_GNU_REL_HI16", /* name */ + true, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - false); /* pcrel_offset */ + true); /* pcrel_offset */ + +/* Low 16 bits of symbol value, pc-relative. */ +static reloc_howto_type elf_mips_gnu_rel_lo16 = + HOWTO (R_MIPS_GNU_REL_LO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_lo16_reloc, /* special_function */ + "R_MIPS_GNU_REL_LO16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true); /* pcrel_offset */ + +/* 16 bit offset for pc-relative branches. */ +static reloc_howto_type elf_mips_gnu_rel16_s2 = + HOWTO (R_MIPS_GNU_REL16_S2, /* 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_MIPS_GNU_REL16_S2", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true); /* pcrel_offset */ + +/* 64 bit pc-relative. */ +static reloc_howto_type elf_mips_gnu_pcrel64 = + HOWTO (R_MIPS_PC64, /* type */ + 0, /* rightshift */ + 4, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_MIPS_PC64", /* name */ + true, /* partial_inplace */ + MINUS_ONE, /* src_mask */ + MINUS_ONE, /* dst_mask */ + true); /* pcrel_offset */ +/* 32 bit pc-relative. */ +static reloc_howto_type elf_mips_gnu_pcrel32 = + HOWTO (R_MIPS_PC32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_MIPS_PC32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + true); /* pcrel_offset */ /* GNU extension to record C++ vtable hierarchy */ static reloc_howto_type elf_mips_gnu_vtinherit_howto = @@ -802,7 +1086,7 @@ _bfd_mips_elf_hi16_reloc (abfd, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; PTR data; @@ -1033,6 +1317,57 @@ _bfd_mips_elf_got16_reloc (abfd, abort (); } +/* Set the GP value for OUTPUT_BFD. Returns false if this is a + dangerous relocation. */ + +static boolean +mips_elf_assign_gp (output_bfd, pgp) + bfd *output_bfd; + bfd_vma *pgp; +{ + unsigned int count; + asymbol **sym; + unsigned int i; + + /* If we've already figured out what GP will be, just return it. */ + *pgp = _bfd_get_gp_value (output_bfd); + if (*pgp) + return true; + + count = bfd_get_symcount (output_bfd); + sym = bfd_get_outsymbols (output_bfd); + + /* The linker script will have created a symbol named `_gp' with the + appropriate value. */ + 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); + return false; + } + + return true; +} + /* 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 @@ -1065,42 +1400,11 @@ mips_elf_final_gp (output_bfd, symbol, relocateable, error_message, pgp) *pgp = symbol->section->output_section->vma + 0x4000; _bfd_set_gp_value (output_bfd, *pgp); } - else + else if (!mips_elf_assign_gp (output_bfd, pgp)) { - 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; - } + *error_message = + (char *) _("GP relative relocation when _gp not defined"); + return bfd_reloc_dangerous; } } @@ -1385,13 +1689,13 @@ mips32_64bit_reloc (abfd, reloc_entry, symbol, data, input_section, static bfd_reloc_status_type mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -1559,12 +1863,20 @@ elf_mips_mach (flags) return 0; } -/* Return printable name for ABI from flagword. */ +/* Return printable name for ABI. */ static INLINE char* -elf_mips_abi_name (flags) - flagword flags; +elf_mips_abi_name (abfd) + bfd *abfd; { + flagword flags; + + if (ABI_N32_P (abfd)) + return "N32"; + else if (ABI_64_P (abfd)) + return "64"; + + flags = elf_elfheader (abfd)->e_flags; switch (flags & EF_MIPS_ABI) { case 0: @@ -1607,7 +1919,11 @@ static CONST struct elf_reloc_map mips_reloc_map[] = { 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 } + { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }, + { BFD_RELOC_MIPS_SUB, R_MIPS_SUB }, + { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE }, + { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST }, + { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP } }; /* Given a BFD reloc type, return a howto structure. */ @@ -1648,42 +1964,76 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, code) return &elf_mips_gnu_vtinherit_howto; case BFD_RELOC_VTABLE_ENTRY: return &elf_mips_gnu_vtentry_howto; + case BFD_RELOC_PCREL_HI16_S: + return &elf_mips_gnu_rel_hi16; + case BFD_RELOC_PCREL_LO16: + return &elf_mips_gnu_rel_lo16; + case BFD_RELOC_16_PCREL_S2: + return &elf_mips_gnu_rel16_s2; + case BFD_RELOC_64_PCREL: + return &elf_mips_gnu_pcrel64; + case BFD_RELOC_32_PCREL: + return &elf_mips_gnu_pcrel32; } } -/* Given a MIPS reloc type, fill in an arelent structure. */ +/* Given a MIPS Elf32_Internal_Rel, 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; +static reloc_howto_type * +mips_rtype_to_howto (r_type) + unsigned int r_type; { - 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; + return &elf_mips16_jump_howto; break; case R_MIPS16_GPREL: - cache_ptr->howto = &elf_mips16_gprel_howto; + return &elf_mips16_gprel_howto; break; case R_MIPS_GNU_VTINHERIT: - cache_ptr->howto = &elf_mips_gnu_vtinherit_howto; + return &elf_mips_gnu_vtinherit_howto; break; case R_MIPS_GNU_VTENTRY: - cache_ptr->howto = &elf_mips_gnu_vtentry_howto; + return &elf_mips_gnu_vtentry_howto; + break; + case R_MIPS_GNU_REL_HI16: + return &elf_mips_gnu_rel_hi16; + break; + case R_MIPS_GNU_REL_LO16: + return &elf_mips_gnu_rel_lo16; + break; + case R_MIPS_GNU_REL16_S2: + return &elf_mips_gnu_rel16_s2; + break; + case R_MIPS_PC64: + return &elf_mips_gnu_pcrel64; + break; + case R_MIPS_PC32: + return &elf_mips_gnu_pcrel32; break; default: BFD_ASSERT (r_type < (unsigned int) R_MIPS_max); - cache_ptr->howto = &elf_mips_howto_table[r_type]; + return &elf_mips_howto_table[r_type]; break; } +} - /* The addend for a GPREL16 or LITERAL relocation comes from the GP +/* Given a MIPS Elf32_Internal_Rel, 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); + cache_ptr->howto = mips_rtype_to_howto (r_type); + + /* 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. */ @@ -1692,6 +2042,23 @@ mips_info_to_howto_rel (abfd, cache_ptr, dst) || r_type == (unsigned int) R_MIPS_LITERAL)) cache_ptr->addend = elf_gp (abfd); } + +/* Given a MIPS Elf32_Internal_Rela, fill in an arelent structure. */ + +static void +mips_info_to_howto_rela (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rela *dst; +{ + /* Since an Elf32_Internal_Rel is an initial prefix of an + Elf32_Internal_Rela, we can just use mips_info_to_howto_rel + above. */ + mips_info_to_howto_rel (abfd, cache_ptr, (Elf32_Internal_Rel *) dst); + + /* If we ever need to do any extra processing with dst->r_addend + (the field omitted in an Elf32_Internal_Rel) we can do it here. */ +} /* A .reginfo section holds a single Elf32_RegInfo structure. These routines swap this structure in and out. They are used outside of @@ -1857,6 +2224,31 @@ bfd_mips_elf_swap_options_out (abfd, in, ex) bfd_h_put_16 (abfd, in->section, ex->section); bfd_h_put_32 (abfd, in->info, ex->info); } +#if 0 +/* Swap in an MSYM entry. */ + +static void +bfd_mips_elf_swap_msym_in (abfd, ex, in) + bfd *abfd; + const Elf32_External_Msym *ex; + Elf32_Internal_Msym *in; +{ + in->ms_hash_value = bfd_h_get_32 (abfd, ex->ms_hash_value); + in->ms_info = bfd_h_get_32 (abfd, ex->ms_info); +} +#endif +/* Swap out an MSYM entry. */ + +static void +bfd_mips_elf_swap_msym_out (abfd, in, ex) + bfd *abfd; + const Elf32_Internal_Msym *in; + Elf32_External_Msym *ex; +{ + bfd_h_put_32 (abfd, in->ms_hash_value, ex->ms_hash_value); + bfd_h_put_32 (abfd, in->ms_info, ex->ms_info); +} + /* Determine whether a symbol is global for the purposes of splitting the symbol table into global symbols and local symbols. At least @@ -1867,7 +2259,7 @@ bfd_mips_elf_swap_options_out (abfd, in, ex) /*ARGSUSED*/ static boolean mips_elf_sym_is_global (abfd, sym) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asymbol *sym; { return (sym->flags & BSF_SECTION_SYM) == 0 ? true : false; @@ -1880,23 +2272,14 @@ 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 + /* Irix 5 and 6 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); + bfd_default_set_arch_mach (abfd, bfd_arch_mips, + elf_mips_mach (elf_elfheader (abfd)->e_flags)); + return true; } /* The final processing done just before writing out a MIPS ELF object @@ -1907,7 +2290,7 @@ mips_elf32_object_p (abfd) void _bfd_mips_elf_final_write_processing (abfd, linker) bfd *abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { unsigned long val; unsigned int i; @@ -1967,6 +2350,7 @@ _bfd_mips_elf_final_write_processing (abfd, linker) { switch ((*hdrpp)->sh_type) { + case SHT_MIPS_MSYM: case SHT_MIPS_LIBLIST: sec = bfd_get_section_by_name (abfd, ".dynstr"); if (sec != NULL) @@ -1992,7 +2376,7 @@ _bfd_mips_elf_final_write_processing (abfd, linker) 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; + (*hdrpp)->sh_link = elf_section_data (sec)->this_idx; break; case SHT_MIPS_SYMBOL_LIB: @@ -2104,6 +2488,8 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) { elf_flags_init (obfd) = true; elf_elfheader (obfd)->e_flags = new_flags; + elf_elfheader (obfd)->e_ident[EI_CLASS] + = elf_elfheader (ibfd)->e_ident[EI_CLASS]; if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) && bfd_get_arch_info (obfd)->the_default) @@ -2191,18 +2577,22 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) old_flags &= ~ (EF_MIPS_ARCH | EF_MIPS_MACH); } - /* Compare ABI's */ - if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI)) + /* Compare ABI's. The 64-bit ABI does not use EF_MIPS_ABI. But, it + does set EI_CLASS differently from any 32-bit ABI. */ + if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI) + || (elf_elfheader (ibfd)->e_ident[EI_CLASS] + != elf_elfheader (obfd)->e_ident[EI_CLASS])) { /* Only error if both are set (to different values). */ - if ((new_flags & EF_MIPS_ABI) - && (old_flags & EF_MIPS_ABI)) + if (((new_flags & EF_MIPS_ABI) && (old_flags & EF_MIPS_ABI)) + || (elf_elfheader (ibfd)->e_ident[EI_CLASS] + != elf_elfheader (obfd)->e_ident[EI_CLASS])) { (*_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)); + elf_mips_abi_name (ibfd), + elf_mips_abi_name (obfd)); ok = false; } new_flags &= ~EF_MIPS_ABI; @@ -2228,7 +2618,7 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) return true; } -static boolean +boolean _bfd_mips_elf_print_private_bfd_data (abfd, ptr) bfd *abfd; PTR ptr; @@ -2253,6 +2643,10 @@ _bfd_mips_elf_print_private_bfd_data (abfd, ptr) fprintf (file, _ (" [abi=EABI64]")); else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI)) fprintf (file, _ (" [abi unknown]")); + else if (ABI_N32_P (abfd)) + fprintf (file, _ (" [abi=N32]")); + else if (ABI_64_P (abfd)) + fprintf (file, _ (" [abi=64]")); else fprintf (file, _ (" [no abi set]")); @@ -2288,7 +2682,7 @@ boolean _bfd_mips_elf_section_from_shdr (abfd, hdr, name) bfd *abfd; Elf_Internal_Shdr *hdr; - const char *name; + char *name; { flagword flags = 0; @@ -2304,7 +2698,7 @@ _bfd_mips_elf_section_from_shdr (abfd, hdr, name) return false; break; case SHT_MIPS_MSYM: - if (strcmp (name, ".msym") != 0) + if (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (abfd)) != 0) return false; break; case SHT_MIPS_CONFLICT: @@ -2339,8 +2733,7 @@ _bfd_mips_elf_section_from_shdr (abfd, hdr, name) return false; break; case SHT_MIPS_OPTIONS: - if (strcmp (name, ".options") != 0 - && strcmp (name, ".MIPS.options") != 0) + if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) != 0) return false; break; case SHT_MIPS_DWARF: @@ -2373,20 +2766,6 @@ _bfd_mips_elf_section_from_shdr (abfd, hdr, name) 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 @@ -2430,7 +2809,18 @@ mips_elf32_section_from_shdr (abfd, hdr, name) bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l, &intopt); - if (intopt.kind == ODK_REGINFO) + if (ABI_64_P (abfd) && 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; + } + else if (intopt.kind == ODK_REGINFO) { Elf32_RegInfo intreg; @@ -2469,12 +2859,6 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) 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) @@ -2517,6 +2901,7 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) #endif } else if (strcmp (name, ".got") == 0 + || strcmp (name, MIPS_ELF_SRDATA_SECTION_NAME (abfd)) == 0 || strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0 || strcmp (name, ".lit4") == 0 @@ -2527,13 +2912,13 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) hdr->sh_type = SHT_MIPS_IFACE; hdr->sh_flags |= SHF_MIPS_NOSTRIP; } - else if (strcmp (name, ".MIPS.content") == 0) + else if (strncmp (name, ".MIPS.content", strlen (".MIPS.content")) == 0) { hdr->sh_type = SHT_MIPS_CONTENT; + hdr->sh_flags |= SHF_MIPS_NOSTRIP; /* The sh_info field is set in final_write_processing. */ } - else if (strcmp (name, ".options") == 0 - || strcmp (name, ".MIPS.options") == 0) + else if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0) { hdr->sh_type = SHT_MIPS_OPTIONS; hdr->sh_entsize = 1; @@ -2555,6 +2940,29 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) hdr->sh_flags |= SHF_MIPS_NOSTRIP; /* The sh_link field is set in final_write_processing. */ } + else if (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (abfd)) == 0) + { + hdr->sh_type = SHT_MIPS_MSYM; + hdr->sh_flags |= SHF_ALLOC; + hdr->sh_entsize = 8; + } + + /* The generic elf_fake_sections will set up REL_HDR using the + default kind of relocations. But, we may actually need both + kinds of relocations, so we set up the second header here. */ + if ((sec->flags & SEC_RELOC) != 0) + { + struct bfd_elf_section_data *esd; + + esd = elf_section_data (sec); + BFD_ASSERT (esd->rel_hdr2 == NULL); + esd->rel_hdr2 + = (Elf_Internal_Shdr *) bfd_zalloc (abfd, sizeof (Elf_Internal_Shdr)); + if (!esd->rel_hdr2) + return false; + _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec, + !elf_section_data (sec)->use_rela_p); + } return true; } @@ -2567,8 +2975,8 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) boolean _bfd_mips_elf_section_from_bfd_section (abfd, hdr, sec, retval) - bfd *abfd; - Elf32_Internal_Shdr *hdr; + bfd *abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; asection *sec; int *retval; { @@ -2597,8 +3005,7 @@ _bfd_mips_elf_set_section_contents (abfd, section, location, offset, count) file_ptr offset; bfd_size_type count; { - if (strcmp (section->name, ".options") == 0 - || strcmp (section->name, ".MIPS.options") == 0) + if (strcmp (section->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0) { bfd_byte *c; @@ -2641,57 +3048,8 @@ _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) + if (hdr->sh_type == SHT_MIPS_REGINFO + && hdr->sh_size > 0) { bfd_byte buf[4]; @@ -2730,7 +3088,22 @@ mips_elf32_section_processing (abfd, hdr) bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l, &intopt); - if (intopt.kind == ODK_REGINFO) + if (ABI_64_P (abfd) && 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; + } + else if (intopt.kind == ODK_REGINFO) { bfd_byte buf[4]; @@ -2749,8 +3122,48 @@ mips_elf32_section_processing (abfd, hdr) } } - return _bfd_mips_elf_section_processing (abfd, hdr); + if (hdr->bfd_section != NULL) + { + const char *name = bfd_get_section_name (abfd, hdr->bfd_section); + + if (strcmp (name, ".sdata") == 0 + || 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, ".sbss") == 0) + { + hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL; + hdr->sh_type = SHT_NOBITS; + } + else if (strcmp (name, MIPS_ELF_SRDATA_SECTION_NAME (abfd)) == 0) + { + hdr->sh_flags |= SHF_ALLOC | 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; } + /* MIPS ELF uses two common sections. One is the usual one, and the other is for small objects. All the small objects are kept @@ -2817,8 +3230,9 @@ _bfd_mips_elf_symbol_processing (abfd, asym) 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)) + treated as SHN_MIPS_SCOMMON symbols on IRIX5. */ + if (asym->value > elf_gp_size (abfd) + || IRIX_COMPAT (abfd) == ict_irix6) break; /* Fall through. */ case SHN_MIPS_SCOMMON: @@ -2858,39 +3272,40 @@ _bfd_mips_elf_symbol_processing (abfd, asym) /* When creating an Irix 5 executable, we need REGINFO and RTPROC segments. */ -static int -mips_elf_additional_program_headers (abfd) +int +_bfd_mips_elf_additional_program_headers (abfd) bfd *abfd; { asection *s; - int ret; + int ret = 0; - ret = 0; - - if (! SGI_COMPAT (abfd)) - return ret; + if (!SGI_COMPAT (abfd)) + return 0; + /* See if we need a PT_MIPS_REGINFO segment. */ 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 (s && (s->flags & SEC_LOAD)) + ++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; - } + /* See if we need a PT_MIPS_OPTIONS segment. */ + if (IRIX_COMPAT (abfd) == ict_irix6 + && bfd_get_section_by_name (abfd, + MIPS_ELF_OPTIONS_SECTION_NAME (abfd))) + ++ret; + + /* See if we need a PT_MIPS_RTPROC segment. */ + if (IRIX_COMPAT (abfd) == ict_irix5 + && bfd_get_section_by_name (abfd, ".dynamic") + && bfd_get_section_by_name (abfd, ".mdebug")) + ++ret; return ret; } /* Modify the segment map for an Irix 5 executable. */ -static boolean -mips_elf_modify_segment_map (abfd) +boolean +_bfd_mips_elf_modify_segment_map (abfd) bfd *abfd; { asection *s; @@ -2929,114 +3344,156 @@ mips_elf_modify_segment_map (abfd) } } - /* 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 IRIX 6, we don't have .mdebug sections, nor does anything but + .dynamic end up in PT_DYNAMIC. However, we do have to insert a + PT_OPTIONS segement immediately following the program header + table. */ + if (IRIX_COMPAT (abfd) == ict_irix6) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) - if (m->p_type == PT_MIPS_RTPROC) + asection *s; + + for (s = abfd->sections; s; s = s->next) + if (elf_section_data (s)->this_hdr.sh_type == SHT_MIPS_OPTIONS) break; - if (m == NULL) + + if (s) { - m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m); + struct elf_segment_map *options_segment; + + /* Usually, there's a program header table. But, sometimes + there's not (like when running the `ld' testsuite). So, + if there's no program header table, we just put the + options segement at the end. */ + for (pm = &elf_tdata (abfd)->segment_map; + *pm != NULL; + pm = &(*pm)->next) + if ((*pm)->p_type == PT_PHDR) + break; + + options_segment = bfd_zalloc (abfd, + sizeof (struct elf_segment_map)); + options_segment->next = *pm; + options_segment->p_type = PT_MIPS_OPTIONS; + options_segment->p_flags = PF_R; + options_segment->p_flags_valid = true; + options_segment->count = 1; + options_segment->sections[0] = s; + *pm = options_segment; + } + } + else + { + /* 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) - return false; + { + m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m); + if (m == NULL) + return false; - m->p_type = PT_MIPS_RTPROC; + 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; - } + 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; + /* 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; + 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++) + /* 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) { - s = bfd_get_section_by_name (abfd, sec_names[i]); - if (s != NULL && (s->flags & SEC_LOAD) != 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++) { - 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; + 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; + 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)) + i = 0; + for (s = abfd->sections; s != NULL; s = s->next) { - n->sections[i] = s; - ++i; + 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; + *pm = n; + } } return true; @@ -3225,7 +3682,8 @@ _bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, - line_ptr)) + line_ptr, + ABI_64_P (abfd) ? 8 : 0)) return true; msec = bfd_get_section_by_name (abfd, ".mdebug"); @@ -3349,39 +3807,9 @@ _bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr, #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. */ +/* MIPS ELF linker 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 mips_elf_link_hash_table { struct elf_link_hash_table root; #if 0 @@ -3456,7 +3884,8 @@ mips_elf_link_hash_newfunc (entry, table, string) /* 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->possibly_dynamic_relocs = 0; + ret->min_dyn_reloc_index = 0; ret->fn_stub = NULL; ret->need_fn_stub = false; ret->call_stub = NULL; @@ -3468,8 +3897,8 @@ mips_elf_link_hash_newfunc (entry, table, string) /* Create a MIPS ELF linker hash table. */ -static struct bfd_link_hash_table * -mips_elf_link_hash_table_create (abfd) +struct bfd_link_hash_table * +_bfd_mips_elf_link_hash_table_create (abfd) bfd *abfd; { struct mips_elf_link_hash_table *ret; @@ -3504,13 +3933,13 @@ mips_elf_link_hash_table_create (abfd) 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) +boolean +_bfd_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; + flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; bfd_vma *valp; { @@ -3528,7 +3957,8 @@ mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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)) + if (sym->st_size > elf_gp_size (abfd) + || IRIX_COMPAT (abfd) == ict_irix6) break; /* Fall through. */ case SHN_MIPS_SCOMMON: @@ -3548,7 +3978,7 @@ mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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.flags = BSF_SECTION_SYM | BSF_DYNAMIC; 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; @@ -3572,7 +4002,7 @@ mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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.flags = BSF_SECTION_SYM | BSF_DYNAMIC; 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; @@ -3981,8 +4411,8 @@ gptab_compare (p1, p2) 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) +boolean +_bfd_mips_elf_final_link (abfd, info) bfd *abfd; struct bfd_link_info *info; { @@ -3998,22 +4428,69 @@ mips_elf_final_link (abfd, info) 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 all the things we linked together were PIC, but we're + producing an executable (rather than a shared object), then the + resulting file is CPIC (i.e., it calls PIC code.) */ + if (!info->shared + && !info->relocateable + && elf_elfheader (abfd)->e_flags & EF_MIPS_PIC) { - 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; - } + elf_elfheader (abfd)->e_flags &= ~EF_MIPS_PIC; + elf_elfheader (abfd)->e_flags |= EF_MIPS_CPIC; + } + + /* We'd carefully arranged the dynamic symbol indices, and then the + generic size_dynamic_sections renumbered them out from under us. + Rather than trying somehow to prevent the renumbering, just do + the sort again. */ + if (elf_hash_table (info)->dynamic_sections_created) + { + bfd *dynobj; + asection *got; + struct mips_got_info *g; + + /* When we resort, we must tell mips_elf_sort_hash_table what + the lowest index it may use is. That's the number of section + symbols we're going to add. The generic ELF linker only + adds these symbols when building a shared object. Note that + we count the sections after (possibly) removing the .options + section above. */ + if (!mips_elf_sort_hash_table (info, (info->shared + ? bfd_count_sections (abfd) + 1 + : 1))) + return false; + + /* Make sure we didn't grow the global .got region. */ + dynobj = elf_hash_table (info)->dynobj; + got = bfd_get_section_by_name (dynobj, ".got"); + g = (struct mips_got_info *) elf_section_data (got)->tdata; + + if (g->global_gotsym != NULL) + BFD_ASSERT ((elf_hash_table (info)->dynsymcount + - g->global_gotsym->dynindx) + <= g->global_gotno); } + /* On IRIX5, we omit the .options section. On IRIX6, however, we + include it, even though we don't process it quite right. (Some + entries are supposed to be merged.) Empirically, we seem to be + better off including it then not. */ + if (IRIX_COMPAT (abfd) == ict_irix5) + for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next) + { + if (strcmp ((*secpp)->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 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) { @@ -4029,17 +4506,14 @@ mips_elf_final_link (abfd, info) { bfd_vma lo; - /* Make up a value. */ + /* Find the GP-relative section with the lowest offset. */ 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; - } + if (o->vma < lo + && (elf_section_data (o)->this_hdr.sh_flags & SHF_MIPS_GPREL)) + lo = o->vma; + + /* And calculate GP relative to that. */ elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd); } else @@ -4572,7 +5046,17 @@ mips_elf_final_link (abfd, info) } /* Invoke the regular ELF backend linker to do all the work. */ - if (! bfd_elf32_bfd_final_link (abfd, info)) + if (ABI_64_P (abfd)) + { +#ifdef BFD64 + if (!bfd_elf64_bfd_final_link (abfd, info)) + return false; +#else + abort (); + return false; +#endif /* BFD64 */ + } + else if (!bfd_elf32_bfd_final_link (abfd, info)) return false; /* Now write out the computed sections. */ @@ -4632,1029 +5116,1782 @@ mips_elf_final_link (abfd, info) return true; } -/* Handle a MIPS ELF HI16 reloc. */ +/* Returns the GOT section for ABFD. */ -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; +static asection * +mips_elf_got_section (abfd) + bfd *abfd; { - bfd_vma insn; - bfd_vma addlo; - - insn = bfd_get_32 (input_bfd, contents + relhi->r_offset); + return bfd_get_section_by_name (abfd, ".got"); +} - addlo = bfd_get_32 (input_bfd, contents + rello->r_offset); - addlo &= 0xffff; +/* Returns the GOT information associated with the link indicated by + INFO. If SGOTP is non-NULL, it is filled in with the GOT + section. */ - addend += ((insn & 0xffff) << 16) + addlo; +static struct mips_got_info * +mips_elf_got_info (abfd, sgotp) + bfd *abfd; + asection **sgotp; +{ + asection *sgot; + struct mips_got_info *g; - if ((addlo & 0x8000) != 0) - addend -= 0x10000; - if ((addend & 0x8000) != 0) - addend += 0x10000; + sgot = mips_elf_got_section (abfd); + 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); - bfd_put_32 (input_bfd, - (insn & 0xffff0000) | ((addend >> 16) & 0xffff), - contents + relhi->r_offset); + if (sgotp) + *sgotp = sgot; + return g; } -/* Handle a MIPS ELF local GOT16 reloc. */ +/* Return whether a relocation is against a local symbol. */ static boolean -mips_elf_relocate_got_local (output_bfd, input_bfd, sgot, relhi, rello, - contents, addend) - bfd *output_bfd; +mips_elf_local_relocation_p (input_bfd, relocation, local_sections) bfd *input_bfd; - asection *sgot; - Elf_Internal_Rela *relhi; - Elf_Internal_Rela *rello; - bfd_byte *contents; - bfd_vma addend; + const Elf_Internal_Rela *relocation; + asection **local_sections; { - 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; + unsigned long r_symndx; + Elf_Internal_Shdr *symtab_hdr; + + r_symndx = ELF32_R_SYM (relocation->r_info); + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + if (! elf_bad_symtab (input_bfd)) + return r_symndx < symtab_hdr->sh_info; + else + { + /* The symbol table does not follow the rule that local symbols + must come before globals. */ + return local_sections[r_symndx] != NULL; + } +} - insn = bfd_get_32 (input_bfd, contents + relhi->r_offset); +/* Sign-extend VALUE, which has the indicated number of BITS. */ - addlo = bfd_get_32 (input_bfd, contents + rello->r_offset); - addlo &= 0xffff; +static bfd_vma +mips_elf_sign_extend (value, bits) + bfd_vma value; + int bits; +{ + if (value & ((bfd_vma)1 << (bits - 1))) + /* VALUE is negative. */ + value |= ((bfd_vma) - 1) << bits; + + return value; +} - addend += ((insn & 0xffff) << 16) + addlo; +/* Return non-zero if the indicated VALUE has overflowed the maximum + range expressable by a signed number with the indicated number of + BITS. */ - if ((addlo & 0x8000) != 0) - addend -= 0x10000; - if ((addend & 0x8000) != 0) - addend += 0x10000; +static boolean +mips_elf_overflow_p (value, bits) + bfd_vma value; + int bits; +{ + bfd_signed_vma svalue = (bfd_signed_vma) value; - /* 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); + if (svalue > (1 << (bits - 1)) - 1) + /* The value is too big. */ + return true; + else if (svalue < -(1 << (bits - 1))) + /* The value is too small. */ + return true; + + /* All is well. */ + return false; +} - assigned_gotno = g->assigned_gotno; - got_contents = sgot->contents; - hipage = addend & 0xffff0000; +/* Calculate the %high function. */ - for (i = MIPS_RESERVED_GOTNO; i < assigned_gotno; i++) - { - address = bfd_get_32 (input_bfd, got_contents + i * 4); - if (hipage == (address & 0xffff0000)) - break; - } +static bfd_vma +mips_elf_high (value) + bfd_vma value; +{ + return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff; +} - 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; - } +/* Calculate the %higher function. */ - bfd_put_32 (input_bfd, hipage, got_contents + assigned_gotno * 4); - ++g->assigned_gotno; - } +static bfd_vma +mips_elf_higher (value) + bfd_vma value ATTRIBUTE_UNUSED; +{ +#ifdef BFD64 + return ((value + (bfd_vma) 0x80008000) >> 32) & 0xffff; +#else + abort (); + return (bfd_vma) -1; +#endif +} + +/* Calculate the %highest function. */ + +static bfd_vma +mips_elf_highest (value) + bfd_vma value ATTRIBUTE_UNUSED; +{ +#ifdef BFD64 + return ((value + (bfd_vma) 0x800080008000) >> 48) & 0xffff; +#else + abort (); + return (bfd_vma) -1; +#endif +} + +/* Returns the GOT index for the global symbol indicated by H. */ + +static bfd_vma +mips_elf_global_got_index (abfd, h) + bfd *abfd; + struct elf_link_hash_entry *h; +{ + bfd_vma index; + asection *sgot; + struct mips_got_info *g; + + g = mips_elf_got_info (abfd, &sgot); + + /* Once we determine the global GOT entry with the lowest dynamic + symbol table index, we must put all dynamic symbols with greater + indices into the GOT. That makes it easy to calculate the GOT + offset. */ + BFD_ASSERT (h->dynindx >= g->global_gotsym->dynindx); + index = ((h->dynindx - g->global_gotsym->dynindx + g->local_gotno) + * MIPS_ELF_GOT_SIZE (abfd)); + BFD_ASSERT (index < sgot->_raw_size); + + return index; +} + +/* Returns the offset for the entry at the INDEXth position + in the GOT. */ + +static bfd_vma +mips_elf_got_offset_from_index (dynobj, output_bfd, index) + bfd *dynobj; + bfd *output_bfd; + bfd_vma index; +{ + asection *sgot; + bfd_vma gp; + + sgot = mips_elf_got_section (dynobj); + gp = _bfd_get_gp_value (output_bfd); + return (sgot->output_section->vma + sgot->output_offset + index - + gp); +} + +/* If H is a symbol that needs a global GOT entry, but has a dynamic + symbol table index lower than any we've seen to date, record it for + posterity. */ + +static boolean +mips_elf_record_global_got_symbol (h, info, g) + struct elf_link_hash_entry *h; + struct bfd_link_info *info; + struct mips_got_info *g ATTRIBUTE_UNUSED; +{ + /* A global symbol in the GOT must also be in the dynamic symbol + table. */ + if (h->dynindx == -1 + && !bfd_elf32_link_record_dynamic_symbol (info, h)) + return false; + + /* If we've already marked this entry as need GOT space, we don't + need to do it again. */ + if (h->got.offset != (bfd_vma) - 1) + return true; - i = - ELF_MIPS_GP_OFFSET (output_bfd) + i * 4; - bfd_put_32 (input_bfd, (insn & 0xffff0000) | (i & 0xffff), - contents + relhi->r_offset); + /* By setting this to a value other than -1, we are indicating that + there needs to be a GOT entry for H. */ + h->got.offset = 0; return true; } -/* Handle MIPS ELF CALL16 reloc and global GOT16 reloc. */ +/* This structure is passed to mips_elf_sort_hash_table_f when sorting + the dynamic symbols. */ + +struct mips_elf_hash_sort_data +{ + /* The symbol in the global GOT with the lowest dynamic symbol table + index. */ + struct elf_link_hash_entry *low; + /* The least dynamic symbol table index corresponding to a symbol + with a GOT entry. */ + long min_got_dynindx; + /* The greatest dynamic symbol table index not corresponding to a + symbol without a GOT entry. */ + long max_non_got_dynindx; +}; + +/* If H needs a GOT entry, assign it the highest available dynamic + index. Otherwise, assign it the lowest available dynamic + index. */ -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; +static boolean +mips_elf_sort_hash_table_f (h, data) + struct mips_elf_link_hash_entry *h; + PTR data; { - bfd_vma insn; + struct mips_elf_hash_sort_data *hsd + = (struct mips_elf_hash_sort_data *) data; + + /* Symbols without dynamic symbol table entries aren't interesting + at all. */ + if (h->root.dynindx == -1) + return true; + + if (h->root.got.offset != 0) + h->root.dynindx = hsd->max_non_got_dynindx++; + else + { + h->root.dynindx = --hsd->min_got_dynindx; + hsd->low = (struct elf_link_hash_entry *) h; + } - insn = bfd_get_32 (input_bfd, contents + rel->r_offset); - bfd_put_32 (input_bfd, - (insn & 0xffff0000) | (offset & 0xffff), - contents + rel->r_offset); + return true; } -/* Relocate a MIPS ELF section. */ +/* Sort the dynamic symbol table so that symbols that need GOT entries + appear towards the end. This reduces the amount of GOT space + required. MAX_LOCAL is used to set the number of local symbols + known to be in the dynamic symbol table. During + mips_elf_size_dynamic_sections, this value is 1. Afterward, the + section symbols are added and the count is higher. */ static boolean -mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, - contents, relocs, local_syms, local_sections) - bfd *output_bfd; +mips_elf_sort_hash_table (info, max_local) 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; + unsigned long max_local; { - 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_elf_hash_sort_data hsd; struct mips_got_info *g; + bfd *dynobj; 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; + hsd.low = NULL; + hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount; + hsd.max_non_got_dynindx = max_local; + mips_elf_link_hash_traverse (((struct mips_elf_link_hash_table *) + elf_hash_table (info)), + mips_elf_sort_hash_table_f, + &hsd); + + /* There shoud have been enough room in the symbol table to + accomodate both the GOT and non-GOT symbols. */ + BFD_ASSERT (hsd.min_got_dynindx == hsd.max_non_got_dynindx); + + /* Now we know which dynamic symbol has the lowest dynamic symbol + table index in the GOT. */ + g = mips_elf_got_info (dynobj, NULL); + g->global_gotsym = hsd.low; + + return true; +} - if (elf_bad_symtab (input_bfd)) +/* Create a local GOT entry for VALUE. Return the index of the entry, + or -1 if it could not be created. */ + +static bfd_vma +mips_elf_create_local_got_entry (abfd, g, sgot, value) + bfd *abfd; + struct mips_got_info *g; + asection *sgot; + bfd_vma value; +{ + if (g->assigned_gotno >= g->local_gotno) { - locsymcount = symtab_hdr->sh_size / sizeof (Elf32_External_Sym); - extsymoff = 0; + /* We didn't allocate enough space in the GOT. */ + (*_bfd_error_handler) + (_("not enough GOT space for local GOT entries")); + bfd_set_error (bfd_error_bad_value); + return (bfd_vma) -1; } - else + + MIPS_ELF_PUT_WORD (abfd, value, + (sgot->contents + + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno)); + return MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++; +} + +/* Returns the GOT offset at which the indicated address can be found. + If there is not yet a GOT entry for this value, create one. Returns + -1 if no satisfactory GOT offset can be found. */ + +static bfd_vma +mips_elf_local_got_index (abfd, info, value) + bfd *abfd; + struct bfd_link_info *info; + bfd_vma value; +{ + asection *sgot; + struct mips_got_info *g; + bfd_byte *entry; + + g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); + + /* Look to see if we already have an appropriate entry. */ + for (entry = (sgot->contents + + MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO); + entry != sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno; + entry += MIPS_ELF_GOT_SIZE (abfd)) { - locsymcount = symtab_hdr->sh_info; - extsymoff = symtab_hdr->sh_info; + bfd_vma address = MIPS_ELF_GET_WORD (abfd, entry); + if (address == value) + return entry - sgot->contents; } - gp = _bfd_get_gp_value (output_bfd); + return mips_elf_create_local_got_entry (abfd, g, sgot, value); +} + +/* Find a GOT entry that is within 32KB of the VALUE. These entries + are supposed to be placed at small offsets in the GOT, i.e., + within 32KB of GP. Return the index into the GOT for this page, + and store the offset from this entry to the desired address in + OFFSETP, if it is non-NULL. */ + +static bfd_vma +mips_elf_got_page (abfd, info, value, offsetp) + bfd *abfd; + struct bfd_link_info *info; + bfd_vma value; + bfd_vma *offsetp; +{ + asection *sgot; + struct mips_got_info *g; + bfd_byte *entry; + bfd_byte *last_entry; + bfd_vma index = 0; + bfd_vma address; + + g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); - rel = relocs; - relend = relocs + input_section->reloc_count; - for (; rel < relend; rel++) + /* Look to see if we aleady have an appropriate entry. */ + last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno; + for (entry = (sgot->contents + + MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO); + entry != last_entry; + entry += MIPS_ELF_GOT_SIZE (abfd)) { - 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; + address = MIPS_ELF_GET_WORD (abfd, entry); - 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) + if (!mips_elf_overflow_p (value - address, 16)) { - bfd_set_error (bfd_error_bad_value); - return false; + /* This entry will serve as the page pointer. We can add a + 16-bit number to it to get the actual address. */ + index = entry - sgot->contents; + break; } - 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)) + } + + /* If we didn't have an appropriate entry, we create one now. */ + if (entry == last_entry) + index = mips_elf_create_local_got_entry (abfd, g, sgot, value); + + if (offsetp) + { + address = MIPS_ELF_GET_WORD (abfd, entry); + *offsetp = value - address; + } + + return index; +} + +/* Find a GOT entry whose higher-order 16 bits are the same as those + for value. Return the index into the GOT for this entry. */ + +static bfd_vma +mips_elf_got16_entry (abfd, info, value) + bfd *abfd; + struct bfd_link_info *info; + bfd_vma value; +{ + asection *sgot; + struct mips_got_info *g; + bfd_byte *entry; + bfd_byte *last_entry; + bfd_vma index = 0; + bfd_vma address; + + /* Although the ABI says that it is "the high-order 16 bits" that we + want, it is really the %high value. The complete value is + calculated with a `addiu' of a LO16 relocation, just as with a + HI16/LO16 pair. */ + value = mips_elf_high (value) << 16; + g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); + + /* Look to see if we already have an appropriate entry. */ + last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno; + for (entry = (sgot->contents + + MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO); + entry != last_entry; + entry += MIPS_ELF_GOT_SIZE (abfd)) + { + address = MIPS_ELF_GET_WORD (abfd, entry); + if ((address & 0xffff0000) == value) { - /* 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); - } + /* This entry has the right high-order 16 bits. */ + index = entry - sgot->contents; + break; } + } - r_symndx = ELF32_R_SYM (rel->r_info); + /* If we didn't have an appropriate entry, we create one now. */ + if (entry == last_entry) + index = mips_elf_create_local_got_entry (abfd, g, sgot, value); - /* 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); - } + return index; +} - 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; - } - } +/* Returns the first relocation of type r_type found, beginning with + RELOCATION. RELEND is one-past-the-end of the relocation table. */ - 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); - } - } - } +static const Elf_Internal_Rela * +mips_elf_next_relocation (r_type, relocation, relend) + unsigned int r_type; + const Elf_Internal_Rela *relocation; + const Elf_Internal_Rela *relend; +{ + /* According to the MIPS ELF ABI, the R_MIPS_LO16 relocation must be + immediately following. However, for the IRIX6 ABI, the next + relocation may be a composed relocation consisting of several + relocations for the same address. In that case, the R_MIPS_LO16 + relocation may occur as one of these. We permit a similar + extension in general, as that is useful for GCC. */ + while (relocation < relend) + { + if (ELF32_R_TYPE (relocation->r_info) == r_type) + return relocation; + + ++relocation; + } + + /* We didn't find it. */ + bfd_set_error (bfd_error_bad_value); + return NULL; +} + +/* Create a rel.dyn relocation for the dynamic linker to resolve. REL + is the original relocation, which is now being transformed into a + dyanmic relocation. The ADDENDP is adjusted if necessary; the + caller should store the result in place of the original addend. */ + +static boolean +mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec, + symbol, addendp, input_section) + bfd *output_bfd; + struct bfd_link_info *info; + const Elf_Internal_Rela *rel; + struct mips_elf_link_hash_entry *h; + asection *sec; + bfd_vma symbol; + bfd_vma *addendp; + asection *input_section; +{ + Elf_Internal_Rel outrel; + boolean skip; + asection *sreloc; + bfd *dynobj; + int r_type; + + r_type = ELF32_R_TYPE (rel->r_info); + dynobj = elf_hash_table (info)->dynobj; + sreloc + = bfd_get_section_by_name (dynobj, + MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)); + BFD_ASSERT (sreloc != NULL); + + skip = false; + + /* We begin by assuming that the offset for the dynamic relocation + is the same as for the original relocation. We'll adjust this + later to reflect the correct output offsets. */ + if (elf_section_data (input_section)->stab_info == NULL) + outrel.r_offset = rel->r_offset; + else + { + /* Except that in a stab section things are more complex. + Because we compress stab information, the offset given in the + relocation may not be the one we want; we must let the stabs + machinery tell us the offset. */ + outrel.r_offset + = (_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 we didn't need the relocation at all, this value will be + -1. */ + if (outrel.r_offset == (bfd_vma) -1) + skip = true; + } + + /* If we've decided to skip this relocation, just output an emtpy + record. Note that R_MIPS_NONE == 0, so that this call to memset + is a way of setting R_TYPE to R_MIPS_NONE. */ + if (skip) + memset (&outrel, 0, sizeof (outrel)); + else + { + long indx; + bfd_vma section_offset; + + /* We must now calculate the dynamic symbol table index to use + in the relocation. */ + if (h != NULL + && (! info->symbolic || (h->root.elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0)) + { + indx = h->root.dynindx; + BFD_ASSERT (indx != -1); } 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)) + if (sec != NULL && bfd_is_abs_section (sec)) + indx = 0; + else if (sec == NULL || sec->owner == 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; + bfd_set_error (bfd_error_bad_value); + return false; } 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; - } + indx = elf_section_data (sec->output_section)->dynindx; + if (indx == 0) + abort (); } - mh = (struct mips_elf_link_hash_entry *) h; - if (h != NULL) - other = h->other; - else if (sym != NULL) - other = sym->st_other; + /* Figure out how far the target of the relocation is from + the beginning of its section. */ + section_offset = symbol - sec->output_section->vma; + /* The relocation we're building is section-relative. + Therefore, the original addend must be adjusted by the + section offset. */ + *addendp += symbol - sec->output_section->vma; + /* Now, the relocation is just against the section. */ + symbol = sec->output_section->vma; + } + + /* If the relocation was previously an absolute relocation, we + must adjust it by the value we give it in the dynamic symbol + table. */ + if (r_type != R_MIPS_REL32) + *addendp += symbol; + + /* The relocation is always an REL32 relocation because we don't + know where the shared library will wind up at load-time. */ + outrel.r_info = ELF32_R_INFO (indx, R_MIPS_REL32); + + /* Adjust the output offset of the relocation to reference the + correct location in the output file. */ + outrel.r_offset += (input_section->output_section->vma + + input_section->output_offset); + } + + /* Put the relocation back out. We have to use the special + relocation outputter in the 64-bit case since the 64-bit + relocation format is non-standard. */ + if (ABI_64_P (output_bfd)) + { + (*get_elf_backend_data (output_bfd)->s->swap_reloc_out) + (output_bfd, &outrel, + (sreloc->contents + + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel))); + } + else + bfd_elf32_swap_reloc_out (output_bfd, &outrel, + (((Elf32_External_Rel *) + sreloc->contents) + + sreloc->reloc_count)); + + /* Record the index of the first relocation referencing H. This + information is later emitted in the .msym section. */ + if (h != NULL + && (h->min_dyn_reloc_index == 0 + || sreloc->reloc_count < h->min_dyn_reloc_index)) + h->min_dyn_reloc_index = sreloc->reloc_count; + + /* We've now added another relocation. */ + ++sreloc->reloc_count; + + /* Make sure the output section is writable. The dynamic linker + will be writing to it. */ + elf_section_data (input_section->output_section)->this_hdr.sh_flags + |= SHF_WRITE; + + /* On IRIX5, make an entry of compact relocation info. */ + if (! skip && IRIX_COMPAT (output_bfd) == ict_irix5) + { + asection* scpt = bfd_get_section_by_name (dynobj, ".compact_rel"); + bfd_byte *cr; + + if (scpt) + { + Elf32_crinfo cptrel; + + 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 - 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; + mips_elf_set_cr_type (cptrel, CRT_MIPS_WORD); + mips_elf_set_cr_dist2to (cptrel, 0); + cptrel.konst = *addendp; + + 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; + } + } - fn_stub = elf_tdata (input_bfd)->local_stubs[r_symndx]; - relocation = (fn_stub->output_section->vma - + fn_stub->output_offset); - } + return true; +} - /* RELOCATION now points to 32 bit code. */ - other = 0; - } +/* Calculate the value produced by the RELOCATION (which comes from + the INPUT_BFD). The ADDEND is the addend to use for this + RELOCATION; RELOCATION->R_ADDEND is ignored. - /* 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; + The result of the relocation calculation is stored in VALUEP. + REQUIRE_JALXP indicates whether or not the opcode used with this + relocation must be JALX. - /* 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; + This function returns bfd_reloc_continue if the caller need take no + further action regarding this relocation, bfd_reloc_notsupported if + something goes dramatically wrong, bfd_reloc_overflow if an + overflow occurs, and bfd_reloc_ok to indicate success. */ - 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; +static bfd_reloc_status_type +mips_elf_calculate_relocation (abfd, + input_bfd, + input_section, + info, + relocation, + addend, + howto, + local_syms, + local_sections, + valuep, + namep, + require_jalxp) + bfd *abfd; + bfd *input_bfd; + asection *input_section; + struct bfd_link_info *info; + const Elf_Internal_Rela *relocation; + bfd_vma addend; + reloc_howto_type *howto; + Elf_Internal_Sym *local_syms; + asection **local_sections; + bfd_vma *valuep; + const char **namep; + boolean *require_jalxp; +{ + /* The eventual value we will return. */ + bfd_vma value; + /* The address of the symbol against which the relocation is + occurring. */ + bfd_vma symbol = 0; + /* The final GP value to be used for the relocatable, executable, or + shared object file being produced. */ + bfd_vma gp = (bfd_vma) - 1; + /* The place (section offset or address) of the storage unit being + relocated. */ + bfd_vma p; + /* The value of GP used to create the relocatable object. */ + bfd_vma gp0 = (bfd_vma) - 1; + /* The offset into the global offset table at which the address of + the relocation entry symbol, adjusted by the addend, resides + during execution. */ + bfd_vma g = (bfd_vma) - 1; + /* The section in which the symbol referenced by the relocation is + located. */ + asection *sec = NULL; + struct mips_elf_link_hash_entry* h = NULL; + /* True if the symbol referred to by this relocation is a local + symbol. */ + boolean local_p; + /* True if the symbol referred to by this relocation is "_gp_disp". */ + boolean gp_disp_p = false; + Elf_Internal_Shdr *symtab_hdr; + size_t extsymoff; + unsigned long r_symndx; + int r_type; + /* True if overflow occurred during the calculation of the + relocation value. */ + boolean overflowed_p; + /* True if this relocation refers to a MIPS16 function. */ + boolean target_is_16_bit_code_p = false; + + /* Parse the relocation. */ + r_symndx = ELF32_R_SYM (relocation->r_info); + r_type = ELF32_R_TYPE (relocation->r_info); + p = (input_section->output_section->vma + + input_section->output_offset + + relocation->r_offset); + + /* Assume that there will be no overflow. */ + overflowed_p = false; + + /* Figure out whether or not the symbol is local, and get the offset + used in the array of hash table entries. */ + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + local_p = mips_elf_local_relocation_p (input_bfd, relocation, + local_sections); + if (! elf_bad_symtab (input_bfd)) + extsymoff = symtab_hdr->sh_info; + else + { + /* The symbol table does not follow the rule that local symbols + must come before globals. */ + extsymoff = 0; + } + + /* Figure out the value of the symbol. */ + if (local_p) + { + Elf_Internal_Sym *sym; - BFD_ASSERT (stub->_raw_size > 0); - relocation = stub->output_section->vma + stub->output_offset; - } + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; - 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) + symbol = sec->output_section->vma + sec->output_offset; + if (ELF_ST_TYPE (sym->st_info) != STT_SECTION) + symbol += sym->st_value; + + /* MIPS16 text labels should be treated as odd. */ + if (sym->st_other == STO_MIPS16) + ++symbol; + + /* Record the name of this symbol, for our caller. */ + *namep = bfd_elf_string_from_elf_section (input_bfd, + symtab_hdr->sh_link, + sym->st_name); + if (*namep == '\0') + *namep = bfd_section_name (input_bfd, sec); + + target_is_16_bit_code_p = (sym->st_other == STO_MIPS16); + } + else + { + /* For global symbols we look up the symbol in the hash-table. */ + h = ((struct mips_elf_link_hash_entry *) + elf_sym_hashes (input_bfd) [r_symndx - extsymoff]); + /* Find the real hash-table entry for this symbol. */ + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link; + + /* Record the name of this symbol, for our caller. */ + *namep = h->root.root.root.string; + + /* See if this is the special _gp_disp symbol. Note that such a + symbol must always be a global symbol. */ + if (strcmp (h->root.root.root.string, "_gp_disp") == 0) + { + /* Relocations against _gp_disp are permitted only with + R_MIPS_HI16 and R_MIPS_LO16 relocations. */ + if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16) + return bfd_reloc_notsupported; + + gp_disp_p = true; + } + /* If this symbol is defined, calculate its address. Note that + _gp_disp is a magic symbol, always implicitly defined by the + linker, so it's inappropriate to check to see whether or not + its defined. */ + else if ((h->root.root.type == bfd_link_hash_defined + || h->root.root.type == bfd_link_hash_defweak) + && h->root.root.u.def.section) + { + sec = h->root.root.u.def.section; + if (sec->output_section) + symbol = (h->root.root.u.def.value + + sec->output_section->vma + + sec->output_offset); + else + symbol = h->root.root.u.def.value; + } + else if (h->root.root.type == bfd_link_hash_undefweak) + /* We allow relocations against undefined weak symbols, giving + it the value zero, so that you can undefined weak functions + and check to see if they exist by looking at their + addresses. */ + symbol = 0; + else if (info->shared && !info->symbolic && !info->no_undefined) + symbol = 0; + else if (strcmp (h->root.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 (abfd, ".dynamic") == NULL); + symbol = 0; + } + else + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.root.string, input_bfd, + input_section, relocation->r_offset, + (!info->shared || info->no_undefined)))) + return bfd_reloc_undefined; + symbol = 0; + } + + target_is_16_bit_code_p = (h->root.other == STO_MIPS16); + } + + /* If this is a 32-bit call to a 16-bit function with a stub, we + need to redirect the call to the stub, unless we're already *in* + a stub. */ + if (r_type != R_MIPS16_26 && !info->relocateable + && ((h != NULL && h->fn_stub != NULL) + || (local_p && elf_tdata (input_bfd)->local_stubs != NULL + && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL)) + && !mips_elf_stub_section_p (input_bfd, input_section)) + { + /* This is a 32-bit call to a 16-bit function. We should + have already noticed that we were going to need the + stub. */ + if (local_p) + sec = elf_tdata (input_bfd)->local_stubs[r_symndx]; + else + { + BFD_ASSERT (h->need_fn_stub); + sec = h->fn_stub; + } + + symbol = sec->output_section->vma + sec->output_offset; + } + /* If this is a 16-bit call to a 32-bit function with a stub, we + need to redirect the call to the stub. */ + else if (r_type == R_MIPS16_26 && !info->relocateable + && h != NULL + && (h->call_stub != NULL || h->call_fp_stub != NULL) + && !target_is_16_bit_code_p) + { + /* 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 (h->call_stub != NULL && h->call_fp_stub != NULL) + { + asection *o; + + sec = NULL; + for (o = input_bfd->sections; o != NULL; o = o->next) { - /* 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 (strncmp (bfd_get_section_name (input_bfd, o), + CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0) { - if (! mips_elf_relocate_got_local (output_bfd, input_bfd, - sgot, rel, rel + 1, - contents, - relocation + addend)) - return false; - r = bfd_reloc_ok; + sec = h->call_fp_stub; + break; } - 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; + if (sec == NULL) + sec = h->call_stub; + } + else if (h->call_stub != NULL) + sec = h->call_stub; + else + sec = h->call_fp_stub; - /* 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); - } + BFD_ASSERT (sec->_raw_size > 0); + symbol = sec->output_section->vma + sec->output_offset; + } - skip = false; + /* Calls from 16-bit code to 32-bit code and vice versa require the + special jalx instruction. */ + *require_jalxp = (!info->relocateable + && ((r_type == R_MIPS16_26) != target_is_16_bit_code_p)); - 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 we haven't already determined the GOT offset, or the GP value, + and we're going to need it, get it now. */ + switch (r_type) + { + case R_MIPS_CALL16: + case R_MIPS_GOT16: + case R_MIPS_GOT_DISP: + case R_MIPS_GOT_HI16: + case R_MIPS_CALL_HI16: + case R_MIPS_GOT_LO16: + case R_MIPS_CALL_LO16: + /* Find the index into the GOT where this value is located. */ + if (!local_p) + { + BFD_ASSERT (addend == 0); + g = mips_elf_global_got_index + (elf_hash_table (info)->dynobj, + (struct elf_link_hash_entry*) h); + } + else if (r_type == R_MIPS_GOT16) + /* There's no need to create a local GOT entry here; the + calculation for a local GOT16 entry does not involve G. */ + break; + else + { + g = mips_elf_local_got_index (abfd, info, symbol + addend); + if (g == (bfd_vma) -1) + return false; + } - outrel.r_offset += (input_section->output_section->vma - + input_section->output_offset); + /* Convert GOT indices to actual offsets. */ + g = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, + abfd, g); + break; + + case R_MIPS_HI16: + case R_MIPS_LO16: + case R_MIPS_GPREL16: + case R_MIPS_GPREL32: + case R_MIPS_LITERAL: + gp0 = _bfd_get_gp_value (input_bfd); + gp = _bfd_get_gp_value (abfd); + break; - addend = bfd_get_32 (input_bfd, contents + rel->r_offset); + default: + break; + } - 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; + /* Figure out what kind of relocation is being performed. */ + switch (r_type) + { + case R_MIPS_NONE: + return bfd_reloc_continue; - 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; + case R_MIPS_16: + value = symbol + mips_elf_sign_extend (addend, 16); + overflowed_p = mips_elf_overflow_p (value, 16); + break; - osec = sec->output_section; - indx = elf_section_data (osec)->dynindx; - if (indx == 0) - abort (); - } + case R_MIPS_32: + case R_MIPS_REL32: + case R_MIPS_64: + if ((info->shared + || (elf_hash_table (info)->dynamic_sections_created + && h != NULL + && ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) + == 0))) + && (input_section->flags & SEC_ALLOC) != 0) + { + /* If we're creating a shared library, or this relocation is + against a symbol in a shared library, then we can't know + where the symbol will end up. So, we create a relocation + record in the output, and leave the job up to the dynamic + linker. */ + value = addend; + if (!mips_elf_create_dynamic_relocation (abfd, + info, + relocation, + h, + sec, + symbol, + &value, + input_section)) + return false; + } + else + { + if (r_type != R_MIPS_REL32) + value = symbol + addend; + else + value = addend; + } + value &= howto->dst_mask; + break; - outrel.r_info = ELF32_R_INFO (indx, R_MIPS_REL32); - addend += relocation; - } + case R_MIPS_PC32: + case R_MIPS_PC64: + case R_MIPS_GNU_REL_LO16: + value = symbol + addend - p; + value &= howto->dst_mask; + break; - if (! skip) - bfd_put_32 (output_bfd, addend, contents + rel->r_offset); + case R_MIPS_GNU_REL16_S2: + value = symbol + mips_elf_sign_extend (addend << 2, 18) - p; + overflowed_p = mips_elf_overflow_p (value, 18); + value = (value >> 2) & howto->dst_mask; + break; - bfd_elf32_swap_reloc_out (output_bfd, &outrel, - (((Elf32_External_Rel *) - sreloc->contents) - + sreloc->reloc_count)); - ++sreloc->reloc_count; + case R_MIPS_GNU_REL_HI16: + value = mips_elf_high (addend + symbol - p); + value &= howto->dst_mask; + break; - if (! skip && SGI_COMPAT (output_bfd)) - { - if (scpt == NULL) - continue; + case R_MIPS16_26: + /* The calculation for R_MIPS_26 is just the same as for an + R_MIPS_26. It's only the storage of the relocated field into + the output file that's different. That's handled in + mips_elf_perform_relocation. So, we just fall through to the + R_MIPS_26 case here. */ + case R_MIPS_26: + if (local_p) + value = (((addend << 2) | (p & 0xf0000000)) + symbol) >> 2; + else + value = (mips_elf_sign_extend (addend << 2, 28) + symbol) >> 2; + value &= howto->dst_mask; + break; - /* 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; - } + case R_MIPS_HI16: + if (!gp_disp_p) + { + value = mips_elf_high (addend + symbol); + value &= howto->dst_mask; + } + else + { + value = mips_elf_high (addend + gp - p); + overflowed_p = mips_elf_overflow_p (value, 16); + } + break; - /* 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; + case R_MIPS_LO16: + if (!gp_disp_p) + value = (symbol + addend) & howto->dst_mask; + else + { + value = addend + gp - p + 4; + /* The MIPS ABI requires checking the R_MIPS_LO16 relocation + for overflow. But, on, say, Irix 5, relocations against + _gp_disp are normally generated from the .cpload + pseudo-op. It generates code that normally looks like + this: + + lui $gp,%hi(_gp_disp) + addiu $gp,$gp,%lo(_gp_disp) + addu $gp,$gp,$t9 + + Here $t9 holds the address of the function being called, + as required by the MIPS ELF ABI. The R_MIPS_LO16 + relocation can easily overflow in this situation, but the + R_MIPS_HI16 relocation will handle the overflow. + Therefore, we consider this a bug in the MIPS ABI, and do + not check for overflow here. */ + } + break; - /* 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; + case R_MIPS_LITERAL: + /* Because we don't merge literal sections, we can handle this + just like R_MIPS_GPREL16. In the long run, we should merge + shared literals, and then we will need to additional work + here. */ - 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); - } + /* Fall through. */ - r = _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, - relocation, addend); - if (r == bfd_reloc_ok) - { - unsigned long insn; + case R_MIPS16_GPREL: + /* The R_MIPS16_GPREL performs the same calculation as + R_MIPS_GPREL16, but stores the relocated bits in a different + order. We don't need to do anything special here; the + differences are handled in mips_elf_perform_relocation. */ + case R_MIPS_GPREL16: + if (local_p) + value = mips_elf_sign_extend (addend, 16) + symbol + gp0 - gp; + else + value = mips_elf_sign_extend (addend, 16) + symbol - gp; + overflowed_p = mips_elf_overflow_p (value, 16); + break; + + case R_MIPS_GOT16: + if (local_p) + { + value = mips_elf_got16_entry (abfd, info, symbol + addend); + if (value == (bfd_vma) -1) + return false; + value + = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, + abfd, + value); + overflowed_p = mips_elf_overflow_p (value, 16); + break; + } - 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); - } + /* Fall through. */ - 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) + case R_MIPS_CALL16: + case R_MIPS_GOT_DISP: + value = g; + overflowed_p = mips_elf_overflow_p (value, 16); + break; + + case R_MIPS_GPREL32: + value = (addend + symbol + gp0 - gp) & howto->dst_mask; + break; + + case R_MIPS_PC16: + value = mips_elf_sign_extend (addend, 16) + symbol - p; + value = (bfd_vma) ((bfd_signed_vma) value / 4); + overflowed_p = mips_elf_overflow_p (value, 16); + break; + + case R_MIPS_GOT_HI16: + case R_MIPS_CALL_HI16: + /* We're allowed to handle these two relocations identically. + The dynamic linker is allowed to handle the CALL relocations + differently by creating a lazy evaluation stub. */ + value = g; + value = mips_elf_high (value); + value &= howto->dst_mask; + break; + + case R_MIPS_GOT_LO16: + case R_MIPS_CALL_LO16: + value = g & howto->dst_mask; + break; + + case R_MIPS_GOT_PAGE: + value = mips_elf_got_page (abfd, info, symbol + addend, NULL); + if (value == (bfd_vma) -1) + return false; + value = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, + abfd, + value); + overflowed_p = mips_elf_overflow_p (value, 16); + break; + + case R_MIPS_GOT_OFST: + mips_elf_got_page (abfd, info, symbol + addend, &value); + overflowed_p = mips_elf_overflow_p (value, 16); + break; + + case R_MIPS_SUB: + value = symbol - addend; + value &= howto->dst_mask; + break; + + case R_MIPS_HIGHER: + value = mips_elf_higher (addend + symbol); + value &= howto->dst_mask; + break; + + case R_MIPS_HIGHEST: + value = mips_elf_highest (addend + symbol); + value &= howto->dst_mask; + break; + + case R_MIPS_SCN_DISP: + value = symbol + addend - sec->output_offset; + value &= howto->dst_mask; + break; + + case R_MIPS_PJUMP: + case R_MIPS_JALR: + /* Both of these may be ignored. R_MIPS_JALR is an optimization + hint; we could improve performance by honoring that hint. */ + return bfd_reloc_continue; + + case R_MIPS_GNU_VTINHERIT: + case R_MIPS_GNU_VTENTRY: + /* We don't do anything with these at present. */ + return bfd_reloc_continue; + + default: + /* An unrecognized relocation type. */ + return bfd_reloc_notsupported; + } + + /* Store the VALUE for our caller. */ + *valuep = value; + return overflowed_p ? bfd_reloc_overflow : bfd_reloc_ok; +} + +/* Obtain the field relocated by RELOCATION. */ + +static bfd_vma +mips_elf_obtain_contents (howto, relocation, input_bfd, contents) + reloc_howto_type *howto; + const Elf_Internal_Rela *relocation; + bfd *input_bfd; + bfd_byte *contents; +{ + bfd_vma x; + bfd_byte *location = contents + relocation->r_offset; + + /* Obtain the bytes. */ + x = bfd_get (8 * bfd_get_reloc_size (howto), input_bfd, location); + + if ((ELF32_R_TYPE (relocation->r_info) == R_MIPS16_26 + || ELF32_R_TYPE (relocation->r_info) == R_MIPS16_GPREL) + && bfd_little_endian (input_bfd)) + /* The two 16-bit words will be reversed on a little-endian + system. See mips_elf_perform_relocation for more details. */ + x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16)); + + return x; +} + +/* It has been determined that the result of the RELOCATION is the + VALUE. Use HOWTO to place VALUE into the output file at the + appropriate position. The SECTION is the section to which the + relocation applies. If REQUIRE_JALX is true, then the opcode used + for the relocation must be either JAL or JALX, and it is + unconditionally converted to JALX. + + Returns false if anything goes wrong. */ + +static boolean +mips_elf_perform_relocation (info, howto, relocation, value, + input_bfd, input_section, + contents, require_jalx) + struct bfd_link_info *info; + reloc_howto_type *howto; + const Elf_Internal_Rela *relocation; + bfd_vma value; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents; + boolean require_jalx; +{ + bfd_vma x; + bfd_byte *location; + int r_type = ELF32_R_TYPE (relocation->r_info); + + /* Figure out where the relocation is occurring. */ + location = contents + relocation->r_offset; + + /* Obtain the current value. */ + x = mips_elf_obtain_contents (howto, relocation, input_bfd, contents); + + /* Clear the field we are setting. */ + x &= ~howto->dst_mask; + + /* If this is the R_MIPS16_26 relocation, we must store the + value in a funny way. */ + if (r_type == R_MIPS16_26) + { + /* R_MIPS16_26 is used for the mips16 jal and jalx instructions. + Most mips16 instructions are 16 bits, but these instructions + are 32 bits. + + The format of these instructions is: + + +--------------+--------------------------------+ + ! JALX ! X! Imm 20:16 ! Imm 25:21 ! + +--------------+--------------------------------+ + ! Immediate 15:0 ! + +-----------------------------------------------+ + + JALX is the 5-bit value 00011. X is 0 for jal, 1 for jalx. + Note that the immediate value in the first word is swapped. + + When producing a relocateable object file, R_MIPS16_26 is + handled mostly like R_MIPS_26. In particular, the addend is + stored as a straight 26-bit value in a 32-bit instruction. + (gas makes life simpler for itself by never adjusting a + R_MIPS16_26 reloc to be against a section, so the addend is + always zero). However, the 32 bit instruction is stored as 2 + 16-bit values, rather than a single 32-bit value. In a + big-endian file, the result is the same; in a little-endian + file, the two 16-bit halves of the 32 bit value are swapped. + This is so that a disassembler can recognize the jal + instruction. + + When doing a final link, R_MIPS16_26 is treated as a 32 bit + instruction stored as two 16-bit values. The addend A is the + contents of the targ26 field. The calculation is the same as + R_MIPS_26. When storing the calculated value, reorder the + immediate value as shown above, and don't forget to store the + value as two 16-bit values. + + To put it in MIPS ABI terms, the relocation field is T-targ26-16, + defined as + + big-endian: + +--------+----------------------+ + | | | + | | targ26-16 | + |31 26|25 0| + +--------+----------------------+ + + little-endian: + +----------+------+-------------+ + | | | | + | sub1 | | sub2 | + |0 9|10 15|16 31| + +----------+--------------------+ + where targ26-16 is sub1 followed by sub2 (i.e., the addend field A is + ((sub1 << 16) | sub2)). + + When producing a relocateable object file, the calculation is + (((A < 2) | (P & 0xf0000000) + S) >> 2) + When producing a fully linked file, the calculation is + let R = (((A < 2) | (P & 0xf0000000) + S) >> 2) + ((R & 0x1f0000) << 5) | ((R & 0x3e00000) >> 5) | (R & 0xffff) */ + + if (!info->relocateable) + /* Shuffle the bits according to the formula above. */ + value = (((value & 0x1f0000) << 5) + | ((value & 0x3e00000) >> 5) + | (value & 0xffff)); + + } + else if (r_type == R_MIPS16_GPREL) + { + /* R_MIPS16_GPREL is used for GP-relative addressing in mips16 + mode. A typical instruction will have a format like this: + + +--------------+--------------------------------+ + ! EXTEND ! Imm 10:5 ! Imm 15:11 ! + +--------------+--------------------------------+ + ! Major ! rx ! ry ! Imm 4:0 ! + +--------------+--------------------------------+ + + EXTEND is the five bit value 11110. Major is the instruction + opcode. + + This is handled exactly like R_MIPS_GPREL16, except that the + addend is retrieved and stored as shown in this diagram; that + is, the Imm fields above replace the V-rel16 field. + + All we need to do here is shuffle the bits appropriately. As + above, the two 16-bit halves must be swapped on a + little-endian system. */ + value = (((value & 0x7e0) << 16) + | ((value & 0xf800) << 5) + | (value & 0x1f)); + } + + /* Set the field. */ + x |= (value & howto->dst_mask); + + /* If required, turn JAL into JALX. */ + if (require_jalx) + { + boolean ok; + bfd_vma opcode = x >> 26; + bfd_vma jalx_opcode; + + /* Check to see if the opcode is already JAL or JALX. */ + if (r_type == R_MIPS16_26) + { + ok = ((opcode == 0x6) || (opcode == 0x7)); + jalx_opcode = 0x7; + } + else + { + ok = ((opcode == 0x3) || (opcode == 0x1d)); + jalx_opcode = 0x1d; + } + + /* If the opcode is not JAL or JALX, there's a problem. */ + if (!ok) + { + (*_bfd_error_handler) + (_("%s: %s+0x%lx: jump to stub routine which is not jal"), + bfd_get_filename (input_bfd), + input_section->name, + (unsigned long) relocation->r_offset); + bfd_set_error (bfd_error_bad_value); + return false; + } + + /* Make this the JALX opcode. */ + x = (x & ~(0x3f << 26)) | (jalx_opcode << 26); + } + + /* Swap the high- and low-order 16 bits on little-endian systems + when doing a MIPS16 relocation. */ + if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26) + && bfd_little_endian (input_bfd)) + x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16)); + + /* Put the value into the output. */ + bfd_put (8 * bfd_get_reloc_size (howto), input_bfd, x, location); + return true; +} + +/* Returns true if SECTION is a MIPS16 stub section. */ + +static boolean +mips_elf_stub_section_p (abfd, section) + bfd *abfd ATTRIBUTE_UNUSED; + asection *section; +{ + const char *name = bfd_get_section_name (abfd, section); + + return (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0 + || strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0 + || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0); +} + +/* Relocate a MIPS ELF section. */ + +boolean +_bfd_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_Rela *rel; + const Elf_Internal_Rela *relend; + bfd_vma addend = 0; + boolean use_saved_addend_p = false; + struct elf_backend_data *bed; + + bed = get_elf_backend_data (output_bfd); + relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel; + for (rel = relocs; rel < relend; ++rel) + { + const char *name; + bfd_vma value; + reloc_howto_type *howto; + boolean require_jalx; + /* True if the relocation is a RELA relocation, rather than a + REL relocation. */ + boolean rela_relocation_p = true; + int r_type = ELF32_R_TYPE (rel->r_info); + + /* Find the relocation howto for this relocation. */ + if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd)) + { + /* Some 32-bit code uses R_MIPS_64. In particular, people use + 64-bit code, but make sure all their addresses are in the + lowermost or uppermost 32-bit section of the 64-bit address + space. Thus, when they use an R_MIPS_64 they mean what is + usually meant by R_MIPS_32, with the exception that the + stored value is sign-extended to 64 bits. */ + howto = elf_mips_howto_table + R_MIPS_32; + + /* On big-endian systems, we need to lie about the position + of the reloc. */ + if (bfd_big_endian (input_bfd)) + rel->r_offset += 4; + } + else + howto = mips_rtype_to_howto (r_type); + + if (!use_saved_addend_p) + { + Elf_Internal_Shdr *rel_hdr; + + /* If these relocations were originally of the REL variety, + we must pull the addend out of the field that will be + relocated. Otherwise, we simply use the contents of the + RELA relocation. To determine which flavor or relocation + this is, we depend on the fact that the INPUT_SECTION's + REL_HDR is read before its REL_HDR2. */ + rel_hdr = &elf_section_data (input_section)->rel_hdr; + if ((size_t) (rel - relocs) + >= (rel_hdr->sh_size / rel_hdr->sh_entsize + * bed->s->int_rels_per_ext_rel)) + rel_hdr = elf_section_data (input_section)->rel_hdr2; + if (rel_hdr->sh_entsize == MIPS_ELF_REL_SIZE (input_bfd)) { - unsigned short extend, insn; - bfd_byte buf[4]; - unsigned long final; + /* Note that this is a REL relocation. */ + rela_relocation_p = false; + + /* Get the addend, which is stored in the input file. */ + addend = mips_elf_obtain_contents (howto, + rel, + input_bfd, + contents); + addend &= howto->src_mask; + + /* For some kinds of relocations, the ADDEND is a + combination of the addend stored in two different + relocations. */ + if (r_type == R_MIPS_HI16 + || r_type == R_MIPS_GNU_REL_HI16 + || (r_type == R_MIPS_GOT16 + && mips_elf_local_relocation_p (input_bfd, rel, + local_sections))) + { + bfd_vma l; + const Elf_Internal_Rela *lo16_relocation; + reloc_howto_type *lo16_howto; + int lo; + + /* The combined value is the sum of the HI16 addend, + left-shifted by sixteen bits, and the LO16 + addend, sign extended. (Usually, the code does + a `lui' of the HI16 value, and then an `addiu' of + the LO16 value.) + + Scan ahead to find a matching LO16 relocation. */ + if (r_type == R_MIPS_GNU_REL_HI16) + lo = R_MIPS_GNU_REL_LO16; + else + lo = R_MIPS_LO16; + lo16_relocation + = mips_elf_next_relocation (lo, rel, relend); + if (lo16_relocation == NULL) + return false; - /* 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 + /* Obtain the addend kept there. */ + lo16_howto = mips_rtype_to_howto (lo); + l = mips_elf_obtain_contents (lo16_howto, + lo16_relocation, + input_bfd, contents); + l &= lo16_howto->src_mask; + l = mips_elf_sign_extend (l, 16); + + addend <<= 16; + + /* Compute the combined addend. */ + addend += l; + } + else if (r_type == R_MIPS16_GPREL) { - 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); + /* The addend is scrambled in the object file. See + mips_elf_perform_relocation for details on the + format. */ + addend = (((addend & 0x1f0000) >> 5) + | ((addend & 0x7e00000) >> 16) + | (addend & 0x1f)); } } 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)) + addend = rel->r_addend; + } + + if (info->relocateable) + { + Elf_Internal_Sym *sym; + unsigned long r_symndx; + + if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd) + && bfd_big_endian (input_bfd)) + rel->r_offset -= 4; + + /* Since we're just relocating, all we need to do is copy + the relocations back out to the object file, unless + they're against a section symbol, in which case we need + to adjust by the section offset, or unless they're GP + relative in which case we need to adjust by the amount + that we're adjusting GP in this relocateable object. */ + + if (!mips_elf_local_relocation_p (input_bfd, rel, local_sections)) + /* There's nothing to do for non-local relocations. */ + continue; + + if (r_type == R_MIPS16_GPREL + || r_type == R_MIPS_GPREL16 + || r_type == R_MIPS_GPREL32 + || r_type == R_MIPS_LITERAL) + addend -= (_bfd_get_gp_value (output_bfd) + - _bfd_get_gp_value (input_bfd)); + else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26 + || r_type == R_MIPS_GNU_REL16_S2) + /* The addend is stored without its two least + significant bits (which are always zero.) In a + non-relocateable link, calculate_relocation will do + this shift; here, we must do it ourselves. */ + addend <<= 2; + + r_symndx = ELF32_R_SYM (rel->r_info); + sym = local_syms + r_symndx; + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + /* Adjust the addend appropriately. */ + addend += local_sections[r_symndx]->output_offset; + + /* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16, + then we only want to write out the high-order 16 bits. + The subsequent R_MIPS_LO16 will handle the low-order bits. */ + if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16 + || r_type == R_MIPS_GNU_REL_HI16) + addend = mips_elf_high (addend); + /* If the relocation is for an R_MIPS_26 relocation, then + the two low-order bits are not stored in the object file; + they are implicitly zero. */ + else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26 + || r_type == R_MIPS_GNU_REL16_S2) + addend >>= 2; + + if (rela_relocation_p) + /* If this is a RELA relocation, just update the addend. + We have to cast away constness for REL. */ + rel->r_addend = addend; + else { - 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; + /* Otherwise, we have to write the value back out. Note + that we use the source mask, rather than the + destination mask because the place to which we are + writing will be source of the addend in the final + link. */ + addend &= howto->src_mask; + + if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd)) + /* See the comment above about using R_MIPS_64 in the 32-bit + ABI. Here, we need to update the addend. It would be + possible to get away with just using the R_MIPS_32 reloc + but for endianness. */ + { + bfd_vma sign_bits; + bfd_vma low_bits; + bfd_vma high_bits; + + if (addend & 0x80000000u) + sign_bits = 0xffffffffu; + else + sign_bits = 0; + + /* If we don't know that we have a 64-bit type, + do two separate stores. */ + if (bfd_big_endian (input_bfd)) + { + /* Store the sign-bits (which are most significant) + first. */ + low_bits = sign_bits; + high_bits = addend; + } + else + { + low_bits = addend; + high_bits = sign_bits; + } + bfd_put_32 (input_bfd, low_bits, + contents + rel->r_offset); + bfd_put_32 (input_bfd, high_bits, + contents + rel->r_offset + 4); + continue; + } + + if (!mips_elf_perform_relocation (info, howto, rel, addend, + input_bfd, input_section, + contents, false)) + return false; } - /* 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; + /* Go on to the next relocation. */ + 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); + /* In the N32 and 64-bit ABIs there may be multiple consecutive + relocations for the same offset. In that case we are + supposed to treat the output of each relocation as the addend + for the next. */ + if (rel + 1 < relend + && rel->r_offset == rel[1].r_offset + && ELF32_R_TYPE (rel[1].r_info) != R_MIPS_NONE) + use_saved_addend_p = true; + else + use_saved_addend_p = false; + + /* Figure out what value we are supposed to relocate. */ + switch (mips_elf_calculate_relocation (output_bfd, + input_bfd, + input_section, + info, + rel, + addend, + howto, + local_syms, + local_sections, + &value, + &name, + &require_jalx)) + { + case bfd_reloc_continue: + /* There's nothing to do. */ + continue; - 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 bfd_reloc_undefined: + /* mips_elf_calculate_relocation already called the + undefined_symbol callback. There's no real point in + trying to perform the relocation at this point, so we + just skip ahead to the next relocation. */ + continue; - 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; + case bfd_reloc_notsupported: + abort (); + break; - default: - break; - } + case bfd_reloc_overflow: + if (use_saved_addend_p) + /* Ignore overflow until we reach the last relocation for + a given location. */ + ; + else + { + BFD_ASSERT (name != NULL); + 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_ok: + break; + + default: + abort (); + break; + } + + /* If we've got another relocation for the address, keep going + until we reach the last one. */ + if (use_saved_addend_p) + { + addend = value; + continue; } - if (r != bfd_reloc_ok) + if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd)) + /* See the comment above about using R_MIPS_64 in the 32-bit + ABI. Until now, we've been using the HOWTO for R_MIPS_32; + that calculated the right value. Now, however, we + sign-extend the 32-bit result to 64-bits, and store it as a + 64-bit value. We are especially generous here in that we + go to extreme lengths to support this usage on systems with + only a 32-bit VMA. */ { - switch (r) + bfd_vma sign_bits; + bfd_vma low_bits; + bfd_vma high_bits; + + if (value & 0x80000000u) + sign_bits = 0xffffffffu; + else + sign_bits = 0; + + /* If we don't know that we have a 64-bit type, + do two separate stores. */ + if (bfd_big_endian (input_bfd)) { - 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; + /* Undo what we did above. */ + rel->r_offset -= 4; + /* Store the sign-bits (which are most significant) + first. */ + low_bits = sign_bits; + high_bits = value; } + else + { + low_bits = value; + high_bits = sign_bits; + } + bfd_put_32 (input_bfd, low_bits, + contents + rel->r_offset); + bfd_put_32 (input_bfd, high_bits, + contents + rel->r_offset + 4); + continue; } + + /* Actually perform the relocation. */ + if (!mips_elf_perform_relocation (info, howto, rel, value, input_bfd, + input_section, contents, + require_jalx)) + return false; } return true; @@ -5665,11 +6902,11 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; +boolean +_bfd_mips_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec) + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; Elf_Internal_Sym *sym; asection *input_sec; { @@ -5692,12 +6929,15 @@ mips_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec) /* The name of the dynamic interpreter. This is put in the .interp section. */ -#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1" +#define ELF_DYNAMIC_INTERPRETER(abfd) \ + (ABI_N32_P (abfd) ? "/usr/lib32/libc.so.1" \ + : ABI_64_P (abfd) ? "/usr/lib64/libc.so.1" \ + : "/usr/lib/libc.so.1") /* Create dynamic sections when linking against a dynamic object. */ -static boolean -mips_elf_create_dynamic_sections (abfd, info) +boolean +_bfd_mips_elf_create_dynamic_sections (abfd, info) bfd *abfd; struct bfd_link_info *info; { @@ -5721,28 +6961,42 @@ mips_elf_create_dynamic_sections (abfd, info) if (! mips_elf_create_got_section (abfd, info)) return false; + /* Create the .msym section on IRIX6. It is used by the dynamic + linker to speed up dynamic relocations, and to avoid computing + the ELF hash for symbols. */ + if (IRIX_COMPAT (abfd) == ict_irix6 + && !mips_elf_create_msym_section (abfd)) + return false; + /* Create .stub section. */ - if (bfd_get_section_by_name (abfd, ".stub") == NULL) + if (bfd_get_section_by_name (abfd, + MIPS_ELF_STUB_SECTION_NAME (abfd)) == NULL) { - s = bfd_make_section (abfd, ".stub"); + s = bfd_make_section (abfd, MIPS_ELF_STUB_SECTION_NAME (abfd)); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags) - || ! bfd_set_section_alignment (abfd, s, 2)) + || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE) + || ! bfd_set_section_alignment (abfd, s, + MIPS_ELF_LOG_FILE_ALIGN (abfd))) return false; } - if (SGI_COMPAT (abfd) + if (IRIX_COMPAT (abfd) == ict_irix5 && !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)) + || ! bfd_set_section_alignment (abfd, s, + MIPS_ELF_LOG_FILE_ALIGN (abfd))) return false; } - if (SGI_COMPAT (abfd)) + /* On IRIX5, we adjust add some additional symbols and change the + alignments of several sections. There is no ABI documentation + indicating that this is necessary on IRIX6, nor any evidence that + the linker takes such action. */ + if (IRIX_COMPAT (abfd) == ict_irix5) { for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++) { @@ -5832,7 +7086,7 @@ mips_elf_create_dynamic_sections (abfd, info) static boolean mips_elf_create_compact_rel_section (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { flagword flags; register asection *s; @@ -5845,7 +7099,8 @@ mips_elf_create_compact_rel_section (abfd, info) s = bfd_make_section (abfd, ".compact_rel"); if (s == NULL || ! bfd_set_section_flags (abfd, s, flags) - || ! bfd_set_section_alignment (abfd, s, 2)) + || ! bfd_set_section_alignment (abfd, s, + MIPS_ELF_LOG_FILE_ALIGN (abfd))) return false; s->_raw_size = sizeof (Elf32_External_compact_rel); @@ -5867,7 +7122,7 @@ mips_elf_create_got_section (abfd, info) struct mips_got_info *g; /* This function may be called more than once. */ - if (bfd_get_section_by_name (abfd, ".got") != NULL) + if (mips_elf_got_section (abfd)) return true; flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY @@ -5898,13 +7153,13 @@ mips_elf_create_got_section (abfd, info) return false; /* The first several global offset table entries are reserved. */ - s->_raw_size = MIPS_RESERVED_GOTNO * 4; + s->_raw_size = MIPS_RESERVED_GOTNO * MIPS_ELF_GOT_SIZE (abfd); g = (struct mips_got_info *) bfd_alloc (abfd, sizeof (struct mips_got_info)); if (g == NULL) return false; - g->global_gotsym = 0; + g->global_gotsym = NULL; g->local_gotno = MIPS_RESERVED_GOTNO; g->assigned_gotno = MIPS_RESERVED_GOTNO; if (elf_section_data (s) == NULL) @@ -5915,15 +7170,66 @@ mips_elf_create_got_section (abfd, info) return false; } elf_section_data (s)->tdata = (PTR) g; + elf_section_data (s)->this_hdr.sh_flags + |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL; return true; } +/* Returns the .msym section for ABFD, creating it if it does not + already exist. Returns NULL to indicate error. */ + +static asection * +mips_elf_create_msym_section (abfd) + bfd *abfd; +{ + asection *s; + + s = bfd_get_section_by_name (abfd, MIPS_ELF_MSYM_SECTION_NAME (abfd)); + if (!s) + { + s = bfd_make_section (abfd, MIPS_ELF_MSYM_SECTION_NAME (abfd)); + if (!s + || !bfd_set_section_flags (abfd, s, + SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_LINKER_CREATED + | SEC_READONLY) + || !bfd_set_section_alignment (abfd, s, + MIPS_ELF_LOG_FILE_ALIGN (abfd))) + return NULL; + } + + return s; +} + +/* Add room for N relocations to the .rel.dyn section in ABFD. */ + +static void +mips_elf_allocate_dynamic_relocations (abfd, n) + bfd *abfd; + unsigned int n; +{ + asection *s; + + s = bfd_get_section_by_name (abfd, MIPS_ELF_REL_DYN_SECTION_NAME (abfd)); + BFD_ASSERT (s != NULL); + + if (s->_raw_size == 0) + { + /* Make room for a null element. */ + s->_raw_size += MIPS_ELF_REL_SIZE (abfd); + ++s->reloc_count; + } + s->_raw_size += n * MIPS_ELF_REL_SIZE (abfd); +} + /* 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) +boolean +_bfd_mips_elf_check_relocs (abfd, info, sec, relocs) bfd *abfd; struct bfd_link_info *info; asection *sec; @@ -5939,6 +7245,7 @@ mips_elf_check_relocs (abfd, info, sec, relocs) const Elf_Internal_Rela *rel_end; asection *sgot; asection *sreloc; + struct elf_backend_data *bed; if (info->relocateable) return true; @@ -6023,7 +7330,7 @@ mips_elf_check_relocs (abfd, info, sec, relocs) asection **n; if (elf_bad_symtab (abfd)) - symcount = symtab_hdr->sh_size / sizeof (Elf32_External_Sym); + symcount = symtab_hdr->sh_size / symtab_hdr->sh_entsize; else symcount = symtab_hdr->sh_info; n = (asection **) bfd_zalloc (abfd, @@ -6113,7 +7420,7 @@ mips_elf_check_relocs (abfd, info, sec, relocs) } else { - sgot = bfd_get_section_by_name (dynobj, ".got"); + sgot = mips_elf_got_section (dynobj); if (sgot == NULL) g = NULL; else @@ -6125,14 +7432,16 @@ mips_elf_check_relocs (abfd, info, sec, relocs) } sreloc = NULL; - - rel_end = relocs + sec->reloc_count; - for (rel = relocs; rel < rel_end; rel++) + bed = get_elf_backend_data (abfd); + rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel; + for (rel = relocs; rel < rel_end; ++rel) { unsigned long r_symndx; + int r_type; struct elf_link_hash_entry *h; r_symndx = ELF32_R_SYM (rel->r_info); + r_type = ELF32_R_TYPE (rel->r_info); if (r_symndx < extsymoff) h = NULL; @@ -6151,7 +7460,7 @@ mips_elf_check_relocs (abfd, info, sec, relocs) /* Some relocs require a global offset table. */ if (dynobj == NULL || sgot == NULL) { - switch (ELF32_R_TYPE (rel->r_info)) + switch (r_type) { case R_MIPS_GOT16: case R_MIPS_CALL16: @@ -6159,19 +7468,19 @@ mips_elf_check_relocs (abfd, info, sec, relocs) case R_MIPS_CALL_LO16: case R_MIPS_GOT_HI16: case R_MIPS_GOT_LO16: + case R_MIPS_GOT_PAGE: + case R_MIPS_GOT_OFST: + case R_MIPS_GOT_DISP: 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); + g = mips_elf_got_info (dynobj, &sgot); break; case R_MIPS_32: case R_MIPS_REL32: + case R_MIPS_64: if (dynobj == NULL && (info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0) @@ -6183,13 +7492,29 @@ mips_elf_check_relocs (abfd, info, sec, relocs) } } - switch (ELF32_R_TYPE (rel->r_info)) + if (!h && (r_type == R_MIPS_CALL_LO16 + || r_type == R_MIPS_GOT_LO16 + || r_type == R_MIPS_GOT_DISP)) { - case R_MIPS_CALL16: - case R_MIPS_CALL_HI16: - case R_MIPS_CALL_LO16: - /* This symbol requires a global offset table entry. */ + /* We may need a local GOT entry for this relocation. We + don't count R_MIPS_GOT_PAGE because we can estimate the + maximum number of pages needed by looking at the size of + the segment. Similar comments apply to R_MIPS_GOT16. We + don't count R_MIPS_GOT_HI16, or R_MIPS_CALL_HI16 because + these are always followed by an R_MIPS_GOT_LO16 or + R_MIPS_CALL_LO16. + + This estimation is very conservative since we can merge + duplicate entries in the GOT. In order to be less + conservative, we could actually build the GOT here, + rather than in relocate_section. */ + g->local_gotno++; + sgot->_raw_size += MIPS_ELF_GOT_SIZE (dynobj); + } + switch (r_type) + { + case R_MIPS_CALL16: if (h == NULL) { (*_bfd_error_handler) @@ -6198,75 +7523,42 @@ mips_elf_check_relocs (abfd, info, sec, relocs) bfd_set_error (bfd_error_bad_value); return false; } + /* Fall through. */ - /* Make sure this symbol is output as a dynamic symbol. */ - if (h->dynindx == -1) + case R_MIPS_CALL_HI16: + case R_MIPS_CALL_LO16: + if (h != NULL) { - if (! bfd_elf32_link_record_dynamic_symbol (info, h)) + /* This symbol requires a global offset table entry. */ + if (!mips_elf_record_global_got_symbol (h, info, g)) return false; - } - if (h->got.offset != (bfd_vma) -1) - { - /* We have already allocated space in the .got. */ - break; + /* 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; } - - /* 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: + case R_MIPS_GOT_DISP: /* 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; - } - + if (h && !mips_elf_record_global_got_symbol (h, info, g)) + return false; break; case R_MIPS_32: case R_MIPS_REL32: + case R_MIPS_64: if ((info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0) { if (sreloc == NULL) { - const char *name = ".rel.dyn"; + const char *name = MIPS_ELF_REL_DYN_SECTION_NAME (dynobj); sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) @@ -6286,19 +7578,11 @@ mips_elf_check_relocs (abfd, info, sec, relocs) } } 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); - } + /* 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. */ + mips_elf_allocate_dynamic_relocations (dynobj, 1); else { struct mips_elf_link_hash_entry *hmips; @@ -6306,21 +7590,28 @@ mips_elf_check_relocs (abfd, info, sec, relocs) /* 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; + ++hmips->possibly_dynamic_relocs; } + + /* Even though we don't directly need a GOT entry for + this symbol, a symbol must have a dynamic symbol + table index greater that DT_MIPS_GOTSYM if there are + dynamic relocations against it. */ + if (h != NULL + && !mips_elf_record_global_got_symbol (h, info, g)) + return false; } - if (SGI_COMPAT (abfd)) + if (SGI_COMPAT (dynobj)) 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)) + if (SGI_COMPAT (dynobj)) mips_elf_hash_table (info)->compact_rel_size += sizeof (Elf32_External_crinfo); break; @@ -6347,7 +7638,7 @@ mips_elf_check_relocs (abfd, info, sec, relocs) 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 + && r_type != 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, @@ -6368,10 +7659,10 @@ mips_elf_check_relocs (abfd, info, sec, relocs) /* 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) +asection * +_bfd_mips_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -6417,12 +7708,12 @@ mips_elf_gc_mark_hook (abfd, info, rel, h, sym) /* 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; +boolean +_bfd_mips_elf_gc_sweep_hook (abfd, info, sec, relocs) + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { #if 0 Elf_Internal_Shdr *symtab_hdr; @@ -6466,8 +7757,8 @@ mips_elf_gc_sweep_hook (abfd, info, sec, relocs) change the definition to something the rest of the link can understand. */ -static boolean -mips_elf_adjust_dynamic_symbol (info, h) +boolean +_bfd_mips_elf_adjust_dynamic_symbol (info, h) struct bfd_link_info *info; struct elf_link_hash_entry *h; { @@ -6493,20 +7784,10 @@ mips_elf_adjust_dynamic_symbol (info, h) file. */ hmips = (struct mips_elf_link_hash_entry *) h; if (! info->relocateable - && hmips->mips_32_relocs != 0 + && hmips->possibly_dynamic_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); - } + mips_elf_allocate_dynamic_relocations (dynobj, + hmips->possibly_dynamic_relocs); /* For a function, create a stub, if needed. */ if (h->type == STT_FUNC @@ -6522,7 +7803,8 @@ mips_elf_adjust_dynamic_symbol (info, h) if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { /* We need .stub section. */ - s = bfd_get_section_by_name (dynobj, ".stub"); + s = bfd_get_section_by_name (dynobj, + MIPS_ELF_STUB_SECTION_NAME (dynobj)); BFD_ASSERT (s != NULL); h->root.u.def.section = s; @@ -6565,8 +7847,8 @@ mips_elf_adjust_dynamic_symbol (info, h) 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) +boolean +_bfd_mips_elf_always_size_sections (output_bfd, info) bfd *output_bfd; struct bfd_link_info *info; { @@ -6595,7 +7877,7 @@ mips_elf_always_size_sections (output_bfd, info) static boolean mips_elf_check_mips16_stubs (h, data) struct mips_elf_link_hash_entry *h; - PTR data; + PTR data ATTRIBUTE_UNUSED; { if (h->fn_stub != NULL && ! h->need_fn_stub) @@ -6641,16 +7923,15 @@ mips_elf_check_mips16_stubs (h, data) /* Set the sizes of the dynamic sections. */ -static boolean -mips_elf_size_dynamic_sections (output_bfd, info) +boolean +_bfd_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; + struct mips_got_info *g = NULL; dynobj = elf_hash_table (info)->dynobj; BFD_ASSERT (dynobj != NULL); @@ -6662,43 +7943,13 @@ mips_elf_size_dynamic_sections (output_bfd, info) { 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; + s->_raw_size + = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1; + s->contents + = (bfd_byte *) ELF_DYNAMIC_INTERPRETER (output_bfd); } } - /* 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. */ @@ -6749,30 +8000,76 @@ mips_elf_size_dynamic_sections (output_bfd, info) if ((target != NULL && (target->flags & SEC_READONLY) != 0 && (target->flags & SEC_ALLOC) != 0) - || strcmp (outname, ".rel.dyn") == 0) + || strcmp (outname, + MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)) == 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) + if (strcmp (name, + MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)) != 0) s->reloc_count = 0; } } else if (strncmp (name, ".got", 4) == 0) { int i; + bfd_size_type loadable_size = 0; + bfd_size_type local_gotno; + struct _bfd *sub; - BFD_ASSERT (elf_section_data (s) != NULL); + 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; + BFD_ASSERT (g != NULL); + + /* Calculate the total loadable size of the output. That + will give us the maximum number of GOT_PAGE entries + required. */ + for (sub = info->input_bfds; sub; sub = sub->link_next) + { + asection *subsection; + + for (subsection = sub->sections; + subsection; + subsection = subsection->next) + { + if ((subsection->flags & SEC_ALLOC) == 0) + continue; + loadable_size += (subsection->_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; + if (IRIX_COMPAT (output_bfd) == ict_irix6) + /* It's possible we will need GOT_PAGE entries as well as + GOT16 entries. Often, these will be able to share GOT + entries, but not always. */ + local_gotno *= 2; + + g->local_gotno += local_gotno; + s->_raw_size += local_gotno * MIPS_ELF_GOT_SIZE (dynobj); + + /* There has to be a global GOT entry for every symbol with + a dynamic symbol table index of DT_MIPS_GOTSYM or + higher. Therefore, it make sense to put those symbols + that need GOT entries at the end of the symbol table. We + do that here. */ + if (!mips_elf_sort_hash_table (info, 1)) + return false; + + if (g->global_gotsym != NULL) + i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx; + else + /* If there are no global symbols, or none requiring + relocations, then GLOBAL_GOTSYM will be NULL. */ + i = 0; + g->global_gotno = i; + s->_raw_size += i * MIPS_ELF_GOT_SIZE (dynobj); } - else if (strncmp (name, ".stub", 5) == 0) + else if (strcmp (name, MIPS_ELF_STUB_SECTION_NAME (output_bfd)) == 0) { /* Irix rld assumes that the function stub isn't at the end of .text section. So put a dummy. XXX */ @@ -6789,6 +8086,11 @@ mips_elf_size_dynamic_sections (output_bfd, info) 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 (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (output_bfd)) + == 0) + s->_raw_size = (sizeof (Elf32_External_Msym) + * (elf_hash_table (info)->dynsymcount + + bfd_count_sections (output_bfd))); else if (strncmp (name, ".init", 5) != 0) { /* It's not one of our sections, so don't allocate space. */ @@ -6797,18 +8099,17 @@ mips_elf_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (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) @@ -6824,206 +8125,166 @@ mips_elf_size_dynamic_sections (output_bfd, info) { /* 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)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0)) return false; } else - if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0)) return false; } if (reltext) { - if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0)) return false; } - if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0)) return false; - if (bfd_get_section_by_name (dynobj, ".rel.dyn")) + if (bfd_get_section_by_name (dynobj, + MIPS_ELF_REL_DYN_SECTION_NAME (dynobj))) { - if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_RELENT, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0)) return false; } - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_CONFLICTNO, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICTNO, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LIBLISTNO, 0)) + if (! MIPS_ELF_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)) + if (! MIPS_ELF_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)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLIST, 0)) return false; } - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_RLD_VERSION, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_VERSION, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_FLAGS, 0)) + if (! MIPS_ELF_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)) + if (! MIPS_ELF_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)) + if (! MIPS_ELF_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)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_IVERSION, 0)) return false; #endif - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_BASE_ADDRESS, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_BASE_ADDRESS, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LOCAL_GOTNO, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LOCAL_GOTNO, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_SYMTABNO, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_SYMTABNO, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_UNREFEXTNO, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_UNREFEXTNO, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_GOTSYM, 0)) + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_GOTSYM, 0)) return false; - if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_HIPAGENO, 0)) + if (IRIX_COMPAT (dynobj) == ict_irix5 + && ! MIPS_ELF_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 (IRIX_COMPAT (dynobj) == ict_irix6 + && (bfd_get_section_by_name + (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj))) + && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 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 (bfd_get_section_by_name (dynobj, + MIPS_ELF_MSYM_SECTION_NAME (dynobj)) + && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_MSYM, 0)) + return false; } - /* 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. */ +/* If NAME is one of the special IRIX6 symbols defined by the linker, + adjust it appropriately now. */ -static boolean -mips_elf_adjust_dynindx (h, cparg) - struct elf_link_hash_entry *h; - PTR cparg; +static void +mips_elf_irix6_finish_dynamic_symbol (abfd, name, sym) + bfd *abfd ATTRIBUTE_UNUSED; + const char *name; + Elf_Internal_Sym *sym; { - unsigned int *cp = (unsigned int *) cparg; - - if (h->dynindx != -1) - h->dynindx += *cp; - return true; + /* The linker script takes care of providing names and values for + these, but we must place them into the right sections. */ + static const char* const text_section_symbols[] = { + "_ftext", + "_etext", + "__dso_displacement", + "__elf_header", + "__program_header_table", + NULL + }; + + static const char* const data_section_symbols[] = { + "_fdata", + "_edata", + "_end", + "_fbss", + NULL + }; + + const char* const *p; + int i; + + for (i = 0; i < 2; ++i) + for (p = (i == 0) ? text_section_symbols : data_section_symbols; + *p; + ++p) + if (strcmp (*p, name) == 0) + { + /* All of these symbols are given type STT_SECTION by the + IRIX6 linker. */ + sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION); + + /* The IRIX linker puts these symbols in special sections. */ + if (i == 0) + sym->st_shndx = SHN_MIPS_TEXT; + else + sym->st_shndx = SHN_MIPS_DATA; + + break; + } } /* 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) +boolean +_bfd_mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) bfd *output_bfd; struct bfd_link_info *info; struct elf_link_hash_entry *h; @@ -7032,11 +8293,14 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) bfd *dynobj; bfd_vma gval; asection *sgot; + asection *smsym; struct mips_got_info *g; const char *name; + struct mips_elf_link_hash_entry *mh; dynobj = elf_hash_table (info)->dynobj; gval = sym->st_value; + mh = (struct mips_elf_link_hash_entry *) h; if (h->plt.offset != (bfd_vma) -1) { @@ -7048,7 +8312,8 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) BFD_ASSERT (h->dynindx != -1); - s = bfd_get_section_by_name (dynobj, ".stub"); + s = bfd_get_section_by_name (dynobj, + MIPS_ELF_STUB_SECTION_NAME (dynobj)); BFD_ASSERT (s != NULL); /* Fill the stub. */ @@ -7082,25 +8347,48 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) BFD_ASSERT (h->dynindx != -1); - sgot = bfd_get_section_by_name (dynobj, ".got"); + sgot = mips_elf_got_section (dynobj); 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) + /* Run through the global symbol table, creating GOT entries for all + the symbols that need them. */ + if (g->global_gotsym != NULL + && h->dynindx >= g->global_gotsym->dynindx) { - bfd_size_type offset; + bfd_vma offset; + bfd_vma value; - /* 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); - } + if (sym->st_value) + value = sym->st_value; + else + /* For an entity defined in a shared object, this will be + NULL. (For functions in shared objects for + which we have created stubs, ST_VALUE will be non-NULL. + That's because such the functions are now no longer defined + in a shared object.) */ + value = h->root.u.def.value; + + offset = mips_elf_global_got_index (dynobj, h); + MIPS_ELF_PUT_WORD (output_bfd, value, sgot->contents + offset); + } + + /* Create a .msym entry, if appropriate. */ + smsym = bfd_get_section_by_name (dynobj, + MIPS_ELF_MSYM_SECTION_NAME (dynobj)); + if (smsym) + { + Elf32_Internal_Msym msym; + + msym.ms_hash_value = bfd_elf_hash (h->root.root.string); + /* It is undocumented what the `1' indicates, but IRIX6 uses + this value. */ + msym.ms_info = ELF32_MS_INFO (mh->min_dyn_reloc_index, 1); + bfd_mips_elf_swap_msym_out + (dynobj, &msym, + ((Elf32_External_Msym *) smsym->contents) + h->dynindx); } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ @@ -7146,6 +8434,10 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) } } + /* Handle the IRIX6-specific symbols. */ + if (IRIX_COMPAT (output_bfd) == ict_irix6) + mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym); + if (SGI_COMPAT (output_bfd) && ! info->shared) { @@ -7162,8 +8454,10 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 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); + /* IRIX6 does not use a .rld_map section. */ + if (IRIX_COMPAT (output_bfd) == ict_irix5) + BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map") + != NULL); mips_elf_hash_table (info)->rld_value = sym->st_value; } } @@ -7178,8 +8472,8 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) /* Finish up the dynamic sections. */ -static boolean -mips_elf_finish_dynamic_sections (output_bfd, info) +boolean +_bfd_mips_elf_finish_dynamic_sections (output_bfd, info) bfd *output_bfd; struct bfd_link_info *info; { @@ -7192,7 +8486,7 @@ mips_elf_finish_dynamic_sections (output_bfd, info) sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); - sgot = bfd_get_section_by_name (dynobj, ".got"); + sgot = mips_elf_got_section (dynobj); if (sgot == NULL) g = NULL; else @@ -7204,39 +8498,41 @@ mips_elf_finish_dynamic_sections (output_bfd, info) if (elf_hash_table (info)->dynamic_sections_created) { - Elf32_External_Dyn *dyncon, *dynconend; + bfd_byte *b; 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++) + for (b = sdyn->contents; + b < sdyn->contents + sdyn->_raw_size; + b += MIPS_ELF_DYN_SIZE (dynobj)) { Elf_Internal_Dyn dyn; const char *name; size_t elemsize; asection *s; + boolean swap_out_p; - bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); + /* Read in the current dynamic entry. */ + (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn); + + /* Assume that we're going to modify it and write it out. */ + swap_out_p = true; switch (dyn.d_tag) { - default: - break; - case DT_RELENT: - s = bfd_get_section_by_name (dynobj, ".rel.dyn"); + s = (bfd_get_section_by_name + (dynobj, + MIPS_ELF_REL_DYN_SECTION_NAME (dynobj))); BFD_ASSERT (s != NULL); - dyn.d_un.d_val = sizeof (Elf32_External_Rel); - bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + dyn.d_un.d_val = MIPS_ELF_REL_SIZE (dynobj); 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: @@ -7251,17 +8547,14 @@ mips_elf_finish_dynamic_sections (output_bfd, info) 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: @@ -7283,38 +8576,52 @@ mips_elf_finish_dynamic_sections (output_bfd, info) } 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: */ + swap_out_p = false; break; case DT_MIPS_IVERSION: /* XXX FIXME: */ + swap_out_p = false; 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_UNREFEXTNO: + /* The index into the dynamic symbol table which is the + entry of the first external symbol that is not + referenced within the same object. */ + dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1; + break; + + case DT_MIPS_GOTSYM: + if (g->global_gotsym) + { + dyn.d_un.d_val = g->global_gotsym->dynindx; + break; + } + /* In case if we don't have global got symbols we default + to setting DT_MIPS_GOTSYM to the same value as + DT_MIPS_SYMTABNO, so we just fall through. */ + case DT_MIPS_SYMTABNO: name = ".dynsym"; - elemsize = sizeof (Elf32_External_Sym); + elemsize = MIPS_ELF_SYM_SIZE (output_bfd); s = bfd_get_section_by_name (output_bfd, name); BFD_ASSERT (s != NULL); @@ -7322,34 +8629,36 @@ mips_elf_finish_dynamic_sections (output_bfd, info) 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; + case DT_MIPS_OPTIONS: + s = (bfd_get_section_by_name + (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd))); + dyn.d_un.d_ptr = s->vma; + break; + + case DT_MIPS_MSYM: + s = (bfd_get_section_by_name + (output_bfd, MIPS_ELF_MSYM_SECTION_NAME (output_bfd))); + dyn.d_un.d_ptr = s->vma; + break; + + default: + swap_out_p = false; + break; } + + if (swap_out_p) + (*get_elf_backend_data (dynobj)->s->swap_dyn_out) + (dynobj, &dyn, b); } } @@ -7358,106 +8667,41 @@ mips_elf_finish_dynamic_sections (output_bfd, info) 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); + MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0, sgot->contents); + MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0x80000000, + sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd)); } if (sgot != NULL) - elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; + elf_section_data (sgot->output_section)->this_hdr.sh_entsize + = MIPS_ELF_GOT_SIZE (output_bfd); { - asection *sdynsym; + asection *smsym; 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? */ + /* ??? The section symbols for the output sections were set up in + _bfd_elf_final_link. SGI sets the STT_NOTYPE attribute for these + symbols. Should we do so? */ - sdynsym = bfd_get_section_by_name (dynobj, ".dynsym"); - if (sdynsym != NULL) + smsym = bfd_get_section_by_name (dynobj, + MIPS_ELF_MSYM_SECTION_NAME (dynobj)); + if (smsym != 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; + Elf32_Internal_Msym msym; - 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)); - } + msym.ms_hash_value = 0; + msym.ms_info = ELF32_MS_INFO (0, 1); - /* 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 */ + for (s = output_bfd->sections; s != NULL; s = s->next) { - 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; + long dynindx = elf_section_data (s)->dynindx; - 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; + bfd_mips_elf_swap_msym_out + (output_bfd, &msym, + (((Elf32_External_Msym *) smsym->contents) + + dynindx)); } } @@ -7479,7 +8723,8 @@ mips_elf_finish_dynamic_sections (output_bfd, info) s->contents)); /* Clean up a dummy stub function entry in .text. */ - s = bfd_get_section_by_name (dynobj, ".stub"); + s = bfd_get_section_by_name (dynobj, + MIPS_ELF_STUB_SECTION_NAME (dynobj)); if (s != NULL) { file_ptr dummy_offset; @@ -7493,9 +8738,10 @@ mips_elf_finish_dynamic_sections (output_bfd, info) } /* Clean up a first relocation in .rel.dyn. */ - s = bfd_get_section_by_name (dynobj, ".rel.dyn"); + s = bfd_get_section_by_name (dynobj, + MIPS_ELF_REL_DYN_SECTION_NAME (dynobj)); if (s != NULL && s->_raw_size > 0) - memset (s->contents, 0, sizeof (Elf32_External_Rel)); + memset (s->contents, 0, MIPS_ELF_REL_SIZE (dynobj)); } return true; @@ -7648,7 +8894,8 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data, 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))) + input_bfd, input_section, (*parent)->address, + true))) goto error_return; break; case bfd_reloc_dangerous: @@ -7743,30 +8990,53 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = #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_backend_sign_extend_vma true +#define elf_info_to_howto mips_info_to_howto_rela #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_object_p _bfd_mips_elf_object_p +#define elf_backend_section_from_shdr _bfd_mips_elf_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_section_processing _bfd_mips_elf_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 + _bfd_mips_elf_additional_program_headers +#define elf_backend_modify_segment_map _bfd_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 elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook +#define elf_backend_create_dynamic_sections \ + _bfd_mips_elf_create_dynamic_sections +#define elf_backend_check_relocs _bfd_mips_elf_check_relocs +#define elf_backend_adjust_dynamic_symbol \ + _bfd_mips_elf_adjust_dynamic_symbol +#define elf_backend_always_size_sections \ + _bfd_mips_elf_always_size_sections +#define elf_backend_size_dynamic_sections \ + _bfd_mips_elf_size_dynamic_sections +#define elf_backend_relocate_section _bfd_mips_elf_relocate_section +#define elf_backend_link_output_symbol_hook \ + _bfd_mips_elf_link_output_symbol_hook +#define elf_backend_finish_dynamic_symbol \ + _bfd_mips_elf_finish_dynamic_symbol +#define elf_backend_finish_dynamic_sections \ + _bfd_mips_elf_finish_dynamic_sections +#define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook +#define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook + +#define elf_backend_got_header_size (4*MIPS_RESERVED_GOTNO) +#define elf_backend_plt_header_size 0 #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 + _bfd_mips_elf_link_hash_table_create +#define bfd_elf32_bfd_final_link _bfd_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 \ @@ -7774,27 +9044,4 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = #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-pj.c b/bfd/elf32-pj.c new file mode 100644 index 0000000..3b96949 --- /dev/null +++ b/bfd/elf32-pj.c @@ -0,0 +1,349 @@ +/* picoJava specific support for 32-bit ELF + Copyright 1999 Free Software Foundation, Inc. + Contributed by Steve Chamberlan of Transmeta (sac@pobox.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 "elf-bfd.h" +#include "elf/pj.h" + +static bfd_reloc_status_type pj_elf_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *pj_elf_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); +static void pj_elf_info_to_howto + PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); + +static reloc_howto_type pj_elf_howto_table[] = +{ + /* No relocation. */ + HOWTO (R_PJ_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 */ + pj_elf_reloc, /* special_function */ + "R_PJ_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_PJ_DATA_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 */ + pj_elf_reloc, /* special_function */ + "R_PJ_DIR32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 32 bit PC relative relocation. */ + HOWTO (R_PJ_CODE_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 */ + pj_elf_reloc, /* special_function */ + "R_PJ_REL32", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + true), /* pcrel_offset */ + +/* 16 bit PC relative relocation. */ + HOWTO (R_PJ_CODE_REL16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overf6w */ + pj_elf_reloc, /* special_function */ + "R_PJ_REL16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (4), + EMPTY_HOWTO (5), + HOWTO (R_PJ_CODE_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 */ + pj_elf_reloc, /* special_function */ + "R_PJ_CODE_DIR32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + EMPTY_HOWTO (7), + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + + HOWTO (R_PJ_CODE_LO16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_LO16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + + HOWTO (R_PJ_CODE_HI16, /* type */ + 16, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_HI16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* GNU extension to record C++ vtable hierarchy */ + HOWTO (R_PJ_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_PJ_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_PJ_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_PJ_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 +pj_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 ATTRIBUTE_UNUSED; +{ + unsigned long insn; + bfd_vma sym_value; + enum elf_pj_reloc_type r_type; + bfd_vma addr = reloc_entry->address; + bfd_byte *hit_data = addr + (bfd_byte *) data; + + r_type = (enum elf_pj_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; + } + + 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_PJ_DATA_DIR32: + insn = bfd_get_32 (abfd, hit_data); + insn += sym_value + reloc_entry->addend; + bfd_put_32 (abfd, insn, hit_data); + break; + + /* Relocations in code are always bigendian, no matter what the + data endianness is. */ + + case R_PJ_CODE_DIR32: + insn = bfd_getb32 (hit_data); + insn += sym_value + reloc_entry->addend; + bfd_putb32 (insn, hit_data); + break; + + case R_PJ_CODE_REL16: + insn = bfd_getb16 (hit_data); + insn += sym_value + reloc_entry->addend + - (input_section->output_section->vma + + input_section->output_offset); + bfd_putb16 (insn, hit_data); + break; + case R_PJ_CODE_LO16: + insn = bfd_getb16 (hit_data); + insn += sym_value + reloc_entry->addend; + bfd_putb16 (insn, hit_data); + break; + + case R_PJ_CODE_HI16: + insn = bfd_getb16 (hit_data); + insn += (sym_value + reloc_entry->addend) >> 16; + bfd_putb16 (insn, hit_data); + break; + + default: + abort (); + break; + } + + return bfd_reloc_ok; +} + +/* This structure is used to map BFD reloc codes to PJ 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 PJ ELF relocs. */ + +static const struct elf_reloc_map pj_reloc_map[] = +{ + { BFD_RELOC_NONE, R_PJ_NONE }, + { BFD_RELOC_32, R_PJ_DATA_DIR32 }, + { BFD_RELOC_PJ_CODE_DIR16, R_PJ_CODE_DIR16 }, + { BFD_RELOC_PJ_CODE_DIR32, R_PJ_CODE_DIR32 }, + { BFD_RELOC_PJ_CODE_LO16, R_PJ_CODE_LO16 }, + { BFD_RELOC_PJ_CODE_HI16, R_PJ_CODE_HI16 }, + { BFD_RELOC_PJ_CODE_REL32, R_PJ_CODE_REL32 }, + { BFD_RELOC_PJ_CODE_REL16, R_PJ_CODE_REL16 }, + { BFD_RELOC_VTABLE_INHERIT, R_PJ_GNU_VTINHERIT }, + { BFD_RELOC_VTABLE_ENTRY, R_PJ_GNU_VTENTRY }, +}; + +/* Given a BFD reloc code, return the howto structure for the + corresponding PJ ELf reloc. */ + +static reloc_howto_type * +pj_elf_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; i < sizeof (pj_reloc_map) / sizeof (struct elf_reloc_map); i++) + { + if (pj_reloc_map[i].bfd_reloc_val == code) + return &pj_elf_howto_table[(int) pj_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Given an ELF reloc, fill in the howto field of a relent. */ + +static void +pj_elf_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr; + Elf_Internal_Rela *dst; +{ + unsigned int r; + + r = ELF32_R_TYPE (dst->r_info); + + BFD_ASSERT (r < (unsigned int) R_PJ_max); + + cache_ptr->howto = &pj_elf_howto_table[r]; +} + +/* Take this moment to fill in the special picoJava bits in the + e_flags field. */ + +static void +pj_elf_final_write_processing (abfd, linker) + bfd *abfd; + boolean linker ATTRIBUTE_UNUSED; +{ + elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_ARCH; + elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_GNUCALLS; +} + +#define TARGET_BIG_SYM bfd_elf32_pj_vec +#define TARGET_BIG_NAME "elf32-pj" +#define TARGET_LITTLE_SYM bfd_elf32_pjl_vec +#define TARGET_LITTLE_NAME "elf32-pjl" +#define ELF_ARCH bfd_arch_pj +#define ELF_MACHINE_CODE EM_PJ +#define ELF_MAXPAGESIZE 0x1000 +#define bfd_elf32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents +#define bfd_elf32_bfd_reloc_type_lookup pj_elf_reloc_type_lookup +#define elf_backend_final_write_processing pj_elf_final_write_processing +#define elf_info_to_howto pj_elf_info_to_howto +#include "elf32-target.h" diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 25bb24a..242cfb7 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -80,8 +80,6 @@ static boolean ppc_elf_gc_sweep_hook PARAMS ((bfd *abfd, 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 *, @@ -1231,7 +1229,7 @@ error_return: static reloc_howto_type * ppc_elf_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE; @@ -1307,7 +1305,7 @@ ppc_elf_reloc_type_lookup (abfd, code) static void ppc_elf_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf32_Internal_Rela *dst; { @@ -1323,13 +1321,13 @@ ppc_elf_info_to_howto (abfd, cache_ptr, dst) static bfd_reloc_status_type ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; @@ -1523,7 +1521,7 @@ ppc_elf_section_from_shdr (abfd, hdr, name) static boolean ppc_elf_fake_sections (abfd, shdr, asect) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; Elf32_Internal_Shdr *shdr; asection *asect; { @@ -1640,7 +1638,7 @@ ppc_elf_additional_program_headers (abfd) static boolean ppc_elf_modify_segment_map (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { return true; } @@ -1881,27 +1879,6 @@ ppc_elf_adjust_dynamic_symbol (info, h) } -/* 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 @@ -2035,7 +2012,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } @@ -2083,43 +2060,6 @@ ppc_elf_size_dynamic_sections (output_bfd, info) } } - /* 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; } @@ -2523,7 +2463,7 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) static asection * ppc_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -2570,7 +2510,7 @@ ppc_elf_gc_mark_hook (abfd, info, rel, h, sym) static boolean ppc_elf_gc_sweep_hook (abfd, info, sec, relocs) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; asection *sec; const Elf_Internal_Rela *relocs; { @@ -2637,8 +2577,8 @@ 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; + const char **namep ATTRIBUTE_UNUSED; + flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; bfd_vma *valp; { @@ -2924,54 +2864,6 @@ ppc_elf_finish_dynamic_sections (output_bfd, info) 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; } @@ -3146,7 +3038,12 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, && ((! info->symbolic && h->dynindx != -1) || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) - && (input_section->flags & SEC_ALLOC) != 0 + && ((input_section->flags & SEC_ALLOC) != 0 + /* Testing SEC_DEBUGGING here may be wrong. + It's here to avoid a crash when + generating a shared library with DWARF + debugging information. */ + || (input_section->flags & SEC_DEBUGGING) != 0) && (r_type == R_PPC_ADDR32 || r_type == R_PPC_ADDR24 || r_type == R_PPC_ADDR16 @@ -3189,6 +3086,14 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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 @@ -3200,13 +3105,15 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, relocation = 0; else { - (*info->callbacks->undefined_symbol)(info, - h->root.root.string, - input_bfd, - input_section, - rel->r_offset); - ret = false; - continue; + if (! (*info->callbacks->undefined_symbol)(info, + h->root.root.string, + input_bfd, + input_section, + rel->r_offset, + (!info->shared + || info->no_undefined))) + return false; + relocation = 0; } } @@ -3230,12 +3137,13 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, || 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; + if (! (*info->callbacks->undefined_symbol) (info, + h->root.root.string, + input_bfd, + input_section, + rel->r_offset, + true)) + return false; continue; } break; @@ -3751,47 +3659,52 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, relocation, addend); - if (r != bfd_reloc_ok) + if (r == bfd_reloc_ok) + ; + else if (r == bfd_reloc_overflow) { - ret = false; - switch (r) + const char *name; + + if (h != NULL) { - default: - break; + 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. */ - 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, + continue; + } + + 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) + continue; + 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, - offset); - } - break; - - } + offset)) + return false; } + else + ret = false; } - #ifdef DEBUG fprintf (stderr, "\n"); #endif diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index ebbe352..ad60e07 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -1,5 +1,5 @@ /* Hitachi SH specific support for 32-bit ELF - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 97, 98, 1999, 2000 Free Software Foundation, Inc. Contributed by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -33,6 +33,14 @@ 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_set_private_flags + PARAMS ((bfd *, flagword)); +static boolean sh_elf_copy_private_data + PARAMS ((bfd *, bfd *)); +static boolean sh_elf_merge_private_data + PARAMS ((bfd *, bfd *)); +boolean sh_elf_set_mach_from_flags + PARAMS ((bfd *)); static boolean sh_elf_relax_section PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); static boolean sh_elf_relax_delete_bytes @@ -207,21 +215,21 @@ static reloc_howto_type sh_elf_howto_table[] = 0xff, /* dst_mask */ true), /* pcrel_offset */ - { 10 }, - { 11 }, - { 12 }, - { 13 }, - { 14 }, - { 15 }, - { 16 }, - { 17 }, - { 18 }, - { 19 }, - { 20 }, - { 21 }, - { 22 }, - { 23 }, - { 24 }, + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + EMPTY_HOWTO (13), + EMPTY_HOWTO (14), + EMPTY_HOWTO (15), + EMPTY_HOWTO (16), + EMPTY_HOWTO (17), + EMPTY_HOWTO (18), + EMPTY_HOWTO (19), + EMPTY_HOWTO (20), + EMPTY_HOWTO (21), + EMPTY_HOWTO (22), + EMPTY_HOWTO (23), + EMPTY_HOWTO (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 @@ -426,7 +434,7 @@ sh_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { unsigned long insn; bfd_vma sym_value; @@ -497,13 +505,13 @@ sh_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, static bfd_reloc_status_type sh_elf_ignore_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; - asymbol *symbol; - PTR data; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != NULL) reloc_entry->address += input_section->output_offset; @@ -548,7 +556,7 @@ static const struct elf_reloc_map sh_reloc_map[] = static reloc_howto_type * sh_elf_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -566,7 +574,7 @@ sh_elf_reloc_type_lookup (abfd, code) static void sh_elf_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *cache_ptr; Elf_Internal_Rela *dst; { @@ -1161,13 +1169,15 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) case R_SH_SWITCH32: /* These relocs types represent .word L2-L1 - The r_offset field holds the difference between the reloc + The r_addend 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. */ + both the r_offset field and the section contents. + N.B. in gas / coff bfd, the elf bfd r_addend is called r_offset, + and the elf bfd r_offset is called r_vaddr. */ - start = irel->r_offset; - stop = (bfd_vma) ((bfd_signed_vma) start - (long) irel->r_addend); + stop = irel->r_offset; + start = (bfd_vma) ((bfd_signed_vma) stop - (long) irel->r_addend); if (start > addr && start < toaddr @@ -1178,8 +1188,6 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) && (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) @@ -1307,6 +1315,56 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) { Elf_Internal_Sym sym; + /* Dwarf line numbers use R_SH_SWITCH32 relocs. */ + if (ELF32_R_TYPE (irelscan->r_info) == (int) R_SH_SWITCH32) + { + bfd_vma start, stop; + bfd_signed_vma voff; + + 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; + } + } + + stop = irelscan->r_offset; + start + = (bfd_vma) ((bfd_signed_vma) stop - (long) irelscan->r_addend); + + /* STOP is in a different section, so it won't change. */ + if (start > addr && start < toaddr) + irelscan->r_addend += count; + + voff = bfd_get_signed_32 (abfd, ocontents + irelscan->r_offset); + stop = (bfd_vma) ((bfd_signed_vma) start + voff); + + if (start > addr + && start < toaddr + && (stop <= addr || stop >= toaddr)) + bfd_put_signed_32 (abfd, voff + count, + ocontents + irelscan->r_offset); + else if (stop > addr + && stop < toaddr + && (start <= addr || start >= toaddr)) + bfd_put_signed_32 (abfd, voff - count, + ocontents + irelscan->r_offset); + } + if (ELF32_R_TYPE (irelscan->r_info) != (int) R_SH_DIR32) continue; @@ -1621,7 +1679,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr) static boolean sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; bfd *input_bfd; asection *input_section; @@ -1731,7 +1789,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; relocation = 0; } @@ -1927,7 +1985,7 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order, static asection * sh_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -1949,6 +2007,9 @@ sh_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -1967,10 +2028,10 @@ sh_elf_gc_mark_hook (abfd, info, rel, h, sym) 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { /* we don't use got and plt entries for sh. */ return true; @@ -2034,6 +2095,109 @@ sh_elf_check_relocs (abfd, info, sec, relocs) return true; } +boolean +sh_elf_set_mach_from_flags (abfd) + bfd * abfd; +{ + flagword flags = elf_elfheader (abfd)->e_flags; + + switch (flags & EF_SH_MACH_MASK) + { + case EF_SH1: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh); + break; + case EF_SH2: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh2); + break; + case EF_SH_DSP: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh_dsp); + break; + case EF_SH3: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3); + break; + case EF_SH3_DSP: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3_dsp); + break; + case EF_SH3E: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3e); + break; + case EF_SH_UNKNOWN: + case EF_SH4: + bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4); + break; + default: + return false; + } + return true; +} + +/* Function to keep SH specific file flags. */ +static boolean +sh_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 sh_elf_set_mach_from_flags (abfd); +} + +/* Copy backend specific data from one object module to another */ +static boolean +sh_elf_copy_private_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; + + return sh_elf_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags); +} + +/* This routine checks for linking big and little endian objects + together, and for linking sh-dsp with sh3e / sh4 objects. */ + +static boolean +sh_elf_merge_private_data (ibfd, obfd) + bfd *ibfd; + bfd *obfd; +{ + flagword old_flags, new_flags; + + if (_bfd_generic_verify_endian_match (ibfd, obfd) == false) + return false; + + if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return true; + + if (! elf_flags_init (obfd)) + { + elf_flags_init (obfd) = true; + elf_elfheader (obfd)->e_flags = 0; + } + old_flags = elf_elfheader (obfd)->e_flags; + new_flags = elf_elfheader (ibfd)->e_flags; + if ((EF_SH_HAS_DSP (old_flags) && EF_SH_HAS_FP (new_flags)) + || (EF_SH_HAS_DSP (new_flags) && EF_SH_HAS_FP (old_flags))) + { + (*_bfd_error_handler) + ("%s: uses %s instructions while previous modules use %s instructions", + bfd_get_filename (ibfd), + EF_SH_HAS_DSP (new_flags) ? "dsp" : "floating point", + EF_SH_HAS_DSP (new_flags) ? "floating point" : "dsp"); + bfd_set_error (bfd_error_bad_value); + return false; + } + elf_elfheader (obfd)->e_flags = EF_SH_MERGE_MACH (old_flags, new_flags); + + return sh_elf_set_mach_from_flags (obfd); +} + #define TARGET_BIG_SYM bfd_elf32_sh_vec #define TARGET_BIG_NAME "elf32-sh" #define TARGET_LITTLE_SYM bfd_elf32_shl_vec @@ -2050,6 +2214,13 @@ sh_elf_check_relocs (abfd, info, sec, relocs) #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_object_p sh_elf_set_mach_from_flags +#define bfd_elf32_bfd_set_private_bfd_flags \ + sh_elf_set_private_flags +#define bfd_elf32_bfd_copy_private_bfd_data \ + sh_elf_copy_private_data +#define bfd_elf32_bfd_merge_private_bfd_data \ + sh_elf_merge_private_data #define elf_backend_gc_mark_hook sh_elf_gc_mark_hook #define elf_backend_gc_sweep_hook sh_elf_gc_sweep_hook diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index ec57c8c..e61a82f 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -1,5 +1,6 @@ /* SPARC-specific support for 32-bit ELF - Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -33,8 +34,6 @@ static boolean elf32_sparc_check_relocs 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 @@ -182,7 +181,7 @@ static CONST struct elf_reloc_map sparc_reloc_map[] = static reloc_howto_type * elf32_sparc_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -211,12 +210,24 @@ elf32_sparc_reloc_type_lookup (abfd, code) static void elf32_sparc_info_to_howto (abfd, cache_ptr, dst) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; 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)]; + switch (ELF32_R_TYPE(dst->r_info)) + { + case R_SPARC_GNU_VTINHERIT: + cache_ptr->howto = &elf32_sparc_vtinherit_howto; + break; + + case R_SPARC_GNU_VTENTRY: + cache_ptr->howto = &elf32_sparc_vtentry_howto; + break; + + default: + BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max_std); + cache_ptr->howto = &_bfd_sparc_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + } } /* For unsupported relocs. */ @@ -229,13 +240,13 @@ sparc_elf_notsupported_reloc (abfd, 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 *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { return bfd_reloc_notsupported; } @@ -256,7 +267,7 @@ sparc_elf_wdisp16_reloc (abfd, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; bfd_vma x; @@ -500,6 +511,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) case R_SPARC_PC10: case R_SPARC_PC22: + if (h != NULL) + h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + if (h != NULL && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) break; @@ -511,6 +525,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) case R_SPARC_WDISP22: case R_SPARC_WDISP19: case R_SPARC_WDISP16: + if (h != NULL) + h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + /* 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., @@ -533,6 +550,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) case R_SPARC_13: case R_SPARC_LO10: case R_SPARC_UA32: + if (h != NULL) + h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + if (info->shared) { /* When creating a shared object, we must copy these @@ -596,7 +616,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) static asection * elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -619,6 +639,9 @@ elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -640,7 +663,7 @@ elf32_sparc_gc_mark_hook (abfd, info, rel, h, sym) static boolean elf32_sparc_gc_sweep_hook (abfd, info, sec, relocs) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; asection *sec; const Elf_Internal_Rela *relocs; { @@ -821,6 +844,11 @@ elf32_sparc_adjust_dynamic_symbol (info, h) if (info->shared) return true; + /* If there are no references to this symbol that do not use the + GOT, we don't need to generate a copy reloc. */ + if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) + 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 @@ -983,7 +1011,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } @@ -1028,51 +1056,6 @@ elf32_sparc_size_dynamic_sections (output_bfd, info) } } - /* 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; } @@ -1134,7 +1117,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, || r_type == R_SPARC_GNU_VTENTRY) continue; - if (r_type < 0 || r_type >= (int) R_SPARC_max) + if (r_type < 0 || r_type >= (int) R_SPARC_max_std) { bfd_set_error (bfd_error_bad_value); return false; @@ -1236,7 +1219,8 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } @@ -1507,15 +1491,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, } 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; + outrel.r_addend = relocation + rel->r_addend; } } @@ -1835,50 +1811,6 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info) 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; } @@ -1898,7 +1830,8 @@ elf32_sparc_merge_private_bfd_data (ibfd, obfd) bfd *obfd; { boolean error; - static int previous_ibfd_e_flags = -1; + /* FIXME: This should not be static. */ + static unsigned long previous_ibfd_e_flags = (unsigned long) -1; if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour || bfd_get_flavour (obfd) != bfd_target_elf_flavour) @@ -1940,13 +1873,16 @@ elf32_sparc_merge_private_bfd_data (ibfd, obfd) (_("%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)); + else if ((ibfd->flags & DYNAMIC) == 0) + { + 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) + && previous_ibfd_e_flags != (unsigned long) -1) { (*_bfd_error_handler) (_("%s: linking little endian files with big endian files"), @@ -1994,7 +1930,7 @@ elf32_sparc_object_p (abfd) static void elf32_sparc_final_write_processing (abfd, linker) bfd *abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { switch (bfd_get_mach (abfd)) { diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index e71353d..4fe28fc 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -1,5 +1,5 @@ /* V850-specific support for 32-bit ELF - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -143,7 +143,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ v850_elf_reloc, /* special_function */ "R_V850_HI16_S", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -158,7 +158,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ v850_elf_reloc, /* special_function */ "R_V850_HI16", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -173,7 +173,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ v850_elf_reloc, /* special_function */ "R_V850_LO16", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -188,7 +188,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ v850_elf_reloc, /* special_function */ "R_V850_32", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ false), /* pcrel_offset */ @@ -203,7 +203,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_V850_16", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ @@ -218,7 +218,7 @@ static reloc_howto_type v850_elf_howto_table[] = complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_V850_8", /* name */ - true, /* partial_inplace */ + false, /* partial_inplace */ 0xff, /* src_mask */ 0xff, /* dst_mask */ false), /* pcrel_offset */ @@ -509,7 +509,7 @@ static const struct v850_elf_reloc_map v850_elf_reloc_map[] = /* Map a bfd relocation into the appropriate howto structure */ static reloc_howto_type * v850_elf_reloc_type_lookup (abfd, code) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; @@ -533,7 +533,7 @@ v850_elf_reloc_type_lookup (abfd, code) /* Set the howto pointer for an V850 ELF reloc. */ static void v850_elf_info_to_howto_rel (abfd, cache_ptr, dst) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; arelent * cache_ptr; Elf32_Internal_Rel * dst; { @@ -547,7 +547,7 @@ v850_elf_info_to_howto_rel (abfd, cache_ptr, dst) /* 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; + bfd * abfd ATTRIBUTE_UNUSED; arelent * cache_ptr; Elf32_Internal_Rela *dst; { @@ -797,7 +797,6 @@ find_remembered_hi16s_reloc (addend, already_found) 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. */ @@ -1253,13 +1252,13 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) /* Insert the addend into the instruction. */ static bfd_reloc_status_type v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; arelent * reloc; asymbol * symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection * isection; bfd * obfd; - char ** err; + char ** err ATTRIBUTE_UNUSED; { long relocation; @@ -1327,7 +1326,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err) /*ARGSUSED*/ static boolean v850_elf_is_local_label_name (abfd, name) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; const char * name; { return ( (name[0] == '.' && (name[1] == 'L' || name[1] == '.')) @@ -1342,7 +1341,7 @@ v850_elf_final_link_relocate (howto, input_bfd, output_bfd, addend, info, sym_sec, is_local) reloc_howto_type * howto; bfd * input_bfd; - bfd * output_bfd; + bfd * output_bfd ATTRIBUTE_UNUSED; asection * input_section; bfd_byte * contents; bfd_vma offset; @@ -1350,7 +1349,7 @@ v850_elf_final_link_relocate (howto, input_bfd, output_bfd, bfd_vma addend; struct bfd_link_info * info; asection * sym_sec; - int is_local; + int is_local ATTRIBUTE_UNUSED; { unsigned long r_type = howto->type; bfd_byte * hit_data = contents + offset; @@ -1369,6 +1368,10 @@ v850_elf_final_link_relocate (howto, input_bfd, output_bfd, + input_section->output_offset + offset); + /* If the sign extension will corrupt the value then we have overflowed. */ + if (((value & 0xff000000) != 0x0) && ((value & 0xff000000) != 0xff000000)) + return bfd_reloc_overflow; + value = SEXT24 (value); /* Only the bottom 24 bits of the PC are valid */ break; @@ -1622,7 +1625,7 @@ fprintf (stderr, "undefined: sec: %s, name: %s\n", { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, true))) return false; #if 0 fprintf (stderr, "unknown: name: %s\n", h->root.root.string); @@ -1666,7 +1669,7 @@ fprintf (stderr, "unknown: name: %s\n", h->root.root.string); case bfd_reloc_undefined: if (! ((*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, - rel->r_offset))) + rel->r_offset, true))) return false; break; @@ -1713,10 +1716,10 @@ fprintf (stderr, "unknown: name: %s\n", h->root.root.string); 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED; { /* No got and plt entries for v850-elf */ return true; @@ -1725,7 +1728,7 @@ v850_elf_gc_sweep_hook (abfd, info, sec, relocs) static asection * v850_elf_gc_mark_hook (abfd, info, rel, h, sym) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; Elf_Internal_Rela *rel; struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; @@ -1747,6 +1750,9 @@ v850_elf_gc_mark_hook (abfd, info, rel, h, sym) case bfd_link_hash_common: return h->root.u.c.p->section; + + default: + break; } } } @@ -1781,7 +1787,7 @@ v850_elf_object_p (abfd) static void v850_elf_final_write_processing (abfd, linker) bfd * abfd; - boolean linker; + boolean linker ATTRIBUTE_UNUSED; { unsigned long val; @@ -1934,8 +1940,8 @@ static asymbol * v850_elf_zcom_symbol_ptr; static boolean v850_elf_section_from_bfd_section (abfd, hdr, sec, retval) - bfd * abfd; - Elf32_Internal_Shdr * hdr; + bfd * abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr * hdr ATTRIBUTE_UNUSED; asection * sec; int * retval; { @@ -2053,10 +2059,10 @@ v850_elf_symbol_processing (abfd, asym) static boolean v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd * abfd; - struct bfd_link_info * info; + struct bfd_link_info * info ATTRIBUTE_UNUSED; const Elf_Internal_Sym * sym; - const char ** namep; - flagword * flagsp; + const char ** namep ATTRIBUTE_UNUSED; + flagword * flagsp ATTRIBUTE_UNUSED; asection ** secp; bfd_vma * valp; { @@ -2114,9 +2120,9 @@ v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) /*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; + bfd * abfd ATTRIBUTE_UNUSED; + struct bfd_link_info * info ATTRIBUTE_UNUSED; + const char * name ATTRIBUTE_UNUSED; Elf_Internal_Sym * sym; asection * input_sec; { @@ -2169,7 +2175,7 @@ v850_elf_section_from_shdr (abfd, hdr, name) section name, which is a hack, but ought to work. */ static boolean v850_elf_fake_sections (abfd, hdr, sec) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; Elf32_Internal_Shdr * hdr; asection * sec; { diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 1964f86..c8d8f0e 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -115,8 +115,6 @@ 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 **)); @@ -127,6 +125,10 @@ 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 *)); +static boolean elf64_alpha_merge_ind_symbols + PARAMS((struct alpha_elf_link_hash_entry *, PTR)); +static Elf_Internal_Rela * elf64_alpha_find_reloc_at_ofs + PARAMS ((Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_vma, int)); struct alpha_elf_link_hash_entry @@ -974,6 +976,17 @@ static const struct elf_reloc_map elf64_alpha_reloc_map[] = {BFD_RELOC_16_PCREL, R_ALPHA_SREL16}, {BFD_RELOC_32_PCREL, R_ALPHA_SREL32}, {BFD_RELOC_64_PCREL, R_ALPHA_SREL64}, + +/* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to process + the explicit !!sequence relocations, and are mapped into the normal + relocations at the end of processing. */ + {BFD_RELOC_ALPHA_USER_LITERAL, R_ALPHA_LITERAL}, + {BFD_RELOC_ALPHA_USER_LITUSE_BASE, R_ALPHA_LITUSE}, + {BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, R_ALPHA_LITUSE}, + {BFD_RELOC_ALPHA_USER_LITUSE_JSR, R_ALPHA_LITUSE}, + {BFD_RELOC_ALPHA_USER_GPDISP, R_ALPHA_GPDISP}, + {BFD_RELOC_ALPHA_USER_GPRELHIGH, R_ALPHA_GPRELHIGH}, + {BFD_RELOC_ALPHA_USER_GPRELLOW, R_ALPHA_GPRELLOW}, }; /* Given a BFD reloc type, return a HOWTO structure. */ @@ -3254,7 +3267,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) } if (strip) - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); else { /* Allocate memory for the section contents. */ @@ -3264,34 +3277,6 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) } } - /* 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 @@ -3332,22 +3317,6 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) 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 @@ -3423,6 +3392,12 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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. */ + + /* The symbol associated with GPDISP and LITUSE is + immaterial. Only the addend is significant. */ + if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE) + continue; + if (r_symndx < symtab_hdr->sh_info) { sym = local_syms + r_symndx; @@ -3505,7 +3480,8 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, { if (!((*info->callbacks->undefined_symbol) (info, h->root.root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } @@ -3985,44 +3961,6 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info) } } - 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; } diff --git a/bfd/elf64-gen.c b/bfd/elf64-gen.c index 2f470ff..78dc09d 100644 --- a/bfd/elf64-gen.c +++ b/bfd/elf64-gen.c @@ -64,6 +64,7 @@ elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) #define TARGET_BIG_NAME "elf64-big" #define ELF_ARCH bfd_arch_unknown #define ELF_MACHINE_CODE EM_NONE +#define ELF_MAXPAGESIZE 0x1 #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 diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 9fb8bb9..6fc0dcd 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -1,6 +1,8 @@ /* MIPS-specific support for 64-bit ELF - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Ian Lance Taylor, Cygnus Support + Linker support added by Mark Mitchell, CodeSourcery, LLC. + This file is part of BFD, the Binary File Descriptor library. @@ -52,14 +54,20 @@ static void mips_elf64_swap_reloc_in 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 void mips_elf64_be_swap_reloc_in + PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *)); +static void mips_elf64_be_swap_reloc_out + PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *)); +static void mips_elf64_be_swap_reloca_in + PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *)); +static void mips_elf64_be_swap_reloca_out + PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *)); 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 *)); @@ -68,10 +76,6 @@ static boolean mips_elf64_slurp_one_reloc_table 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)); @@ -80,6 +84,9 @@ static boolean mips_elf64_write_armap from smaller values. Start with zero, widen, *then* decrement. */ #define MINUS_ONE (((bfd_vma)0) - 1) +/* The number of local .got entries we reserve. */ +#define MIPS_RESERVED_GOTNO (2) + /* The relocation table used for SHT_REL sections. */ static reloc_howto_type mips_elf64_howto_table_rel[] = @@ -614,7 +621,23 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false) /* pcrel_offset */ + false), /* pcrel_offset */ + + /* Protected jump conversion. This is an optimization hint. No + relocation is required for correctness. */ + HOWTO (R_MIPS_JALR, /* 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_JALR", /* name */ + false, /* partial_inplace */ + 0x00000000, /* src_mask */ + 0x00000000, /* dst_mask */ + false), /* pcrel_offset */ }; /* The relocation table used for SHT_RELA sections. */ @@ -1152,7 +1175,23 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false) /* pcrel_offset */ + false), /* pcrel_offset */ + + /* Protected jump conversion. This is an optimization hint. No + relocation is required for correctness. */ + HOWTO (R_MIPS_JALR, /* 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_JALR", /* name */ + false, /* partial_inplace */ + 0x00000000, /* src_mask */ + 0x00000000, /* dst_mask */ + false), /* pcrel_offset */ }; /* Swap in a MIPS 64-bit Rel reloc. */ @@ -1188,10 +1227,6 @@ mips_elf64_swap_reloca_in (abfd, src, dst) 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 @@ -1208,8 +1243,6 @@ mips_elf64_swap_reloc_out (abfd, src, dst) 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 @@ -1227,6 +1260,96 @@ mips_elf64_swap_reloca_out (abfd, src, dst) bfd_h_put_64 (abfd, src->r_addend, (bfd_byte *) dst->r_addend); } +/* Swap in a MIPS 64-bit Rel reloc. */ + +static void +mips_elf64_be_swap_reloc_in (abfd, src, dst) + bfd *abfd; + const bfd_byte *src; + Elf_Internal_Rel *dst; +{ + Elf64_Mips_Internal_Rel mirel; + + mips_elf64_swap_reloc_in (abfd, + (const Elf64_Mips_External_Rel *) src, + &mirel); + + dst[0].r_offset = mirel.r_offset; + dst[0].r_info = ELF32_R_INFO (mirel.r_sym, mirel.r_type); + dst[1].r_offset = mirel.r_offset; + dst[1].r_info = ELF32_R_INFO (mirel.r_ssym, mirel.r_type2); + dst[2].r_offset = mirel.r_offset; + dst[2].r_info = ELF32_R_INFO (STN_UNDEF, mirel.r_type3); +} + +/* Swap in a MIPS 64-bit Rela reloc. */ + +static void +mips_elf64_be_swap_reloca_in (abfd, src, dst) + bfd *abfd; + const bfd_byte *src; + Elf_Internal_Rela *dst; +{ + Elf64_Mips_Internal_Rela mirela; + + mips_elf64_swap_reloca_in (abfd, + (const Elf64_Mips_External_Rela *) src, + &mirela); + + dst[0].r_offset = mirela.r_offset; + dst[0].r_info = ELF32_R_INFO (mirela.r_sym, mirela.r_type); + dst[0].r_addend = mirela.r_addend; + dst[1].r_offset = mirela.r_offset; + dst[1].r_info = ELF32_R_INFO (mirela.r_ssym, mirela.r_type2); + dst[1].r_addend = 0; + dst[2].r_offset = mirela.r_offset; + dst[2].r_info = ELF32_R_INFO (STN_UNDEF, mirela.r_type3); + dst[2].r_addend = 0; +} + +/* Swap out a MIPS 64-bit Rel reloc. */ + +static void +mips_elf64_be_swap_reloc_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Rel *src; + bfd_byte *dst; +{ + Elf64_Mips_Internal_Rel mirel; + + mirel.r_offset = src->r_offset; + mirel.r_type = ELF32_R_TYPE (src->r_info); + mirel.r_sym = ELF32_R_SYM (src->r_info); + mirel.r_type2 = R_MIPS_NONE; + mirel.r_ssym = STN_UNDEF; + mirel.r_type3 = R_MIPS_NONE; + + mips_elf64_swap_reloc_out (abfd, &mirel, + (Elf64_Mips_External_Rel *) dst); +} + +/* Swap out a MIPS 64-bit Rela reloc. */ + +static void +mips_elf64_be_swap_reloca_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Rela *src; + bfd_byte *dst; +{ + Elf64_Mips_Internal_Rela mirela; + + mirela.r_offset = src->r_offset; + mirela.r_type = ELF32_R_TYPE (src->r_info); + mirela.r_addend = src->r_addend; + mirela.r_sym = ELF32_R_SYM (src->r_info); + mirela.r_type2 = R_MIPS_NONE; + mirela.r_ssym = STN_UNDEF; + mirela.r_type3 = R_MIPS_NONE; + + mips_elf64_swap_reloca_out (abfd, &mirela, + (Elf64_Mips_External_Rela *) dst); +} + /* A mapping from BFD reloc types to MIPS ELF reloc types. */ struct elf_reloc_map @@ -1255,7 +1378,11 @@ static CONST struct elf_reloc_map mips_reloc_map[] = { 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 } + { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }, + { BFD_RELOC_MIPS_SUB, R_MIPS_SUB }, + { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE }, + { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST }, + { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP } }; /* Given a BFD reloc type, return a howto structure. */ @@ -1688,115 +1815,6 @@ mips_elf64_write_relocs (abfd, sec, data) == 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. */ @@ -2063,6 +2081,8 @@ const struct elf_size_info mips_elf64_size_info = sizeof (Elf64_External_Sym), sizeof (Elf64_External_Dyn), sizeof (Elf_External_Note), + 4, /* hash-table entry size */ + 3, /* internal relocations per external relocations */ 64, /* arch_size */ 8, /* file_align */ ELFCLASS64, @@ -2073,7 +2093,12 @@ const struct elf_size_info mips_elf64_size_info = bfd_elf64_swap_symbol_out, mips_elf64_slurp_reloc_table, bfd_elf64_slurp_symbol_table, - bfd_elf64_swap_dyn_in + bfd_elf64_swap_dyn_in, + bfd_elf64_swap_dyn_out, + mips_elf64_be_swap_reloc_in, + mips_elf64_be_swap_reloc_out, + mips_elf64_be_swap_reloca_in, + mips_elf64_be_swap_reloca_out }; #define TARGET_LITTLE_SYM bfd_elf64_littlemips_vec @@ -2082,29 +2107,67 @@ const struct elf_size_info mips_elf64_size_info = #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_collect true +#define elf_backend_type_change_ok true +#define elf_backend_can_gc_sections true #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_section_from_shdr _bfd_mips_elf_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_section_processing _bfd_mips_elf_section_processing #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing +#define elf_backend_additional_program_headers \ + _bfd_mips_elf_additional_program_headers +#define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map #define elf_backend_final_write_processing \ _bfd_mips_elf_final_write_processing #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap - +#define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook +#define elf_backend_create_dynamic_sections \ + _bfd_mips_elf_create_dynamic_sections +#define elf_backend_check_relocs _bfd_mips_elf_check_relocs +#define elf_backend_adjust_dynamic_symbol \ + _bfd_mips_elf_adjust_dynamic_symbol +#define elf_backend_always_size_sections \ + _bfd_mips_elf_always_size_sections +#define elf_backend_size_dynamic_sections \ + _bfd_mips_elf_size_dynamic_sections +#define elf_backend_relocate_section _bfd_mips_elf_relocate_section +#define elf_backend_link_output_symbol_hook \ + _bfd_mips_elf_link_output_symbol_hook +#define elf_backend_finish_dynamic_symbol \ + _bfd_mips_elf_finish_dynamic_symbol +#define elf_backend_finish_dynamic_sections \ + _bfd_mips_elf_finish_dynamic_sections +#define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook +#define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook +#define elf_backend_got_header_size (4*MIPS_RESERVED_GOTNO) +#define elf_backend_plt_header_size 0 +#define elf_backend_may_use_rel_p 1 + +/* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit + MIPS-specific function only applies to IRIX5, which had no 64-bit + ABI. */ #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_link_hash_table_create \ + _bfd_mips_elf_link_hash_table_create +#define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link #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_bfd_print_private_bfd_data \ + _bfd_mips_elf_print_private_bfd_data +#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_archive_functions #define bfd_elf64_archive_slurp_armap mips_elf64_slurp_armap #define bfd_elf64_archive_slurp_extended_name_table \ diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 17fe98d..46e7775 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -1,5 +1,6 @@ /* SPARC-specific support for 64-bit ELF - Copyright (C) 1993, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -32,6 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */ #define MINUS_ONE (~ (bfd_vma) 0) +static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create + PARAMS((bfd *)); static reloc_howto_type *sparc64_elf_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); static void sparc64_elf_info_to_howto @@ -51,8 +54,13 @@ 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 int sparc64_elf_get_symbol_type + PARAMS (( Elf_Internal_Sym *, int)); +static boolean sparc64_elf_add_symbol_hook + PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + const char **, flagword *, asection **, bfd_vma *)); +static void sparc64_elf_symbol_processing + PARAMS ((bfd *, asymbol *)); static boolean sparc64_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); @@ -61,6 +69,15 @@ 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 *)); +static long sparc64_elf_get_reloc_upper_bound PARAMS ((bfd *, asection *)); +static long sparc64_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); +static boolean sparc64_elf_slurp_one_reloc_table + PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, asymbol **, boolean)); +static boolean sparc64_elf_slurp_reloc_table + PARAMS ((bfd *, asection *, asymbol **, boolean)); +static long sparc64_elf_canonicalize_dynamic_reloc + PARAMS ((bfd *, arelent **, asymbol **)); +static void sparc64_elf_write_relocs PARAMS ((bfd *, asection *, PTR)); /* The relocation "howto" table. */ @@ -213,10 +230,428 @@ sparc64_elf_info_to_howto (abfd, cache_ptr, dst) 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)]; + BFD_ASSERT (ELF64_R_TYPE_ID (dst->r_info) < (unsigned int) R_SPARC_max_std); + cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE_ID (dst->r_info)]; } +/* Due to the way how we handle R_SPARC_OLO10, each entry in a SHT_RELA + section can represent up to two relocs, we must tell the user to allocate + more space. */ + +static long +sparc64_elf_get_reloc_upper_bound (abfd, sec) + bfd *abfd; + asection *sec; +{ + return (sec->reloc_count * 2 + 1) * sizeof (arelent *); +} + +static long +sparc64_elf_get_dynamic_reloc_upper_bound (abfd) + bfd *abfd; +{ + return _bfd_elf_get_dynamic_reloc_upper_bound (abfd) * 2; +} + +/* Read relocations for ASECT from REL_HDR. There are RELOC_COUNT of + them. We cannot use generic elf routines for this, because R_SPARC_OLO10 + has secondary addend in ELF64_R_TYPE_DATA. We handle it as two relocations + for the same location, R_SPARC_LO10 and R_SPARC_13. */ + +static boolean +sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, dynamic) + bfd *abfd; + asection *asect; + Elf_Internal_Shdr *rel_hdr; + asymbol **symbols; + boolean dynamic; +{ + struct elf_backend_data * const ebd = get_elf_backend_data (abfd); + PTR allocated = NULL; + bfd_byte *native_relocs; + arelent *relent; + unsigned int i; + int entsize; + bfd_size_type count; + arelent *relents; + + 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 = asect->relocation + asect->reloc_count; + + entsize = rel_hdr->sh_entsize; + BFD_ASSERT (entsize == sizeof (Elf64_External_Rela)); + + count = rel_hdr->sh_size / entsize; + + for (i = 0, relent = relents; i < count; + i++, relent++, native_relocs += entsize) + { + Elf_Internal_Rela rela; + + bfd_elf64_swap_reloca_in (abfd, (Elf64_External_Rela *) native_relocs, &rela); + + /* 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 (ELF64_R_SYM (rela.r_info) == 0) + relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + else + { + asymbol **ps, *s; + + ps = symbols + ELF64_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; + + BFD_ASSERT (ELF64_R_TYPE_ID (rela.r_info) < (unsigned int) R_SPARC_max_std); + if (ELF64_R_TYPE_ID (rela.r_info) == R_SPARC_OLO10) + { + relent->howto = &sparc64_elf_howto_table[R_SPARC_LO10]; + relent[1].address = relent->address; + relent++; + relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + relent->addend = ELF64_R_TYPE_DATA (rela.r_info); + relent->howto = &sparc64_elf_howto_table[R_SPARC_13]; + } + else + relent->howto = &sparc64_elf_howto_table[ELF64_R_TYPE_ID (rela.r_info)]; + } + + asect->reloc_count += relent - relents; + + if (allocated != NULL) + free (allocated); + + return true; + + error_return: + if (allocated != NULL) + free (allocated); + return false; +} + +/* Read in and swap the external relocs. */ + +static boolean +sparc64_elf_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); + Elf_Internal_Shdr *rel_hdr; + Elf_Internal_Shdr *rel_hdr2; + + 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; + rel_hdr2 = d->rel_hdr2; + + BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset + || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset)); + } + else + { + /* Note that ASECT->RELOC_COUNT tends not to be accurate in this + case because relocations against this section may use the + dynamic symbol table, and in that case bfd_section_from_shdr + in elf.c does not update the RELOC_COUNT. */ + if (asect->_raw_size == 0) + return true; + + rel_hdr = &d->this_hdr; + asect->reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize; + rel_hdr2 = NULL; + } + + asect->relocation = ((arelent *) + bfd_alloc (abfd, + asect->reloc_count * 2 * sizeof (arelent))); + if (asect->relocation == NULL) + return false; + + /* The sparc64_elf_slurp_one_reloc_table routine increments reloc_count. */ + asect->reloc_count = 0; + + if (!sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, + dynamic)) + return false; + + if (rel_hdr2 + && !sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr2, symbols, + dynamic)) + return false; + + return true; +} + +/* 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. */ + +static long +sparc64_elf_canonicalize_dynamic_reloc (abfd, storage, syms) + bfd *abfd; + arelent **storage; + asymbol **syms; +{ + asection *s; + long ret; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + 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_RELA)) + { + arelent *p; + long count, i; + + if (! sparc64_elf_slurp_reloc_table (abfd, s, syms, true)) + return -1; + count = s->reloc_count; + p = s->relocation; + for (i = 0; i < count; i++) + *storage++ = p++; + ret += count; + } + } + + *storage = NULL; + + return ret; +} + +/* Write out the relocs. */ + +static void +sparc64_elf_write_relocs (abfd, sec, data) + bfd *abfd; + asection *sec; + PTR data; +{ + boolean *failedp = (boolean *) data; + Elf_Internal_Shdr *rela_hdr; + Elf64_External_Rela *outbound_relocas, *src_rela; + unsigned int idx, count; + 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 two relocs that refer to the same address + into R_SPARC_OLO10 if first one is R_SPARC_LO10 and the + latter is R_SPARC_13 with 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; + if (sec->orelocation[idx]->howto->type == R_SPARC_LO10 + && idx < sec->reloc_count - 1) + { + arelent *r = sec->orelocation[idx + 1]; + + if (r->howto->type == R_SPARC_13 + && r->address == addr + && bfd_is_abs_section ((*r->sym_ptr_ptr)->section) + && (*r->sym_ptr_ptr)->value == 0) + ++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; + } + + /* Figure out whether the relocations are RELA or REL relocations. */ + if (rela_hdr->sh_type != SHT_RELA) + abort (); + + /* orelocation has the data, reloc_count has the count... */ + outbound_relocas = (Elf64_External_Rela *) rela_hdr->contents; + src_rela = outbound_relocas; + + for (idx = 0; idx < sec->reloc_count; idx++) + { + Elf_Internal_Rela dst_rela; + arelent *ptr; + asymbol *sym; + int n; + + 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) + 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; + } + + if (ptr->howto->type == R_SPARC_LO10 + && idx < sec->reloc_count - 1) + { + arelent *r = sec->orelocation[idx + 1]; + + if (r->howto->type == R_SPARC_13 + && r->address == ptr->address + && bfd_is_abs_section ((*r->sym_ptr_ptr)->section) + && (*r->sym_ptr_ptr)->value == 0) + { + idx++; + dst_rela.r_info + = ELF64_R_INFO (n, ELF64_R_TYPE_INFO (r->addend, + R_SPARC_OLO10)); + } + else + dst_rela.r_info = ELF64_R_INFO (n, R_SPARC_LO10); + } + else + dst_rela.r_info = ELF64_R_INFO (n, ptr->howto->type); + + dst_rela.r_addend = ptr->addend; + bfd_elf64_swap_reloca_out (abfd, &dst_rela, src_rela); + ++src_rela; + } +} + +/* Sparc64 ELF linker hash table. */ + +struct sparc64_elf_app_reg +{ + unsigned char bind; + unsigned short shndx; + bfd *abfd; + char *name; +}; + +struct sparc64_elf_link_hash_table +{ + struct elf_link_hash_table root; + + struct sparc64_elf_app_reg app_regs [4]; +}; + +/* Get the Sparc64 ELF linker hash table from a link_info structure. */ + +#define sparc64_elf_hash_table(p) \ + ((struct sparc64_elf_link_hash_table *) ((p)->hash)) + +/* Create a Sparc64 ELF linker hash table. */ + +static struct bfd_link_hash_table * +sparc64_elf_bfd_link_hash_table_create (abfd) + bfd *abfd; +{ + struct sparc64_elf_link_hash_table *ret; + + ret = ((struct sparc64_elf_link_hash_table *) + bfd_zalloc (abfd, sizeof (struct sparc64_elf_link_hash_table))); + if (ret == (struct sparc64_elf_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; + } + + return &ret->root.root; +} + + /* Utility for performing the standard initial work of an instruction relocation. *PRELOCATION will contain the relocated item. @@ -441,8 +876,8 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) /* sethi (. - plt0), %g1 */ sethi = 0x03000000 | (i * PLT_ENTRY_SIZE); - /* ba,a,pt %icc, plt1 */ - ba = 0x30480000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff); + /* ba,a,pt %xcc, plt1 */ + ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff); bfd_put_32 (output_bfd, sethi, entry); bfd_put_32 (output_bfd, ba, entry+4); @@ -479,7 +914,7 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) 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); + bfd_put_64 (output_bfd, contents - (entry+4), ptr); } } } @@ -514,11 +949,15 @@ sparc64_elf_plt_ptr_offset (index, max) /* See above for details. */ - block = (index - LARGE_PLT_THRESHOLD) / 160; - ofs = (index - LARGE_PLT_THRESHOLD) % 160; - last = (max - LARGE_PLT_THRESHOLD) % 160; + block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) + + LARGE_PLT_THRESHOLD; + ofs = index - block; + if (block + 160 > max) + last = (max - LARGE_PLT_THRESHOLD) % 160; + else + last = 160; - return ((LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE + return (block * PLT_ENTRY_SIZE + last * 6*4 + ofs * 8); } @@ -570,7 +1009,7 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs) else h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - switch (ELF64_R_TYPE (rel->r_info)) + switch (ELF64_R_TYPE_ID (rel->r_info)) { case R_SPARC_GOT10: case R_SPARC_GOT13: @@ -809,7 +1248,7 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs) default: (*_bfd_error_handler)(_("%s: check_relocs: unhandled reloc type %d"), bfd_get_filename(abfd), - ELF64_R_TYPE (rel->r_info)); + ELF64_R_TYPE_ID (rel->r_info)); return false; } } @@ -817,6 +1256,223 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs) return true; } +/* Hook called by the linker routine which adds symbols from an object + file. We use it for STT_REGISTER symbols. */ + +static boolean +sparc64_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; +{ + static char *stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" }; + + if (ELF_ST_TYPE (sym->st_info) == STT_REGISTER) + { + int reg; + struct sparc64_elf_app_reg *p; + + reg = (int)sym->st_value; + switch (reg & ~1) + { + case 2: reg -= 2; break; + case 6: reg -= 4; break; + default: + (*_bfd_error_handler) + (_("%s: Only registers %%g[2367] can be declared using STT_REGISTER"), + bfd_get_filename (abfd)); + return false; + } + + if (info->hash->creator != abfd->xvec + || (abfd->flags & DYNAMIC) != 0) + { + /* STT_REGISTER only works when linking an elf64_sparc object. + If STT_REGISTER comes from a dynamic object, don't put it into + the output bfd. The dynamic linker will recheck it. */ + *namep = NULL; + return true; + } + + p = sparc64_elf_hash_table(info)->app_regs + reg; + + if (p->name != NULL && strcmp (p->name, *namep)) + { + (*_bfd_error_handler) + (_("Register %%g%d used incompatibly: " + "previously declared in %s to %s, in %s redefined to %s"), + (int)sym->st_value, + bfd_get_filename (p->abfd), *p->name ? p->name : "#scratch", + bfd_get_filename (abfd), **namep ? *namep : "#scratch"); + return false; + } + + if (p->name == NULL) + { + if (**namep) + { + struct elf_link_hash_entry *h; + + h = (struct elf_link_hash_entry *) + bfd_link_hash_lookup (info->hash, *namep, false, false, false); + + if (h != NULL) + { + unsigned char type = h->type; + + if (type > STT_FUNC) type = 0; + (*_bfd_error_handler) + (_("Symbol `%s' has differing types: " + "previously %s, REGISTER in %s"), + *namep, stt_types [type], bfd_get_filename (abfd)); + return false; + } + + p->name = bfd_hash_allocate (&info->hash->table, + strlen (*namep) + 1); + if (!p->name) + return false; + + strcpy (p->name, *namep); + } + else + p->name = ""; + p->bind = ELF_ST_BIND (sym->st_info); + p->abfd = abfd; + p->shndx = sym->st_shndx; + } + else + { + if (p->bind == STB_WEAK + && ELF_ST_BIND (sym->st_info) == STB_GLOBAL) + { + p->bind = STB_GLOBAL; + p->abfd = abfd; + } + } + *namep = NULL; + return true; + } + else if (! *namep || ! **namep) + return true; + else + { + int i; + struct sparc64_elf_app_reg *p; + + p = sparc64_elf_hash_table(info)->app_regs; + for (i = 0; i < 4; i++, p++) + if (p->name != NULL && ! strcmp (p->name, *namep)) + { + unsigned char type = ELF_ST_TYPE (sym->st_info); + + if (type > STT_FUNC) type = 0; + (*_bfd_error_handler) + (_("Symbol `%s' has differing types: " + "REGISTER in %s, %s in %s"), + *namep, bfd_get_filename (p->abfd), stt_types [type], + bfd_get_filename (abfd)); + return false; + } + } + return true; +} + +/* This function takes care of emiting STT_REGISTER symbols + which we cannot easily keep in the symbol hash table. */ + +static boolean +sparc64_elf_output_arch_syms (output_bfd, info, finfo, func) + bfd *output_bfd; + struct bfd_link_info *info; + PTR finfo; + boolean (*func) PARAMS ((PTR, const char *, + Elf_Internal_Sym *, asection *)); +{ + int reg; + struct sparc64_elf_app_reg *app_regs = + sparc64_elf_hash_table(info)->app_regs; + Elf_Internal_Sym sym; + + /* We arranged in size_dynamic_sections to put the STT_REGISTER entries + at the end of the dynlocal list, so they came at the end of the local + symbols in the symtab. Except that they aren't STB_LOCAL, so we need + to back up symtab->sh_info. */ + if (elf_hash_table (info)->dynlocal) + { + bfd * dynobj = elf_hash_table (info)->dynobj; + asection *dynsymsec = bfd_get_section_by_name (dynobj, ".dynsym"); + struct elf_link_local_dynamic_entry *e; + + for (e = elf_hash_table (info)->dynlocal; e ; e = e->next) + if (e->input_indx == -1) + break; + if (e) + { + elf_section_data (dynsymsec->output_section)->this_hdr.sh_info + = e->dynindx; + } + } + + if (info->strip == strip_all) + return true; + + for (reg = 0; reg < 4; reg++) + if (app_regs [reg].name != NULL) + { + if (info->strip == strip_some + && bfd_hash_lookup (info->keep_hash, + app_regs [reg].name, + false, false) == NULL) + continue; + + sym.st_value = reg < 2 ? reg + 2 : reg + 4; + sym.st_size = 0; + sym.st_other = 0; + sym.st_info = ELF_ST_INFO (app_regs [reg].bind, STT_REGISTER); + sym.st_shndx = app_regs [reg].shndx; + if (! (*func) (finfo, app_regs [reg].name, &sym, + sym.st_shndx == SHN_ABS + ? bfd_abs_section_ptr : bfd_und_section_ptr)) + return false; + } + + return true; +} + +static int +sparc64_elf_get_symbol_type (elf_sym, type) + Elf_Internal_Sym * elf_sym; + int type; +{ + if (ELF_ST_TYPE (elf_sym->st_info) == STT_REGISTER) + return STT_REGISTER; + else + return type; +} + +/* A STB_GLOBAL,STT_REGISTER symbol should be BSF_GLOBAL + even in SHN_UNDEF section. */ + +static void +sparc64_elf_symbol_processing (abfd, asym) + bfd *abfd; + asymbol *asym; +{ + elf_symbol_type *elfsym; + + elfsym = (elf_symbol_type *) asym; + if (elfsym->internal_elf_sym.st_info + == ELF_ST_INFO (STB_GLOBAL, STT_REGISTER)) + { + asym->flags |= BSF_GLOBAL; + } +} + /* 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 @@ -1097,7 +1753,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) if (strip) { - _bfd_strip_section_from_output (s); + _bfd_strip_section_from_output (info, s); continue; } @@ -1116,6 +1772,11 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) 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. */ + int reg; + struct sparc64_elf_app_reg * app_regs; + struct bfd_strtab_hash *dynstr; + struct elf_link_hash_table *eht = elf_hash_table (info); + if (! info->shared) { if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)) @@ -1127,9 +1788,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) 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)) + || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0)) return false; } @@ -1144,56 +1803,57 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) 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; + /* Add dynamic STT_REGISTER symbols and corresponding DT_SPARC_REGISTER + entries if needed. */ + app_regs = sparc64_elf_hash_table (info)->app_regs; + dynstr = eht->dynstr; - 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. */ + for (reg = 0; reg < 4; reg++) + if (app_regs [reg].name != NULL) + { + struct elf_link_local_dynamic_entry *entry, *e; + + if (! bfd_elf64_add_dynamic_entry (info, DT_SPARC_REGISTER, 0)) + return false; - ++c; - } + entry = (struct elf_link_local_dynamic_entry *) + bfd_hash_allocate (&info->hash->table, sizeof (*entry)); + if (entry == NULL) + return false; - elf_link_hash_traverse (elf_hash_table (info), - sparc64_elf_adjust_dynindx, - (PTR) &c); - elf_hash_table (info)->dynsymcount += c; + /* We cheat here a little bit: the symbol will not be local, so we + put it at the end of the dynlocal linked list. We will fix it + later on, as we have to fix other fields anyway. */ + entry->isym.st_value = reg < 2 ? reg + 2 : reg + 4; + entry->isym.st_size = 0; + if (*app_regs [reg].name != '\0') + entry->isym.st_name + = _bfd_stringtab_add (dynstr, app_regs[reg].name, true, false); + else + entry->isym.st_name = 0; + entry->isym.st_other = 0; + entry->isym.st_info = ELF_ST_INFO (app_regs [reg].bind, + STT_REGISTER); + entry->isym.st_shndx = app_regs [reg].shndx; + entry->next = NULL; + entry->input_bfd = output_bfd; + entry->input_indx = -1; + + if (eht->dynlocal == NULL) + eht->dynlocal = entry; + else + { + for (e = eht->dynlocal; e->next; e = e->next) + ; + e->next = entry; + } + eht->dynsymcount++; + } } 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. */ @@ -1245,8 +1905,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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) + r_type = ELF64_R_TYPE_ID (rel->r_info); + if (r_type < 0 || r_type >= (int) R_SPARC_max_std) { bfd_set_error (bfd_error_bad_value); return false; @@ -1395,7 +2055,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, - input_section, rel->r_offset))) + input_section, rel->r_offset, + (!info->shared || info->no_undefined)))) return false; relocation = 0; } @@ -1531,7 +2192,11 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, & ELF_LINK_HASH_DEF_REGULAR) == 0)) { BFD_ASSERT (h->dynindx != -1); - outrel.r_info = ELF64_R_INFO (h->dynindx, r_type); + outrel.r_info + = ELF64_R_INFO (h->dynindx, + ELF64_R_TYPE_INFO ( + ELF64_R_TYPE_DATA (rel->r_info), + r_type)); outrel.r_addend = rel->r_addend; } else @@ -1581,16 +2246,12 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, } } - 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; + outrel.r_info + = ELF64_R_INFO (indx, + ELF64_R_TYPE_INFO ( + ELF64_R_TYPE_DATA (rel->r_info), + r_type)); + outrel.r_addend = relocation + rel->r_addend; } } @@ -1605,7 +2266,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, reloc in an unallocated section. */ if (skip || (input_section->flags & SEC_ALLOC) != 0 - || ELF64_R_TYPE (outrel.r_info) != R_SPARC_RELATIVE) + || ELF64_R_TYPE_ID (outrel.r_info) != R_SPARC_RELATIVE) continue; } break; @@ -1905,7 +2566,8 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) { 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_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4) + -(splt->output_section->vma + splt->output_offset); } rela.r_offset += (splt->output_section->vma + splt->output_offset); rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT); @@ -2007,6 +2669,7 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info) struct bfd_link_info *info; { bfd *dynobj; + int stt_regidx = -1; asection *sdyn; asection *sgot; @@ -2037,6 +2700,17 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info) 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; + case DT_SPARC_REGISTER: + if (stt_regidx == -1) + { + stt_regidx = + _bfd_elf_link_lookup_local_dynindx (info, output_bfd, -1); + if (stt_regidx == -1) + return false; + } + dyn.d_un.d_val = stt_regidx++; + bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); + /* fallthrough */ default: name = NULL; size = false; break; } @@ -2090,50 +2764,6 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info) 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; } @@ -2171,25 +2801,40 @@ sparc64_elf_merge_private_bfd_data (ibfd, obfd) { 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; + if ((ibfd->flags & DYNAMIC) != 0) + { + /* We don't want dynamic objects memory ordering and + architecture to have any role. That's what dynamic linker + should do. */ + old_flags &= ~(EF_SPARCV9_MM | EF_SPARC_SUN_US1 | EF_SPARC_HAL_R1); + old_flags |= (new_flags + & (EF_SPARCV9_MM + | EF_SPARC_SUN_US1 + | EF_SPARC_HAL_R1)); + } + else + { + /* Choose the highest architecture requirements. */ + 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) @@ -2210,7 +2855,34 @@ sparc64_elf_merge_private_bfd_data (ibfd, obfd) } return true; } + +/* Print a STT_REGISTER symbol to file FILE. */ +static const char * +sparc64_elf_print_symbol_all (abfd, filep, symbol) + bfd *abfd; + PTR filep; + asymbol *symbol; +{ + FILE *file = (FILE *) filep; + int reg, type; + + if (ELF_ST_TYPE (((elf_symbol_type *) symbol)->internal_elf_sym.st_info) + != STT_REGISTER) + return NULL; + + reg = ((elf_symbol_type *) symbol)->internal_elf_sym.st_value; + type = symbol->flags; + fprintf (file, "REG_%c%c%11s%c%c R", "GOLI" [reg / 8], '0' + (reg & 7), "", + ((type & BSF_LOCAL) + ? (type & BSF_GLOBAL) ? '!' : 'l' + : (type & BSF_GLOBAL) ? 'g' : ' '), + (type & BSF_WEAK) ? 'w' : ' '); + if (symbol->name == NULL || symbol->name [0] == '\0') + return "#scratch"; + else + return symbol->name; +} /* Set the right machine number for a SPARC64 ELF file. */ @@ -2225,6 +2897,45 @@ sparc64_elf_object_p (abfd) return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach); } +/* Relocations in the 64 bit SPARC ELF ABI are more complex than in + standard ELF, because R_SPARC_OLO10 has secondary addend in + ELF64_R_TYPE_DATA field. This structure is used to redirect the + relocation handling routines. */ + +const struct elf_size_info sparc64_elf_size_info = +{ + sizeof (Elf64_External_Ehdr), + sizeof (Elf64_External_Phdr), + sizeof (Elf64_External_Shdr), + sizeof (Elf64_External_Rel), + sizeof (Elf64_External_Rela), + sizeof (Elf64_External_Sym), + sizeof (Elf64_External_Dyn), + sizeof (Elf_External_Note), + 4, /* hash-table entry size */ + /* internal relocations per external relocations. + For link purposes we use just 1 internal per + 1 external, for assembly and slurp symbol table + we use 2. */ + 1, + 64, /* arch_size */ + 8, /* file_align */ + ELFCLASS64, + EV_CURRENT, + bfd_elf64_write_out_phdrs, + bfd_elf64_write_shdrs_and_ehdr, + sparc64_elf_write_relocs, + bfd_elf64_swap_symbol_out, + sparc64_elf_slurp_reloc_table, + bfd_elf64_slurp_symbol_table, + bfd_elf64_swap_dyn_in, + bfd_elf64_swap_dyn_out, + NULL, + NULL, + NULL, + NULL +}; + #define TARGET_BIG_SYM bfd_elf64_sparc_vec #define TARGET_BIG_NAME "elf64-sparc" #define ELF_ARCH bfd_arch_sparc @@ -2236,13 +2947,28 @@ sparc64_elf_object_p (abfd) /* This is the value that we used before the ABI was released. */ #define ELF_MACHINE_ALT1 EM_OLD_SPARCV9 +#define bfd_elf64_bfd_link_hash_table_create \ + sparc64_elf_bfd_link_hash_table_create + #define elf_info_to_howto \ sparc64_elf_info_to_howto +#define bfd_elf64_get_reloc_upper_bound \ + sparc64_elf_get_reloc_upper_bound +#define bfd_elf64_get_dynamic_reloc_upper_bound \ + sparc64_elf_get_dynamic_reloc_upper_bound +#define bfd_elf64_canonicalize_dynamic_reloc \ + sparc64_elf_canonicalize_dynamic_reloc #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_add_symbol_hook \ + sparc64_elf_add_symbol_hook +#define elf_backend_get_symbol_type \ + sparc64_elf_get_symbol_type +#define elf_backend_symbol_processing \ + sparc64_elf_symbol_processing #define elf_backend_check_relocs \ sparc64_elf_check_relocs #define elf_backend_adjust_dynamic_symbol \ @@ -2255,10 +2981,16 @@ sparc64_elf_object_p (abfd) sparc64_elf_finish_dynamic_symbol #define elf_backend_finish_dynamic_sections \ sparc64_elf_finish_dynamic_sections +#define elf_backend_print_symbol_all \ + sparc64_elf_print_symbol_all +#define elf_backend_output_arch_syms \ + sparc64_elf_output_arch_syms #define bfd_elf64_bfd_merge_private_bfd_data \ sparc64_elf_merge_private_bfd_data +#define elf_backend_size_info \ + sparc64_elf_size_info #define elf_backend_object_p \ sparc64_elf_object_p diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c index 5952e74..38778b7 100644 --- a/bfd/elfarm-nabi.c +++ b/bfd/elfarm-nabi.c @@ -35,8 +35,10 @@ #define TARGET_BIG_NAME "elf32-bigarm" #define elf_info_to_howto 0 -#define elf_info_to_howto_rel elf32_arm_info_to_howto_rel +#define elf_info_to_howto_rel elf32_arm_info_to_howto +#define ARM_ELF_ABI_VERSION 0 +#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM static reloc_howto_type * elf32_arm_reloc_type_lookup PARAMS ((bfd * abfd, bfd_reloc_code_real_type code)); @@ -574,8 +576,8 @@ static reloc_howto_type elf32_arm_thm_pc9_howto = static void -elf32_arm_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) - bfd * abfd; +elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc) + bfd * abfd ATTRIBUTE_UNUSED; arelent * bfd_reloc; Elf32_Internal_Rel * elf_reloc; { @@ -639,7 +641,7 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = static reloc_howto_type * elf32_arm_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { unsigned int i; diff --git a/bfd/elfarm-oabi.c b/bfd/elfarm-oabi.c index f219b92..72f62f2 100644 --- a/bfd/elfarm-oabi.c +++ b/bfd/elfarm-oabi.c @@ -23,6 +23,10 @@ #include "libbfd.h" #include "elf-bfd.h" +#ifndef NUM_ELEM +#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0]) +#endif + #define USE_RELA #define TARGET_LITTLE_SYM bfd_elf32_littlearm_oabi_vec @@ -33,6 +37,9 @@ #define elf_info_to_howto elf32_arm_info_to_howto #define elf_info_to_howto_rel 0 +#define ARM_ELF_ABI_VERSION 0 +#define ARM_ELF_OS_ABI_VERSION 0 + static reloc_howto_type elf32_arm_howto_table[] = { /* No relocation */ @@ -173,7 +180,7 @@ static reloc_howto_type elf32_arm_howto_table[] = 0, /* bitsize */ false, /* pc_relative */ 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ + complain_overflow_dont,/* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_ARM_SBREL32", /* name */ false, /* partial_inplace */ @@ -254,7 +261,24 @@ static reloc_howto_type elf32_arm_howto_table[] = 0, /* src_mask */ 0, /* dst_mask */ false), /* pcrel_offset */ - + + /* XXX - gap in index numbering here. */ + + 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 */ + + /* XXX - gap in index numbering here. */ HOWTO (R_ARM_RREL32, /* type */ 0, /* rightshift */ @@ -310,22 +334,38 @@ static reloc_howto_type elf32_arm_howto_table[] = false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false), /* pcrel_offset */ - + false) /* pcrel_offset */ }; +/* Locate a reloc in the howto table. This function must be used + when the entry number is is > R_ARM_GNU_VTINHERIT. */ +static reloc_howto_type * +find_howto (r_type) + unsigned int r_type; +{ + int i; + + for (i = NUM_ELEM (elf32_arm_howto_table); i--;) + if (elf32_arm_howto_table [i].type == r_type) + return elf32_arm_howto_table + i; + + return NULL; +} + static void elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; 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]; + + if (r_type <= R_ARM_GNU_VTINHERIT) + bfd_reloc->howto = & elf32_arm_howto_table[r_type]; + else + bfd_reloc->howto = find_howto (r_type); } struct elf32_arm_reloc_map @@ -336,38 +376,37 @@ struct elf32_arm_reloc_map 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,} + {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_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 }, + {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT }, + {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY } }; static reloc_howto_type * elf32_arm_reloc_type_lookup (abfd, code) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; 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]; - } + for (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]; + if (code == BFD_RELOC_ARM_PLT32) + return find_howto (R_ARM_PLT32); + return NULL; } diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 22f6488..c5edf9b 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1,5 +1,6 @@ /* ELF executable support for BFD. - Copyright 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright 1991, 92, 93, 94, 95, 96, 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 @@ -129,6 +130,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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) +#define elf_link_record_local_dynamic_symbol \ + NAME(_bfd_elf,link_record_local_dynamic_symbol) #if ARCH_SIZE == 64 #define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y) @@ -162,6 +165,9 @@ static void elf_swap_shdr_out #define section_from_elf_index bfd_section_from_elf_index +static boolean elf_slurp_reloc_table_from_section + PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type, + arelent *, asymbol **, boolean)); static boolean elf_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **, boolean)); @@ -201,8 +207,13 @@ elf_swap_symbol_in (abfd, src, dst) const Elf_External_Sym *src; Elf_Internal_Sym *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + dst->st_name = bfd_h_get_32 (abfd, (bfd_byte *) src->st_name); - dst->st_value = get_word (abfd, (bfd_byte *) src->st_value); + if (signed_vma) + dst->st_value = get_signed_word (abfd, (bfd_byte *) src->st_value); + else + 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); @@ -289,10 +300,15 @@ elf_swap_shdr_in (abfd, src, dst) const Elf_External_Shdr *src; Elf_Internal_Shdr *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + 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); + if (signed_vma) + dst->sh_addr = get_signed_word (abfd, (bfd_byte *) src->sh_addr); + else + 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); @@ -335,11 +351,21 @@ elf_swap_phdr_in (abfd, src, dst) const Elf_External_Phdr *src; Elf_Internal_Phdr *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + 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); + if (signed_vma) + { + dst->p_vaddr = get_signed_word (abfd, (bfd_byte *) src->p_vaddr); + dst->p_paddr = get_signed_word (abfd, (bfd_byte *) src->p_paddr); + } + else + { + 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); @@ -419,11 +445,13 @@ elf_swap_dyn_in (abfd, p, dst) } INLINE void -elf_swap_dyn_out (abfd, src, dst) +elf_swap_dyn_out (abfd, src, p) bfd *abfd; const Elf_Internal_Dyn *src; - Elf_External_Dyn *dst; + PTR p; { + Elf_External_Dyn *dst = (Elf_External_Dyn *) p; + put_word (abfd, src->d_tag, dst->d_tag); put_word (abfd, src->d_un.d_val, dst->d_un.d_val); } @@ -729,7 +757,7 @@ write_relocs (abfd, sec, data) 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; + int use_rela_p; asymbol *last_sym = 0; int last_sym_idx = 0; @@ -757,6 +785,16 @@ write_relocs (abfd, sec, data) return; } + /* Figure out whether the relocations are RELA or REL relocations. */ + if (rela_hdr->sh_type == SHT_RELA) + use_rela_p = true; + else if (rela_hdr->sh_type == SHT_REL) + use_rela_p = false; + else + /* Every relocation section should be either an SHT_RELA or an + SHT_REL section. */ + abort (); + /* orelocation has the data, reloc_count has the count... */ if (use_rela_p) { @@ -839,6 +877,8 @@ write_relocs (abfd, sec, data) 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; @@ -851,7 +891,8 @@ write_relocs (abfd, sec, data) last_sym_idx = n; } - if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec + 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; @@ -1185,50 +1226,27 @@ error_return: return -1; } -/* Read in and swap the external relocs. */ +/* Read relocations for ASECT from REL_HDR. There are RELOC_COUNT of + them. */ static boolean -elf_slurp_reloc_table (abfd, asect, symbols, dynamic) +elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, + relents, symbols, dynamic) bfd *abfd; asection *asect; + Elf_Internal_Shdr *rel_hdr; + bfd_size_type reloc_count; + arelent *relents; 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; @@ -1240,10 +1258,6 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic) 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)); @@ -1298,8 +1312,6 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic) (*ebd->elf_info_to_howto_rel) (abfd, relent, &rel); } - asect->relocation = relents; - if (allocated != NULL) free (allocated); @@ -1311,6 +1323,82 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic) return false; } +/* 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 bfd_elf_section_data * const d = elf_section_data (asect); + Elf_Internal_Shdr *rel_hdr; + Elf_Internal_Shdr *rel_hdr2; + bfd_size_type reloc_count; + bfd_size_type reloc_count2; + arelent *relents; + + 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 = rel_hdr->sh_size / rel_hdr->sh_entsize; + rel_hdr2 = d->rel_hdr2; + reloc_count2 = (rel_hdr2 + ? (rel_hdr2->sh_size / rel_hdr2->sh_entsize) + : 0); + + BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2); + BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset + || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset)); + + } + else + { + /* Note that ASECT->RELOC_COUNT tends not to be accurate in this + case because relocations against this section may use the + dynamic symbol table, and in that case bfd_section_from_shdr + in elf.c does not update the RELOC_COUNT. */ + if (asect->_raw_size == 0) + return true; + + rel_hdr = &d->this_hdr; + reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize; + rel_hdr2 = NULL; + reloc_count2 = 0; + } + + relents = ((arelent *) + bfd_alloc (abfd, + (reloc_count + reloc_count2) * sizeof (arelent))); + if (relents == NULL) + return false; + + if (!elf_slurp_reloc_table_from_section (abfd, asect, + rel_hdr, reloc_count, + relents, + symbols, dynamic)) + return false; + + if (rel_hdr2 + && !elf_slurp_reloc_table_from_section (abfd, asect, + rel_hdr2, reloc_count2, + relents + reloc_count, + symbols, dynamic)) + return false; + + + asect->relocation = relents; + return true; +} + #ifdef DEBUG static void elf_debug_section (num, hdr) @@ -1439,7 +1527,8 @@ const struct elf_size_info NAME(_bfd_elf,size_info) = { sizeof (Elf_External_Sym), sizeof (Elf_External_Dyn), sizeof (Elf_External_Note), - + ARCH_SIZE / 8, + 1, ARCH_SIZE, FILE_ALIGN, ELFCLASS, EV_CURRENT, elf_write_out_phdrs, @@ -1448,5 +1537,10 @@ const struct elf_size_info NAME(_bfd_elf,size_info) = { elf_swap_symbol_out, elf_slurp_reloc_table, elf_slurp_symbol_table, - elf_swap_dyn_in + elf_swap_dyn_in, + elf_swap_dyn_out, + NULL, + NULL, + NULL, + NULL }; diff --git a/bfd/elflink.c b/bfd/elflink.c index dc0b042..6534d84 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1,5 +1,5 @@ /* ELF linking support for BFD. - Copyright 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -100,7 +100,7 @@ _bfd_elf_create_dynamic_sections (abfd, info) flagword flags, pltflags; register asection *s; struct elf_backend_data *bed = get_elf_backend_data (abfd); - int ptralign; + int ptralign = 0; switch (bed->s->arch_size) { @@ -147,7 +147,8 @@ _bfd_elf_create_dynamic_sections (abfd, info) return false; } - s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section (abfd, + bed->default_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)) @@ -156,18 +157,20 @@ _bfd_elf_create_dynamic_sections (abfd, info) 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; + if (bed->want_dynbss) + { + /* 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 + /* 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 @@ -178,13 +181,16 @@ _bfd_elf_create_dynamic_sections (abfd, info) 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; + if (! info->shared) + { + s = bfd_make_section (abfd, + (bed->default_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; @@ -212,6 +218,32 @@ _bfd_elf_link_record_dynamic_symbol (info, h) boolean copy; bfd_size_type indx; + /* XXX: The ABI draft says the linker must turn hidden and + internal symbols into STB_LOCAL symbols when producing the + DSO. However, if ld.so honors st_other in the dynamic table, + this would not be necessary. */ + switch (ELF_ST_VISIBILITY (h->other)) + { + case STV_INTERNAL: + case STV_HIDDEN: + /* This symbol must be defined in the shared object or + executable. */ + if (h->root.type == bfd_link_hash_undefined) + { + bfd * abfd = h->root.u.undef.abfd; + const char * name = h->root.root.string; + + (*info->callbacks->undefined_symbol) + (info, name, abfd, bfd_und_section_ptr, 0, true); + } + + h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL; + break; + + default: + break; + } + h->dynindx = elf_hash_table (info)->dynsymcount; ++elf_hash_table (info)->dynsymcount; @@ -256,8 +288,84 @@ _bfd_elf_link_record_dynamic_symbol (info, h) return true; } + +/* Return the dynindex of a local dynamic symbol. */ + +long +_bfd_elf_link_lookup_local_dynindx (info, input_bfd, input_indx) + struct bfd_link_info *info; + bfd *input_bfd; + long input_indx; +{ + struct elf_link_local_dynamic_entry *e; + + for (e = elf_hash_table (info)->dynlocal; e ; e = e->next) + if (e->input_bfd == input_bfd && e->input_indx == input_indx) + return e->dynindx; + return -1; +} + +/* 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_hash_table_dynsyms + PARAMS ((struct elf_link_hash_entry *, PTR)); + +static boolean +elf_link_renumber_hash_table_dynsyms (h, data) + struct elf_link_hash_entry *h; + PTR data; +{ + size_t *count = (size_t *) data; + + if (h->dynindx != -1) + h->dynindx = ++(*count); + + return true; +} + +/* Assign dynsym indicies. In a shared library we generate a section + symbol for each output section, which come first. Next come all of + the back-end allocated local dynamic syms, followed by the rest of + the global symbols. */ + +unsigned long +_bfd_elf_link_renumber_dynsyms (output_bfd, info) + bfd *output_bfd; + struct bfd_link_info *info; +{ + unsigned long dynsymcount = 0; + + if (info->shared) + { + asection *p; + for (p = output_bfd->sections; p ; p = p->next) + elf_section_data (p)->dynindx = ++dynsymcount; + } + + if (elf_hash_table (info)->dynlocal) + { + struct elf_link_local_dynamic_entry *p; + for (p = elf_hash_table (info)->dynlocal; p ; p = p->next) + p->dynindx = ++dynsymcount; + } + + elf_link_hash_traverse (elf_hash_table (info), + elf_link_renumber_hash_table_dynsyms, + &dynsymcount); + + /* There is an unused NULL entry at the head of the table which + we must account for in our count. Unless there weren't any + symbols, which means we'll have no table at all. */ + if (dynsymcount != 0) + ++dynsymcount; + + return elf_hash_table (info)->dynsymcount = dynsymcount; +} -/* Create a special linker section, or return a pointer to a linker section already created */ +/* 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) diff --git a/bfd/elflink.h b/bfd/elflink.h index 32bfab0..bddf290 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -1,5 +1,5 @@ /* ELF linker support. - Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -48,10 +48,17 @@ 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)); +static boolean elf_link_read_relocs_from_section + PARAMS ((bfd *, Elf_Internal_Shdr *, PTR, Elf_Internal_Rela *)); +static void elf_link_output_relocs + PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *)); +static boolean elf_link_size_reloc_section + PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); +static void elf_link_adjust_relocs + PARAMS ((bfd *, Elf_Internal_Shdr *, unsigned int, + struct elf_link_hash_entry **)); /* Given an ELF BFD, add symbols to the global hash table as appropriate. */ @@ -73,6 +80,138 @@ elf_bfd_link_add_symbols (abfd, info) } } +/* Return true iff this is a non-common definition of a symbol. */ +static boolean +is_global_symbol_definition (abfd, sym) + bfd * abfd ATTRIBUTE_UNUSED; + Elf_Internal_Sym * sym; +{ + /* Local symbols do not count, but target specific ones might. */ + if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL + && ELF_ST_BIND (sym->st_info) < STB_LOOS) + return false; + + /* If the section is undefined, then so is the symbol. */ + if (sym->st_shndx == SHN_UNDEF) + return false; + + /* If the symbol is defined in the common section, then + it is a common definition and so does not count. */ + if (sym->st_shndx == SHN_COMMON) + return false; + + /* If the symbol is in a target specific section then we + must rely upon the backend to tell us what it is. */ + if (sym->st_shndx >= SHN_LORESERVE && sym->st_shndx < SHN_ABS) + /* FIXME - this function is not coded yet: + + return _bfd_is_global_symbol_definition (abfd, sym); + + Instead for now assume that the definition is not global, + Even if this is wrong, at least the linker will behave + in the same way that it used to do. */ + return false; + + return true; +} + + +/* Search the symbol table of the archive element of the archive ABFD + whoes archove map contains a mention of SYMDEF, and determine if + the symbol is defined in this element. */ +static boolean +elf_link_is_defined_archive_symbol (abfd, symdef) + bfd * abfd; + carsym * symdef; +{ + Elf_Internal_Shdr * hdr; + Elf_External_Sym * esym; + Elf_External_Sym * esymend; + Elf_External_Sym * buf = NULL; + size_t symcount; + size_t extsymcount; + size_t extsymoff; + boolean result = false; + + abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset); + if (abfd == (bfd *) NULL) + return false; + + if (! bfd_check_format (abfd, bfd_object)) + return false; + + /* If we have already included the element containing this symbol in the + link then we do not need to include it again. Just claim that any symbol + it contains is not a definition, so that our caller will not decide to + (re)include this element. */ + if (abfd->archive_pass) + return false; + + /* Select the appropriate symbol table. */ + if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) + hdr = &elf_tdata (abfd)->symtab_hdr; + else + hdr = &elf_tdata (abfd)->dynsymtab_hdr; + + 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. */ + 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) + return false; + + /* Read in the symbol table. + FIXME: This ought to be cached somewhere. */ + 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))) + { + free (buf); + return false; + } + + /* Scan the symbol table looking for SYMDEF. */ + esymend = buf + extsymcount; + for (esym = buf; + esym < esymend; + esym++) + { + Elf_Internal_Sym sym; + const char * name; + + elf_swap_symbol_in (abfd, esym, & sym); + + name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); + if (name == (const char *) NULL) + break; + + if (strcmp (name, symdef->name) == 0) + { + result = is_global_symbol_definition (abfd, & sym); + break; + } + } + + free (buf); + + return result; +} + /* 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 @@ -193,7 +332,24 @@ elf_link_add_archive_symbols (abfd, info) if (h == NULL) continue; - if (h->root.type != bfd_link_hash_undefined) + if (h->root.type == bfd_link_hash_common) + { + /* We currently have a common symbol. The archive map contains + a reference to this symbol, so we may want to include it. We + only want to include it however, if this archive element + contains a definition of the symbol, not just another common + declaration of it. + + Unfortunately some archivers (including GNU ar) will put + declarations of common symbols into their archive maps, as + well as real definitions, so we cannot just go by the archive + map alone. Instead we must read in the element's symbol + table and check that to see what kind of symbol definition + this is. */ + if (! elf_link_is_defined_archive_symbol (abfd, symdef)) + continue; + } + else if (h->root.type != bfd_link_hash_undefined) { if (h->root.type != bfd_link_hash_undefweak) defined[i] = true; @@ -358,6 +514,17 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, break; } + /* In cases involving weak versioned symbols, we may wind up trying + to merge a symbol with itself. Catch that here, to avoid the + confusion that results if we try to override a symbol with + itself. The additional tests catch cases like + _GLOBAL_OFFSET_TABLE_, which are regular symbols defined in a + dynamic object, which we do want to handle here. */ + if (abfd == oldbfd + && ((abfd->flags & DYNAMIC) == 0 + || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)) + return true; + /* NEWDYN and OLDDYN indicate whether the new or old symbol, respectively, is from a dynamic object. */ @@ -366,10 +533,35 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, else newdyn = false; - if (oldbfd == NULL || (oldbfd->flags & DYNAMIC) == 0) - olddyn = false; + if (oldbfd != NULL) + olddyn = (oldbfd->flags & DYNAMIC) != 0; else - olddyn = true; + { + asection *hsec; + + /* This code handles the special SHN_MIPS_{TEXT,DATA} section + indices used by MIPS ELF. */ + switch (h->root.type) + { + default: + hsec = NULL; + break; + + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + hsec = h->root.u.def.section; + break; + + case bfd_link_hash_common: + hsec = h->root.u.c.p->section; + break; + } + + if (hsec == NULL) + olddyn = false; + else + olddyn = (hsec->symbol->flags & BSF_DYNAMIC) != 0; + } /* NEWDEF and OLDDEF indicate whether the new or old symbol, respectively, appear to be a definition rather than reference. */ @@ -484,14 +676,19 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, 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. */ + object to override a weak symbol in a shared object. + + We prefer a non-weak definition in a shared library to a weak + definition in the executable. */ if (newdyn && newdef && (olddef || (h->root.type == bfd_link_hash_common && (bind == STB_WEAK - || ELF_ST_TYPE (sym->st_info) == STT_FUNC)))) + || ELF_ST_TYPE (sym->st_info) == STT_FUNC))) + && (h->root.type != bfd_link_hash_defweak + || bind == STB_WEAK)) { *override = true; newdef = false; @@ -535,7 +732,10 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, 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. */ + symbol is a function or is weak. + + As above, we permit a non-weak definition in a shared object to + override a weak definition in a regular object. */ if (! newdyn && (newdef @@ -544,7 +744,9 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, || h->type == STT_FUNC))) && olddyn && olddef - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0) + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 + && (bind != STB_WEAK + || h->root.type == bfd_link_hash_defweak)) { /* Change the hash table entry to undefined, and let _bfd_generic_link_add_one_symbol do the right thing with the @@ -618,6 +820,45 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, h->verinfo.vertree = NULL; } + /* Handle the special case of a weak definition in a regular object + followed by a non-weak definition in a shared object. In this + case, we prefer the definition in the shared object. */ + if (olddef + && h->root.type == bfd_link_hash_defweak + && newdef + && newdyn + && bind != STB_WEAK) + { + /* To make this work we have to frob the flags so that the rest + of the code does not think we are using the regular + definition. */ + if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) + h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; + else if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0) + h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC; + h->elf_link_hash_flags &= ~ (ELF_LINK_HASH_DEF_REGULAR + | ELF_LINK_HASH_DEF_DYNAMIC); + + /* If H is the target of an indirection, we want the caller to + use H rather than the indirect symbol. Otherwise if we are + defining a new indirect symbol we will wind up attaching it + to the entry we are overriding. */ + *sym_hash = h; + } + + /* Handle the special case of a non-weak definition in a shared + object followed by a weak definition in a regular object. In + this case we prefer to definition in the shared object. To make + this work we have to tell the caller to not treat the new symbol + as a definition. */ + if (olddef + && olddyn + && h->root.type != bfd_link_hash_defweak + && newdef + && ! newdyn + && bind == STB_WEAK) + *override = true; + return true; } @@ -649,9 +890,11 @@ elf_link_add_object_symbols (abfd, info) struct elf_link_hash_entry *weaks; Elf_External_Sym *esym; Elf_External_Sym *esymend; + struct elf_backend_data *bed; - add_symbol_hook = get_elf_backend_data (abfd)->elf_add_symbol_hook; - collect = get_elf_backend_data (abfd)->collect; + bed = get_elf_backend_data (abfd); + add_symbol_hook = bed->elf_add_symbol_hook; + collect = bed->collect; if ((abfd->flags & DYNAMIC) == 0) dynamic = false; @@ -866,6 +1109,23 @@ elf_link_add_object_symbols (abfd, info) goto error_return; link = elf_elfsections (abfd)[elfsec]->sh_link; + { + /* The shared libraries distributed with hpux11 have a bogus + sh_link field for the ".dynamic" section. This code detects + when LINK refers to a section that is not a string table and + tries to find the string table for the ".dynsym" section + instead. */ + Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[link]; + if (hdr->sh_type != SHT_STRTAB) + { + asection *s = bfd_get_section_by_name (abfd, ".dynsym"); + int 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++) @@ -1184,7 +1444,11 @@ elf_link_add_object_symbols (abfd, info) strcpy (newname, name); p = newname + namelen; *p++ = ELF_VER_CHR; - if ((iver.vs_vers & VERSYM_HIDDEN) == 0) + /* If this is a defined non-hidden version symbol, + we add another @ to the name. This indicates the + default version of the symbol. */ + if ((iver.vs_vers & VERSYM_HIDDEN) == 0 + && sym.st_shndx != SHN_UNDEF) *p++ = ELF_VER_CHR; strcpy (p, verstr); @@ -1308,9 +1572,24 @@ elf_link_add_object_symbols (abfd, info) h->type = ELF_ST_TYPE (sym.st_info); } - if (sym.st_other != 0 - && (definition || h->other == 0)) - h->other = sym.st_other; + /* If st_other has a processor-specific meaning, specific code + might be needed here. */ + if (sym.st_other != 0) + { + /* Combine visibilities, using the most constraining one. */ + unsigned char hvis = ELF_ST_VISIBILITY (h->other); + unsigned char symvis = ELF_ST_VISIBILITY (sym.st_other); + + if (symvis && (hvis > symvis || hvis == 0)) + h->other = sym.st_other; + + /* If neither has visibility, use the st_other of the + definition. This is an arbitrary choice, since the + other bits have no general meaning. */ + if (!symvis && !hvis + && (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 @@ -1461,44 +1740,7 @@ elf_link_add_object_symbols (abfd, info) == 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. */ + (*bed->elf_backend_copy_indirect_symbol) (ht, hi); /* See if the new flags lead us to realize that the symbol must be dynamic. */ @@ -1571,43 +1813,7 @@ elf_link_add_object_symbols (abfd, info) | 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. */ + (*bed->elf_backend_copy_indirect_symbol) (h, hi); /* See if the new flags lead us to realize that the symbol must be dynamic. */ @@ -1937,16 +2143,18 @@ elf_link_create_dynamic_sections (abfd, info) && ! _bfd_elf_link_record_dynamic_symbol (info, h)) return false; + bed = get_elf_backend_data (abfd); + 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; + elf_section_data (s)->this_hdr.sh_entsize = bed->s->sizeof_hash_entry; /* 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; @@ -1989,14 +2197,174 @@ elf_add_dynamic_entry (info, tag, val) return true; } + +/* Record a new local dynamic symbol. */ + +boolean +elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) + struct bfd_link_info *info; + bfd *input_bfd; + long input_indx; +{ + struct elf_link_local_dynamic_entry *entry; + struct elf_link_hash_table *eht; + struct bfd_strtab_hash *dynstr; + Elf_External_Sym esym; + unsigned long dynstr_index; + char *name; + + /* See if the entry exists already. */ + for (entry = elf_hash_table (info)->dynlocal; entry ; entry = entry->next) + if (entry->input_bfd == input_bfd && entry->input_indx == input_indx) + return true; + + entry = (struct elf_link_local_dynamic_entry *) + bfd_alloc (input_bfd, sizeof (*entry)); + if (entry == NULL) + return false; + + /* Go find the symbol, so that we can find it's name. */ + if (bfd_seek (input_bfd, + (elf_tdata (input_bfd)->symtab_hdr.sh_offset + + input_indx * sizeof (Elf_External_Sym)), + SEEK_SET) != 0 + || (bfd_read (&esym, sizeof (Elf_External_Sym), 1, input_bfd) + != sizeof (Elf_External_Sym))) + return false; + elf_swap_symbol_in (input_bfd, &esym, &entry->isym); + + name = (bfd_elf_string_from_elf_section + (input_bfd, elf_tdata (input_bfd)->symtab_hdr.sh_link, + entry->isym.st_name)); + + 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; + } + + dynstr_index = _bfd_stringtab_add (dynstr, name, true, false); + if (dynstr_index == (unsigned long) -1) + return false; + entry->isym.st_name = dynstr_index; + + eht = elf_hash_table (info); + + entry->next = eht->dynlocal; + eht->dynlocal = entry; + entry->input_bfd = input_bfd; + entry->input_indx = input_indx; + eht->dynsymcount++; + + /* Whatever binding the symbol had before, it's now local. */ + entry->isym.st_info + = ELF_ST_INFO (STB_LOCAL, ELF_ST_TYPE (entry->isym.st_info)); + + /* The dynindx will be set at the end of size_dynamic_sections. */ + + 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. */ +/* Read and swap the relocs from the section indicated by SHDR. This + may be either a REL or a RELA section. The relocations are + translated into RELA relocations and stored in INTERNAL_RELOCS, + which should have already been allocated to contain enough space. + The EXTERNAL_RELOCS are a buffer where the external form of the + relocations should be stored. + + Returns false if something goes wrong. */ + +static boolean +elf_link_read_relocs_from_section (abfd, shdr, external_relocs, + internal_relocs) + bfd *abfd; + Elf_Internal_Shdr *shdr; + PTR external_relocs; + Elf_Internal_Rela *internal_relocs; +{ + struct elf_backend_data *bed; + + /* If there aren't any relocations, that's OK. */ + if (!shdr) + return true; + + /* Position ourselves at the start of the section. */ + if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0) + return false; + + /* Read the relocations. */ + if (bfd_read (external_relocs, 1, shdr->sh_size, abfd) + != shdr->sh_size) + return false; + + bed = get_elf_backend_data (abfd); + + /* Convert the external relocations to the internal format. */ + if (shdr->sh_entsize == sizeof (Elf_External_Rel)) + { + Elf_External_Rel *erel; + Elf_External_Rel *erelend; + Elf_Internal_Rela *irela; + Elf_Internal_Rel *irel; + + erel = (Elf_External_Rel *) external_relocs; + erelend = erel + shdr->sh_size / shdr->sh_entsize; + irela = internal_relocs; + irel = bfd_alloc (abfd, (bed->s->int_rels_per_ext_rel + * sizeof (Elf_Internal_Rel))); + for (; erel < erelend; erel++, irela += bed->s->int_rels_per_ext_rel) + { + unsigned char i; + + if (bed->s->swap_reloc_in) + (*bed->s->swap_reloc_in) (abfd, (bfd_byte *) erel, irel); + else + elf_swap_reloc_in (abfd, erel, irel); + + for (i = 0; i < bed->s->int_rels_per_ext_rel; ++i) + { + irela[i].r_offset = irel[i].r_offset; + irela[i].r_info = irel[i].r_info; + irela[i].r_addend = 0; + } + } + } + else + { + Elf_External_Rela *erela; + Elf_External_Rela *erelaend; + Elf_Internal_Rela *irela; + + BFD_ASSERT (shdr->sh_entsize == sizeof (Elf_External_Rela)); + + erela = (Elf_External_Rela *) external_relocs; + erelaend = erela + shdr->sh_size / shdr->sh_entsize; + irela = internal_relocs; + for (; erela < erelaend; erela++, irela += bed->s->int_rels_per_ext_rel) + { + if (bed->s->swap_reloca_in) + (*bed->s->swap_reloca_in) (abfd, (bfd_byte *) erela, irela); + else + elf_swap_reloca_in (abfd, erela, irela); + } + } + + return true; +} + +/* Read and swap the relocs for a section O. 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. If O has two relocation + sections (both REL and RELA relocations), then the REL_HDR + relocations will appear first in INTERNAL_RELOCS, followed by the + REL_HDR2 relocations. */ Elf_Internal_Rela * NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, @@ -2010,6 +2378,7 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, Elf_Internal_Shdr *rel_hdr; PTR alloc1 = NULL; Elf_Internal_Rela *alloc2 = NULL; + struct elf_backend_data *bed = get_elf_backend_data (abfd); if (elf_section_data (o)->relocs != NULL) return elf_section_data (o)->relocs; @@ -2023,7 +2392,8 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, { size_t size; - size = o->reloc_count * sizeof (Elf_Internal_Rela); + size = (o->reloc_count * bed->s->int_rels_per_ext_rel + * sizeof (Elf_Internal_Rela)); if (keep_memory) internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size); else @@ -2034,53 +2404,27 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, if (external_relocs == NULL) { - alloc1 = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size); + size_t size = (size_t) rel_hdr->sh_size; + + if (elf_section_data (o)->rel_hdr2) + size += (size_t) elf_section_data (o)->rel_hdr2->sh_size; + alloc1 = (PTR) bfd_malloc (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)) + if (!elf_link_read_relocs_from_section (abfd, rel_hdr, + external_relocs, + internal_relocs)) + goto error_return; + if (!elf_link_read_relocs_from_section + (abfd, + elf_section_data (o)->rel_hdr2, + ((bfd_byte *) external_relocs) + rel_hdr->sh_size, + internal_relocs + (rel_hdr->sh_size / rel_hdr->sh_entsize + * bed->s->int_rels_per_ext_rel))) 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) @@ -2109,7 +2453,7 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, /*ARGSUSED*/ boolean NAME(bfd_elf,record_link_assignment) (output_bfd, info, name, provide) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; const char *name; boolean provide; @@ -2145,7 +2489,10 @@ NAME(bfd_elf,record_link_assignment) (output_bfd, info, name, provide) h->verinfo.verdef = NULL; h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; - h->type = STT_OBJECT; + + /* When possible, keep the original type of the symbol */ + if (h->type == STT_NOTYPE) + h->type = STT_OBJECT; if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_DYNAMIC)) != 0 @@ -2182,8 +2529,6 @@ struct elf_assign_sym_version_info 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; }; @@ -2228,7 +2573,7 @@ compute_bucket_count (info) struct bfd_link_info *info; { size_t dynsymcount = elf_hash_table (info)->dynsymcount; - size_t best_size; + size_t best_size = 0; unsigned long int *hashcodes; unsigned long int *hashcodesp; unsigned long int i; @@ -2381,7 +2726,6 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; @@ -2405,20 +2749,6 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; @@ -2481,12 +2811,25 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, } } + /* 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; + } + /* 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), @@ -2508,8 +2851,14 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, /* 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 there are initialization and/or finalization functions to + call then add the corresponding DT_INIT/DT_FINI entries. */ + h = (info->init_function + ? elf_link_hash_lookup (elf_hash_table (info), + info->init_function, false, + false, false) + : NULL); if (h != NULL && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR | ELF_LINK_HASH_DEF_REGULAR)) != 0) @@ -2517,8 +2866,11 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, if (! elf_add_dynamic_entry (info, DT_INIT, 0)) return false; } - h = elf_link_hash_lookup (elf_hash_table (info), "_fini", false, - false, false); + h = (info->fini_function + ? elf_link_hash_lookup (elf_hash_table (info), + info->fini_function, false, + false, false) + : NULL); if (h != NULL && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR | ELF_LINK_HASH_DEF_REGULAR)) != 0) @@ -2526,6 +2878,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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) @@ -2538,7 +2891,6 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, /* 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; @@ -2549,6 +2901,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, asection *s; size_t bucketcount = 0; Elf_Internal_Sym isym; + size_t hash_entry_size; /* Set up the version definition section. */ s = bfd_get_section_by_name (dynobj, ".gnu.version_d"); @@ -2559,17 +2912,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; - } + _bfd_strip_section_from_output (info, s); else { unsigned int cdefs; @@ -2579,23 +2922,6 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; @@ -2635,7 +2961,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, if (soname_indx != (bfd_size_type) -1) { - def.vd_hash = bfd_elf_hash ((const unsigned char *) soname); + def.vd_hash = bfd_elf_hash (soname); defaux.vda_name = soname_indx; } else @@ -2644,7 +2970,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, bfd_size_type indx; name = output_bfd->filename; - def.vd_hash = bfd_elf_hash ((const unsigned char *) name); + def.vd_hash = bfd_elf_hash (name); indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, name, true, false); if (indx == (bfd_size_type) -1) @@ -2692,7 +3018,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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_hash = bfd_elf_hash (t->name); def.vd_aux = sizeof (Elf_External_Verdef); if (t->next != NULL) def.vd_next = (sizeof (Elf_External_Verdef) @@ -2762,19 +3088,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, (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; - } + _bfd_strip_section_from_output (info, s); else { Elf_Internal_Verneed *t; @@ -2840,8 +3154,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) { - a->vna_hash = bfd_elf_hash ((const unsigned char *) - a->vna_nodename); + a->vna_hash = bfd_elf_hash (a->vna_nodename); indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, a->vna_nodename, true, false); if (indx == (bfd_size_type) -1) @@ -2866,7 +3179,12 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, } } - dynsymcount = elf_hash_table (info)->dynsymcount; + /* Assign dynsym indicies. In a shared library we generate a + section symbol for each output section, which come first. + Next come all of the back-end allocated local dynamic syms, + followed by the rest of the global symbols. */ + + dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); /* Work out the size of the symbol version section. */ s = bfd_get_section_by_name (dynobj, ".gnu.version"); @@ -2874,16 +3192,10 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; + _bfd_strip_section_from_output (info, s); + /* The DYNSYMCOUNT might have changed if we were going to + output a dynamic symbol table entry for S. */ + dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); } else { @@ -2925,14 +3237,16 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, s = bfd_get_section_by_name (dynobj, ".hash"); BFD_ASSERT (s != NULL); - s->_raw_size = (2 + bucketcount + dynsymcount) * (ARCH_SIZE / 8); + hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize; + s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size); 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)); + bfd_put (8 * hash_entry_size, output_bfd, bucketcount, s->contents); + bfd_put (8 * hash_entry_size, output_bfd, dynsymcount, + s->contents + hash_entry_size); elf_hash_table (info)->bucketcount = bucketcount; @@ -3035,6 +3349,33 @@ elf_fix_symbol_flags (h, eif) h->plt.offset = (bfd_vma) -1; } + /* If this is a weak defined symbol in a dynamic object, and we know + the real definition in the dynamic object, copy interesting flags + over to the real definition. */ + 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 the real definition is defined by a regular object file, + don't do anything special. See the longer description in + elf_adjust_dynamic_symbol, below. */ + if ((weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) + h->weakdef = NULL; + else + weakdef->elf_link_hash_flags |= + (h->elf_link_hash_flags + & (ELF_LINK_HASH_REF_REGULAR + | ELF_LINK_HASH_REF_REGULAR_NONWEAK + | ELF_LINK_NON_GOT_REF)); + } + return true; } @@ -3117,32 +3458,14 @@ elf_adjust_dynamic_symbol (h, data) if (h->weakdef != NULL) { - struct elf_link_hash_entry *weakdef; + /* If we get to this point, we know there is an implicit + reference by a regular object file via the weak symbol H. + FIXME: Is this really true? What if the traversal finds + H->WEAKDEF before it finds H? */ + h->weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; - 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 (! elf_adjust_dynamic_symbol (h->weakdef, (PTR) eif)) + return false; } /* If a symbol has no type and no size and does not require a PLT @@ -3281,6 +3604,7 @@ elf_link_assign_sym_version (h, data) struct elf_assign_sym_version_info *sinfo = (struct elf_assign_sym_version_info *) data; struct bfd_link_info *info = sinfo->info; + struct elf_backend_data *bed; struct elf_info_failed eif; char *p; @@ -3299,6 +3623,7 @@ elf_link_assign_sym_version (h, data) if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) return true; + bed = get_elf_backend_data (sinfo->output_bfd); p = strchr (h->root.root.string, ELF_VER_CHR); if (p != NULL && h->verinfo.vertree == NULL) { @@ -3365,12 +3690,8 @@ elf_link_assign_sym_version (h, data) && 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; + (*bed->elf_backend_hide_symbol) (h); /* FIXME: The name of the symbol has already been recorded in the dynamic string table section. */ @@ -3481,11 +3802,8 @@ elf_link_assign_sym_version (h, data) && 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; + (*bed->elf_backend_hide_symbol) (h); /* FIXME: The name of the symbol has already been recorded in the dynamic string table section. */ @@ -3506,11 +3824,8 @@ elf_link_assign_sym_version (h, data) && 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; + (*bed->elf_backend_hide_symbol) (h); /* FIXME: The name of the symbol has already been recorded in the dynamic string table section. */ } @@ -3519,26 +3834,6 @@ elf_link_assign_sym_version (h, data) 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. */ @@ -3606,6 +3901,101 @@ struct elf_outext_info struct elf_final_link_info *finfo; }; +/* Compute the size of, and allocate space for, REL_HDR which is the + section header for a section containing relocations for O. */ + +static boolean +elf_link_size_reloc_section (abfd, rel_hdr, o) + bfd *abfd; + Elf_Internal_Shdr *rel_hdr; + asection *o; +{ + register struct elf_link_hash_entry **p, **pend; + unsigned reloc_count; + + /* Figure out how many relocations there will be. */ + if (rel_hdr == &elf_section_data (o)->rel_hdr) + reloc_count = elf_section_data (o)->rel_count; + else + reloc_count = elf_section_data (o)->rel_count2; + + /* That allows us to calculate the size of the section. */ + rel_hdr->sh_size = rel_hdr->sh_entsize * 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) + return false; + + /* We only allocate one set of hash entries, so we only do it the + first time we are called. */ + if (elf_section_data (o)->rel_hashes == NULL) + { + p = ((struct elf_link_hash_entry **) + bfd_malloc (o->reloc_count + * sizeof (struct elf_link_hash_entry *))); + if (p == NULL && o->reloc_count != 0) + return false; + + elf_section_data (o)->rel_hashes = p; + pend = p + o->reloc_count; + for (; p < pend; p++) + *p = NULL; + } + + return true; +} + +/* When performing a relocateable link, the input relocations are + preserved. But, if they reference global symbols, the indices + referenced must be updated. Update all the relocations in + REL_HDR (there are COUNT of them), using the data in REL_HASH. */ + +static void +elf_link_adjust_relocs (abfd, rel_hdr, count, rel_hash) + bfd *abfd; + Elf_Internal_Shdr *rel_hdr; + unsigned int count; + struct elf_link_hash_entry **rel_hash; +{ + unsigned int i; + + for (i = 0; i < 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); + } + } +} + /* Do the final step of an ELF link. */ boolean @@ -3761,39 +4151,76 @@ elf_bfd_final_link (abfd, info) if (! _bfd_elf_compute_section_file_positions (abfd, info)) goto error_return; + /* Figure out how many relocations we will have in each section. + Just using RELOC_COUNT isn't good enough since that doesn't + maintain a separate value for REL vs. RELA relocations. */ + if (info->relocateable) + for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) + for (o = sub->sections; o != NULL; o = o->next) + { + asection *output_section; + + if (! o->linker_mark) + { + /* This section was omitted from the link. */ + continue; + } + + output_section = o->output_section; + + if (output_section != NULL + && (o->flags & SEC_RELOC) != 0) + { + struct bfd_elf_section_data *esdi + = elf_section_data (o); + struct bfd_elf_section_data *esdo + = elf_section_data (output_section); + unsigned int *rel_count; + unsigned int *rel_count2; + + /* We must be careful to add the relocation froms the + input section to the right output count. */ + if (esdi->rel_hdr.sh_entsize == esdo->rel_hdr.sh_entsize) + { + rel_count = &esdo->rel_count; + rel_count2 = &esdo->rel_count2; + } + else + { + rel_count = &esdo->rel_count2; + rel_count2 = &esdo->rel_count; + } + + *rel_count += (esdi->rel_hdr.sh_size + / esdi->rel_hdr.sh_entsize); + if (esdi->rel_hdr2) + *rel_count2 += (esdi->rel_hdr2->sh_size + / esdi->rel_hdr2->sh_entsize); + } + } + /* 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) + if (!elf_link_size_reloc_section (abfd, + &elf_section_data (o)->rel_hdr, + o)) 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) + if (elf_section_data (o)->rel_hdr2 + && !elf_link_size_reloc_section (abfd, + elf_section_data (o)->rel_hdr2, + o)) 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; } + + /* Now, reset REL_COUNT and REL_COUNT2 so that we can use them + to count upwards while actually outputting the relocations. */ + elf_section_data (o)->rel_count = 0; + elf_section_data (o)->rel_count2 = 0; } _bfd_elf_assign_file_positions_for_relocs (abfd); @@ -3895,7 +4322,8 @@ elf_bfd_final_link (abfd, info) 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))); + * sizeof (Elf_Internal_Rela) + * bed->s->int_rels_per_ext_rel)); finfo.external_syms = ((Elf_External_Sym *) bfd_malloc (max_sym_count * sizeof (Elf_External_Sym))); @@ -3967,9 +4395,11 @@ elf_bfd_final_link (abfd, info) } /* That wrote out all the local symbols. Finish up the symbol table - with the global symbols. */ + with the global symbols. Even if we want to strip everything we + can, we still need to deal with those global symbols that got + converted to local in a version script. */ - if (info->strip != strip_all && info->shared) + if (info->shared) { /* Output any global symbols that got converted to local in a version script. We do this in a separate step since ELF @@ -3986,11 +4416,79 @@ elf_bfd_final_link (abfd, info) return false; } - /* The sh_info field records the index of the first non local - symbol. */ + /* 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; + { + Elf_Internal_Sym sym; + Elf_External_Sym *dynsym = + (Elf_External_Sym *)finfo.dynsym_sec->contents; + long last_local = 0; + + /* Write out the section symbols for the output sections. */ + if (info->shared) + { + asection *s; + + sym.st_size = 0; + sym.st_name = 0; + sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); + sym.st_other = 0; + + for (s = abfd->sections; s != NULL; s = s->next) + { + int indx; + indx = elf_section_data (s)->this_idx; + BFD_ASSERT (indx > 0); + sym.st_shndx = indx; + sym.st_value = s->vma; + + elf_swap_symbol_out (abfd, &sym, + dynsym + elf_section_data (s)->dynindx); + } + + last_local = bfd_count_sections (abfd); + } + + /* Write out the local dynsyms. */ + if (elf_hash_table (info)->dynlocal) + { + struct elf_link_local_dynamic_entry *e; + for (e = elf_hash_table (info)->dynlocal; e ; e = e->next) + { + asection *s; + + sym.st_size = e->isym.st_size; + sym.st_other = e->isym.st_other; + + /* Copy the internal symbol as is. + Note that we saved a word of storage and overwrote + the original st_name with the dynstr_index. */ + sym = e->isym; + + if (e->isym.st_shndx > 0 && e->isym.st_shndx < SHN_LORESERVE) + { + s = bfd_section_from_elf_index (e->input_bfd, + e->isym.st_shndx); + + sym.st_shndx = + elf_section_data (s->output_section)->this_idx; + sym.st_value = (s->output_section->vma + + s->output_offset + + e->isym.st_value); + } + + if (last_local < e->dynindx) + last_local = e->dynindx; + + elf_swap_symbol_out (abfd, &sym, dynsym + e->dynindx); + } + } + + elf_section_data (finfo.dynsym_sec->output_section)->this_hdr.sh_info = + last_local + 1; + } /* We get the global symbols from the hash table. */ eoinfo.failed = false; @@ -4001,6 +4499,18 @@ elf_bfd_final_link (abfd, info) if (eoinfo.failed) return false; + /* If backend needs to output some symbols not present in the hash + table, do it now. */ + if (bed->elf_backend_output_arch_syms) + { + if (! (*bed->elf_backend_output_arch_syms) + (abfd, info, (PTR) &finfo, + (boolean (*) PARAMS ((PTR, const char *, + Elf_Internal_Sym *, asection *))) + elf_link_output_sym)) + return false; + } + /* Flush all symbols to the file. */ if (! elf_link_flush_output_syms (&finfo)) return false; @@ -4035,47 +4545,17 @@ elf_bfd_final_link (abfd, info) /* 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); - } - } + elf_link_adjust_relocs (abfd, &elf_section_data (o)->rel_hdr, + elf_section_data (o)->rel_count, + elf_section_data (o)->rel_hashes); + if (elf_section_data (o)->rel_hdr2 != NULL) + elf_link_adjust_relocs (abfd, elf_section_data (o)->rel_hdr2, + elf_section_data (o)->rel_count2, + (elf_section_data (o)->rel_hashes + + elf_section_data (o)->rel_count)); /* Set the reloc_count field to 0 to prevent write_relocs from trying to swap the relocs out itself. */ @@ -4106,15 +4586,11 @@ elf_bfd_final_link (abfd, info) { 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"; + name = info->init_function; goto get_sym; case DT_FINI: - name = "_fini"; + name = info->fini_function; get_sym: { struct elf_link_hash_entry *h; @@ -4423,7 +4899,6 @@ elf_link_output_extsym (h, data) 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 @@ -4431,7 +4906,7 @@ elf_link_output_extsym (h, data) { if (! ((*finfo->info->callbacks->undefined_symbol) (finfo->info, h->root.root.string, h->root.u.undef.abfd, - (asection *) NULL, 0))) + (asection *) NULL, 0, true))) { eoinfo->failed = true; return false; @@ -4459,8 +4934,10 @@ elf_link_output_extsym (h, data) 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) + nothing else to do unless it is a forced local symbol. */ + if (strip + && h->dynindx == -1 + && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) return true; sym.st_value = 0; @@ -4577,14 +5054,23 @@ elf_link_output_extsym (h, data) /* 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, + mark the symbol as weak undefined; if there are non-weak + references, mark the symbol as strong. 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); + && (ELF_ST_BIND(sym.st_info) == STB_GLOBAL + || ELF_ST_BIND(sym.st_info) == STB_WEAK)) + { + int bindtype; + + if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK) != 0) + bindtype = STB_GLOBAL; + else + bindtype = STB_WEAK; + sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info)); + } /* 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 @@ -4594,6 +5080,7 @@ elf_link_output_extsym (h, data) { size_t bucketcount; size_t bucket; + size_t hash_entry_size; bfd_byte *bucketpos; bfd_vma chain; @@ -4606,13 +5093,15 @@ elf_link_output_extsym (h, data) bucketcount = elf_hash_table (finfo->info)->bucketcount; bucket = h->elf_hash_value % bucketcount; + hash_entry_size + = elf_section_data (finfo->hash_sec)->this_hdr.sh_entsize; 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))); + + (bucket + 2) * hash_entry_size); + chain = bfd_get (8 * hash_entry_size, finfo->output_bfd, bucketpos); + bfd_put (8 * hash_entry_size, finfo->output_bfd, h->dynindx, bucketpos); + bfd_put (8 * hash_entry_size, finfo->output_bfd, chain, + ((bfd_byte *) finfo->hash_sec->contents + + (bucketcount + 2 + h->dynindx) * hash_entry_size)); if (finfo->symver_sec != NULL && finfo->symver_sec->contents != NULL) { @@ -4659,6 +5148,76 @@ elf_link_output_extsym (h, data) return true; } +/* Copy the relocations indicated by the INTERNAL_RELOCS (which + originated from the section given by INPUT_REL_HDR) to the + OUTPUT_BFD. */ + +static void +elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, + internal_relocs) + bfd *output_bfd; + asection *input_section; + Elf_Internal_Shdr *input_rel_hdr; + Elf_Internal_Rela *internal_relocs; +{ + Elf_Internal_Rela *irela; + Elf_Internal_Rela *irelaend; + Elf_Internal_Shdr *output_rel_hdr; + asection *output_section; + unsigned int *rel_countp = NULL; + + output_section = input_section->output_section; + output_rel_hdr = NULL; + + if (elf_section_data (output_section)->rel_hdr.sh_entsize + == input_rel_hdr->sh_entsize) + { + output_rel_hdr = &elf_section_data (output_section)->rel_hdr; + rel_countp = &elf_section_data (output_section)->rel_count; + } + else if (elf_section_data (output_section)->rel_hdr2 + && (elf_section_data (output_section)->rel_hdr2->sh_entsize + == input_rel_hdr->sh_entsize)) + { + output_rel_hdr = elf_section_data (output_section)->rel_hdr2; + rel_countp = &elf_section_data (output_section)->rel_count2; + } + + BFD_ASSERT (output_rel_hdr != NULL); + + irela = internal_relocs; + irelaend = irela + input_rel_hdr->sh_size / input_rel_hdr->sh_entsize; + if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel)) + { + Elf_External_Rel *erel; + + erel = ((Elf_External_Rel *) output_rel_hdr->contents + *rel_countp); + 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 + *rel_countp); + for (; irela < irelaend; irela++, erela++) + elf_swap_reloca_out (output_bfd, irela, erela); + } + + /* Bump the counter, so that we know where to add the next set of + relocations. */ + *rel_countp += input_rel_hdr->sh_size / input_rel_hdr->sh_entsize; +} + /* 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 @@ -4684,10 +5243,11 @@ elf_link_input_bfd (finfo, input_bfd) long *pindex; asection **ppsection; asection *o; + struct elf_backend_data *bed; output_bfd = finfo->output_bfd; - relocate_section = - get_elf_backend_data (output_bfd)->elf_backend_relocate_section; + bed = get_elf_backend_data (output_bfd); + relocate_section = bed->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 @@ -4920,14 +5480,15 @@ elf_link_input_bfd (finfo, input_bfd) 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; + irelaend = + irela + o->reloc_count * bed->s->int_rels_per_ext_rel; rel_hash = (elf_section_data (o->output_section)->rel_hashes - + o->output_section->reloc_count); + + elf_section_data (o->output_section)->rel_count + + elf_section_data (o->output_section)->rel_count2); for (; irela < irelaend; irela++, rel_hash++) { unsigned long r_symndx; @@ -5051,40 +5612,16 @@ elf_link_input_bfd (finfo, input_bfd) /* 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; + elf_link_output_relocs (output_bfd, o, + input_rel_hdr, + internal_relocs); + internal_relocs + += input_rel_hdr->sh_size / input_rel_hdr->sh_entsize; + input_rel_hdr = elf_section_data (o)->rel_hdr2; + if (input_rel_hdr) + elf_link_output_relocs (output_bfd, o, + input_rel_hdr, + internal_relocs); } } @@ -5141,7 +5678,8 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) /* Figure out the symbol index. */ rel_hash_ptr = (elf_section_data (output_section)->rel_hashes - + output_section->reloc_count); + + elf_section_data (output_section)->rel_count + + elf_section_data (output_section)->rel_count2); if (link_order->type == bfd_section_reloc_link_order) { indx = link_order->u.reloc.p->u.section->target_index; @@ -5250,7 +5788,7 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) 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_section_data (output_section)->rel_count); elf_swap_reloc_out (output_bfd, &irel, erel); } else @@ -5262,11 +5800,11 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) 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_section_data (output_section)->rel_count); elf_swap_reloca_out (output_bfd, &irela, erela); } - ++output_section->reloc_count; + ++elf_section_data (output_section)->rel_count; return true; } @@ -5486,8 +6024,8 @@ elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, reloca elf_swap_reloca_out (output_bfd, &outrel, (((Elf_External_Rela *) lsect->section->contents) - + lsect->section->reloc_count)); - ++lsect->section->reloc_count; + + elf_section_data (lsect->section)->rel_count)); + ++elf_section_data (lsect->section)->rel_count; } } } @@ -5559,6 +6097,7 @@ elf_gc_mark (info, sec, gc_mark_hook) size_t extsymoff; Elf_External_Sym *locsyms, *freesyms = NULL; bfd *input_bfd = sec->owner; + struct elf_backend_data *bed = get_elf_backend_data (input_bfd); /* GCFIXME: how to arrange so that relocs and symbols are not reread continually? */ @@ -5602,7 +6141,7 @@ elf_gc_mark (info, sec, gc_mark_hook) ret = false; goto out1; } - relend = relstart + sec->reloc_count; + relend = relstart + sec->reloc_count * bed->s->int_rels_per_ext_rel; for (rel = relstart; rel < relend; rel++) { @@ -5671,6 +6210,9 @@ elf_gc_sweep (info, gc_sweep_hook) { asection *o; + if (bfd_get_flavour (sub) != bfd_target_elf_flavour) + continue; + for (o = sub->sections; o != NULL; o = o->next) { /* Keep special sections. Keep .debug sections. */ @@ -5808,6 +6350,7 @@ elf_gc_smash_unused_vtentry_relocs (h, okp) asection *sec; bfd_vma hstart, hend; Elf_Internal_Rela *relstart, *relend, *rel; + struct elf_backend_data *bed; /* Take care of both those symbols that do not describe vtables as well as those that are not loaded. */ @@ -5825,7 +6368,8 @@ elf_gc_smash_unused_vtentry_relocs (h, okp) (sec->owner, sec, NULL, (Elf_Internal_Rela *) NULL, true)); if (!relstart) return *(boolean *)okp = false; - relend = relstart + sec->reloc_count; + bed = get_elf_backend_data (sec->owner); + relend = relstart + sec->reloc_count * bed->s->int_rels_per_ext_rel; for (rel = relstart; rel < relend; ++rel) if (rel->r_offset >= hstart && rel->r_offset < hend) @@ -5883,6 +6427,10 @@ elf_gc_sections (abfd, info) for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) { asection *o; + + if (bfd_get_flavour (sub) != bfd_target_elf_flavour) + continue; + for (o = sub->sections; o != NULL; o = o->next) { if (o->flags & SEC_KEEP) @@ -5959,8 +6507,8 @@ win: boolean elf_gc_record_vtentry (abfd, sec, h, addend) - bfd *abfd; - asection *sec; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; struct elf_link_hash_entry *h; bfd_vma addend; { @@ -5986,30 +6534,31 @@ elf_gc_record_vtentry (abfd, sec, h, addend) /* Allocate one extra entry for use as a "done" flag for the consolidation pass. */ - bytes = (size / FILE_ALIGN + 1) * sizeof(boolean); + bytes = (size / FILE_ALIGN + 1) * sizeof (boolean); if (ptr) { - size_t oldbytes; - - ptr = realloc (ptr-1, bytes); - if (ptr == NULL) - return false; + ptr = bfd_realloc (ptr - 1, bytes); + + if (ptr != NULL) + { + size_t oldbytes; - oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof(boolean); - memset (ptr + oldbytes, 0, bytes - oldbytes); + oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof (boolean); + memset (((char *)ptr) + oldbytes, 0, bytes - oldbytes); + } } else - { - ptr = calloc (1, bytes); - if (ptr == NULL) - return false; - } + ptr = bfd_zmalloc (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_used = ptr + 1; h->vtable_entries_size = size; } + h->vtable_entries_used[addend / FILE_ALIGN] = true; return true; @@ -6037,10 +6586,14 @@ elf_gc_common_finalize_got_offsets (abfd, info) /* 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_signed_vma *local_got; bfd_size_type j, locsymcount; Elf_Internal_Shdr *symtab_hdr; + if (bfd_get_flavour (i) != bfd_target_elf_flavour) + continue; + + local_got = elf_local_got_refcounts (i); if (!local_got) continue; diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 9acabd1..b1f4867 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -80,6 +80,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_plt_alignment #define elf_backend_plt_alignment 2 #endif +#ifndef elf_backend_want_dynbss +#define elf_backend_want_dynbss 1 +#endif #define bfd_elfNN_bfd_debug_info_start bfd_void #define bfd_elfNN_bfd_debug_info_end bfd_void @@ -202,6 +205,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #endif #ifndef ELF_MAXPAGESIZE + #error ELF_MAXPAGESIZE is not defined #define ELF_MAXPAGESIZE 1 #endif @@ -233,6 +237,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_section_from_shdr #define elf_backend_section_from_shdr 0 #endif +#ifndef elf_backend_section_from_phdr +#define elf_backend_section_from_phdr 0 +#endif #ifndef elf_backend_fake_sections #define elf_backend_fake_sections 0 #endif @@ -290,6 +297,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_plt_header_size #define elf_backend_plt_header_size 0 #endif +#ifndef elf_backend_post_process_headers +#define elf_backend_post_process_headers NULL +#endif +#ifndef elf_backend_print_symbol_all +#define elf_backend_print_symbol_all NULL +#endif +#ifndef elf_backend_output_arch_syms +#define elf_backend_output_arch_syms NULL +#endif +#ifndef elf_backend_copy_indirect_symbol +#define elf_backend_copy_indirect_symbol _bfd_elf_link_hash_copy_indirect +#endif +#ifndef elf_backend_hide_symbol +#define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol +#endif + + +/* Previously, backends could only use SHT_REL or SHT_RELA relocation + sections, but not both. They defined USE_REL to indicate SHT_REL + sections, and left it undefined to indicated SHT_RELA sections. + For backwards compatibility, we still support this usage. */ +#ifndef USE_REL +#define USE_REL 0 +#else +#undef USE_REL +#define USE_REL 1 +#endif + +/* Use these in new code. */ +#ifndef elf_backend_may_use_rel_p +#define elf_backend_may_use_rel_p USE_REL +#endif +#ifndef elf_backend_may_use_rela_p +#define elf_backend_may_use_rela_p !USE_REL +#endif +#ifndef elf_backend_default_use_rela_p +#define elf_backend_default_use_rela_p !USE_REL +#endif #ifndef ELF_MACHINE_ALT1 #define ELF_MACHINE_ALT1 0 @@ -303,20 +348,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define elf_backend_size_info _bfd_elfNN_size_info #endif +#ifndef elf_backend_sign_extend_vma +#define elf_backend_sign_extend_vma 0 +#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, @@ -326,6 +368,7 @@ static CONST struct elf_backend_data elfNN_bed = elf_backend_get_symbol_type, elf_backend_section_processing, elf_backend_section_from_shdr, + elf_backend_section_from_phdr, elf_backend_fake_sections, elf_backend_section_from_bfd_section, elf_backend_add_symbol_hook, @@ -344,6 +387,11 @@ static CONST struct elf_backend_data elfNN_bed = elf_backend_modify_segment_map, elf_backend_gc_mark_hook, elf_backend_gc_sweep_hook, + elf_backend_post_process_headers, + elf_backend_print_symbol_all, + elf_backend_output_arch_syms, + elf_backend_copy_indirect_symbol, + elf_backend_hide_symbol, elf_backend_ecoff_debug_swap, ELF_MACHINE_ALT1, ELF_MACHINE_ALT2, @@ -351,14 +399,26 @@ static CONST struct elf_backend_data elfNN_bed = elf_backend_got_symbol_offset, elf_backend_got_header_size, elf_backend_plt_header_size, + elf_backend_collect, + elf_backend_type_change_ok, + elf_backend_may_use_rel_p, + elf_backend_may_use_rela_p, + elf_backend_default_use_rela_p, + elf_backend_sign_extend_vma, 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 + elf_backend_can_gc_sections, + elf_backend_want_dynbss }; +/* Forward declaration for use when initialising alternative_target field. */ +#ifdef TARGET_LITTLE_SYM +extern const bfd_target TARGET_LITTLE_SYM; +#endif + #ifdef TARGET_BIG_SYM const bfd_target TARGET_BIG_SYM = { @@ -442,8 +502,15 @@ const bfd_target TARGET_BIG_SYM = BFD_JUMP_TABLE_LINK (bfd_elfNN), BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN), + /* Alternative endian target. */ +#ifdef TARGET_LITTLE_SYM + & TARGET_LITTLE_SYM, +#else + NULL, +#endif + /* backend_data: */ - (PTR) &elfNN_bed, + (PTR) &elfNN_bed }; #endif @@ -530,7 +597,14 @@ const bfd_target TARGET_LITTLE_SYM = BFD_JUMP_TABLE_LINK (bfd_elfNN), BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN), + /* Alternative endian target. */ +#ifdef TARGET_BIG_SYM + & TARGET_BIG_SYM, +#else + NULL, +#endif + /* backend_data: */ - (PTR) &elfNN_bed, + (PTR) &elfNN_bed }; #endif diff --git a/bfd/epoc-pe-arm.c b/bfd/epoc-pe-arm.c index ea89a0b..48a277a 100644 --- a/bfd/epoc-pe-arm.c +++ b/bfd/epoc-pe-arm.c @@ -25,6 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_BIG_SYM arm_epoc_pe_big_vec #define TARGET_BIG_NAME "epoc-pe-arm-big" +#define bfd_arm_allocate_interworking_sections \ + bfd_arm_epoc_pe_allocate_interworking_sections +#define bfd_arm_get_bfd_for_interworking \ + bfd_arm_epoc_pe_get_bfd_for_interworking +#define bfd_arm_process_before_allocation \ + bfd_arm_epoc_pe_process_before_allocation #include "pe-arm.c" diff --git a/bfd/freebsd.h b/bfd/freebsd.h index 8bb19ac..e80c213 100644 --- a/bfd/freebsd.h +++ b/bfd/freebsd.h @@ -1,5 +1,5 @@ /* BFD back-end definitions used by all FreeBSD targets. - Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1996, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -76,11 +76,7 @@ MY(write_object_contents) (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)) { diff --git a/bfd/hash.c b/bfd/hash.c index 4c6e987..173eaf7 100644 --- a/bfd/hash.c +++ b/bfd/hash.c @@ -1,5 +1,5 @@ /* hash.c -- hash table routines for BFD - Copyright (C) 1993, 94, 95, 1997 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 97, 1999 Free Software Foundation, Inc. Written by Steve Chamberlain This file is part of BFD, the Binary File Descriptor library. @@ -73,7 +73,7 @@ SUBSECTION The function <> take as an argument a function to use to create new entries. For a basic hash table, use the function <>. @xref{Deriving - a New Hash Table Type} for why you would want to use a + a New Hash Table Type}, for why you would want to use a different value for this argument. @findex bfd_hash_allocate @@ -450,7 +450,7 @@ struct bfd_hash_entry * bfd_hash_newfunc (entry, table, string) struct bfd_hash_entry *entry; struct bfd_hash_table *table; - const char *string; + const char *string ATTRIBUTE_UNUSED; { if (entry == (struct bfd_hash_entry *) NULL) entry = ((struct bfd_hash_entry *) diff --git a/bfd/hosts/alphalinux.h b/bfd/hosts/alphalinux.h index d9ba1b7..09b8d69 100644 --- a/bfd/hosts/alphalinux.h +++ b/bfd/hosts/alphalinux.h @@ -1,6 +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 + structure is currently 1080 bytes long, but we allow up to 4096 bytes to allow for some future growth. */ -#define TRAD_CORE_EXTRA_SIZE_ALLOWED 1024 +#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/hp300hpux.c b/bfd/hp300hpux.c index 9552318..46bfea0 100644 --- a/bfd/hp300hpux.c +++ b/bfd/hp300hpux.c @@ -1,5 +1,5 @@ /* BFD backend for hp-ux 9000/300 - Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 94, 95, 97, 99, 2000 Free Software Foundation, Inc. Written by Glenn Engel. This file is part of BFD, the Binary File Descriptor library. @@ -270,11 +270,8 @@ MY (write_object_contents) (abfd) 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); @@ -336,9 +333,9 @@ MY (write_object_contents) (abfd) static void convert_sym_type (sym_pointer, cache_ptr, abfd) - struct external_nlist *sym_pointer; + struct external_nlist *sym_pointer ATTRIBUTE_UNUSED; aout_symbol_type *cache_ptr; - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { int name_type; int new_type; @@ -626,7 +623,7 @@ MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) struct hp300hpux_reloc *bytes; arelent *cache_ptr; asymbol **symbols; - bfd_size_type symcount; + bfd_size_type symcount ATTRIBUTE_UNUSED; { int r_index; int r_extern = 0; diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c index a7c22f5..0a3e6b2 100644 --- a/bfd/hppabsd-core.c +++ b/bfd/hppabsd-core.c @@ -298,6 +298,8 @@ const bfd_target hppabsd_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; #endif diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c index 6be709f..bfaa2c2 100644 --- a/bfd/hpux-core.c +++ b/bfd/hpux-core.c @@ -400,5 +400,7 @@ const bfd_target hpux_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/i386linux.c b/bfd/i386linux.c index 804bdcd..5df2a11 100644 --- a/bfd/i386linux.c +++ b/bfd/i386linux.c @@ -1,5 +1,6 @@ /* BFD back-end for linux flavored i386 a.out binaries. - Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -297,7 +298,7 @@ new_fixup (info, h, value, builtin) static boolean linux_link_create_dynamic_sections (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { flagword flags; register asection *s; diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c index 1f0344e..a999dd0 100644 --- a/bfd/i386lynx.c +++ b/bfd/i386lynx.c @@ -1,5 +1,6 @@ /* BFD back-end for i386 a.out binaries under LynxOS. - Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1999 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -324,7 +325,7 @@ NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) struct reloc_ext_external *bytes; arelent *cache_ptr; asymbol **symbols; - bfd_size_type symcount; + bfd_size_type symcount ATTRIBUTE_UNUSED; { int r_index; int r_extern; @@ -348,7 +349,7 @@ NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) struct reloc_std_external *bytes; arelent *cache_ptr; asymbol **symbols; - bfd_size_type symcount; + bfd_size_type symcount ATTRIBUTE_UNUSED; { int r_index; int r_extern; diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c index c6f24b2..c9ec864 100644 --- a/bfd/i386msdos.c +++ b/bfd/i386msdos.c @@ -1,5 +1,6 @@ /* BFD back-end for MS-DOS executables. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. Written by Bryan Ford of the University of Utah. Contributed by the Center for Software Science at the @@ -58,8 +59,8 @@ struct exe_header static int msdos_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -238,6 +239,8 @@ const bfd_target i386msdos_vec = BFD_JUMP_TABLE_LINK (msdos), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c index 2a01f5b..0aadee5 100644 --- a/bfd/i386os9k.c +++ b/bfd/i386os9k.c @@ -1,5 +1,5 @@ /* BFD back-end for os9000 i386 binaries. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -305,8 +305,8 @@ os9k_set_section_contents (abfd, section, location, offset, count) static int os9k_sizeof_headers (ignore_abfd, ignore) - bfd *ignore_abfd; - boolean ignore; + bfd *ignore_abfd ATTRIBUTE_UNUSED; + boolean ignore ATTRIBUTE_UNUSED; { return sizeof (struct internal_exec); } @@ -367,5 +367,7 @@ const bfd_target i386os9k_vec = BFD_JUMP_TABLE_LINK (os9k), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0, }; diff --git a/bfd/ieee.c b/bfd/ieee.c index 126b136..82b3bac 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -1,5 +1,5 @@ /* BFD back-end for ieee-695 objects. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. @@ -685,7 +685,7 @@ get_symbol (abfd, max_index, this_type ) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; ieee_data_type *ieee; ieee_symbol_type *last_symbol; unsigned int *symbol_count; @@ -1010,7 +1010,7 @@ ieee_get_symtab (abfd, location) 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}; + {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr, { 0 }}; if (abfd->symcount) { @@ -1280,6 +1280,7 @@ ieee_slurp_debug (abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); asection *sec; + file_ptr debug_end; if (ieee->w.r.debug_information_part == 0) return true; @@ -1289,7 +1290,13 @@ ieee_slurp_debug (abfd) 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; + + debug_end = ieee->w.r.data_part; + if (debug_end == 0) + debug_end = ieee->w.r.trailer_part; + if (debug_end == 0) + debug_end = ieee->w.r.me_record; + sec->_raw_size = debug_end - ieee->w.r.debug_information_part; return true; } @@ -1329,7 +1336,7 @@ ieee_archive_p (abfd) if (this_byte (&(ieee->h)) != Module_Beginning) { abfd->tdata.ieee_ar_data = save; - goto error_return; + goto got_wrong_format_error; } next_byte (&(ieee->h)); @@ -1338,7 +1345,7 @@ ieee_archive_p (abfd) { bfd_release (abfd, ieee); abfd->tdata.ieee_ar_data = save; - goto error_return; + goto got_wrong_format_error; } /* Throw away the filename */ read_id (&(ieee->h)); @@ -1441,6 +1448,8 @@ ieee_archive_p (abfd) return abfd->xvec; + got_wrong_format_error: + bfd_set_error (bfd_error_wrong_format); error_return: if (elts != NULL) free (elts); @@ -1652,7 +1661,7 @@ fail: void ieee_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -1665,7 +1674,7 @@ ieee_get_symbol_info (ignore_abfd, symbol, ret) void ieee_print_symbol (ignore_abfd, afile, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; @@ -3163,7 +3172,7 @@ block () static void relocate_debug (output, input) - bfd *output; + bfd *output ATTRIBUTE_UNUSED; bfd *input; { #define IBS 400 @@ -3762,13 +3771,13 @@ ieee_find_nearest_line (abfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; + bfd_vma offset ATTRIBUTE_UNUSED; + const char **filename_ptr ATTRIBUTE_UNUSED; + const char **functionname_ptr ATTRIBUTE_UNUSED; + unsigned int *line_ptr ATTRIBUTE_UNUSED; { return false; } @@ -3807,8 +3816,8 @@ ieee_generic_stat_arch_elt (abfd, buf) static int ieee_sizeof_headers (abfd, x) - bfd *abfd; - boolean x; + bfd *abfd ATTRIBUTE_UNUSED; + boolean x ATTRIBUTE_UNUSED; { return 0; } @@ -3966,5 +3975,7 @@ const bfd_target ieee_vec = BFD_JUMP_TABLE_LINK (ieee), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/ihex.c b/bfd/ihex.c index b9953d3..d00c59b 100644 --- a/bfd/ihex.c +++ b/bfd/ihex.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel Hex objects. - Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor of Cygnus Support . This file is part of BFD, the Binary File Descriptor library. @@ -146,7 +146,7 @@ static int ihex_sizeof_headers PARAMS ((bfd *, boolean)); /* The number of bytes we put on one line during output. */ -#define CHUNK (21) +#define CHUNK 16 /* Macros for converting between hex and binary. */ @@ -947,8 +947,8 @@ ihex_set_arch_mach (abfd, arch, mach) /*ARGSUSED*/ static int ihex_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -1037,5 +1037,7 @@ const bfd_target ihex_vec = BFD_JUMP_TABLE_LINK (ihex), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/irix-core.c b/bfd/irix-core.c index 964ca20..006e6a7 100644 --- a/bfd/irix-core.c +++ b/bfd/irix-core.c @@ -270,6 +270,8 @@ const bfd_target irix_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index cb4a4df..79a176d 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -1,6 +1,7 @@ /* 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. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. ** NOTE: libbfd.h is a GENERATED file. Don't change it; instead, @@ -364,7 +365,7 @@ extern boolean _bfd_dwarf1_find_nearest_line /* 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 *)); + const char **, unsigned int *, unsigned int)); /* A routine to create entries for a bfd_link_hash_table. */ extern struct bfd_hash_entry *_bfd_link_hash_newfunc @@ -478,6 +479,9 @@ extern bfd_size_type _bfd_stringtab_add /* Write out a string table. */ extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *)); + +/* Check that endianness of input and output file match. */ +extern boolean _bfd_generic_verify_endian_match PARAMS ((bfd *, bfd *)); /* Macros to tell if bfds are read or write enabled. @@ -499,6 +503,17 @@ void bfd_assert PARAMS ((const char*,int)); #define BFD_FAIL() \ { bfd_assert(__FILE__,__LINE__); } +extern void _bfd_abort PARAMS ((const char *, int, const char *)) + ATTRIBUTE_NORETURN; + +/* if gcc, we can give a function name, too */ +#if !defined (__GNUC__) || __GNUC_MINOR__ <= 5 +#define __PRETTY_FUNCTION__ ((char *) NULL) +#endif + +#undef abort +#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) + FILE * bfd_cache_lookup_worker PARAMS ((bfd *)); extern bfd *bfd_last_cache; diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 8abd1f5..881af73 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1,5 +1,5 @@ /* Assorted BFD support routines, only used internally. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -45,7 +45,7 @@ DESCRIPTION /*ARGSUSED*/ boolean bfd_false (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return false; @@ -57,7 +57,7 @@ bfd_false (ignore) /*ARGSUSED*/ boolean bfd_true (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { return true; } @@ -68,7 +68,7 @@ bfd_true (ignore) /*ARGSUSED*/ PTR bfd_nullvoidptr (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return NULL; @@ -77,7 +77,7 @@ bfd_nullvoidptr (ignore) /*ARGSUSED*/ int bfd_0 (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { return 0; } @@ -85,7 +85,7 @@ bfd_0 (ignore) /*ARGSUSED*/ unsigned int bfd_0u (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { return 0; } @@ -93,7 +93,7 @@ bfd_0u (ignore) /*ARGUSED*/ long bfd_0l (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { return 0; } @@ -104,7 +104,7 @@ bfd_0l (ignore) /*ARGSUSED*/ long _bfd_n1 (ignore_abfd) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return -1; @@ -113,15 +113,15 @@ _bfd_n1 (ignore_abfd) /*ARGSUSED*/ void bfd_void (ignore) - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { } /*ARGSUSED*/ boolean _bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd) - bfd *ignore_core_bfd; - bfd *ignore_exec_bfd; + bfd *ignore_core_bfd ATTRIBUTE_UNUSED; + bfd *ignore_exec_bfd ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return false; @@ -133,7 +133,7 @@ _bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd) /*ARGSUSED*/ char * _bfd_nocore_core_file_failing_command (ignore_abfd) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return (char *)NULL; @@ -145,7 +145,7 @@ _bfd_nocore_core_file_failing_command (ignore_abfd) /*ARGSUSED*/ int _bfd_nocore_core_file_failing_signal (ignore_abfd) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_invalid_operation); return 0; @@ -154,7 +154,7 @@ _bfd_nocore_core_file_failing_signal (ignore_abfd) /*ARGSUSED*/ const bfd_target * _bfd_dummy_target (ignore_abfd) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; { bfd_set_error (bfd_error_wrong_format); return 0; @@ -274,7 +274,10 @@ bfd_read (ptr, size, nitems, abfd) get = size * nitems; if (abfd->where + get > bim->size) { - get = bim->size - abfd->where; + if (bim->size < (bfd_size_type) abfd->where) + get = 0; + else + get = bim->size - abfd->where; bfd_set_error (bfd_error_file_truncated); } memcpy (ptr, bim->buffer + abfd->where, get); @@ -293,7 +296,7 @@ bfd_read (ptr, size, nitems, abfd) 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 (nread != (int) (size * nitems)) { if (ferror (bfd_cache_lookup (abfd))) bfd_set_error (bfd_error_system_call); @@ -677,10 +680,22 @@ bfd_seek (abfd, position, direction) if ((abfd->flags & BFD_IN_MEMORY) != 0) { + struct bfd_in_memory *bim; + + bim = (struct bfd_in_memory *) abfd->iostream; + if (direction == SEEK_SET) abfd->where = position; else abfd->where += position; + + if ((bfd_size_type) abfd->where > bim->size) + { + abfd->where = bim->size; + bfd_set_error (bfd_error_file_truncated); + return -1; + } + return 0; } @@ -792,7 +807,7 @@ DESCRIPTION .{* Byte swapping macros for user section data. *} . .#define bfd_put_8(abfd, val, ptr) \ -. (*((unsigned char *)(ptr)) = (unsigned char)(val)) +. ((void) (*((unsigned char *)(ptr)) = (unsigned char)(val))) .#define bfd_put_signed_8 \ . bfd_put_8 .#define bfd_get_8(abfd, ptr) \ @@ -827,6 +842,20 @@ DESCRIPTION .#define bfd_get_signed_64(abfd, ptr) \ . BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) . +.#define bfd_get(bits, abfd, ptr) \ +. ((bits) == 8 ? bfd_get_8 (abfd, ptr) \ +. : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ +. : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ +. : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ +. : (abort (), (bfd_vma) - 1)) +. +.#define bfd_put(bits, abfd, val, ptr) \ +. ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ +. : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ +. : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ +. : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ +. : (abort (), (void) 0)) +. */ /* @@ -989,7 +1018,7 @@ bfd_getl_signed_32 (addr) bfd_vma bfd_getb64 (addr) - register const bfd_byte *addr; + register const bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 bfd_vma low, high; @@ -1013,7 +1042,7 @@ bfd_getb64 (addr) bfd_vma bfd_getl64 (addr) - register const bfd_byte *addr; + register const bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 bfd_vma low, high; @@ -1037,7 +1066,7 @@ bfd_getl64 (addr) bfd_signed_vma bfd_getb_signed_64 (addr) - register const bfd_byte *addr; + register const bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 bfd_vma low, high; @@ -1061,7 +1090,7 @@ bfd_getb_signed_64 (addr) bfd_signed_vma bfd_getl_signed_64 (addr) - register const bfd_byte *addr; + register const bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 bfd_vma low, high; @@ -1106,8 +1135,8 @@ bfd_putl32 (data, addr) void bfd_putb64 (data, addr) - bfd_vma data; - register bfd_byte *addr; + bfd_vma data ATTRIBUTE_UNUSED; + register bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 addr[0] = (bfd_byte)(data >> (7*8)); @@ -1125,8 +1154,8 @@ bfd_putb64 (data, addr) void bfd_putl64 (data, addr) - bfd_vma data; - register bfd_byte *addr; + bfd_vma data ATTRIBUTE_UNUSED; + register bfd_byte *addr ATTRIBUTE_UNUSED; { #ifdef BFD64 addr[7] = (bfd_byte)(data >> (7*8)); @@ -1152,22 +1181,29 @@ _bfd_generic_get_section_contents (abfd, section, location, offset, count) 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); + if (count == 0) + return true; + + if ((bfd_size_type) (offset + count) > section->_raw_size) + { + bfd_set_error (bfd_error_invalid_operation); + return false; + } + + if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0 + || bfd_read (location, (bfd_size_type) 1, count, abfd) != count) + return false; + + 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; + bfd *abfd ATTRIBUTE_UNUSED; + sec_ptr section ATTRIBUTE_UNUSED; + bfd_window *w ATTRIBUTE_UNUSED; + file_ptr offset ATTRIBUTE_UNUSED; + bfd_size_type count ATTRIBUTE_UNUSED; { #ifdef USE_MMAP if (count == 0) @@ -1246,7 +1282,7 @@ bfd_log2 (x) { unsigned int result = 0; - while ((((bfd_vma) 1) << result) < x) + while ((x = (x >> 1)) != 0) ++result; return result; } @@ -1261,3 +1297,26 @@ bfd_generic_is_local_label_name (abfd, name) return (name[0] == locals_prefix); } +/* Can be used from / for bfd_merge_private_bfd_data to check that + endianness matches between input and output file. Returns + true for a match, otherwise returns false and emits an error. */ +boolean +_bfd_generic_verify_endian_match (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; +} diff --git a/bfd/libbfd.h b/bfd/libbfd.h index f804bde..f9baf5a 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1,6 +1,7 @@ /* 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. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. Written by Cygnus Support. ** NOTE: libbfd.h is a GENERATED file. Don't change it; instead, @@ -364,7 +365,7 @@ extern boolean _bfd_dwarf1_find_nearest_line /* 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 *)); + const char **, unsigned int *, unsigned int)); /* A routine to create entries for a bfd_link_hash_table. */ extern struct bfd_hash_entry *_bfd_link_hash_newfunc @@ -478,6 +479,9 @@ extern bfd_size_type _bfd_stringtab_add /* Write out a string table. */ extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *)); + +/* Check that endianness of input and output file match. */ +extern boolean _bfd_generic_verify_endian_match PARAMS ((bfd *, bfd *)); /* Macros to tell if bfds are read or write enabled. @@ -499,6 +503,17 @@ void bfd_assert PARAMS ((const char*,int)); #define BFD_FAIL() \ { bfd_assert(__FILE__,__LINE__); } +extern void _bfd_abort PARAMS ((const char *, int, const char *)) + ATTRIBUTE_NORETURN; + +/* if gcc, we can give a function name, too */ +#if !defined (__GNUC__) || __GNUC_MINOR__ <= 5 +#define __PRETTY_FUNCTION__ ((char *) NULL) +#endif + +#undef abort +#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) + FILE * bfd_cache_lookup_worker PARAMS ((bfd *)); extern bfd *bfd_last_cache; @@ -661,6 +676,13 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_ALPHA_LITERAL", "BFD_RELOC_ALPHA_ELF_LITERAL", "BFD_RELOC_ALPHA_LITUSE", + "BFD_RELOC_ALPHA_USER_LITERAL", + "BFD_RELOC_ALPHA_USER_LITUSE_BASE", + "BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF", + "BFD_RELOC_ALPHA_USER_LITUSE_JSR", + "BFD_RELOC_ALPHA_USER_GPDISP", + "BFD_RELOC_ALPHA_USER_GPRELHIGH", + "BFD_RELOC_ALPHA_USER_GPRELLOW", "BFD_RELOC_ALPHA_HINT", "BFD_RELOC_ALPHA_LINKAGE", "BFD_RELOC_ALPHA_CODEADDR", @@ -679,6 +701,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MIPS_GOT_LO16", "BFD_RELOC_MIPS_CALL_HI16", "BFD_RELOC_MIPS_CALL_LO16", + "BFD_RELOC_MIPS_SUB", + "BFD_RELOC_MIPS_GOT_PAGE", + "BFD_RELOC_MIPS_GOT_OFST", + "BFD_RELOC_MIPS_GOT_DISP", "BFD_RELOC_386_GOT32", "BFD_RELOC_386_PLT32", @@ -700,6 +726,12 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_NS32K_DISP_8_PCREL", "BFD_RELOC_NS32K_DISP_16_PCREL", "BFD_RELOC_NS32K_DISP_32_PCREL", + "BFD_RELOC_PJ_CODE_HI16", + "BFD_RELOC_PJ_CODE_LO16", + "BFD_RELOC_PJ_CODE_DIR16", + "BFD_RELOC_PJ_CODE_DIR32", + "BFD_RELOC_PJ_CODE_REL16", + "BFD_RELOC_PJ_CODE_REL32", "BFD_RELOC_PPC_B26", "BFD_RELOC_PPC_BA26", "BFD_RELOC_PPC_TOC16", @@ -730,9 +762,11 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_PPC_EMB_RELST_HA", "BFD_RELOC_PPC_EMB_BIT_FLD", "BFD_RELOC_PPC_EMB_RELSDA", + "BFD_RELOC_I370_D12", "BFD_RELOC_CTOR", "BFD_RELOC_ARM_PCREL_BRANCH", "BFD_RELOC_ARM_IMMEDIATE", + "BFD_RELOC_ARM_ADRL_IMMEDIATE", "BFD_RELOC_ARM_OFFSET_IMM", "BFD_RELOC_ARM_SHIFT_IMM", "BFD_RELOC_ARM_SWI", @@ -836,6 +870,23 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MCORE_PCREL_IMM4BY2", "BFD_RELOC_MCORE_PCREL_32", "BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2", + "BFD_RELOC_MCORE_RVA", + "BFD_RELOC_AVR_7_PCREL", + "BFD_RELOC_AVR_13_PCREL", + "BFD_RELOC_AVR_16_PM", + "BFD_RELOC_AVR_LO8_LDI", + "BFD_RELOC_AVR_HI8_LDI", + "BFD_RELOC_AVR_HH8_LDI", + "BFD_RELOC_AVR_LO8_LDI_NEG", + "BFD_RELOC_AVR_HI8_LDI_NEG", + "BFD_RELOC_AVR_HH8_LDI_NEG", + "BFD_RELOC_AVR_LO8_LDI_PM", + "BFD_RELOC_AVR_HI8_LDI_PM", + "BFD_RELOC_AVR_HH8_LDI_PM", + "BFD_RELOC_AVR_LO8_LDI_PM_NEG", + "BFD_RELOC_AVR_HI8_LDI_PM_NEG", + "BFD_RELOC_AVR_HH8_LDI_PM_NEG", + "BFD_RELOC_AVR_CALL", "BFD_RELOC_VTABLE_INHERIT", "BFD_RELOC_VTABLE_ENTRY", "@@overflow: BFD_RELOC_UNUSED@@", diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 0dc2121..9b1a026 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -1,5 +1,5 @@ /* BFD COFF object file private structure. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -56,7 +56,7 @@ typedef struct coff_tdata file_ptr sym_filepos; struct coff_ptr_struct *raw_syments; - unsigned int raw_syment_count; + unsigned long raw_syment_count; /* These are only valid once writing has begun */ long int relocbase; @@ -97,6 +97,9 @@ typedef struct coff_tdata /* Used by coff_find_nearest_line. */ PTR line_info; + /* The timestamp from the COFF file header. */ + long timestamp; + /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ flagword flags; @@ -213,12 +216,14 @@ struct xcoff_section_tdata #define xcoff_section_data(abfd, sec) \ ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) -/* Tdata for sections in PEI image files. */ +/* Tdata for sections in PE files. */ struct pei_section_tdata { /* The virtual size of the section. */ bfd_size_type virt_size; + /* The PE section flags. */ + long pe_flags; }; /* An accessor macro for the pei_section_tdata structure. */ @@ -249,6 +254,11 @@ struct coff_link_hash_entry /* Pointer to array of auxiliary entries, if any. */ union internal_auxent *aux; + + /* Flag word; legal values follow. */ + unsigned short coff_link_hash_flags; + /* Symbol is a PE section symbol. */ +#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) }; /* COFF linker hash table. */ @@ -462,6 +472,41 @@ struct coff_final_link_info struct internal_reloc *internal_relocs; }; +/* Most COFF variants have no way to record the alignment of a + section. This struct is used to set a specific alignment based on + the name of the section. */ + +struct coff_section_alignment_entry +{ + /* The section name. */ + const char *name; + + /* This is either (unsigned int) -1, indicating that the section + name must match exactly, or it is the number of letters which + must match at the start of the name. */ + unsigned int comparison_length; + + /* These macros may be used to fill in the first two fields in a + structure initialization. */ +#define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) +#define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) + + /* Only use this entry if the default section alignment for this + target is at least that much (as a power of two). If this field + is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ + unsigned int default_alignment_min; + + /* Only use this entry if the default section alignment for this + target is no greater than this (as a power of two). If this + field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ + unsigned int default_alignment_max; + +#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) + + /* The desired alignment for this section (as a power of two). */ + unsigned int alignment_power; +}; + 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 diff --git a/bfd/libcoff.h b/bfd/libcoff.h index c418a4d..bee4ce9 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -1,5 +1,5 @@ /* BFD COFF object file private structure. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -56,7 +56,7 @@ typedef struct coff_tdata file_ptr sym_filepos; struct coff_ptr_struct *raw_syments; - unsigned int raw_syment_count; + unsigned long raw_syment_count; /* These are only valid once writing has begun */ long int relocbase; @@ -97,6 +97,9 @@ typedef struct coff_tdata /* Used by coff_find_nearest_line. */ PTR line_info; + /* The timestamp from the COFF file header. */ + long timestamp; + /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ flagword flags; @@ -213,12 +216,14 @@ struct xcoff_section_tdata #define xcoff_section_data(abfd, sec) \ ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) -/* Tdata for sections in PEI image files. */ +/* Tdata for sections in PE files. */ struct pei_section_tdata { /* The virtual size of the section. */ bfd_size_type virt_size; + /* The PE section flags. */ + long pe_flags; }; /* An accessor macro for the pei_section_tdata structure. */ @@ -249,6 +254,11 @@ struct coff_link_hash_entry /* Pointer to array of auxiliary entries, if any. */ union internal_auxent *aux; + + /* Flag word; legal values follow. */ + unsigned short coff_link_hash_flags; + /* Symbol is a PE section symbol. */ +#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01) }; /* COFF linker hash table. */ @@ -462,6 +472,41 @@ struct coff_final_link_info struct internal_reloc *internal_relocs; }; +/* Most COFF variants have no way to record the alignment of a + section. This struct is used to set a specific alignment based on + the name of the section. */ + +struct coff_section_alignment_entry +{ + /* The section name. */ + const char *name; + + /* This is either (unsigned int) -1, indicating that the section + name must match exactly, or it is the number of letters which + must match at the start of the name. */ + unsigned int comparison_length; + + /* These macros may be used to fill in the first two fields in a + structure initialization. */ +#define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1) +#define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1) + + /* Only use this entry if the default section alignment for this + target is at least that much (as a power of two). If this field + is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ + unsigned int default_alignment_min; + + /* Only use this entry if the default section alignment for this + target is no greater than this (as a power of two). If this + field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */ + unsigned int default_alignment_max; + +#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1) + + /* The desired alignment for this section (as a power of two). */ + unsigned int alignment_power; +}; + 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 @@ -581,6 +626,22 @@ struct lineno_cache_entry *lineno; /* Have the line numbers been relocated yet ? */ boolean done_lineno; } coff_symbol_type; + /* COFF symbol classifications. */ + +enum coff_symbol_classification +{ + /* Global symbol. */ + COFF_SYMBOL_GLOBAL, + /* Common symbol. */ + COFF_SYMBOL_COMMON, + /* Undefined symbol. */ + COFF_SYMBOL_UNDEFINED, + /* Local symbol. */ + COFF_SYMBOL_LOCAL, + /* PE section symbol. */ + COFF_SYMBOL_PE_SECTION +}; + typedef struct { void (*_bfd_coff_swap_aux_in) PARAMS (( @@ -648,6 +709,7 @@ typedef struct unsigned int _bfd_auxesz; unsigned int _bfd_relsz; unsigned int _bfd_linesz; + unsigned int _bfd_filnmlen; boolean _bfd_coff_long_filenames; boolean _bfd_coff_long_section_names; unsigned int _bfd_coff_default_section_alignment_power; @@ -680,7 +742,8 @@ typedef struct flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( bfd *abfd, PTR internal_scnhdr, - const char *name)); + const char *name, + asection *section)); void (*_bfd_set_alignment_hook) PARAMS (( bfd *abfd, asection *sec, @@ -717,7 +780,7 @@ typedef struct arelent *r, unsigned int shrink, struct bfd_link_info *link_info)); - boolean (*_bfd_coff_sym_is_global) PARAMS (( + enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS (( bfd *abfd, struct internal_syment *)); boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( @@ -808,6 +871,7 @@ typedef struct #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_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen) #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) @@ -833,8 +897,9 @@ typedef struct #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_styp_to_sec_flags_hook(abfd, scnhdr, name, section)\ + ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\ + (abfd, scnhdr, name, section)) #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) @@ -857,8 +922,8 @@ typedef struct ((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)\ +#define bfd_coff_classify_symbol(abfd, sym)\ + ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\ (abfd, sym)) #define bfd_coff_compute_section_file_positions(abfd)\ diff --git a/bfd/libecoff.h b/bfd/libecoff.h index ad269a5..4561805 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -1,5 +1,5 @@ /* BFD ECOFF object file private structure. - Copyright (C) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -341,7 +341,7 @@ extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr)); ((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)); + PARAMS ((bfd *abfd, PTR hdr, const char *name, asection *section)); extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd)); /* ECOFF auxiliary information swapping routines. These are the same diff --git a/bfd/libhppa.h b/bfd/libhppa.h index 35b40ef..c32eabe 100644 --- a/bfd/libhppa.h +++ b/bfd/libhppa.h @@ -1,5 +1,6 @@ /* HP PA-RISC SOM object file format: definitions internal to BFD. - Copyright (C) 1990, 91, 92, 93, 94 , 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 98, 1999 + Free Software Foundation, Inc. Contributed by the Center for Software Science at the University of Utah (pa-gdb-bugs@cs.utah.edu). @@ -51,6 +52,10 @@ static INLINE unsigned long assemble_17 (unsigned int, unsigned int, static INLINE void dis_assemble_17 (unsigned int, unsigned int *, unsigned int *, unsigned int *) __attribute__ ((__unused__)); +static INLINE void dis_assemble_22 (unsigned int, 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 *) @@ -67,7 +72,7 @@ static INLINE void low_sign_unext (unsigned int, unsigned int, unsigned int *) static INLINE unsigned long hppa_field_adjust (unsigned long, unsigned long, unsigned short) __attribute__ ((__unused__)); -static INLINE char bfd_hppa_insn2fmt (unsigned long) +static INLINE int bfd_hppa_insn2fmt (unsigned long) __attribute__ ((__unused__)); static INLINE unsigned long hppa_rebuild_insn (bfd *, unsigned long, unsigned long, unsigned long) @@ -99,7 +104,9 @@ enum hppa_reloc_field_selector_type R_HPPA_RPSEL = 0xe, R_HPPA_TSEL = 0xf, R_HPPA_LTSEL = 0x10, - R_HPPA_RTSEL = 0x11 + R_HPPA_RTSEL = 0x11, + R_HPPA_LTPSEL = 0x12, + R_HPPA_RTPSEL = 0x13 }; /* /usr/include/reloc.h defines these to constants. We want to use @@ -152,7 +159,9 @@ enum hppa_reloc_field_selector_type_alt e_rpsel = R_HPPA_RPSEL, e_tsel = R_HPPA_TSEL, e_ltsel = R_HPPA_LTSEL, - e_rtsel = R_HPPA_RTSEL + e_rtsel = R_HPPA_RTSEL, + e_ltpsel = R_HPPA_LTPSEL, + e_rtpsel = R_HPPA_RTPSEL }; enum hppa_reloc_expr_type @@ -192,7 +201,7 @@ enum hppa_reloc_expr_type_alt #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 */ +#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 @@ -202,17 +211,17 @@ enum hppa_reloc_expr_type_alt #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 GET_BIT(X, WHICH) \ + GET_FIELD (X, WHICH, WHICH) -#define MASK( SIZE ) \ +#define MASK(SIZE) \ (~((-1) << SIZE)) -#define CATENATE( X, XSIZE, Y, YSIZE ) \ - (((X & MASK( XSIZE )) << YSIZE) | (Y & MASK( YSIZE ))) +#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) +#define ELEVEN(X) \ + CATENATE (GET_BIT (X, 10), 1, GET_FIELD (X, 0, 9), 10) /* Some functions to manipulate PA instructions. */ @@ -233,7 +242,7 @@ static INLINE unsigned int assemble_3 (x) unsigned int x; { - return (((x & 1) << 2) | ((x & 6) >> 1)) & 7; + return CATENATE (GET_BIT (x, 2), 1, GET_FIELD (x, 0, 1), 2); } static INLINE void @@ -244,7 +253,7 @@ dis_assemble_3 (x, r) *r = (((x & 4) >> 2) | ((x & 3) << 1)) & 7; } -static INLINE unsigned int /* PA 2.0 */ +static INLINE unsigned int assemble_6 (x, y) unsigned int x, y; { @@ -255,9 +264,8 @@ 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); + return CATENATE (CATENATE (y, 1, GET_BIT (x, 10), 1), 2, + GET_FIELD (x, 0, 9), 9); } static INLINE void @@ -269,53 +277,40 @@ dis_assemble_12 (as12, x, y) *x = ((as12 & 0x3ff) << 1) | ((as12 & 0x400) >> 10); } -static INLINE unsigned long /* PA 2.0 */ +static INLINE unsigned long 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 ); + 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 */ +static INLINE unsigned long 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 ); + 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 @@ -323,12 +318,9 @@ 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); + temp = CATENATE (CATENATE (z, 1, x, 5), 6, + CATENATE (GET_BIT (y, 10), 1, GET_FIELD (y, 0, 9), 10), 11); return temp; } @@ -344,6 +336,18 @@ dis_assemble_17 (as17, x, y, z) *y = (((as17 & 0x00400) >> 10) | ((as17 & 0x3ff) << 1)) & 0x7ff; } +static INLINE void +dis_assemble_22 (as22, a, b, c, d) + unsigned int as22; + unsigned int *a, *b, *c, *d; +{ + + *d = (as22 & 0x200000) >> 21; + *a = (as22 & 0x1f0000) >> 16; + *b = (as22 & 0x0f800) >> 11; + *c = (((as22 & 0x00400) >> 10) | ((as22 & 0x3ff) << 1)) & 0x7ff; +} + static INLINE unsigned long assemble_21 (x) unsigned int x; @@ -358,18 +362,16 @@ assemble_21 (x) return temp & 0x1fffff; } -static INLINE unsigned long /* PA 2.0 */ +static INLINE unsigned long 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 ); + temp = CATENATE (CATENATE (d, 1, a, 5), 6, + CATENATE (b, 5, ELEVEN (c), 11), 16); - return sign_extend( temp, 22 ); + return sign_extend (temp, 22); } static INLINE void @@ -458,7 +460,7 @@ hppa_field_adjust (value, constant_value, r_field) { switch (r_field) { - case e_fsel: /* F : no change */ + case e_fsel: /* F : no change */ case e_nsel: /* N : no change */ value += constant_value; break; @@ -471,7 +473,7 @@ hppa_field_adjust (value, constant_value, r_field) value = (value & 0xfffff800) >> 11; break; - case e_rssel: /* RS : Sign extend from bit 21 */ + case e_rssel: /* RS : Sign extend from bit 21 */ value += constant_value; if (value & 0x00000400) value |= 0xfffff800; @@ -485,19 +487,19 @@ hppa_field_adjust (value, constant_value, r_field) value = (value & 0xfffff800) >> 11; break; - case e_rsel: /* R : Set bits 0-20 to zero */ + 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 */ + right 11 bits */ value += constant_value; value += 0x800; value = (value & 0xfffff800) >> 11; break; - case e_rdsel: /* RD : Set bits 0-20 to one */ + case e_rdsel: /* RD : Set bits 0-20 to one */ value += constant_value; value |= 0xfffff800; break; @@ -562,17 +564,26 @@ hppa_field_adjust (value, constant_value, r_field) #define BLE 0x39 #define BE 0x38 +#define CMPBDT 0x27 +#define CMPBDF 0x2f +#define CMPIBD 0x3b +#define LDD 0x14 +#define STD 0x1c +#define LDWL 0x17 +#define STWL 0x1f +#define FDLW 0x16 +#define FSTW 0x1e /* 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 +static INLINE int bfd_hppa_insn2fmt (insn) unsigned long insn; { - char fmt = -1; + int fmt = -1; unsigned char op = get_opcode (insn); switch (op) @@ -594,6 +605,9 @@ bfd_hppa_insn2fmt (insn) case ADDIBF: case BVB: case BB: + case CMPBDT: + case CMPBDF: + case CMPIBD: fmt = 12; break; case LDO: @@ -607,9 +621,24 @@ bfd_hppa_insn2fmt (insn) case STWM: fmt = 14; break; + case LDWL: + case STWL: + case FDLW: + case FSTW: + /* This is a hack. Unfortunately, format 11 is already taken + and we're using integers rather than an enum, so it's hard + to describe the 10a format. */ + fmt = -11; + break; + case LDD: + case STD: + fmt = 10; + break; case BL: case BE: case BLE: + if ((insn & 0x00008000) == 0x00008000) + return 22; fmt = 17; break; case LDIL: @@ -629,7 +658,7 @@ bfd_hppa_insn2fmt (insn) static INLINE unsigned long hppa_rebuild_insn (abfd, insn, value, r_format) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; unsigned long insn; unsigned long value; unsigned long r_format; diff --git a/bfd/libpei.h b/bfd/libpei.h new file mode 100644 index 0000000..88f9f73 --- /dev/null +++ b/bfd/libpei.h @@ -0,0 +1,254 @@ +/* Support for the generic parts of PE/PEI; common header information. + Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Written by Cygnus Solutions. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public 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 + +PE/PEI rearrangement (and code added): Donn Terry + Softway Systems, Inc. +*/ + +/* 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. +*/ + +#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 + +/* These functions are architecture dependent, and are in peicode.h: + coff_swap_reloc_in + int coff_swap_reloc_out + coff_swap_filehdr_in + coff_swap_scnhdr_in + pe_mkobject + pe_mkobject_hook */ + +/* The functions described below are common across all PE/PEI + implementations architecture types, and actually appear in + peigen.c. */ + +void _bfd_pei_swap_sym_in PARAMS ((bfd*, PTR, PTR)); +#define coff_swap_sym_in _bfd_pei_swap_sym_in + +unsigned int _bfd_pei_swap_sym_out PARAMS ((bfd*, PTR, PTR)); +#define coff_swap_sym_out _bfd_pei_swap_sym_out + +void _bfd_pei_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +#define coff_swap_aux_in _bfd_pei_swap_aux_in + +unsigned int _bfd_pei_swap_aux_out \ + PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +#define coff_swap_aux_out _bfd_pei_swap_aux_out + +void _bfd_pei_swap_lineno_in PARAMS ((bfd*, PTR, PTR)); +#define coff_swap_lineno_in _bfd_pei_swap_lineno_in + +unsigned int _bfd_pei_swap_lineno_out PARAMS ((bfd*, PTR, PTR)); +#define coff_swap_lineno_out _bfd_pei_swap_lineno_out + +void _bfd_pei_swap_aouthdr_in PARAMS ((bfd*, PTR, PTR)); +#define coff_swap_aouthdr_in _bfd_pei_swap_aouthdr_in + +unsigned int _bfd_pei_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR)); +#define coff_swap_aouthdr_out _bfd_pei_swap_aouthdr_out + +unsigned int _bfd_pei_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR)); +#define coff_swap_scnhdr_out _bfd_pei_swap_scnhdr_out + +boolean _bfd_pe_print_private_bfd_data_common PARAMS ((bfd *, PTR)); + +boolean _bfd_pe_bfd_copy_private_bfd_data_common PARAMS ((bfd *, bfd *)); + +void _bfd_pe_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); + +boolean _bfd_pei_final_link_postscript + PARAMS ((bfd *, struct coff_final_link_info *)); + +#ifndef coff_final_link_postscript +#define coff_final_link_postscript _bfd_pei_final_link_postscript +#endif +/* The following are needed only for ONE of pe or pei, but don't + otherwise vary; peicode.h fixes up ifdefs but we provide the + prototype. */ + +unsigned int _bfd_pe_only_swap_filehdr_out PARAMS ((bfd*, PTR, PTR)); +unsigned int _bfd_pei_only_swap_filehdr_out PARAMS ((bfd*, PTR, PTR)); +boolean _bfd_pe_bfd_copy_private_section_data + PARAMS ((bfd *, asection *, bfd *, asection *)); diff --git a/bfd/linker.c b/bfd/linker.c index 947514c..6e9ee65 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1,5 +1,6 @@ /* linker.c -- BFD linker routines - Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 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. @@ -74,7 +75,7 @@ SUBSECTION @cindex target vector (_bfd_link_hash_table_create) The linker routines must create a hash table, which must be derived from <> described in - <>. @xref{Hash Tables} for information on how to + <>. @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. @@ -1748,8 +1749,8 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, case MDEF: /* Handle a multiple definition. */ { - asection *msec; - bfd_vma mval; + asection *msec = NULL; + bfd_vma mval = 0; switch (h->type) { @@ -2523,7 +2524,9 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order) break; } ok = bfd_set_section_contents (abfd, sec, (PTR) buf, - (file_ptr) link_order->offset, size); + (file_ptr) + (link_order->offset * + bfd_octets_per_byte (abfd)), size); free (buf); if (! ok) return false; @@ -2591,7 +2594,9 @@ _bfd_default_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, + (file_ptr) + (link_order->offset * + bfd_octets_per_byte (abfd)), link_order->size); } } @@ -2602,7 +2607,7 @@ _bfd_default_link_order (abfd, info, sec, link_order) static boolean default_fill_link_order (abfd, info, sec, link_order) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; asection *sec; struct bfd_link_order *link_order; { @@ -2625,7 +2630,9 @@ default_fill_link_order (abfd, info, sec, link_order) for (i = 1; i < size; i += 2) space[i] = fill; result = bfd_set_section_contents (abfd, sec, space, - (file_ptr) link_order->offset, + (file_ptr) + (link_order->offset * + bfd_octets_per_byte (abfd)), link_order->size); free (space); return result; @@ -2742,7 +2749,10 @@ default_indirect_link_order (output_bfd, info, output_section, link_order, /* Output the section contents. */ if (! bfd_set_section_contents (output_bfd, output_section, (PTR) new_contents, - link_order->offset, link_order->size)) + (file_ptr) + (link_order->offset * + bfd_octets_per_byte (output_bfd)), + link_order->size)) goto error_return; if (contents != NULL) @@ -2797,8 +2807,8 @@ DESCRIPTION boolean _bfd_generic_link_split_section (abfd, sec) - bfd *abfd; - asection *sec; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; { return false; } diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c index c8f47a8..2251757 100644 --- a/bfd/m68klinux.c +++ b/bfd/m68klinux.c @@ -1,5 +1,6 @@ /* BFD back-end for linux flavored m68k a.out binaries. - Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -301,7 +302,7 @@ new_fixup (info, h, value, builtin) static boolean linux_link_create_dynamic_sections (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { flagword flags; register asection *s; diff --git a/bfd/makefile.dos b/bfd/makefile.dos deleted file mode 100644 index 8a22c6a..0000000 --- a/bfd/makefile.dos +++ /dev/null @@ -1,49 +0,0 @@ -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/mipsbsd.c b/bfd/mipsbsd.c index e7ba68d..7a680fb 100644 --- a/bfd/mipsbsd.c +++ b/bfd/mipsbsd.c @@ -1,5 +1,5 @@ /* BFD backend for MIPS BSD (a.out) binaries. - Copyright (C) 1993, 94, 95, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. Written by Ralph Campbell. This file is part of BFD, the Binary File Descriptor library. @@ -187,10 +187,10 @@ MY(write_object_contents) (abfd) */ static bfd_reloc_status_type mips_fix_jmp_addr (abfd,reloc_entry,symbol,data,input_section,output_bfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; struct symbol_cache_entry *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; { @@ -240,13 +240,13 @@ mips_fix_hi16_s PARAMS ((bfd *, arelent *, asymbol *, PTR, static bfd_reloc_status_type mips_fix_hi16_s (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; - asection *input_section; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; @@ -389,6 +389,8 @@ static CONST struct aout_backend_data MY(backend_data) = { 0 /* finish_dynamic_link */ }; +extern const bfd_target aout_mips_big_vec; + const bfd_target aout_mips_little_vec = { "a.out-mips-little", /* name */ @@ -425,7 +427,9 @@ const bfd_target aout_mips_little_vec = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - (PTR) MY_backend_data, + & aout_mips_big_vec, + + (PTR) MY_backend_data }; const bfd_target aout_mips_big_vec = @@ -464,5 +468,7 @@ const bfd_target aout_mips_big_vec = BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - (PTR) MY_backend_data, + & aout_mips_little_vec, + + (PTR) MY_backend_data }; diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c index 21b184d..828c2a1 100644 --- a/bfd/netbsd-core.c +++ b/bfd/netbsd-core.c @@ -247,5 +247,7 @@ const bfd_target netbsd_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/netbsd.h b/bfd/netbsd.h index a5482f0..760ed95 100644 --- a/bfd/netbsd.h +++ b/bfd/netbsd.h @@ -1,5 +1,5 @@ /* BFD back-end definitions used by all NetBSD targets. - Copyright (C) 1990, 91, 92, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -91,11 +91,7 @@ MY(write_object_contents) (abfd) 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)) { diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h index 6f1d47d..5c1e255 100644 --- a/bfd/nlm-target.h +++ b/bfd/nlm-target.h @@ -55,6 +55,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ There are two such structures here: one for big-endian machines and one for little-endian machines. */ +/* Forward declaration for use when initialising alternative_target field. */ +#ifdef TARGET_LITTLE_SYM +extern const bfd_target TARGET_LITTLE_SYM; +#endif #ifdef TARGET_BIG_SYM const bfd_target TARGET_BIG_SYM = @@ -137,6 +141,13 @@ const bfd_target TARGET_BIG_SYM = BFD_JUMP_TABLE_LINK (nlm), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + /* Alternative endian target. */ +#ifdef TARGET_LITTLE_SYM + & TARGET_LITTLE_SYM, +#else + NULL, +#endif + /* backend_data: */ (PTR) TARGET_BACKEND_DATA }; @@ -223,6 +234,13 @@ const bfd_target TARGET_LITTLE_SYM = BFD_JUMP_TABLE_LINK (nlm), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + /* Alternative endian target. */ +#ifdef TARGET_BIG_SYM + & TARGET_BIG_SYM, +#else + NULL, +#endif + /* backend_data: */ (PTR) TARGET_BACKEND_DATA }; diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c index ecf2de8..5af4834 100644 --- a/bfd/nlm32-ppc.c +++ b/bfd/nlm32-ppc.c @@ -1,5 +1,5 @@ /* Support for 32-bit PowerPC NLM (NetWare Loadable Module) - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -639,11 +639,11 @@ nlm_powerpc_read_reloc (abfd, sym, secp, rel) static boolean nlm_powerpc_mangle_relocs (abfd, sec, data, offset, count) - bfd *abfd; - asection *sec; - PTR data; - bfd_vma offset; - bfd_size_type count; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + bfd_vma offset ATTRIBUTE_UNUSED; + bfd_size_type count ATTRIBUTE_UNUSED; { return true; } diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c index 5963adb..ab4d80a 100644 --- a/bfd/nlm32-sparc.c +++ b/bfd/nlm32-sparc.c @@ -1,5 +1,5 @@ /* Support for 32-bit SPARC NLM (NetWare Loadable Module) - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -118,7 +118,7 @@ struct nlm32_sparc_reloc_ext { static boolean nlm_sparc_read_reloc (abfd, sym, secp, rel) bfd *abfd; - nlmNAME(symbol_type) *sym; + nlmNAME(symbol_type) *sym ATTRIBUTE_UNUSED; asection **secp; arelent *rel; { @@ -232,11 +232,11 @@ nlm_sparc_write_reloc (abfd, sec, rel) static boolean nlm_sparc_mangle_relocs (abfd, sec, data, offset, count) - bfd *abfd; - asection *sec; - PTR data; - bfd_vma offset; - bfd_size_type count; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + bfd_vma offset ATTRIBUTE_UNUSED; + bfd_size_type count ATTRIBUTE_UNUSED; { return true; } diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index 63ac0c3..ad1a2f8 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -1,5 +1,5 @@ /* NLM (NetWare Loadable Module) executable support for BFD. - Copyright (C) 1993, 94, 95, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 98, 1999 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support, using ELF support as the template. @@ -971,7 +971,7 @@ nlm_make_empty_symbol (abfd) void nlm_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -982,7 +982,7 @@ nlm_get_symbol_info (ignore_abfd, symbol, ret) void nlm_print_symbol (abfd, afile, symbol, how) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; diff --git a/bfd/oasys.c b/bfd/oasys.c index b51560e..e69053b 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -1,5 +1,5 @@ /* BFD back-end for oasys objects. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support, . @@ -515,7 +515,7 @@ fail: static void oasys_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -526,7 +526,7 @@ oasys_get_symbol_info (ignore_abfd, symbol, ret) static void oasys_print_symbol (ignore_abfd, afile, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; @@ -844,10 +844,10 @@ oasys_get_section_contents (abfd, section, location, offset, count) long oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; sec_ptr section; arelent **relptr; - asymbol **symbols; + asymbol **symbols ATTRIBUTE_UNUSED; { unsigned int reloc_count = 0; oasys_reloc_type *src = (oasys_reloc_type *) (section->relocation); @@ -1403,13 +1403,13 @@ oasys_find_nearest_line (abfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; + bfd_vma offset ATTRIBUTE_UNUSED; + char **filename_ptr ATTRIBUTE_UNUSED; + char **functionname_ptr ATTRIBUTE_UNUSED; + unsigned int *line_ptr ATTRIBUTE_UNUSED; { return false; @@ -1436,8 +1436,8 @@ oasys_generic_stat_arch_elt (abfd, buf) static int oasys_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -1531,5 +1531,7 @@ const bfd_target oasys_vec = BFD_JUMP_TABLE_LINK (oasys), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/osf-core.c b/bfd/osf-core.c index 671f4af..4f4fc12 100644 --- a/bfd/osf-core.c +++ b/bfd/osf-core.c @@ -250,5 +250,7 @@ const bfd_target osf_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/pc532-mach.c b/bfd/pc532-mach.c index 73f4ac4..3b77d5d 100644 --- a/bfd/pc532-mach.c +++ b/bfd/pc532-mach.c @@ -1,5 +1,5 @@ /* BFD back-end for Mach3/532 a.out-ish binaries. - Copyright (C) 1990, 1991, 1992, 1994 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1994, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -92,11 +92,7 @@ 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)) diff --git a/bfd/pe-arm.c b/bfd/pe-arm.c index d315888..6c6b659 100644 --- a/bfd/pe-arm.c +++ b/bfd/pe-arm.c @@ -31,4 +31,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define PCRELOFFSET true #define COFF_LONG_SECTION_NAMES +#ifndef bfd_arm_allocate_interworking_sections +#define bfd_arm_allocate_interworking_sections \ + bfd_arm_pe_allocate_interworking_sections +#define bfd_arm_get_bfd_for_interworking \ + bfd_arm_pe_get_bfd_for_interworking +#define bfd_arm_process_before_allocation \ + bfd_arm_pe_process_before_allocation +#endif + +#ifdef ARM_WINCE +#define TARGET_UNDERSCORE 0 +#endif + #include "coff-arm.c" diff --git a/bfd/pe-i386.c b/bfd/pe-i386.c index bcdbe44..a2eb784 100644 --- a/bfd/pe-i386.c +++ b/bfd/pe-i386.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 PECOFF files. - Copyright 1995 Free Software Foundation, Inc. + Copyright 1995, 1996, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -27,5 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define PCRELOFFSET true #define TARGET_UNDERSCORE '_' #define COFF_LONG_SECTION_NAMES +#define COFF_LONG_FILENAMES + +#define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 } #include "coff-i386.c" diff --git a/bfd/pe-mips.c b/bfd/pe-mips.c new file mode 100644 index 0000000..9b89369 --- /dev/null +++ b/bfd/pe-mips.c @@ -0,0 +1,998 @@ +/* BFD back-end for MIPS PE COFF files. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + Modified from coff-i386.c by DJ Delorie, dj@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 COFF_WITH_PE +#define COFF_LONG_SECTION_NAMES +#define PCRELOFFSET true + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +#include "coff/mipspe.h" + +#include "coff/internal.h" + +#include "coff/pe.h" + +#include "libcoff.h" + +static bfd_reloc_status_type coff_mips_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *coff_mips_rtype_to_howto + PARAMS ((bfd *, asection *, struct internal_reloc *, + struct coff_link_hash_entry *, struct internal_syment *, + + bfd_vma *)); +#if 0 +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 *)); +#endif +#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 mips 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_mips_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, + error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd; + char **error_message ATTRIBUTE_UNUSED; +{ + 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 +#if 0 + /* dj - handle it like any other reloc? */ + /* FIXME: How should this case be handled? */ + if (reloc_entry->howto->type == MIPS_R_RVA && diff != 0) + abort (); +#endif +#endif + +#define DOIT(x) \ + x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & 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 ATTRIBUTE_UNUSED; + reloc_howto_type *howto; +{ + return ! howto->pc_relative && howto->type != MIPS_R_RVA; +} +#endif + +#ifndef PCRELOFFSET +#define PCRELOFFSET false +#endif + +static reloc_howto_type 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_ABSOLUTE, /* 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 */ + coff_mips_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 */ + coff_mips_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. */ + coff_mips_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 */ + coff_mips_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 */ + coff_mips_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 */ + coff_mips_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 */ + coff_mips_reloc, /* special_function */ + "LITERAL", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + EMPTY_HOWTO (13), + EMPTY_HOWTO (14), + EMPTY_HOWTO (15), + EMPTY_HOWTO (16), + EMPTY_HOWTO (17), + EMPTY_HOWTO (18), + EMPTY_HOWTO (19), + EMPTY_HOWTO (20), + EMPTY_HOWTO (21), + EMPTY_HOWTO (22), + EMPTY_HOWTO (23), + EMPTY_HOWTO (24), + EMPTY_HOWTO (25), + EMPTY_HOWTO (26), + EMPTY_HOWTO (27), + EMPTY_HOWTO (28), + EMPTY_HOWTO (29), + EMPTY_HOWTO (30), + EMPTY_HOWTO (31), + EMPTY_HOWTO (32), + EMPTY_HOWTO (33), + HOWTO (MIPS_R_RVA, /* 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_mips_reloc, /* special_function */ + "rva32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + EMPTY_HOWTO (35), + EMPTY_HOWTO (36), + HOWTO (MIPS_R_PAIR, /* 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_mips_reloc, /* special_function */ + "PAIR", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ +}; + +/* Turn a howto into a reloc nunmber */ + +#define SELECT_RELOC(x,howto) { x.r_type = howto->type; } +#define BADMAG(x) MIPSBADMAG(x) +#define MIPS 1 /* Customize coffcode.h */ + +#define RTYPE2HOWTO(cache_ptr, dst) \ + (cache_ptr)->howto = howto_table + (dst)->r_type; + +/* 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; \ + } + + +/* Convert an rtype to howto for the COFF backend linker. */ + +static reloc_howto_type * +coff_mips_rtype_to_howto (abfd, sec, rel, h, sym, addendp) + bfd *abfd ATTRIBUTE_UNUSED; + 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 == MIPS_R_RVA) + { + *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; + } +#endif + + return howto; +} + +#define coff_rtype_to_howto coff_mips_rtype_to_howto + + +#define coff_bfd_reloc_type_lookup coff_mips_reloc_type_lookup + + + +/* Get the howto structure for a generic reloc type. */ + +static reloc_howto_type * +coff_mips_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + 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; +/* FIXME? + 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; +*/ + case BFD_RELOC_RVA: + mips_type = MIPS_R_RVA; + break; + default: + return (reloc_howto_type *) NULL; + } + + return &howto_table[mips_type]; +} + +static void +mips_swap_reloc_in (abfd, src, dst) + bfd *abfd; + PTR src; + PTR dst; +{ + static struct internal_reloc pair_prev; + 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); + reloc_dst->r_size = 0; + reloc_dst->r_extern = 0; + reloc_dst->r_offset = 0; + + switch (reloc_dst->r_type) + { + case MIPS_R_REFHI: + pair_prev = *reloc_dst; + break; + case MIPS_R_PAIR: + reloc_dst->r_offset = reloc_dst->r_symndx; + if (reloc_dst->r_offset & 0x8000) + reloc_dst->r_offset -= 0x10000; + /*printf("dj: pair offset is %08x\n", reloc_dst->r_offset);*/ + reloc_dst->r_symndx = pair_prev.r_symndx; + break; + } +} + +static unsigned int +mips_swap_reloc_out (abfd, src, dst) + bfd *abfd; + PTR src; + PTR dst; +{ + static int prev_offset = 1; + static bfd_vma prev_addr = 0; + struct internal_reloc *reloc_src = (struct internal_reloc *)src; + struct external_reloc *reloc_dst = (struct external_reloc *)dst; + + switch (reloc_src->r_type) + { + case MIPS_R_REFHI: + prev_addr = reloc_src->r_vaddr; + prev_offset = reloc_src->r_offset; + break; + case MIPS_R_REFLO: + if (reloc_src->r_vaddr == prev_addr) + { + /* FIXME: only slightly hackish. If we see a REFLO pointing to + the same address as a REFHI, we assume this is the matching + PAIR reloc and output it accordingly. The symndx is really + the low 16 bits of the addend */ + 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, MIPS_R_PAIR, (bfd_byte *) + reloc_dst->r_type); + return RELSZ; + } + break; + } + + 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); + return RELSZ; +} + +#define coff_swap_reloc_in mips_swap_reloc_in +#define coff_swap_reloc_out mips_swap_reloc_out +#define NO_COFF_RELOCS + +static boolean +coff_pe_mips_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; +{ + bfd_vma gp; + boolean gp_undefined; + size_t adjust; + struct internal_reloc *rel; + struct internal_reloc *rel_end; + unsigned int i; + boolean got_lo; + + if (info->relocateable) + { + (*_bfd_error_handler)(_("\ +%s: `ld -r' not supported with PE MIPS objects\n"), + bfd_get_filename (input_bfd)); + bfd_set_error (bfd_error_bad_value); + return false; + } + + BFD_ASSERT (input_bfd->xvec->byteorder + == output_bfd->xvec->byteorder); + +#if 0 + printf("dj: relocate %s(%s) %08x\n", + input_bfd->filename, input_section->name, + input_section->output_section->vma + input_section->output_offset); +#endif + + gp = _bfd_get_gp_value (output_bfd); + if (gp == 0) + gp_undefined = true; + else + gp_undefined = false; + + got_lo = false; + + adjust = 0; + + rel = relocs; + rel_end = rel + input_section->reloc_count; + for (i = 0; rel < rel_end; rel++, i++) + { + long symndx; + struct coff_link_hash_entry *h; + struct internal_syment *sym; + bfd_vma addend = 0; + bfd_vma val, tmp, targ, src, low; + reloc_howto_type *howto; + unsigned char *mem = contents + rel->r_vaddr; + + 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, true))) + return false; + } + } + + src = rel->r_vaddr + input_section->output_section->vma + + input_section->output_offset; +#if 0 + printf("dj: reloc %02x %-8s a=%08x/%08x(%08x) v=%08x+%08x %s\n", + rel->r_type, howto_table[rel->r_type].name, + src, rel->r_vaddr, *(unsigned long *)mem, val, rel->r_offset, + h?h->root.root.string:"(none)"); +#endif + + /* OK, at this point the following variables are set up: + src = VMA of the memory we're fixing up + mem = pointer to memory we're fixing up + val = VMA of what we need to refer to + */ + +#define UI(x) (*_bfd_error_handler)(_("%s: unimplemented %s\n"), \ + bfd_get_filename (input_bfd), x); \ + bfd_set_error (bfd_error_bad_value); + + switch (rel->r_type) + { + case MIPS_R_ABSOLUTE: + /* ignore these */ + break; + + case MIPS_R_REFHALF: + UI("refhalf"); + break; + + case MIPS_R_REFWORD: + tmp = bfd_get_32(input_bfd, mem); + /* printf("refword: src=%08x targ=%08x+%08x\n", src, tmp, val); */ + tmp += val; + bfd_put_32(input_bfd, tmp, mem); + break; + + case MIPS_R_JMPADDR: + tmp = bfd_get_32(input_bfd, mem); + targ = val + (tmp&0x03ffffff)*4; + if ((src & 0xf0000000) != (targ & 0xf0000000)) + { + (*_bfd_error_handler)(_("%s: jump too far away\n"), + bfd_get_filename (input_bfd)); + bfd_set_error (bfd_error_bad_value); + return false; + } + tmp &= 0xfc000000; + tmp |= (targ/4) & 0x3ffffff; + bfd_put_32(input_bfd, tmp, mem); + break; + + case MIPS_R_REFHI: + tmp = bfd_get_32(input_bfd, mem); + switch (rel[1].r_type) + { + case MIPS_R_PAIR: + /* MS PE object */ + targ = val + rel[1].r_offset + ((tmp & 0xffff) << 16); + break; + case MIPS_R_REFLO: + /* GNU COFF object */ + low = bfd_get_32(input_bfd, contents + rel[1].r_vaddr); + low &= 0xffff; + if (low & 0x8000) + low -= 0x10000; + targ = val + low + ((tmp & 0xffff) << 16); + break; + default: + (*_bfd_error_handler)(_("%s: bad pair/reflo after refhi\n"), + bfd_get_filename (input_bfd)); + bfd_set_error (bfd_error_bad_value); + return false; + } + tmp &= 0xffff0000; + tmp |= (targ >> 16) & 0xffff; + bfd_put_32(input_bfd, tmp, mem); + break; + + case MIPS_R_REFLO: + tmp = bfd_get_32(input_bfd, mem); + targ = val + (tmp & 0xffff); + /* printf("refword: src=%08x targ=%08x\n", src, targ); */ + tmp &= 0xffff0000; + tmp |= targ & 0xffff; + bfd_put_32(input_bfd, tmp, mem); + break; + + case MIPS_R_GPREL: + case MIPS_R_LITERAL: + UI("gprel"); + break; + + case MIPS_R_SECTION: + UI("section"); + break; + + case MIPS_R_SECREL: + UI("secrel"); + break; + + case MIPS_R_SECRELLO: + UI("secrello"); + break; + + case MIPS_R_SECRELHI: + UI("secrelhi"); + break; + + case MIPS_R_RVA: + tmp = bfd_get_32 (input_bfd, mem); + /* printf("rva: src=%08x targ=%08x+%08x\n", src, tmp, val); */ + tmp += val + - pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase; + bfd_put_32 (input_bfd, tmp, mem); + break; + + case MIPS_R_PAIR: + /* ignore these */ + break; + } + } + + return true; +} + +#define coff_relocate_section coff_pe_mips_relocate_section + +#ifdef TARGET_UNDERSCORE + +/* If mips 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_mips_is_local_label_name PARAMS ((bfd *, const char *)); + +static boolean +coff_mips_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_mips_is_local_label_name + +#endif /* TARGET_UNDERSCORE */ + +#define COFF_NO_HACK_SCNHDR_SIZE + +#include "coffcode.h" + +const bfd_target +#ifdef TARGET_SYM + TARGET_SYM = +#else + mipslpe_vec = +#endif +{ +#ifdef TARGET_NAME + TARGET_NAME, +#else + "pe-mips", /* 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, 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), + + NULL, + + COFF_SWAP_TABLE +}; diff --git a/bfd/pe-ppc.c b/bfd/pe-ppc.c index a2bac04..7d4a547 100644 --- a/bfd/pe-ppc.c +++ b/bfd/pe-ppc.c @@ -38,4 +38,7 @@ Boston, MA 02111-1307, USA. */ /* FIXME: verify PCRELOFFSET is always false */ +/* FIXME: This target no longer works. Search for POWERPC_LE_PE in + coff-ppc.c and peigen.c. */ + #include "coff-ppc.c" diff --git a/bfd/pe-sh.c b/bfd/pe-sh.c new file mode 100644 index 0000000..7e48b0e --- /dev/null +++ b/bfd/pe-sh.c @@ -0,0 +1,31 @@ +/* BFD back-end for SH PECOFF files. + Copyright 1995, 2000 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_SHL_SYM shlpe_vec +#define TARGET_SHL_NAME "pe-shl" +#define COFF_WITH_PE +#define PCRELOFFSET true +#define TARGET_UNDERSCORE '_' +#define COFF_LONG_SECTION_NAMES + +#include "coff-sh.c" diff --git a/bfd/pei-arm.c b/bfd/pei-arm.c index 4ba5b3a..b7ae01e 100644 --- a/bfd/pei-arm.c +++ b/bfd/pei-arm.c @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 diff --git a/bfd/pei-i386.c b/bfd/pei-i386.c index 8b52968..8f0f77a 100644 --- a/bfd/pei-i386.c +++ b/bfd/pei-i386.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 PE IMAGE COFF files. - Copyright 1995 Free Software Foundation, Inc. + Copyright 1995, 1996, 1999 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -22,14 +22,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 +#define COFF_LONG_FILENAMES -#include "coff-i386.c" - - +#define COFF_SECTION_ALIGNMENT_ENTRIES \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ +{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 } +#include "coff-i386.c" diff --git a/bfd/pei-mcore.c b/bfd/pei-mcore.c index d4a872c..78c3b95 100644 --- a/bfd/pei-mcore.c +++ b/bfd/pei-mcore.c @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 diff --git a/bfd/pei-mips.c b/bfd/pei-mips.c new file mode 100644 index 0000000..472d35d --- /dev/null +++ b/bfd/pei-mips.c @@ -0,0 +1,32 @@ +/* BFD back-end for MIPS PE IMAGE COFF files. + Copyright 1995, 2000 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 mipslpei_vec +#define TARGET_NAME "pei-mips" +#define COFF_IMAGE_WITH_PE +#define PCRELOFFSET true +#define COFF_LONG_SECTION_NAMES + +#include "pe-mips.c" + + + diff --git a/bfd/pei-ppc.c b/bfd/pei-ppc.c index 839bc0f..86e1a5d 100644 --- a/bfd/pei-ppc.c +++ b/bfd/pei-ppc.c @@ -32,8 +32,6 @@ Boston, MA 02111-1307, USA. */ #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 @@ -41,7 +39,7 @@ Boston, MA 02111-1307, USA. */ /* FIXME: Verify PCRELOFFSET is always false */ -#include "coff-ppc.c" - - +/* FIXME: This target no longer works. Search for POWERPC_LE_PE in + coff-ppc.c and peigen.c. */ +#include "coff-ppc.c" diff --git a/bfd/pei-sh.c b/bfd/pei-sh.c new file mode 100644 index 0000000..2fb8b1c --- /dev/null +++ b/bfd/pei-sh.c @@ -0,0 +1,35 @@ +/* BFD back-end for SH PE IMAGE COFF files. + Copyright 1995, 2000 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_SHL_SYM shlpei_vec +#define TARGET_SHL_NAME "pei-shl" +#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-sh.c" + + + diff --git a/bfd/peicode.h b/bfd/peicode.h index 79d16e5..7238c78 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1,6 +1,6 @@ -/* Support for the generic parts of most COFF variants, for BFD. - Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Cygnus Support. +/* Support for the generic parts of PE/PEI, for BFD. + Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Written by Cygnus Solutions. This file is part of BFD, the Binary File Descriptor library. @@ -21,6 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Most of this hacked by Steve Chamberlain, sac@cygnus.com + +PE/PEI rearrangement (and code added): Donn Terry + Softway Systems, Inc. */ /* Hey look, some documentation [and in a place you expect to find it]! @@ -52,186 +55,98 @@ Most of this hacked by Steve Chamberlain, wasting too much time. */ -#ifdef coff_bfd_print_private_bfd_data +#include "libpei.h" + 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 + PARAMS ((bfd *, PTR)) = +#ifndef coff_bfd_print_private_bfd_data + NULL; #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) + coff_bfd_print_private_bfd_data; +#undef coff_bfd_print_private_bfd_data #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 +static boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR)); +#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data -#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 +static boolean (*pe_saved_coff_bfd_copy_private_bfd_data) + PARAMS ((bfd *, bfd *)) = +#ifndef coff_bfd_copy_private_bfd_data + NULL; +#else + coff_bfd_copy_private_bfd_data; +#undef coff_bfd_copy_private_bfd_data #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 +static boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); +#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data -/* 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 +#define coff_mkobject pe_mkobject +#define coff_mkobject_hook pe_mkobject_hook +#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 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 *)); + +#ifdef COFF_IMAGE_WITH_PE +/* This structure contains static variables used by the ILF code. */ +typedef asection * asection_ptr; + +typedef struct +{ + bfd * abfd; + bfd_byte * data; + struct bfd_in_memory * bim; + unsigned short magic; + + arelent * reltab; + unsigned int relcount; + + coff_symbol_type * sym_cache; + coff_symbol_type * sym_ptr; + unsigned int sym_index; + + unsigned int * sym_table; + unsigned int * table_ptr; + + combined_entry_type * native_syms; + combined_entry_type * native_ptr; + + coff_symbol_type ** sym_ptr_table; + coff_symbol_type ** sym_ptr_ptr; + + unsigned int sec_index; + + char * string_table; + char * string_ptr; + char * end_string_ptr; + + SYMENT * esym_table; + SYMENT * esym_ptr; + + struct internal_reloc * int_reltab; +} +pe_ILF_vars; + +static asection_ptr pe_ILF_make_a_section PARAMS ((pe_ILF_vars *, const char *, unsigned int, flagword)); +static void pe_ILF_make_a_reloc PARAMS ((pe_ILF_vars *, bfd_vma, bfd_reloc_code_real_type, asection_ptr)); +static void pe_ILF_make_a_symbol PARAMS ((pe_ILF_vars *, const char *, const char *, asection_ptr, flagword)); +static void pe_ILF_save_relocs PARAMS ((pe_ILF_vars *, asection_ptr)); +static void pe_ILF_make_a_symbol_reloc PARAMS ((pe_ILF_vars *, bfd_vma, bfd_reloc_code_real_type, struct symbol_cache_entry **, unsigned int)); +static boolean pe_ILF_build_a_bfd PARAMS ((bfd *, unsigned short, bfd_byte *, bfd_byte *, unsigned int, unsigned int)); +static const bfd_target * pe_ILF_object_p PARAMS ((bfd *)); +static const bfd_target * pe_bfd_object_p PARAMS ((bfd *)); +#endif /* COFF_IMAGE_WITH_PE */ /**********************************************************************/ +#ifndef NO_COFF_RELOCS static void coff_swap_reloc_in (abfd, src, dst) bfd *abfd; @@ -277,7 +192,7 @@ coff_swap_reloc_out (abfd, src, dst) #endif return RELSZ; } - +#endif /* not NO_COFF_RELOCS */ static void coff_swap_filehdr_in (abfd, src, dst) @@ -295,6 +210,21 @@ coff_swap_filehdr_in (abfd, src, dst) 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); +#ifdef COFF_IMAGE_WITH_PE + /* There are really two magic numbers involved; the magic number + that says this is a NT executable (PEI) and the magic number that + determines the architecture. The former is DOSMAGIC, stored in + the e_magic field. The latter is stored in the f_magic field. + If the NT magic number isn't valid, the architecture magic number + could be mimicked by some other field (specifically, the number + of relocs in section 3). Since this routine can only be called + correctly for a PEI file, check the e_magic number here, and, if + it doesn't match, clobber the f_magic number so that we don't get + a false match. */ + if (bfd_h_get_16 (abfd, (bfd_byte *) filehdr_src->e_magic) != DOSMAGIC) + filehdr_dst->f_magic = -1; +#endif + /* 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) @@ -308,1837 +238,1090 @@ coff_swap_filehdr_in (abfd, src, dst) } #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; -} +#define coff_swap_filehdr_out _bfd_pei_only_swap_filehdr_out #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; -} - +#define coff_swap_filehdr_out _bfd_pe_only_swap_filehdr_out #endif static void -coff_swap_sym_in (abfd, ext1, in1) +coff_swap_scnhdr_in (abfd, ext, in) bfd *abfd; - PTR ext1; - PTR in1; + PTR ext; + PTR in; { - 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!; + 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); + + /* MS handles overflow of line numbers by carrying into the reloc + field (it appears). Since it's supposed to be zero for PE + *IMAGE* format, that's safe. This is still a bit iffy. */ +#ifdef COFF_IMAGE_WITH_PE + scnhdr_int->s_nlnno = + (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nlnno) + + (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nreloc) << 16)); + scnhdr_int->s_nreloc = 0; #else - memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); + 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); #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) + + if (scnhdr_int->s_vaddr != 0) { - 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; */ + scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; + scnhdr_int->s_vaddr &= 0xffffffff; } -#ifdef coff_swap_sym_in_hook - coff_swap_sym_in_hook(abfd, ext1, in1); +#ifndef COFF_NO_HACK_SCNHDR_SIZE + /* If this section holds uninitialized data, use the virtual size + (stored in s_paddr) instead of the physical size. */ + if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0) + { + scnhdr_int->s_size = scnhdr_int->s_paddr; + /* This code used to set scnhdr_int->s_paddr to 0. However, + coff_set_alignment_hook stores s_paddr in virt_size, which + only works if it correctly holds the virtual size of the + section. */ + } #endif } -static unsigned int -coff_swap_sym_out (abfd, inp, extp) - bfd *abfd; - PTR inp; - PTR extp; +static boolean +pe_mkobject (abfd) + bfd * abfd; { - 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 - } + pe_data_type *pe; + abfd->tdata.pe_obj_data = + (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type)); - 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); + if (abfd->tdata.pe_obj_data == 0) + return false; + + pe = pe_data (abfd); + + pe->coff.pe = 1; - return SYMESZ; + /* in_reloc_p is architecture dependent. */ + pe->in_reloc_p = in_reloc_p; + return true; } -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; +/* Create the COFF backend specific information. */ +static PTR +pe_mkobject_hook (abfd, filehdr, aouthdr) + bfd * abfd; + PTR filehdr; + PTR aouthdr ATTRIBUTE_UNUSED; { - 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; + struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; + pe_data_type *pe; + if (pe_mkobject (abfd) == false) + return NULL; - 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; - } + 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; - 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 + pe->coff.timestamp = internal_f->f_timdat; - 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]); - } + obj_raw_syment_count (abfd) = + obj_conv_table_size (abfd) = + internal_f->f_nsyms; - 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); - } -} + pe->real_flags = internal_f->f_flags; -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; + if ((internal_f->f_flags & F_DLL) != 0) + pe->dll = 1; + if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) + abfd->flags |= HAS_DEBUG; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: +#ifdef COFF_IMAGE_WITH_PE + if (aouthdr) + pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe; #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); +#ifdef ARM + if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) + coff_data (abfd) ->flags = 0; #endif + + return (PTR) pe; +} - 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]); - } +static boolean +pe_print_private_bfd_data (abfd, vfile) + bfd *abfd; + PTR vfile; +{ + FILE *file = (FILE *) vfile; - 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 + if (!_bfd_pe_print_private_bfd_data_common (abfd, vfile)) + return false; + + if (pe_saved_coff_bfd_print_private_bfd_data != NULL) { - 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); + fputc ('\n', file); + + return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); } - return AUXESZ; + return true; } +/* Copy any private info we understand from the input bfd + to the output bfd. */ -static void -coff_swap_lineno_in (abfd, ext1, in1) - bfd *abfd; - PTR ext1; - PTR in1; +static boolean +pe_bfd_copy_private_bfd_data (ibfd, obfd) + bfd *ibfd, *obfd; { - 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); -} + if (!_bfd_pe_bfd_copy_private_bfd_data_common (ibfd, obfd)) + return false; -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); + if (pe_saved_coff_bfd_copy_private_bfd_data) + return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); - PUT_LINENO_LNNO (abfd, in->l_lnno, ext); - return LINESZ; + return true; } +#define coff_bfd_copy_private_section_data \ + _bfd_pe_bfd_copy_private_section_data +#define coff_get_symbol_info _bfd_pe_get_symbol_info +#ifdef COFF_IMAGE_WITH_PE + +/* Code to handle Microsoft's Image Library Format. + Also known as LINK6 format. + Documentation about this format can be found at: + + http://msdn.microsoft.com/library/specs/pecoff_section8.htm */ + +/* The following constants specify the sizes of the various data + structures that we have to create in order to build a bfd describing + an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 + and SIZEOF_IDATA7 below is to allow for the possibility that we might + need a padding byte in order to ensure 16 bit alignment for the section's + contents. + + The value for SIZEOF_ILF_STRINGS is computed as follows: + + There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters + per symbol for their names (longest section name is .idata$x). + + There will be two symbols for the imported value, one the symbol name + and one with _imp__ prefixed. Allowing for the terminating nul's this + is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). + + The strings in the string table must start STRING__SIZE_SIZE bytes into + the table in order to for the string lookup code in coffgen/coffcode to + work. */ +#define NUM_ILF_RELOCS 8 +#define NUM_ILF_SECTIONS 6 +#define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) + +#define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) +#define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) +#define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) +#define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) +#define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) +#define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) +#define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) +#define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ + + 21 + strlen (source_dll) \ + + NUM_ILF_SECTIONS * 9 \ + + STRING_SIZE_SIZE) +#define SIZEOF_IDATA2 (5 * 4) +#define SIZEOF_IDATA4 (1 * 4) +#define SIZEOF_IDATA5 (1 * 4) +#define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) +#define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) +#define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) + +#define ILF_DATA_SIZE \ + sizeof (* vars.bim) \ + + SIZEOF_ILF_SYMS \ + + SIZEOF_ILF_SYM_TABLE \ + + SIZEOF_ILF_NATIVE_SYMS \ + + SIZEOF_ILF_SYM_PTR_TABLE \ + + SIZEOF_ILF_EXT_SYMS \ + + SIZEOF_ILF_RELOCS \ + + SIZEOF_ILF_INT_RELOCS \ + + SIZEOF_ILF_STRINGS \ + + SIZEOF_IDATA2 \ + + SIZEOF_IDATA4 \ + + SIZEOF_IDATA5 \ + + SIZEOF_IDATA6 \ + + SIZEOF_IDATA7 \ + + SIZEOF_ILF_SECTIONS \ + + MAX_TEXT_SECTION_SIZE + + +/* Create an empty relocation against the given symbol. */ static void -coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1) - bfd *abfd; - PTR aouthdr_ext1; - PTR aouthdr_int1; +pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, + bfd_vma address, + bfd_reloc_code_real_type reloc, + struct symbol_cache_entry ** sym, + unsigned int sym_index) { - 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; - } + arelent * entry; + struct internal_reloc * internal; -#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; + entry = vars->reltab + vars->relcount; + internal = vars->int_reltab + vars->relcount; + + entry->address = address; + entry->addend = 0; + entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); + entry->sym_ptr_ptr = sym; + + internal->r_vaddr = address; + internal->r_symndx = sym_index; + internal->r_type = entry->howto->type; +#if 0 /* These fields do not need to be initialised. */ + internal->r_size = 0; + internal->r_extern = 0; + internal->r_offset = 0; #endif + + vars->relcount ++; + + BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); } - -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; +/* Create an empty relocation against the given section. */ +static void +pe_ILF_make_a_reloc (pe_ILF_vars * vars, + bfd_vma address, + bfd_reloc_code_real_type reloc, + asection_ptr sec) { - 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; - } + pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, + coff_section_data (vars->abfd, sec)->i); } -static unsigned int -coff_swap_aouthdr_out (abfd, in, out) - bfd *abfd; - PTR in; - PTR out; +/* Move the queued relocs into the given section. */ +static void +pe_ILF_save_relocs (pe_ILF_vars * vars, + asection_ptr sec) { - 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; + /* Make sure that there is somewhere to store the internal relocs. */ + if (coff_section_data (vars->abfd, sec) == NULL) + /* We should probably return an error indication here. */ + abort (); - bfd_vma sa = extra->SectionAlignment; - bfd_vma fa = extra->FileAlignment; - bfd_vma ib = extra->ImageBase ; + coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; + coff_section_data (vars->abfd, sec)->keep_relocs = true; - 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)) + sec->relocation = vars->reltab; + sec->reloc_count = vars->relcount; + sec->flags |= SEC_RELOC; - /* We like to have the sizes aligned */ + vars->reltab += vars->relcount; + vars->int_reltab += vars->relcount; + vars->relcount = 0; - aouthdr_in->bsize = FA (aouthdr_in->bsize); + BFD_ASSERT ((bfd_byte *)vars->int_reltab < (bfd_byte *)vars->string_table); +} +/* Create a global symbol and add it to the relevant tables. */ +static void +pe_ILF_make_a_symbol (pe_ILF_vars * vars, + const char * prefix, + const char * symbol_name, + asection_ptr section, + flagword extra_flags) +{ + coff_symbol_type * sym; + combined_entry_type * ent; + SYMENT * esym; + unsigned short sclass; - extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; + if (extra_flags & BSF_LOCAL) + sclass = C_STAT; + else + sclass = C_EXT; + +#ifdef THUMBPEMAGIC + if (vars->magic == THUMBPEMAGIC) + { + if (extra_flags & BSF_FUNCTION) + sclass = C_THUMBEXTFUNC; + else if (extra_flags & BSF_LOCAL) + sclass = C_THUMBSTAT; + else + sclass = C_THUMBEXT; + } +#endif - /* first null out all data directory entries .. */ - memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0); + BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); + + sym = vars->sym_ptr; + ent = vars->native_ptr; + esym = vars->esym_ptr; - add_data_entry (abfd, extra, 0, ".edata", ib); - add_data_entry (abfd, extra, 1, ".idata", ib); - add_data_entry (abfd, extra, 2, ".rsrc" ,ib); + /* Copy the symbol's name into the string table. */ + sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); -#ifdef POWERPC_LE_PE - /* FIXME: do other PE platforms use this? */ - add_data_entry (abfd, extra, 3, ".pdata" ,ib); + if (section == NULL) + section = (asection_ptr) & bfd_und_section; + + /* Initialise the external symbol. */ + bfd_h_put_32 (vars->abfd, vars->string_ptr - vars->string_table, (bfd_byte *) esym->e.e.e_offset); + bfd_h_put_16 (vars->abfd, section->target_index, (bfd_byte *) esym->e_scnum); + esym->e_sclass[0] = sclass; + + /* The following initialisations are unnecessary - the memory is + zero initialised. They are just kept here as reminders. */ +#if 0 + esym->e.e.e_zeroes = 0; + esym->e_value = 0; + esym->e_type = T_NULL; + esym->e_numaux = 0; #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; + + /* Initialise the internal symbol structure. */ + ent->u.syment.n_sclass = sclass; + ent->u.syment.n_scnum = section->target_index; + ent->u.syment._n._n_n._n_offset = (long) sym; + +#if 0 /* See comment above. */ + ent->u.syment.n_value = 0; + ent->u.syment.n_flags = 0; + ent->u.syment.n_type = T_NULL; + ent->u.syment.n_numaux = 0; + ent->fix_value = 0; #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); + + sym->symbol.the_bfd = vars->abfd; + sym->symbol.name = vars->string_ptr; + sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; + sym->symbol.section = section; + sym->native = ent; + +#if 0 /* See comment above. */ + sym->symbol.value = 0; + sym->symbol.udata.i = 0; + sym->done_lineno = false; + sym->lineno = NULL; #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; + + * vars->table_ptr = vars->sym_index; + * vars->sym_ptr_ptr = sym; + + /* Adjust pointers for the next symbol. */ + vars->sym_index ++; + vars->sym_ptr ++; + vars->sym_ptr_ptr ++; + vars->table_ptr ++; + vars->native_ptr ++; + vars->esym_ptr ++; + vars->string_ptr += strlen (symbol_name) + strlen (prefix) + 1; + + BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); } -static void - coff_swap_scnhdr_in (abfd, ext, in) - bfd *abfd; - PTR ext; - PTR in; +/* Create a section. */ +static asection_ptr +pe_ILF_make_a_section (pe_ILF_vars * vars, + const char * name, + unsigned int size, + flagword extra_flags) { - 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); + asection_ptr sec; + flagword flags; + + sec = bfd_make_section_old_way (vars->abfd, name); + if (sec == NULL) + return NULL; + + flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; + + bfd_set_section_flags (vars->abfd, sec, flags | extra_flags); + + bfd_set_section_alignment (vars->abfd, sec, 2); + + /* Check that we will not run out of space. */ + BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); + + /* Set the section size and contents. The actual + contents are filled in by our parent. */ + bfd_set_section_size (vars->abfd, sec, size); + sec->contents = vars->data; + sec->target_index = vars->sec_index ++; + + /* Advance data pointer in the vars structure. */ + vars->data += size; + + /* Skip the padding byte if it was not needed. + The logic here is that if the string length is odd, + then the entire string length, including the null byte, + is even and so the extra, padding byte, is not needed. */ + if (size & 1) + vars->data --; + + /* Create a coff_section_tdata structure for our use. */ + sec->used_by_bfd = (struct coff_section_tdata *) vars->data; + vars->data += sizeof (struct coff_section_tdata); - 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); + BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); + + /* Create a symbol to refer to this section. */ + pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); - 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; - } + /* Cache the index to the symbol in the coff_section_data structure. */ + coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; + + return sec; } -static unsigned int -coff_swap_scnhdr_out (abfd, in, out) - bfd *abfd; - PTR in; - PTR out; +/* This structure contains the code that goes into the .text section + in order to perform a jump into the DLL lookup table. The entries + in the table are index by the magic number used to represent the + machine type in the PE file. The contents of the data[] arrays in + these entries are stolen from the jtab[] arrays in ld/pe-dll.c. + The SIZE field says how many bytes in the DATA array are actually + used. The OFFSET field says where in the data array the address + of the .idata$5 section should be placed. */ +#define MAX_TEXT_SECTION_SIZE 32 + +typedef struct { - 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; + unsigned short magic; + unsigned char data[MAX_TEXT_SECTION_SIZE]; + unsigned int size; + unsigned int offset; } +jump_table; -static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] = +static jump_table jtab[] = { - 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") +#ifdef I386MAGIC + { I386MAGIC, + { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, + 8, 2 + }, +#endif + +#ifdef MC68MAGIC + { MC68MAGIC, { /* XXX fill me in */ }, 0, 0 }, +#endif +#ifdef MIPS_ARCH_MAGIC_WINCE + { MIPS_ARCH_MAGIC_WINCE, + { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, + 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, + 16, 0 + }, +#endif + +#ifdef SH_ARCH_MAGIC_WINCE + { SH_ARCH_MAGIC_WINCE, + { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, + 12, 8 + }, +#endif + +#ifdef ARMPEMAGIC + { ARMPEMAGIC, + { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, + 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, + 12, 8 + }, +#endif + +#ifdef THUMBPEMAGIC + { THUMBPEMAGIC, + { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, + 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, + 16, 12 + }, +#endif + { 0, { 0 }, 0, 0 } }; -/**********************************************************************/ -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"); +#ifndef NUM_ENTRIES +#define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) #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) +/* Build a full BFD from the information supplied in a ILF object. */ +static boolean +pe_ILF_build_a_bfd (bfd * abfd, + unsigned short magic, + bfd_byte * symbol_name, + bfd_byte * source_dll, + unsigned int ordinal, + unsigned int types) +{ + bfd_byte * ptr; + pe_ILF_vars vars; + struct internal_filehdr internal_f; + unsigned int import_type; + unsigned int import_name_type; + asection_ptr id4, id5, id6 = NULL, text = NULL; + coff_symbol_type ** imp_sym; + unsigned int imp_index; + + /* Decode and verify the types field of the ILF structure. */ + import_type = types & 0x3; + import_name_type = (types & 0x1c) >> 2; + + switch (import_type) { - datasize = bfd_section_size (abfd, section); - dataoff = 0; - - if (datasize == 0) - return true; + case IMPORT_CODE: + case IMPORT_DATA: + break; + + case IMPORT_CONST: + /* XXX code yet to be written. */ + _bfd_error_handler (_("%s: Unhandled import type; %x"), + bfd_get_filename (abfd), import_type); + return false; + + default: + _bfd_error_handler (_("%s: Unrecognised import type; %x"), + bfd_get_filename (abfd), import_type); + return false; } - 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; + switch (import_name_type) + { + case IMPORT_ORDINAL: + case IMPORT_NAME: + case IMPORT_NAME_NOPREFIX: + case IMPORT_NAME_UNDECORATE: + break; + + default: + _bfd_error_handler (_("%s: Unrecognised import name type; %x"), + bfd_get_filename (abfd), import_name_type); + return false; } -#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; + /* Initialise local variables. + + Note these are kept in a structure rather than being + declared as statics since bfd frowns on global variables. + + We are going to construct the contents of the BFD in memory, + so allocate all the space that we will need right now. */ + ptr = bfd_zalloc (abfd, ILF_DATA_SIZE); + if (ptr == NULL) + return false; - datasize = bfd_section_size (abfd, rel_section); + /* Create a bfd_in_memory structure. */ + vars.bim = (struct bfd_in_memory *) ptr; + vars.bim->buffer = ptr; + vars.bim->size = ILF_DATA_SIZE; + ptr += sizeof (* vars.bim); - 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 + /* Initialise the pointers to regions of the memory and the + other contents of the pe_ILF_vars structure as well. */ + vars.sym_cache = (coff_symbol_type *) ptr; + vars.sym_ptr = (coff_symbol_type *) ptr; + vars.sym_index = 0; + ptr += SIZEOF_ILF_SYMS; + + vars.sym_table = (unsigned int *) ptr; + vars.table_ptr = (unsigned int *) ptr; + ptr += SIZEOF_ILF_SYM_TABLE; - 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")); + vars.native_syms = (combined_entry_type *) ptr; + vars.native_ptr = (combined_entry_type *) ptr; + ptr += SIZEOF_ILF_NATIVE_SYMS; - 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; + vars.sym_ptr_table = (coff_symbol_type **) ptr; + vars.sym_ptr_ptr = (coff_symbol_type **) ptr; + ptr += SIZEOF_ILF_SYM_PTR_TABLE; + + vars.esym_table = (SYMENT *) ptr; + vars.esym_ptr = (SYMENT *) ptr; + ptr += SIZEOF_ILF_EXT_SYMS; + + vars.reltab = (arelent *) ptr; + vars.relcount = 0; + ptr += SIZEOF_ILF_RELOCS; - adj = (extra->ImageBase - section->vma) & 0xffffffff; + vars.int_reltab = (struct internal_reloc *) ptr; + ptr += SIZEOF_ILF_INT_RELOCS; - start = dataoff; - stop = dataoff + datasize; - for (i = start; i < stop; i += onaline) + vars.string_table = ptr; + vars.string_ptr = ptr + STRING_SIZE_SIZE; + ptr += SIZEOF_ILF_STRINGS; + vars.end_string_ptr = ptr; + + /* The remaining space in bim->buffer is used + by the pe_ILF_make_a_section() function. */ + vars.data = ptr; + vars.abfd = abfd; + vars.sec_index = 0; + vars.magic = magic; + + /* Create the initial .idata$ sections: + [.idata$2: Import Directory Table -- not needed] + .idata$4: Import Lookup Table + .idata$5: Import Address Table + + Note we do not create a .idata$3 section as this is + created for us by the linker script. */ + id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); + id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); + if (id4 == NULL || id5 == NULL) + return false; + + /* Fill in the contents of these sections. */ + if (import_name_type == IMPORT_ORDINAL) { - 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 */ - ; - } + if (ordinal == 0) + /* XXX - treat as IMPORT_NAME ??? */ + abort (); - 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); + * (unsigned int *) id4->contents = ordinal | 0x80000000UL; + * (unsigned int *) id5->contents = ordinal | 0x80000000UL; + } + else + { + char * symbol; - fprintf(file, "%08lx %08lx %08lx %08lx %08lx\n", - hint_addr, - time_stamp, - forward_chain, - dll_name, - first_thunk); + /* Create .idata$6 - the Hint Name Table. */ + id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); + if (id6 == NULL) + return false; - if (hint_addr == 0 && first_thunk == 0) - break; + /* If necessary, trim the import symbol name. */ + symbol = symbol_name; - /* the image base is present in the section->vma */ - dll = (char *) data + dll_name + adj; - fprintf(file, _("\n\tDLL Name: %s\n"), dll); + if (import_name_type != IMPORT_NAME) + /* Skip any prefix in symbol_name. */ + while (*symbol == '@' || * symbol == '?' || * symbol == '_') + ++ symbol; - if (hint_addr != 0) + if (import_name_type == IMPORT_NAME_UNDECORATE) { - 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"); - } - } + /* Truncate at the first '@' */ + while (* symbol != 0 && * symbol != '@') + symbol ++; - if (hint_addr != first_thunk && time_stamp == 0) - { - int differ = 0; - int idx2; - - idx2 = first_thunk + adj; - - for (j=0;j>> 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")); - } + * symbol = 0; } - - fprintf(file, "\n"); - + + id6->contents[0] = ordinal & 0xff; + id6->contents[1] = ordinal >> 8; + + strcpy (id6->contents + 2, symbol); } - 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) + if (import_name_type != IMPORT_ORDINAL) { - datasize = bfd_section_size (abfd, section); - dataoff = 0; + pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6); + pe_ILF_save_relocs (& vars, id4); + + pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6); + pe_ILF_save_relocs (& vars, id5); } - 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) + /* Create extra sections depending upon the type of import we are dealing with. */ + switch (import_type) + { + int i; + + case IMPORT_CODE: + /* Create a .text section. + First we need to look up its contents in the jump table. */ + for (i = NUM_ENTRIES (jtab); i--;) { - if (section->vma - extra->ImageBase <= addr - && ((section->vma - extra->ImageBase - + bfd_section_size (abfd, section)) - >= addr + size)) + if (jtab[i].size == 0) + continue; + if (jtab[i].magic == magic) 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 we did not find a matching entry something is wrong. */ + if (i < 0) + abort (); - if (eat_member == 0) - continue; + /* Create the .text section. */ + text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); + if (text == NULL) + return false; - if (edata_start < eat_actual && eat_actual < edata_end) + /* Copy in the jump code. */ + memcpy (text->contents, jtab[i].data, jtab[i].size); + + /* Create an import symbol. */ + pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); + imp_sym = vars.sym_ptr_ptr - 1; + imp_index = vars.sym_index - 1; + + /* Create a reloc for the data in the text section. */ +#ifdef MIPS_ARCH_MAGIC_WINCE + if (magic == MIPS_ARCH_MAGIC_WINCE) { - /* 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); + pe_ILF_make_a_symbol_reloc (& vars, 0, BFD_RELOC_HI16_S, + (asection **) imp_sym, imp_index); + pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_LO16, text); + pe_ILF_make_a_symbol_reloc (& vars, 4, BFD_RELOC_LO16, + (asection **) imp_sym, imp_index); } 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); +#endif + pe_ILF_make_a_symbol_reloc (& vars, jtab[i].offset, BFD_RELOC_32, + (asymbol **) imp_sym, imp_index); - char *name = (char *) data + name_ptr + adj; + pe_ILF_save_relocs (& vars, text); + break; - bfd_vma ord = bfd_get_16(abfd, - data + - edt.ot_addr - + (i*2) + adj); - fprintf(file, - "\t[%4ld] %s\n", (long) ord, name); + case IMPORT_DATA: + break; + default: + /* XXX code not yet written. */ + abort (); } + + /* Initialise the bfd. */ + memset (& internal_f, 0, sizeof (internal_f)); + + internal_f.f_magic = magic; + internal_f.f_symptr = 0; + internal_f.f_nsyms = 0; + internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ + + if ( ! bfd_set_start_address (abfd, 0) + || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) + return false; - 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) + if (bfd_coff_mkobject_hook (abfd, (PTR) & internal_f, NULL) == NULL) return false; - bfd_get_section_contents (abfd, - section, - (PTR) data, 0, - bfd_section_size (abfd, section)); + coff_data (abfd)->pe = 1; +#ifdef THUMBPEMAGIC + if (vars.magic == THUMBPEMAGIC) + /* Stop some linker warnings about thumb code not supporting interworking. */ + coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; +#endif + + /* Switch from file contents to memory contents. */ + bfd_cache_close (abfd); - start = 0; + abfd->iostream = (PTR) vars.bim; + abfd->flags |= BFD_IN_MEMORY /* | HAS_LOCALS */; + abfd->where = 0; + obj_sym_filepos (abfd) = 0; - for (i = start; i < stop; i += onaline) + /* Now create a symbol describing the imported value. */ + switch (import_type) { - 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; + bfd_byte * ptr; - 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); + case IMPORT_CODE: + pe_ILF_make_a_symbol (& vars, "", symbol_name, text, + BSF_NOT_AT_END | BSF_FUNCTION); - 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)); + /* Create an import symbol for the DLL, without the + .dll suffix. */ + ptr = strrchr (source_dll, '.'); + if (ptr) + * ptr = 0; + pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); + if (ptr) + * ptr = '.'; + break; + + case IMPORT_DATA: + /* Nothing to do here. */ + break; + + default: + /* XXX code not yet written. */ + abort (); + } - fprintf(file, "%08lx %08lx %08lx %08lx %08lx", - begin_addr, - end_addr, - eh_handler, - eh_data, - prolog_end_addr); + /* Point the bfd at the symbol table. */ + obj_symbols (abfd) = vars.sym_cache; + bfd_get_symcount (abfd) = vars.sym_index; + + obj_raw_syments (abfd) = vars.native_syms; + obj_raw_syment_count (abfd) = vars.sym_index; -#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"); - } + obj_coff_external_syms (abfd) = (PTR) vars.esym_table; + obj_coff_keep_syms (abfd) = true; + + obj_convert (abfd) = vars.sym_table; + obj_conv_table_size (abfd) = vars.sym_index; + + obj_coff_strings (abfd) = vars.string_table; + obj_coff_keep_strings (abfd) = true; - free (data); + abfd->flags |= HAS_SYMS; return true; } -static const char *tbl[6] = +/* We have detected a Image Library Format archive element. + Decode the element and return the appropriate target. */ +static const bfd_target * +pe_ILF_object_p (bfd * abfd) { -"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)); + bfd_byte buffer[16]; + bfd_byte * ptr; + bfd_byte * symbol_name; + bfd_byte * source_dll; + unsigned int machine; + unsigned long size; + unsigned int ordinal; + unsigned int types; + unsigned short magic; + + /* Upon entry the first four buyes of the ILF header have + already been read. Now read the rest of the header. */ + if (bfd_read (buffer, 1, 16, abfd) != 16) + return NULL; - start = 0; + ptr = buffer; + + /* We do not bother to check the version number. + version = bfd_h_get_16 (abfd, ptr); */ + ptr += 2; - stop = bfd_section_size (abfd, section); + machine = bfd_h_get_16 (abfd, ptr); + ptr += 2; - for (i = start; i < stop;) + /* Check that the machine type is recognised. */ + magic = 0; + + switch (machine) { - 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; + case IMAGE_FILE_MACHINE_UNKNOWN: + case IMAGE_FILE_MACHINE_ALPHA: + case IMAGE_FILE_MACHINE_ALPHA64: + case IMAGE_FILE_MACHINE_IA64: + break; + + case IMAGE_FILE_MACHINE_I386: +#ifdef I386MAGIC + magic = I386MAGIC; +#endif + break; + + case IMAGE_FILE_MACHINE_M68K: +#ifdef MC68AGIC + magic = MC68MAGIC; +#endif + break; + + case IMAGE_FILE_MACHINE_R3000: + case IMAGE_FILE_MACHINE_R4000: + case IMAGE_FILE_MACHINE_R10000: + + case IMAGE_FILE_MACHINE_MIPS16: + case IMAGE_FILE_MACHINE_MIPSFPU: + case IMAGE_FILE_MACHINE_MIPSFPU16: +#ifdef MIPS_ARCH_MAGIC_WINCE + magic = MIPS_ARCH_MAGIC_WINCE; +#endif + break; + + case IMAGE_FILE_MACHINE_SH3: + case IMAGE_FILE_MACHINE_SH4: +#ifdef SH_ARCH_MAGIC_WINCE + magic = SH_ARCH_MAGIC_WINCE; +#endif + break; + + case IMAGE_FILE_MACHINE_ARM: +#ifdef ARMPEMAGIC + magic = ARMPEMAGIC; +#endif + break; + + case IMAGE_FILE_MACHINE_THUMB: +#ifdef THUMBPEMAGIC + { + extern bfd_target armpei_little_vec; + + if (abfd->xvec == & armpei_little_vec) + magic = THUMBPEMAGIC; + } +#endif + break; + + case IMAGE_FILE_MACHINE_POWERPC: + /* We no longer support PowerPC. */ + default: + _bfd_error_handler + ( +_("%s: Unrecognised machine type (0x%x) in Import Library Format archive"), + bfd_get_filename (abfd), machine); + bfd_set_error (bfd_error_malformed_archive); + + return NULL; + break; } - 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++) + if (magic == 0) { - 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); + _bfd_error_handler + ( +_("%s: Recognised but unhandled machine type (0x%x) in Import Library Format archive"), + bfd_get_filename (abfd), machine); + bfd_set_error (bfd_error_wrong_format); + + return NULL; + } + + /* We do not bother to check the date. + date = bfd_h_get_32 (abfd, ptr); */ + ptr += 4; + + size = bfd_h_get_32 (abfd, ptr); + ptr += 4; - if (pe_saved_coff_bfd_print_private_bfd_data != NULL) + if (size == 0) { - fputc ('\n', file); - - return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); + _bfd_error_handler + (_("%s: size field is zero in Import Library Format header"), + bfd_get_filename (abfd)); + bfd_set_error (bfd_error_malformed_archive); + + return NULL; } - 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; + ordinal = bfd_h_get_16 (abfd, ptr); + ptr += 2; - 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; + types = bfd_h_get_16 (abfd, ptr); + /* ptr += 2; */ - if (pe_mkobject (abfd) == false) + /* Now read in the two strings that follow. */ + ptr = bfd_alloc (abfd, size); + if (ptr == NULL) + return NULL; + + if (bfd_read (ptr, 1, size, abfd) != size) 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 + symbol_name = ptr; + source_dll = ptr + strlen (ptr) + 1; - return (PTR) pe; + /* Verify that the strings are null terminated. */ + if (ptr[size - 1] != 0 || ((unsigned long) (source_dll - ptr) >= size)) + { + _bfd_error_handler + (_("%s: string not null terminated in ILF object file."), + bfd_get_filename (abfd)); + bfd_set_error (bfd_error_malformed_archive); + + return NULL; + } + + /* Now construct the bfd. */ + if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, + source_dll, ordinal, types)) + return NULL; + + return abfd->xvec; } - - -/* 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; +static const bfd_target * +pe_bfd_object_p (bfd * abfd) { - /* 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); + /* We need 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 buffer[4]; + file_ptr offset; + unsigned long signature; + + /* Detect if this a Microsoft Import Library Format element. */ + if (bfd_seek (abfd, 0x00, SEEK_SET) != 0 + || bfd_read (buffer, 1, 4, abfd) != 4) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } - return true; -} - -#ifdef COFF_IMAGE_WITH_PE - -/* Copy private section data. */ + signature = bfd_h_get_32 (abfd, buffer); + + if (signature == 0xffff0000) + return pe_ILF_object_p (abfd); + + if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0 + || bfd_read (buffer, 1, 4, abfd) != 4) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } -#define coff_bfd_copy_private_section_data pe_bfd_copy_private_section_data + offset = bfd_h_get_32 (abfd, buffer); -static boolean pe_bfd_copy_private_section_data - PARAMS ((bfd *, asection *, bfd *, asection *)); + if (bfd_seek (abfd, offset, SEEK_SET) != 0 + || bfd_read (buffer, 1, 4, abfd) != 4) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } -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; + signature = bfd_h_get_32 (abfd, buffer); - if (coff_section_data (ibfd, isec) != NULL - && pei_section_data (ibfd, isec) != NULL) + if (signature != 0x4550) { - 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; + 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; } - return true; + return coff_object_p (abfd); } -#endif +#define coff_object_p pe_bfd_object_p +#endif /* COFF_IMAGE_WITH_PE */ diff --git a/bfd/peigen.c b/bfd/peigen.c new file mode 100644 index 0000000..639ea89 --- /dev/null +++ b/bfd/peigen.c @@ -0,0 +1,1911 @@ +/* Support for the generic parts of PE/PEI; the common executable parts. + Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Written by Cygnus Solutions. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public 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 + +PE/PEI rearrangement (and code added): Donn Terry + Softway Systems, Inc. +*/ + +/* 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. +*/ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "coff/internal.h" + +/* NOTE: it's strange to be including an architecture specific header + in what's supposed to be general (to PE/PEI) code. However, that's + where the definitions are, and they don't vary per architecture + within PE/PEI, so we get them from there. FIXME: The lack of + variance is an assumption which may prove to be incorrect if new + PE/PEI targets are created. */ +#include "coff/i386.h" + +#include "coff/pe.h" +#include "libcoff.h" +#include "libpei.h" + +/* FIXME: This file has various tests of POWERPC_LE_PE. Those tests + worked when the code was in peicode.h, but no longer work now that + the code is in peigen.c. PowerPC NT is said to be dead. If + anybody wants to revive the code, you will have to figure out how + to handle those issues. */ + +static void add_data_entry + PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma)); +static boolean pe_print_pdata PARAMS ((bfd *, PTR)); +static boolean pe_print_reloc PARAMS ((bfd *, PTR)); + +/**********************************************************************/ + +void +_bfd_pei_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 { + memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); + } + + 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); + +#ifndef STRICT_PE_FORMAT + /* This is for Gnu-created DLLs */ + + /* 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; + +#if 0 + /* 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; */ +#else + /* Create synthetic empty sections as needed. DJ */ + if (in->n_scnum == 0) + { + asection *sec; + for (sec=abfd->sections; sec; sec=sec->next) + { + if (strcmp (sec->name, in->n_name) == 0) + { + in->n_scnum = sec->target_index; + break; + } + } + } + if (in->n_scnum == 0) + { + int unused_section_number = 0; + asection *sec; + char *name; + for (sec=abfd->sections; sec; sec=sec->next) + if (unused_section_number <= sec->target_index) + unused_section_number = sec->target_index+1; + + name = bfd_alloc (abfd, strlen (in->n_name) + 10); + if (name == NULL) + return; + strcpy (name, in->n_name); + sec = bfd_make_section_anyway (abfd, name); + + sec->vma = 0; + sec->lma = 0; + sec->_cooked_size = 0; + sec->_raw_size = 0; + sec->filepos = 0; + sec->rel_filepos = 0; + sec->reloc_count = 0; + sec->line_filepos = 0; + sec->lineno_count = 0; + sec->userdata = NULL; + sec->next = (asection *) NULL; + sec->flags = 0; + sec->alignment_power = 2; + sec->flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD; + + sec->target_index = unused_section_number; + + in->n_scnum = unused_section_number; + } + in->n_sclass = C_STAT; +#endif + } +#endif + +#ifdef coff_swap_sym_in_hook + /* This won't work in peigen.c, but since it's for PPC PE, it's not + worth fixing. */ + coff_swap_sym_in_hook(abfd, ext1, in1); +#endif +} + +unsigned int +_bfd_pei_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 { + memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); + } + + 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; +} + +void +_bfd_pei_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) + bfd *abfd; + PTR ext1; + int type; + int class; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; + 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 { + memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); + } + return; + + + case C_STAT: + case C_LEAFSTAT: + 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); + in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx); + + 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 + { + 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); + } +} + +unsigned int +_bfd_pei_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) + bfd *abfd; + PTR inp; + int type; + int class; + int indx ATTRIBUTE_UNUSED; + int numaux ATTRIBUTE_UNUSED; + 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 { + memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); + } + return AUXESZ; + + + case C_STAT: + case C_LEAFSTAT: + 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); + bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx); + + 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 + { + 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; +} + +void +_bfd_pei_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); +} + +unsigned int +_bfd_pei_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; +} + +void +_bfd_pei_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 + +} + +/* A support function for below. */ + +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; + } +} + +unsigned int +_bfd_pei_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", 0); + + /* Don't call add_data_entry for .idata$2 or .idata$5. It's done in + bfd_coff_final_link where all the required information is + available. */ + + /* However, until other .idata fixes are made (pending patch), the + entry for .idata is needed for backwards compatability. FIXME. */ + add_data_entry (abfd, extra, 1, ".idata" ,0); + + add_data_entry (abfd, extra, 2, ".rsrc" ,0); + + add_data_entry (abfd, extra, 3, ".pdata", 0); + + /* For some reason, the virtual size (which is what's set by + add_data_entry) for .reloc is not the same as the size recorded + in this slot by MSVC; it doesn't seem to cause problems (so far), + but since it's the best we've got, use it. It does do the right + thing for .pdata. */ + if (pe_data (abfd)->has_reloc_section) + add_data_entry (abfd, extra, 5, ".reloc", 0); + + { + 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; + /* The image size is the total VIRTUAL size (which is what is + in the virt_size field). Files have been seen (from MSVC + 5.0 link.exe) where the file size of the .data segment is + quite small compared to the virtual size. Without this + fix, strip munges the file. */ + isize += SA (FA (pei_section_data (abfd, sec)->virt_size)); + } + + 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); + +#define LINKER_VERSION 256 /* That is, 2.56 */ + + /* This piece of magic sets the "linker version" field to + LINKER_VERSION. */ + bfd_h_put_16 (abfd, + LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256, + (bfd_byte *) aouthdr_out->standard.vstamp); + + 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; +} + +unsigned int +_bfd_pei_only_swap_filehdr_out (abfd, in, out) + bfd *abfd; + PTR in; + PTR out; +{ + int idx; + struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in; + struct external_PEI_filehdr *filehdr_out = (struct external_PEI_filehdr *)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; +} + +unsigned int +_bfd_pe_only_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; +} + +unsigned int +_bfd_pei_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, but zero if it has no content (as in .bss, + sometimes). */ + + if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 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); + + + /* s_paddr in PE is really the virtual 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... */ + + { + int flags = scnhdr_int->s_flags; + bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags); + } + + if (coff_data (abfd)->link_info + && ! coff_data (abfd)->link_info->relocateable + && ! coff_data (abfd)->link_info->shared + && strcmp (scnhdr_int->s_name, ".text") == 0) + { + /* By inference from looking at MS output, the 32 bit field + which is the combintion of the number_of_relocs and + number_of_linenos is used for the line number count in + executables. A 16-bit field won't do for cc1. The MS + document says that the number of relocs is zero for + executables, but the 17-th bit has been observed to be there. + Overflow is not an issue: a 4G-line program will overflow a + bunch of other fields long before this! */ + bfd_h_put_16 (abfd, scnhdr_int->s_nlnno & 0xffff, + (bfd_byte *) scnhdr_ext->s_nlnno); + bfd_h_put_16 (abfd, scnhdr_int->s_nlnno >> 16, + (bfd_byte *) scnhdr_ext->s_nreloc); + } + else + { + 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") +}; + +/**********************************************************************/ +#ifdef POWERPC_LE_PE +/* The code for the PPC really falls in the "architecture dependent" + category. However, it's not clear that anyone will ever care, so + we're ignoring the issue for now; if/when PPC matters, some of this + may need to go into peicode.h, or arguments passed to enable the + PPC- specific code. */ +#endif + +/**********************************************************************/ +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; + 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; + + fprintf (file, _("\nThe import table is the .idata section\n")); + } + else + { + /* idata buried in some other section: e.g. KERNEL32.DLL. */ + 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 (addr >= section->vma + && addr < section->vma + bfd_section_size(abfd,section)) + break; + } + if (section == NULL) + { + fprintf (file, + _("\nThere is an import table, but the section containing it could not be found\n")); + return true; + } + + fprintf (file, _("\nThere is an import table in %s at 0x%lx\n"), + section->name, (unsigned long)addr); + + dataoff = addr - section->vma; + 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 = - section->vma; + + for (i = 0; i < datasize; 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 > datasize) + { + /* check stuff */ + ; + } + + hint_addr = bfd_get_32 (abfd, data + i + dataoff); + time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff); + forward_chain = bfd_get_32 (abfd, data + i + 8 + dataoff); + dll_name = bfd_get_32 (abfd, data + i + 12 + dataoff); + first_thunk = bfd_get_32 (abfd, data + i + 16 + dataoff); + + 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; + + dll = (char *) data + dll_name - section->vma + dataoff; + 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 < datasize; 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 < datasize; 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; + fprintf (file, _("\nThe export table is the .edata section\n")); + } + else + { + /* edata is buried in some other section: e.g. NTDLL.DLL. */ + 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 (addr >= section->vma + && addr < section->vma + bfd_section_size (abfd, section)) + break; + } + if (section == NULL) + { + fprintf (file, + _("\nThere is an export table, but the section containing it could not be found\n")); + return true; + } + + fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), + section->name, (unsigned long) addr); + + datasize = size; + dataoff = addr - section->vma; + } + + 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 = - (section->vma + dataoff); + + /* 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 is 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 = eat_member; + bfd_vma edata_start = bfd_get_section_vma (abfd, section); + 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 == NULL + || coff_section_data (abfd, section) == NULL + || pei_section_data (abfd, section) == NULL) + return true; + + stop = pei_section_data (abfd, section)->virt_size; + 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 Exception\n")); + fprintf (file, + _(" \t\tAddress Address Handler Data Address Mask\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; + int em_data; + + 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)); + + em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3); + eh_handler &= 0xfffffffc; + prolog_end_addr &= 0xfffffffc; + + fprintf (file, "%08lx %08lx %08lx %08lx %08lx %x", + begin_addr, + end_addr, + eh_handler, + eh_data, + prolog_end_addr, + em_data); + +#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; +} + +#define IMAGE_REL_BASED_HIGHADJ 4 +static const char * const tbl[] = +{ +"ABSOLUTE", +"HIGH", +"LOW", +"HIGHLOW", +"HIGHADJ", +"MIPS_JMPADDR", +"UNKNOWN", /* MUST be last */ +}; + +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 == NULL) + 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); + unsigned int t = (e & 0xF000) >> 12; + int off = e & 0x0FFF; + + if (t >= sizeof (tbl) / sizeof (tbl[0])) + t = (sizeof (tbl) / sizeof (tbl[0])) - 1; + + fprintf (file, + _("\treloc %4d offset %4x [%4lx] %s"), + j, off, (long) (off + virtual_address), tbl[t]); + + /* HIGHADJ takes an argument, - the next record *is* the + low 16 bits of addend. */ + if (t == IMAGE_REL_BASED_HIGHADJ) + { + fprintf (file, " (%4x)", + ((unsigned int) + bfd_get_16 (abfd, data + i + 8 + j * 2 + 2))); + j++; + } + + fprintf (file, "\n"); + } + i += size; + } + + free (data); + + return true; +} + +/* Print out the program headers. */ + +boolean +_bfd_pe_print_private_bfd_data_common (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 + + /* ctime implies '\n'. */ + fprintf (file, "\nTime/Date\t\t%s", ctime (&pe->coff.timestamp)); + 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); + + return true; +} + +/* Copy any private info we understand from the input bfd + to the output bfd. */ + +boolean +_bfd_pe_bfd_copy_private_bfd_data_common (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; + + /* for strip: if we removed .reloc, we'll make a real mess of things + if we don't remove this entry as well. */ + if (! pe_data (obfd)->has_reloc_section) + { + pe_data(obfd)->pe_opthdr.DataDirectory[5].VirtualAddress = 0; + pe_data(obfd)->pe_opthdr.DataDirectory[5].Size = 0; + } + return true; +} + +/* Copy private section data. */ +boolean +_bfd_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; + pei_section_data (obfd, osec)->pe_flags = + pei_section_data (ibfd, isec)->pe_flags; + } + + return true; +} + +void +_bfd_pe_get_symbol_info (abfd, symbol, ret) + bfd *abfd; + asymbol *symbol; + symbol_info *ret; +{ + coff_get_symbol_info (abfd, symbol, ret); + + if (pe_data (abfd) != NULL + && ((symbol->flags & BSF_DEBUGGING) == 0 + || (symbol->flags & BSF_DEBUGGING_RELOC) != 0) + && ! bfd_is_abs_section (symbol->section)) + ret->value += pe_data (abfd)->pe_opthdr.ImageBase; +} + +/* Handle the .idata section and other things that need symbol table + access. */ + +boolean +_bfd_pei_final_link_postscript (abfd, pfinfo) + bfd *abfd; + struct coff_final_link_info *pfinfo; +{ + struct coff_link_hash_entry *h1; + struct bfd_link_info *info = pfinfo->info; + + /* There are a few fields that need to be filled in now while we + have symbol table access. + + The .idata subsections aren't directly available as sections, but + they are in the symbol table, so get them from there. */ + + /* The import directory. This is the address of .idata$2, with size + of .idata$2 + .idata$3. */ + h1 = coff_link_hash_lookup (coff_hash_table (info), + ".idata$2", false, false, true); + if (h1 != NULL) + { + pe_data(abfd)->pe_opthdr.DataDirectory[1].VirtualAddress = + (h1->root.u.def.value + + h1->root.u.def.section->output_section->vma + + h1->root.u.def.section->output_offset); + h1 = coff_link_hash_lookup (coff_hash_table (info), + ".idata$4", false, false, true); + pe_data (abfd)->pe_opthdr.DataDirectory[1].Size = + ((h1->root.u.def.value + + h1->root.u.def.section->output_section->vma + + h1->root.u.def.section->output_offset) + - pe_data(abfd)->pe_opthdr.DataDirectory[1].VirtualAddress); + + /* The import address table. This is the size/address of + .idata$5. */ + h1 = coff_link_hash_lookup (coff_hash_table (info), + ".idata$5", false, false, true); + pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress = + (h1->root.u.def.value + + h1->root.u.def.section->output_section->vma + + h1->root.u.def.section->output_offset); + h1 = coff_link_hash_lookup (coff_hash_table (info), + ".idata$6", false, false, true); + pe_data (abfd)->pe_opthdr.DataDirectory[12].Size = + ((h1->root.u.def.value + + h1->root.u.def.section->output_section->vma + + h1->root.u.def.section->output_offset) + - pe_data(abfd)->pe_opthdr.DataDirectory[12].VirtualAddress); + } + + /* If we couldn't find idata$2, we either have an excessively + trivial program or are in DEEP trouble; we have to assume trivial + program.... */ + return true; +} diff --git a/bfd/po/POTFILES.in b/bfd/po/POTFILES.in index ae49966..51a980b 100644 --- a/bfd/po/POTFILES.in +++ b/bfd/po/POTFILES.in @@ -1,9 +1,6 @@ -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 @@ -14,7 +11,8 @@ aout64.c aoutf1.h aoutx.h archive.c -bfd-in.h +archures.c +armnetbsd.c bfd.c binary.c bout.c @@ -36,10 +34,8 @@ 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 @@ -55,9 +51,6 @@ 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 @@ -69,26 +62,27 @@ cpu-fr30.c cpu-h8300.c cpu-h8500.c cpu-hppa.c +cpu-i370.c cpu-i386.c cpu-i860.c cpu-i960.c cpu-m10200.c -cpu-sh.c -elf-m10300.c +cpu-m10300.c +cpu-m32r.c cpu-m68k.c cpu-m88k.c cpu-mcore.c -elf32-m32r.c +cpu-mips.c cpu-ns32k.c +cpu-pj.c cpu-powerpc.c cpu-rs6000.c -libbfd.h +cpu-sh.c 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 @@ -100,7 +94,7 @@ ecofflink.c ecoffswap.h elf-bfd.h elf-m10200.c -libhppa.h +elf-m10300.c elf.c elf32-arc.c elf32-arm.h @@ -108,15 +102,16 @@ elf32-d10v.c elf32-d30v.c elf32-fr30.c elf32-gen.c -elf32-hppa.c -elf32-hppa.h +elf32-i370.c elf32-i386.c elf32-i860.c -reloc.c +elf32-i960.c +elf32-m32r.c elf32-m68k.c elf32-m88k.c elf32-mcore.c -targets.c +elf32-mips.c +elf32-pj.c elf32-ppc.c elf32-sh.c elf32-sparc.c @@ -133,20 +128,15 @@ 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 @@ -163,24 +153,23 @@ ihex.c init.c irix-core.c libaout.h -libbfd-in.h libbfd.c -libcoff-in.h +libbfd.h libcoff.h libecoff.h +libhppa.h libieee.h libnlm.h liboasys.h +libpei.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 @@ -208,11 +197,11 @@ pei-i386.c pei-mcore.c pei-ppc.c peicode.h +peigen.c ppcboot.c -ptrace-core.c +reloc.c reloc16.c riscix.c -rs6000-core.c sco5-core.c section.c som.c @@ -225,7 +214,7 @@ stab-syms.c stabs.c sunos.c syms.c -sysdep.h +targets.c tekhex.c trad-core.c vaxnetbsd.c @@ -237,28 +226,3 @@ 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 index f7ffbb4..b423792 100644 --- a/bfd/po/bfd.pot +++ b/bfd/po/bfd.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-04-18 18:26-0400\n" +"POT-Creation-Date: 2000-02-25 22:13-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -14,41 +14,41 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: ENCODING\n" -#: aout-adobe.c:182 +#: aout-adobe.c:183 #, c-format msgid "%s: Unknown section type in a.out.adobe file: %x\n" msgstr "" -#: aoutx.h:1237 aoutx.h:1651 +#: aoutx.h:1244 aoutx.h:1658 #, c-format msgid "%s: can not represent section `%s' in a.out object file format" msgstr "" -#: aoutx.h:1621 +#: aoutx.h:1628 #, c-format msgid "" "%s: can not represent section for symbol `%s' in a.out object file format" msgstr "" -#: aoutx.h:1623 +#: aoutx.h:1630 msgid "*unknown*" msgstr "" -#: aoutx.h:3667 +#: aoutx.h:3674 #, c-format msgid "%s: relocateable link from %s to %s not supported" msgstr "" -#: archive.c:1716 +#: archive.c:1724 msgid "Warning: writing archive was slow: rewriting timestamp\n" msgstr "" -#: archive.c:1987 +#: archive.c:1990 msgid "Reading archive file mod timestamp" msgstr "" #. FIXME: bfd can't call perror. -#: archive.c:2011 +#: archive.c:2014 msgid "Writing updated armap timestamp" msgstr "" @@ -133,28 +133,42 @@ msgstr "" msgid "bfd assertion fail %s:%d" msgstr "" +#: bfd.c:697 +#, c-format +msgid "BFD internal error, aborting at %s line %d in %s\n" +msgstr "" + +#: bfd.c:701 +#, c-format +msgid "BFD internal error, aborting at %s line %d\n" +msgstr "" + +#: bfd.c:703 +msgid "Please report this bug.\n" +msgstr "" + #: binary.c:298 #, c-format msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx." msgstr "" -#: coff-a29k.c:121 +#: coff-a29k.c:122 msgid "Missing IHCONST" msgstr "" -#: coff-a29k.c:181 +#: coff-a29k.c:182 msgid "Missing IHIHALF" msgstr "" -#: coff-a29k.c:213 +#: coff-a29k.c:214 msgid "Unrecognized reloc" msgstr "" -#: coff-a29k.c:406 +#: coff-a29k.c:427 msgid "missing IHCONST reloc" msgstr "" -#: coff-a29k.c:497 +#: coff-a29k.c:518 msgid "missing IHIHALF reloc" msgstr "" @@ -162,141 +176,146 @@ msgstr "" msgid "GP relative relocation used when GP not defined" msgstr "" -#: coff-alpha.c:1486 elf64-alpha.c:4051 +#: coff-alpha.c:1486 elf64-alpha.c:3984 msgid "using multiple gp values" msgstr "" -#: coff-alpha.c:1992 coff-mips.c:1435 elf32-mips.c:5175 +#: coff-alpha.c:1992 coff-mips.c:1435 msgid "GP relative relocation when GP not defined" msgstr "" -#: coff-arm.c:884 +#: coff-arm.c:895 elf32-arm.h:258 #, c-format msgid "%s: unable to find THUMB glue '%s' for `%s'" msgstr "" -#: coff-arm.c:913 +#: coff-arm.c:924 elf32-arm.h:291 #, c-format msgid "%s: unable to find ARM glue '%s' for `%s'" msgstr "" -#: coff-arm.c:1192 coff-arm.c:1286 +#: coff-arm.c:1199 coff-arm.c:1293 elf32-arm.h:857 elf32-arm.h:955 #, c-format msgid "%s(%s): warning: interworking not enabled." msgstr "" -#: coff-arm.c:1196 +#: coff-arm.c:1203 elf32-arm.h:958 #, c-format msgid " first occurrence: %s: arm call to thumb" msgstr "" -#: coff-arm.c:1290 +#: coff-arm.c:1297 elf32-arm.h:860 #, c-format msgid " first occurrence: %s: thumb call to arm" msgstr "" -#: coff-arm.c:1293 +#: coff-arm.c:1300 msgid " consider relinking with --support-old-code enabled" msgstr "" -#: coff-arm.c:1581 coff-tic80.c:682 cofflink.c:2722 +#: coff-arm.c:1586 coff-tic80.c:682 cofflink.c:2980 #, c-format msgid "%s: bad reloc address 0x%lx in section `%s'" msgstr "" -#: coff-arm.c:2036 +#: coff-arm.c:1923 +#, c-format +msgid "%s: illegal symbol index in reloc: %d" +msgstr "" + +#: coff-arm.c:2050 #, c-format msgid "%s: ERROR: compiled for APCS-%d whereas target %s uses APCS-%d" msgstr "" -#: coff-arm.c:2051 +#: coff-arm.c:2065 #, c-format msgid "" "%s: ERROR: passes floats in float registers whereas target %s uses integer " "registers" msgstr "" -#: coff-arm.c:2054 +#: coff-arm.c:2068 #, c-format msgid "" "%s: ERROR: passes floats in integer registers whereas target %s uses float " "registers" msgstr "" -#: coff-arm.c:2069 +#: coff-arm.c:2083 #, c-format msgid "" "%s: ERROR: compiled as position independent code, whereas target %s is " "absolute position" msgstr "" -#: coff-arm.c:2072 +#: coff-arm.c:2086 #, c-format msgid "" "%s: ERROR: compiled as absolute position code, whereas target %s is position " "independent" msgstr "" -#: coff-arm.c:2101 +#: coff-arm.c:2115 #, c-format msgid "Warning: input file %s supports interworking, whereas %s does not." msgstr "" -#: coff-arm.c:2104 +#: coff-arm.c:2118 #, c-format msgid "Warning: input file %s does not support interworking, whereas %s does." msgstr "" -#: coff-arm.c:2132 +#: coff-arm.c:2146 #, c-format msgid "private flags = %x:" msgstr "" -#: coff-arm.c:2140 +#: coff-arm.c:2154 elf32-arm.h:2088 msgid " [floats passed in float registers]" msgstr "" -#: coff-arm.c:2142 +#: coff-arm.c:2156 elf32-arm.h:2090 msgid " [floats passed in integer registers]" msgstr "" -#: coff-arm.c:2145 +#: coff-arm.c:2159 elf32-arm.h:2093 msgid " [position independent]" msgstr "" -#: coff-arm.c:2147 +#: coff-arm.c:2161 elf32-arm.h:2095 msgid " [absolute position]" msgstr "" -#: coff-arm.c:2151 +#: coff-arm.c:2165 msgid " [interworking flag not initialised]" msgstr "" -#: coff-arm.c:2153 +#: coff-arm.c:2167 msgid " [interworking supported]" msgstr "" -#: coff-arm.c:2155 +#: coff-arm.c:2169 msgid " [interworking not supported]" msgstr "" -#: coff-arm.c:2204 +#: coff-arm.c:2218 #, c-format msgid "" "Warning: Not setting interworking flag of %s, since it has already been " "specified as non-interworking" msgstr "" -#: coff-arm.c:2208 +#: coff-arm.c:2222 #, c-format msgid "Warning: Clearing the interworking flag of %s due to outside request" msgstr "" -#: coff-i960.c:135 coff-i960.c:484 +#: coff-i960.c:136 coff-i960.c:485 msgid "uncertain calling convention for non-COFF symbol" msgstr "" -#: coff-mips.c:875 elf32-mips.c:1183 +#: coff-mips.c:875 elf32-mips.c:1322 msgid "GP relative relocation when _gp not defined" msgstr "" @@ -324,289 +343,410 @@ msgstr "" msgid "ignoring reloc %s\n" msgstr "" -#: coffcode.h:3413 +#: coffcode.h:3928 #, c-format msgid "%s: warning: illegal symbol index %ld in line numbers" msgstr "" -#: coffcode.h:3427 +#: coffcode.h:3942 #, c-format msgid "%s: warning: duplicate line number information for `%s'" msgstr "" -#: coffcode.h:3748 +#: coffcode.h:4297 #, c-format msgid "%s: Unrecognized storage class %d for %s symbol `%s'" msgstr "" -#: coffcode.h:3932 +#: coffcode.h:4428 +#, c-format +msgid "warning: %s: local symbol `%s' has no section" +msgstr "" + +#: coffcode.h:4541 #, c-format msgid "%s: warning: illegal symbol index %ld in relocs" msgstr "" -#: coffcode.h:3970 +#: coffcode.h:4579 #, c-format msgid "%s: illegal relocation type %d at address 0x%lx" msgstr "" -#: coffgen.c:1607 +#: coffgen.c:1613 #, c-format msgid "%s: bad string table size %lu" msgstr "" -#: cofflink.c:423 +#: coffgen.c:2076 +#, c-format +msgid "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld" +msgstr "" + +#: cofflink.c:518 elflink.h:1568 #, c-format msgid "Warning: type of symbol `%s' changed from %d to %d in %s" msgstr "" -#: cofflink.c:2093 +#: cofflink.c:2285 #, c-format msgid "%s: relocs in section `%s', but it has no contents" msgstr "" -#: coffswap.h:879 +#: cofflink.c:2619 coffswap.h:904 #, c-format -msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff" +msgid "%s: %s: reloc overflow: 0x%lx > 0xffff" msgstr "" -#: coffswap.h:892 +#: cofflink.c:2628 coffswap.h:891 #, c-format -msgid "%s: %s: reloc overflow: 0x%lx > 0xffff" +msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff" msgstr "" -#: dwarf2.c:420 +#: dwarf2.c:429 msgid "Dwarf Error: Can't find .debug_abbrev section." msgstr "" -#: dwarf2.c:438 +#: dwarf2.c:447 #, c-format msgid "Dwarf Error: Abbrev offset (%u) bigger than abbrev size (%u)." msgstr "" -#: dwarf2.c:614 +#: dwarf2.c:627 #, c-format msgid "Dwarf Error: Invalid or unhandled FORM value: %d." msgstr "" -#: dwarf2.c:720 +#: dwarf2.c:700 +msgid "Dwarf Error: mangled line number section (bad file number)." +msgstr "" + +#: dwarf2.c:791 msgid "Dwarf Error: Can't find .debug_line section." msgstr "" -#: dwarf2.c:881 +#: dwarf2.c:963 msgid "Dwarf Error: mangled line number section." msgstr "" -#: dwarf2.c:1054 dwarf2.c:1201 +#: dwarf2.c:1151 dwarf2.c:1307 #, c-format msgid "Dwarf Error: Could not find abbrev number %d." msgstr "" -#: dwarf2.c:1162 +#: dwarf2.c:1268 #, c-format msgid "" "Dwarf Error: found dwarf version '%hu', this reader only handles version 2 " "information." msgstr "" -#: dwarf2.c:1169 +#: dwarf2.c:1275 #, c-format msgid "" "Dwarf Error: found address size '%u', this reader can not handle sizes " "greater than '%u'." msgstr "" -#: dwarf2.c:1192 +#: dwarf2.c:1298 #, c-format msgid "Dwarf Error: Bad abbrev number: %d." msgstr "" -#: ecoff.c:1308 +#: ecoff.c:1325 #, c-format msgid "Unknown basic type %d" msgstr "" -#: ecoff.c:1580 +#: ecoff.c:1597 #, c-format msgid "" "\n" " End+1 symbol: %ld" msgstr "" -#: ecoff.c:1587 ecoff.c:1590 +#: ecoff.c:1604 ecoff.c:1607 #, c-format msgid "" "\n" " First symbol: %ld" msgstr "" -#: ecoff.c:1602 +#: ecoff.c:1619 #, c-format msgid "" "\n" " End+1 symbol: %-7ld Type: %s" msgstr "" -#: ecoff.c:1609 +#: ecoff.c:1626 #, c-format msgid "" "\n" " Local symbol: %ld" msgstr "" -#: ecoff.c:1617 +#: ecoff.c:1634 #, c-format msgid "" "\n" " struct; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1622 +#: ecoff.c:1639 #, c-format msgid "" "\n" " union; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1627 +#: ecoff.c:1644 #, c-format msgid "" "\n" " enum; End+1 symbol: %ld" msgstr "" -#: ecoff.c:1633 +#: ecoff.c:1650 #, 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 +#: elf-m10200.c:455 elf-m10300.c:670 elf32-arm.h:1852 elf32-d10v.c:493 +#: elf32-fr30.c:650 elf32-m32r.c:1157 elf32-v850.c:1677 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 +#: elf-m10200.c:459 elf-m10300.c:674 elf32-arm.h:1856 elf32-d10v.c:497 +#: elf32-fr30.c:654 elf32-m32r.c:1161 elf32-v850.c:1681 msgid "internal error: unsupported relocation error" msgstr "" -#: elf-m10200.c:463 elf-m10300.c:675 elf32-d10v.c:498 elf32-m32r.c:1165 +#: elf-m10200.c:463 elf-m10300.c:678 elf32-arm.h:1860 elf32-d10v.c:501 +#: 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 +#: elf-m10200.c:467 elf-m10300.c:682 elf32-arm.h:1864 elf32-d10v.c:505 +#: elf32-fr30.c:662 elf32-m32r.c:1169 elf32-v850.c:1701 msgid "internal error: unknown error" msgstr "" -#: elf.c:320 +#: elf.c:323 #, c-format msgid "%s: invalid string offset %u >= %lu for section `%s'" msgstr "" -#: elf.c:543 +#: elf.c:546 msgid "" "\n" "Program Header:\n" msgstr "" -#: elf.c:591 +#: elf.c:594 msgid "" "\n" "Dynamic Section:\n" msgstr "" -#: elf.c:693 +#: elf.c:696 msgid "" "\n" "Version definitions:\n" msgstr "" -#: elf.c:716 +#: elf.c:719 msgid "" "\n" "Version References:\n" msgstr "" -#: elf.c:721 +#: elf.c:724 #, c-format msgid " required from %s:\n" msgstr "" -#: elf.c:1882 +#: elf.c:1286 +#, c-format +msgid "%s: invalid link %lu for reloc section %s (index %u)" +msgstr "" + +#: elf.c:2045 #, c-format msgid "" "creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = " "0x%.8lx\n" msgstr "" -#: elf.c:2481 +#: elf.c:2648 #, c-format msgid "%s: Not enough room for program headers (allocated %u, need %u)" msgstr "" -#: elf.c:2584 +#: elf.c:2747 #, c-format msgid "%s: Not enough room for program headers, try linking with -N" msgstr "" -#: elf.c:2710 +#: elf.c:2873 #, c-format msgid "Error: First section in segment (%s) starts at 0x%x" msgstr "" -#: elf.c:2713 +#: elf.c:2876 #, c-format msgid " whereas segment starts at 0x%x" msgstr "" -#: elf.c:2983 +#: elf.c:3146 #, c-format msgid "%s: warning: allocated section `%s' not in segment" msgstr "" -#: elf.c:3350 +#: elf.c:3525 #, c-format msgid "%s: symbol `%s' required but not present" msgstr "" -#: elf.c:3359 +#: elf.c:3534 #, c-format msgid "" "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = " "0x%.8lx%s\n" msgstr "" -#: elf.c:3501 +#: elf.c:3676 #, c-format msgid "%s: warning: Empty loadable segment detected\n" msgstr "" -#: elf.c:4774 +#: elf.c:4952 #, c-format msgid "%s: unsupported relocation type %s" msgstr "" -#: elf32-fr30.c:658 elf32-v850.c:1682 -msgid "internal error: dangerous relocation" +#: elf32-arm.h:1787 elf32-i386.c:1299 elf32-ppc.c:3092 +#, c-format +msgid "" +"%s: warning: unresolvable relocation against symbol `%s' from %s section" +msgstr "" + +#: elf32-arm.h:1890 +#, c-format +msgid "" +"Warning: Not setting interwork flag of %s since it has already been " +"specified as non-interworking" msgstr "" -#: elf32-hppa.c:1215 -msgid "Unsupported call to hppa_elf_reloc" +#: elf32-arm.h:1894 +#, c-format +msgid "Warning: Clearing the interwork flag of %s due to outside request" msgstr "" -#: elf32-i386.c:1293 +#: elf32-arm.h:1942 #, c-format msgid "" -"%s: warning: unresolvable relocation against symbol `%s' from %s section" +"Warning: Clearing the interwork flag in %s because non-interworking code in " +"%s has been linked with it" +msgstr "" + +#: elf32-arm.h:1976 +#, c-format +msgid "%s: compiled for a %s endian system and target is %s endian" +msgstr "" + +#: elf32-arm.h:2022 +#, c-format +msgid "Error: %s compiled for APCS-%d, whereas %s is compiled for APCS-%d" +msgstr "" + +#: elf32-arm.h:2030 +#, c-format +msgid "" +"Error: %s passes floats in %s registers, whereas %s passes them in %s " +"registers" +msgstr "" + +#: elf32-arm.h:2033 elf32-arm.h:2035 +msgid "float" +msgstr "" + +#: elf32-arm.h:2033 elf32-arm.h:2035 +msgid "integer" +msgstr "" + +#: elf32-arm.h:2038 +#, c-format +msgid "Error: %s is compiled as position %s code, whereas %s is not" +msgstr "" + +#: elf32-arm.h:2041 +msgid "independent" +msgstr "" + +#: elf32-arm.h:2041 +msgid "dependent" +msgstr "" + +#: elf32-arm.h:2047 +#, c-format +msgid "Warning: %s %s interworking, whereas %s %s" +msgstr "" + +#: elf32-arm.h:2050 +msgid "supports" +msgstr "" + +#: elf32-arm.h:2050 +msgid "does not support" +msgstr "" + +#: elf32-arm.h:2052 +msgid "does not" +msgstr "" + +#: elf32-arm.h:2052 +msgid "does" +msgstr "" + +#. Ignore init flag - it may not be set, despite the flags field containing valid data. +#: elf32-arm.h:2075 elf32-m68k.c:430 elf32-mips.c:2525 +#, c-format +msgid "private flags = %lx:" +msgstr "" + +#: elf32-arm.h:2078 +msgid " [interworking enabled]" +msgstr "" + +#: elf32-arm.h:2080 +msgid " [interworking not enabled]" +msgstr "" + +#: elf32-arm.h:2083 +msgid " [APCS-26]" +msgstr "" + +#: elf32-arm.h:2085 +msgid " [APCS-32]" +msgstr "" + +#: elf32-fr30.c:658 elf32-v850.c:1685 +msgid "internal error: dangerous relocation" +msgstr "" + +#: elf32-i386.c:239 +#, c-format +msgid "%s: invalid relocation type %d" msgstr "" #: elf32-m32r.c:808 msgid "SDA relocation when _SDA_BASE_ not defined" msgstr "" -#: elf32-m32r.c:892 elf32-ppc.c:3071 +#: elf32-m32r.c:892 elf32-ppc.c:2963 #, c-format msgid "%s: unknown relocation type %d" msgstr "" @@ -616,17 +756,1248 @@ msgstr "" msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)" msgstr "" -#: elf32-m32r.c:1906 +#: elf32-m32r.c:1902 #, c-format msgid "%s: Instruction set mismatch with previous modules" msgstr "" -#: elf32-m32r.c:1929 +#: elf32-m32r.c:1925 #, c-format msgid "private flags = %lx" msgstr "" -#: elf32-m32r.c:1934 +#: elf32-m32r.c:1930 msgid ": m32r instructions" msgstr "" +#: elf32-m32r.c:1931 +msgid ": m32rx instructions" +msgstr "" + +#: elf32-m68k.c:433 +msgid " [cpu32]" +msgstr "" + +#: elf32-mcore.c:329 +#, c-format +msgid "%s: compiled for a %s endian system and target is %s endian.\n" +msgstr "" + +#: elf32-mcore.c:377 elf32-mcore.c:504 +#, c-format +msgid "%s: Relocation %s (%d) is not currently supported.\n" +msgstr "" + +#: elf32-mcore.c:463 +#, c-format +msgid "%s: Unknown relocation type %d\n" +msgstr "" + +#: elf32-mips.c:1481 +msgid "32bits gp relative relocation occurs for an external symbol" +msgstr "" + +#: elf32-mips.c:1630 +#, c-format +msgid "Linking mips16 objects into %s format is not supported" +msgstr "" + +#: elf32-mips.c:2360 elf32-ppc.c:1408 +#, c-format +msgid "%s: compiled for a big endian system and target is little endian" +msgstr "" + +#: elf32-mips.c:2362 elf32-ppc.c:1410 +#, c-format +msgid "%s: compiled for a little endian system and target is big endian" +msgstr "" + +#: elf32-mips.c:2411 +#, c-format +msgid "%s: linking PIC files with non-PIC files" +msgstr "" + +#: elf32-mips.c:2421 +#, c-format +msgid "%s: linking abicalls files with non-abicalls files" +msgstr "" + +#: elf32-mips.c:2451 +#, c-format +msgid "%s: ISA mismatch (-mips%d) with previous modules (-mips%d)" +msgstr "" + +#: elf32-mips.c:2460 +#, c-format +msgid "%s: ISA mismatch (%d) with previous modules (%d)" +msgstr "" + +#: elf32-mips.c:2483 +#, c-format +msgid "%s: ABI mismatch: linking %s module with previous %s modules" +msgstr "" + +#: elf32-mips.c:2497 elf32-ppc.c:1477 elf64-sparc.c:2827 +#, c-format +msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)" +msgstr "" + +#: elf32-mips.c:2528 +msgid " [abi=O32]" +msgstr "" + +#: elf32-mips.c:2530 +msgid " [abi=O64]" +msgstr "" + +#: elf32-mips.c:2532 +msgid " [abi=EABI32]" +msgstr "" + +#: elf32-mips.c:2534 +msgid " [abi=EABI64]" +msgstr "" + +#: elf32-mips.c:2536 +msgid " [abi unknown]" +msgstr "" + +#: elf32-mips.c:2538 +msgid " [abi=N32]" +msgstr "" + +#: elf32-mips.c:2540 +msgid " [abi=64]" +msgstr "" + +#: elf32-mips.c:2542 +msgid " [no abi set]" +msgstr "" + +#: elf32-mips.c:2545 +msgid " [mips1]" +msgstr "" + +#: elf32-mips.c:2547 +msgid " [mips2]" +msgstr "" + +#: elf32-mips.c:2549 +msgid " [mips3]" +msgstr "" + +#: elf32-mips.c:2551 +msgid " [mips4]" +msgstr "" + +#: elf32-mips.c:2553 +msgid " [unknown ISA]" +msgstr "" + +#: elf32-mips.c:2556 +msgid " [32bitmode]" +msgstr "" + +#: elf32-mips.c:2558 +msgid " [not 32bitmode]" +msgstr "" + +#: elf32-mips.c:4161 +msgid "static procedure (no name)" +msgstr "" + +#: elf32-mips.c:4778 elf64-alpha.c:4358 +#, c-format +msgid "%s: illegal section name `%s'" +msgstr "" + +#: elf32-mips.c:5305 +msgid "not enough GOT space for local GOT entries" +msgstr "" + +#: elf32-mips.c:6363 +#, c-format +msgid "%s: %s+0x%lx: jump to stub routine which is not jal" +msgstr "" + +#: elf32-mips.c:7342 +#, c-format +msgid "%s: CALL16 reloc at 0x%lx not against global symbol" +msgstr "" + +#: elf32-ppc.c:1443 +#, c-format +msgid "" +"%s: compiled with -mrelocatable and linked with modules compiled normally" +msgstr "" + +#: elf32-ppc.c:1451 +#, c-format +msgid "" +"%s: compiled normally and linked with modules compiled with -mrelocatable" +msgstr "" + +#: elf32-ppc.c:1578 +#, c-format +msgid "%s: Unknown special linker type %d" +msgstr "" + +#: elf32-ppc.c:2251 elf32-ppc.c:2285 elf32-ppc.c:2320 +#, c-format +msgid "%s: relocation %s cannot be used when making a shared object" +msgstr "" + +#: elf32-ppc.c:3121 +#, c-format +msgid "%s: unknown relocation type %d for symbol %s" +msgstr "" + +#: elf32-ppc.c:3488 elf32-ppc.c:3510 elf32-ppc.c:3559 +#, c-format +msgid "" +"%s: The target (%s) of a %s relocation is in the wrong output section (%s)" +msgstr "" + +#: elf32-ppc.c:3625 +#, c-format +msgid "%s: Relocation %s is not yet supported for symbol %s." +msgstr "" + +#: elf32-sh.c:681 +#, c-format +msgid "%s: 0x%lx: warning: bad R_SH_USES offset" +msgstr "" + +#: elf32-sh.c:693 +#, c-format +msgid "%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x" +msgstr "" + +#: elf32-sh.c:710 +#, c-format +msgid "%s: 0x%lx: warning: bad R_SH_USES load offset" +msgstr "" + +#: elf32-sh.c:725 +#, c-format +msgid "%s: 0x%lx: warning: could not find expected reloc" +msgstr "" + +#: elf32-sh.c:762 +#, c-format +msgid "%s: 0x%lx: warning: symbol in unexpected section" +msgstr "" + +#: elf32-sh.c:884 +#, c-format +msgid "%s: 0x%lx: warning: could not find expected COUNT reloc" +msgstr "" + +#: elf32-sh.c:893 +#, c-format +msgid "%s: 0x%lx: warning: bad count" +msgstr "" + +#: elf32-sh.c:1279 elf32-sh.c:1666 +#, c-format +msgid "%s: 0x%lx: fatal: reloc overflow while relaxing" +msgstr "" + +#: elf32-sparc.c:1484 elf64-sparc.c:2240 +#, c-format +msgid "%s: probably compiled without -fPIC?" +msgstr "" + +#: elf32-sparc.c:1854 +#, c-format +msgid "%s: compiled for a v8plus system and target is v8" +msgstr "" + +#: elf32-sparc.c:1863 +#, c-format +msgid "%s: compiled for a v8plusa system and target is v8plus" +msgstr "" + +#: elf32-sparc.c:1871 +#, c-format +msgid "%s: compiled for a 64 bit system and target is 32 bit" +msgstr "" + +#: elf32-sparc.c:1883 +#, c-format +msgid "%s: linking little endian files with big endian files" +msgstr "" + +#: elf32-v850.c:680 +#, c-format +msgid "Variable `%s' cannot occupy in multiple small data regions" +msgstr "" + +#: elf32-v850.c:683 +#, c-format +msgid "" +"Variable `%s' can only be in one of the small, zero, and tiny data regions" +msgstr "" + +#: elf32-v850.c:686 +#, c-format +msgid "" +"Variable `%s' cannot be in both small and zero data regions simultaneously" +msgstr "" + +#: elf32-v850.c:689 +#, c-format +msgid "" +"Variable `%s' cannot be in both small and tiny data regions simultaneously" +msgstr "" + +#: elf32-v850.c:692 +#, c-format +msgid "" +"Variable `%s' cannot be in both zero and tiny data regions simultaneously" +msgstr "" + +#: elf32-v850.c:1070 +msgid "FAILED to find previous HI16 reloc\n" +msgstr "" + +#: elf32-v850.c:1689 +msgid "could not locate special linker symbol __gp" +msgstr "" + +#: elf32-v850.c:1693 +msgid "could not locate special linker symbol __ep" +msgstr "" + +#: elf32-v850.c:1697 +msgid "could not locate special linker symbol __ctbp" +msgstr "" + +#: elf32-v850.c:1886 +#, c-format +msgid "%s: Architecture mismatch with previous modules" +msgstr "" + +#: elf32-v850.c:1905 +#, c-format +msgid "private flags = %lx: " +msgstr "" + +#: elf32-v850.c:1910 +msgid "v850 architecture" +msgstr "" + +#: elf32-v850.c:1911 +msgid "v850e architecture" +msgstr "" + +#: elf32-v850.c:1912 +msgid "v850ea architecture" +msgstr "" + +#: elf64-alpha.c:947 +msgid "GPDISP relocation did not find ldah and lda instructions" +msgstr "" + +#: elf64-alpha.c:2999 +#, c-format +msgid "%s: .got subsegment exceeds 64K (size %d)" +msgstr "" + +#: elf64-sparc.c:1248 +#, c-format +msgid "%s: check_relocs: unhandled reloc type %d" +msgstr "" + +#: elf64-sparc.c:1285 +msgid "%s: Only registers %%g[2367] can be declared using STT_REGISTER" +msgstr "" + +#: elf64-sparc.c:1305 +msgid "" +"Register %%g%d used incompatibly: previously declared in %s to %s, in %s " +"redefined to %s" +msgstr "" + +#: elf64-sparc.c:1328 +#, c-format +msgid "Symbol `%s' has differing types: previously %s, REGISTER in %s" +msgstr "" + +#: elf64-sparc.c:1374 +#, c-format +msgid "Symbol `%s' has differing types: REGISTER in %s, %s in %s" +msgstr "" + +#: elf64-sparc.c:2809 +#, c-format +msgid "%s: linking UltraSPARC specific with HAL specific code" +msgstr "" + +#: elfcode.h:1061 +#, c-format +msgid "%s: version count (%ld) does not match symbol count (%ld)" +msgstr "" + +#: elflink.c:423 +#, c-format +msgid "%s: Section %s is already to large to put hole of %ld bytes in" +msgstr "" + +#: elflink.h:1388 +#, c-format +msgid "%s: %s: invalid version %u (max %d)" +msgstr "" + +#: elflink.h:1429 +#, c-format +msgid "%s: %s: invalid needed version %d" +msgstr "" + +#: elflink.h:1546 +#, c-format +msgid "Warning: size of symbol `%s' changed from %lu to %lu in %s" +msgstr "" + +#: elflink.h:1790 +#, c-format +msgid "%s: warning: unexpected redefinition of `%s'" +msgstr "" + +#: elflink.h:3480 +#, c-format +msgid "warning: type and size of dynamic symbol `%s' are not defined" +msgstr "" + +#: elflink.h:3752 +#, c-format +msgid "%s: undefined versioned symbol name %s" +msgstr "" + +#: elflink.h:4981 +#, c-format +msgid "%s: could not find output section %s for input section %s" +msgstr "" + +#: i386linux.c:450 m68klinux.c:454 sparclinux.c:452 +#, c-format +msgid "Output file requires shared library `%s'\n" +msgstr "" + +#: i386linux.c:458 m68klinux.c:462 sparclinux.c:460 +#, c-format +msgid "Output file requires shared library `%s.so.%s'\n" +msgstr "" + +#: i386linux.c:646 i386linux.c:696 m68klinux.c:653 m68klinux.c:701 +#: sparclinux.c:649 sparclinux.c:699 +#, c-format +msgid "Symbol %s not defined for fixups\n" +msgstr "" + +#: i386linux.c:720 m68klinux.c:725 sparclinux.c:723 +msgid "Warning: fixup count mismatch\n" +msgstr "" + +#: ieee.c:167 +#, c-format +msgid "%s: string too long (%d chars, max 65535)" +msgstr "" + +#: ieee.c:297 +#, c-format +msgid "%s: unrecognized symbol `%s' flags 0x%x" +msgstr "" + +#: ieee.c:793 +#, c-format +msgid "%s: unimplemented ATI record %u for symbol %u" +msgstr "" + +#: ieee.c:818 +#, c-format +msgid "%s: unexpected ATN type %d in external part" +msgstr "" + +#: ieee.c:840 +#, c-format +msgid "%s: unexpected type after ATN" +msgstr "" + +#: ihex.c:259 +#, c-format +msgid "%s:%d: unexpected character `%s' in Intel Hex file\n" +msgstr "" + +#: ihex.c:369 +#, c-format +msgid "%s:%d: bad checksum in Intel Hex file (expected %u, found %u)" +msgstr "" + +#: ihex.c:421 +#, c-format +msgid "%s:%d: bad extended address record length in Intel Hex file" +msgstr "" + +#: ihex.c:438 +#, c-format +msgid "%s:%d: bad extended start address length in Intel Hex file" +msgstr "" + +#: ihex.c:455 +#, c-format +msgid "%s:%d: bad extended linear address record length in Intel Hex file" +msgstr "" + +#: ihex.c:472 +#, c-format +msgid "%s:%d: bad extended linear start address length in Intel Hex file" +msgstr "" + +#: ihex.c:489 +#, c-format +msgid "%s:%d: unrecognized ihex type %u in Intel Hex file\n" +msgstr "" + +#: ihex.c:609 +#, c-format +msgid "%s: internal error in ihex_read_section" +msgstr "" + +#: ihex.c:644 +#, c-format +msgid "%s: bad section length in ihex_read_section" +msgstr "" + +#: ihex.c:858 +#, c-format +msgid "%s: address 0x%s out of range for Intex Hex file" +msgstr "" + +#: libbfd.c:484 +#, c-format +msgid "not mapping: data=%lx mapped=%d\n" +msgstr "" + +#: libbfd.c:487 +msgid "not mapping: env var not set\n" +msgstr "" + +#: linker.c:2679 +#, c-format +msgid "Attempt to do relocateable link with %s input and %s output" +msgstr "" + +#: oasys.c:1016 +#, c-format +msgid "%s: can not represent section `%s' in oasys" +msgstr "" + +#: osf-core.c:146 +#, c-format +msgid "Unhandled OSF/1 core file section type %d\n" +msgstr "" + +#: peicode.h:395 +#, c-format +msgid "%s: Import Library Format archives are not currently supported" +msgstr "" + +#: peigen.c:938 +#, c-format +msgid "%s: line number overflow: 0x%lx > 0xffff" +msgstr "" + +#: peigen.c:950 +#, c-format +msgid "%s: reloc overflow: 0x%lx > 0xffff" +msgstr "" + +#: peigen.c:963 +msgid "Export Directory [.edata (or where ever we found it)]" +msgstr "" + +#: peigen.c:964 +msgid "Import Directory [parts of .idata]" +msgstr "" + +#: peigen.c:965 +msgid "Resource Directory [.rsrc]" +msgstr "" + +#: peigen.c:966 +msgid "Exception Directory [.pdata]" +msgstr "" + +#: peigen.c:967 +msgid "Security Directory" +msgstr "" + +#: peigen.c:968 +msgid "Base Relocation Directory [.reloc]" +msgstr "" + +#: peigen.c:969 +msgid "Debug Directory" +msgstr "" + +#: peigen.c:970 +msgid "Description Directory" +msgstr "" + +#: peigen.c:971 +msgid "Special Directory" +msgstr "" + +#: peigen.c:972 +msgid "Thread Storage Directory [.tls]" +msgstr "" + +#: peigen.c:973 +msgid "Load Configuration Directory" +msgstr "" + +#: peigen.c:974 +msgid "Bound Import Directory" +msgstr "" + +#: peigen.c:975 +msgid "Import Address Table Directory" +msgstr "" + +#: peigen.c:976 peigen.c:977 peigen.c:978 +msgid "Reserved" +msgstr "" + +#: peigen.c:1022 +msgid "" +"\n" +"The import table is the .idata section\n" +msgstr "" + +#: peigen.c:1044 +msgid "" +"\n" +"There is an import table, but the section containing it could not be found\n" +msgstr "" + +#: peigen.c:1048 +#, c-format +msgid "" +"\n" +"There is an import table in %s at 0x%lx\n" +msgstr "" + +#: peigen.c:1089 +#, c-format +msgid "" +"\n" +"Function descriptor located at the start address: %04lx\n" +msgstr "" + +#: peigen.c:1092 +#, c-format +msgid "\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n" +msgstr "" + +#: peigen.c:1098 +msgid "" +"\n" +"No reldata section! Function descriptor not decoded.\n" +msgstr "" + +#: peigen.c:1103 +msgid "" +"\n" +"The Import Tables (interpreted .idata section contents)\n" +msgstr "" + +#: peigen.c:1105 +msgid " vma: Hint Time Forward DLL First\n" +msgstr "" + +#: peigen.c:1107 +msgid " Table Stamp Chain Name Thunk\n" +msgstr "" + +#: peigen.c:1157 +#, c-format +msgid "" +"\n" +"\tDLL Name: %s\n" +msgstr "" + +#: peigen.c:1161 peigen.c:1224 +msgid "\tvma: Hint/Ord Member-Name\n" +msgstr "" + +#: peigen.c:1223 +msgid "\tThe Import Address Table (difference found)\n" +msgstr "" + +#: peigen.c:1230 +msgid "\t>>> Ran out of IAT members!\n" +msgstr "" + +#: peigen.c:1248 +msgid "\tThe Import Address Table is identical\n" +msgstr "" + +#: peigen.c:1297 +msgid "" +"\n" +"The export table is the .edata section\n" +msgstr "" + +#: peigen.c:1319 +msgid "" +"\n" +"There is an export table, but the section containing it could not be found\n" +msgstr "" + +#: peigen.c:1323 +#, c-format +msgid "" +"\n" +"There is an export table in %s at 0x%lx\n" +msgstr "" + +#: peigen.c:1355 +msgid "" +"\n" +"The Export Tables (interpreted .edata section contents)\n" +"\n" +msgstr "" + +#: peigen.c:1358 +#, c-format +msgid "Export Flags \t\t\t%lx\n" +msgstr "" + +#: peigen.c:1361 +#, c-format +msgid "Time/Date stamp \t\t%lx\n" +msgstr "" + +#: peigen.c:1364 +#, c-format +msgid "Major/Minor \t\t\t%d/%d\n" +msgstr "" + +#: peigen.c:1367 +msgid "Name \t\t\t\t" +msgstr "" + +#: peigen.c:1373 +#, c-format +msgid "Ordinal Base \t\t\t%ld\n" +msgstr "" + +#: peigen.c:1376 +msgid "Number in:\n" +msgstr "" + +#: peigen.c:1379 +#, c-format +msgid "\tExport Address Table \t\t%lx\n" +msgstr "" + +#: peigen.c:1383 +#, c-format +msgid "\t[Name Pointer/Ordinal] Table\t%lu\n" +msgstr "" + +#: peigen.c:1386 +msgid "Table Addresses\n" +msgstr "" + +#: peigen.c:1389 +msgid "\tExport Address Table \t\t" +msgstr "" + +#: peigen.c:1394 +msgid "\tName Pointer Table \t\t" +msgstr "" + +#: peigen.c:1399 +msgid "\tOrdinal Table \t\t\t" +msgstr "" + +#: peigen.c:1415 +#, c-format +msgid "" +"\n" +"Export Address Table -- Ordinal Base %ld\n" +msgstr "" + +#: peigen.c:1436 +msgid "Forwarder RVA" +msgstr "" + +#: peigen.c:1444 +msgid "Export RVA" +msgstr "" + +#: peigen.c:1451 +msgid "" +"\n" +"[Ordinal/Name Pointer] Table\n" +msgstr "" + +#: peigen.c:1496 +#, c-format +msgid "Warning, .pdata section size (%ld) is not a multiple of %d\n" +msgstr "" + +#: peigen.c:1500 +msgid "" +"\n" +"The Function Table (interpreted .pdata section contents)\n" +msgstr "" + +#: peigen.c:1502 +msgid " vma:\t\tBegin End EH EH PrologEnd Exception\n" +msgstr "" + +#: peigen.c:1504 +msgid " \t\tAddress Address Handler Data Address Mask\n" +msgstr "" + +#: peigen.c:1576 +msgid " Register save millicode" +msgstr "" + +#: peigen.c:1579 +msgid " Register restore millicode" +msgstr "" + +#: peigen.c:1582 +msgid " Glue code sequence" +msgstr "" + +#: peigen.c:1628 +msgid "" +"\n" +"\n" +"PE File Base Relocations (interpreted .reloc section contents)\n" +msgstr "" + +#: peigen.c:1663 +#, c-format +msgid "" +"\n" +"Virtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n" +msgstr "" + +#: peigen.c:1676 +#, c-format +msgid "\treloc %4d offset %4x [%4lx] %s" +msgstr "" + +#. The MS dumpbin program reportedly ands with 0xff0f before +#. printing the characteristics field. Not sure why. No reason to +#. emulate it here. +#: peigen.c:1715 +#, c-format +msgid "" +"\n" +"Characteristics 0x%x\n" +msgstr "" + +#: ppcboot.c:418 +msgid "" +"\n" +"ppcboot header:\n" +msgstr "" + +#: ppcboot.c:419 +#, c-format +msgid "Entry offset = 0x%.8lx (%ld)\n" +msgstr "" + +#: ppcboot.c:420 +#, c-format +msgid "Length = 0x%.8lx (%ld)\n" +msgstr "" + +#: ppcboot.c:423 +#, c-format +msgid "Flag field = 0x%.2x\n" +msgstr "" + +#: ppcboot.c:429 +#, c-format +msgid "Partition name = \"%s\"\n" +msgstr "" + +#: ppcboot.c:448 +#, c-format +msgid "" +"\n" +"Partition[%d] start = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n" +msgstr "" + +#: ppcboot.c:454 +#, c-format +msgid "Partition[%d] end = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n" +msgstr "" + +#: ppcboot.c:460 +#, c-format +msgid "Partition[%d] sector = 0x%.8lx (%ld)\n" +msgstr "" + +#: ppcboot.c:461 +#, c-format +msgid "Partition[%d] length = 0x%.8lx (%ld)\n" +msgstr "" + +#: som.c:5335 +msgid "som_sizeof_headers unimplemented" +msgstr "" + +#: srec.c:290 +#, c-format +msgid "%s:%d: Unexpected character `%s' in S-record file\n" +msgstr "" + +#: syms.c:974 +msgid "Unsupported .stab relocation" +msgstr "" + +#: vms-gsd.c:357 +#, c-format +msgid "bfd_make_section (%s) failed" +msgstr "" + +#: vms-gsd.c:371 +#, c-format +msgid "bfd_set_section_flags (%s, %x) failed" +msgstr "" + +#: vms-gsd.c:407 +#, c-format +msgid "Size mismatch section %s=%lx, %s=%lx" +msgstr "" + +#: vms-gsd.c:702 +#, c-format +msgid "unknown gsd/egsd subtype %d" +msgstr "" + +#: vms-hdr.c:405 +msgid "Object module NOT error-free !\n" +msgstr "" + +#: vms-misc.c:541 +#, c-format +msgid "Stack overflow (%d) in _bfd_vms_push" +msgstr "" + +#: vms-misc.c:560 +msgid "Stack underflow in _bfd_vms_pop" +msgstr "" + +#: vms-misc.c:931 +msgid "_bfd_vms_output_counted called with zero bytes" +msgstr "" + +#: vms-misc.c:936 +msgid "_bfd_vms_output_counted called with too many bytes" +msgstr "" + +#: vms-misc.c:1069 +#, c-format +msgid "Symbol %s replaced by %s\n" +msgstr "" + +#: vms-misc.c:1133 +#, c-format +msgid "failed to enter %s" +msgstr "" + +#: vms-tir.c:69 +msgid "No Mem !" +msgstr "" + +#: vms-tir.c:309 +msgid "Bad section index in ETIR_S_C_STA_PQ" +msgstr "" + +#: vms-tir.c:324 +#, c-format +msgid "Unsupported STA cmd %d" +msgstr "" + +#: vms-tir.c:329 vms-tir.c:1287 +#, c-format +msgid "Reserved STA cmd %d" +msgstr "" + +#: vms-tir.c:436 +#, c-format +msgid "ETIR_S_C_STO_GBL: no symbol \"%s\"" +msgstr "" + +#: vms-tir.c:457 +#, c-format +msgid "ETIR_S_C_STO_CA: no symbol \"%s\"" +msgstr "" + +#: vms-tir.c:470 +msgid "ETIR_S_C_STO_RB/AB: Not supported" +msgstr "" + +#: vms-tir.c:528 +msgid "ETIR_S_C_STO_LP_PSB: Not supported" +msgstr "" + +#: vms-tir.c:534 +msgid "ETIR_S_C_STO_HINT_GBL: not implemented" +msgstr "" + +#: vms-tir.c:540 +msgid "ETIR_S_C_STO_HINT_PS: not implemented" +msgstr "" + +#: vms-tir.c:544 vms-tir.c:1460 +#, c-format +msgid "Reserved STO cmd %d" +msgstr "" + +#: vms-tir.c:657 +msgid "ETIR_S_C_OPR_INSV: Not supported" +msgstr "" + +#: vms-tir.c:675 +msgid "ETIR_S_C_OPR_USH: Not supported" +msgstr "" + +#: vms-tir.c:681 +msgid "ETIR_S_C_OPR_ROT: Not supported" +msgstr "" + +#: vms-tir.c:700 +msgid "ETIR_S_C_OPR_REDEF: Not supported" +msgstr "" + +#: vms-tir.c:706 +msgid "ETIR_S_C_OPR_DFLIT: Not supported" +msgstr "" + +#: vms-tir.c:710 vms-tir.c:1656 +#, c-format +msgid "Reserved OPR cmd %d" +msgstr "" + +#: vms-tir.c:779 vms-tir.c:1726 +#, c-format +msgid "Reserved CTL cmd %d" +msgstr "" + +#: vms-tir.c:808 +msgid "ETIR_S_C_STC_LP: not supported" +msgstr "" + +#: vms-tir.c:826 +msgid "ETIR_S_C_STC_GBL: not supported" +msgstr "" + +#: vms-tir.c:834 +msgid "ETIR_S_C_STC_GCA: not supported" +msgstr "" + +#: vms-tir.c:843 +msgid "ETIR_S_C_STC_PS: not supported" +msgstr "" + +#. +#. * stack byte from image +#. * arg: - +#. * +#. +#: vms-tir.c:1187 +msgid "Stack-from-image not implemented" +msgstr "" + +#: vms-tir.c:1207 +msgid "Stack-entry-mask not fully implemented" +msgstr "" + +#. +#. * 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 +#. +#: vms-tir.c:1223 +msgid "PASSMECH not fully implemented" +msgstr "" + +#: vms-tir.c:1243 +msgid "Stack-local-symbol not fully implemented" +msgstr "" + +#: vms-tir.c:1258 +msgid "Stack-literal not fully implemented" +msgstr "" + +#: vms-tir.c:1280 +msgid "Stack-local-symbol-entry-point-mask not fully implemented" +msgstr "" + +#: vms-tir.c:1456 +#, c-format +msgid "Unimplemented STO cmd %d" +msgstr "" + +#: vms-tir.c:1596 +msgid "TIR_S_C_OPR_ASH incomplete" +msgstr "" + +#: vms-tir.c:1610 +msgid "TIR_S_C_OPR_USH incomplete" +msgstr "" + +#: vms-tir.c:1624 +msgid "TIR_S_C_OPR_ROT incomplete" +msgstr "" + +#. +#. * redefine symbol to current location +#. +#: vms-tir.c:1645 +msgid "TIR_S_C_OPR_REDEF not supported" +msgstr "" + +#. +#. * define a literal +#. +#: vms-tir.c:1652 +msgid "TIR_S_C_OPR_DFLIT not supported" +msgstr "" + +#: vms-tir.c:1707 +msgid "TIR_S_C_CTL_DFLOC not fully implemented" +msgstr "" + +#: vms-tir.c:1715 +msgid "TIR_S_C_CTL_STLOC not fully implemented" +msgstr "" + +#: vms-tir.c:1723 +msgid "TIR_S_C_CTL_STKDL not fully implemented" +msgstr "" + +#: vms-tir.c:1778 +#, c-format +msgid "Obj code %d not found" +msgstr "" + +#: vms-tir.c:2127 +#, c-format +msgid "SEC_RELOC with no relocs in section %s" +msgstr "" + +#: vms-tir.c:2401 +#, c-format +msgid "Unhandled relocation %s" +msgstr "" + +#: xcofflink.c:1661 +#, c-format +msgid "%s: `%s' has line numbers but no enclosing section" +msgstr "" + +#: xcofflink.c:1713 +#, c-format +msgid "%s: class %d symbol `%s' has no aux entries" +msgstr "" + +#: xcofflink.c:1736 +#, c-format +msgid "%s: symbol `%s' has unrecognized csect type %d" +msgstr "" + +#: xcofflink.c:1748 +#, c-format +msgid "%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d" +msgstr "" + +#: xcofflink.c:1787 +#, c-format +msgid "%s: XMC_TC0 symbol `%s' is class %d scnlen %d" +msgstr "" + +#: xcofflink.c:1911 +#, c-format +msgid "%s: symbol `%s' has unrecognized smclas %d" +msgstr "" + +#: xcofflink.c:1930 +#, c-format +msgid "%s: csect `%s' not in enclosing section" +msgstr "" + +#: xcofflink.c:2034 +#, c-format +msgid "%s: misplaced XTY_LD `%s'" +msgstr "" + +#: xcofflink.c:2345 +#, c-format +msgid "%s: reloc %s:%d not in csect" +msgstr "" + +#: xcofflink.c:2480 +#, c-format +msgid "%s: XCOFF shared object when not producing XCOFF output" +msgstr "" + +#: xcofflink.c:2501 +#, c-format +msgid "%s: dynamic object with no .loader section" +msgstr "" + +#: xcofflink.c:3141 +#, c-format +msgid "%s: no such symbol" +msgstr "" + +#: xcofflink.c:3733 +#, c-format +msgid "warning: attempt to export undefined symbol `%s'" +msgstr "" + +#: xcofflink.c:4709 +#, c-format +msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling" +msgstr "" + +#: xcofflink.c:5534 xcofflink.c:5890 xcofflink.c:5927 xcofflink.c:6244 +#, c-format +msgid "%s: loader reloc in unrecognized section `%s'" +msgstr "" + +#: xcofflink.c:5556 xcofflink.c:6255 +#, c-format +msgid "%s: `%s' in loader reloc but not loader sym" +msgstr "" + +#: xcofflink.c:5571 +#, c-format +msgid "%s: loader reloc in read-only section %s" +msgstr "" + +#: xcofflink.c:6451 +#, c-format +msgid "%s: unsupported relocation type 0x%02x" +msgstr "" + +#: xcofflink.c:6497 +#, c-format +msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry" +msgstr "" diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index cbda407..d9db826 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -1,5 +1,5 @@ /* BFD back-end for PPCbug boot records. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Michael Meissner, Cygnus Support, This file is part of BFD, the Binary File Descriptor library. @@ -225,7 +225,7 @@ ppcboot_object_p (abfd) static boolean ppcboot_get_section_contents (abfd, section, location, offset, count) bfd *abfd; - asection *section; + asection *section ATTRIBUTE_UNUSED; PTR location; file_ptr offset; bfd_size_type count; @@ -241,7 +241,7 @@ ppcboot_get_section_contents (abfd, section, location, offset, count) static long ppcboot_get_symtab_upper_bound (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { return (PPCBOOT_SYMS + 1) * sizeof (asymbol *); } @@ -340,7 +340,7 @@ ppcboot_make_empty_symbol (abfd) static void ppcboot_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -395,8 +395,8 @@ ppcboot_set_section_contents (abfd, sec, data, offset, size) static int ppcboot_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return sizeof (ppcboot_hdr_t); } @@ -531,5 +531,7 @@ const bfd_target ppcboot_vec = BFD_JUMP_TABLE_LINK (ppcboot), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + NULL }; diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c index 2b4fdbb..0969dce 100644 --- a/bfd/ptrace-core.c +++ b/bfd/ptrace-core.c @@ -224,6 +224,8 @@ const bfd_target ptrace_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/reloc.c b/bfd/reloc.c index 8885814..a3318e6 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -1,5 +1,5 @@ /* BFD support for handling relocation entries. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -25,7 +25,7 @@ SECTION 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 + en-masse and translated into an internal form. A common routine <> acts upon the canonical form to do the fixup. @@ -340,13 +340,26 @@ CODE_FRAGMENT . {* 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.*} +. {* Some formats record a relocation addend in the section contents +. rather than with the relocation. For ELF formats this is the +. distinction between USE_REL and USE_RELA (though the code checks +. for USE_REL == 1/0). The value of this field is TRUE if the +. addend is recorded with the section contents; when performing a +. partial link (ld -r) the section contents (the data) will be +. modified. The value of this field is FALSE if addends are +. recorded with the relocation (in arelent.addend); when performing +. a partial link the relocation will be modified. +. All relocations for all ELF USE_RELA targets should set this field +. to FALSE (values of TRUE should be looked on with suspicion). +. However, the converse is not true: not all relocations of all ELF +. USE_REL targets set this field to TRUE. Why this is so is peculiar +. to each particular target. For relocs that aren't used in partial +. links (e.g. GOT stuff) it doesn't matter what this is set to. *} . 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 +. byte 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 @@ -389,6 +402,14 @@ DESCRIPTION .#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) . + +DESCRIPTION + This is used to fill in an empty howto entry in an array. + +.#define EMPTY_HOWTO(C) \ +. HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false) +. + DESCRIPTION Helper routine to turn a symbol into a relocation value. @@ -519,17 +540,14 @@ bfd_check_overflow (how, bitsize, rightshift, addrsize, relocation) 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. */ + explicitly allow an address wrap too, which means a bitfield + of n bits is allowed to store -2**n to 2**n-1. Thus overflow + if the value has some, but not all, bits set outside the + field. */ a >>= rightshift; - if ((a & ~ fieldmask) != 0) - { - signmask = (fieldmask >> 1) + 1; - ss = (signmask << rightshift) - 1; - if ((ss | relocation) != ~ (bfd_vma) 0) - flag = bfd_reloc_overflow; - } + ss = a & ~ fieldmask; + if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & ~ fieldmask)) + flag = bfd_reloc_overflow; break; default: @@ -584,7 +602,7 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, { bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; - bfd_size_type addr = reloc_entry->address; + bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; asection *reloc_target_output_section; @@ -620,7 +638,8 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, } /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > input_section->_cooked_size) + if (reloc_entry->address > input_section->_cooked_size / + bfd_octets_per_byte (abfd)) return bfd_reloc_outofrange; /* Work out which section the relocation is targetted at and the @@ -863,23 +882,23 @@ space consuming. For each target: R result Do this: - i i i i i o o o o o from bfd_get - 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 + (( i i i i i o o o o o from bfd_get + 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 + = A A A A A And this: - ... i i i i i o o o o o from bfd_get - and N N N N N get instruction + ( i i i i i o o o o o from bfd_get + and N N N N N ) get instruction ----------------------- - ... B B B B B + = B B B B B And then: - B B B B B - or A A A A A + ( 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 + = R R R R R R R R R R put into bfd_put */ #define DOIT(x) \ @@ -889,41 +908,41 @@ space consuming. For each target: { case 0: { - char x = bfd_get_8 (abfd, (char *) data + addr); + char x = bfd_get_8 (abfd, (char *) data + octets); DOIT (x); - bfd_put_8 (abfd, x, (unsigned char *) data + addr); + bfd_put_8 (abfd, x, (unsigned char *) data + octets); } break; case 1: { - short x = bfd_get_16 (abfd, (bfd_byte *) data + addr); + short x = bfd_get_16 (abfd, (bfd_byte *) data + octets); DOIT (x); - bfd_put_16 (abfd, x, (unsigned char *) data + addr); + bfd_put_16 (abfd, x, (unsigned char *) data + octets); } break; case 2: { - long x = bfd_get_32 (abfd, (bfd_byte *) data + addr); + long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); DOIT (x); - bfd_put_32 (abfd, x, (bfd_byte *) data + addr); + bfd_put_32 (abfd, x, (bfd_byte *) data + octets); } break; case -2: { - long x = bfd_get_32 (abfd, (bfd_byte *) data + addr); + long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); relocation = -relocation; DOIT (x); - bfd_put_32 (abfd, x, (bfd_byte *) data + addr); + bfd_put_32 (abfd, x, (bfd_byte *) data + octets); } break; case -1: { - long x = bfd_get_16 (abfd, (bfd_byte *) data + addr); + long x = bfd_get_16 (abfd, (bfd_byte *) data + octets); relocation = -relocation; DOIT (x); - bfd_put_16 (abfd, x, (bfd_byte *) data + addr); + bfd_put_16 (abfd, x, (bfd_byte *) data + octets); } break; @@ -934,9 +953,9 @@ space consuming. For each target: case 4: #ifdef BFD64 { - bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr); + bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + octets); DOIT (x); - bfd_put_64 (abfd, x, (bfd_byte *) data + addr); + bfd_put_64 (abfd, x, (bfd_byte *) data + octets); } #else abort (); @@ -986,7 +1005,7 @@ bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, { bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; - bfd_size_type addr = reloc_entry->address; + bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; asection *reloc_target_output_section; @@ -1006,7 +1025,7 @@ bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, 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, @@ -1253,29 +1272,29 @@ space consuming. For each target: R result Do this: - i i i i i o o o o o from bfd_get - 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 + (( i i i i i o o o o o from bfd_get + 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 + = A A A A A And this: - ... i i i i i o o o o o from bfd_get - and N N N N N get instruction + ( i i i i i o o o o o from bfd_get + and N N N N N ) get instruction ----------------------- - ... B B B B B + = B B B B B And then: - B B B B B - or A A A A A + ( 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 + = R R R R R R R R R R put into bfd_put */ #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); + data = (bfd_byte *) data_start + (octets - data_start_offset); switch (howto->size) { @@ -1405,8 +1424,8 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) bfd_byte *location; { int size; - bfd_vma x; - boolean overflow; + bfd_vma x = 0; + bfd_reloc_status_type flag; unsigned int rightshift = howto->rightshift; unsigned int bitpos = howto->bitpos; @@ -1444,7 +1463,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) 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; + flag = bfd_reloc_ok; if (howto->complain_on_overflow != complain_overflow_dont) { bfd_vma addrmask, fieldmask, signmask, ss; @@ -1470,7 +1489,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) signmask = ~ (fieldmask >> 1); ss = a & signmask; if (ss != 0 && ss != ((addrmask >> rightshift) & signmask)) - overflow = true; + flag = bfd_reloc_overflow; /* 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 @@ -1482,7 +1501,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) if ((b & signmask) != 0) { /* Set all the bits above the sign bit. */ - b -= signmask <<= 1; + b -= signmask << 1; } b = (b & addrmask) >> bitpos; @@ -1500,7 +1519,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) */ signmask = (fieldmask >> 1) + 1; if (((~ (a ^ b)) & (a ^ sum)) & signmask) - overflow = true; + flag = bfd_reloc_overflow; break; @@ -1520,55 +1539,35 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) b = (b & addrmask) >> bitpos; sum = (a + b) & addrmask; if ((a | b | sum) & ~ fieldmask) - overflow = true; + flag = bfd_reloc_overflow; 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. */ + /* Much like the signed check, but for a field one bit + wider, and no trimming with addrmask. We allow a + bitfield to represent numbers in the range -2**n to + 2**n-1, where n is the number of bits in the field. + Note that when bfd_vma is 32 bits, a 32-bit reloc can't + overflow, which is exactly what we want. */ 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; + signmask = ~ fieldmask; + ss = a & signmask; + if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & signmask)) + flag = bfd_reloc_overflow; - 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; - } + signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; + if ((b & signmask) != 0) + b -= signmask << 1; - /* We just assume (b & ~ fieldmask) == 0. */ + b >>= bitpos; 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; - } + + signmask = fieldmask + 1; + if (((~ (a ^ b)) & (a ^ sum)) & signmask) + flag = bfd_reloc_overflow; break; @@ -1609,7 +1608,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) break; } - return overflow ? bfd_reloc_overflow : bfd_reloc_ok; + return flag; } /* @@ -1944,6 +1943,25 @@ ENUMDOC The GNU linker currently doesn't do any of this optimizing. ENUM + BFD_RELOC_ALPHA_USER_LITERAL +ENUMX + BFD_RELOC_ALPHA_USER_LITUSE_BASE +ENUMX + BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF +ENUMX + BFD_RELOC_ALPHA_USER_LITUSE_JSR +ENUMX + BFD_RELOC_ALPHA_USER_GPDISP +ENUMX + BFD_RELOC_ALPHA_USER_GPRELHIGH +ENUMX + BFD_RELOC_ALPHA_USER_GPRELLOW +ENUMDOC + The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to + process the explicit !!sequence relocations, and are mapped + into the normal relocations at the end of processing. + +ENUM BFD_RELOC_ALPHA_HINT ENUMDOC The HINT relocation indicates a value that should be filled into the @@ -2028,6 +2046,14 @@ ENUMX BFD_RELOC_MIPS_CALL_HI16 ENUMX BFD_RELOC_MIPS_CALL_LO16 +ENUMX + BFD_RELOC_MIPS_SUB +ENUMX + BFD_RELOC_MIPS_GOT_PAGE +ENUMX + BFD_RELOC_MIPS_GOT_OFST +ENUMX + BFD_RELOC_MIPS_GOT_DISP COMMENT ENUMDOC MIPS ELF relocations. @@ -2081,6 +2107,21 @@ ENUMDOC ns32k relocations ENUM + BFD_RELOC_PJ_CODE_HI16 +ENUMX + BFD_RELOC_PJ_CODE_LO16 +ENUMX + BFD_RELOC_PJ_CODE_DIR16 +ENUMX + BFD_RELOC_PJ_CODE_DIR32 +ENUMX + BFD_RELOC_PJ_CODE_REL16 +ENUMX + BFD_RELOC_PJ_CODE_REL32 +ENUMDOC + Picojava relocs. Not all of these appear in object files. + +ENUM BFD_RELOC_PPC_B26 ENUMX BFD_RELOC_PPC_BA26 @@ -2144,6 +2185,11 @@ ENUMDOC Power(rs6000) and PowerPC relocations. ENUM + BFD_RELOC_I370_D12 +ENUMDOC + IBM 370/390 relocations + +ENUM BFD_RELOC_CTOR ENUMDOC The type of reloc used to build a contructor table - at the moment @@ -2158,6 +2204,8 @@ ENUMDOC ENUM BFD_RELOC_ARM_IMMEDIATE ENUMX + BFD_RELOC_ARM_ADRL_IMMEDIATE +ENUMX BFD_RELOC_ARM_OFFSET_IMM ENUMX BFD_RELOC_ARM_SHIFT_IMM @@ -2305,46 +2353,46 @@ ENUMDOC ENUM BFD_RELOC_D30V_9_PCREL ENUMDOC - This is a 6-bit pc-relative reloc with - the right 3 bits assumed to be 0. + 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 + 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. + of the container. ENUM BFD_RELOC_D30V_15 ENUMDOC - This is a 12-bit absolute reloc with the - right 3 bitsassumed to be 0. + 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. + 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 + 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. + of the container. ENUM BFD_RELOC_D30V_21 ENUMDOC - This is an 18-bit absolute reloc with + 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 + 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 + 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. @@ -2526,7 +2574,7 @@ ENUM 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 @@ -2537,15 +2585,102 @@ ENUMX BFD_RELOC_MCORE_PCREL_32 ENUMX BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2 +ENUMX + BFD_RELOC_MCORE_RVA ENUMDOC Motorola Mcore relocations. - + +ENUM + BFD_RELOC_AVR_7_PCREL +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit pc relative + short offset into 7 bits. +ENUM + BFD_RELOC_AVR_13_PCREL +ENUMDOC + This is a 16 bit reloc for the AVR that stores 13 bit pc relative + short offset into 12 bits. +ENUM + BFD_RELOC_AVR_16_PM +ENUMDOC + This is a 16 bit reloc for the AVR that stores 17 bit value (usually + program memory address) into 16 bits. +ENUM + BFD_RELOC_AVR_LO8_LDI +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (usually + data memory address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_HI8_LDI +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit + of data memory address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_HH8_LDI +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit + of program memory address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_LO8_LDI_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (usually data memory address) into 8 bit immediate value of SUBI insn. +ENUM + BFD_RELOC_AVR_HI8_LDI_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 8 bit of data memory address) into 8 bit immediate value of + SUBI insn. +ENUM + BFD_RELOC_AVR_HH8_LDI_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (most high 8 bit of program memory address) into 8 bit immediate value + of LDI or SUBI insn. +ENUM + BFD_RELOC_AVR_LO8_LDI_PM +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (usually + command address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_HI8_LDI_PM +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit + of command address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_HH8_LDI_PM +ENUMDOC + This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit + of command address) into 8 bit immediate value of LDI insn. +ENUM + BFD_RELOC_AVR_LO8_LDI_PM_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (usually command address) into 8 bit immediate value of SUBI insn. +ENUM + BFD_RELOC_AVR_HI8_LDI_PM_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 8 bit of 16 bit command address) into 8 bit immediate value + of SUBI insn. +ENUM + BFD_RELOC_AVR_HH8_LDI_PM_NEG +ENUMDOC + This is a 16 bit reloc for the AVR that stores negated 8 bit value + (high 6 bit of 22 bit command address) into 8 bit immediate + value of SUBI insn. +ENUM + BFD_RELOC_AVR_CALL +ENUMDOC + This is a 32 bit reloc for the AVR that stores 23 bit value + into 22 bits. + ENUM BFD_RELOC_VTABLE_INHERIT ENUMX BFD_RELOC_VTABLE_ENTRY ENUMDOC - These two relocations are used by the linker to determine which of + 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 @@ -2559,7 +2694,7 @@ ENUMDOC 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 + 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. @@ -2680,9 +2815,9 @@ DESCRIPTION /*ARGSUSED*/ boolean bfd_generic_relax_section (abfd, section, link_info, again) - bfd *abfd; - asection *section; - struct bfd_link_info *link_info; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; boolean *again; { *again = false; @@ -2705,8 +2840,8 @@ DESCRIPTION /*ARGSUSED*/ boolean bfd_generic_gc_sections (abfd, link_info) - bfd *abfd; - struct bfd_link_info *link_info; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; { return true; } @@ -2805,7 +2940,8 @@ bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, 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))) + input_bfd, input_section, (*parent)->address, + true))) goto error_return; break; case bfd_reloc_dangerous: diff --git a/bfd/reloc16.c b/bfd/reloc16.c index 7e7952e..0e7c18a 100644 --- a/bfd/reloc16.c +++ b/bfd/reloc16.c @@ -81,7 +81,8 @@ bfd_coff_reloc16_get_value (reloc, link_info, input_section) { if (! ((*link_info->callbacks->undefined_symbol) (link_info, bfd_asymbol_name (symbol), - input_section->owner, input_section, reloc->address))) + input_section->owner, input_section, reloc->address, + true))) abort (); value = 0; } @@ -194,9 +195,10 @@ bfd_coff_reloc16_relax_section (abfd, i, link_info, again) { 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)); + /* Allocate and initialize the shrinks array for this section. + The last element is used as an accumlator of shrinks. */ + shrinks = (int *) bfd_malloc ((reloc_count + 1) * sizeof (int)); + memset (shrinks, 0, (reloc_count + 1) * sizeof (int)); /* Loop until nothing changes in this section. */ do { @@ -218,13 +220,14 @@ bfd_coff_reloc16_relax_section (abfd, i, link_info, again) if (shrink != shrinks[i]) { another_pass = 1; - for (j = i + 1; j < reloc_count; j++) + for (j = i + 1; j <= reloc_count; j++) shrinks[j] += shrink - shrinks[i]; } } } while (another_pass); + shrink = shrinks[reloc_count]; free((char *)shrinks); } diff --git a/bfd/riscix.c b/bfd/riscix.c index f5ab49a..b3eb18c 100644 --- a/bfd/riscix.c +++ b/bfd/riscix.c @@ -1,5 +1,5 @@ /* BFD back-end for RISC iX (Acorn, arm) binaries. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -154,7 +154,7 @@ static reloc_howto_type riscix_std_reloc_howto[] = { 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}, + EMPTY_HOWTO (-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) }; @@ -166,13 +166,13 @@ static reloc_howto_type riscix_std_reloc_howto[] = { 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc_entry ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *input_section ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { /* This is dead simple at present. */ return bfd_reloc_ok; @@ -187,7 +187,7 @@ riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation; bfd_size_type addr = reloc_entry->address; diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c index b20555f..6de7441 100644 --- a/bfd/rs6000-core.c +++ b/bfd/rs6000-core.c @@ -1,5 +1,5 @@ /* IBM RS/6000 "XCOFF" back-end for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 2000 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 @@ -81,26 +81,47 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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. + this seems to be the quickest/easiest 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. */ + right now. + + AIX 4.3 defines an entirely new structure (core_dumpx). Yet the + basic logic stays the same and we can still use our macro + redefinition mechanism to effect the necessary changes. */ + +#ifdef AIX_CORE_DUMPX_CORE +#define CORE_DATA_SIZE_FIELD c_dataorg +#define CORE_COMM_FIELD c_u.U_proc.pi_comm +#define SAVE_FIELD c_flt.hctx.r32 +#define STACK_END_ADDR coredata.c_stackorg + coredata.c_size +#define LOADER_OFFSET_FIELD c_loader +#define LOADER_REGION_SIZE coredata.c_lsize +#define CORE_DUMP core_dumpx +#else #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 +#define LOADER_OFFSET_FIELD c_tab +#define LOADER_REGION_SIZE 0x7ffffff +#define CORE_DUMP core_dump #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 +#define LOADER_OFFSET_FIELD c_tab +#define LOADER_REGION_SIZE 0x7ffffff +#define CORE_DUMP core_dump +#endif #endif /* These are stored in the bfd's tdata */ typedef struct { - struct core_dump hdr; /* core file header */ + struct CORE_DUMP hdr; /* core file header */ } Rs6kCorData; static asection *make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, @@ -137,7 +158,7 @@ const bfd_target * rs6000coff_core_p (abfd) bfd *abfd; { - struct core_dump coredata; + struct CORE_DUMP coredata; struct stat statbuf; bfd_size_type nread; char *tmpptr; @@ -145,8 +166,8 @@ rs6000coff_core_p (abfd) 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)) + 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); @@ -197,6 +218,15 @@ rs6000coff_core_p (abfd) return NULL; } +#ifdef AIX_CORE_DUMPX_CORE + /* For the core_dumpx format, make sure c_entries == 0 If it does + not, the core file uses the old format */ + if (coredata.c_entries != 0) + { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } +#else /* Sanity check on the c_tab field. */ if ((u_long) coredata.c_tab < sizeof coredata || (u_long) coredata.c_tab >= statbuf.st_size || @@ -205,6 +235,7 @@ rs6000coff_core_p (abfd) bfd_set_error (bfd_error_wrong_format); return NULL; } +#endif /* Issue warning if the core file was truncated during writing. */ if (coredata.c_flag & CORE_TRUNC) @@ -253,9 +284,9 @@ rs6000coff_core_p (abfd) See if we can just fake it. */ if (!make_bfd_asection (abfd, ".ldinfo", SEC_HAS_CONTENTS, - (bfd_size_type) 0x7fffffff, + (bfd_size_type) LOADER_REGION_SIZE, (bfd_vma) 0, - (file_ptr) coredata.c_tab)) + (file_ptr) coredata.LOADER_OFFSET_FIELD)) return NULL; #ifndef CORE_VERSION_1 @@ -284,7 +315,7 @@ rs6000coff_core_p (abfd) { struct ld_info ldinfo; bfd_size_type ldinfo_size; - file_ptr ldinfo_offset = (file_ptr) coredata.c_tab; + file_ptr ldinfo_offset = (file_ptr) coredata.LOADER_OFFSET_FIELD; /* .data section from executable. */ if (coredata.c_datasize) @@ -360,7 +391,7 @@ rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd) bfd *core_bfd; bfd *exec_bfd; { - struct core_dump coredata; + struct CORE_DUMP coredata; struct ld_info ldinfo; bfd_size_type size; char *path, *s; @@ -372,7 +403,7 @@ rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd) || bfd_read (&coredata, sizeof coredata, 1, core_bfd) != sizeof coredata) return false; - if (bfd_seek (core_bfd, (long) coredata.c_tab, SEEK_SET) != 0) + if (bfd_seek (core_bfd, (long) coredata.LOADER_OFFSET_FIELD, SEEK_SET) != 0) return false; size = (char *) &ldinfo.ldinfo_filename[0] - (char *) &ldinfo.ldinfo_next; diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c index f10c8f1..46c97d2 100644 --- a/bfd/sco5-core.c +++ b/bfd/sco5-core.c @@ -425,5 +425,7 @@ const bfd_target sco5_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/section.c b/bfd/section.c index 18778b5..b3b7608 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1,5 +1,5 @@ /* Object file "section" support for the BFD library. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -150,6 +150,27 @@ SUBSECTION CODE_FRAGMENT . +. {* This structure is used for a comdat section, as in PE. A comdat +. section is associated with a particular symbol. When the linker +. sees a comdat section, it keeps only one of the sections with a +. given name and associated with a given symbol. *} +. +.struct bfd_comdat_info +.{ +. {* The name of the symbol associated with a comdat section. *} +. const char *name; +. +. {* The local symbol table index of the symbol associated with a +. comdat section. This is only meaningful to the object file format +. specific code; it is not an index into the list returned by +. bfd_canonicalize_symtab. *} +. long symbol; +. +. {* If this section is being discarded, the linker uses this field +. to point to the input section which is being kept. *} +. struct sec *sec; +.}; +. .typedef struct sec .{ . {* The name of the section; the name isn't a copy, the pointer is @@ -307,6 +328,14 @@ CODE_FRAGMENT . {* This section should not be subject to garbage collection. *} .#define SEC_KEEP 0x1000000 . +. {* This section contains "short" data, and should be placed +. "near" the GP. *} +.#define SEC_SMALL_DATA 0x2000000 +. +. {* This section contains data which may be shared with other +. executables or shared objects. *} +.#define SEC_SHARED 0x4000000 +. . {* End of section flags. *} . . {* Some internal packed boolean fields. *} @@ -340,22 +369,25 @@ CODE_FRAGMENT . . 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 *} +. {* The size of the section in octets, 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 +. {* The original size on disk of the section, in octets. 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. *} +. offset in *bytes* into the output section of the first byte in the +. input section (byte ==> smallest addressable unit on the +. target). In most cases, if this was going to start at the +. 100th octet (8-bit quantity) in the output section, this value +. would be 100. However, if the target byte size is 16 bits +. (bfd_octets_per_byte is "2"), this value would be 50. *} . . bfd_vma output_offset; . @@ -413,6 +445,10 @@ CODE_FRAGMENT . . unsigned int lineno_count; . +. {* Optional information about a COMDAT entry; NULL if not COMDAT *} +. +. struct bfd_comdat_info *comdat; +. . {* When a section is being output, this value changes as more . linenumbers are written out *} . @@ -472,28 +508,60 @@ CODE_FRAGMENT .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) +. ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \ +. : (section)->_raw_size) .#define bfd_get_section_size_after_reloc(section) \ -. ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) +. ((section)->reloc_done ? (section)->_cooked_size \ +. : (abort (), (bfd_size_type) 1)) */ +/* We use a macro to initialize the static asymbol structures because + traditional C does not permit us to initialize a union member while + gcc warns if we don't initialize it. */ + /* the_bfd, name, value, attr, section [, udata] */ +#ifdef __STDC__ +#define GLOBAL_SYM_INIT(NAME, SECTION) \ + { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }} +#else +#define GLOBAL_SYM_INIT(NAME, SECTION) \ + { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION } +#endif + /* 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}, + GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section), + GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section), + GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section), + GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &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 } + /* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ \ + { NAME, 0, 0, FLAGS, 0, 0, 0, 0, \ + \ + /* vma, lma, _cooked_size, _raw_size, output_offset, output_section, */ \ + 0, 0, 0, 0, 0, (struct sec *) &SEC, \ + \ + /* alig..., reloc..., orel..., reloc_count, filepos, rel_..., line_... */ \ + 0, 0, 0, 0, 0, 0, 0, \ + \ + /* userdata, contents, lineno, lineno_count */ \ + 0, 0, 0, 0, \ + \ + /* comdat_info, moving_line_filepos, target_index, used_by_bfd, */ \ + NULL, 0, 0, 0, \ + \ + /* cons..., owner, symbol */ \ + 0, 0, (struct symbol_cache_entry *) &global_syms[IDX], \ + \ + /* symbol_ptr_ptr, link_order_head, ..._tail */ \ + (struct symbol_cache_entry **) &SYM, 0, 0 \ + } STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol, BFD_COM_SECTION_NAME, 0); @@ -636,6 +704,7 @@ bfd_make_section_anyway (abfd, name) newsect->reloc_count = 0; newsect->line_filepos = 0; newsect->owner = abfd; + newsect->comdat = NULL; /* 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 @@ -733,7 +802,7 @@ DESCRIPTION /*ARGSUSED*/ boolean bfd_set_section_flags (abfd, section, flags) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; sec_ptr section; flagword flags; { @@ -856,7 +925,7 @@ 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. + @var{offset} for @var{count} octets. @@ -1033,43 +1102,73 @@ FUNCTION SYNOPSIS void _bfd_strip_section_from_output - (asection *section); + (struct bfd_link_info *info, asection *section); DESCRIPTION - Remove @var{section} from the output. If the output section becomes - empty, remove it from the output bfd. + Remove @var{section} from the output. If the output section + becomes empty, remove it from the output bfd. @var{info} may + be NULL; if it is not, it is used to decide whether the output + section is empty. */ void -_bfd_strip_section_from_output (s) +_bfd_strip_section_from_output (info, s) + struct bfd_link_info *info; asection *s; { asection **spp, *os; struct bfd_link_order *p, *pp; + boolean keep_os; + /* Excise the input section from the link order. + + FIXME: For all calls that I can see to this function, the link + orders have not yet been set up. So why are we checking them? -- + Ian */ 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; + break; + } + + keep_os = os->link_order_head != NULL; - if (!os->link_order_head) + if (! keep_os && info != NULL) + { + bfd *abfd; + for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) + { + asection *is; + for (is = abfd->sections; is != NULL; is = is->next) + { + if (is != s && is->output_section == os) + break; + } + if (is != NULL) + break; + } + if (abfd != NULL) + keep_os = true; + } + + /* If the output section is empty, remove it too. Careful about sections + that have been discarded in the link script -- they are mapped to + bfd_abs_section, which has no owner. */ + if (!keep_os && os->owner != NULL) + { + for (spp = &os->owner->sections; *spp; spp = &(*spp)->next) + if (*spp == os) { - /* Excise the output section. */ - for (spp = &os->owner->sections; *spp; spp = &(*spp)->next) - if (*spp == os) - { - *spp = os->next; - os->owner->section_count--; - break; - } + *spp = os->next; + os->owner->section_count--; + break; } - break; - } + } } diff --git a/bfd/som.c b/bfd/som.c index b5786b5..cd61cc6 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -148,6 +148,7 @@ struct som_misc_symbol_info unsigned int symbol_info; unsigned int symbol_value; unsigned int priv_level; + unsigned int secondary_def; }; /* Forward declarations */ @@ -440,9 +441,7 @@ static const struct fixup_format som_fixup_formats[256] = 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 */ @@ -459,8 +458,9 @@ static const struct fixup_format som_fixup_formats[256] = 1, "L4=RD8next) { int reloc_offset, current_rounding_mode; +#ifndef NO_PCREL_MODES + int current_call_mode; +#endif /* Find a subspace of this space. */ if (!som_is_subspace (subsection) @@ -2700,6 +2726,9 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) reloc_offset = 0; som_initialize_reloc_queue (reloc_queue); current_rounding_mode = R_N_MODE; +#ifndef NO_PCREL_MODES + current_call_mode = R_SHORT_PCREL_MODE; +#endif /* Translate each BFD relocation into one or more SOM relocations. */ @@ -2764,6 +2793,10 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) case R_END_TRY: case R_N0SEL: case R_N1SEL: +#ifndef NO_PCREL_MODES + case R_SHORT_PCREL_MODE: + case R_LONG_PCREL_MODE: +#endif reloc_offset = bfd_reloc->address; break; @@ -2888,6 +2921,19 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) } break; +#ifndef NO_PCREL_MODES + case R_LONG_PCREL_MODE: + case R_SHORT_PCREL_MODE: + if (bfd_reloc->howto->type != current_call_mode) + { + bfd_put_8 (abfd, bfd_reloc->howto->type, p); + subspace_reloc_size += 1; + p += 1; + current_call_mode = bfd_reloc->howto->type; + } + break; +#endif + case R_EXIT: case R_ALT_ENTRY: case R_FSEL: @@ -4010,6 +4056,13 @@ som_bfd_derive_misc_symbol_info (abfd, sym, info) /* Set the symbol's value. */ info->symbol_value = sym->value + sym->section->vma; + + /* The secondary_def field is for weak symbols. */ + if (sym->flags & BSF_WEAK) + info->secondary_def = true; + else + info->secondary_def = false; + } /* Build and write, in one big chunk, the entire symbol table for @@ -4053,6 +4106,7 @@ som_build_and_write_symbol_table (abfd) som_symtab[i].symbol_info = info.symbol_info; som_symtab[i].xleast = 3; som_symtab[i].symbol_value = info.symbol_value | info.priv_level; + som_symtab[i].secondary_def = info.secondary_def; } /* Everything is ready, seek to the right location and @@ -4292,7 +4346,7 @@ som_slurp_symbol_table (abfd) 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 + /* If the symbol's scope is SS_UNSAT, then these are undefined function symbols. */ if (bufp->symbol_scope == SS_UNSAT) sym->symbol.flags |= BSF_FUNCTION; @@ -4340,6 +4394,10 @@ som_slurp_symbol_table (abfd) break; } + /* Check for a weak symbol. */ + if (bufp->secondary_def) + sym->symbol.flags |= BSF_WEAK; + /* 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] == '$' @@ -5882,7 +5940,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) /* Fill in the lst symbol record. */ curr_lst_sym->hidden = 0; - curr_lst_sym->secondary_def = 0; + curr_lst_sym->secondary_def = info.secondary_def; curr_lst_sym->symbol_type = info.symbol_type; curr_lst_sym->symbol_scope = info.symbol_scope; curr_lst_sym->check_level = 0; @@ -6258,6 +6316,8 @@ const bfd_target som_vec = BFD_JUMP_TABLE_LINK (som), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c index 86d4e7e..73a29b3 100644 --- a/bfd/sparclinux.c +++ b/bfd/sparclinux.c @@ -1,5 +1,6 @@ /* BFD back-end for linux flavored sparc a.out binaries. - Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -299,7 +300,7 @@ new_fixup (info, h, value, builtin) static boolean linux_link_create_dynamic_sections (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { flagword flags; register asection *s; diff --git a/bfd/srec.c b/bfd/srec.c index 70d2f96..31f69b0 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -171,7 +171,7 @@ srec_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 +#define CHUNK 16 /* 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. */ @@ -1000,31 +1000,28 @@ srec_write_section (abfd, tdata, list) tdata_type *tdata; srec_data_list_type *list; { - unsigned int bytes_written = 0; + unsigned int octets_written = 0; bfd_byte *location = list->data; - while (bytes_written < list->size) + while (octets_written < list->size) { bfd_vma address; + unsigned int octets_this_chunk = list->size - octets_written; - unsigned int bytes_this_chunk = list->size - bytes_written; + if (octets_this_chunk > CHUNK) + octets_this_chunk = CHUNK; - if (bytes_this_chunk > CHUNK) - { - bytes_this_chunk = CHUNK; - } - - address = list->where + bytes_written; + address = list->where + octets_written / bfd_octets_per_byte (abfd); if (! srec_write_record (abfd, tdata->type, address, location, - location + bytes_this_chunk)) + location + octets_this_chunk)) return false; - bytes_written += bytes_this_chunk; - location += bytes_this_chunk; + octets_written += octets_this_chunk; + location += octets_this_chunk; } return true; @@ -1139,8 +1136,8 @@ symbolsrec_write_object_contents (abfd) /*ARGSUSED*/ static int srec_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -1209,7 +1206,7 @@ srec_get_symtab (abfd, alocation) /*ARGSUSED*/ static void srec_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -1219,7 +1216,7 @@ srec_get_symbol_info (ignore_abfd, symbol, ret) /*ARGSUSED*/ static void srec_print_symbol (ignore_abfd, afile, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; @@ -1318,6 +1315,8 @@ const bfd_target srec_vec = BFD_JUMP_TABLE_LINK (srec), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; @@ -1373,5 +1372,7 @@ const bfd_target symbolsrec_vec = BFD_JUMP_TABLE_LINK (srec), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/stabs.c b/bfd/stabs.c index ffc000d..e9ac167 100644 --- a/bfd/stabs.c +++ b/bfd/stabs.c @@ -1,5 +1,5 @@ /* Stabs in sections linking support. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -230,6 +230,8 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) sinfo->strings = _bfd_stringtab_init (); if (sinfo->strings == NULL) goto error_return; + /* Make sure the first byte is zero. */ + (void) _bfd_stringtab_add (sinfo->strings, "", true, true); if (! bfd_hash_table_init_n (&sinfo->includes.root, stab_link_includes_newfunc, 251)) @@ -619,8 +621,8 @@ _bfd_write_stab_strings (output_bfd, psinfo) bfd_vma _bfd_stab_section_offset (output_bfd, psinfo, stabsec, psecinfo, offset) - bfd *output_bfd; - PTR *psinfo; + bfd *output_bfd ATTRIBUTE_UNUSED; + PTR *psinfo ATTRIBUTE_UNUSED; asection *stabsec; PTR *psecinfo; bfd_vma offset; diff --git a/bfd/sunos.c b/bfd/sunos.c index e34f878..ada6857 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -1,5 +1,5 @@ /* BFD backend for SunOS binaries. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -1257,7 +1257,7 @@ sunos_add_one_symbol (info, abfd, name, flags, section, value, string, /*ARGSUSED*/ struct bfd_link_needed_list * bfd_sunos_get_needed_list (abfd, info) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; { if (info->hash->creator != &MY(vec)) @@ -1607,7 +1607,7 @@ static boolean sunos_scan_std_relocs (info, abfd, sec, relocs, rel_size) struct bfd_link_info *info; bfd *abfd; - asection *sec; + asection *sec ATTRIBUTE_UNUSED; const struct reloc_std_external *relocs; bfd_size_type rel_size; { @@ -1767,7 +1767,7 @@ static boolean sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_size) struct bfd_link_info *info; bfd *abfd; - asection *sec; + asection *sec ATTRIBUTE_UNUSED; const struct reloc_ext_external *relocs; bfd_size_type rel_size; { @@ -2173,8 +2173,8 @@ sunos_scan_dynamic_symbol (h, data) /*ARGSUSED*/ static boolean sunos_link_dynamic_object (info, abfd) - struct bfd_link_info *info; - bfd *abfd; + struct bfd_link_info *info ATTRIBUTE_UNUSED; + bfd *abfd ATTRIBUTE_UNUSED; { return true; } @@ -2427,7 +2427,7 @@ sunos_check_dynamic_reloc (info, input_bfd, input_section, harg, reloc, asection *input_section; struct aout_link_hash_entry *harg; PTR reloc; - bfd_byte *contents; + bfd_byte *contents ATTRIBUTE_UNUSED; boolean *skip; bfd_vma *relocationp; { diff --git a/bfd/syms.c b/bfd/syms.c index f69d1f2..6546f58 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -1,5 +1,5 @@ /* Generic symbol-table support for the BFD library. - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Cygnus Support. @@ -227,7 +227,7 @@ CODE_FRAGMENT . <> *} . . {* The symbol is a debugging record. The value has an arbitary -. meaning. *} +. meaning, unless BSF_DEBUGGING_RELOC is also set. *} .#define BSF_DEBUGGING 0x08 . . {* The symbol denotes a function entry point. Used in ELF, @@ -285,6 +285,11 @@ CODE_FRAGMENT . others someday. *} .#define BSF_OBJECT 0x10000 . +. {* This symbol is a debugging symbol. The value is the offset +. into the section of the data. BSF_DEBUGGING should be set +. as well. *} +.#define BSF_DEBUGGING_RELOC 0x20000 +. . flagword flags; . . {* A pointer to the section to which this symbol is @@ -523,6 +528,11 @@ static CONST struct section_to_type stt[] = {".sdata", 'g'}, /* Small initialized data. */ {".text", 't'}, {"code", 't'}, /* MRI .text */ + {".drectve", 'i'}, /* MSVC's .drective section */ + {".idata", 'i'}, /* MSVC's .idata (import) section */ + {".edata", 'e'}, /* MSVC's .edata (export) section */ + {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ + {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ {0, 0} }; @@ -572,11 +582,30 @@ bfd_decode_symclass (symbol) if (bfd_is_com_section (symbol->section)) return 'C'; if (bfd_is_und_section (symbol->section)) - return 'U'; + { + if (symbol->flags & BSF_WEAK) + { + /* If weak, determine if it's specifically an object + or non-object weak. */ + if (symbol->flags & BSF_OBJECT) + return 'v'; + else + return 'w'; + } + else + return 'U'; + } if (bfd_is_ind_section (symbol->section)) return 'I'; if (symbol->flags & BSF_WEAK) - return 'W'; + { + /* If weak, determine if it's specifically an object + or non-object weak. */ + if (symbol->flags & BSF_OBJECT) + return 'V'; + else + return 'W'; + } if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL))) return '?'; @@ -602,6 +631,26 @@ bfd_decode_symclass (symbol) /* FUNCTION + bfd_is_undefined_symclass + +DESCRIPTION + Returns non-zero if the class symbol returned by + bfd_decode_symclass represents an undefined symbol. + Returns zero otherwise. + +SYNOPSIS + boolean bfd_is_undefined_symclass (int symclass); +*/ + +boolean +bfd_is_undefined_symclass (symclass) + int symclass; +{ + return symclass == 'U' || symclass == 'w' || symclass == 'v'; +} + +/* +FUNCTION bfd_symbol_info DESCRIPTION @@ -619,10 +668,12 @@ bfd_symbol_info (symbol, ret) symbol_info *ret; { ret->type = bfd_decode_symclass (symbol); - if (ret->type != 'U') - ret->value = symbol->value + symbol->section->vma; - else + + if (bfd_is_undefined_symclass (ret->type)) ret->value = 0; + else + ret->value = symbol->value + symbol->section->vma; + ret->name = symbol->name; } @@ -698,10 +749,10 @@ _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep) /*ARGSUSED*/ asymbol * _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym) - bfd *abfd; - boolean dynamic; + bfd *abfd ATTRIBUTE_UNUSED; + boolean dynamic ATTRIBUTE_UNUSED; const PTR minisym; - asymbol *sym; + asymbol *sym ATTRIBUTE_UNUSED; { return *(asymbol **) minisym; } @@ -796,7 +847,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, { struct stab_find_info *info; bfd_size_type stabsize, strsize; - bfd_byte *stab, *str, *last_stab; + bfd_byte *stab, *str; + bfd_byte *last_stab = NULL; bfd_size_type stroff; struct indexentry *indexentry; char *directory_name, *file_name; @@ -1032,23 +1084,24 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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)); - } - } + 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: diff --git a/bfd/targets.c b/bfd/targets.c index bb6e51d..1f2217b 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -1,5 +1,5 @@ /* Generic target-file-type support for the BFD library. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -245,7 +245,8 @@ Write cached information into a file being written, at <>. . boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); -The general target vector. +The general target vector. These vectors are initialized using the +BFD_JUMP_TABLE macros. . . {* Generic entry points. *} @@ -460,10 +461,21 @@ The general target vector. . PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); . +A pointer to an alternative bfd_target in case the current one is not +satisfactory. This can happen when the target cpu supports both big +and little endian code, and target chosen by the linker has the wrong +endianness. The function open_output() in ld/ldlang.c uses this field +to find an alternative output format that is suitable. + +. {* Opposite endian version of this target. *} +. const struct bfd_target * alternative_target; +. + Data for use by back-end routines, which isn't generic enough to belong in this structure. . PTR backend_data; +. .} bfd_target; */ @@ -482,6 +494,7 @@ 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 armnetbsd_vec; extern const bfd_target armpe_little_vec; extern const bfd_target armpe_big_vec; extern const bfd_target armpei_little_vec; @@ -493,6 +506,7 @@ 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_avr_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; @@ -505,8 +519,10 @@ 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_i370_vec; extern const bfd_target bfd_elf32_i386_vec; extern const bfd_target bfd_elf32_i860_vec; +extern const bfd_target bfd_elf32_i960_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; @@ -515,6 +531,8 @@ 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_pj_vec; +extern const bfd_target bfd_elf32_pjl_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; @@ -573,6 +591,8 @@ 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 mipslpe_vec; +extern const bfd_target mipslpei_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; @@ -593,6 +613,8 @@ 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 shlpe_vec; +extern const bfd_target shlpei_vec; extern const bfd_target sparcle_aout_vec; extern const bfd_target sparclinux_vec; extern const bfd_target sparclynx_aout_vec; @@ -624,7 +646,8 @@ 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 cisco_core_big_vec; +extern const bfd_target cisco_core_little_vec; extern const bfd_target hpux_core_vec; extern const bfd_target hppabsd_core_vec; extern const bfd_target irix_core_vec; @@ -668,6 +691,7 @@ const bfd_target * const bfd_target_vector[] = { #ifdef BFD64 &bfd_elf64_alpha_vec, #endif + &bfd_elf32_avr_vec, &bfd_elf32_bigarc_vec, &bfd_elf32_bigarm_vec, &bfd_elf32_bigarm_oabi_vec, @@ -677,9 +701,13 @@ const bfd_target * const bfd_target_vector[] = { #endif &bfd_elf32_d10v_vec, &bfd_elf32_d30v_vec, +#if 0 &bfd_elf32_hppa_vec, +#endif + &bfd_elf32_i370_vec, &bfd_elf32_i386_vec, &bfd_elf32_i860_vec, + &bfd_elf32_i960_vec, &bfd_elf32_little_generic_vec, &bfd_elf32_littlearc_vec, &bfd_elf32_littlearm_vec, @@ -694,6 +722,8 @@ const bfd_target * const bfd_target_vector[] = { &bfd_elf32_m68k_vec, &bfd_elf32_m88k_vec, &bfd_elf32_sparc_vec, + &bfd_elf32_pj_vec, + &bfd_elf32_pjl_vec, &bfd_elf32_powerpc_vec, &bfd_elf32_powerpcle_vec, &bfd_elf32_v850_vec, @@ -707,7 +737,7 @@ const bfd_target * const bfd_target_vector[] = { #if 0 &bfd_elf64_sparc_vec, #endif - /* We don't include cisco_core_vec. Although it has a magic number, + /* 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 @@ -762,6 +792,7 @@ const bfd_target * const bfd_target_vector[] = { &i386pei_vec, &armcoff_little_vec, &armcoff_big_vec, + &armnetbsd_vec, &armpe_little_vec, &armpe_big_vec, &armpei_little_vec, @@ -1077,3 +1108,32 @@ bfd_target_list () return name_list; } + +/* +FUNCTION + bfd_seach_for_target + +SYNOPSIS + const bfd_target * bfd_search_for_target (int (* search_func)(const bfd_target *, void *), void *); + +DESCRIPTION + Return a pointer to the first transfer vector in the list of + transfer vectors maintained by BFD that produces a non-zero + result when passed to the function @var{search_func}. The + parameter @var{data} is passed, unexamined, to the search + function. +*/ + +const bfd_target * +bfd_search_for_target (search_func, data) + int (* search_func) PARAMS ((const bfd_target * target, void * data)); + void * data; +{ + const bfd_target * const * target; + + for (target = bfd_target_vector; * target != NULL; target ++) + if (search_func (* target, data)) + return * target; + + return NULL; +} diff --git a/bfd/tekhex.c b/bfd/tekhex.c index c88fe2d..b1ffe75 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -1,5 +1,6 @@ /* BFD backend for Extended Tektronix Hex Format objects. - Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support . This file is part of BFD, the Binary File Descriptor library. @@ -599,7 +600,7 @@ move_section_contents (abfd, section, locationp, offset, count, get) bfd *abfd; asection *section; PTR locationp; - file_ptr offset; + file_ptr offset ATTRIBUTE_UNUSED; bfd_size_type count; boolean get; { @@ -928,8 +929,8 @@ tekhex_write_object_contents (abfd) static int tekhex_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; @@ -951,7 +952,7 @@ tekhex_make_empty_symbol (abfd) static void tekhex_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -960,7 +961,7 @@ tekhex_get_symbol_info (ignore_abfd, symbol, ret) static void tekhex_print_symbol (ignore_abfd, filep, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR filep; asymbol *symbol; bfd_print_symbol_type how; @@ -1061,5 +1062,7 @@ const bfd_target tekhex_vec = BFD_JUMP_TABLE_LINK (tekhex), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/trad-core.c b/bfd/trad-core.c index 21d920b..633c53d 100644 --- a/bfd/trad-core.c +++ b/bfd/trad-core.c @@ -1,5 +1,5 @@ /* BFD back end for traditional Unix core files (U-area and raw sections) - Copyright 1988, 89, 91, 92, 93, 94, 95, 96, 1998 + Copyright 1988, 89, 91, 92, 93, 94, 95, 96, 98, 99, 2000 Free Software Foundation, Inc. Written by John Gilmore of Cygnus Support. @@ -105,22 +105,24 @@ trad_unix_core_file_p (abfd) bfd_set_error (bfd_error_system_call); return 0; } - if (NBPG * (UPAGES + u.u_dsize + if ((unsigned long) (NBPG * (UPAGES + u.u_dsize #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE - - u.u_tsize + - u.u_tsize #endif - + u.u_ssize) > statbuf.st_size) + + u.u_ssize)) + > (unsigned long) 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) + if ((unsigned long) (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 + + TRAD_CORE_EXTRA_SIZE_ALLOWED #endif - < statbuf.st_size) + ) + < (unsigned long) 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). */ @@ -200,7 +202,7 @@ trad_unix_core_file_p (abfd) 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_regsec (abfd)->vma = - (bfd_vma) u.u_ar0; core_datasec (abfd)->filepos = NBPG * UPAGES; core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize @@ -239,7 +241,7 @@ trad_unix_core_file_failing_command (abfd) /* ARGSUSED */ int trad_unix_core_file_failing_signal (ignore_abfd) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; { #ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd); @@ -251,7 +253,8 @@ trad_unix_core_file_failing_signal (ignore_abfd) /* ARGSUSED */ boolean trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; + bfd *core_bfd ATTRIBUTE_UNUSED; + bfd *exec_bfd ATTRIBUTE_UNUSED; { return true; /* FIXME, We have no way of telling at this point */ } @@ -312,5 +315,7 @@ const bfd_target trad_core_vec = BFD_JUMP_TABLE_LINK (_bfd_nolink), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 /* backend_data */ }; diff --git a/bfd/versados.c b/bfd/versados.c index 0dcd108..27f4f88 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -1,5 +1,5 @@ /* BFD back-end for VERSAdos-E objects. - Copyright 1995, 96, 1997 Free Software Foundation, Inc. + Copyright 1995, 96, 97, 98, 1999 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support . Versados is a Motorola trademark. @@ -690,11 +690,11 @@ versados_get_section_contents (abfd, section, location, offset, count) 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; + bfd *abfd ATTRIBUTE_UNUSED; + sec_ptr section ATTRIBUTE_UNUSED; + PTR location ATTRIBUTE_UNUSED; + file_ptr offset ATTRIBUTE_UNUSED; + bfd_size_type bytes_to_do ATTRIBUTE_UNUSED; { return false; } @@ -703,8 +703,8 @@ versados_set_section_contents (abfd, section, location, offset, bytes_to_do) /*ARGSUSED */ static int versados_sizeof_headers (abfd, exec) - bfd *abfd; - boolean exec; + bfd *abfd ATTRIBUTE_UNUSED; + boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -756,7 +756,7 @@ versados_get_symtab (abfd, alocation) /*ARGSUSED */ void versados_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -766,7 +766,7 @@ versados_get_symbol_info (ignore_abfd, symbol, ret) /*ARGSUSED */ void versados_print_symbol (ignore_abfd, afile, symbol, how) - bfd *ignore_abfd; + bfd *ignore_abfd ATTRIBUTE_UNUSED; PTR afile; asymbol *symbol; bfd_print_symbol_type how; @@ -788,7 +788,7 @@ versados_print_symbol (ignore_abfd, afile, symbol, how) long versados_get_reloc_upper_bound (abfd, asect) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; sec_ptr asect; { return (asect->reloc_count + 1) * sizeof (arelent *); @@ -919,5 +919,7 @@ const bfd_target versados_vec = BFD_JUMP_TABLE_LINK (versados), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + NULL, + (PTR) 0 }; diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c index 6a52462..ac3fe69 100644 --- a/bfd/vms-gsd.c +++ b/bfd/vms-gsd.c @@ -1,6 +1,6 @@ /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998 Free Software Foundation Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation Inc. go and read the openVMS linker manual (esp. appendix B) if you don't know what's going on here :-) @@ -282,7 +282,7 @@ _bfd_vms_slurp_gsd (abfd, objtype) vms_symbol_entry *entry; unsigned long base_addr; unsigned long align_addr; - static int psect_idx = 0; + static unsigned int psect_idx = 0; #if VMS_DEBUG vms_debug (2, "GSD/EGSD (%d/%x)\n", objtype, objtype); @@ -354,7 +354,8 @@ _bfd_vms_slurp_gsd (abfd, objtype) section = bfd_make_section (abfd, name); if (!section) { - fprintf (stderr, "bfd_make_section (%s) failed\n", name); + (*_bfd_error_handler) (_("bfd_make_section (%s) failed"), + name); return -1; } old_flags = bfd_getl16 (vms_rec + 2); @@ -366,7 +367,9 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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); + (*_bfd_error_handler) + (_("bfd_set_section_flags (%s, %x) failed"), + name, new_flags); return -1; } section->alignment_power = vms_rec[1]; @@ -400,7 +403,12 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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); + (*_bfd_error_handler) + (_("Size mismatch section %s=%lx, %s=%lx"), + old_section->name, + (unsigned long) old_section->_raw_size, + section->name, + (unsigned long) section->_raw_size); return -1; } else if (section->_raw_size > old_section->_raw_size) @@ -716,16 +724,15 @@ _bfd_vms_slurp_gsd (abfd, objtype) int _bfd_vms_write_gsd (abfd, objtype) bfd *abfd; - int objtype; + int objtype ATTRIBUTE_UNUSED; { asection *section; asymbol *symbol; - int symnum; + unsigned 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); diff --git a/bfd/vms-hdr.c b/bfd/vms-hdr.c index 01d20aa..3b36b32 100644 --- a/bfd/vms-hdr.c +++ b/bfd/vms-hdr.c @@ -1,6 +1,6 @@ /* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. HDR record handling functions EMH record handling functions @@ -249,7 +249,7 @@ _bfd_vms_write_hdr (abfd, objtype) int objtype; { asymbol *symbol; - int symnum; + unsigned int symnum; int had_case = 0; int had_file = 0; @@ -334,8 +334,6 @@ _bfd_vms_write_hdr (abfd, objtype) if (symbol->flags & BSF_FILE) { - char *s; - if (strncmp ((char *)symbol->name, "name[6] - '0'; diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c index a5fdae4..311192c 100644 --- a/bfd/vms-misc.c +++ b/bfd/vms-misc.c @@ -1,6 +1,6 @@ /* vms-misc.c -- Miscellaneous functions for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Klaus K"ampf (kkaempf@rmi.de) @@ -198,11 +198,12 @@ _bfd_vms_hash_newfunc (entry, table, string) bfd_set_error (bfd_error_no_memory); return (struct bfd_hash_entry *)NULL; } + entry = (struct bfd_hash_entry *) ret; } /* Call the allocation method of the base class. */ - ret = (vms_symbol_entry *) bfd_hash_newfunc ((struct bfd_hash_entry *)ret, table, string); + ret = (vms_symbol_entry *) bfd_hash_newfunc (entry, table, string); #if VMS_DEBUG vms_debug (6, "_bfd_vms_hash_newfunc ret %p\n", ret); #endif @@ -219,7 +220,7 @@ _bfd_vms_hash_newfunc (entry, table, string) void _bfd_vms_get_header_values (abfd, buf, type, length) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; unsigned char *buf; int *type; int *length; @@ -343,7 +344,8 @@ _bfd_vms_get_record (abfd) /* read the record header on Alpha. */ if ((test_len != 0) - && (bfd_read (PRIV(vms_buf), 1, test_len, abfd) != test_len)) + && (bfd_read (PRIV(vms_buf), 1, test_len, abfd) + != (bfd_size_type) test_len)) { bfd_set_error (bfd_error_file_truncated); return 0; @@ -418,7 +420,8 @@ _bfd_vms_get_record (abfd) #if VMS_DEBUG vms_debug (10, "bfd_read remaining %d\n", remaining); #endif - if (bfd_read (vms_buf + test_len, 1, remaining, abfd) != remaining) + if (bfd_read (vms_buf + test_len, 1, remaining, abfd) != + (bfd_size_type) remaining) { bfd_set_error (bfd_error_file_truncated); return 0; @@ -1007,10 +1010,8 @@ _bfd_vms_length_hash_symbol (abfd, in, maxlen) 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; @@ -1054,7 +1055,7 @@ _bfd_vms_length_hash_symbol (abfd, in, maxlen) if ((in_len > maxlen) && PRIV(flag_hash_long_names)) - sprintf (out, "_%08x", result); + sprintf (out, "_%08lx", result); else *out = 0; diff --git a/bfd/vms-tir.c b/bfd/vms-tir.c index 782f52b..124b1b3 100644 --- a/bfd/vms-tir.c +++ b/bfd/vms-tir.c @@ -1,6 +1,6 @@ /* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. TIR record handling functions ETIR record handling functions @@ -61,7 +61,7 @@ check_section (abfd, size) int offset; offset = PRIV(image_ptr) - PRIV(image_section)->contents; - if ((offset + size) > PRIV(image_section)->_raw_size) + if ((bfd_size_type) (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) @@ -121,7 +121,7 @@ image_dump (abfd, ptr, size, offset) bfd *abfd; unsigned char *ptr; int size; - int offset; + int offset ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr)); @@ -301,7 +301,7 @@ etir_sta (abfd, cmd, ptr) case ETIR_S_C_STA_PQ: { uquad dummy; - int psect; + unsigned int psect; psect = bfd_getl32 (ptr); if (psect >= PRIV(section_count)) @@ -559,7 +559,7 @@ static boolean etir_opr (abfd, cmd, ptr) bfd *abfd; int cmd; - unsigned char *ptr; + unsigned char *ptr ATTRIBUTE_UNUSED; { long op1, op2; @@ -791,7 +791,7 @@ static boolean etir_stc (abfd, cmd, ptr) bfd *abfd; int cmd; - unsigned char *ptr; + unsigned char *ptr ATTRIBUTE_UNUSED; { #if VMS_DEBUG @@ -907,7 +907,7 @@ etir_stc (abfd, cmd, ptr) static asection * new_section (abfd, idx) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; int idx; { asection *section; @@ -947,10 +947,8 @@ new_section (abfd, idx) static int alloc_section (abfd, idx) bfd *abfd; - int idx; + unsigned int idx; { - asection *section; - #if VMS_DEBUG _bfd_vms_debug (4, "alloc_section %d\n", idx); #endif @@ -1060,7 +1058,7 @@ tir_sta (bfd *abfd, unsigned char *ptr) */ { unsigned long dummy; - int psect; + unsigned int psect; if (cmd == TIR_S_C_STA_PB) psect = *ptr++; @@ -1092,7 +1090,7 @@ tir_sta (bfd *abfd, unsigned char *ptr) */ { unsigned long dummy; - int psect; + unsigned int psect; if (cmd == TIR_S_C_STA_PW) psect = *ptr++; @@ -1124,7 +1122,7 @@ tir_sta (bfd *abfd, unsigned char *ptr) */ { unsigned long dummy; - int psect; + unsigned int psect; if (cmd == TIR_S_C_STA_PL) psect = *ptr++; @@ -1672,7 +1670,7 @@ tir_ctl (bfd *abfd, unsigned char *ptr) */ { unsigned long dummy; - int psect; + unsigned int psect; #if VMS_DEBUG _bfd_vms_debug (5, "tir_ctl %d\n", *ptr); @@ -1942,7 +1940,7 @@ _bfd_vms_slurp_tir (abfd, objtype) int _bfd_vms_slurp_dbg (abfd, objtype) bfd *abfd; - int objtype; + int objtype ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (2, "DBG/EDBG\n"); @@ -1960,8 +1958,8 @@ _bfd_vms_slurp_dbg (abfd, objtype) int _bfd_vms_slurp_tbt (abfd, objtype) - bfd *abfd; - int objtype; + bfd *abfd ATTRIBUTE_UNUSED; + int objtype ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (2, "TBT/ETBT\n"); @@ -1978,8 +1976,8 @@ _bfd_vms_slurp_tbt (abfd, objtype) int _bfd_vms_slurp_lnk (abfd, objtype) - bfd *abfd; - int objtype; + bfd *abfd ATTRIBUTE_UNUSED; + int objtype ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (2, "LNK\n"); @@ -2094,7 +2092,7 @@ end_etir_record (abfd) int _bfd_vms_write_tir (abfd, objtype) bfd *abfd; - int objtype; + int objtype ATTRIBUTE_UNUSED; { asection *section; vms_section *sptr; @@ -2177,10 +2175,10 @@ _bfd_vms_write_tir (abfd, objtype) for (;;) { bfd_size_type addr = (*rptr)->address; - int len = bfd_get_reloc_size ((*rptr)->howto); + bfd_size_type len = bfd_get_reloc_size ((*rptr)->howto); if (sptr->offset < addr) /* sptr starts before reloc */ { - int before = addr - sptr->offset; + bfd_size_type before = addr - sptr->offset; if (sptr->size <= before) /* complete before */ { sto_imm (abfd, sptr, vaddr, section->index); @@ -2463,8 +2461,8 @@ _bfd_vms_write_tir (abfd, objtype) int _bfd_vms_write_tbt (abfd, objtype) - bfd *abfd; - int objtype; + bfd *abfd ATTRIBUTE_UNUSED; + int objtype ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (2, "vms_write_tbt (%p, %d)\n", abfd, objtype); @@ -2478,8 +2476,8 @@ _bfd_vms_write_tbt (abfd, objtype) int _bfd_vms_write_dbg (abfd, objtype) - bfd *abfd; - int objtype; + bfd *abfd ATTRIBUTE_UNUSED; + int objtype ATTRIBUTE_UNUSED; { #if VMS_DEBUG _bfd_vms_debug (2, "vms_write_dbg (%p, objtype)\n", abfd, objtype); diff --git a/bfd/vms.c b/bfd/vms.c index a5fc13a..f0ea63f 100644 --- a/bfd/vms.c +++ b/bfd/vms.c @@ -1,6 +1,6 @@ /* vms.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Klaus K"ampf (kkaempf@rmi.de) @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "vms.h" static boolean vms_initialize PARAMS ((bfd *)); -static int priv_section_count; +static unsigned 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)); @@ -132,11 +132,10 @@ static boolean vms_bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags)); 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 */ + BFD_ENDIAN_LITTLE, /* data byte order is little */ + BFD_ENDIAN_LITTLE, /* header byte order is little */ (HAS_RELOC | HAS_SYMS | WP_TEXT | D_PAGED), /* object flags */ @@ -170,16 +169,17 @@ const bfd_target vms_alpha_vec = BFD_JUMP_TABLE_LINK (vms), BFD_JUMP_TABLE_DYNAMIC (vms), + NULL, + (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 */ + BFD_ENDIAN_LITTLE, /* data byte order is little */ + BFD_ENDIAN_LITTLE, /* header byte order is little */ (HAS_RELOC | HAS_SYMS /* object flags */ | WP_TEXT | D_PAGED @@ -215,6 +215,8 @@ const bfd_target vms_vax_vec = BFD_JUMP_TABLE_LINK (vms), BFD_JUMP_TABLE_DYNAMIC (vms), + NULL, + (PTR) 0 }; @@ -331,7 +333,7 @@ fill_section_ptr (entry, sections) /* fill forward references (these contain section number, not section ptr). */ - if ((int)sec < priv_section_count) + if ((unsigned int) sec < priv_section_count) { sec = ((vms_symbol_entry *)entry)->symbol->section = ((asection **)sections)[(int)sec]; @@ -357,8 +359,6 @@ static boolean vms_fixup_sections (abfd) bfd *abfd; { - asection *s; - if (PRIV(fixup_done)) return true; @@ -538,7 +538,7 @@ vms_object_p (abfd) static const struct bfd_target * vms_archive_p (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_archive_p(%p)\n", abfd); @@ -646,7 +646,6 @@ vms_close_and_cleanup (abfd) { asection *sec; vms_section *es, *es1; - vms_reloc *er, *er1; int i; #if VMS_DEBUG @@ -722,7 +721,7 @@ vms_close_and_cleanup (abfd) /* Ask the BFD to free all cached information. */ static boolean vms_bfd_free_cached_info (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd); @@ -769,11 +768,11 @@ vms_new_section_hook (abfd, 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + PTR buf ATTRIBUTE_UNUSED; + file_ptr offset ATTRIBUTE_UNUSED; + bfd_size_type buf_size ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n", @@ -791,11 +790,11 @@ vms_get_section_contents (abfd, section, buf, offset, buf_size) 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + bfd_window *w ATTRIBUTE_UNUSED; + file_ptr offset ATTRIBUTE_UNUSED; + bfd_size_type count ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n", @@ -814,8 +813,8 @@ vms_get_section_contents_in_window (abfd, section, w, offset, count) static boolean vms_bfd_copy_private_bfd_data (src, dest) - bfd *src; - bfd *dest; + bfd *src ATTRIBUTE_UNUSED; + bfd *dest ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src, dest); @@ -833,8 +832,8 @@ vms_bfd_copy_private_bfd_data (src, dest) static boolean vms_bfd_merge_private_bfd_data (ibfd, obfd) - bfd *ibfd; - bfd *obfd; + bfd *ibfd ATTRIBUTE_UNUSED; + bfd *obfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd, obfd); @@ -852,8 +851,8 @@ vms_bfd_merge_private_bfd_data (ibfd, obfd) static boolean vms_bfd_set_private_flags (abfd, flags) - bfd *abfd; - flagword flags; + bfd *abfd ATTRIBUTE_UNUSED; + flagword flags ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd, (long)flags); @@ -867,10 +866,10 @@ vms_bfd_set_private_flags (abfd, flags) static boolean vms_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec) - bfd *srcbfd; - asection *srcsec; - bfd *dstbfd; - asection *dstsec; + bfd *srcbfd ATTRIBUTE_UNUSED; + asection *srcsec ATTRIBUTE_UNUSED; + bfd *dstbfd ATTRIBUTE_UNUSED; + asection *dstsec ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n", @@ -884,10 +883,10 @@ vms_bfd_copy_private_section_data (srcbfd, srcsec, dstbfd, dstsec) static boolean vms_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym) - bfd *ibfd; - asymbol *isym; - bfd *obfd; - asymbol *osym; + bfd *ibfd ATTRIBUTE_UNUSED; + asymbol *isym ATTRIBUTE_UNUSED; + bfd *obfd ATTRIBUTE_UNUSED; + asymbol *osym ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n", @@ -903,7 +902,7 @@ vms_bfd_copy_private_symbol_data (ibfd, isym, obfd, osym) static char * vms_core_file_failing_command (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd); @@ -917,7 +916,7 @@ vms_core_file_failing_command (abfd) static int vms_core_file_failing_signal (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd); @@ -931,8 +930,8 @@ vms_core_file_failing_signal (abfd) static boolean vms_core_file_matches_executable_p (abfd, bbfd) - bfd *abfd; - bfd *bbfd; + bfd *abfd ATTRIBUTE_UNUSED; + bfd *bbfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd, bbfd); @@ -947,7 +946,7 @@ vms_core_file_matches_executable_p (abfd, bbfd) static boolean vms_slurp_armap (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_slurp_armap(%p)\n", abfd); @@ -961,7 +960,7 @@ vms_slurp_armap (abfd) static boolean vms_slurp_extended_name_table (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_slurp_extended_name_table(%p)\n", abfd); @@ -975,10 +974,10 @@ vms_slurp_extended_name_table (abfd) static boolean vms_construct_extended_name_table (abfd, tabloc, tablen, name) - bfd *abfd; - char **tabloc; - bfd_size_type *tablen; - const char **name; + bfd *abfd ATTRIBUTE_UNUSED; + char **tabloc ATTRIBUTE_UNUSED; + bfd_size_type *tablen ATTRIBUTE_UNUSED; + const char **name ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_construct_extended_name_table(%p)\n", abfd); @@ -991,9 +990,9 @@ vms_construct_extended_name_table (abfd, tabloc, tablen, name) static void vms_truncate_arname (abfd, pathname, arhdr) - bfd *abfd; - CONST char *pathname; - char *arhdr; + bfd *abfd ATTRIBUTE_UNUSED; + CONST char *pathname ATTRIBUTE_UNUSED; + char *arhdr ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_truncate_arname(%p, %s, %s)\n", abfd, pathname, arhdr); @@ -1006,11 +1005,11 @@ vms_truncate_arname (abfd, pathname, arhdr) 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; + bfd *arch ATTRIBUTE_UNUSED; + unsigned int elength ATTRIBUTE_UNUSED; + struct orl *map ATTRIBUTE_UNUSED; + unsigned int orl_count ATTRIBUTE_UNUSED; + int stridx ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_write_armap(%p, %d, %p, %d %d)\n", @@ -1023,7 +1022,7 @@ vms_write_armap (arch, elength, map, orl_count, stridx) static PTR vms_read_ar_hdr (abfd) - bfd * abfd; + bfd * abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_read_ar_hdr(%p)\n", abfd); @@ -1040,8 +1039,8 @@ vms_read_ar_hdr (abfd) static bfd * vms_openr_next_archived_file (arch, prev) - bfd *arch; - bfd *prev; + bfd *arch ATTRIBUTE_UNUSED; + bfd *prev ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_openr_next_archived_file(%p, %p)\n", arch, prev); @@ -1084,7 +1083,7 @@ vms_generic_stat_arch_elt (abfd, stat) static boolean vms_update_armap_timestamp (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_update_armap_timestamp(%p)\n", abfd); @@ -1193,7 +1192,7 @@ _bfd_vms_make_empty_symbol (abfd) static void vms_print_symbol (abfd, file, symbol, how) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; PTR file; asymbol *symbol; bfd_print_symbol_type how; @@ -1241,7 +1240,7 @@ vms_print_symbol (abfd, file, symbol, how) static void vms_get_symbol_info (abfd, symbol, ret) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asymbol *symbol; symbol_info *ret; { @@ -1288,7 +1287,7 @@ vms_get_symbol_info (abfd, symbol, ret) static boolean vms_bfd_is_local_label_name (abfd, name) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; const char *name; { #if VMS_DEBUG @@ -1302,8 +1301,8 @@ vms_bfd_is_local_label_name (abfd, name) static alent * vms_get_lineno (abfd, symbol) - bfd *abfd; - asymbol *symbol; + bfd *abfd ATTRIBUTE_UNUSED; + asymbol *symbol ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_lineno(%p, %p)\n", abfd, symbol); @@ -1318,13 +1317,13 @@ vms_get_lineno (abfd, symbol) 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; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; + bfd_vma offset ATTRIBUTE_UNUSED; + CONST char **file ATTRIBUTE_UNUSED; + CONST char **func ATTRIBUTE_UNUSED; + unsigned int *line ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_find_nearest_line(%p, %s, %p, %ld, , , )\n", @@ -1340,9 +1339,9 @@ vms_find_nearest_line (abfd, section, symbols, offset, file, func, line) static asymbol * vms_bfd_make_debug_symbol (abfd, ptr, size) - bfd *abfd; - void *ptr; - unsigned long size; + bfd *abfd ATTRIBUTE_UNUSED; + void *ptr ATTRIBUTE_UNUSED; + unsigned long size ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd, ptr, size); @@ -1393,8 +1392,8 @@ vms_minisymbol_to_symbol (abfd, dynamic, minisym, sym) static long vms_get_reloc_upper_bound (abfd, section) - bfd *abfd; - asection *section; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_reloc_upper_bound(%p, %s)\n", abfd, section->name); @@ -1411,10 +1410,10 @@ vms_get_reloc_upper_bound (abfd, section) static long vms_canonicalize_reloc (abfd, section, location, symbols) - bfd *abfd; - asection *section; - arelent **location; - asymbol **symbols; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + arelent **location ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_canonicalize_reloc(%p, %s, , )\n", abfd, section->name); @@ -1429,13 +1428,13 @@ vms_canonicalize_reloc (abfd, section, location, symbols) 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; + bfd *abfd ATTRIBUTE_UNUSED; + arelent *reloc ATTRIBUTE_UNUSED; + asymbol *sym ATTRIBUTE_UNUSED; + PTR data ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + bfd *output_bfd ATTRIBUTE_UNUSED; + char **error_message ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd, output_bfd); @@ -1679,7 +1678,7 @@ static reloc_howto_type alpha_howto_table[] = static const struct reloc_howto_struct * vms_bfd_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { int alpha_type; @@ -1721,8 +1720,8 @@ vms_bfd_reloc_type_lookup (abfd, code) static boolean vms_set_arch_mach (abfd, arch, mach) bfd *abfd; - enum bfd_architecture arch; - unsigned long mach; + enum bfd_architecture arch ATTRIBUTE_UNUSED; + unsigned long mach ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_set_arch_mach(%p, %d, %ld)\n", abfd, arch, mach); @@ -1765,8 +1764,8 @@ vms_set_section_contents (abfd, section, location, offset, count) static int vms_sizeof_headers (abfd, reloc) - bfd *abfd; - boolean reloc; + bfd *abfd ATTRIBUTE_UNUSED; + boolean reloc ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_sizeof_headers(%p, %s)\n", abfd, (reloc)?"True":"False"); @@ -1781,12 +1780,12 @@ vms_sizeof_headers (abfd, reloc) 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; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; + struct bfd_link_order *link_order ATTRIBUTE_UNUSED; + bfd_byte *data ATTRIBUTE_UNUSED; + boolean relocateable ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n", @@ -1800,10 +1799,10 @@ vms_bfd_get_relocated_section_contents (abfd, link_info, link_order, data, static boolean vms_bfd_relax_section (abfd, section, link_info, again) - bfd *abfd; - asection *section; - struct bfd_link_info *link_info; - boolean *again; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; + boolean *again ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_relax_section(%p, %s, %p, )\n", @@ -1814,8 +1813,8 @@ vms_bfd_relax_section (abfd, section, link_info, again) static boolean vms_bfd_gc_sections (abfd, link_info) - bfd *abfd; - struct bfd_link_info *link_info; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_gc_sections(%p, %p)\n", abfd, link_info); @@ -1829,7 +1828,7 @@ vms_bfd_gc_sections (abfd, link_info) static struct bfd_link_hash_table * vms_bfd_link_hash_table_create (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_link_hash_table_create(%p)\n", abfd); @@ -1842,8 +1841,8 @@ vms_bfd_link_hash_table_create (abfd) static boolean vms_bfd_link_add_symbols (abfd, link_info) - bfd *abfd; - struct bfd_link_info *link_info; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_link_add_symbols(%p, %p)\n", abfd, link_info); @@ -1857,8 +1856,8 @@ vms_bfd_link_add_symbols (abfd, link_info) static boolean vms_bfd_final_link (abfd, link_info) - bfd *abfd; - struct bfd_link_info *link_info; + bfd *abfd ATTRIBUTE_UNUSED; + struct bfd_link_info *link_info ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_final_link(%p, %p)\n", abfd, link_info); @@ -1870,8 +1869,8 @@ vms_bfd_final_link (abfd, link_info) static boolean vms_bfd_link_split_section (abfd, section) - bfd *abfd; - asection *section; + bfd *abfd ATTRIBUTE_UNUSED; + asection *section ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_link_split_section(%p, %s)\n", abfd, section->name); @@ -1885,7 +1884,7 @@ vms_bfd_link_split_section (abfd, section) static long vms_get_dynamic_symtab_upper_bound (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_dynamic_symtab_upper_bound(%p)\n", abfd); @@ -1895,8 +1894,8 @@ vms_get_dynamic_symtab_upper_bound (abfd) static boolean vms_bfd_print_private_bfd_data (abfd, file) - bfd *abfd; - void *file; + bfd *abfd ATTRIBUTE_UNUSED; + void *file ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_bfd_print_private_bfd_data(%p)\n", abfd); @@ -1909,8 +1908,8 @@ vms_bfd_print_private_bfd_data (abfd, file) static long vms_canonicalize_dynamic_symtab (abfd, symbols) - bfd *abfd; - asymbol **symbols; + bfd *abfd ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_canonicalize_dynamic_symtab(%p, )\n", abfd); @@ -1923,7 +1922,7 @@ vms_canonicalize_dynamic_symtab (abfd, symbols) static long vms_get_dynamic_reloc_upper_bound (abfd) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_get_dynamic_reloc_upper_bound(%p)\n", abfd); @@ -1936,9 +1935,9 @@ vms_get_dynamic_reloc_upper_bound (abfd) static long vms_canonicalize_dynamic_reloc (abfd, arel, symbols) - bfd *abfd; - arelent **arel; - asymbol **symbols; + bfd *abfd ATTRIBUTE_UNUSED; + arelent **arel ATTRIBUTE_UNUSED; + asymbol **symbols ATTRIBUTE_UNUSED; { #if VMS_DEBUG vms_debug (1, "vms_canonicalize_dynamic_reloc(%p)\n", abfd); diff --git a/bfd/vms.h b/bfd/vms.h index d6bdd02..7143986 100644 --- a/bfd/vms.h +++ b/bfd/vms.h @@ -1,6 +1,6 @@ #undef vms /* vms.h -- Header file for VMS (Alpha and Vax) support. - Copyright 1996, 1997 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Klaus K"ampf (kkaempf@rmi.de) @@ -583,7 +583,7 @@ struct vms_private_data_struct { 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 */ + unsigned 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 */ diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index c882d23..3f488d7 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -1,5 +1,5 @@ /* POWER/PowerPC XCOFF linker support. - Copyright 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor , Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -3061,7 +3061,7 @@ 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; + boolean syscall ATTRIBUTE_UNUSED; { struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; @@ -3272,10 +3272,15 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 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; + if (entry == NULL) + hentry = NULL; + else + { + 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 @@ -6416,7 +6421,7 @@ _bfd_ppc_xcoff_relocate_section (output_bfd, info, input_bfd, { if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.string, input_bfd, input_section, - rel->r_vaddr - input_section->vma))) + rel->r_vaddr - input_section->vma, true))) return false; /* Don't try to process the reloc. It can't help, and diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b8a3d27..f89a4e8 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,894 @@ +2000-03-31 John David Anglin + + * readelf.c: Include sys/types.h before sys/stat.h for ultrix. + +2000-03-27 Nick Clifton + + * rddbg.c (read_section_stabs_debugging_info): Catch out of range + string offsets in corrupt stabs entries. + +2000-03-27 Alan Modra + + * readelf.c: Include elf/avr.h + (dump_relocations): Add EM_AVR case. + +2000-03-09 Tim Waugh + + * strings.1: Correct '-bytes' to '--bytes'. + +2000-03-08 H.J. Lu + + * Makefile.am (install-exec-local): Depend on + install-binPROGRAMS for parallel make. + * Makefile.in: Regenerated. + +2000-02-27 Ian Lance Taylor + + From Brad Lucier : + * readelf.c (process_dynamic_segment): Add cast to make sure + argument to %* is int. + +2000-02-25 H.J. Lu + + * configure.in (AC_SEARCH_LIBS): Pass m, not -lm. + +2000-02-24 Nick Clifton + + * configure.in: Add arm-wince, mips-pe and sh-pe targets. + * configure: Regenerate. + + * dlltoolc.: Add support for sh-pe and mips-pe targets. + * rescoff.c: Add support for sh-pe and mips-pe targets. + +2000-02-23 H.J. Lu + + * readelf.c (get_osabi_name): Handle ELFOSABI_LINUX. + +2000-02-22 Nick Clifton + + * readelf.c (process_symbol_table): Remove use of ELF_ST_OTHER. + +2000-02-22 Ian Lance Taylor + + From Brad Lucier : + * readelf.c (process_version_sections): Add casts to make sure + argument to %* is an int. + (process_mips_specific): Add casts to make printf arguments match + format. + +2000-02-21 Alan Modra + + * objdump.c (dump_section_header): Change `opb' to unsigned. + (find_symbol_for_address): Same here. + (disassemble_data): And here. Change `addr_offset', + `stop_offset', `nextstop_offset' to unsigned long. + (dump_data): Change opb to unsigned. + +2000-02-18 Frank Ch. Eigler + + * resrc.c: Remove unmatched #if for cygwin. + +2000-02-14 Fernando Nasser + + * binutils.texi: Document the change of flavor name from atpcs-special + to special-atpcs to prevent name conflict in gdb. + +2000-02-08 Timothy Wall + + * objdump.c (show_line): Fix bug preventing printing of the very + first line (line zero) of a file when interlisting source and + assembly. Added option to print entire context from start of file + when the first line from that file is encountered. + +2000-02-03 Timothy Wall + + * binutils/objdump.c (dump_section_header, find_symbol_for_address, + show_line, disassemble_bytes, disassemble_data, dump_data): + distinguish between octets and bytes. + +2000-01-27 Thomas de Lellis + + * nm.c (print_symbol_info_bsd): Use bfd_is_undefined_symclass to + check to unresolved symbols. + (print_symbol_info_sysv): Ditto. + (print_symbol_info_posix): Ditto. + + * binutils.texi: Document new 'V' symclass flag for nm. + +2000-01-27 Nick Clifton + + * binutils.texi (objdump): Document new ARM specific + disassembler options. + + * objdump.c (usage): Call disassembler_usage(). + +2000-01-27 Alan Modra + + * readelf.c (get_dynamic_flags): Return buff. + (process_dynamic_segment): Don't pass error strings to printf + as format arg. + (read_and_display_attr): Use lx and ld to print longs. + (process_corefile_note_segment): Cast bfd_vma to unsigned long + before printing. + Update copyright. + +2000-01-17 Nick Clifton + + * readelf.c (get_osabi_name): Recognise ELFOSABI_ARM. + +2000-01-15 Alan Modra + + * debug.c (debug_name_type): Return DEBUG_TYPE_NULL rather than + false. + (debug_tag_type): Here too. + * ieee.c (ieee_builtin_type): And here. + * stabs.c (parse_stab_type, parse_stab_array_type): And here. + +2000-01-13 Nick Clifton + + * readelf.c (get_machine_name): Change EM_S370 to return "IBM + System/370". + +2000-01-11 Nick Clifton + + * readelf.c (get_dynamic_type): Remove DT_ENCODING. + +2000-01-10 Nick Clifton + + * readelf.c (get_note_type): Display NT_WIN32PSTATUS notes. + +2000-01-07 Mumit Khan + + * windres.c (long_options): Add --use-temp-file and + --no-use-temp-file options. + (usage): Document. + (main): Handle. + + * windres.h: Update read_rc_file prototype. + + * resrc.c (cpp_temp_file): New static variable. + (istream_type): New static variable. + (close_pipe): Delete function. + (run_cmd): New static function. + (open_input_stream): New static function. + (close_input_stream): New static function. + (look_for_default): Handle DOS directory separator. Use + open_input_stream instead of popen. + (read_rc_file): Likewise. + + * binutils.texi: Document --use-temp-file, --no-use-temp-file + options. + +2000-01-04 Mumit Khan + + * dlltool.c (create_compat_implib): New variable. + (gen_exp_file): Use. + (make_one_lib_file): Use. + (long_options): Add --compat-implib option. + (usage): Handle. + (main): Handle. + + * dllwrap.c (enum target_type): Rename MINGW32_TARGET to MINGW_TARGET. + (main): Use. Don't look for "32" in cygwin and mingw target names. + +2000-01-03 Nick Clifton + + * binutils.texi: Document new, ARM specific disassembler + command line switch "-M force-thumb". + +1999-12-28 Nick Clifton + + * readelf.c: Update with new constants added by Oct 4, 1999 + ELF ABI draft. + (guess_is_rela): Add new machine codes, but leave + rel type undetermined. + (get_machine_name): Add new machine codes. + (get_section_type_name): Add new section types. + (get_elf_section_flags): New funciton: Decode section flags. + (process_section_headers): Call get_elf_section_flags() in + order to decode flags in section header. + (get_dynamic_flags): New function: Decode dynamic section + flags. + (process_dynamic_section): Display flags (if present). + (get_symbol_type): Add STT_COMMON. + (get_symbol_visibility): New function: Decode a symbol's + visibility. + (process_symbol_table): Call get_symbol_visibility(). + (get_note_type): Add NT_PRXFPREGS. + +1999-12-26 Ian Lance Taylor + + * strings.c (main): Correct handling of numeric argument. + +1999-12-23 Andrew Haley + + * dlltool.c (mtable): mcore how_jtab_roff is 4 bytes into the + jtab; was 8. + +1999-12-17 Nick Clifton + + * dlltool.c (mtable): Stop compile time warnings about missing + initialisers. + (yyerror): Stop compile time warnings about unused paramater. + (INIT_SEC_DATA): New macro: initialise an entry in the secdata + array. + (secdata): Stop ccompile time warnings about uninitialised + fields. + (dtab): Stop compile time warnings about unused parameter. + (long_options): Stop compile time warning about missing + initialiser. + +1999-12-10 Nick Clifton + + * readelf.c (print_vma): Support native 64bit ELF systems. + +1999-12-09 Nick Clifton + + * dlltool.c (mtable): Add epoc-arm specific entry. + Make default arm entry pass -mpacs-26 to assembler. + (flush_page): Do not mangle null entries. + +1999-12-07 H . J . Lu hjl@valinux.com + + * readelf.c: Fix compile time warnings. Support more than 999 + symbols. + +1999-12-03 Nick Clifton + + * readelf.c (enum print_mode): New type. + (print_vma): New function. + (dump_relocations): Use print_vma to display bfd_vma values. + (process_file_header): Use print_vma to display bfd_vma values. + (process_program_headers): Use print_vma to display bfd_vma values. + (process_section_headers): Use print_vma to display bfd_vma values. + (dynamic_segment_parisc_val): Use print_vma to display bfd_vma values. + (process_dynamic_segment): Use print_vma to display bfd_vma values. + (process_symbol_table): Use print_vma to display bfd_vma values. + (process_mips_specific): Use print_vma to display bfd_vma values. + +1999-11-25 Fred Fish + + * readelf.c (process_note): Change arg from Elf_External_Note + to Elf32_Internal_Note, which also turns the function body + into little more than a call to printf. + (process_corefile_note_segment): Substantially rewritten + to properly handle case where target and host are different + endianness, handle note sections with padding, and add some + cruft to handle notes with unterminated name data. + +1999-11-22 Nick Clifton + + * objcopy.c (copy_usage): Reformat. + (strip_usage): Reformat. + +1999-11-21 Nick Clifton + + * objdump.c (usage): Overhaul output: One line per switch. + Textual description of each switch. Distinguish between + optional switches and required switches. + (long_options): Add 'g', 'G' and 'z' short options. + (main): Distinguish between optional switches and required + switches. + + * binutils.texi: Add -g -G and -z short options for + --debugging, --stabs and --disassemble-zeroes. + +1999-11-03 Nick Clifton + + * dlltool.c (flush_page): Clip short values to prevent warnings + from the assembler. + Change default mcore machine name to 'mcore-le' and rename + big-endian version to 'mcore-be'. + +1999-10-27 Fred Fish + + * objdump.c (display_bfd): Break into two functions. The + actual dumping code moves to dump_bfd. If bfd is not + unambiguously recognized as a bfd_object, attempt to dump + it as a bfd_core. + (dump_bfd): New function. + +1999-10-26 Nick Clifton + + * dlltool.c (assemble_file): Remove spurious test of exp_name. + +1999-10-22 Nick Clifton + + * dlltool.c (struct mac): Add new field 'how_default_as_switches'. + (mtable): Initialise new field. Some machines have a non empty + string for this field. + (HOW_BFD_TARGET): Undefine and replace with... + (HOW_BFD_READ_TARGET): New macro: bfd target to use when opening a + file for reading. This is set to 0 so that any recognisable bfd + format can be read. + (HOW_BFD_WRITE_TARGET): New macro: bfd target to use when opening + a file for writing. This is set to the target machine type. + (ASM_SWITCHES): New macro: default switches to use when assembling + a file. + (assemble_file): New function: Assemble a source file into a + destination object file. + (gen_exp_file): Use assemble_file to create the exp file. + (make_one_lib_file): Use assemble_file to create the lib file. + Open output file use HOW_BFD_WRITE_TARGET and input files using + HOW_BFD_READ_TARGET. + (make_head): Use assemble_file to create the head file. + (make_tail): Use assemble_file to create the tail file. + (gen_lib_file): Open output file use HOW_BFD_WRITE_TARGET. + +1999-10-15 Ian Lance Taylor + + * ar.c (normalize): Fix full_pathname code. + +1999-10-08 Ben Elliston + + * binutils.texi: Some rewording and clarifications. + +1999-09-15 Ulrich Drepper + + * readelf.c (dynamic_segment_parisc_val): Print 0 for DLD_FLAGS if + the value is zero. + (process_symbol_table): Don't print histogram if hash table is empty. + +1999-09-15 Ulrich Drepper + + * readelf.c (get_parisc_dynamic_type): Handle DT_HP_GST_* values. + +1999-09-02 Ulrich Drepper + + * readelf.c (get_symbol_type): Add support for HPUX and PARISC + specific symbol types. + + * readelf.c: Add HPUX and PARISC extensions to dynamic and program + header table printing. + + * readelf.c (get_machine_flags): Add handling of PARISC. + +1999-09-29 Mumit Khan + + * dlltool.c (scan_drectve_symbols): Handle type tags in exported + symbols. + (scan_filtered_symbols): Likewise. + +1999-09-19 Ian Lance Taylor + + * resrc.c (write_rc_rcdata): Fix local variable shadowing + problem. If RCDATA_BUFFER data can be read as strings, modify + code to print the strings as comments. + * resres.c: Add casts to avoid warnings. + (write_res_data, read_res_data): Don't put the program name in the + error message; fatal already puts it there. + +1999-09-14 Michael Meissner + + * configure.in (Canonicalization of target names): Remove adding + ${CONFIG_SHELL} in front of $ac_config_sub, since autoconfig 2.14 + generates $ac_config_sub with a ${CONFIG_SHELL} already. + * configure: Regenerate. + +1999-09-12 Ian Lance Taylor + + * ar.c (main): Clear output_file if we don't change the archive. + (delete_members, replace_members): Likewise. + +1999-09-12 Donn Terry + + * objdump.c (dump_headers): If wide_output, print Flags header. + + * objdump.c (dump_section_header): Print any comdat information. + + * objcopy.c (parse_flags): Handle "noload", "debug", and "share". + * binutils.texi, objcopy.1: Document new flags. + + * ar.c (counted_name_mode): New static variable. + (counted_name_counter): New static variable. + (map_over_members): Handle counted mode. + (usage): Mention N modifier. + (main): Handle N modifier. + (delete_members): Handle counted mode. + * binutils.texi, ar.1: Document N modifier. + + * ar.c (print_contents): Change printing of member name for + POSIX.2 conformance. + + * ar.c (output_filename): Make const. + (open_inarch): If creating a new empty archive, set + output_filename. + +1999-09-12 Ian Lance Taylor + + * ar.c (full_pathname): New static variable. + (map_over_members): Call normalize on command line parameter. + (usage): Mention P modifier. + (normalize): If full_pathname is true, don't do anything. + (main): Accept P modifier. + (delete_members): Call normalize on command line parameter. + * binutils.texi, ar.1: Document P modifier. + +1999-09-09 Andreas Schwab + + * binutils.texi: Add info dir entries for all programs described + here. Fix arguments of @var to not contain punctuation. + +1999-09-06 Donn Terry + + * nm.c (print_symbol_info_bsd): Check for 'w' as well as 'U'. + (print_symbol_info_sysv): Likewise. + (print_symbol_info_posix): Likewise. + +1999-09-04 Steve Chamberlain + + * readelf.c: Include "elf/pj.h". + (dump_relocations): Handle EM_PJ. + (get_machine_name): Likewise. + (get_machine_flags): Likewise. + +1999-08-31 Scott Bambrough + + * readelf.c (get_note_type): New function: Decode the e_type + value of a note. + (process_note): New function: Display the contents of a core note. + (process_corefile_note_segment): New function. + (process_corefile_note_segments): New function. + (process_corefile_contents): New function. + (process_file): Add call to process_corefile_contents. + (parse_args): Add parsing of -n/--notes command line switch. + (usage): Document new command line switch. + + * binutils.texi: Documemnt new command line switch to readelf. + +1999-08-31 Ian Lance Taylor + + * binutils.texi (Bug Reporting): Clarify that large files should + not be sent to bug-gnu-utils. + +1999-08-28 Stephane Carrez + + * readelf.c (process_extended_line_op): New parameter pointer_size, + read the address according to pointer_size. + (debug_line_pointer_size): New global to indicate the + size of address in .debug_line section. + (debug_displays, prescan_debug_info): Prescan the .debug_info section + to record the size of address in `debug_line_pointer_size'. + (process_section_contents): Before dumping any section, execute + the pre-scan operation defined for some debug sections. + +1999-08-27 Jim Wilson + + * readelf.c (display_debug_lines): Use i-1 not i in standard_opcodes + access. + (display_debug_aranges): New local excess. Use for calculating padding + and add that into ranges. Break from loop only if length is also 0. + +1999-08-27 Jim Wilson + + * readelf.c (display_debug_lines, case DW_LNS_const_add_pc): Multiply + adv by info.li_min_insn_length. + +1999-08-26 Jakub Jelinek + + * readelf.c (get_sparc64_dynamic_type): New function. + (get_dynamic_type): Use it. + +1999-08-26 Jim Wilson + + * readelf.c (display_debug_lines, case default): Change second line + setting adv to use = not +=. + +1999-08-19 Nick Clifton + + * dlltool.c: Added more examples to the comment at the start. + +1999-08-18 Nick Clifton + + * dlltool.c (make_head): Only emit interworking directive if + necessary. + +Thu Jul 15 22:44:21 1999 Hans-Peter Nilsson + + * readelf.c (process_abbrev_section): Handle standard-conforming + single zero at the end of the section. + +1999-08-09 Ian Lance Taylor + + * objdump.c (exit_status): New static variable. + (nonfatal): New static function. + (disassemble_data): Set exit_status on error. + (read_section_stabs): Likewise. + (display_bfd): Likewise. Call nonfatal rather than bfd_nonfatal. + (display_file): Call nonfatal rather than bfd_nonfatal. + (display_target_list, display_info_table): Likewise. + (main): Return exit_status rather than 0. + +1999-08-08 Ian Lance Taylor + + * objdump.c (dump_section_header): Update for renaming of + SEC_SHORT to SEC_SMALL_DATA. Print SEC_SHARED flag. + + From Eli Zaretskii : + * binutils.texi: Document cxxfilt as MS-DOS name for c++filt. + + * configure.in: Define and substitute DEMANGLER_NAME. + * Makefile.am (DEMANGLER_PROG): Set to cxxfilt. + (man_MANS): Use DEMANGLER_NAME rather than DEMANGLER_PROG. + (bin_PROGRAMS): Remove $(DEMANGLER_PROG). + (noinst_PROGRAMS): Add $(DEMANGLER_PROG). + (cxxfilt_SOURCES): Rename from c__filt_SOURCES. + (cxxfilt_LDADD): Rename from c__filt_LDADD. + ($(DEMANGLER_NAME).1): Rename from $(DEMANGLER_PROG).1. Use + DEMANGLER_NAME rather than DEMANGLER_PROG in substitution. + (MOSTLYCLEANFILES): Use DEMANGLER_NAME rather than + DEMANGLER_PROG. + (install-exec-local): When installing noinst_PROGRAMS, change + cxxfilt to $(DEMANGLER_NAME). + * configure, Makefile.in: Rebuild. + + * Makefile.am: Rename .dep* files to DEP*. Change DEP variable to + MKDEP. + * Makefile.in: Rebuild. + +1999-08-05 Donn Terry + + * Makefile.am (YACC): If bison is not in the source tree, use + @YACC@ rather than bison -y. + (LEX): If flex is not in the source tree, use @LEX@ rather than + flex. + * configure.in: Build dlltool for i[3-6]86-*-interix. + * Makefile.in, configure: Rebuild. + +1999-07-21 Ian Lance Taylor + + From Mark Elbrecht: + * configure.bat: Remove; obsolete. + +1999-07-16 Jakub Jelinek + + * readelf.c (get_machine_flags): Print EF_SPARC_SUN_US3. + +1999-07-15 Ian Lance Taylor + + * configure.in: Bump version number to 2.9.5. + * configure: Rebuild. + +1999-07-14 Richard Henderson + + * objdump.c (dump_section_header): Print SEC_SHORT. + +1999-07-11 Ian Lance Taylor + + * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSED + as appropriate. Add variable initializations. Add casts. + * objdump.c (disassemble_bytes): Change j to bfd_vma. + * readelf.c (process_syminfo): Change i to unsigned int. + (display_debug_info): Change abbrev_number to unsigned long. + (process_mips_specific): Change fcnt to size_t. + +1999-07-09 Nick Clifton + + * readelf.c: Only support decoding 64bit ELF files if the compiler + supports a 64 bit data type. + Add -I equivalent for --histogram. + Add -A command-line option to display architecture specific information. + +1999-07-08 Jakub Jelinek + + * readelf.c (guess_is_rela): Sparcv9 and v8plus use rela. + (dump_relocations): Use ELF64_R_TYPE_ID for Sparc, for R_SPARC_OLO10 + print the secondary addend. + (get_machine_flags): Print Sparc machine flags. + (get_symbol_type): Print STT_REGISTER. + +1999-07-08 Ian Lance Taylor + + * stabs.c (parse_stab_type): Fix handling of template names with + template parameters containing `::'. + (stab_demangle_type): Handle a qualified name in a pointer to + member. + +1999-06-23 Ian Lance Taylor + + * Makefile.am (dlltool_SOURCES): Add dyn-string.c. + * Makefile.in: Rebuild. + +1999-06-23 Mumit Khan + + * configure.in (HAVE_EXECUTABLE_SUFFIX): Define. + * dlltool.c (look_for_prog): Use HAVE_EXECUTABLE_SUFFIX. + * dllwrap.c (look_for_prog): Likewise. + * resrc.c (look_for_default): Likewise. + * configure, config.in: Rebuild. + +1999-06-22 Ian Lance Taylor + + Based on patches from Mumit Khan : + * configure.in: Define EXECUTABLE_SUFFIX. + * dlltool.c: Include "dyn-string.h". Include based on + ANSI_PROTOTYPES, not __STDC__. + (outfile): Remove. + (gen_exp_file): Change uses of outfile to use alloca. + (make_one_lib_file, make_head, make_tail): Likewise. + (gen_lib_file): Likewise. + (look_for_prog): New static function. + (deduce_name): Rewrite to use look_for_prog. + (mcore_elf_gen_out_file): Use dyn_string_t rather than outfile. + * dllwrap.c: Don't include , , , + , or . Include and either + or . + (driver_name): Initialize to NULL, not "gcc". + (dlltool_name): Initialize to NULL, not "dlltool". + (display, inform, look_for_prog, deduce_name): New static + functions. + (usage): Mention -mno-cygwin. + (OPTION_MNO_CYGWIN): Define. + (main): Handle -mno-cygwin. Deduce driver_name and dlltool_name. + * resrc.c (look_for_default): Make static. Remove unused local + path. Check using EXECUTABLE_SUFFIX. + (read_rc_file): Allocate enough space to hold EXECUTABLE_SUFFIX. + * Makefile.am: Rebuild dependencies. + (dllwrap_LDADD): Add $(INTLLIBS). + * configure, Makefile.in, config.in: Rebuild. + +Mon Jun 21 16:49:11 1999 Jeffrey A Law (law@cygnus.com) + + * readelf.c (dump_relocations): Use elf_hppa_reloc_type instead of + elf32_hppa_reloc_type. + +1999-06-17 Nick Clifton + + * dlltool.c (mcore_elf_gen_out_file): Link object files with the + .exp file, not the .lib file. + +Fri Jun 18 20:17:51 1999 Mumit Khan + + * deflex.l: Accept single-character symbol names. + +1999-06-16 Nick Clifton + + * readelf.c (get_symbol_type): Detect ARM symbols typed as Thumb + functions. + +1999-06-14 Nick Clifton + + * objdump.c (disassembler_options): New variable. + (usage): Document new -M/--disassembler-options option. + (long_options): Add --disassembler-options. + (disassemble_data): Initialise disassembler_options field of + disassembler_info structure. + (main): Add parsing of -M option. + + * binutils.texi: Document new command line switch to objdump. + + * NEWS: Describe new command line switch to objdump. + + +Mon Jun 14 10:27:54 1999 Andreas Schwab + + * binutils.texi: Fix typos. + +1999-06-13 Ian Lance Taylor + + * objdump.c (disassemble_bytes): If the disassembler returns an + error, print out anything it may have printed to the buffer. From + H.J. Lu . + + * defparse.y (explist): Remove separate expline to eliminate + shift/reduce conflict. + + From Kai-Uwe Rommel : + * defparse.y: Add tokens NONSHARED, SINGLE, MULTIPLE, + INITINSTANCE, INITGLOBAL, TERMINSTANCE, and TERMGLOBAL. + (command): Add option_list after LIBRARY. + (attr): Accept and ignore NONSHARED, SINGLE, and MULTIPLE. + (option_list, option): New nonterminals. + * deflex.l: Recognize NONSHARED, SINGLE, MULTIPLE, INITINSTANCE, + INITGLOBAL, TERMINSTANCE, and TERMGLOBAL. + +1999-06-12 Ian Lance Taylor + + * ar.c (O_BINARY): Define as 0 if not defined. + (ranlib_touch): Open file with O_BINARY. + + * rename.c (O_BINARY): Define as 0 if not defined. + (simple_copy): Open files with O_BINARY. + + Based on patch from H. Peter Anvin : + * objcopy.c (struct section_list): Add copy field. + (sections_copied): New static variable. + (copy_options): Add "only-section". + (copy_usage): Mention -j and --only-section. + (find_section_list): Initialize copy field. + (is_strip_section): Check for copying sections. + (copy_object): Check sections_copied when calling filter_symbols. + (setup_section): Check for copying sections. + (copy_section): Likewise. + (copy_main): Handle -j/--only-section. + * binutils.texi, objcopy.1: Document -j/--only-section. + + * configure.in: If frexp is not available, check in -lm. + * configure: Rebuild. + + * readelf.c (get_elf_class): Use correct printf format for type. + (get_data_encoding): Likewise. + (get_osabi_name): Likewise. + (process_file_header): Don't pass an extra argument to printf. + (process_dynamic_segment): Cast dynamic_size to long before + printing. + (decode_location_expression): Cast byte_get to long before + printing. + +Wed Jun 9 11:40:16 1999 Andreas Schwab + + * readelf.c (dump_section): Cast values from byte_get to + [unsigned] long for printing, in case it is wider than long. + (display_block): Likewise. + (read_and_display_attr): Likewise. + (decode_location_expression): Likewise. Don't depend on + evaluation order. + +Mon Jun 7 12:14:57 1999 Andreas Schwab + + * windres.c (usage): Fix typo. + +1999-06-04 Nick Clifton + + * readelf.c: Use 64bit wide fields in internal strcutures even if + targetting a 32bit architecture. + (dump_relocations): Take a new parameter - the number of symbols + in the symbol table. + +1999-06-04 Nick Clifton + + * readelf.c: Add support for 64bit ELF files. + +1999-06-03 Nick Clifton + + * dlltool.c (mcore_elf_gen_out_file): Use constants for temporary + file names. + +Wed Jun 2 12:34:36 1999 Richard Henderson + + * dlltool.c (gen_exp_file): Revert 19990411 change. + +Mon May 31 09:56:22 1999 Andreas Schwab + + * readelf.c (process_relocs): Determine type of reloc from + DT_PLTREL and from section type. + +1999-05-29 Nick Clifton + + * readelf.c (get_elf_class): Display unknown class number. + (get_data_encoding): Display unknown encoding number. + (get_osabi_name): Display unknown ABI number. + (process_file_header): Display unknown version number. + +1999-05-29 Nick Clifton + + * readelf.c (dump_relocations): Fix typo. + +1999-05-28 Nick Clifton + + * readelf.c (dump_relocations): Add extra parameter: is_rela to + specify the kind of relocations to be dumped. Call guess_is_rela + if this parameter has a value of UNKNOWN. + (guess_is_rela): New function: Guess the kind of reloc being used + baced on the machine number. + (process_relocs): Determine type of reloc before calling + dump_relocations. + +1999-05-28 Ian Lance Taylor + + * readelf.c: Include "elf/i960.h". + (dump_relocations): Handle EM_960. + +Thu May 27 11:58:33 1999 Andreas Schwab + + * objcopy.c (copy_archive): Preserve dates of archive members if + requested. + + * readelf.c (dump_relocations): Always print the addend on RELA + systems even if there is no symbol. + (process_program_headers): Reset dynamic_size before looping + through the program headers. + (process_version_sections): Cast sh_offset to unsigned long for + printing in case bfd_vma is wider. + (process_symbol_table): Use get_symbol_index_type when printing + st_shndx. + +1999-05-17 DJ Delorie + + * windres.c: add verbose option + (main): process verbose option + * resrc.c (look_for_default): new. Look for the default + preprocessor in a given location. + (read_rc_file): for foo/bar-windres, look for foo/bar-gcc, + foo/gcc (in case of foo/windres), and then gcc (the old default). + +1999-05-16 Nick Clifton + + * dlltool.c (deduce_name): New function: Deduce name of program to + run. + (mcore_elf_out_file): New variable: Name of mcore-elf output file. + (mcore_elf_linker): New variable: Name of linker to use. + (mcore_elf_linker_flags): New variable: Linker flags to pass. + (scan_obj_file): Cache filenames if necessary. + (usage): Document new command line options. + (main): Support new command line options: -M (generate an + mcore-elf output file) -L (name of linker to use) -F (flags to + pass to linker). + (mcore_elf_cache_filename): Store a filename in a cache. + (mcore_elf_gen_out_file): New function: Generate an output file + per the mcore-elf spec. + +1999-05-15 Nick Clifton + + * configure.in (BUILD_MISC): Build dlltool for mcore + * configure: Regenerate. + * dlltool.c: Update example in comment. + (DLLTOOL_MCORE): Define. + (DLLTOOL_MCORE_ELF): Define. + (DRECTVE_SECTION_NAME): Define. + (mcore_be_jtab, mcore_le_jtab): Binary for performing an mcore + jump to address. + (mtable): Add entries for mcore variants. + (rvaafter, rvabefore, asm_prefix): Add mcore suppport. + (scan_drectve_symbols): Use DRECTVE_SECTION_NAME. + (make_head, make_tail): Cope if file cannot be created. + (usage): Improve layout. + +1999-05-13 DJ Delorie + + * rclex.l: add code to suppress certain output from cpp, replace + all returns with MAYBE_RETURN + (MAYBE_RETURN): new, implement the suppression by returning + IGNORED_TOKEN as needed. + (cpp_line): remember which file we're in, mark data from included + *.h files for suppression. + * rcparse.y (input): allow IGNORED_TOKEN outside of known constructs + +1999-05-10 DJ Delorie + + * windres.c (quot): Quote shell metacharacters in a string + (main): quote parameters to cpp that might have metacharacters in + them. Allow -D as an alias for --define to allow for sharing make + macros with gcc. + + * objdump.c (dump_reloc_set): don't core if howto->name is NULL + + * Makefile.am: Give rescoff.c a cpu-specific -D so it can set + the correct BFD. + * Makefile.in: ditto + * rescoff.c (write_coff_file): Set the correct BFD + +1999-05-06 Ian Lance Taylor + + * rename.c (smart_rename): Fix test of whether file exists. + +1999-05-06 Nick Clifton + + * objdump.c (disassemble_data): Set display_endian based on target + endianism. + +1999-05-05 Catherine Moore + + * dlltool.c (interwork): Remove. + (arm_interwork_jtab): Use bx insn. + (thumb_jtab): Likewise. + (MARM_INTERWORK): New machine type. + (rvaafter): Handle it. + (rvabefore) Likewise. + (asm_prefix): Likewise. + (gen_exp_type): Check machine type instead of + interwork flag. + (make_one_lib_file): Likewise. + (make_head): Likewise. + (make_tail): Likewise. + (usage): Update machine types. + (main): Remove -interwork support. + +1999-05-05 Catherine Moore + + * readelf.c (get_machine_flags): Check for EF_CPU32. + (get_data_encoding): Fix typo. + 1999-04-26 Tom Tromey * aclocal.m4, configure: Updated for new version of libtool. @@ -63,7 +954,7 @@ Tue Apr 13 21:22:00 1999 Catherine Moore 1999-04-05 Nick Clifton * readelf.c (decode_location_expression): Fix DW_OP_const8{s|u} - decodes. + decodes. 1999-04-04 Ian Lance Taylor diff --git a/binutils/Makefile.am b/binutils/Makefile.am index 4f3014f..f98438e 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -15,9 +15,9 @@ tooldir = $(exec_prefix)/$(target_alias) CC_FOR_BUILD = @CC_FOR_BUILD@ EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ -YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L$(srcdir)/../bison/ ; else echo bison -y ; fi` +YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi` YFLAGS = -d -LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi` +LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi` # these two are almost the same program AR_PROG=ar @@ -38,7 +38,7 @@ OBJDUMP_PROG=objdump # This is the demangler, as a standalone program. # Note: This one is used as the installed name too, unlike the above. -DEMANGLER_PROG=c++filt +DEMANGLER_PROG=cxxfilt ADDR2LINE_PROG=addr2line @@ -50,14 +50,15 @@ DLLWRAP_PROG=dllwrap SRCONV_PROG=srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) man_MANS = ar.1 nm.1 objdump.1 ranlib.1 size.1 strings.1 strip.1 objcopy.1 \ - addr2line.1 nlmconv.1 $(DEMANGLER_PROG).1 + addr2line.1 nlmconv.1 $(DEMANGLER_NAME).1 PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ -bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ +bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ -## We need a special rule to install the programs which are built with -new -noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) +## We need a special rule to install the programs which are built with +## -new, and to rename cxxfilt to c++filt. +noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG) EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG) @@ -68,7 +69,7 @@ BASEDIR = $(srcdir)/.. BFDDIR = $(BASEDIR)/bfd INCDIR = $(BASEDIR)/include -DEP = mkdep +MKDEP = mkdep INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl -DLOCALEDIR="\"$(prefix)/share/locale\"" @@ -178,8 +179,8 @@ stamp-under: Makefile cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h $(COMPILE) -c -DMAIN -DVERSION='"$(VERSION)"' $(BASEDIR)/libiberty/cplus-dem.c -c__filt_SOURCES = -c__filt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS) +cxxfilt_SOURCES = +cxxfilt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS) ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c $(BULIBS) ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) @@ -234,12 +235,15 @@ sysinfo.o: sysinfo.c srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) -dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) +dlltool_SOURCES = dlltool.c defparse.y deflex.l dyn-string.c $(BULIBS) dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) dlltool.o:dlltool.c $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/dlltool.c +rescoff.o:rescoff.c + $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/rescoff.c + coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) sysdump_SOURCES = sysdump.c $(BULIBS) @@ -257,7 +261,7 @@ windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.l \ windres_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) dllwrap_SOURCES = dllwrap.c dyn-string.c -dllwrap_LDADD = $(LIBIBERTY) +dllwrap_LDADD = $(LIBIBERTY) $(INTLLIBS) DISTSTUFF = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ @@ -269,18 +273,18 @@ DISTCLEANFILES = stamp-under sysinfo underscore.c sysroff.c sysroff.h \ site.exp site.bak # Targets to rebuild dependencies in this Makefile. -# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES). -.dep: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h - rm -f .dep1 - $(MAKE) DEP=$(DEP) .dep1 - sed -f dep.sed <.dep1 >.dep +# Have to get rid of DEP1 here so that "$?" later includes all of $(CFILES). +DEP: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h + rm -f DEP1 + $(MAKE) MKDEP=$(MKDEP) DEP1 + sed -f dep.sed DEP # This rule really wants a mkdep that runs "gcc -MM". -.dep1: $(CFILES) $(GENERATED_CFILES) - rm -f .dep2 - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2 - $(DEP) -f .dep2 $(INCLUDES) $? - $(SHELL) $(srcdir)/../move-if-change .dep2 .dep1 +DEP1: $(CFILES) $(GENERATED_CFILES) + rm -f DEP2 + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP2 + $(MKDEP) -f DEP2 $(INCLUDES) $? + $(SHELL) $(srcdir)/../move-if-change DEP2 DEP1 dep.sed: dep-in.sed config.status objdir=`pwd`; \ @@ -290,19 +294,19 @@ dep.sed: dep-in.sed config.status -e 's!@SRCDIR@!$(srcdir)!' \ -e "s!@OBJDIR@!$${objdir}!" -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am .PHONY: dep dep-in dep-am @@ -319,24 +323,24 @@ binutils.info: $(srcdir)/binutils.texi config.texi MAINTAINERCLEANFILES = config.texi -$(DEMANGLER_PROG).1: cxxfilt.man Makefile - sed -e 's/@PROGRAM@/$(DEMANGLER_PROG)/' < $(srcdir)/cxxfilt.man \ - > $(DEMANGLER_PROG).1 +$(DEMANGLER_NAME).1: cxxfilt.man Makefile + sed -e 's/@PROGRAM@/$(DEMANGLER_NAME)/' < $(srcdir)/cxxfilt.man \ + > $(DEMANGLER_NAME).1 -MOSTLYCLEANFILES = sysinfo $(DEMANGLER_PROG).1 binutils.log binutils.sum \ +MOSTLYCLEANFILES = sysinfo $(DEMANGLER_NAME).1 binutils.log binutils.sum \ abcdefgh* mostlyclean-local: -rm -rf tmpdir -CLEANFILES = dep.sed .dep .dep1 +CLEANFILES = dep.sed DEP DEP1 .PHONY: install-exec-local -install-exec-local: $(bin_PROGRAMS) $(noinst_PROGRAMS) +install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS) @list='$(noinst_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done $(mkinstalldirs) $(tooldir)/bin @@ -378,7 +382,8 @@ debug.o: debug.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ debug.h dlltool.o: dlltool.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h $(INCDIR)/demangle.h dlltool.h + $(INCDIR)/getopt.h $(INCDIR)/demangle.h dyn-string.h \ + dlltool.h filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h ieee.o: ieee.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/ieee.h \ @@ -459,8 +464,8 @@ readelf.o: readelf.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/m32r.h $(INCDIR)/elf/d10v.h \ $(INCDIR)/elf/d30v.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/mn10200.h \ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/arc.h \ - $(INCDIR)/elf/fr30.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h + $(INCDIR)/elf/fr30.h $(INCDIR)/elf/mcore.h $(INCDIR)/elf/i960.h \ + bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h resres.o: resres.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ windres.h winduni.h diff --git a/binutils/Makefile.in b/binutils/Makefile.in index c32ae4d..b3d4360 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -75,6 +75,7 @@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ DATADIRNAME = @DATADIRNAME@ +DEMANGLER_NAME = @DEMANGLER_NAME@ DLLTOOL = @DLLTOOL@ DLLTOOL_DEFS = @DLLTOOL_DEFS@ EXEEXT = @EXEEXT@ @@ -87,7 +88,6 @@ INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLOBJS = @INTLOBJS@ -LD = @LD@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAINT = @MAINT@ @@ -95,7 +95,7 @@ MAKEINFO = @MAKEINFO@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ NLMCONV_DEFS = @NLMCONV_DEFS@ -NM = @NM@ +OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ POFILES = @POFILES@ POSUB = @POSUB@ @@ -103,7 +103,6 @@ RANLIB = @RANLIB@ UNDERSCORE = @UNDERSCORE@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ -USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@ VERSION = @VERSION@ l = @l@ @@ -118,9 +117,9 @@ tooldir = $(exec_prefix)/$(target_alias) CC_FOR_BUILD = @CC_FOR_BUILD@ EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ -YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L$(srcdir)/../bison/ ; else echo bison -y ; fi` +YACC = `if [ -f ../bison/bison ]; then echo ../bison/bison -y -L$(srcdir)/../bison/; else echo @YACC@; fi` YFLAGS = -d -LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi` +LEX = `if [ -f ../flex/flex ]; then echo ../flex/flex; else echo @LEX@; fi` # these two are almost the same program AR_PROG = ar @@ -141,7 +140,7 @@ OBJDUMP_PROG = objdump # This is the demangler, as a standalone program. # Note: This one is used as the installed name too, unlike the above. -DEMANGLER_PROG = c++filt +DEMANGLER_PROG = cxxfilt ADDR2LINE_PROG = addr2line @@ -153,14 +152,14 @@ DLLWRAP_PROG = dllwrap SRCONV_PROG = srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) man_MANS = ar.1 nm.1 objdump.1 ranlib.1 size.1 strings.1 strip.1 objcopy.1 \ - addr2line.1 nlmconv.1 $(DEMANGLER_PROG).1 + addr2line.1 nlmconv.1 $(DEMANGLER_NAME).1 PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ -bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ +bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ -noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) +noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG) EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG) @@ -171,7 +170,7 @@ BASEDIR = $(srcdir)/.. BFDDIR = $(BASEDIR)/bfd INCDIR = $(BASEDIR)/include -DEP = mkdep +MKDEP = mkdep INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl -DLOCALEDIR="\"$(prefix)/share/locale\"" @@ -254,8 +253,8 @@ nm_new_SOURCES = nm.c $(BULIBS) objdump_SOURCES = objdump.c prdbg.c $(DEBUG_SRCS) $(BULIBS) objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(INTLLIBS) -c__filt_SOURCES = -c__filt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS) +cxxfilt_SOURCES = +cxxfilt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS) ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c $(BULIBS) ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) @@ -267,7 +266,7 @@ addr2line_SOURCES = addr2line.c $(BULIBS) srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) -dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) +dlltool_SOURCES = dlltool.c defparse.y deflex.l dyn-string.c $(BULIBS) dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) @@ -282,7 +281,7 @@ windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.l \ windres_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS) dllwrap_SOURCES = dllwrap.c dyn-string.c -dllwrap_LDADD = $(LIBIBERTY) +dllwrap_LDADD = $(LIBIBERTY) $(INTLLIBS) DISTSTUFF = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \ syslex.c deflex.c defparse.h defparse.c rclex.c rcparse.h rcparse.c @@ -294,20 +293,20 @@ DISTCLEANFILES = stamp-under sysinfo underscore.c sysroff.c sysroff.h \ MAINTAINERCLEANFILES = config.texi -MOSTLYCLEANFILES = sysinfo $(DEMANGLER_PROG).1 binutils.log binutils.sum \ +MOSTLYCLEANFILES = sysinfo $(DEMANGLER_NAME).1 binutils.log binutils.sum \ abcdefgh* -CLEANFILES = dep.sed .dep .dep1 +CLEANFILES = dep.sed DEP DEP1 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = bin_PROGRAMS = size$(EXEEXT) objdump$(EXEEXT) ar$(EXEEXT) \ -strings$(EXEEXT) ranlib$(EXEEXT) c++filt$(EXEEXT) objcopy$(EXEEXT) \ -@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ \ -addr2line$(EXEEXT) readelf$(EXEEXT) @BUILD_DLLWRAP@ @BUILD_MISC@ -noinst_PROGRAMS = nm-new$(EXEEXT) strip-new$(EXEEXT) +strings$(EXEEXT) ranlib$(EXEEXT) objcopy$(EXEEXT) @BUILD_NLMCONV@ \ +@BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ addr2line$(EXEEXT) \ +readelf$(EXEEXT) @BUILD_DLLWRAP@ @BUILD_MISC@ +noinst_PROGRAMS = nm-new$(EXEEXT) strip-new$(EXEEXT) cxxfilt$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) @@ -331,8 +330,8 @@ coffdump_OBJECTS = coffdump.o coffgrok.o bucomm.o version.o filemode.o coffdump_LDADD = $(LDADD) coffdump_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a coffdump_LDFLAGS = -dlltool_OBJECTS = dlltool.o defparse.o deflex.o bucomm.o version.o \ -filemode.o +dlltool_OBJECTS = dlltool.o defparse.o deflex.o dyn-string.o bucomm.o \ +version.o filemode.o dlltool_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a dlltool_LDFLAGS = windres_OBJECTS = windres.o resrc.o rescoff.o resbin.o rcparse.o \ @@ -363,10 +362,6 @@ ranlib_OBJECTS = ar.o is-ranlib.o arparse.o arlex.o arsup.o rename.o \ bucomm.o version.o filemode.o ranlib_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a ranlib_LDFLAGS = -c__filt_OBJECTS = -c__filt_DEPENDENCIES = cplus-dem.o underscore.o \ -../libiberty/libiberty.a -c__filt_LDFLAGS = objcopy_OBJECTS = objcopy.o not-strip.o rename.o rddbg.o debug.o \ stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o objcopy_LDADD = $(LDADD) @@ -388,6 +383,10 @@ stabs.o ieee.o rdcoff.o wrstabs.o bucomm.o version.o filemode.o strip_new_LDADD = $(LDADD) strip_new_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a strip_new_LDFLAGS = +cxxfilt_OBJECTS = +cxxfilt_DEPENDENCIES = cplus-dem.o underscore.o \ +../libiberty/libiberty.a +cxxfilt_LDFLAGS = LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LEXLIB = @LEXLIB@ YLWRAP = $(top_srcdir)/../ylwrap @@ -412,10 +411,10 @@ configure.in deflex.c defparse.c nlmheader.c rclex.c rcparse.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best -SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(c__filt_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) -OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(c__filt_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) +SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) $(cxxfilt_SOURCES) +OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) $(cxxfilt_OBJECTS) all: all-redirect .SUFFIXES: @@ -583,10 +582,6 @@ ranlib$(EXEEXT): $(ranlib_OBJECTS) $(ranlib_DEPENDENCIES) @rm -f ranlib$(EXEEXT) $(LINK) $(ranlib_LDFLAGS) $(ranlib_OBJECTS) $(ranlib_LDADD) $(LIBS) -c++filt$(EXEEXT): $(c__filt_OBJECTS) $(c__filt_DEPENDENCIES) - @rm -f c++filt$(EXEEXT) - $(LINK) $(c__filt_LDFLAGS) $(c__filt_OBJECTS) $(c__filt_LDADD) $(LIBS) - objcopy$(EXEEXT): $(objcopy_OBJECTS) $(objcopy_DEPENDENCIES) @rm -f objcopy$(EXEEXT) $(LINK) $(objcopy_LDFLAGS) $(objcopy_OBJECTS) $(objcopy_LDADD) $(LIBS) @@ -606,6 +601,10 @@ nm-new$(EXEEXT): $(nm_new_OBJECTS) $(nm_new_DEPENDENCIES) strip-new$(EXEEXT): $(strip_new_OBJECTS) $(strip_new_DEPENDENCIES) @rm -f strip-new$(EXEEXT) $(LINK) $(strip_new_LDFLAGS) $(strip_new_OBJECTS) $(strip_new_LDADD) $(LIBS) + +cxxfilt$(EXEEXT): $(cxxfilt_OBJECTS) $(cxxfilt_DEPENDENCIES) + @rm -f cxxfilt$(EXEEXT) + $(LINK) $(cxxfilt_LDFLAGS) $(cxxfilt_OBJECTS) $(cxxfilt_LDADD) $(LIBS) .l.c: $(SHELL) $(YLWRAP) "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS) .y.c: @@ -898,7 +897,7 @@ 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; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -1125,28 +1124,30 @@ sysinfo.o: sysinfo.c dlltool.o:dlltool.c $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/dlltool.c +rescoff.o:rescoff.c + $(COMPILE) -c $(DLLTOOL_DEFS) $(srcdir)/rescoff.c + # coff/sym.h and coff/ecoff.h won't be found by the automatic dependency # scripts, since they are only included conditionally. nlmconv.o: nlmconv.c $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h ldname=`echo ld | sed '$(transform)'`; \ $(COMPILE) -c -DLD_NAME="\"$${ldname}\"" @NLMCONV_DEFS@ $(srcdir)/nlmconv.c - diststuff: $(DISTSTUFF) info # Targets to rebuild dependencies in this Makefile. -# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES). -.dep: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h - rm -f .dep1 - $(MAKE) DEP=$(DEP) .dep1 - sed -f dep.sed <.dep1 >.dep +# Have to get rid of DEP1 here so that "$?" later includes all of $(CFILES). +DEP: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h + rm -f DEP1 + $(MAKE) MKDEP=$(MKDEP) DEP1 + sed -f dep.sed DEP # This rule really wants a mkdep that runs "gcc -MM". -.dep1: $(CFILES) $(GENERATED_CFILES) - rm -f .dep2 - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2 - $(DEP) -f .dep2 $(INCLUDES) $? - $(SHELL) $(srcdir)/../move-if-change .dep2 .dep1 +DEP1: $(CFILES) $(GENERATED_CFILES) + rm -f DEP2 + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP2 + $(MKDEP) -f DEP2 $(INCLUDES) $? + $(SHELL) $(srcdir)/../move-if-change DEP2 DEP1 dep.sed: dep-in.sed config.status objdir=`pwd`; \ @@ -1156,19 +1157,19 @@ dep.sed: dep-in.sed config.status -e 's!@SRCDIR@!$(srcdir)!' \ -e "s!@OBJDIR@!$${objdir}!" -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am .PHONY: dep dep-in dep-am @@ -1183,19 +1184,19 @@ binutils.dvi: $(srcdir)/binutils.texi config.texi binutils.info: $(srcdir)/binutils.texi config.texi -$(DEMANGLER_PROG).1: cxxfilt.man Makefile - sed -e 's/@PROGRAM@/$(DEMANGLER_PROG)/' < $(srcdir)/cxxfilt.man \ - > $(DEMANGLER_PROG).1 +$(DEMANGLER_NAME).1: cxxfilt.man Makefile + sed -e 's/@PROGRAM@/$(DEMANGLER_NAME)/' < $(srcdir)/cxxfilt.man \ + > $(DEMANGLER_NAME).1 mostlyclean-local: -rm -rf tmpdir .PHONY: install-exec-local -install-exec-local: $(bin_PROGRAMS) $(noinst_PROGRAMS) +install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS) @list='$(noinst_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done $(mkinstalldirs) $(tooldir)/bin @@ -1237,7 +1238,8 @@ debug.o: debug.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ debug.h dlltool.o: dlltool.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h $(INCDIR)/demangle.h dlltool.h + $(INCDIR)/getopt.h $(INCDIR)/demangle.h dyn-string.h \ + dlltool.h filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h ieee.o: ieee.c ../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/ieee.h \ @@ -1318,8 +1320,8 @@ readelf.o: readelf.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/elf/sparc.h $(INCDIR)/elf/m32r.h $(INCDIR)/elf/d10v.h \ $(INCDIR)/elf/d30v.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/mn10200.h \ $(INCDIR)/elf/mn10300.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/arc.h \ - $(INCDIR)/elf/fr30.h bucomm.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/getopt.h + $(INCDIR)/elf/fr30.h $(INCDIR)/elf/mcore.h $(INCDIR)/elf/i960.h \ + bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h resres.o: resres.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ bucomm.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ windres.h winduni.h diff --git a/binutils/NEWS b/binutils/NEWS index 76dcebd..8d24ccd 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -2,8 +2,17 @@ Changes in binutils 2.10: -* objdump support for -mi386:intel which causes disassembly to be displayed with - intel syntax. +* New command line switch to objdump --file-start-context which shows the + entire file contents up to the source line first encountered for a given + file. + +* New command line switch to objdump -M (or --disassembler-options) which takes + a parameter which can then be interpreted on a per-target basis by the + disassembler. Used by ARM targets to select register name sets, ISA, APCS or + raw verions. + +* objdump support for -mi386:intel which causes disassembly to be displayed + with intel syntax. * New program: readelf. This displays the contents of ELF format files, regardless of target machine. @@ -18,6 +27,9 @@ Changes in binutils 2.10: * dlltool now takes --export-all-symbols, --no-export-all-symbols, --exclude-symbols, and --no-default-excludes options. +* objcopy now takes a -j/--only-section option to copy only the specified + sections. + Changes in binutils 2.9: * Added windres program, which can be used to manipulate resources in WIN32 diff --git a/binutils/aclocal.m4 b/binutils/aclocal.m4 index 88a1565..2d62d71 100644 --- a/binutils/aclocal.m4 +++ b/binutils/aclocal.m4 @@ -105,7 +105,7 @@ fi AC_SUBST($1)]) -# serial 35 AC_PROG_LIBTOOL +# serial 40 AC_PROG_LIBTOOL AC_DEFUN(AC_PROG_LIBTOOL, [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl @@ -114,10 +114,11 @@ 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" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ || AC_MSG_ERROR([libtool configure failed]) # Reload cache, that may have been modified by ltconfig @@ -146,24 +147,33 @@ 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 +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + # 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" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext @@ -195,33 +205,28 @@ case "$host" in fi ;; -*-*-cygwin*) - AC_SYS_LIBTOOL_CYGWIN +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; - +]) 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_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) # 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_DEFUN(AC_ENABLE_SHARED, [dnl +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], @@ -246,15 +251,15 @@ 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_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +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_DEFUN(AC_ENABLE_STATIC, [dnl +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], @@ -279,16 +284,16 @@ 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_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +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_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +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], @@ -313,9 +318,8 @@ 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_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) # AC_PROG_LD - find the path to the GNU or non-GNU linker AC_DEFUN(AC_PROG_LD, @@ -333,7 +337,7 @@ if test "$ac_cv_prog_gcc" = yes; then case "$ac_prog" in # Accept absolute paths. changequote(,)dnl - /* | [A-Za-z]:[\\/]*) + [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' changequote([,])dnl # Canonicalize the path of ld @@ -359,10 +363,10 @@ else fi AC_CACHE_VAL(ac_cv_path_LD, [if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -385,7 +389,6 @@ 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 ]) @@ -407,10 +410,10 @@ AC_CACHE_VAL(ac_cv_path_NM, # Let the user override the test. ac_cv_path_NM="$NM" else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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 @@ -431,230 +434,24 @@ else 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_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, [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'" +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm ;; -irix*) - ac_symcode='[BCDEGRST]' +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") ;; -solaris*) - ac_symcode='[BDT]' +*) + AC_CHECK_LIB(m, main, LIBM="-lm") ;; 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 < $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 < conftest.c -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c' - - cat <> 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 < $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 @@ -665,13 +462,14 @@ AC_CHECK_LIB(m, cos) # '${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, [ +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl 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 + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) ]) # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for @@ -683,16 +481,23 @@ AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [ # 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 +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi ]) - if test x"$enable_ltdl_install" != x"no"; then + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= fi ]) @@ -704,9 +509,9 @@ 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 + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl # Like AC_CONFIG_HEADER, but automatically create stamp file. diff --git a/binutils/addr2line.c b/binutils/addr2line.c index 3cee867..72707c2 100644 --- a/binutils/addr2line.c +++ b/binutils/addr2line.c @@ -123,7 +123,7 @@ static void find_address_in_section (abfd, section, data) bfd *abfd; asection *section; - PTR data; + PTR data ATTRIBUTE_UNUSED; { bfd_vma vma; bfd_size_type size; diff --git a/binutils/ar.1 b/binutils/ar.1 index e4e8cff..cd71a40 100644 --- a/binutils/ar.1 +++ b/binutils/ar.1 @@ -1,6 +1,6 @@ -.\" Copyright (c) 1991 Free Software Foundation +.\" Copyright (c) 1991, 1992, 1993, 1995, 1998, 1999 Free Software Foundation .\" See section COPYING for conditions for redistribution -.TH ar 1 "5 November 1991" "cygnus support" "GNU Development Tools" +.TH ar 1 "1999" "Cygnus Solutions" "GNU Development Tools" .de BP .sp .ti \-.2i @@ -14,10 +14,13 @@ ar \- create, modify, and extract from archives. .hy 0 .na .BR ar " [\|" "-" "\|]"\c -.I {dmpqrtx}[abcilosSuvV] \c +.I {dmpqrtx}[abcfilNoPsSuvV] \c [\|\c .I membername\c \&\|] \c +[\|\c +.I count\c +\&\|] \c .I archive\c \& \c .I files\c @@ -406,6 +409,15 @@ member must be present as the \c This modifier is accepted but not used. .TP +.B N +Uses the +.I count +parameter. This is used if there are multiple entries in the archive +with the same name. Extract or delete instance +.I count +of the given name from the archive. + +.TP .B o Preserve the \c .I original\c @@ -414,6 +426,18 @@ you do not specify this modifier, files extracted from the archive will be stamped with the time of extraction. .TP +.B P +Use the full path name when matching names in the archive. +.B ar +can not create an archive with a full path name (such archives are not +POSIX complaint), but other archive creators can. This option will +cause +.B ar +to match file names using a complete path name, which can be +convenient when extracting a single file from an archive created by +another tool. + +.TP .B s Write an object-file index into the archive, or update an existing one, even if no other change is made to the archive. You may use this modifier @@ -491,7 +515,7 @@ The GNU Binary Utilities\c \&. .SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. +Copyright (c) 1991, 1992, 1993, 1995, 1998, 1999 Free Software Foundation, Inc. .PP Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice diff --git a/binutils/ar.c b/binutils/ar.c index c951ef7..ad9e59d 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -40,6 +40,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define EXT_NAME_LEN 6 /* ditto for *NIX */ #endif +/* We need to open files in binary modes on system where that makes a + difference. */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #define BUFSIZE 8192 /* Kludge declaration from BFD! This is ugly! FIXME! XXX */ @@ -141,9 +147,19 @@ enum pos static bfd ** get_pos_bfd PARAMS ((bfd **, enum pos, const char *)); +/* For extract/delete only. If COUNTED_NAME_MODE is true, we only + extract the COUNTED_NAME_COUNTER instance of that name. */ +static boolean counted_name_mode = 0; +static int counted_name_counter = 0; + /* Whether to truncate names of files stored in the archive. */ static boolean ar_truncate = false; +/* Whether to use a full file name match when searching an archive. + This is convenient for archives created by the Microsoft lib + program. */ +static boolean full_pathname = false; + int interactive = 0; static void @@ -165,6 +181,7 @@ map_over_members (arch, function, files, count) int count; { bfd *head; + int match_count; if (count == 0) { @@ -175,6 +192,7 @@ map_over_members (arch, function, files, count) } return; } + /* This may appear to be a baroque way of accomplishing what we want. However we have to iterate over the filenames in order to notice where a filename is requested but does not exist in the archive. Ditto @@ -185,6 +203,7 @@ map_over_members (arch, function, files, count) { boolean found = false; + match_count = 0; for (head = arch->next; head; head = head->next) { PROGRESS (1); @@ -196,8 +215,17 @@ map_over_members (arch, function, files, count) bfd_stat_arch_elt (head, &buf); } if ((head->filename != NULL) && - (!strcmp (*files, head->filename))) + (!strcmp (normalize (*files, arch), head->filename))) { + ++match_count; + if (counted_name_mode + && match_count != counted_name_counter) + { + /* Counting, and didn't match on count; go on to the + next one. */ + continue; + } + found = true; function (head); } @@ -221,7 +249,8 @@ usage (help) if (! is_ranlib) { /* xgettext:c-format */ - fprintf (s, _("Usage: %s [-]{dmpqrstx}[abcilosSuvV] [member-name] archive-file file...\n"), program_name); + fprintf (s, _("Usage: %s [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"), + program_name); /* xgettext:c-format */ fprintf (s, _(" %s -M [ 0) replace_members (arch, files, operation == quick_append); + else + output_filename = NULL; break; /* Shouldn't happen! */ @@ -681,6 +738,9 @@ open_inarch (archive_filename, file) || ! bfd_set_format (arch, bfd_archive) || ! bfd_close (arch)) bfd_fatal (archive_filename); + + /* If we die creating a new archive, don't leave it around. */ + output_filename = archive_filename; } arch = bfd_openr (archive_filename, target); @@ -730,8 +790,7 @@ print_contents (abfd) fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); if (verbose) - /* xgettext:c-format */ - printf (_("\n\n\n"), bfd_get_filename (abfd)); + printf ("\n<%s>\n\n", bfd_get_filename (abfd)); bfd_seek (abfd, 0, SEEK_SET); @@ -1069,6 +1128,8 @@ delete_members (arch, files_to_delete) bfd **current_ptr_ptr; boolean found; boolean something_changed = false; + int match_count; + for (; *files_to_delete != NULL; ++files_to_delete) { /* In a.out systems, the armap is optional. It's also called @@ -1085,23 +1146,33 @@ delete_members (arch, files_to_delete) } found = false; + match_count = 0; current_ptr_ptr = &(arch->next); while (*current_ptr_ptr) { - if (strcmp (*files_to_delete, (*current_ptr_ptr)->filename) == 0) + if (strcmp (normalize (*files_to_delete, arch), + (*current_ptr_ptr)->filename) == 0) { - found = true; - something_changed = true; - if (verbose) - printf ("d - %s\n", - *files_to_delete); - *current_ptr_ptr = ((*current_ptr_ptr)->next); - goto next_file; - } - else - { - current_ptr_ptr = &((*current_ptr_ptr)->next); + ++match_count; + if (counted_name_mode + && match_count != counted_name_counter) + { + /* Counting, and didn't match on count; go on to the + next one. */ + } + else + { + found = true; + something_changed = true; + if (verbose) + printf ("d - %s\n", + *files_to_delete); + *current_ptr_ptr = ((*current_ptr_ptr)->next); + goto next_file; + } } + + current_ptr_ptr = &((*current_ptr_ptr)->next); } if (verbose && found == false) @@ -1114,9 +1185,9 @@ delete_members (arch, files_to_delete) } if (something_changed == true) - { - write_archive (arch); - } + write_archive (arch); + else + output_filename = NULL; } @@ -1267,6 +1338,8 @@ replace_members (arch, files_to_move, quick) if (changed) write_archive (arch); + else + output_filename = NULL; } static void @@ -1296,7 +1369,7 @@ ranlib_touch (archname) bfd *arch; char **matching; - f = open (archname, O_RDWR, 0); + f = open (archname, O_RDWR | O_BINARY, 0); if (f < 0) { bfd_set_error (bfd_error_system_call); diff --git a/binutils/arparse.y b/binutils/arparse.y index d6c7600..a5e90fa 100644 --- a/binutils/arparse.y +++ b/binutils/arparse.y @@ -193,7 +193,7 @@ verbose_command: static int yyerror (x) - const char *x; + const char *x ATTRIBUTE_UNUSED; { extern int linenumber; diff --git a/binutils/arsup.c b/binutils/arsup.c index 38fd695..d6809fc 100644 --- a/binutils/arsup.c +++ b/binutils/arsup.c @@ -1,5 +1,6 @@ /* arsup.c - Archive support for MRI compatibility - Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -95,7 +96,7 @@ FILE *outfile; static void ar_directory_doer (abfd, ignore) bfd *abfd; - bfd *ignore; + bfd *ignore ATTRIBUTE_UNUSED; { print_arelt_descr(outfile, abfd, verbose); } diff --git a/binutils/binutils.texi b/binutils/binutils.texi index 5f7c646..99f72fe 100644 --- a/binutils/binutils.texi +++ b/binutils/binutils.texi @@ -5,15 +5,28 @@ @ifinfo @format START-INFO-DIR-ENTRY -* Binutils: (binutils). The GNU binary utilities "ar", "objcopy", - "objdump", "nm", "nlmconv", "size", "readelf" - "strings", "strip", "ranlib" and "dlltool". +* Binutils: (binutils). The GNU binary utilities. +* ar: (binutils)ar. Create, modify, and extract from archives +* nm: (binutils)nm. List symbols from object files +* objcopy: (binutils)objcopy. Copy and translate object files +* objdump: (binutils)objdump. Display information from object files +* ranlib: (binutils)ranlib. Generate index to archive contents +* readelf: (binutils)readelf. Display the contents of ELF format files. +* size: (binutils)size. List section sizes and total size +* strings: (binutils)strings. List printable strings from files +* strip: (binutils)strip. Discard symbols +* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols +* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt +* addr2line: (binutils)addr2line. Convert addresses to file and line +* nlmconv: (binutils)nlmconv. Converts object code into an NLM +* windres: (binutils)windres. Manipulate Windows resources +* dlltool: (binutils)dlltool. Create files needed to build and use DLLs END-INFO-DIR-ENTRY @end format @end ifinfo @ifinfo -Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. +Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -41,7 +54,7 @@ into another language, under the above conditions for modified versions. @c This file documents the GNU binary utilities "ar", "ld", "objcopy", @c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib". @c -@c Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. +@c Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. @c @c This text may be freely distributed under the terms of the GNU @c General Public License. @@ -118,7 +131,8 @@ List printable strings from files Discard symbols @item c++filt -Demangle encoded C++ symbols +Demangle encoded C++ symbols (on MS-DOS, this program is named +@code{cxxfilt}) @item addr2line Convert addresses into file names and line numbers @@ -145,6 +159,7 @@ Create the files needed to build and use Dynamic Link Libraries * strings:: List printable strings from files * strip:: Discard symbols * c++filt:: Filter to demangle encoded C++ symbols +* cxxfilt: c++filt. MS-DOS name for c++filt * addr2line:: Convert addresses to file and line * nlmconv:: Converts object code into an NLM * windres:: Manipulate Windows resources @@ -161,7 +176,7 @@ Create the files needed to build and use Dynamic Link Libraries @cindex archives @cindex collections of files @smallexample -ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}] +ar [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] @var{archive} [@var{member}@dots{}] ar -M [ ? */ #undef HAVE_TIME_T_IN_TIME_H diff --git a/binutils/configure b/binutils/configure index 594e154..65f6612 100755 --- a/binutils/configure +++ b/binutils/configure @@ -20,7 +20,7 @@ ac_help="$ac_help 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" + --disable-libtool-lock avoid locking (might break parallel builds)" ac_help="$ac_help --enable-targets alternative target configurations" ac_help="$ac_help @@ -49,6 +49,7 @@ program_suffix=NONE program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -163,6 +164,7 @@ Configuration: --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -333,6 +335,11 @@ EOF -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -498,12 +505,16 @@ 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" +if test -z "$sitefile"; then + 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 +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -590,7 +601,7 @@ 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 +echo "configure:605: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -611,7 +622,7 @@ 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 +echo "configure:626: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -629,7 +640,7 @@ 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 +echo "configure:644: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -664,7 +675,7 @@ test "$host_alias" != "$target_alias" && # 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:668: checking for a BSD compatible install" >&5 +echo "configure:679: 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 @@ -717,7 +728,7 @@ 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:721: checking whether build environment is sane" >&5 +echo "configure:732: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -774,7 +785,7 @@ test "$program_suffix" != NONE && 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:778: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:789: 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 @@ -803,7 +814,7 @@ fi PACKAGE=binutils -VERSION=2.9.4 +VERSION=2.9.5 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; } @@ -820,7 +831,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:824: checking for working aclocal" >&5 +echo "configure:835: 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. @@ -833,7 +844,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:837: checking for working autoconf" >&5 +echo "configure:848: 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. @@ -846,7 +857,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:850: checking for working automake" >&5 +echo "configure:861: 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. @@ -859,7 +870,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:863: checking for working autoheader" >&5 +echo "configure:874: 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. @@ -872,7 +883,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:876: checking for working makeinfo" >&5 +echo "configure:887: 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. @@ -958,7 +969,7 @@ 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:962: checking for $ac_word" >&5 +echo "configure:973: 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 @@ -988,7 +999,7 @@ 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:992: checking for $ac_word" >&5 +echo "configure:1003: 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 @@ -1018,7 +1029,7 @@ 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:1022: checking for $ac_word" >&5 +echo "configure:1033: 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 @@ -1069,7 +1080,7 @@ fi # 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:1073: checking for $ac_word" >&5 +echo "configure:1084: 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 @@ -1101,7 +1112,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1105: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1116: 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. @@ -1112,12 +1123,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1116 "configure" +#line 1127 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1132: \"$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 @@ -1143,12 +1154,12 @@ 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:1147: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1158: 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:1152: checking whether we are using GNU C" >&5 +echo "configure:1163: 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 @@ -1157,7 +1168,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1161: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1172: \"$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 @@ -1176,7 +1187,7 @@ 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:1180: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1191: 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 @@ -1219,11 +1230,11 @@ 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:1223: checking for ld used by GCC" >&5 +echo "configure:1234: 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]:[\\/]*) + [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` @@ -1243,19 +1254,19 @@ echo "configure:1223: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1247: checking for GNU ld" >&5 +echo "configure:1258: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1250: checking for non-GNU ld" >&5 +echo "configure:1261: 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}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -1280,9 +1291,8 @@ 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:1286: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1296: 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 @@ -1298,7 +1308,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1302: checking for BSD-compatible nm" >&5 +echo "configure:1312: 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 @@ -1306,10 +1316,10 @@ else # Let the user override the test. ac_cv_path_NM="$NM" else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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 @@ -1333,213 +1343,8 @@ 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:1340: 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 <&5; (eval $ac_compile) 2>&5; }; then - # Now try to grab the symbols. - ac_nlist=conftest.nm - - if { (eval echo configure:1407: \"$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 < conftest.c -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c' - - cat <> 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:1459: \"$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:1505: 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 <&5; (eval $ac_compile) 2>&5; }; then - # Now try to grab the symbols. - ac_nlist=conftest.nm - if { (eval echo configure:1517: \"$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:1543: checking whether ln -s works" >&5 +echo "configure:1348: 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 @@ -1559,30 +1364,37 @@ else echo "$ac_t""no" 1>&6 fi -if test $host != $build; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac # 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" + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 1585 "configure"' > conftest.$ac_ext - if { (eval echo configure:1586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 1397 "configure"' > conftest.$ac_ext + if { (eval echo configure:1398: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -1603,19 +1415,19 @@ case "$host" in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:1607: checking whether the C compiler needs -belf" >&5 +echo "configure:1419: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1431: \"$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 @@ -1634,161 +1446,9 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 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:1642: 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:1674: 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:1709: 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:1741: 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 @@ -1841,10 +1501,11 @@ 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" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ || { echo "configure: error: libtool configure failed" 1>&2; exit 1; } # Reload cache, that may have been modified by ltconfig @@ -1902,7 +1563,7 @@ 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:1906: checking for $ac_word" >&5 +echo "configure:1567: 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 @@ -1932,7 +1593,7 @@ 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:1936: checking for $ac_word" >&5 +echo "configure:1597: 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 @@ -1983,7 +1644,7 @@ fi # 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:1987: checking for $ac_word" >&5 +echo "configure:1648: 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 @@ -2015,7 +1676,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2019: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1680: 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. @@ -2026,12 +1687,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2030 "configure" +#line 1691 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1696: \"$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 @@ -2057,12 +1718,12 @@ 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:2061: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1722: 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:2066: checking whether we are using GNU C" >&5 +echo "configure:1727: 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 @@ -2071,7 +1732,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1736: \"$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 @@ -2090,7 +1751,7 @@ 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:2094: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1755: 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 @@ -2127,7 +1788,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2131: checking for $ac_word" >&5 +echo "configure:1792: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2158,7 +1819,7 @@ done test -n "$YACC" || YACC="yacc" echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2162: checking how to run the C preprocessor" >&5 +echo "configure:1823: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -2173,13 +1834,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1844: \"$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 : @@ -2190,13 +1851,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1861: \"$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 : @@ -2207,13 +1868,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1878: \"$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 : @@ -2243,7 +1904,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2247: checking for $ac_word" >&5 +echo "configure:1908: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2276,7 +1937,7 @@ test -n "$LEX" || LEX=""$missing_dir/missing flex"" # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2280: checking for $ac_word" >&5 +echo "configure:1941: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2310,7 +1971,7 @@ then *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:2314: checking for yywrap in -l$ac_lib" >&5 +echo "configure:1975: checking for yywrap in -l$ac_lib" >&5 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2318,7 +1979,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1994: \"$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 @@ -2352,7 +2013,7 @@ fi fi echo $ac_n "checking lex output file root""... $ac_c" 1>&6 -echo "configure:2356: checking lex output file root" >&5 +echo "configure:2017: checking lex output file root" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2373,7 +2034,7 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 -echo "configure:2377: checking whether yytext is a pointer" >&5 +echo "configure:2038: checking whether yytext is a pointer" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2385,14 +2046,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c ac_save_LIBS="$LIBS" LIBS="$LIBS $LEXLIB" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_prog_lex_yytext_pointer=yes else @@ -2416,7 +2077,7 @@ fi ALL_LINGUAS= echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:2420: checking for POSIXized ISC" >&5 +echo "configure:2081: 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 @@ -2437,12 +2098,12 @@ else fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2441: checking for ANSI C header files" >&5 +echo "configure:2102: 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 < #include @@ -2450,7 +2111,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2454: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2115: \"$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* @@ -2467,7 +2128,7 @@ 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 @@ -2485,7 +2146,7 @@ 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 @@ -2506,7 +2167,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2517,7 +2178,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2541,12 +2202,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2545: checking for working const" >&5 +echo "configure:2206: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2260: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2616,21 +2277,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:2620: checking for inline" >&5 +echo "configure:2281: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2295: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2656,12 +2317,12 @@ EOF esac echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:2660: checking for off_t" >&5 +echo "configure:2321: 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 < #if STDC_HEADERS @@ -2689,12 +2350,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2693: checking for size_t" >&5 +echo "configure:2354: 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 < #if STDC_HEADERS @@ -2724,19 +2385,19 @@ 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:2728: checking for working alloca.h" >&5 +echo "configure:2389: 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 < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:2740: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2401: \"$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 @@ -2757,12 +2418,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:2761: checking for alloca" >&5 +echo "configure:2422: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2455: \"$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 @@ -2822,12 +2483,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:2826: checking whether alloca needs Cray hooks" >&5 +echo "configure:2487: 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 <&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:2856: checking for $ac_func" >&5 +echo "configure:2517: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2545: \"$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 @@ -2907,7 +2568,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:2911: checking stack direction for C alloca" >&5 +echo "configure:2572: 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 @@ -2915,7 +2576,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2599: \"$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 @@ -2959,17 +2620,17 @@ 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:2963: checking for $ac_hdr" >&5 +echo "configure:2624: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2973: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2634: \"$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* @@ -2998,12 +2659,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3002: checking for $ac_func" >&5 +echo "configure:2663: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2691: \"$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 @@ -3051,7 +2712,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3055: checking for working mmap" >&5 +echo "configure:2716: 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 @@ -3059,7 +2720,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2864: \"$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 @@ -3227,17 +2888,17 @@ 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:3231: checking for $ac_hdr" >&5 +echo "configure:2892: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3241: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2902: \"$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* @@ -3267,12 +2928,12 @@ done __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3271: checking for $ac_func" >&5 +echo "configure:2932: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2960: \"$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 @@ -3324,12 +2985,12 @@ done for ac_func in stpcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3328: checking for $ac_func" >&5 +echo "configure:2989: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3017: \"$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 @@ -3386,19 +3047,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:3390: checking for LC_MESSAGES" >&5 +echo "configure:3051: 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 < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:3402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3063: \"$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 @@ -3419,7 +3080,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:3423: checking whether NLS is requested" >&5 +echo "configure:3084: 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" @@ -3439,7 +3100,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:3443: checking whether included gettext is requested" >&5 +echo "configure:3104: 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" @@ -3458,17 +3119,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:3462: checking for libintl.h" >&5 +echo "configure:3123: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3133: \"$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* @@ -3485,19 +3146,19 @@ 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:3489: checking for gettext in libc" >&5 +echo "configure:3150: 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 < int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:3501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3162: \"$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 @@ -3513,7 +3174,7 @@ 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:3517: checking for bindtextdomain in -lintl" >&5 +echo "configure:3178: 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 @@ -3521,7 +3182,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3197: \"$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 @@ -3548,19 +3209,19 @@ 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:3552: checking for gettext in libintl" >&5 +echo "configure:3213: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3225: \"$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 @@ -3588,7 +3249,7 @@ 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:3592: checking for $ac_word" >&5 +echo "configure:3253: 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 @@ -3622,12 +3283,12 @@ fi for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3626: checking for $ac_func" >&5 +echo "configure:3287: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3315: \"$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 @@ -3677,7 +3338,7 @@ 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:3681: checking for $ac_word" >&5 +echo "configure:3342: 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 @@ -3713,7 +3374,7 @@ 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:3717: checking for $ac_word" >&5 +echo "configure:3378: 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 @@ -3745,7 +3406,7 @@ else fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -3785,7 +3446,7 @@ fi # 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:3789: checking for $ac_word" >&5 +echo "configure:3450: 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 @@ -3819,7 +3480,7 @@ 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:3823: checking for $ac_word" >&5 +echo "configure:3484: 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 @@ -3855,7 +3516,7 @@ 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:3859: checking for $ac_word" >&5 +echo "configure:3520: 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 @@ -3945,7 +3606,7 @@ fi LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:3949: checking for catalogs to be installed" >&5 +echo "configure:3610: checking for catalogs to be installed" >&5 NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in @@ -3973,17 +3634,17 @@ echo "configure:3949: checking for catalogs to be installed" >&5 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:3977: checking for linux/version.h" >&5 +echo "configure:3638: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3987: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3648: \"$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* @@ -4046,7 +3707,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:4050: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:3711: 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" @@ -4069,12 +3730,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:4073: checking for Cygwin environment" >&5 +echo "configure:3734: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3750: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -4102,19 +3763,19 @@ 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:4106: checking for mingw32 environment" >&5 +echo "configure:3767: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3779: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -4133,7 +3794,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:4137: checking for executable suffix" >&5 +echo "configure:3798: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4143,7 +3804,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:4147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:3808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -4163,6 +3824,16 @@ test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT +if test -n "$EXEEXT"; then + cat >> confdefs.h <<\EOF +#define HAVE_EXECUTABLE_SUFFIX 1 +EOF + +fi +cat >> confdefs.h <&6 -echo "configure:4180: checking for $ac_word" >&5 +echo "configure:3851: 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 @@ -4215,7 +3886,7 @@ fi # 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:4219: checking for a BSD compatible install" >&5 +echo "configure:3890: 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 @@ -4282,19 +3953,22 @@ 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:4286: checking for build system executable suffix" >&5 +echo "configure:3957: 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 + rm -f conftest* + echo 'int main () { return 0; }' > conftest.c + bfd_cv_build_exeext= + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5 + for file in conftest.*; do + case $file in + *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;; + esac + done + rm -f conftest* + test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no fi echo "$ac_t""$bfd_cv_build_exeext" 1>&6 @@ -4303,21 +3977,28 @@ echo "$ac_t""$bfd_cv_build_exeext" 1>&6 fi +DEMANGLER_NAME=c++filt +case "${host}" in + *-*-go32* | *-*-msdos*) + DEMANGLER_NAME=cxxfilt +esac + + for ac_hdr in string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4311: checking for $ac_hdr" >&5 +echo "configure:3992: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4321: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4002: \"$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* @@ -4344,12 +4025,12 @@ fi done echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:4348: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:4029: 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 < #include @@ -4365,7 +4046,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:4369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4050: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -4388,19 +4069,19 @@ 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:4392: checking for working alloca.h" >&5 +echo "configure:4073: 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 < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4085: \"$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 @@ -4421,12 +4102,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4425: checking for alloca" >&5 +echo "configure:4106: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4139: \"$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 @@ -4486,12 +4167,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4490: checking whether alloca needs Cray hooks" >&5 +echo "configure:4171: 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 <&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:4520: checking for $ac_func" >&5 +echo "configure:4201: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4229: \"$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 @@ -4571,7 +4252,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4575: checking stack direction for C alloca" >&5 +echo "configure:4256: 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 @@ -4579,7 +4260,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4283: \"$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 @@ -4622,12 +4303,12 @@ fi for ac_func in sbrk utimes do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4626: checking for $ac_func" >&5 +echo "configure:4307: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4335: \"$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 @@ -4675,20 +4356,84 @@ fi done +# Some systems have frexp only in -lm, not in -lc. + +echo $ac_n "checking for library containing frexp""... $ac_c" 1>&6 +echo "configure:4363: checking for library containing frexp" >&5 +if eval "test \"`echo '$''{'ac_cv_search_frexp'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_frexp="no" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_frexp="none required" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +test "$ac_cv_search_frexp" = "no" && for i in m; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_frexp="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" +fi + +echo "$ac_t""$ac_cv_search_frexp" 1>&6 +if test "$ac_cv_search_frexp" != "no"; then + test "$ac_cv_search_frexp" = "none required" || LIBS="$ac_cv_search_frexp $LIBS" + +else : + +fi + echo $ac_n "checking for time_t in time.h""... $ac_c" 1>&6 -echo "configure:4680: checking for time_t in time.h" >&5 +echo "configure:4425: checking for time_t in time.h" >&5 if eval "test \"`echo '$''{'bu_cv_decl_time_t_time_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { time_t i; ; return 0; } EOF -if { (eval echo configure:4692: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4437: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_decl_time_t_time_h=yes else @@ -4709,19 +4454,19 @@ EOF fi echo $ac_n "checking for time_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:4713: checking for time_t in sys/types.h" >&5 +echo "configure:4458: checking for time_t in sys/types.h" >&5 if eval "test \"`echo '$''{'bu_cv_decl_time_t_types_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { time_t i; ; return 0; } EOF -if { (eval echo configure:4725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4470: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_decl_time_t_types_h=yes else @@ -4744,12 +4489,12 @@ fi # Under Next 3.2 apparently does not define struct utimbuf # by default. echo $ac_n "checking for utime.h""... $ac_c" 1>&6 -echo "configure:4748: checking for utime.h" >&5 +echo "configure:4493: checking for utime.h" >&5 if eval "test \"`echo '$''{'bu_cv_header_utime_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifdef HAVE_TIME_H @@ -4760,7 +4505,7 @@ int main() { struct utimbuf s; ; return 0; } EOF -if { (eval echo configure:4764: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4509: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bu_cv_header_utime_h=yes else @@ -4781,12 +4526,12 @@ EOF fi echo $ac_n "checking whether fprintf must be declared""... $ac_c" 1>&6 -echo "configure:4785: checking whether fprintf must be declared" >&5 +echo "configure:4530: checking whether fprintf must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_fprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4807,7 +4552,7 @@ int main() { char *(*pfn) = (char *(*)) fprintf ; return 0; } EOF -if { (eval echo configure:4811: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4556: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_fprintf=no else @@ -4828,12 +4573,12 @@ EOF fi echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 -echo "configure:4832: checking whether strstr must be declared" >&5 +echo "configure:4577: 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 < @@ -4854,7 +4599,7 @@ int main() { char *(*pfn) = (char *(*)) strstr ; return 0; } EOF -if { (eval echo configure:4858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_strstr=no else @@ -4875,12 +4620,12 @@ EOF fi echo $ac_n "checking whether sbrk must be declared""... $ac_c" 1>&6 -echo "configure:4879: checking whether sbrk must be declared" >&5 +echo "configure:4624: checking whether sbrk must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_sbrk'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4901,7 +4646,7 @@ int main() { char *(*pfn) = (char *(*)) sbrk ; return 0; } EOF -if { (eval echo configure:4905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4650: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_sbrk=no else @@ -4922,12 +4667,12 @@ EOF fi echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 -echo "configure:4926: checking whether getenv must be declared" >&5 +echo "configure:4671: 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 < @@ -4948,7 +4693,7 @@ int main() { char *(*pfn) = (char *(*)) getenv ; return 0; } EOF -if { (eval echo configure:4952: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4697: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_getenv=no else @@ -4969,12 +4714,12 @@ EOF fi echo $ac_n "checking whether environ must be declared""... $ac_c" 1>&6 -echo "configure:4973: checking whether environ must be declared" >&5 +echo "configure:4718: checking whether environ must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_environ'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4995,7 +4740,7 @@ int main() { char *(*pfn) = (char *(*)) environ ; return 0; } EOF -if { (eval echo configure:4999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4744: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_environ=no else @@ -5018,7 +4763,7 @@ fi case "${host}" in -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows) +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) cat >> confdefs.h <<\EOF #define USE_BINARY_FOPEN 1 EOF @@ -5031,7 +4776,7 @@ esac 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` + result=`$ac_config_sub $targ 2>/dev/null` if test -n "$result"; then canon_targets="$canon_targets $result" else @@ -5081,27 +4826,50 @@ do *-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;; esac case $targ in - arm-*pe*) + arm-*pe* | arm-*-wince) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; thumb-*pe*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; i[3-6]86-*pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)' - ;; + ;; + i3-686-*-interix) + BUILD_DLLTOOL='$(DLLTOOL_PROG)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" + ;; powerpc*-*-*pe* | powerpc*-*-cygwin*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; + sh*-*-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mips*-*-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mcore-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mcore-*elf) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE_ELF" + ;; esac fi done @@ -5290,12 +5058,7 @@ s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g s%@RANLIB@%$RANLIB%g s%@CC@%$CC%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%@YACC@%$YACC%g s%@LEX@%$LEX%g @@ -5331,6 +5094,7 @@ s%@HDEFINES@%$HDEFINES%g s%@AR@%$AR%g s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g s%@EXEEXT_FOR_BUILD@%$EXEEXT_FOR_BUILD%g +s%@DEMANGLER_NAME@%$DEMANGLER_NAME%g s%@NLMCONV_DEFS@%$NLMCONV_DEFS%g s%@BUILD_NLMCONV@%$BUILD_NLMCONV%g s%@BUILD_SRCONV@%$BUILD_SRCONV%g diff --git a/binutils/configure.bat b/binutils/configure.bat deleted file mode 100755 index f7d70f1..0000000 --- a/binutils/configure.bat +++ /dev/null @@ -1,63 +0,0 @@ -@echo off -if "%1" == "h8/300" goto h8300 - -echo Configuring binutils for go32 -update ../bfd/hosts/go32.h sysdep.h -goto common - -:h8300 -echo Configuring binutils for H8/300 -update ..\bfd\hosts\h-go32.h sysdep.h - -:common - -echo # Makefile generated by "configure.bat"> Makefile - -if exist config.sed del config.sed - -sed -n "/^VERSION=/ p" Makefile.in | sed -e "s/^/s^/" -e "s/=/^\"/" -e "s/$/\"^/" > config.sed -sed -f config.sed version.c > version2.c - -if exist config.sed del config.sed - -echo "s/version\./version2\./g ">> config.sed -echo "s/-DVERSION=[^ ]* // ">> config.sed - -echo "s/^ \$(srcdir)\/move-if-change/ update/ ">> config.sed -echo "/^###$/ i\ ">> config.sed -echo "CC = gcc ">> config.sed -echo "s/:\([^ ]\)/: \1/g ">> config.sed -echo "s/^ \ *\.\// go32 / ">> config.sed -echo "s/`echo \$(srcdir)\///g ">> config.sed -echo "s/ | sed 's,\^\\\.\/,,'`//g ">> config.sed -echo "s/^ cd \$(srcdir)[ ]*;// ">> config.sed - -echo "/^arparse\.c/ i\ ">> config.sed -echo "arparse.o: arparse.c\ ">> config.sed -echo " $(CC) -c $(CFLAGS) $(INCLUDES) $(HDEFINES) $(TDEFINES) arparse.c ">> config.sed -echo "/\$(BISON)/ c\ ">> config.sed -echo " bison $(BISONFLAGS) -o $@ arparse.y ">> config.sed -echo "/y\.tab\./ d ">> config.sed - -echo "/^arlex.c/ { ">> config.sed -echo " i\ ">> config.sed -echo "arlex.o: arlex.c ">> config.sed -echo " i\ ">> config.sed -echo " $(CC) -c $(CFLAGS) $(INCLUDES) $(HDEFINES) $(TDEFINES) arlex.c ">> config.sed -echo "} ">> config.sed -echo "/\$(LEX)/ c\ ">> config.sed -echo " flex $(LEX_OPTIONS) arlex.l ">> config.sed -echo "s/lex\.yy\./lexyy./g ">> config.sed - -echo "s/'"/\\"/g ">> config.sed -echo "s/"'/\\"/g ">> config.sed - -echo "s/c++filt/cxxfilt/g ">> 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 - -echo int prepends_underscore = 1; > underscore.c - diff --git a/binutils/configure.in b/binutils/configure.in index 298dcd8..aa10ce9 100644 --- a/binutils/configure.in +++ b/binutils/configure.in @@ -5,7 +5,7 @@ AC_INIT(ar.c) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(binutils, 2.9.4) +AM_INIT_AUTOMAKE(binutils, 2.9.5) AM_PROG_LIBTOOL @@ -44,6 +44,12 @@ CY_GNU_GETTEXT AM_MAINTAINER_MODE AC_EXEEXT +if test -n "$EXEEXT"; then + AC_DEFINE(HAVE_EXECUTABLE_SUFFIX, 1, + [Does the platform use an executable suffix?]) +fi +AC_DEFINE_UNQUOTED(EXECUTABLE_SUFFIX, "${EXEEXT}", + [Suffix used for executables, if any.]) # host-specific stuff: @@ -59,11 +65,21 @@ AC_PROG_INSTALL BFD_CC_FOR_BUILD +DEMANGLER_NAME=c++filt +case "${host}" in + *-*-go32* | *-*-msdos*) + DEMANGLER_NAME=cxxfilt +esac +AC_SUBST(DEMANGLER_NAME) + AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h) AC_HEADER_SYS_WAIT AC_FUNC_ALLOCA AC_CHECK_FUNCS(sbrk utimes) +# Some systems have frexp only in -lm, not in -lc. +AC_SEARCH_LIBS(frexp, m) + AC_MSG_CHECKING(for time_t in time.h) AC_CACHE_VAL(bu_cv_decl_time_t_time_h, [AC_TRY_COMPILE([#include ], [time_t i;], @@ -114,7 +130,7 @@ BFD_BINARY_FOPEN 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` + result=`$ac_config_sub $targ 2>/dev/null` if test -n "$result"; then canon_targets="$canon_targets $result" else @@ -166,16 +182,16 @@ changequote([,])dnl *-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;; esac case $targ in - arm-*pe*) + arm-*pe* | arm-*-wince) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; thumb-*pe*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; changequote(,)dnl i[3-6]86-*pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) changequote([,])dnl @@ -183,12 +199,35 @@ changequote([,])dnl DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)' - ;; + ;; + i[3-6]86-*-interix) + BUILD_DLLTOOL='$(DLLTOOL_PROG)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" + ;; powerpc*-*-*pe* | powerpc*-*-cygwin*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' - ;; + ;; + sh*-*-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mips*-*-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mcore-*pe) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE" + BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' + ;; + mcore-*elf) + BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' + DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE_ELF" + ;; esac fi done diff --git a/binutils/debug.c b/binutils/debug.c index 173d627..82a9094 100644 --- a/binutils/debug.c +++ b/binutils/debug.c @@ -1,5 +1,5 @@ /* debug.c -- Handle generic debugging information. - Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -603,7 +603,7 @@ debug_error (message) static struct debug_name * debug_add_to_namespace (info, nsp, name, kind, linkage) - struct debug_handle *info; + struct debug_handle *info ATTRIBUTE_UNUSED; struct debug_namespace **nsp; const char *name; enum debug_object_kind kind; @@ -1039,8 +1039,8 @@ debug_record_line (handle, lineno, addr) boolean debug_start_common_block (handle, name) - PTR handle; - const char *name; + PTR handle ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; { /* FIXME */ debug_error (_("debug_start_common_block: not implemented")); @@ -1051,8 +1051,8 @@ debug_start_common_block (handle, name) boolean debug_end_common_block (handle, name) - PTR handle; - const char *name; + PTR handle ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; { /* FIXME */ debug_error (_("debug_end_common_block: not implemented")); @@ -1143,10 +1143,10 @@ debug_record_typed_const (handle, name, type, val) boolean debug_record_label (handle, name, type, addr) - PTR handle; - const char *name; - debug_type type; - bfd_vma addr; + PTR handle ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; + debug_type type ATTRIBUTE_UNUSED; + bfd_vma addr ATTRIBUTE_UNUSED; { /* FIXME. */ debug_error (_("debug_record_label not implemented")); @@ -1219,7 +1219,7 @@ debug_record_variable (handle, name, type, kind, val) /*ARGSUSED*/ static struct debug_type * debug_make_type (info, kind, size) - struct debug_handle *info; + struct debug_handle *info ATTRIBUTE_UNUSED; enum debug_type_kind kind; unsigned int size; { @@ -1781,7 +1781,7 @@ debug_make_undefined_tagged_type (handle, name, kind) /*ARGSUSED*/ debug_baseclass debug_make_baseclass (handle, type, bitpos, virtual, visibility) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_type type; bfd_vma bitpos; boolean virtual; @@ -1809,7 +1809,7 @@ debug_make_baseclass (handle, type, bitpos, virtual, visibility) /*ARGSUSED*/ debug_field debug_make_field (handle, name, type, bitpos, bitsize, visibility) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; const char *name; debug_type type; bfd_vma bitpos; @@ -1840,7 +1840,7 @@ debug_make_field (handle, name, type, bitpos, bitsize, visibility) /*ARGSUSED*/ debug_field debug_make_static_member (handle, name, type, physname, visibility) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; const char *name; debug_type type; const char *physname; @@ -1866,7 +1866,7 @@ debug_make_static_member (handle, name, type, physname, visibility) /*ARGSUSED*/ debug_method debug_make_method (handle, name, variants) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; const char *name; debug_method_variant *variants; { @@ -1894,7 +1894,7 @@ debug_make_method (handle, name, variants) debug_method_variant debug_make_method_variant (handle, physname, type, visibility, constp, volatilep, voffset, context) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; const char *physname; debug_type type; enum debug_visibility visibility; @@ -1926,7 +1926,7 @@ debug_make_method_variant (handle, physname, type, visibility, constp, debug_method_variant debug_make_static_method_variant (handle, physname, type, visibility, constp, volatilep) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; const char *physname; debug_type type; enum debug_visibility visibility; @@ -1988,7 +1988,7 @@ debug_name_type (handle, name, type) nm = debug_add_to_namespace (info, &info->current_file->globals, name, DEBUG_OBJECT_TYPE, DEBUG_LINKAGE_NONE); if (nm == NULL) - return false; + return DEBUG_TYPE_NULL; nm->u.type = t; @@ -2044,7 +2044,7 @@ debug_tag_type (handle, name, type) nm = debug_add_to_namespace (info, &info->current_file->globals, name, DEBUG_OBJECT_TAG, DEBUG_LINKAGE_NONE); if (nm == NULL) - return false; + return DEBUG_TYPE_NULL; nm->u.tag = t; @@ -2058,7 +2058,7 @@ debug_tag_type (handle, name, type) /*ARGSUSED*/ boolean debug_record_type_size (handle, type, size) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_type type; unsigned int size; { @@ -2394,7 +2394,7 @@ debug_get_fields (handle, type) /*ARGSUSED*/ debug_type debug_get_field_type (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL) @@ -2407,7 +2407,7 @@ debug_get_field_type (handle, field) /*ARGSUSED*/ const char * debug_get_field_name (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL) @@ -2420,7 +2420,7 @@ debug_get_field_name (handle, field) /*ARGSUSED*/ bfd_vma debug_get_field_bitpos (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL || field->static_member) @@ -2433,7 +2433,7 @@ debug_get_field_bitpos (handle, field) /*ARGSUSED*/ bfd_vma debug_get_field_bitsize (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL || field->static_member) @@ -2446,7 +2446,7 @@ debug_get_field_bitsize (handle, field) /*ARGSUSED*/ enum debug_visibility debug_get_field_visibility (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL) @@ -2458,7 +2458,7 @@ debug_get_field_visibility (handle, field) const char * debug_get_field_physname (handle, field) - PTR handle; + PTR handle ATTRIBUTE_UNUSED; debug_field field; { if (field == NULL || ! field->static_member) @@ -2598,7 +2598,7 @@ debug_write_type (info, fns, fhandle, type, name) { unsigned int i; int is; - const char *tag; + const char *tag = NULL; /* If we have a name for this type, just output it. We only output typedef names after they have been defined. We output type tags @@ -2648,7 +2648,6 @@ debug_write_type (info, fns, fhandle, type, name) if (name != NULL) name->mark = info->mark; - tag = NULL; if (name != NULL && type->kind != DEBUG_KIND_NAMED && type->kind != DEBUG_KIND_TAGGED) diff --git a/binutils/deflex.l b/binutils/deflex.l index e7fa362..15a43c0 100644 --- a/binutils/deflex.l +++ b/binutils/deflex.l @@ -1,6 +1,6 @@ %{/* deflex.l - Lexer for .def files */ -/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -50,11 +50,18 @@ int linenumber; "WRITE" { return WRITE;} "EXECUTE" { return EXECUTE;} "SHARED" { return SHARED;} +"NONSHARED" { return NONSHARED;} +"SINGLE" { return SINGLE;} +"MULTIPLE" { return MULTIPLE;} +"INITINSTANCE" { return INITINSTANCE;} +"INITGLOBAL" { return INITGLOBAL;} +"TERMINSTANCE" { return TERMINSTANCE;} +"TERMGLOBAL" { return TERMGLOBAL;} [0-9][x0-9A-Fa-f]* { yylval.number = strtol (yytext,0,0); return NUMBER; } -[A-Za-z$:\-\_?][A-Za-z0-9/$:\-\_@?]+ { +[A-Za-z$:\-\_?][A-Za-z0-9/$:\-\_@?]* { yylval.id = xstrdup (yytext); return ID; } diff --git a/binutils/defparse.y b/binutils/defparse.y index 1cb6360..5718d46 100644 --- a/binutils/defparse.y +++ b/binutils/defparse.y @@ -1,6 +1,6 @@ %{ /* defparse.y - parser for .def files */ -/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -30,7 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ %token NAME, LIBRARY, DESCRIPTION, STACKSIZE, HEAPSIZE, CODE, DATA %token SECTIONS, EXPORTS, IMPORTS, VERSIONK, BASE, CONSTANT -%token READ WRITE EXECUTE SHARED NONAME +%token READ WRITE EXECUTE SHARED NONSHARED NONAME +%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL %token ID %token NUMBER %type opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA @@ -45,7 +46,7 @@ start: start command command: NAME opt_name opt_base { def_name ($2, $3); } - | LIBRARY opt_name opt_base { def_library ($2, $3); } + | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } | EXPORTS explist | DESCRIPTION ID { def_description ($2);} | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} @@ -61,7 +62,6 @@ command: explist: /* EMPTY */ - | expline | explist expline ; @@ -108,10 +108,13 @@ opt_number: ',' NUMBER { $$=$2;} ; attr: - READ { $$ = 1;} - | WRITE { $$ = 2;} - | EXECUTE { $$=4;} - | SHARED { $$=8;} + READ { $$ = 1; } + | WRITE { $$ = 2; } + | EXECUTE { $$ = 4; } + | SHARED { $$ = 8; } + | NONSHARED { $$ = 0; } + | SINGLE { $$ = 0; } + | MULTIPLE { $$ = 0; } ; opt_CONSTANT: @@ -153,5 +156,14 @@ opt_base: BASE '=' NUMBER { $$= $3;} | { $$=-1;} ; - +option_list: + /* empty */ + | option_list opt_comma option + ; +option: + INITINSTANCE + | INITGLOBAL + | TERMINSTANCE + | TERMGLOBAL + ; diff --git a/binutils/dlltool.c b/binutils/dlltool.c index ed5cf5e..4189b5e 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -1,5 +1,5 @@ /* dlltool.c -- tool to generate stuff for PE style DLLs - Copyright (C) 1995, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -121,16 +121,16 @@ printf ("hello from the dll and the other entry point %s\n", s); } - printf() + int printf (void) { return 9; } - main.c - - void main() + themain.c: + int main (void) { - cdef(); + cdef (); + return 0; } thedll.def @@ -143,29 +143,54 @@ SECTIONS donkey READ WRITE aardvark EXECUTE - # compile up the parts of the dll + # Compile up the parts of the dll and the program - gcc -c file1.c - gcc -c file2.c + gcc -c file1.c file2.c themain.c - # put them in a library (you don't have to, you - # could name all the .os on the dlltool line) + # Optional: put the dll objects into a library + # (you don't have to, you could name all the object + # files on the dlltool line) ar qcv thedll.in file1.o file2.o ranlib thedll.in - # run this tool over the library and the def file - ./dlltool --def thedll.def --output-exp thedll.o --output-lib thedll.a + # Run this tool over the DLL's .def file and generate an exports + # file (thedll.o) and an imports file (thedll.a). + # (You may have to use -S to tell dlltool where to find the assembler). + + dlltool --def thedll.def --output-exp thedll.o --output-lib thedll.a - # build the dll with the library with file1.o, file2.o and the export table + # Build the dll with the library and the export table + ld -o thedll.dll thedll.o thedll.in - # build the mainline - gcc -c themain.c + # Link the executable with the import library + + gcc -o themain.exe themain.o thedll.a + + This example can be extended if relocations are needed in the DLL: - # link the executable with the import library - ld -e main -Tthemain.ld -o themain.exe themain.o thedll.a + # Compile up the parts of the dll and the program + gcc -c file1.c file2.c themain.c + + # Run this tool over the DLL's .def file and generate an imports file. + + dlltool --def thedll.def --output-lib thedll.lib + + # Link the executable with the import library and generate a base file + # at the same time + + gcc -o themain.exe themain.o thedll.lib -Wl,--base-file -Wl,themain.base + + # Run this tool over the DLL's .def file and generate an exports file + # which includes the relocations from the base file. + + dlltool --def thedll.def --base-file themain.base --output-exp thedll.exp + + # Build the dll with file1.o, file2.o and the export table + + ld -o thedll.dll thedll.exp file1.o file2.o */ /* .idata section description @@ -221,11 +246,14 @@ #include "bucomm.h" #include "getopt.h" #include "demangle.h" +#include "dyn-string.h" #include "dlltool.h" #include #include -#ifdef __STDC__ +#include + +#ifdef ANSI_PROTOTYPES #include #else #include @@ -236,6 +264,15 @@ #include "coff/internal.h" #endif +/* Forward references. */ +static char *look_for_prog PARAMS ((const char *, const char *, int)); +static char *deduce_name PARAMS ((const char *)); + +#ifdef DLLTOOL_MCORE_ELF +static void mcore_elf_cache_filename (char *); +static void mcore_elf_gen_out_file (void); +#endif + #ifdef HAVE_SYS_WAIT_H #include #else /* ! HAVE_SYS_WAIT_H */ @@ -304,7 +341,7 @@ typedef struct iheadt static iheadtype *import_list = NULL; -static char *as_name = "as"; +static char *as_name = NULL; static char * as_flags = ""; static int no_idata4; @@ -319,10 +356,6 @@ static int add_indirect = 0; static int add_underscore = 0; static int dontdeltemps = 0; -#ifdef DLLTOOL_ARM -static int interwork = 0; -#endif - /* True if we should export all symbols. Otherwise, we only export symbols listed in .drectve sections or in the def file. */ static boolean export_all_symbols; @@ -334,6 +367,10 @@ static boolean do_default_excludes; /* Default symbols to exclude when exporting all the symbols. */ static const char *default_excludes = "DllMain@12,DllEntryPoint@0,impure_ptr"; +/* True if we should add __imp_ to import libraries for backward + compatibility to old Cygwin releases. */ +static boolean create_compat_implib; + static char *def_file; extern char * program_name; @@ -345,10 +382,6 @@ static int verbose; static FILE *output_def; static FILE *base_file; -#ifdef DLLTOOL_BEOS -static const char *mname = "beos"; -#endif - #ifdef DLLTOOL_ARM static const char *mname = "arm"; #endif @@ -361,6 +394,31 @@ static const char *mname = "i386"; static const char *mname = "ppc"; #endif +#ifdef DLLTOOL_SH +static const char *mname = "sh"; +#endif + +#ifdef DLLTOOL_MIPS +static const char *mname = "mips"; +#endif + +#ifdef DLLTOOL_MCORE +static const char * mname = "mcore-le"; +#endif + +#ifdef DLLTOOL_MCORE_ELF +static const char * mname = "mcore-elf"; +static char * mcore_elf_out_file = NULL; +static char * mcore_elf_linker = NULL; +static char * mcore_elf_linker_flags = NULL; + +#define DRECTVE_SECTION_NAME ((machine == MMCORE_ELF || machine == MMCORE_ELF_LE) ? ".exports" : ".drectve") +#endif + +#ifndef DRECTVE_SECTION_NAME +#define DRECTVE_SECTION_NAME ".drectve" +#endif + #define PATHMAX 250 /* What's the right name for this ? */ #define TMP_ASM "dc.s" @@ -370,8 +428,7 @@ static const char *mname = "ppc"; #define TMP_TAIL_O "dt.o" #define TMP_STUB "ds" -/* This bit of assemly does jmp * .... -s set how_jtab_roff to mark where the 32bit abs branch should go */ +/* This bit of assemly does jmp * .... */ static const unsigned char i386_jtab[] = { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 @@ -379,22 +436,48 @@ static const unsigned char i386_jtab[] = static const unsigned char arm_jtab[] = { - 0x00, 0xc0, 0x9f, 0xe5, - 0x00, 0xf0, 0x9c, 0xe5, + 0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ + 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */ + 0, 0, 0, 0 +}; + +static const unsigned char arm_interwork_jtab[] = +{ + 0x04, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ + 0x00, 0xc0, 0x9c, 0xe5, /* ldr ip, [ip] */ + 0x1c, 0xff, 0x2f, 0xe1, /* bx ip */ 0, 0, 0, 0 }; static const unsigned char thumb_jtab[] = { - 0xc0, 0xb4, - 0x02, 0x4e, - 0x36, 0x68, - 0x01, 0x96, - 0x40, 0xbd, - 0xc0, 0x46, + 0x40, 0xb4, /* push {r6} */ + 0x02, 0x4e, /* ldr r6, [pc, #8] */ + 0x36, 0x68, /* ldr r6, [r6] */ + 0xb4, 0x46, /* mov ip, r6 */ + 0x40, 0xbc, /* pop {r6} */ + 0x60, 0x47, /* bx ip */ 0, 0, 0, 0 }; +static const unsigned char mcore_be_jtab[] = +{ + 0x71, 0x02, /* lrw r1,2 */ + 0x81, 0x01, /* ld.w r1,(r1,0) */ + 0x00, 0xC1, /* jmp r1 */ + 0x12, 0x00, /* nop */ + 0x00, 0x00, 0x00, 0x00 /*
*/ +}; + +static const unsigned char mcore_le_jtab[] = +{ + 0x02, 0x71, /* lrw r1,2 */ + 0x01, 0x81, /* ld.w r1,(r1,0) */ + 0xC1, 0x00, /* jmp r1 */ + 0x00, 0x12, /* nop */ + 0x00, 0x00, 0x00, 0x00 /*
*/ +}; + /* This is the glue sequence for PowerPC PE. There is a */ /* tocrel16-tocdefn reloc against the first instruction. */ /* We also need a IMGLUE reloc against the glue function */ @@ -417,12 +500,6 @@ static const unsigned char ppc_jtab[] = static bfd_vma ppc_glue_insn = 0x80410004; #endif -/* The outfile array must be big enough to contain a fully - qualified path name, plus an arbitary series of command - line switches. We hope that PATH_MAX times two will be - enough. */ -static char outfile [PATHMAX * 2]; - struct mac { const char *type; @@ -436,6 +513,7 @@ struct mac const char *how_space; const char *how_align_short; const char *how_align_long; + const char *how_default_as_switches; const char *how_bfd_target; enum bfd_architecture how_bfd_arch; const unsigned char *how_jtab; @@ -450,31 +528,91 @@ mtable[] = #define MARM 0 "arm", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", - ".global", ".space", ".align\t2",".align\t4","pe-arm-little", bfd_arch_arm, + ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", + "pe-arm-little", bfd_arch_arm, arm_jtab, sizeof (arm_jtab), 8 } , { #define M386 1 - "i386", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",".align\t4","pe-i386",bfd_arch_i386, - i386_jtab, sizeof (i386_jtab), 2 + "i386", ".byte", ".short", ".long", ".asciz", "#", + "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "pe-i386",bfd_arch_i386, + i386_jtab, sizeof (i386_jtab), 2 } , { #define MPPC 2 - "ppc", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",".align\t4","pe-powerpcle",bfd_arch_powerpc, - ppc_jtab, sizeof (ppc_jtab), 0 + "ppc", ".byte", ".short", ".long", ".asciz", "#", + "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "pe-powerpcle",bfd_arch_powerpc, + ppc_jtab, sizeof (ppc_jtab), 0 } , { #define MTHUMB 3 "thumb", ".byte", ".short", ".long", ".asciz", "@", - "push\t{r6, r7}\n\tldr\tr6, [pc, #8]\n\tldr\tr6, [r6]\n\tstr\tr6, [sp, #4]\n\tpop\t{r6, pc}\n\tnop", - ".global", ".space", ".align\t2",".align\t4","pe-arm-little", bfd_arch_arm, + "push\t{r6}\n\tldr\tr6, [pc, #8]\n\tldr\tr6, [r6]\n\tmov\tip, r6\n\tpop\t{r6}\n\tbx\tip", + ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + "pe-arm-little", bfd_arch_arm, thumb_jtab, sizeof (thumb_jtab), 12 } , -{ 0} +#define MARM_INTERWORK 4 + { + "arm_interwork", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tip,[ip]\n\tbx\tip\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + "pe-arm-little", bfd_arch_arm, + arm_interwork_jtab, sizeof (arm_interwork_jtab), 12 + } + , + { +#define MMCORE_BE 5 + "mcore-be", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "", + "pe-mcore-big", bfd_arch_mcore, + mcore_be_jtab, sizeof (mcore_be_jtab), 8 + } + , + { +#define MMCORE_LE 6 + "mcore-le", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "-EL", + "pe-mcore-little", bfd_arch_mcore, + mcore_le_jtab, sizeof (mcore_le_jtab), 8 + } + , + { +#define MMCORE_ELF 7 + "mcore-elf-be", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "", + "elf32-mcore-big", bfd_arch_mcore, + mcore_be_jtab, sizeof (mcore_be_jtab), 8 + } + , + { +#define MMCORE_ELF_LE 8 + "mcore-elf-le", ".byte", ".short", ".long", ".asciz", "//", + "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", + ".global", ".space", ".align\t2",".align\t4", "-EL", + "elf32-mcore-little", bfd_arch_mcore, + mcore_le_jtab, sizeof (mcore_le_jtab), 8 + } + , + { +#define MARM_EPOC 9 + "arm", ".byte", ".short", ".long", ".asciz", "@", + "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", + ".global", ".space", ".align\t2",".align\t4", "", + "epoc-pe-arm-little", bfd_arch_arm, + arm_jtab, sizeof (arm_jtab), 8 + } + , + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; typedef struct dlist @@ -621,6 +759,11 @@ rvaafter (machine) case M386: case MPPC: case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: break; default: /* xgettext:c-format */ @@ -640,6 +783,11 @@ rvabefore (machine) case M386: case MPPC: case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: return ".rva\t"; default: /* xgettext:c-format */ @@ -658,6 +806,11 @@ asm_prefix (machine) case MARM: case MPPC: case MTHUMB: + case MARM_INTERWORK: + case MMCORE_BE: + case MMCORE_LE: + case MMCORE_ELF: + case MMCORE_ELF_LE: break; case M386: return "_"; @@ -681,12 +834,15 @@ asm_prefix (machine) #define ASM_RVA_BEFORE rvabefore(machine) #define ASM_RVA_AFTER rvaafter(machine) #define ASM_PREFIX asm_prefix(machine) -#define ASM_ALIGN_LONG mtable[machine].how_align_long -#define HOW_BFD_TARGET 0 /* always default*/ -#define HOW_BFD_ARCH mtable[machine].how_bfd_arch -#define HOW_JTAB mtable[machine].how_jtab -#define HOW_JTAB_SIZE mtable[machine].how_jtab_size -#define HOW_JTAB_ROFF mtable[machine].how_jtab_roff +#define ASM_ALIGN_LONG mtable[machine].how_align_long +#define HOW_BFD_READ_TARGET 0 /* always default*/ +#define HOW_BFD_WRITE_TARGET mtable[machine].how_bfd_target +#define HOW_BFD_ARCH mtable[machine].how_bfd_arch +#define HOW_JTAB mtable[machine].how_jtab +#define HOW_JTAB_SIZE mtable[machine].how_jtab_size +#define HOW_JTAB_ROFF mtable[machine].how_jtab_roff +#define ASM_SWITCHES mtable[machine].how_default_as_switches + static char **oav; void @@ -728,7 +884,7 @@ static int d_is_exe; int yyerror (err) - const char *err; + const char * err ATTRIBUTE_UNUSED; { /* xgettext:c-format */ warn (_("Syntax error in def file %s:%d\n"), def_file, linenumber); @@ -1071,9 +1227,9 @@ scan_drectve_symbols (abfd) char * buf; char * p; char * e; - + /* Look for .drectve's */ - s = bfd_get_section_by_name (abfd, ".drectve"); + s = bfd_get_section_by_name (abfd, DRECTVE_SECTION_NAME); if (s == NULL) return; @@ -1084,10 +1240,12 @@ scan_drectve_symbols (abfd) bfd_get_section_contents (abfd, s, buf, 0, size); /* xgettext:c-format */ - inform (_("Sucking in info from .drective section in %s\n"), - bfd_get_filename (abfd)); + inform (_("Sucking in info from %s section in %s\n"), + DRECTVE_SECTION_NAME, bfd_get_filename (abfd)); - /* Search for -export: strings */ + /* Search for -export: strings. The exported symbols can optionally + have type tags (eg., -export:foo,data), so handle those as well. + Currently only data tag is supported. */ p = buf; e = buf + size; while (p < e) @@ -1097,25 +1255,35 @@ scan_drectve_symbols (abfd) { char * name; char * c; + flagword flags = BSF_FUNCTION; p += 8; name = p; - while (p < e && *p != ' ' && *p != '-') + while (p < e && *p != ',' && *p != ' ' && *p != '-') p++; c = xmalloc (p - name + 1); memcpy (c, name, p - name); c[p - name] = 0; + if (p < e && *p == ',') /* found type tag. */ + { + char *tag_start = ++p; + while (p < e && *p != ' ' && *p != '-') + p++; + if (strncmp (tag_start, "data", 4) == 0) + flags &= ~BSF_FUNCTION; + } /* FIXME: The 5th arg is for the `constant' field. What should it be? Not that it matters since it's not currently useful. */ - def_exports (c, 0, -1, 0, 0, 0); + def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION)); if (add_stdcall_alias && strchr (c, '@')) { char *exported_name = xstrdup (c); char *atsym = strchr (exported_name, '@'); *atsym = '\0'; + /* Note: stdcall alias symbols can never be data. */ def_exports (exported_name, xstrdup (c), -1, 0, 0, 0); } } @@ -1157,13 +1325,15 @@ scan_filtered_symbols (abfd, minisyms, symcount, size) if (bfd_get_symbol_leading_char (abfd) == symbol_name[0]) ++symbol_name; - def_exports (xstrdup (symbol_name) , 0, -1, 0, 0, 0); + def_exports (xstrdup (symbol_name) , 0, -1, 0, 0, + ! (sym->flags & BSF_FUNCTION)); if (add_stdcall_alias && strchr (symbol_name, '@')) { char *exported_name = xstrdup (symbol_name); char *atsym = strchr (exported_name, '@'); *atsym = '\0'; + /* Note: stdcall alias symbols can never be data. */ def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0); } } @@ -1327,7 +1497,7 @@ scan_open_obj_file (abfd) /* FIXME: we ought to read in and block out the base relocations */ /* xgettext:c-format */ - inform (_("%s: Done reading %s\n"), bfd_get_filename (abfd)); + inform (_("Done reading %s\n"), bfd_get_filename (abfd)); } static void @@ -1353,10 +1523,20 @@ scan_obj_file (filename) bfd_close (arfile); arfile = bfd_openr_next_archived_file (f, arfile); } + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + inform (_("Cannot produce mcore-elf dll from archive file: %s"), filename); +#endif } else if (bfd_check_format (f, bfd_object)) { scan_open_obj_file (f); + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + mcore_elf_cache_filename ((char *) filename); +#endif } bfd_close (f); @@ -1416,10 +1596,17 @@ flush_page (f, need, page_addr, on_page) ASM_LONG, (on_page * 2) + (on_page & 1) * 2 + 8, ASM_C); + for (i = 0; i < on_page; i++) { - fprintf (f, "\t%s\t0x%lx\n", ASM_SHORT, (need[i] - page_addr) | 0x3000); + long needed = need[i]; + + if (needed) + needed = ((needed - page_addr) | 0x3000) & 0xffff; + + fprintf (f, "\t%s\t0x%lx\n", ASM_SHORT, needed); } + /* And padding */ if (on_page & 1) fprintf (f, "\t%s\t0x%x\n", ASM_SHORT, 0 | 0x0000); @@ -1575,6 +1762,22 @@ generate_idata_ofile (filvar) } } +/* Assemble the specified file. */ +static void +assemble_file (source, dest) + const char * source; + const char * dest; +{ + char * cmd; + + cmd = (char *) alloca (strlen (ASM_SWITCHES) + strlen (as_flags) + + strlen (source) + strlen (dest) + 50); + + sprintf (cmd, "%s %s -o %s %s", ASM_SWITCHES, as_flags, dest, source); + + run (as_name, cmd); +} + static void gen_exp_file () { @@ -1647,8 +1850,8 @@ gen_exp_file () } } fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE, - ASM_PREFIX, - exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal); + ASM_PREFIX, + exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal); i++; } @@ -1678,12 +1881,13 @@ gen_exp_file () if (a_list) { - fprintf (f, "\t.section .drectve\n"); + fprintf (f, "\t.section %s\n", DRECTVE_SECTION_NAME); for (dl = a_list; dl; dl = dl->next) { fprintf (f, "\t%s\t\"%s\"\n", ASM_TEXT, dl->text); } } + if (d_list) { fprintf (f, "\t.section .rdata\n"); @@ -1691,9 +1895,9 @@ gen_exp_file () { char *p; int l; - /* We dont output as ascii 'cause there can - be quote characters in the string */ - + + /* We don't output as ascii because there can + be quote characters in the string. */ l = 0; for (p = dl->text; *p; p++) { @@ -1719,7 +1923,7 @@ gen_exp_file () /* Add to the output file a way of getting to the exported names - without using the import library. */ + without using the import library. */ if (add_indirect) { fprintf (f, "\t.section\t.rdata\n"); @@ -1729,9 +1933,11 @@ gen_exp_file () /* We use a single underscore for MS compatibility, and a double underscore for backward compatibility with old cygwin releases. */ - fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); + if (create_compat_implib) + fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); fprintf (f, "\t%s\t_imp__%s\n", ASM_GLOBAL, exp->name); - fprintf (f, "__imp_%s:\n", exp->name); + if (create_compat_implib) + fprintf (f, "__imp_%s:\n", exp->name); fprintf (f, "_imp__%s:\n", exp->name); fprintf (f, "\t%s\t%s\n", ASM_LONG, exp->name); } @@ -1765,8 +1971,6 @@ gen_exp_file () int src; int dst = 0; int last = -1; - int totsize = 0; - qsort (copy, num_entries, sizeof (long), sfunc); /* Delete duplcates */ for (src = 0; src < num_entries; src++) @@ -1780,31 +1984,18 @@ gen_exp_file () on_page = 0; for (j = 0; j < num_entries; j++) { - totsize += 2; addr = copy[j]; if ((addr & PAGE_MASK) != page_addr) { - totsize += 8 + (on_page & 1)*2; flush_page (f, need, page_addr, on_page); on_page = 0; page_addr = addr & PAGE_MASK; } need[on_page++] = addr; } - - /* Pad the section to an even 32-byte boundary. This will make - the BeOS loader much happier, and shouldn't matter for other - OSes. */ - while ((totsize + 8 + (on_page & 1)*2) % 32 != 0) - { - /* 0x0000 is an absolute relocation that should be ignored. */ - need[on_page++] = 0x0000; - totsize += 2; - } - flush_page (f, need, page_addr, on_page); - /* fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);*/ +/* fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);*/ } } @@ -1813,15 +2004,8 @@ gen_exp_file () fclose (f); /* assemble the file */ - sprintf (outfile, "%s -o %s %s", as_flags, exp_name, TMP_ASM); + assemble_file (TMP_ASM, exp_name); -#ifdef DLLTOOL_ARM - if (interwork) - strcat (outfile, " -mthumb-interwork"); -#endif - - run (as_name, outfile); - if (dontdeltemps == 0) unlink (TMP_ASM); @@ -1900,15 +2084,16 @@ typedef struct #define NSECS 7 +#define INIT_SEC_DATA(id, name, flags, align) { id, name, flags, align, NULL, NULL, NULL, 0, NULL } static sinfo secdata[NSECS] = { - { TEXT, ".text", SEC_CODE | SEC_HAS_CONTENTS, 2}, - { DATA, ".data", SEC_DATA, 2}, - { BSS, ".bss", 0, 2}, - { IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2}, - { IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2}, - { IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2}, - { IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1} + INIT_SEC_DATA (TEXT, ".text", SEC_CODE | SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (DATA, ".data", SEC_DATA, 2), + INIT_SEC_DATA (BSS, ".bss", 0, 2), + INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1) }; #else @@ -2001,16 +2186,22 @@ make_one_lib_file (exp, i) { #if 0 { + char *name; FILE *f; - char *prefix="d"; - sprintf (outfile, "%ss%05d.s", prefix, i); - f = fopen (outfile, FOPEN_WT); + const char *prefix = "d"; + char *dest; + + name = (char *) alloca (strlen (prefix) + 10); + sprintf (name, "%ss%05d.s", prefix, i); + f = fopen (name, FOPEN_WT); fprintf (f, "\t.text\n"); fprintf (f, "\t%s\t%s%s\n", ASM_GLOBAL, ASM_PREFIX, exp->name); - fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); + if (create_compat_implib) + fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); fprintf (f, "\t%s\t_imp__%s\n", ASM_GLOBAL, exp->name); - fprintf (f, "%s%s:\n\t%s\t__imp_%s\n", ASM_PREFIX, - exp->name, ASM_JUMP, exp->name); + if (create_compat_implib) + fprintf (f, "%s%s:\n\t%s\t__imp_%s\n", ASM_PREFIX, + exp->name, ASM_JUMP, exp->name); fprintf (f, "\t.section\t.idata$7\t%s To force loading of head\n", ASM_C); fprintf (f, "\t%s\t%s\n", ASM_LONG, head_label); @@ -2019,7 +2210,8 @@ make_one_lib_file (exp, i) fprintf (f,"%s Import Address Table\n", ASM_C); fprintf (f, "\t.section .idata$5\n"); - fprintf (f, "__imp_%s:\n", exp->name); + if (create_compat_implib) + fprintf (f, "__imp_%s:\n", exp->name); fprintf (f, "_imp__%s:\n", exp->name); dump_iat (f, exp); @@ -2039,15 +2231,9 @@ make_one_lib_file (exp, i) fclose (f); - sprintf (outfile, "%s -o %ss%05d.o %ss%d.s", - as_flags, prefix, i, prefix, i); - -#ifdef DLLTOOL_ARM - if (interwork) - strcat (outfile, " -mthumb-interwork"); -#endif - - run (as_name, outfile); + dest = (char *) alloca (strlen (prefix) + 10); + sprintf (dest, "%ss%05d.o", prefix, i); + assemble_file (name, dest); } #else /* if 0 */ { @@ -2074,7 +2260,7 @@ make_one_lib_file (exp, i) sprintf (outname, "%s%05d.o", TMP_STUB, i); - abfd = bfd_openw (outname, HOW_BFD_TARGET); + abfd = bfd_openw (outname, HOW_BFD_WRITE_TARGET); if (!abfd) /* xgettext:c-format */ @@ -2087,7 +2273,7 @@ make_one_lib_file (exp, i) bfd_set_arch_mach (abfd, HOW_BFD_ARCH, 0); #ifdef DLLTOOL_ARM - if (interwork) + if (machine == MARM_INTERWORK || machine == MTHUMB) bfd_set_private_flags (abfd, F_INTERWORK); #endif @@ -2146,13 +2332,16 @@ make_one_lib_file (exp, i) /* Generate imp symbols with one underscore for Microsoft compatibility, and with two underscores for backward compatibility with old versions of cygwin. */ - iname = bfd_make_empty_symbol(abfd); - iname->name = make_label ("__imp_", exp->name); - iname->section = secdata[IDATA5].sec; - iname->flags = BSF_GLOBAL; - iname->value = 0; + if (create_compat_implib) + { + iname = bfd_make_empty_symbol (abfd); + iname->name = make_label ("__imp_", exp->name); + iname->section = secdata[IDATA5].sec; + iname->flags = BSF_GLOBAL; + iname->value = 0; + } - iname2 = bfd_make_empty_symbol(abfd); + iname2 = bfd_make_empty_symbol (abfd); iname2->name = make_label ("_imp__", exp->name); iname2->section = secdata[IDATA5].sec; iname2->flags = BSF_GLOBAL; @@ -2167,7 +2356,8 @@ make_one_lib_file (exp, i) iname_pp = ptrs + oidx; - ptrs[oidx++] = iname; + if (create_compat_implib) + ptrs[oidx++] = iname; ptrs[oidx++] = iname2; iname_lab_pp = ptrs + oidx; @@ -2451,7 +2641,7 @@ make_one_lib_file (exp, i) bfd_set_symtab (abfd, ptrs, oidx); bfd_close (abfd); - abfd = bfd_openr (outname, HOW_BFD_TARGET); + abfd = bfd_openr (outname, HOW_BFD_READ_TARGET); return abfd; } #endif @@ -2460,8 +2650,14 @@ make_one_lib_file (exp, i) static bfd * make_head () { - FILE * f = fopen (TMP_HEAD_S, FOPEN_WT); + FILE *f = fopen (TMP_HEAD_S, FOPEN_WT); + if (f == NULL) + { + fatal (_("failed to open temporary head file: %s"), TMP_HEAD_S); + return NULL; + } + fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C); fprintf (f, "\t.section .idata$2\n"); @@ -2493,6 +2689,7 @@ make_head () fprintf (f, "\t%s\t0\n", ASM_LONG); fprintf (f, "fthunk:\n"); } + if (!no_idata4) { fprintf (f, "\t.section\t.idata$4\n"); @@ -2501,30 +2698,31 @@ make_head () fprintf (f, "\t.section .idata$4\n"); fprintf (f, "hname:\n"); } + fclose (f); - sprintf (outfile, "%s -o %s %s", as_flags, TMP_HEAD_O, TMP_HEAD_S); - -#ifdef DLLTOOL_ARM - if (interwork) - strcat (outfile, " -mthumb-interwork"); -#endif - - run (as_name, outfile); + assemble_file (TMP_HEAD_S, TMP_HEAD_O); - return bfd_openr (TMP_HEAD_O, HOW_BFD_TARGET); + return bfd_openr (TMP_HEAD_O, HOW_BFD_READ_TARGET); } static bfd * make_tail () { - FILE * f = fopen (TMP_TAIL_S, FOPEN_WT); + FILE *f = fopen (TMP_TAIL_S, FOPEN_WT); + if (f == NULL) + { + fatal (_("failed to open temporary tail file: %s"), TMP_TAIL_S); + return NULL; + } + if (!no_idata4) { fprintf (f, "\t.section .idata$4\n"); fprintf (f, "\t%s\t0\n", ASM_LONG); } + if (!no_idata5) { fprintf (f, "\t.section .idata$5\n"); @@ -2562,16 +2760,9 @@ make_tail () fclose (f); - sprintf (outfile, "%s -o %s %s", as_flags, TMP_TAIL_O, TMP_TAIL_S); - -#ifdef DLLTOOL_ARM - if (interwork) - strcat (outfile, " -mthumb-interwork"); -#endif - - run (as_name, outfile); + assemble_file (TMP_TAIL_S, TMP_TAIL_O); - return bfd_openr (TMP_TAIL_O, HOW_BFD_TARGET); + return bfd_openr (TMP_TAIL_O, HOW_BFD_READ_TARGET); } static void @@ -2586,7 +2777,7 @@ gen_lib_file () unlink (imp_name); - outarch = bfd_openw (imp_name, HOW_BFD_TARGET); + outarch = bfd_openw (imp_name, HOW_BFD_WRITE_TARGET); if (!outarch) /* xgettext:c-format */ @@ -2644,12 +2835,15 @@ gen_lib_file () if (dontdeltemps < 2) { + char *name; + + name = (char *) alloca (sizeof TMP_STUB + 10); for (i = 0, exp = d_exports; exp; i++, exp = exp->next) { - sprintf (outfile, "%s%05d.o", TMP_STUB, i); - if (unlink (outfile) < 0) + sprintf (name, "%s%05d.o", TMP_STUB, i); + if (unlink (name) < 0) /* xgettext:c-format */ - warn (_("cannot delete %s: %s\n"), outfile, strerror (errno)); + warn (_("cannot delete %s: %s\n"), name, strerror (errno)); } } @@ -2708,7 +2902,11 @@ remove_null_names (ptr) static void dtab (ptr) - export_type **ptr; + export_type ** ptr +#ifndef SACDEBUG +ATTRIBUTE_UNUSED +#endif + ; { #ifdef SACDEBUG int i; @@ -2938,17 +3136,18 @@ usage (file, status) /* xgetext:c-format */ fprintf (file, _("Usage %s \n"), program_name); /* xgetext:c-format */ - fprintf (file, _(" -m --machine Create {arm, i386, ppc, thumb} DLL. [default: %s]\n"), mname); + fprintf (file, _(" -m --machine Create as DLL for . [default: %s]\n"), mname); + fprintf (file, _(" possible : arm[_interwork], i386, mcore[-elf]{-le|-be}, ppc, thumb\n")); fprintf (file, _(" -e --output-exp Generate an export file.\n")); fprintf (file, _(" -l --output-lib Generate an interface library.\n")); fprintf (file, _(" -a --add-indirect Add dll indirects to export file.\n")); fprintf (file, _(" -D --dllname Name of input dll to put into interface lib.\n")); fprintf (file, _(" -d --input-def Name of .def file to be read in.\n")); fprintf (file, _(" -z --output-def Name of .def file to be created.\n")); - fprintf (file, _(" --export-all-symbols Export all symbols to .def\n")); - fprintf (file, _(" --no-export-all-symbols Only export listed symbols\n")); - fprintf (file, _(" --exclude-symbols Don't export \n")); - fprintf (file, _(" --no-default-excludes Clear default exclude symbols\n")); + fprintf (file, _(" --export-all-symbols Export all symbols to .def\n")); + fprintf (file, _(" --no-export-all-symbols Only export listed symbols\n")); + fprintf (file, _(" --exclude-symbols Don't export \n")); + fprintf (file, _(" --no-default-excludes Clear default exclude symbols\n")); fprintf (file, _(" -b --base-file Read linker generated base file.\n")); fprintf (file, _(" -x --no-idata4 Don't generate idata$4 section.\n")); fprintf (file, _(" -c --no-idata5 Don't generate idata$5 section.\n")); @@ -2957,14 +3156,16 @@ usage (file, status) fprintf (file, _(" -A --add-stdcall-alias Add aliases without @.\n")); fprintf (file, _(" -S --as Use for assembler.\n")); fprintf (file, _(" -f --as-flags Pass to the assembler.\n")); -#ifdef DLLTOOL_ARM - fprintf (file, _(" -i --interwork Support ARM/Thumb interworking.\n")); -#endif + fprintf (file, _(" -C --compat-implib Create backward compatible import library.\n")); fprintf (file, _(" -n --no-delete Keep temp files (repeat for extra preservation).\n")); fprintf (file, _(" -v --verbose Be verbose.\n")); fprintf (file, _(" -V --version Display the program version.\n")); fprintf (file, _(" -h --help Display this information.\n")); - +#ifdef DLLTOOL_MCORE_ELF + fprintf (file, _(" -M --mcore-elf Process mcore-elf object files into .\n")); + fprintf (file, _(" -L --linker Use as the linker.\n")); + fprintf (file, _(" -F --linker-flags Pass to the linker.\n")); +#endif exit (status); } @@ -2972,15 +3173,13 @@ usage (file, status) #define OPTION_NO_EXPORT_ALL_SYMS (OPTION_EXPORT_ALL_SYMS + 1) #define OPTION_EXCLUDE_SYMS (OPTION_NO_EXPORT_ALL_SYMS + 1) #define OPTION_NO_DEFAULT_EXCLUDES (OPTION_EXCLUDE_SYMS + 1) -#define OPTION_NO_IDATA4 'x' -#define OPTION_NO_IDATA5 'c' static const struct option long_options[] = { {"no-delete", no_argument, NULL, 'n'}, {"dllname", required_argument, NULL, 'D'}, - {"no-idata4", no_argument, NULL, OPTION_NO_IDATA4}, - {"no-idata5", no_argument, NULL, OPTION_NO_IDATA5}, + {"no-idata4", no_argument, NULL, 'x'}, + {"no-idata5", no_argument, NULL, 'c'}, {"output-exp", required_argument, NULL, 'e'}, {"output-def", required_argument, NULL, 'z'}, {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL_SYMS}, @@ -3001,10 +3200,9 @@ static const struct option long_options[] = {"base-file", required_argument, NULL, 'b'}, {"as", required_argument, NULL, 'S'}, {"as-flags", required_argument, NULL, 'f'}, -#ifdef DLLTOOL_ARM - {"interwork", no_argument, NULL, 'i'}, -#endif - {0} + {"mcore-elf", required_argument, NULL, 'M'}, + {"compat-implib", no_argument, NULL, 'C'}, + {NULL,0,NULL,0} }; int @@ -3024,18 +3222,17 @@ main (ac, av) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - while ((c = getopt_long (ac, av, "xcz:S:aD:l:e:nkAvVb:Uh?m:d:f:i", + while ((c = getopt_long (ac, av, +#ifdef DLLTOOL_MCORE_ELF + "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVhM:L:F:", +#else + "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVh", +#endif long_options, 0)) != EOF) { switch (c) { - case OPTION_NO_IDATA4: - no_idata4 = 1; - break; - case OPTION_NO_IDATA5: - no_idata5 = 1; - break; case OPTION_EXPORT_ALL_SYMS: export_all_symbols = true; break; @@ -3048,6 +3245,12 @@ main (ac, av) case OPTION_NO_DEFAULT_EXCLUDES: do_default_excludes = false; break; + case 'x': + no_idata4 = 1; + break; + case 'c': + no_idata5 = 1; + break; case 'S': as_name = optarg; break; @@ -3085,18 +3288,6 @@ main (ac, av) case 'V': print_version (program_name); break; -#ifdef DLLTOOL_ARM - case 'i': - interwork = 1; - break; -#endif - case 'y': -#if 0 - /* We don't currently define YYDEBUG when building - defparse.y. */ - yydebug = 1; -#endif - break; case 'U': add_underscore = 1; break; @@ -3120,6 +3311,20 @@ main (ac, av) fatal (_("Unable to open base-file: %s"), optarg); break; +#ifdef DLLTOOL_MCORE_ELF + case 'M': + mcore_elf_out_file = optarg; + break; + case 'L': + mcore_elf_linker = optarg; + break; + case 'F': + mcore_elf_linker_flags = optarg; + break; +#endif + case 'C': + create_compat_implib = 1; + break; default: usage (stderr, 1); break; @@ -3127,10 +3332,8 @@ main (ac, av) } for (i = 0; mtable[i].type; i++) - { - if (strcmp (mtable[i].type, mname) == 0) - break; - } + if (strcmp (mtable[i].type, mname) == 0) + break; if (!mtable[i].type) /* xgettext:c-format */ @@ -3138,12 +3341,6 @@ main (ac, av) machine = i; -#ifdef DLLTOOL_ARM - /* Always enable interworking for Thumb targets. */ - if (machine == MTHUMB && (! interwork)) - interwork = 1; -#endif - if (!dll_name && exp_name) { int len = strlen (exp_name) + 5; @@ -3152,6 +3349,9 @@ main (ac, av) strcat (dll_name, ".dll"); } + if (as_name == NULL) + as_name = deduce_name ("as"); + /* Don't use the default exclude list if we're reading only the symbols in the .drectve section. The default excludes are meant to avoid exporting DLL entry point and Cygwin32 impure_ptr. */ @@ -3194,6 +3394,256 @@ main (ac, av) if (output_def) gen_def_file (); - + +#ifdef DLLTOOL_MCORE_ELF + if (mcore_elf_out_file) + mcore_elf_gen_out_file (); +#endif + return 0; } + +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + appropriate. */ + +static char * +look_for_prog (prog_name, prefix, end_prefix) + const char *prog_name; + const char *prefix; + int end_prefix; +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (prog_name) +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", prog_name); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + +/* Deduce the name of the program we are want to invoke. + PROG_NAME is the basic name of the program we want to run, + eg "as" or "ld". The catch is that we might want actually + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + +static char * +deduce_name (prog_name) + const char *prog_name; +{ + char *cmd; + char *dash, *slash, *cp; + + dash = NULL; + slash = NULL; + for (cp = program_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } + + cmd = NULL; + + if (dash != NULL) + { + /* First, try looking for a prefixed PROG_NAME in the + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); + } + + if (slash != NULL && cmd == NULL) + { + /* Next, try looking for a PROG_NAME in the same directory as + that of this program. */ + cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); + } + + if (cmd == NULL) + { + /* Just return PROG_NAME as is. */ + cmd = xstrdup (prog_name); + } + + return cmd; +} + +#ifdef DLLTOOL_MCORE_ELF +typedef struct fname_cache +{ + char * filename; + struct fname_cache * next; +} +fname_cache; + +static fname_cache fnames; + +static void +mcore_elf_cache_filename (char * filename) +{ + fname_cache * ptr; + + ptr = & fnames; + + while (ptr->next != NULL) + ptr = ptr->next; + + ptr->filename = filename; + ptr->next = (fname_cache *) malloc (sizeof (fname_cache)); + if (ptr->next != NULL) + ptr->next->next = NULL; +} + +#define MCORE_ELF_TMP_OBJ "mcoreelf.o" +#define MCORE_ELF_TMP_EXP "mcoreelf.exp" +#define MCORE_ELF_TMP_LIB "mcoreelf.lib" + +static void +mcore_elf_gen_out_file (void) +{ + fname_cache * ptr; + dyn_string_t ds; + + /* Step one. Run 'ld -r' on the input object files in order to resolve + any internal references and to generate a single .exports section. */ + ptr = & fnames; + + ds = dyn_string_new (100); + dyn_string_append (ds, "-r "); + + if (mcore_elf_linker_flags != NULL) + dyn_string_append (ds, mcore_elf_linker_flags); + + while (ptr->next != NULL) + { + dyn_string_append (ds, ptr->filename); + dyn_string_append (ds, " "); + + ptr = ptr->next; + } + + dyn_string_append (ds, "-o "); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); + + if (mcore_elf_linker == NULL) + mcore_elf_linker = deduce_name ("ld"); + + run (mcore_elf_linker, ds->s); + + dyn_string_delete (ds); + + /* Step two. Create a .exp file and a .lib file from the temporary file. + Do this by recursively invoking dlltool....*/ + ds = dyn_string_new (100); + + dyn_string_append (ds, "-S "); + dyn_string_append (ds, as_name); + + dyn_string_append (ds, " -e "); + dyn_string_append (ds, MCORE_ELF_TMP_EXP); + dyn_string_append (ds, " -l "); + dyn_string_append (ds, MCORE_ELF_TMP_LIB); + dyn_string_append (ds, " " ); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); + + if (verbose) + dyn_string_append (ds, " -v"); + + if (dontdeltemps) + { + dyn_string_append (ds, " -n"); + + if (dontdeltemps > 1) + dyn_string_append (ds, " -n"); + } + + /* XXX - FIME: ought to check/copy other command line options as well. */ + + run (program_name, ds->s); + + dyn_string_delete (ds); + + /* Step four. Feed the .exp and object files to ld -shared to create the dll. */ + ds = dyn_string_new (100); + + dyn_string_append (ds, "-shared "); + + if (mcore_elf_linker_flags) + dyn_string_append (ds, mcore_elf_linker_flags); + + dyn_string_append (ds, " "); + dyn_string_append (ds, MCORE_ELF_TMP_EXP); + dyn_string_append (ds, " "); + dyn_string_append (ds, MCORE_ELF_TMP_OBJ); + dyn_string_append (ds, " -o "); + dyn_string_append (ds, mcore_elf_out_file); + + run (mcore_elf_linker, ds->s); + + dyn_string_delete (ds); + + if (dontdeltemps == 0) + unlink (MCORE_ELF_TMP_EXP); + + if (dontdeltemps < 2) + unlink (MCORE_ELF_TMP_OBJ); +} +#endif /* DLLTOOL_MCORE_ELF */ diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c index 574611b..25bf519 100644 --- a/binutils/dllwrap.c +++ b/binutils/dllwrap.c @@ -1,5 +1,5 @@ /* dllwrap.c -- wrapper for DLLTOOL and GCC to generate PE style DLLs - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. Contributed by Mumit Khan (khan@xraylith.wisc.edu). This file is part of GNU Binutils. @@ -26,21 +26,10 @@ #endif #endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif - #include "bfd.h" #include "libiberty.h" #include "bucomm.h" @@ -49,6 +38,13 @@ #include #include +#include + +#ifdef ANSI_PROTOTYPES +#include +#else +#include +#endif #ifdef HAVE_SYS_WAIT_H #include @@ -83,7 +79,7 @@ #endif /* ! HAVE_SYS_WAIT_H */ static char *program_version = "0.2.4"; -static char *driver_name = "gcc"; +static char *driver_name = NULL; static char *cygwin_driver_flags = "-Wl,--dll -nostartfiles"; static char *mingw32_driver_flags = "-mdll"; @@ -91,14 +87,14 @@ static char *generic_driver_flags = "-Wl,--dll"; static char *entry_point; -static char *dlltool_name = "dlltool"; +static char *dlltool_name = NULL; static char *target = TARGET; typedef enum { UNKNOWN_TARGET, CYGWIN_TARGET, - MINGW32_TARGET + MINGW_TARGET } target_type; @@ -122,11 +118,186 @@ static int delete_def_file = 1; static int run PARAMS ((const char *, char *)); static void usage PARAMS ((FILE *, int)); +static void display PARAMS ((const char *, va_list)); +static void inform PARAMS ((const char *, ...)); +static char *look_for_prog PARAMS ((const char *, const char *, int)); +static char *deduce_name PARAMS ((const char *)); static void delete_temp_files PARAMS ((void)); static void cleanup_and_exit PARAMS ((int status)); /**********************************************************************/ +/* Please keep the following 4 routines in sync with dlltool.c: + display () + inform () + look_for_prog () + deduce_name () + It's not worth the hassle to break these out since dllwrap will + (hopefully) soon be retired in favor of `ld --shared. */ + +static void +display (message, args) + const char * message; + va_list args; +{ + if (program_name != NULL) + fprintf (stderr, "%s: ", program_name); + + vfprintf (stderr, message, args); + + if (message [strlen (message) - 1] != '\n') + fputc ('\n', stderr); +} + + +static void +#ifdef __STDC__ +inform (const char * message, ...) +#else +inform (message, va_alist) + const char * message; + va_dcl +#endif +{ + va_list args; + + if (!verbose) + return; + +#ifdef __STDC__ + va_start (args, message); +#else + va_start (args); +#endif + + display (message, args); + + va_end (args); +} + +/* Look for the program formed by concatenating PROG_NAME and the + string running from PREFIX to END_PREFIX. If the concatenated + string contains a '/', try appending EXECUTABLE_SUFFIX if it is + appropriate. */ + +static char * +look_for_prog (prog_name, prefix, end_prefix) + const char *prog_name; + const char *prefix; + int end_prefix; +{ + struct stat s; + char *cmd; + + cmd = xmalloc (strlen (prefix) + + strlen (prog_name) +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", prog_name); + + if (strchr (cmd, '/') != NULL) + { + int found; + + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + /* xgettext:c-format */ + inform (_("Tried file: %s"), cmd); + free (cmd); + return NULL; + } + } + + /* xgettext:c-format */ + inform (_("Using file: %s"), cmd); + + return cmd; +} + +/* Deduce the name of the program we are want to invoke. + PROG_NAME is the basic name of the program we want to run, + eg "as" or "ld". The catch is that we might want actually + run "i386-pe-as" or "ppc-pe-ld". + + If argv[0] contains the full path, then try to find the program + in the same place, with and then without a target-like prefix. + + Given, argv[0] = /usr/local/bin/i586-cygwin32-dlltool, + deduce_name("as") uses the following search order: + + /usr/local/bin/i586-cygwin32-as + /usr/local/bin/as + as + + If there's an EXECUTABLE_SUFFIX, it'll use that as well; for each + name, it'll try without and then with EXECUTABLE_SUFFIX. + + Given, argv[0] = i586-cygwin32-dlltool, it will not even try "as" + as the fallback, but rather return i586-cygwin32-as. + + Oh, and given, argv[0] = dlltool, it'll return "as". + + Returns a dynamically allocated string. */ + +static char * +deduce_name (prog_name) + const char *prog_name; +{ + char *cmd; + char *dash, *slash, *cp; + + dash = NULL; + slash = NULL; + for (cp = program_name; *cp != '\0'; ++cp) + { + if (*cp == '-') + dash = cp; + if ( +#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = NULL; + } + } + + cmd = NULL; + + if (dash != NULL) + { + /* First, try looking for a prefixed PROG_NAME in the + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); + } + + if (slash != NULL && cmd == NULL) + { + /* Next, try looking for a PROG_NAME in the same directory as + that of this program. */ + cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); + } + + if (cmd == NULL) + { + /* Just return PROG_NAME as is. */ + cmd = xstrdup (prog_name); + } + + return cmd; +} + static void delete_temp_files () { @@ -341,6 +512,7 @@ usage (file, status) fprintf (file, " --image-base Specify image base address\n"); fprintf (file, " --target i386-cygwin32 or i386-mingw32\n"); fprintf (file, " --dry-run Show what needs to be run\n"); + fprintf (file, " --mno-cygwin Create Mingw DLL\n"); fprintf (file, " Options passed to DLLTOOL:\n"); fprintf (file, " --machine \n"); fprintf (file, " --output-exp Generate export file.\n"); @@ -381,9 +553,10 @@ usage (file, status) #define OPTION_ENTRY (OPTION_DLLTOOL_NAME + 1) #define OPTION_IMAGE_BASE (OPTION_ENTRY + 1) #define OPTION_TARGET (OPTION_IMAGE_BASE + 1) +#define OPTION_MNO_CYGWIN (OPTION_TARGET + 1) /* DLLTOOL options. */ -#define OPTION_NODELETE (OPTION_TARGET + 1) +#define OPTION_NODELETE (OPTION_MNO_CYGWIN + 1) #define OPTION_DLLNAME (OPTION_NODELETE + 1) #define OPTION_NO_IDATA4 (OPTION_DLLNAME + 1) #define OPTION_NO_IDATA5 (OPTION_NO_IDATA4 + 1) @@ -568,6 +741,9 @@ main (argc, argv) case OPTION_TARGET: target = optarg; break; + case OPTION_MNO_CYGWIN: + target = "i386-mingw32"; + break; case OPTION_BASE_FILE: base_file_name = optarg; delete_base_file = 0; @@ -614,7 +790,7 @@ main (argc, argv) } } } - + /* sanity checks. */ if (! dll_name && ! dll_file_name) { @@ -631,7 +807,14 @@ main (argc, argv) { dll_file_name = xstrdup (dll_name); } - + + /* Deduce driver-name and dlltool-name from our own. */ + if (driver_name == NULL) + driver_name = deduce_name ("gcc"); + + if (dlltool_name == NULL) + dlltool_name = deduce_name ("dlltool"); + if (! def_file_seen) { char *fileprefix = choose_temp_base (); @@ -647,10 +830,10 @@ main (argc, argv) } /* set the target platform. */ - if (strstr (target, "cygwin32")) + if (strstr (target, "cygwin")) which_target = CYGWIN_TARGET; - else if (strstr (target, "mingw32")) - which_target = MINGW32_TARGET; + else if (strstr (target, "mingw")) + which_target = MINGW_TARGET; else which_target = UNKNOWN_TARGET; @@ -686,7 +869,7 @@ main (argc, argv) driver_flags = cygwin_driver_flags; break; - case MINGW32_TARGET: + case MINGW_TARGET: driver_flags = mingw32_driver_flags; break; @@ -707,7 +890,7 @@ main (argc, argv) entry_point = "__cygwin_dll_entry@12"; break; - case MINGW32_TARGET: + case MINGW_TARGET: entry_point = "_DllMainCRTStartup@12"; break; diff --git a/binutils/dyn-string.c b/binutils/dyn-string.c index a4a3043..a164018 100644 --- a/binutils/dyn-string.c +++ b/binutils/dyn-string.c @@ -15,8 +15,8 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file lives in at least two places: binutils and gcc. Don't change one without the other. */ diff --git a/binutils/dyn-string.h b/binutils/dyn-string.h index a22bbbf..cbd25c3 100644 --- a/binutils/dyn-string.h +++ b/binutils/dyn-string.h @@ -15,8 +15,8 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file lives in at least two places: binutils and gcc. Don't change one without the other. */ diff --git a/binutils/filemode.c b/binutils/filemode.c index 58b52ba..f9811bc 100644 --- a/binutils/filemode.c +++ b/binutils/filemode.c @@ -1,5 +1,5 @@ /* filemode.c -- make a string describing file modes - Copyright (C) 1985, 90, 91, 94, 95, 1997 Free Software Foundation, Inc. + Copyright (C) 1985, 90, 91, 94, 95, 97, 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 @@ -230,8 +230,8 @@ ftypelet (bits) static void setst (bits, chars) - unsigned long bits; - char *chars; + unsigned long bits ATTRIBUTE_UNUSED; + char *chars ATTRIBUTE_UNUSED; { #ifdef S_ISUID if (bits & S_ISUID) diff --git a/binutils/ieee.c b/binutils/ieee.c index 17a5b88..a3bb93b 100644 --- a/binutils/ieee.c +++ b/binutils/ieee.c @@ -1,5 +1,5 @@ /* ieee.c -- Read and write IEEE-695 debugging information. - Copyright (C) 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -779,7 +779,7 @@ ieee_builtin_type (info, p, indx) case builtin_bcd_float: ieee_error (info, p, _("BCD float type not supported")); - return false; + return DEBUG_TYPE_NULL; } if (name != NULL) @@ -4104,7 +4104,7 @@ static const struct debug_write_fns ieee_fns = /*ARGSUSED*/ static boolean ieee_init_buffer (info, buflist) - struct ieee_handle *info; + struct ieee_handle *info ATTRIBUTE_UNUSED; struct ieee_buflist *buflist; { buflist->head = NULL; @@ -4145,7 +4145,7 @@ ieee_change_buffer (info, buflist) /*ARGSUSED*/ static boolean ieee_append_buffer (info, mainbuf, newbuf) - struct ieee_handle *info; + struct ieee_handle *info ATTRIBUTE_UNUSED; struct ieee_buflist *mainbuf; struct ieee_buflist *newbuf; { @@ -5135,7 +5135,7 @@ ieee_finish_compilation_unit (info) static void ieee_add_bb11_blocks (abfd, sec, data) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; PTR data; { @@ -5258,8 +5258,8 @@ ieee_add_bb11 (info, sec, low, high) /*ARGSUSED*/ static boolean ieee_start_source (p, filename) - PTR p; - const char *filename; + PTR p ATTRIBUTE_UNUSED; + const char *filename ATTRIBUTE_UNUSED; { return true; } @@ -5725,7 +5725,7 @@ ieee_array_type (p, low, high, stringp) PTR p; bfd_signed_vma low; bfd_signed_vma high; - boolean stringp; + boolean stringp ATTRIBUTE_UNUSED; { struct ieee_handle *info = (struct ieee_handle *) p; unsigned int eleindx; @@ -5792,7 +5792,7 @@ ieee_array_type (p, low, high, stringp) static boolean ieee_set_type (p, bitstringp) PTR p; - boolean bitstringp; + boolean bitstringp ATTRIBUTE_UNUSED; { struct ieee_handle *info = (struct ieee_handle *) p; boolean localp; @@ -7012,7 +7012,7 @@ ieee_typdef (p, name) static boolean ieee_tag (p, name) PTR p; - const char *name; + const char *name ATTRIBUTE_UNUSED; { struct ieee_handle *info = (struct ieee_handle *) p; @@ -7026,9 +7026,9 @@ ieee_tag (p, name) static boolean ieee_int_constant (p, name, val) - PTR p; - const char *name; - bfd_vma val; + PTR p ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; + bfd_vma val ATTRIBUTE_UNUSED; { /* FIXME. */ return true; @@ -7038,9 +7038,9 @@ ieee_int_constant (p, name, val) static boolean ieee_float_constant (p, name, val) - PTR p; - const char *name; - double val; + PTR p ATTRIBUTE_UNUSED; + const char *name ATTRIBUTE_UNUSED; + double val ATTRIBUTE_UNUSED; { /* FIXME. */ return true; @@ -7051,8 +7051,8 @@ ieee_float_constant (p, name, val) static boolean ieee_typed_constant (p, name, val) PTR p; - const char *name; - bfd_vma val; + const char *name ATTRIBUTE_UNUSED; + bfd_vma val ATTRIBUTE_UNUSED; { struct ieee_handle *info = (struct ieee_handle *) p; diff --git a/binutils/nm.c b/binutils/nm.c index c51b7fb..ade3f7c 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -1305,13 +1305,13 @@ print_archive_filename_bsd (filename) static void print_archive_filename_sysv (filename) - char *filename; + char *filename ATTRIBUTE_UNUSED; { } static void print_archive_filename_posix (filename) - char *filename; + char *filename ATTRIBUTE_UNUSED; { } @@ -1319,7 +1319,7 @@ print_archive_filename_posix (filename) static void print_archive_member_bsd (archive, filename) - char *archive; + char *archive ATTRIBUTE_UNUSED; CONST char *filename; { if (!filename_per_symbol) @@ -1427,7 +1427,7 @@ print_symbol_info_bsd (info, abfd) symbol_info *info; bfd *abfd; { - if (info->type == 'U') + if (bfd_is_undefined_symclass (info->type)) { printf ("%*s", #ifdef BFD64 @@ -1458,7 +1458,7 @@ print_symbol_info_sysv (info, abfd) bfd *abfd; { print_symname ("%-20s|", info->name, abfd); /* Name */ - if (info->type == 'U') + if (bfd_is_undefined_symclass (info->type)) printf (" "); /* Value */ else print_value (info->value); @@ -1481,7 +1481,7 @@ print_symbol_info_posix (info, abfd) { print_symname ("%s ", info->name, abfd); printf ("%c ", info->type); - if (info->type == 'U') + if (bfd_is_undefined_symclass (info->type)) printf (" "); else print_value (info->value); diff --git a/binutils/objcopy.1 b/binutils/objcopy.1 index aee7760..b3fa296 100644 --- a/binutils/objcopy.1 +++ b/binutils/objcopy.1 @@ -1,6 +1,6 @@ -.\" Copyright (c) 1991, 93, 94, 95, 96, 97, 1998 Free Software Foundation +.\" Copyright (c) 1991, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation .\" See section COPYING for conditions for redistribution -.TH objcopy 1 "October 1994" "cygnus support" "GNU Development Tools" +.TH objcopy 1 "1999" "Cygnus Solutions" "GNU Development Tools" .de BP .sp .ti \-.2i @@ -18,6 +18,7 @@ objcopy \- copy and translate object files .RB "[\|" \-F\ \fIbfdname\fR\ |\ \fB\-\-target=\fIbfdname\fR "\|]" .RB "[\|" \-I\ \fIbfdname\fR\ |\ \fB\-\-input\-target=\fIbfdname\fR "\|]" .RB "[\|" \-O\ \fIbfdname\fR\ |\ \fB\-\-output\-target=\fIbfdname\fR "\|]" +.RB "[\|" \-j\ \fIsectionname\fR\ |\ \fB\-\-only\-section=\fIsectionname\fR "\|]" .RB "[\|" \-R\ \fIsectionname\fR\ |\ \fB\-\-remove\-section=\fIsectionname\fR "\|]" .RB "[\|" \-S\fR\ |\ \fB\-\-strip\-all\fR "\|]" .RB "[\|" \-g\fR\ |\ \fB\-\-strip\-debug\fR "\|]" @@ -123,6 +124,12 @@ Use as the object format for both the input and the output file; i.e. simply transfer data from source to destination with no translation. .TP +.B \-j \fIsectionname\fR, \fB\-\-only\-section=\fIsectionname +Copy only the named section from the input file to the output file, +discarding all other sections. This option may be given more than +once. Note that using this option inappropriately may make the output +file unusable. +.TP .B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname Remove the named section from the file. This option may be given more than once. Note that using this option inappropriately may make the @@ -242,9 +249,9 @@ if the named section does not exist. .B \fB\-\-set\-section\-flags=\fIsection=flags Set the flags for the named section. The \fIflags\fP argument is a comma separated string of flag names. The recognized names are -\fIalloc\fP, \fIload\fP, \fIreadonly\fP, \fIcode\fP, \fIdata\fP, and -\fIrom\fP. Not all flags are meaningful for all object file -formats. +\fIalloc\fP, \fIcontents\fP, \fIload\fP, \fInoload\fP, \fIreadonly\fP, +\fIcode\fP, \fIdata\fP, \fIrom\fP, \fIshare\fP, and \fIdebug\fP. Not +all flags are meaningful for all object file formats. .TP .B \fB\-\-add\-section=\fIsectionname=filename Add a new section named \fIsectionname\fR while copying the file. The @@ -301,7 +308,7 @@ The GNU Binary Utilities\c \&, Roland H. Pesch (June 1993). .SH COPYING -Copyright (c) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. +Copyright (c) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. .PP Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 5fd7777..37b12e7 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -111,6 +111,7 @@ struct section_list const char * name; /* Section name. */ boolean used; /* Whether this entry was used. */ boolean remove; /* Whether to remove this section. */ + boolean copy; /* Whether to copy this section. */ enum change_action change_vma;/* Whether to change or set VMA. */ bfd_vma vma_val; /* Amount to change by or set to. */ enum change_action change_lma;/* Whether to change or set LMA. */ @@ -121,6 +122,7 @@ struct section_list static struct section_list *change_sections; static boolean sections_removed; +static boolean sections_copied; /* Changes to the start address. */ static bfd_vma change_start = 0; @@ -246,6 +248,7 @@ static struct option copy_options[] = {"debugging", no_argument, 0, OPTION_DEBUGGING}, {"discard-all", no_argument, 0, 'x'}, {"discard-locals", no_argument, 0, 'X'}, + {"only-section", required_argument, 0, 'j'}, {"format", required_argument, 0, 'F'}, /* Obsolete */ {"gap-fill", required_argument, 0, OPTION_GAP_FILL}, {"help", no_argument, 0, 'h'}, @@ -290,29 +293,52 @@ copy_usage (stream, exit_status) FILE *stream; int exit_status; { + fprintf (stream, _("Usage: %s in-file [out-file]\n"), program_name); + fprintf (stream, _(" The switches are:\n")); fprintf (stream, _("\ -Usage: %s [-vVSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-b byte]\n\ - [-R section] [-i interleave] [--interleave=interleave] [--byte=byte]\n\ - [--input-target=bfdname] [--output-target=bfdname] [--target=bfdname]\n\ - [--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n\ - [--discard-locals] [--debugging] [--remove-section=section]\n"), - program_name); - fprintf (stream, _("\ - [--gap-fill=val] [--pad-to=address] [--preserve-dates]\n\ - [--set-start=val] \n\ - [--change-start=incr] [--change-addresses=incr] \n\ - (--adjust-start and --adjust-vma are aliases for these two) \n\ - [--change-section-address=section{=,+,-}val]\n\ - (--adjust-section-vma is an alias for --change-section-address)\n\ - [--change-section-lma=section{=,+,-}val]\n\ - [--change-section-vma=section{=,+,-}val]\n\ - [--adjust-warnings] [--no-adjust-warnings]\n\ - [--change-warnings] [--no-change-warnings]\n\ - [--set-section-flags=section=flags] [--add-section=sectionname=filename]\n\ - [--keep-symbol symbol] [-K symbol] [--strip-symbol symbol] [-N symbol]\n\ - [--localize-symbol symbol] [-L symbol] [--weaken-symbol symbol]\n\ - [-W symbol] [--change-leading-char] [--remove-leading-char] [--weaken]\n\ - [--verbose] [--version] [--help] in-file [out-file]\n")); + -I --input-target Assume input file is in format \n\ + -O --output-target Create an output file in format \n\ + -F --target Set both input and output format to \n\ + --debugging Convert debugging information, if possible\n\ + -p --preserve-dates Copy modified/access timestamps to the output\n\ + -j --only-section Only copy section into the output\n\ + -R --remove-section Remove section from the output\n\ + -S --strip-all Remove all symbol and relocation information\n\ + -g --strip-debug Remove all debugging symbols\n\ + --strip-unneeded Remove all symbols not needed by relocations\n\ + -N --strip-symbol Do not copy symbol \n\ + -K --keep-symbol Only copy symbol \n\ + -L --localize-symbol Force symbol to be marked as a local\n\ + -W --weaken-symbol Force symbol to be marked as a weak\n\ + --weaken Force all global symbols to be marked as weak\n\ + -x --discard-all Remove all non-global symbols\n\ + -X --discard-locals Remove any compiler-generated symbols\n\ + -i --interleave Only copy one out of every bytes\n\ + -b --byte Select byte in every interleaved block\n\ + --gap-fill Fill gaps between sections with \n\ + --pad-to Pad the last section up to address \n\ + --set-start Set the start address to \n\ + {--change-start|--adjust-start} \n\ + Add to the start address\n\ + {--change-addresses|--adjust-vma} \n\ + Add to LMA, VMA and start addresses\n\ + {--change-section-address|--adjust-section-vma} {=|+|-}\n\ + Change LMA and VMA of section by \n\ + --change-section-lma {=|+|-}\n\ + Change the LMA of section by \n\ + --change-section-vma {=|+|-}\n\ + Change the VMA of section by \n\ + {--[no-]change-warnings|--[no-]adjust-warnings}\n\ + Warn if a named section does not exist\n\ + --set-section-flags =\n\ + Set section 's properties to \n\ + --add-section = Add section found in to output\n\ + --change-leading-char Force output format's leading character style\n\ + --remove-leading-char Remove leading character from global symbols\n\ + -v --verbose List all object files modified\n\ + -V --version Display this program's version number\n\ + -h --help Display this output\n\ +")); list_supported_targets (program_name, stream); if (exit_status == 0) fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n")); @@ -324,14 +350,27 @@ strip_usage (stream, exit_status) FILE *stream; int exit_status; { + fprintf (stream, _("Usage: %s in-file(s)\n"), program_name); + fprintf (stream, _(" The switches are:\n")); fprintf (stream, _("\ -Usage: %s [-vVsSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-R section]\n\ - [--input-target=bfdname] [--output-target=bfdname] [--target=bfdname]\n\ - [--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n\ - [--discard-locals] [--keep-symbol symbol] [-K symbol]\n\ - [--strip-symbol symbol] [-N symbol] [--remove-section=section]\n\ - [-o file] [--preserve-dates] [--verbose] [--version] [--help] file...\n"), - program_name); + -I --input-target Assume input file is in format \n\ + -O --output-target Create an output file in format \n\ + -F --target Set both input and output format to \n\ + -p --preserve-dates Copy modified/access timestamps to the output\n\ + -R --remove-section Remove section from the output\n\ + -s --strip-all Remove all symbol and relocation information\n\ + -g -S --strip-debug Remove all debugging symbols\n\ + --strip-unneeded Remove all symbols not needed by relocations\n\ + -N --strip-symbol Do not copy symbol \n\ + -K --keep-symbol Only copy symbol \n\ + -x --discard-all Remove all non-global symbols\n\ + -X --discard-locals Remove any compiler-generated symbols\n\ + -v --verbose List all object files modified\n\ + -V --version Display this program's version number\n\ + -h --help Display this output\n\ + -o Place stripped output into \n\ +")); + list_supported_targets (program_name, stream); if (exit_status == 0) fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n")); @@ -367,10 +406,13 @@ parse_flags (s) else if (strncasecmp (fname, s, len) == 0) ret |= fval PARSE_FLAG ("alloc", SEC_ALLOC); PARSE_FLAG ("load", SEC_LOAD); + PARSE_FLAG ("noload", SEC_NEVER_LOAD); PARSE_FLAG ("readonly", SEC_READONLY); + PARSE_FLAG ("debug", SEC_DEBUGGING); PARSE_FLAG ("code", SEC_CODE); PARSE_FLAG ("data", SEC_DATA); PARSE_FLAG ("rom", SEC_ROM); + PARSE_FLAG ("share", SEC_SHARED); PARSE_FLAG ("contents", SEC_HAS_CONTENTS); #undef PARSE_FLAG else @@ -381,7 +423,7 @@ parse_flags (s) strncpy (copy, s, len); copy[len] = '\0'; non_fatal (_("unrecognized section flag `%s'"), copy); - fatal (_("supported flags: alloc, load, readonly, code, data, rom, contents")); + fatal (_("supported flags: alloc, load, noload, readonly, debug, code, data, rom, share, contents")); } s = snext; @@ -411,6 +453,7 @@ find_section_list (name, add) p->name = name; p->used = false; p->remove = false; + p->copy = false; p->change_vma = CHANGE_IGNORE; p->change_lma = CHANGE_IGNORE; p->vma_val = 0; @@ -461,7 +504,7 @@ is_specified_symbol (name, list) static boolean is_strip_section (abfd, sec) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; { struct section_list *p; @@ -474,10 +517,15 @@ is_strip_section (abfd, sec) || convert_debugging)) return true; - if (! sections_removed) + if (! sections_removed && ! sections_copied) return false; + p = find_section_list (bfd_get_section_name (abfd, sec), false); - return p != NULL && p->remove ? true : false; + if (sections_removed && p != NULL && p->remove) + return true; + if (sections_copied && (p == NULL || ! p->copy)) + return true; + return false; } /* Choose which symbol entries to copy; put the result in OSYMS. @@ -594,7 +642,7 @@ filter_bytes (memhunk, size) for (; from < end; from += interleave) *to++ = *from; - if (*size % interleave > copy_byte) + if (*size % interleave > (bfd_size_type) copy_byte) *size = (*size / interleave) + 1; else *size /= interleave; @@ -816,6 +864,7 @@ copy_object (ibfd, obfd) || localize_specific_list != NULL || weaken_specific_list != NULL || sections_removed + || sections_copied || convert_debugging || change_leading_char || remove_leading_char @@ -962,6 +1011,16 @@ copy_archive (ibfd, obfd, output_target) (char *) NULL); bfd *output_bfd = bfd_openw (output_name, output_target); bfd *last_element; + struct stat buf; + int stat_status = 0; + + if (preserve_dates) + { + stat_status = bfd_stat_arch_elt (this_element, &buf); + if (stat_status != 0) + non_fatal (_("internal stat error on %s"), + bfd_get_filename (this_element)); + } l = (struct name_list *) xmalloc (sizeof (struct name_list)); l->name = output_name; @@ -984,6 +1043,9 @@ copy_archive (ibfd, obfd, output_target) status = 1; } + if (preserve_dates && stat_status == 0) + set_times (output_name, &buf); + /* Open the newly output file and attach to our list. */ output_bfd = bfd_openr (output_name, output_target); @@ -1114,7 +1176,9 @@ setup_section (ibfd, isection, obfdarg) if (p != NULL) p->used = true; - if (p != NULL && p->remove) + if (sections_removed && p != NULL && p->remove) + return; + if (sections_copied && (p == NULL || ! p->copy)) return; osection = bfd_make_section_anyway (obfd, bfd_section_name (ibfd, isection)); @@ -1243,7 +1307,9 @@ copy_section (ibfd, isection, obfdarg) p = find_section_list (bfd_section_name (ibfd, isection), false); - if (p != NULL && p->remove) + if (sections_removed && p != NULL && p->remove) + return; + if (sections_copied && (p == NULL || ! p->copy)) return; osection = isection->output_section; @@ -1331,7 +1397,7 @@ copy_section (ibfd, isection, obfdarg) static void get_sections (obfd, osection, secppparg) - bfd *obfd; + bfd *obfd ATTRIBUTE_UNUSED; asection *osection; PTR secppparg; { @@ -1438,8 +1504,8 @@ static boolean write_debugging_info (obfd, dhandle, symcountp, symppp) bfd *obfd; PTR dhandle; - long *symcountp; - asymbol ***symppp; + long *symcountp ATTRIBUTE_UNUSED; + asymbol ***symppp ATTRIBUTE_UNUSED; { if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour) return write_ieee_debugging_info (obfd, dhandle); @@ -1644,7 +1710,7 @@ copy_main (argc, argv) struct section_list *p; struct stat statbuf; - while ((c = getopt_long (argc, argv, "b:i:I:K:N:s:O:d:F:L:R:SpgxXVvW:", + while ((c = getopt_long (argc, argv, "b:i:I:j:K:N:s:O:d:F:L:R:SpgxXVvW:", copy_options, (int *) 0)) != EOF) { switch (c) @@ -1670,8 +1736,17 @@ copy_main (argc, argv) case 'F': input_target = output_target = optarg; break; + case 'j': + p = find_section_list (optarg, true); + if (p->remove) + fatal (_("%s both copied and removed"), optarg); + p->copy = true; + sections_copied = true; + break; case 'R': p = find_section_list (optarg, true); + if (p->copy) + fatal (_("%s both copied and removed"), optarg); p->remove = true; sections_removed = true; break; @@ -1769,15 +1844,21 @@ copy_main (argc, argv) const char *s; int len; char *name; - char *option; + char *option = NULL; bfd_vma val; - enum change_action what; + enum change_action what = CHANGE_IGNORE; switch (c) { - case OPTION_CHANGE_SECTION_ADDRESS: option = "--change-section-address"; break; - case OPTION_CHANGE_SECTION_LMA: option = "--change-section-lma"; break; - case OPTION_CHANGE_SECTION_VMA: option = "--change-section-vma"; break; + case OPTION_CHANGE_SECTION_ADDRESS: + option = "--change-section-address"; + break; + case OPTION_CHANGE_SECTION_LMA: + option = "--change-section-lma"; + break; + case OPTION_CHANGE_SECTION_VMA: + option = "--change-section-vma"; + break; } s = strchr (optarg, '='); diff --git a/binutils/objdump.c b/binutils/objdump.c index 3f9e8c4..488d4f3 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -44,6 +44,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ extern int fprintf PARAMS ((FILE *, const char *, ...)); #endif +/* Exit status. */ +static int exit_status = 0; + static char *default_target = NULL; /* default at runtime */ static int show_version = 0; /* show the version number */ @@ -72,6 +75,7 @@ static bfd_vma start_address = (bfd_vma) -1; /* --start-address */ static bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */ static int dump_debugging; /* --debugging */ static bfd_vma adjust_section_vma = 0; /* --adjust-vma */ +static int file_start_context = 0; /* --file-start-context */ /* Extra info to pass to the disassembler address printing function. */ struct objdump_disasm_info { @@ -83,6 +87,9 @@ struct objdump_disasm_info { /* Architecture to disassemble for, or default if NULL. */ static char *machine = (char *) NULL; +/* Target specific options to the disassembler. */ +static char *disassembler_options = (char *) NULL; + /* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */ static enum bfd_endian endian = BFD_ENDIAN_UNKNOWN; @@ -110,6 +117,9 @@ static void usage PARAMS ((FILE *, int)); static void +nonfatal PARAMS ((const char *)); + +static void display_file PARAMS ((char *filename, char *target)); static void @@ -216,22 +226,53 @@ usage (stream, status) FILE *stream; int status; { + fprintf (stream, _("Usage: %s file(s)\n"), program_name); + fprintf (stream, _(" At least one of the following switches must be given:\n")); fprintf (stream, _("\ -Usage: %s [-ahifCdDprRtTxsSlw] [-b bfdname] [-m machine] [-j section-name]\n\ - [--archive-headers] [--target=bfdname] [--debugging] [--disassemble]\n\ - [--disassemble-all] [--disassemble-zeroes] [--file-headers]\n\ - [--section-headers] [--headers]\n\ - [--info] [--section=section-name] [--line-numbers] [--source]\n"), - program_name); - fprintf (stream, _("\ - [--architecture=machine] [--reloc] [--full-contents] [--stabs]\n\ - [--syms] [--all-headers] [--dynamic-syms] [--dynamic-reloc]\n\ - [--wide] [--version] [--help] [--private-headers]\n\ - [--start-address=addr] [--stop-address=addr]\n\ - [--prefix-addresses] [--[no-]show-raw-insn] [--demangle]\n\ - [--adjust-vma=offset] [-EB|-EL] [--endian={big|little}] objfile...\n\ -at least one option besides -l (--line-numbers) must be given\n")); - list_supported_targets (program_name, stream); + -a --archive-headers Display archive header information\n\ + -f --file-headers Display the contents of the overall file header\n\ + -p --private-headers Display object format specific file header contents\n\ + -h --[section-]headers Display the contents of the section headers\n\ + -x --all-headers Display the contents of all headers\n\ + -d --disassemble Display assembler contents of executable sections\n\ + -D --disassemble-all Display assembler contents of all sections\n\ + -S --source Intermix source code with disassembly\n\ + -s --full-contents Display the full contents of all sections requested\n\ + -g --debugging Display debug information in object file\n\ + -G --stabs Display the STABS contents of an ELF format file\n\ + -t --syms Display the contents of the symbol table(s)\n\ + -T --dynamic-syms Display the contents of the dynamic symbol table\n\ + -r --reloc Display the relocation entries in the file\n\ + -R --dynamic-reloc Display the dynamic relocation entries in the file\n\ + -V --version Display this program's version number\n\ + -i --info List object formats and architectures supported\n\ + -H --help Display this information\n\ +")); + if (status != 2) + { + fprintf (stream, _("\n The following switches are optional:\n")); + fprintf (stream, _("\ + -b --target Specify the target object format as \n\ + -m --architecture Specify the target architecture as \n\ + -j --section Only display information for section \n\ + -M --disassembler-options Pass text on to the disassembler\n\ + -EB --endian=big Assume big endian format when disassembling\n\ + -EL --endian=little Assume little endian format when disassembling\n\ + --file-start-context Include context from start of file (with -S)\n\ + -l --line-numbers Include line numbers and filenames in output\n\ + -C --demangle Decode mangled/processed symbol names\n\ + -w --wide Format output for more than 80 columns\n\ + -z --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\ + --start-address Only process data whoes address is >= \n\ + --stop-address Only process data whoes address is <= \n\ + --prefix-addresses Print complete address alongside disassembly\n\ + --[no-]show-raw-insn Display hex alongside symbolic disassembly\n\ + --adjust-vma Add to all displayed section addresses\n\ +\n")); + list_supported_targets (program_name, stream); + + disassembler_usage (stream); + } if (status == 0) fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n")); exit (status); @@ -251,15 +292,17 @@ static struct option long_options[]= {"private-headers", no_argument, NULL, 'p'}, {"architecture", required_argument, NULL, 'm'}, {"archive-headers", no_argument, NULL, 'a'}, - {"debugging", no_argument, &dump_debugging, 1}, - {"demangle", no_argument, &do_demangle, 1}, + {"debugging", no_argument, NULL, 'g'}, + {"demangle", no_argument, NULL, 'C'}, {"disassemble", no_argument, NULL, 'd'}, {"disassemble-all", no_argument, NULL, 'D'}, - {"disassemble-zeroes", no_argument, &disassemble_zeroes, 1}, + {"disassembler-options", required_argument, NULL, 'M'}, + {"disassemble-zeroes", no_argument, NULL, 'z'}, {"dynamic-reloc", no_argument, NULL, 'R'}, {"dynamic-syms", no_argument, NULL, 'T'}, {"endian", required_argument, NULL, OPTION_ENDIAN}, {"file-headers", no_argument, NULL, 'f'}, + {"file-start-context", no_argument, &file_start_context, 1}, {"full-contents", no_argument, NULL, 's'}, {"headers", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'H'}, @@ -272,27 +315,36 @@ static struct option long_options[]= {"section-headers", no_argument, NULL, 'h'}, {"show-raw-insn", no_argument, &show_raw_insn, 1}, {"source", no_argument, NULL, 'S'}, - {"stabs", no_argument, &dump_stab_section_info, 1}, + {"stabs", no_argument, NULL, 'G'}, {"start-address", required_argument, NULL, OPTION_START_ADDRESS}, {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS}, {"syms", no_argument, NULL, 't'}, {"target", required_argument, NULL, 'b'}, - {"version", no_argument, &show_version, 1}, - {"wide", no_argument, &wide_output, 'w'}, + {"version", no_argument, NULL, 'V'}, + {"wide", no_argument, NULL, 'w'}, {0, no_argument, 0, 0} }; static void +nonfatal (msg) + const char *msg; +{ + bfd_nonfatal (msg); + exit_status = 1; +} + +static void dump_section_header (abfd, section, ignored) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *section; - PTR ignored; + PTR ignored ATTRIBUTE_UNUSED; { char *comma = ""; + unsigned int opb = bfd_octets_per_byte (abfd); printf ("%3d %-13s %08lx ", section->index, bfd_get_section_name (abfd, section), - (unsigned long) bfd_section_size (abfd, section)); + (unsigned long) bfd_section_size (abfd, section) / opb); printf_vma (bfd_get_section_vma (abfd, section)); printf (" "); printf_vma (section->lma); @@ -324,6 +376,8 @@ dump_section_header (abfd, section, ignored) PF (SEC_NEVER_LOAD, "NEVER_LOAD"); PF (SEC_EXCLUDE, "EXCLUDE"); PF (SEC_SORT_ENTRIES, "SORT_ENTRIES"); + PF (SEC_SMALL_DATA, "SMALL_DATA"); + PF (SEC_SHARED, "SHARED"); if ((section->flags & SEC_LINK_ONCE) != 0) { @@ -347,6 +401,11 @@ dump_section_header (abfd, section, ignored) break; } printf ("%s%s", comma, ls); + + if (section->comdat != NULL) + printf (" (COMDAT %s %ld)", section->comdat->name, + section->comdat->symbol); + comma = ", "; } @@ -359,11 +418,17 @@ dump_headers (abfd) bfd *abfd; { printf (_("Sections:\n")); + #ifndef BFD64 - printf (_("Idx Name Size VMA LMA File off Algn\n")); + printf (_("Idx Name Size VMA LMA File off Algn")); #else - printf (_("Idx Name Size VMA LMA File off Algn\n")); + printf (_("Idx Name Size VMA LMA File off Algn")); #endif + + if (wide_output) + printf (_(" Flags")); + printf ("\n"); + bfd_map_over_sections (abfd, dump_section_header, (PTR) NULL); } @@ -678,6 +743,7 @@ find_symbol_for_address (abfd, sec, vma, require_sec, place) long min = 0; long max = sorted_symcount; long thisplace; + unsigned int opb = bfd_octets_per_byte (abfd); if (sorted_symcount < 1) return NULL; @@ -725,7 +791,7 @@ find_symbol_for_address (abfd, sec, vma, require_sec, place) || ((abfd->flags & HAS_RELOC) != 0 && vma >= bfd_get_section_vma (abfd, sec) && vma < (bfd_get_section_vma (abfd, sec) - + bfd_section_size (abfd, sec))))) + + bfd_section_size (abfd, sec) / opb)))) { long i; @@ -949,10 +1015,10 @@ skip_to_line (p, line, show) listing. */ static void -show_line (abfd, section, off) +show_line (abfd, section, addr_offset) bfd *abfd; asection *section; - bfd_vma off; + bfd_vma addr_offset; { CONST char *filename; CONST char *functionname; @@ -961,7 +1027,7 @@ show_line (abfd, section, off) if (! with_line_numbers && ! with_source_code) return; - if (! bfd_find_nearest_line (abfd, section, syms, off, &filename, + if (! bfd_find_nearest_line (abfd, section, syms, addr_offset, &filename, &functionname, &line)) return; @@ -1013,8 +1079,8 @@ show_line (abfd, section, off) else { l = line - SHOW_PRECEDING_CONTEXT_LINES; - if (l <= 0) - l = 1; + if (l < 0) + l = 0; } if (p->f == NULL) @@ -1064,9 +1130,12 @@ show_line (abfd, section, off) p->next = print_files; print_files = p; - l = line - SHOW_PRECEDING_CONTEXT_LINES; - if (l <= 0) - l = 1; + if (file_start_context) + l = 0; + else + l = line - SHOW_PRECEDING_CONTEXT_LINES; + if (l < 0) + l = 0; skip_to_line (p, l, false); if (p->f != NULL) skip_to_line (p, line, true); @@ -1134,7 +1203,7 @@ objdump_sprintf (va_alist) n = strlen (buf); - while ((f->buffer + f->size) - f->current < n + 1) + while ((size_t) ((f->buffer + f->size) - f->current) < n + 1) { size_t curroff; @@ -1170,31 +1239,33 @@ objdump_sprintf (va_alist) /* Disassemble some data in memory between given values. */ static void -disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, +disassemble_bytes (info, disassemble_fn, insns, data, + start_offset, stop_offset, relppp, relppend) struct disassemble_info *info; disassembler_ftype disassemble_fn; boolean insns; bfd_byte *data; - bfd_vma start; - bfd_vma stop; + bfd_vma start_offset; + bfd_vma stop_offset; arelent ***relppp; arelent **relppend; { struct objdump_disasm_info *aux; asection *section; - int bytes_per_line; + int octets_per_line; boolean done_dot; int skip_addr_chars; - bfd_vma i; + bfd_vma addr_offset; + int opb = info->octets_per_byte; aux = (struct objdump_disasm_info *) info->application_data; section = aux->sec; if (insns) - bytes_per_line = 4; + octets_per_line = 4; else - bytes_per_line = 16; + octets_per_line = 16; /* Figure out how many characters to skip at the start of an address, to make the disassembly look nicer. We discard leading @@ -1206,8 +1277,8 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, char buf[30]; char *s; - sprintf_vma (buf, - section->vma + bfd_section_size (section->owner, section)); + sprintf_vma (buf, section->vma + + bfd_section_size (section->owner, section) / opb); s = buf; while (s[0] == '0' && s[1] == '0' && s[2] == '0' && s[3] == '0' && s[4] == '0') @@ -1220,34 +1291,35 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, info->insn_info_valid = 0; done_dot = false; - i = start; - while (i < stop) + addr_offset = start_offset; + while (addr_offset < stop_offset) { bfd_vma z; - int bytes = 0; + int octets = 0; boolean need_nl = false; - /* If we see more than SKIP_ZEROES bytes of zeroes, we just + /* If we see more than SKIP_ZEROES octets of zeroes, we just print `...'. */ - for (z = i; z < stop; z++) + for (z = addr_offset * opb; z < stop_offset * opb; z++) if (data[z] != 0) break; if (! disassemble_zeroes && (info->insn_info_valid == 0 || info->branch_delay_insns == 0) - && (z - i >= SKIP_ZEROES - || (z == stop && z - i < SKIP_ZEROES_AT_END))) + && (z - addr_offset * opb >= SKIP_ZEROES + || (z == stop_offset * opb && + z - addr_offset * opb < SKIP_ZEROES_AT_END))) { printf ("\t...\n"); - /* If there are more nonzero bytes to follow, we only skip + /* If there are more nonzero octets to follow, we only skip zeroes in multiples of 4, to try to avoid running over the start of an instruction which happens to start with zero. */ - if (z != stop) - z = i + ((z - i) &~ 3); + if (z != stop_offset * opb) + z = addr_offset * opb + ((z - addr_offset * opb) &~ 3); - bytes = z - i; + octets = z - addr_offset * opb; } else { @@ -1259,13 +1331,13 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, done_dot = false; if (with_line_numbers || with_source_code) - show_line (aux->abfd, section, i); + show_line (aux->abfd, section, addr_offset); if (! prefix_addresses) { char *s; - sprintf_vma (buf, section->vma + i); + sprintf_vma (buf, section->vma + addr_offset); for (s = buf + skip_addr_chars; *s == '0'; s++) *s = ' '; if (*s == '\0') @@ -1275,7 +1347,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, else { aux->require_sec = true; - objdump_print_address (section->vma + i, info); + objdump_print_address (section->vma + addr_offset, info); aux->require_sec = false; putchar (' '); } @@ -1290,59 +1362,64 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, info->bytes_per_line = 0; info->bytes_per_chunk = 0; - /* FIXME: This is wrong. It tests the number of bytes + /* FIXME: This is wrong. It tests the number of octets in the last instruction, not the current one. */ if (*relppp < relppend - && (**relppp)->address >= i - && (**relppp)->address < i + bytes) + && (**relppp)->address >= addr_offset + && (**relppp)->address < addr_offset + octets / opb) info->flags = INSN_HAS_RELOC; else info->flags = 0; - bytes = (*disassemble_fn) (section->vma + i, info); + octets = (*disassemble_fn) (section->vma + addr_offset, info); info->fprintf_func = (fprintf_ftype) fprintf; info->stream = stdout; if (info->bytes_per_line != 0) - bytes_per_line = info->bytes_per_line; - if (bytes < 0) - break; + octets_per_line = info->bytes_per_line; + if (octets < 0) + { + if (sfile.current != sfile.buffer) + printf ("%s\n", sfile.buffer); + free (sfile.buffer); + break; + } } else { - long j; + bfd_vma j; - bytes = bytes_per_line; - if (i + bytes > stop) - bytes = stop - i; + octets = octets_per_line; + if (addr_offset + octets / opb > stop_offset) + octets = (stop_offset - addr_offset) * opb; - for (j = i; j < i + bytes; ++j) + for (j = addr_offset * opb; j < addr_offset * opb + octets; ++j) { if (isprint (data[j])) - buf[j - i] = data[j]; + buf[j - addr_offset * opb] = data[j]; else - buf[j - i] = '.'; + buf[j - addr_offset * opb] = '.'; } - buf[j - i] = '\0'; + buf[j - addr_offset * opb] = '\0'; } if (prefix_addresses ? show_raw_insn > 0 : show_raw_insn >= 0) { - long j; + bfd_vma j; /* If ! prefix_addresses and ! wide_output, we print - bytes_per_line bytes per line. */ - pb = bytes; - if (pb > bytes_per_line && ! prefix_addresses && ! wide_output) - pb = bytes_per_line; + octets_per_line octets per line. */ + pb = octets; + if (pb > octets_per_line && ! prefix_addresses && ! wide_output) + pb = octets_per_line; if (info->bytes_per_chunk) bpc = info->bytes_per_chunk; else bpc = 1; - for (j = i; j < i + pb; j += bpc) + for (j = addr_offset * opb; j < addr_offset * opb + pb; j += bpc) { int k; if (bpc > 1 && info->display_endian == BFD_ENDIAN_LITTLE) @@ -1359,7 +1436,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, } } - for (; pb < bytes_per_line; pb += bpc) + for (; pb < octets_per_line; pb += bpc) { int k; @@ -1387,25 +1464,25 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, ? show_raw_insn > 0 : show_raw_insn >= 0) { - while (pb < bytes) + while (pb < octets) { - long j; + bfd_vma j; char *s; putchar ('\n'); - j = i + pb; + j = addr_offset * opb + pb; - sprintf_vma (buf, section->vma + j); + sprintf_vma (buf, section->vma + j / opb); for (s = buf + skip_addr_chars; *s == '0'; s++) *s = ' '; if (*s == '\0') *--s = '0'; printf ("%s:\t", buf + skip_addr_chars); - pb += bytes_per_line; - if (pb > bytes) - pb = bytes; - for (; j < i + pb; j += bpc) + pb += octets_per_line; + if (pb > octets) + pb = octets; + for (; j < addr_offset * opb + pb; j += bpc) { int k; @@ -1435,8 +1512,8 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, && (section->flags & SEC_RELOC) != 0) { while ((*relppp) < relppend - && ((**relppp)->address >= (bfd_vma) i - && (**relppp)->address < (bfd_vma) i + bytes)) + && ((**relppp)->address >= (bfd_vma) addr_offset + && (**relppp)->address < (bfd_vma) addr_offset + octets / opb)) { arelent *q; @@ -1487,7 +1564,7 @@ disassemble_bytes (info, disassemble_fn, insns, data, start, stop, relppp, if (need_nl) printf ("\n"); - i += bytes; + addr_offset += octets / opb; } } @@ -1497,11 +1574,12 @@ static void disassemble_data (abfd) bfd *abfd; { - long i; + unsigned long addr_offset; disassembler_ftype disassemble_fn; struct disassemble_info disasm_info; struct objdump_disasm_info aux; asection *section; + unsigned int opb = bfd_octets_per_byte (abfd); print_files = NULL; prev_functionname = NULL; @@ -1523,6 +1601,7 @@ disassemble_data (abfd) aux.require_sec = false; disasm_info.print_address_func = objdump_print_address; disasm_info.symbol_at_address_func = objdump_symbol_at_address; + disasm_info.octets_per_byte = opb; if (machine != (char *) NULL) { @@ -1553,16 +1632,19 @@ disassemble_data (abfd) fprintf (stderr, _("%s: Can't disassemble for architecture %s\n"), program_name, bfd_printable_arch_mach (bfd_get_arch (abfd), 0)); + exit_status = 1; return; } disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); + disasm_info.disassembler_options = disassembler_options; + if (bfd_big_endian (abfd)) - disasm_info.endian = BFD_ENDIAN_BIG; + disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG; else if (bfd_little_endian (abfd)) - disasm_info.endian = BFD_ENDIAN_LITTLE; + disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_LITTLE; else /* ??? Aborting here seems too drastic. We could default to big or little instead. */ @@ -1577,7 +1659,7 @@ disassemble_data (abfd) arelent **relbuf = NULL; arelent **relpp = NULL; arelent **relppend = NULL; - long stop; + unsigned long stop_offset; asymbol *sym = NULL; long place = 0; @@ -1640,37 +1722,37 @@ disassemble_data (abfd) disasm_info.buffer_length = datasize; if (start_address == (bfd_vma) -1 || start_address < disasm_info.buffer_vma) - i = 0; + addr_offset = 0; else - i = start_address - disasm_info.buffer_vma; + addr_offset = start_address - disasm_info.buffer_vma; if (stop_address == (bfd_vma) -1) - stop = datasize; + stop_offset = datasize / opb; else { if (stop_address < disasm_info.buffer_vma) - stop = 0; + stop_offset = 0; else - stop = stop_address - disasm_info.buffer_vma; - if (stop > disasm_info.buffer_length) - stop = disasm_info.buffer_length; + stop_offset = stop_address - disasm_info.buffer_vma; + if (stop_offset > disasm_info.buffer_length / opb) + stop_offset = disasm_info.buffer_length / opb; } - sym = find_symbol_for_address (abfd, section, section->vma + i, + sym = find_symbol_for_address (abfd, section, section->vma + addr_offset, true, &place); - while (i < stop) + while (addr_offset < stop_offset) { asymbol *nextsym; - long nextstop; + unsigned long nextstop_offset; boolean insns; - if (sym != NULL && bfd_asymbol_value (sym) <= section->vma + i) + if (sym != NULL && bfd_asymbol_value (sym) <= section->vma + addr_offset) { int x; for (x = place; (x < sorted_symcount - && bfd_asymbol_value (sorted_syms[x]) <= section->vma + i); + && bfd_asymbol_value (sorted_syms[x]) <= section->vma + addr_offset); ++x) continue; disasm_info.symbols = & sorted_syms[place]; @@ -1683,20 +1765,23 @@ disassemble_data (abfd) { printf ("\n"); objdump_print_addr_with_sym (abfd, section, sym, - section->vma + i, + section->vma + addr_offset, &disasm_info, false); printf (":\n"); } - if (sym != NULL && bfd_asymbol_value (sym) > section->vma + i) + if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset) nextsym = sym; else if (sym == NULL) nextsym = NULL; else { + /* Search forward for the next appropriate symbol in + SECTION. Note that all the symbols are sorted + together into one big array, and that some sections + may have overlapping addresses. */ while (place < sorted_symcount - /* ??? Why the test for != section? */ && (sorted_syms[place]->section != section || (bfd_asymbol_value (sorted_syms[place]) <= bfd_asymbol_value (sym)))) @@ -1707,19 +1792,19 @@ disassemble_data (abfd) nextsym = sorted_syms[place]; } - if (sym != NULL && bfd_asymbol_value (sym) > section->vma + i) + if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset) { - nextstop = bfd_asymbol_value (sym) - section->vma; - if (nextstop > stop) - nextstop = stop; + nextstop_offset = bfd_asymbol_value (sym) - section->vma; + if (nextstop_offset > stop_offset) + nextstop_offset = stop_offset; } else if (nextsym == NULL) - nextstop = stop; + nextstop_offset = stop_offset; else { - nextstop = bfd_asymbol_value (nextsym) - section->vma; - if (nextstop > stop) - nextstop = stop; + nextstop_offset = bfd_asymbol_value (nextsym) - section->vma; + if (nextstop_offset > stop_offset) + nextstop_offset = stop_offset; } /* If a symbol is explicitly marked as being an object @@ -1727,7 +1812,7 @@ disassemble_data (abfd) disassembling them. */ if (disassemble_all || sym == NULL - || bfd_asymbol_value (sym) > section->vma + i + || bfd_asymbol_value (sym) > section->vma + addr_offset || ((sym->flags & BSF_OBJECT) == 0 && (strstr (bfd_asymbol_name (sym), "gnu_compiled") == NULL) @@ -1738,10 +1823,10 @@ disassemble_data (abfd) else insns = false; - disassemble_bytes (&disasm_info, disassemble_fn, insns, data, i, - nextstop, &relpp, relppend); + disassemble_bytes (&disasm_info, disassemble_fn, insns, data, + addr_offset, nextstop_offset, &relpp, relppend); - i = nextstop; + addr_offset = nextstop_offset; sym = nextsym; } @@ -1804,6 +1889,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name) { fprintf (stderr, _("%s: %s has no %s section\n"), program_name, bfd_get_filename (abfd), strsect_name); + exit_status = 1; return false; } @@ -1820,6 +1906,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name) bfd_errmsg (bfd_get_error ())); free (stabs); free (strtab); + exit_status = 1; return false; } @@ -1831,6 +1918,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name) bfd_errmsg (bfd_get_error ())); free (stabs); free (strtab); + exit_status = 1; return false; } @@ -1859,7 +1947,7 @@ static void print_section_stabs (abfd, stabsect_name, strsect_name) bfd *abfd; const char *stabsect_name; - const char *strsect_name; + const char *strsect_name ATTRIBUTE_UNUSED; { int i; unsigned file_string_table_offset = 0, next_file_string_table_offset = 0; @@ -1996,23 +2084,12 @@ bfd *abfd; bfd_print_private_bfd_data (abfd, stdout); } +/* Dump selected contents of ABFD */ + static void -display_bfd (abfd) +dump_bfd (abfd) bfd *abfd; { - char **matching; - - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) - { - bfd_nonfatal (bfd_get_filename (abfd)); - if (bfd_get_error () == bfd_error_file_ambiguously_recognized) - { - list_matching_formats (matching); - free (matching); - } - return; - } - /* If we are adjusting section VMA's, change them all now. Changing the BFD information is a hack. However, we must do it, or bfd_find_nearest_line will not do the right thing. */ @@ -2068,8 +2145,12 @@ display_bfd (abfd) if (dhandle != NULL) { if (! print_debugging_info (stdout, dhandle)) - fprintf (stderr, _("%s: printing debugging information failed\n"), - bfd_get_filename (abfd)); + { + fprintf (stderr, + _("%s: printing debugging information failed\n"), + bfd_get_filename (abfd)); + exit_status = 1; + } } } if (syms) @@ -2085,6 +2166,47 @@ display_bfd (abfd) } static void +display_bfd (abfd) + bfd *abfd; +{ + char **matching; + + if (bfd_check_format_matches (abfd, bfd_object, &matching)) + { + dump_bfd (abfd); + return; + } + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + nonfatal (bfd_get_filename (abfd)); + list_matching_formats (matching); + free (matching); + return; + } + + if (bfd_get_error () != bfd_error_file_not_recognized) + { + nonfatal (bfd_get_filename (abfd)); + return; + } + + if (bfd_check_format_matches (abfd, bfd_core, &matching)) + { + dump_bfd (abfd); + return; + } + + nonfatal (bfd_get_filename (abfd)); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); + } +} + +static void display_file (filename, target) char *filename; char *target; @@ -2094,7 +2216,7 @@ display_file (filename, target) file = bfd_openr (filename, target); if (file == NULL) { - bfd_nonfatal (filename); + nonfatal (filename); return; } @@ -2111,9 +2233,7 @@ display_file (filename, target) if (arfile == NULL) { if (bfd_get_error () != bfd_error_no_more_archived_files) - { - bfd_nonfatal (bfd_get_filename (file)); - } + nonfatal (bfd_get_filename (file)); break; } @@ -2142,8 +2262,9 @@ dump_data (abfd) asection *section; bfd_byte *data = 0; bfd_size_type datasize = 0; - bfd_size_type i; - bfd_size_type start, stop; + bfd_size_type addr_offset; + bfd_size_type start_offset, stop_offset; + unsigned int opb = bfd_octets_per_byte (abfd); for (section = abfd->sections; section != NULL; section = section->next) @@ -2167,28 +2288,31 @@ dump_data (abfd) if (start_address == (bfd_vma) -1 || start_address < section->vma) - start = 0; + start_offset = 0; else - start = start_address - section->vma; + start_offset = start_address - section->vma; if (stop_address == (bfd_vma) -1) - stop = bfd_section_size (abfd, section); + stop_offset = bfd_section_size (abfd, section) / opb; else { if (stop_address < section->vma) - stop = 0; + stop_offset = 0; else - stop = stop_address - section->vma; - if (stop > bfd_section_size (abfd, section)) - stop = bfd_section_size (abfd, section); + stop_offset = stop_address - section->vma; + if (stop_offset > bfd_section_size (abfd, section) / opb) + stop_offset = bfd_section_size (abfd, section) / opb; } - for (i = start; i < stop; i += onaline) + for (addr_offset = start_offset; + addr_offset < stop_offset; addr_offset += onaline) { bfd_size_type j; - printf (" %04lx ", (unsigned long int) (i + section->vma)); - for (j = i; j < i + onaline; j++) + printf (" %04lx ", (unsigned long int) + (addr_offset + section->vma)); + for (j = addr_offset * opb; + j < addr_offset * opb + onaline; j++) { - if (j < stop) + if (j < stop_offset * opb) printf ("%02x", (unsigned) (data[j])); else printf (" "); @@ -2197,9 +2321,9 @@ dump_data (abfd) } printf (" "); - for (j = i; j < i + onaline; j++) + for (j = addr_offset; j < addr_offset * opb + onaline; j++) { - if (j >= stop) + if (j >= stop_offset * opb) printf (" "); else printf ("%c", isprint (data[j]) ? data[j] : '.'); @@ -2215,7 +2339,7 @@ dump_data (abfd) /* Should perhaps share code and display with nm? */ static void dump_symbols (abfd, dynamic) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; boolean dynamic; { asymbol **current; @@ -2468,7 +2592,10 @@ dump_reloc_set (abfd, sec, relpp, relcount) if (sym_name) { printf_vma (q->address); - printf (" %-16s ", q->howto->name); + if (q->howto->name) + printf (" %-16s ", q->howto->name); + else + printf (" %-16d ", q->howto->type); objdump_print_symname (abfd, (struct disassemble_info *) NULL, *q->sym_ptr_ptr); } @@ -2528,14 +2655,14 @@ display_target_list () if (abfd == NULL) { - bfd_nonfatal (dummy_name); + nonfatal (dummy_name); continue; } if (! bfd_set_format (abfd, bfd_object)) { if (bfd_get_error () != bfd_error_invalid_operation) - bfd_nonfatal (p->name); + nonfatal (p->name); continue; } @@ -2581,7 +2708,7 @@ display_info_table (first, last) if (abfd == NULL) { - bfd_nonfatal (p->name); + nonfatal (p->name); ok = false; } @@ -2590,7 +2717,7 @@ display_info_table (first, last) if (! bfd_set_format (abfd, bfd_object)) { if (bfd_get_error () != bfd_error_invalid_operation) - bfd_nonfatal (p->name); + nonfatal (p->name); ok = false; } } @@ -2686,12 +2813,10 @@ main (argc, argv) bfd_init (); set_default_bfd_target (); - while ((c = getopt_long (argc, argv, "pib:m:VCdDlfahrRtTxsSj:wE:", + while ((c = getopt_long (argc, argv, "pib:m:M:VCdDlfahHrRtTxsSj:wE:zgG", long_options, (int *) 0)) != EOF) { - if (c != 'l' && c != OPTION_START_ADDRESS && c != OPTION_STOP_ADDRESS) - seenflag = true; switch (c) { case 0: @@ -2699,106 +2824,140 @@ main (argc, argv) case 'm': machine = optarg; break; + case 'M': + disassembler_options = optarg; + break; case 'j': only = optarg; break; case 'l': - with_line_numbers = 1; + with_line_numbers = true; break; case 'b': target = optarg; break; + case 'C': + do_demangle = true; + break; + case 'w': + wide_output = true; + break; + case OPTION_ADJUST_VMA: + adjust_section_vma = parse_vma (optarg, "--adjust-vma"); + break; + case OPTION_START_ADDRESS: + start_address = parse_vma (optarg, "--start-address"); + break; + case OPTION_STOP_ADDRESS: + stop_address = parse_vma (optarg, "--stop-address"); + break; + case 'E': + if (strcmp (optarg, "B") == 0) + endian = BFD_ENDIAN_BIG; + else if (strcmp (optarg, "L") == 0) + endian = BFD_ENDIAN_LITTLE; + else + { + fprintf (stderr, _("%s: unrecognized -E option\n"), + program_name); + usage (stderr, 1); + } + break; + case OPTION_ENDIAN: + if (strncmp (optarg, "big", strlen (optarg)) == 0) + endian = BFD_ENDIAN_BIG; + else if (strncmp (optarg, "little", strlen (optarg)) == 0) + endian = BFD_ENDIAN_LITTLE; + else + { + fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"), + program_name, optarg); + usage (stderr, 1); + } + break; + case 'f': dump_file_header = true; + seenflag = true; break; case 'i': formats_info = true; + seenflag = true; break; case 'p': - dump_private_headers = 1; + dump_private_headers = true; + seenflag = true; break; case 'x': - dump_private_headers = 1; - dump_symtab = 1; - dump_reloc_info = 1; + dump_private_headers = true; + dump_symtab = true; + dump_reloc_info = true; dump_file_header = true; - dump_ar_hdrs = 1; - dump_section_headers = 1; + dump_ar_hdrs = true; + dump_section_headers = true; + seenflag = true; break; case 't': - dump_symtab = 1; + dump_symtab = true; + seenflag = true; break; case 'T': - dump_dynamic_symtab = 1; - break; - case 'C': - do_demangle = 1; + dump_dynamic_symtab = true; + seenflag = true; break; case 'd': disassemble = true; + seenflag = true; + break; + case 'z': + disassemble_zeroes = true; break; case 'D': - disassemble = disassemble_all = true; + disassemble = true; + disassemble_all = true; + seenflag = true; break; case 'S': disassemble = true; with_source_code = true; + seenflag = true; + break; + case 'g': + dump_debugging = 1; + seenflag = true; + break; + case 'G': + dump_stab_section_info = true; + seenflag = true; break; case 's': - dump_section_contents = 1; + dump_section_contents = true; + seenflag = true; break; case 'r': - dump_reloc_info = 1; + dump_reloc_info = true; + seenflag = true; break; case 'R': - dump_dynamic_reloc_info = 1; + dump_dynamic_reloc_info = true; + seenflag = true; break; case 'a': - dump_ar_hdrs = 1; + dump_ar_hdrs = true; + seenflag = true; break; case 'h': - dump_section_headers = 1; + dump_section_headers = true; + seenflag = true; break; case 'H': usage (stdout, 0); + seenflag = true; case 'V': - show_version = 1; - break; - case 'w': - wide_output = 1; - break; - case OPTION_ADJUST_VMA: - adjust_section_vma = parse_vma (optarg, "--adjust-vma"); - break; - case OPTION_START_ADDRESS: - start_address = parse_vma (optarg, "--start-address"); - break; - case OPTION_STOP_ADDRESS: - stop_address = parse_vma (optarg, "--stop-address"); - break; - case 'E': - if (strcmp (optarg, "B") == 0) - endian = BFD_ENDIAN_BIG; - else if (strcmp (optarg, "L") == 0) - endian = BFD_ENDIAN_LITTLE; - else - { - fprintf (stderr, _("%s: unrecognized -E option\n"), program_name); - usage (stderr, 1); - } - break; - case OPTION_ENDIAN: - if (strncmp (optarg, "big", strlen (optarg)) == 0) - endian = BFD_ENDIAN_BIG; - else if (strncmp (optarg, "little", strlen (optarg)) == 0) - endian = BFD_ENDIAN_LITTLE; - else - { - fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"), - program_name, optarg); - usage (stderr, 1); - } + show_version = true; + seenflag = true; break; + default: usage (stderr, 1); } @@ -2808,12 +2967,10 @@ main (argc, argv) print_version ("objdump"); if (seenflag == false) - usage (stderr, 1); + usage (stderr, 2); if (formats_info) - { - display_info (); - } + display_info (); else { if (optind == argc) @@ -2825,5 +2982,5 @@ main (argc, argv) END_PROGRESS (program_name); - return 0; + return exit_status; } diff --git a/binutils/po/POTFILES.in b/binutils/po/POTFILES.in index 47f3860..a3a0586 100644 --- a/binutils/po/POTFILES.in +++ b/binutils/po/POTFILES.in @@ -1,4 +1,3 @@ -readelf.c addr2line.c ar.c arsup.c @@ -10,6 +9,7 @@ coffdump.c coffgrok.c coffgrok.h debug.c +debug.c debug.h dlltool.c dlltool.h @@ -18,6 +18,7 @@ dyn-string.c dyn-string.h filemode.c ieee.c +ieee.c is-ranlib.c is-strip.c maybe-ranlib.c @@ -31,7 +32,10 @@ objcopy.c objdump.c prdbg.c rdcoff.c +rdcoff.c rddbg.c +rddbg.c +readelf.c rename.c resbin.c rescoff.c @@ -40,6 +44,7 @@ resres.c size.c srconv.c stabs.c +stabs.c strings.c sysdump.c version.c @@ -48,5 +53,3 @@ windres.h winduni.c winduni.h wrstabs.c -testsuite/binutils-all/readelf.h -testsuite/binutils-all/testprog.c diff --git a/binutils/po/binutils.pot b/binutils/po/binutils.pot index beeb383..42b808e 100644 --- a/binutils/po/binutils.pot +++ b/binutils/po/binutils.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-04-26 10:11-0600\n" +"POT-Creation-Date: 2000-02-25 22:16-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -22,8 +22,8 @@ msgid "" " [--basenames] [--functions] [addr addr ...]\n" msgstr "" -#: addr2line.c:83 ar.c:255 nlmconv.c:1141 nm.c:304 objcopy.c:318 objcopy.c:337 -#: objdump.c:236 readelf.c:1133 size.c:89 strings.c:512 windres.c:723 +#: addr2line.c:83 ar.c:286 nlmconv.c:1141 nm.c:304 objcopy.c:344 objcopy.c:376 +#: objdump.c:277 readelf.c:1697 size.c:89 strings.c:512 windres.c:737 msgid "Report bugs to bug-gnu-utils@gnu.org\n" msgstr "" @@ -32,231 +32,240 @@ msgstr "" msgid "%s: can not get addresses from archive" msgstr "" -#: ar.c:207 +#: ar.c:235 #, c-format msgid "no entry %s in archive\n" msgstr "" -#: ar.c:224 +#: ar.c:252 #, c-format msgid "" -"Usage: %s [-]{dmpqrstx}[abcilosSuvV] [member-name] archive-file file...\n" +"Usage: %s [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file " +"file...\n" msgstr "" -#: ar.c:226 +#: ar.c:255 #, c-format msgid " %s -M [\n" -"\n" +msgid "internal stat error on %s" msgstr "" -#: ar.c:751 ar.c:819 +#: ar.c:810 ar.c:878 #, c-format msgid "%s is not a valid archive" msgstr "" -#: ar.c:787 +#: ar.c:846 #, c-format msgid "stat returns negative size for %s" msgstr "" -#: ar.c:908 +#: ar.c:967 #, c-format msgid "%s is not an archive" msgstr "" -#: ar.c:915 +#: ar.c:974 #, c-format msgid "%s: creating %s\n" msgstr "" -#: ar.c:1110 +#: ar.c:1181 #, c-format msgid "No member named `%s'\n" msgstr "" -#: ar.c:1162 +#: ar.c:1233 #, c-format msgid "%s: no entry %s in archive %s!\n" msgstr "" -#: ar.c:1322 +#: ar.c:1395 #, c-format msgid "%s: no archive map to update" msgstr "" -#: arsup.c:86 +#: arsup.c:87 #, c-format msgid "No entry %s in archive.\n" msgstr "" -#: arsup.c:118 +#: arsup.c:119 #, c-format msgid "Can't open file %s\n" msgstr "" -#: arsup.c:166 +#: arsup.c:167 #, c-format msgid "%s: Can't open output archive %s\n" msgstr "" -#: arsup.c:178 +#: arsup.c:179 #, c-format msgid "%s: Can't open input archive %s\n" msgstr "" -#: arsup.c:184 +#: arsup.c:185 #, c-format msgid "%s: file %s is not an archive\n" msgstr "" -#: arsup.c:225 +#: arsup.c:226 #, c-format msgid "%s: no output archive specified yet\n" msgstr "" -#: arsup.c:245 arsup.c:280 arsup.c:316 arsup.c:336 arsup.c:394 +#: arsup.c:246 arsup.c:281 arsup.c:317 arsup.c:337 arsup.c:395 #, c-format msgid "%s: no open output archive\n" msgstr "" -#: arsup.c:253 arsup.c:354 arsup.c:374 +#: arsup.c:254 arsup.c:355 arsup.c:375 #, c-format msgid "%s: can't open file %s\n" msgstr "" -#: arsup.c:301 arsup.c:370 arsup.c:449 +#: arsup.c:302 arsup.c:371 arsup.c:450 #, c-format msgid "%s: can't find module file %s\n" msgstr "" -#: arsup.c:401 +#: arsup.c:402 #, c-format msgid "Current open archive is %s\n" msgstr "" -#: arsup.c:428 +#: arsup.c:429 #, c-format msgid "%s: no open archive\n" msgstr "" @@ -398,294 +407,338 @@ msgstr "" msgid "debug_get_real_type: circular debug information for %s\n" msgstr "" -#: debug.c:2663 +#: debug.c:2662 msgid "debug_write_type: illegal type encountered" msgstr "" -#: dlltool.c:627 dlltool.c:646 dlltool.c:666 +#: dlltool.c:770 dlltool.c:794 dlltool.c:819 #, c-format msgid "Internal error: Unknown machine type: %d\n" msgstr "" -#: dlltool.c:700 +#: dlltool.c:856 #, c-format msgid "Can't open def file: %s" msgstr "" -#: dlltool.c:705 +#: dlltool.c:861 #, c-format msgid "Processing def file: %s" msgstr "" -#: dlltool.c:709 +#: dlltool.c:865 msgid "Processed def file" msgstr "" -#: dlltool.c:734 +#: dlltool.c:890 #, c-format msgid "Syntax error in def file %s:%d\n" msgstr "" -#: dlltool.c:767 +#: dlltool.c:923 #, c-format msgid "NAME: %s base: %x" msgstr "" -#: dlltool.c:770 +#: dlltool.c:926 msgid "Can't have LIBRARY and NAME\n" msgstr "" -#: dlltool.c:786 +#: dlltool.c:942 #, c-format msgid "LIBRARY: %s base: %x" msgstr "" -#: dlltool.c:789 +#: dlltool.c:945 #, c-format msgid "%s: Can't have LIBRARY and NAME\n" msgstr "" -#: dlltool.c:1044 +#: dlltool.c:1200 resrc.c:271 #, c-format msgid "wait: %s" msgstr "" -#: dlltool.c:1049 +#: dlltool.c:1205 resrc.c:276 #, c-format msgid "subprocess got fatal signal %d" msgstr "" -#: dlltool.c:1055 +#: dlltool.c:1211 #, c-format msgid "%s exited with status %d\n" msgstr "" -#: dlltool.c:1087 +#: dlltool.c:1243 #, c-format -msgid "Sucking in info from .drective section in %s\n" +msgid "Sucking in info from %s section in %s\n" msgstr "" -#: dlltool.c:1197 +#: dlltool.c:1367 #, c-format msgid "Excluding symbol: %s\n" msgstr "" -#: dlltool.c:1292 dlltool.c:1303 nm.c:902 nm.c:913 objdump.c:379 objdump.c:396 +#: dlltool.c:1462 dlltool.c:1473 nm.c:902 nm.c:913 objdump.c:444 objdump.c:461 #, c-format msgid "%s: no symbols\n" msgstr "" #. FIXME: we ought to read in and block out the base relocations -#: dlltool.c:1330 +#: dlltool.c:1500 #, c-format -msgid "%s: Done reading %s\n" +msgid "Done reading %s\n" msgstr "" -#: dlltool.c:1341 +#: dlltool.c:1511 #, c-format msgid "Unable to open object file: %s" msgstr "" -#: dlltool.c:1344 +#: dlltool.c:1514 #, c-format msgid "Scanning object file %s" msgstr "" -#: dlltool.c:1434 +#: dlltool.c:1529 +#, c-format +msgid "Cannot produce mcore-elf dll from archive file: %s" +msgstr "" + +#: dlltool.c:1621 msgid "Adding exports to output file" msgstr "" -#: dlltool.c:1479 +#: dlltool.c:1666 msgid "Added exports to output file" msgstr "" -#: dlltool.c:1587 +#: dlltool.c:1790 #, c-format msgid "Generating export file: %s\n" msgstr "" -#: dlltool.c:1592 +#: dlltool.c:1795 #, c-format msgid "Unable to open temporary assembler file: %s" msgstr "" -#: dlltool.c:1595 +#: dlltool.c:1798 #, c-format msgid "Opened temporary file: %s" msgstr "" -#: dlltool.c:1828 +#: dlltool.c:2012 msgid "Generated exports file" msgstr "" -#: dlltool.c:2081 +#: dlltool.c:2267 #, c-format msgid "bfd_open failed open stub file: %s" msgstr "" -#: dlltool.c:2084 +#: dlltool.c:2270 #, c-format msgid "Creating stub file: %s" msgstr "" -#: dlltool.c:2593 +#: dlltool.c:2657 +#, c-format +msgid "failed to open temporary head file: %s" +msgstr "" + +#: dlltool.c:2716 +#, c-format +msgid "failed to open temporary tail file: %s" +msgstr "" + +#: dlltool.c:2784 #, c-format msgid "Can't open .lib file: %s" msgstr "" -#: dlltool.c:2596 +#: dlltool.c:2787 #, c-format msgid "Creating library file: %s\n" msgstr "" -#: dlltool.c:2652 +#: dlltool.c:2846 #, c-format msgid "cannot delete %s: %s\n" msgstr "" -#: dlltool.c:2656 +#: dlltool.c:2850 msgid "Created lib file" msgstr "" -#: dlltool.c:2757 +#: dlltool.c:2955 #, c-format msgid "Warning, ignoring duplicate EXPORT %s %d,%d\n" msgstr "" -#: dlltool.c:2763 +#: dlltool.c:2961 #, c-format msgid "Error, duplicate EXPORT with oridinals: %s" msgstr "" -#: dlltool.c:2890 +#: dlltool.c:3088 msgid "Processing definitions" msgstr "" -#: dlltool.c:2928 +#: dlltool.c:3126 msgid "Processed definitions" msgstr "" #. xgetext:c-format -#: dlltool.c:2939 +#: dlltool.c:3137 #, c-format msgid "Usage %s \n" msgstr "" #. xgetext:c-format -#: dlltool.c:2941 +#: dlltool.c:3139 #, c-format msgid "" -" -m --machine Create {arm, i386, ppc, thumb} DLL. [default: " -"%s]\n" +" -m --machine Create as DLL for . [default: %s]\n" msgstr "" -#: dlltool.c:2942 +#: dlltool.c:3140 +msgid "" +" possible : arm[_interwork], i386, mcore[-elf]{-le|-be}, " +"ppc, thumb\n" +msgstr "" + +#: dlltool.c:3141 msgid " -e --output-exp Generate an export file.\n" msgstr "" -#: dlltool.c:2943 +#: dlltool.c:3142 msgid " -l --output-lib Generate an interface library.\n" msgstr "" -#: dlltool.c:2944 +#: dlltool.c:3143 msgid " -a --add-indirect Add dll indirects to export file.\n" msgstr "" -#: dlltool.c:2945 +#: dlltool.c:3144 msgid "" " -D --dllname Name of input dll to put into interface lib.\n" msgstr "" -#: dlltool.c:2946 +#: dlltool.c:3145 msgid " -d --input-def Name of .def file to be read in.\n" msgstr "" -#: dlltool.c:2947 +#: dlltool.c:3146 msgid " -z --output-def Name of .def file to be created.\n" msgstr "" -#: dlltool.c:2948 -msgid " --export-all-symbols Export all symbols to .def\n" +#: dlltool.c:3147 +msgid " --export-all-symbols Export all symbols to .def\n" msgstr "" -#: dlltool.c:2949 -msgid " --no-export-all-symbols Only export listed symbols\n" +#: dlltool.c:3148 +msgid " --no-export-all-symbols Only export listed symbols\n" msgstr "" -#: dlltool.c:2950 -msgid " --exclude-symbols Don't export \n" +#: dlltool.c:3149 +msgid " --exclude-symbols Don't export \n" msgstr "" -#: dlltool.c:2951 -msgid " --no-default-excludes Clear default exclude symbols\n" +#: dlltool.c:3150 +msgid " --no-default-excludes Clear default exclude symbols\n" msgstr "" -#: dlltool.c:2952 +#: dlltool.c:3151 msgid " -b --base-file Read linker generated base file.\n" msgstr "" -#: dlltool.c:2953 +#: dlltool.c:3152 msgid " -x --no-idata4 Don't generate idata$4 section.\n" msgstr "" -#: dlltool.c:2954 +#: dlltool.c:3153 msgid " -c --no-idata5 Don't generate idata$5 section.\n" msgstr "" -#: dlltool.c:2955 +#: dlltool.c:3154 msgid "" " -U --add-underscore Add underscores to symbols in interface " "library.\n" msgstr "" -#: dlltool.c:2956 +#: dlltool.c:3155 msgid " -k --kill-at Kill @ from exported names.\n" msgstr "" -#: dlltool.c:2957 +#: dlltool.c:3156 msgid " -A --add-stdcall-alias Add aliases without @.\n" msgstr "" -#: dlltool.c:2958 +#: dlltool.c:3157 msgid " -S --as Use for assembler.\n" msgstr "" -#: dlltool.c:2959 +#: dlltool.c:3158 msgid " -f --as-flags Pass to the assembler.\n" msgstr "" -#: dlltool.c:2961 -msgid " -i --interwork Support ARM/Thumb interworking.\n" +#: dlltool.c:3159 +msgid "" +" -C --compat-implib Create backward compatible import library.\n" msgstr "" -#: dlltool.c:2963 +#: dlltool.c:3160 msgid "" " -n --no-delete Keep temp files (repeat for extra " "preservation).\n" msgstr "" -#: dlltool.c:2964 +#: dlltool.c:3161 msgid " -v --verbose Be verbose.\n" msgstr "" -#: dlltool.c:2965 +#: dlltool.c:3162 msgid " -V --version Display the program version.\n" msgstr "" -#: dlltool.c:2966 +#: dlltool.c:3163 msgid " -h --help Display this information.\n" msgstr "" -#: dlltool.c:3120 +#: dlltool.c:3165 +msgid "" +" -M --mcore-elf Process mcore-elf object files into .\n" +msgstr "" + +#: dlltool.c:3166 +msgid " -L --linker Use as the linker.\n" +msgstr "" + +#: dlltool.c:3167 +msgid " -F --linker-flags Pass to the linker.\n" +msgstr "" + +#: dlltool.c:3311 #, c-format msgid "Unable to open base-file: %s" msgstr "" -#: dlltool.c:3137 +#: dlltool.c:3340 #, c-format msgid "Machine '%s' not supported" msgstr "" +#: dlltool.c:3443 dllwrap.c:215 +#, c-format +msgid "Tried file: %s" +msgstr "" + +#: dlltool.c:3450 dllwrap.c:222 +#, c-format +msgid "Using file: %s" +msgstr "" + #: ieee.c:316 msgid "unexpected end of debugging information" msgstr "" @@ -1183,318 +1236,441 @@ msgid "" "Archive index:\n" msgstr "" -#: objcopy.c:293 -#, c-format -msgid "" -"Usage: %s [-vVSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-b byte]\n" -" [-R section] [-i interleave] [--interleave=interleave] [--byte=byte]\n" -" [--input-target=bfdname] [--output-target=bfdname] " -"[--target=bfdname]\n" -" [--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n" -" [--discard-locals] [--debugging] [--remove-section=section]\n" +#: objcopy.c:296 +#, c-format +msgid "Usage: %s in-file [out-file]\n" +msgstr "" + +#: objcopy.c:297 objcopy.c:354 +msgid " The switches are:\n" +msgstr "" + +#: objcopy.c:298 +msgid "" +" -I --input-target Assume input file is in format \n" +" -O --output-target Create an output file in format " +"\n" +" -F --target Set both input and output format to " +"\n" +" --debugging Convert debugging information, if " +"possible\n" +" -p --preserve-dates Copy modified/access timestamps to the " +"output\n" +" -j --only-section Only copy section into the output\n" +" -R --remove-section Remove section from the output\n" +" -S --strip-all Remove all symbol and relocation " +"information\n" +" -g --strip-debug Remove all debugging symbols\n" +" --strip-unneeded Remove all symbols not needed by " +"relocations\n" +" -N --strip-symbol Do not copy symbol \n" +" -K --keep-symbol Only copy symbol \n" +" -L --localize-symbol Force symbol to be marked as a " +"local\n" +" -W --weaken-symbol Force symbol to be marked as a " +"weak\n" +" --weaken Force all global symbols to be marked as " +"weak\n" +" -x --discard-all Remove all non-global symbols\n" +" -X --discard-locals Remove any compiler-generated symbols\n" +" -i --interleave Only copy one out of every " +"bytes\n" +" -b --byte Select byte in every interleaved " +"block\n" +" --gap-fill Fill gaps between sections with \n" +" --pad-to Pad the last section up to address " +"\n" +" --set-start Set the start address to \n" +" {--change-start|--adjust-start} \n" +" Add to the start address\n" +" {--change-addresses|--adjust-vma} \n" +" Add to LMA, VMA and start " +"addresses\n" +" {--change-section-address|--adjust-section-vma} {=|+|-}\n" +" Change LMA and VMA of section by " +"\n" +" --change-section-lma {=|+|-}\n" +" Change the LMA of section by " +"\n" +" --change-section-vma {=|+|-}\n" +" Change the VMA of section by " +"\n" +" {--[no-]change-warnings|--[no-]adjust-warnings}\n" +" Warn if a named section does not exist\n" +" --set-section-flags =\n" +" Set section 's properties to " +"\n" +" --add-section = Add section found in to " +"output\n" +" --change-leading-char Force output format's leading character " +"style\n" +" --remove-leading-char Remove leading character from global " +"symbols\n" +" -v --verbose List all object files modified\n" +" -V --version Display this program's version number\n" +" -h --help Display this output\n" msgstr "" -#: objcopy.c:300 -msgid "" -" [--gap-fill=val] [--pad-to=address] [--preserve-dates]\n" -" [--set-start=val] \n" -" [--change-start=incr] [--change-addresses=incr] \n" -" (--adjust-start and --adjust-vma are aliases for these two) \n" -" [--change-section-address=section{=,+,-}val]\n" -" (--adjust-section-vma is an alias for --change-section-address)\n" -" [--change-section-lma=section{=,+,-}val]\n" -" [--change-section-vma=section{=,+,-}val]\n" -" [--adjust-warnings] [--no-adjust-warnings]\n" -" [--change-warnings] [--no-change-warnings]\n" -" [--set-section-flags=section=flags] " -"[--add-section=sectionname=filename]\n" -" [--keep-symbol symbol] [-K symbol] [--strip-symbol symbol] [-N " -"symbol]\n" -" [--localize-symbol symbol] [-L symbol] [--weaken-symbol symbol]\n" -" [-W symbol] [--change-leading-char] [--remove-leading-char] " -"[--weaken]\n" -" [--verbose] [--version] [--help] in-file [out-file]\n" +#: objcopy.c:353 +#, c-format +msgid "Usage: %s in-file(s)\n" msgstr "" -#: objcopy.c:327 -#, c-format +#: objcopy.c:355 msgid "" -"Usage: %s [-vVsSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-R section]\n" -" [--input-target=bfdname] [--output-target=bfdname] " -"[--target=bfdname]\n" -" [--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n" -" [--discard-locals] [--keep-symbol symbol] [-K symbol]\n" -" [--strip-symbol symbol] [-N symbol] [--remove-section=section]\n" -" [-o file] [--preserve-dates] [--verbose] [--version] [--help] " -"file...\n" +" -I --input-target Assume input file is in format \n" +" -O --output-target Create an output file in format " +"\n" +" -F --target Set both input and output format to " +"\n" +" -p --preserve-dates Copy modified/access timestamps to the " +"output\n" +" -R --remove-section Remove section from the output\n" +" -s --strip-all Remove all symbol and relocation " +"information\n" +" -g -S --strip-debug Remove all debugging symbols\n" +" --strip-unneeded Remove all symbols not needed by " +"relocations\n" +" -N --strip-symbol Do not copy symbol \n" +" -K --keep-symbol Only copy symbol \n" +" -x --discard-all Remove all non-global symbols\n" +" -X --discard-locals Remove any compiler-generated symbols\n" +" -v --verbose List all object files modified\n" +" -V --version Display this program's version number\n" +" -h --help Display this output\n" +" -o Place stripped output into \n" msgstr "" -#: objcopy.c:383 +#: objcopy.c:425 #, c-format msgid "unrecognized section flag `%s'" msgstr "" -#: objcopy.c:384 -msgid "supported flags: alloc, load, readonly, code, data, rom, contents" +#: objcopy.c:426 +msgid "" +"supported flags: alloc, load, noload, readonly, debug, code, data, rom, " +"share, contents" msgstr "" -#: objcopy.c:623 +#: objcopy.c:671 #, c-format msgid "copy from %s(%s) to %s(%s)\n" msgstr "" -#: objcopy.c:642 +#: objcopy.c:690 #, c-format msgid "Warning: Output file cannot represent architecture %s" msgstr "" -#: objcopy.c:669 +#: objcopy.c:717 #, c-format msgid "can't create section `%s': %s" msgstr "" -#: objcopy.c:755 +#: objcopy.c:803 #, c-format msgid "Can't fill gap after %s: %s" msgstr "" -#: objcopy.c:780 +#: objcopy.c:828 #, c-format msgid "Can't add padding to %s: %s" msgstr "" -#: objcopy.c:916 +#: objcopy.c:965 #, c-format msgid "%s: error copying private BFD data: %s" msgstr "" -#: objcopy.c:950 +#: objcopy.c:999 #, c-format msgid "cannot mkdir %s for archive copying (error: %s)" msgstr "" -#: objcopy.c:1204 +#: objcopy.c:1268 #, c-format msgid "%s: section `%s': error in %s: %s" msgstr "" -#: objcopy.c:1476 +#: objcopy.c:1542 #, c-format msgid "%s: can't create debugging section: %s" msgstr "" -#: objcopy.c:1491 +#: objcopy.c:1557 #, c-format msgid "%s: can't set debugging section contents: %s" msgstr "" -#: objcopy.c:1500 +#: objcopy.c:1566 #, c-format msgid "%s: don't know how to write debugging information for %s" msgstr "" -#: objcopy.c:1605 +#: objcopy.c:1671 #, c-format msgid "%s: cannot stat: %s" msgstr "" -#: objcopy.c:1655 +#: objcopy.c:1721 msgid "byte number must be non-negative" msgstr "" -#: objcopy.c:1660 +#: objcopy.c:1726 msgid "interleave must be positive" msgstr "" -#: objcopy.c:1729 +#: objcopy.c:1742 objcopy.c:1749 +#, c-format +msgid "%s both copied and removed" +msgstr "" + +#: objcopy.c:1804 msgid "bad format for --add-section NAME=FILENAME" msgstr "" -#: objcopy.c:1732 +#: objcopy.c:1807 #, c-format msgid "cannot stat: %s: %s" msgstr "" -#: objcopy.c:1750 +#: objcopy.c:1825 #, c-format msgid "cannot open: %s: %s" msgstr "" -#: objcopy.c:1754 +#: objcopy.c:1829 #, c-format msgid "%s: fread failed" msgstr "" -#: objcopy.c:1791 +#: objcopy.c:1872 #, c-format msgid "bad format for %s" msgstr "" -#: objcopy.c:1855 +#: objcopy.c:1936 #, c-format msgid "Warning: truncating gap-fill from 0x%s to 0x%x" msgstr "" -#: objcopy.c:1879 +#: objcopy.c:1960 msgid "bad format for --set-section-flags" msgstr "" -#: objcopy.c:1909 +#: objcopy.c:1990 msgid "byte number must be less than interleave" msgstr "" -#: objcopy.c:1928 +#: objcopy.c:2009 #, c-format msgid "Cannot stat: %s: %s" msgstr "" -#: objcopy.c:1968 +#: objcopy.c:2049 #, c-format msgid "Warning: --change-section-vma %s%c0x%s never used" msgstr "" -#: objcopy.c:1981 +#: objcopy.c:2062 #, c-format msgid "Warning: --change-section-lma %s%c0x%s never used" msgstr "" -#: objdump.c:219 +#: objdump.c:229 #, c-format -msgid "" -"Usage: %s [-ahifCdDprRtTxsSlw] [-b bfdname] [-m machine] [-j section-name]\n" -" [--archive-headers] [--target=bfdname] [--debugging] [--disassemble]\n" -" [--disassemble-all] [--disassemble-zeroes] [--file-headers]\n" -" [--section-headers] [--headers]\n" -" [--info] [--section=section-name] [--line-numbers] [--source]\n" +msgid "Usage: %s file(s)\n" msgstr "" -#: objdump.c:226 +#: objdump.c:230 +msgid " At least one of the following switches must be given:\n" +msgstr "" + +#: objdump.c:231 +msgid "" +" -a --archive-headers Display archive header information\n" +" -f --file-headers Display the contents of the overall file header\n" +" -p --private-headers Display object format specific file header " +"contents\n" +" -h --[section-]headers Display the contents of the section headers\n" +" -x --all-headers Display the contents of all headers\n" +" -d --disassemble Display assembler contents of executable " +"sections\n" +" -D --disassemble-all Display assembler contents of all sections\n" +" -S --source Intermix source code with disassembly\n" +" -s --full-contents Display the full contents of all sections " +"requested\n" +" -g --debugging Display debug information in object file\n" +" -G --stabs Display the STABS contents of an ELF format file\n" +" -t --syms Display the contents of the symbol table(s)\n" +" -T --dynamic-syms Display the contents of the dynamic symbol table\n" +" -r --reloc Display the relocation entries in the file\n" +" -R --dynamic-reloc Display the dynamic relocation entries in the " +"file\n" +" -V --version Display this program's version number\n" +" -i --info List object formats and architectures supported\n" +" -H --help Display this information\n" +msgstr "" + +#: objdump.c:253 msgid "" -" [--architecture=machine] [--reloc] [--full-contents] [--stabs]\n" -" [--syms] [--all-headers] [--dynamic-syms] [--dynamic-reloc]\n" -" [--wide] [--version] [--help] [--private-headers]\n" -" [--start-address=addr] [--stop-address=addr]\n" -" [--prefix-addresses] [--[no-]show-raw-insn] [--demangle]\n" -" [--adjust-vma=offset] [-EB|-EL] [--endian={big|little}] objfile...\n" -"at least one option besides -l (--line-numbers) must be given\n" +"\n" +" The following switches are optional:\n" +msgstr "" + +#: objdump.c:254 +msgid "" +" -b --target Specify the target object format as " +"\n" +" -m --architecture Specify the target architecture as " +"\n" +" -j --section Only display information for section " +"\n" +" -M --disassembler-options Pass text on to the disassembler\n" +" -EB --endian=big Assume big endian format when " +"disassembling\n" +" -EL --endian=little Assume little endian format when " +"disassembling\n" +" --file-start-context Include context from start of file (with " +"-S)\n" +" -l --line-numbers Include line numbers and filenames in " +"output\n" +" -C --demangle Decode mangled/processed symbol names\n" +" -w --wide Format output for more than 80 columns\n" +" -z --disassemble-zeroes Do not skip blocks of zeroes when " +"disassembling\n" +" --start-address Only process data whoes address is >= " +"\n" +" --stop-address Only process data whoes address is <= " +"\n" +" --prefix-addresses Print complete address alongside " +"disassembly\n" +" --[no-]show-raw-insn Display hex alongside symbolic disassembly\n" +" --adjust-vma Add to all displayed section " +"addresses\n" +"\n" msgstr "" -#: objdump.c:361 +#: objdump.c:420 msgid "Sections:\n" msgstr "" -#: objdump.c:363 -msgid "Idx Name Size VMA LMA File off Algn\n" +#: objdump.c:423 +msgid "Idx Name Size VMA LMA File off Algn" msgstr "" -#: objdump.c:365 +#: objdump.c:425 msgid "" "Idx Name Size VMA LMA File off " -"Algn\n" +"Algn" +msgstr "" + +#: objdump.c:429 +msgid " Flags" msgstr "" -#: objdump.c:414 +#: objdump.c:479 #, c-format msgid "%s: %s: not a dynamic object\n" msgstr "" -#: objdump.c:431 +#: objdump.c:496 #, c-format msgid "%s: %s: No dynamic symbols\n" msgstr "" -#: objdump.c:1131 +#: objdump.c:1200 msgid "Out of virtual memory\n" msgstr "" -#: objdump.c:1532 +#: objdump.c:1611 #, c-format msgid "%s: Can't use supplied machine %s\n" msgstr "" -#: objdump.c:1553 +#: objdump.c:1632 #, c-format msgid "%s: Can't disassemble for architecture %s\n" msgstr "" -#: objdump.c:1627 +#: objdump.c:1709 #, c-format msgid "Disassembly of section %s:\n" msgstr "" -#: objdump.c:1798 +#: objdump.c:1883 #, c-format msgid "" "No %s section present\n" "\n" msgstr "" -#: objdump.c:1805 +#: objdump.c:1890 #, c-format msgid "%s: %s has no %s section\n" msgstr "" -#: objdump.c:1818 objdump.c:1829 +#: objdump.c:1904 objdump.c:1916 #, c-format msgid "%s: Reading %s section of %s failed: %s\n" msgstr "" -#: objdump.c:1871 +#: objdump.c:1959 #, c-format msgid "" "Contents of %s section:\n" "\n" msgstr "" -#: objdump.c:1971 +#: objdump.c:2059 #, c-format msgid "architecture: %s, " msgstr "" -#: objdump.c:1974 +#: objdump.c:2062 #, c-format msgid "flags 0x%08x:\n" msgstr "" -#: objdump.c:1987 +#: objdump.c:2075 msgid "" "\n" "start address 0x" msgstr "" -#: objdump.c:2030 +#: objdump.c:2107 #, c-format msgid "" "\n" "%s: file format %s\n" msgstr "" -#: objdump.c:2071 +#: objdump.c:2150 #, c-format msgid "%s: printing debugging information failed\n" msgstr "" -#: objdump.c:2105 +#: objdump.c:2227 #, c-format msgid "In archive %s:\n" msgstr "" -#: objdump.c:2158 +#: objdump.c:2279 #, c-format msgid "Contents of section %s:\n" msgstr "" -#: objdump.c:2661 +#: objdump.c:2788 #, c-format msgid "BFD header file version %s\n" msgstr "" -#: objdump.c:2786 +#: objdump.c:2861 #, c-format msgid "%s: unrecognized -E option\n" msgstr "" -#: objdump.c:2797 +#: objdump.c:2873 #, c-format msgid "%s: unrecognized --endian type `%s'\n" msgstr "" @@ -1533,884 +1709,902 @@ msgstr "" msgid "Last stabs entries before error:\n" msgstr "" -#: readelf.c:229 readelf.c:255 +#: readelf.c:301 readelf.c:327 #, c-format msgid "%s: Error: " msgstr "" -#: readelf.c:241 readelf.c:270 +#: readelf.c:313 readelf.c:342 #, c-format msgid "%s: Warning: " msgstr "" -#: readelf.c:300 readelf.c:325 +#: readelf.c:392 readelf.c:530 #, c-format msgid "Unhandled data length: %d\n" msgstr "" -#: readelf.c:420 +#: readelf.c:589 msgid "Don't know about relocations on this machine architecture\n" msgstr "" -#: readelf.c:426 +#: readelf.c:629 readelf.c:658 readelf.c:690 readelf.c:718 +msgid "out of memory parsing relocs" +msgstr "" + +#: readelf.c:736 msgid "" " Offset Info Type Symbol's Value Symbol's Name " "Addend\n" msgstr "" -#: readelf.c:429 +#: readelf.c:739 msgid " Offset Info Type Symbol's Value Symbol's Name\n" msgstr "" -#: readelf.c:533 +#: readelf.c:879 readelf.c:881 #, c-format msgid "unrecognised: %-7lx" msgstr "" -#: readelf.c:551 +#: readelf.c:906 #, c-format msgid "" msgstr "" -#: readelf.c:703 +#: readelf.c:1113 #, c-format msgid "Processor Specific: %lx" msgstr "" -#: readelf.c:706 +#: readelf.c:1132 #, c-format msgid "Operating System specific: %lx" msgstr "" -#: readelf.c:708 readelf.c:961 +#: readelf.c:1135 readelf.c:1500 #, c-format msgid ": %lx" msgstr "" -#: readelf.c:722 +#: readelf.c:1149 msgid "NONE (None)" msgstr "" -#: readelf.c:723 +#: readelf.c:1150 msgid "REL (Relocatable file)" msgstr "" -#: readelf.c:724 +#: readelf.c:1151 msgid "EXEC (Executable file)" msgstr "" -#: readelf.c:725 +#: readelf.c:1152 msgid "DYN (Shared object file)" msgstr "" -#: readelf.c:726 +#: readelf.c:1153 msgid "CORE (Core file)" msgstr "" -#: readelf.c:730 +#: readelf.c:1157 #, c-format msgid "Processor Specific: (%x)" msgstr "" -#: readelf.c:732 +#: readelf.c:1159 #, c-format msgid "OS Specific: (%x)" msgstr "" -#: readelf.c:734 readelf.c:793 readelf.c:897 readelf.c:1072 +#: readelf.c:1161 readelf.c:1238 readelf.c:1632 #, c-format msgid ": %x" msgstr "" -#: readelf.c:747 +#: readelf.c:1174 msgid "None" msgstr "" -#: readelf.c:894 -msgid "ELFDATA2LSB (little endian)" -msgstr "" - -#: readelf.c:895 -msgid "ELFDATA2MSB (big endian)" -msgstr "" - -#: readelf.c:1108 +#: readelf.c:1670 msgid "Usage: readelf {options} elf-file(s)\n" msgstr "" -#: readelf.c:1109 +#: readelf.c:1671 msgid " Options are:\n" msgstr "" -#: readelf.c:1110 -msgid "" -" -a or --all Equivalent to: -h -l -S -s -r -d -V --histogram\n" +#: readelf.c:1672 +msgid " -a or --all Equivalent to: -h -l -S -s -r -d -V -A -I\n" msgstr "" -#: readelf.c:1111 +#: readelf.c:1673 msgid " -h or --file-header Display the ELF file header\n" msgstr "" -#: readelf.c:1112 +#: readelf.c:1674 msgid " -l or --program-headers or --segments\n" msgstr "" -#: readelf.c:1113 +#: readelf.c:1675 msgid " Display the program headers\n" msgstr "" -#: readelf.c:1114 +#: readelf.c:1676 msgid " -S or --section-headers or --sections\n" msgstr "" -#: readelf.c:1115 +#: readelf.c:1677 msgid " Display the sections' header\n" msgstr "" -#: readelf.c:1116 +#: readelf.c:1678 msgid " -e or --headers Equivalent to: -h -l -S\n" msgstr "" -#: readelf.c:1117 +#: readelf.c:1679 msgid " -s or --syms or --symbols Display the symbol table\n" msgstr "" -#: readelf.c:1118 +#: readelf.c:1680 +msgid " -n or --notes Display the core notes (if present)\n" +msgstr "" + +#: readelf.c:1681 msgid " -r or --relocs Display the relocations (if present)\n" msgstr "" -#: readelf.c:1119 +#: readelf.c:1682 msgid " -d or --dynamic Display the dynamic segment (if present)\n" msgstr "" -#: readelf.c:1120 +#: readelf.c:1683 msgid " -V or --version-info Display the version sections (if present)\n" msgstr "" -#: readelf.c:1121 +#: readelf.c:1684 +msgid "" +" -A or --arch-specific Display architecture specific information (if " +"any).\n" +msgstr "" + +#: readelf.c:1685 msgid "" " -D or --use-dynamic Use the dynamic section info when displaying " "symbols\n" msgstr "" -#: readelf.c:1122 +#: readelf.c:1686 msgid " -x or --hex-dump=\n" msgstr "" -#: readelf.c:1123 +#: readelf.c:1687 msgid " Dump the contents of section \n" msgstr "" -#: readelf.c:1124 +#: readelf.c:1688 msgid " -w[liapr] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges]\n" msgstr "" -#: readelf.c:1125 +#: readelf.c:1689 msgid "" " Display the contents of DWARF2 debug sections\n" msgstr "" -#: readelf.c:1127 +#: readelf.c:1691 msgid " -i or --instruction-dump=\n" msgstr "" -#: readelf.c:1128 +#: readelf.c:1692 msgid "" " Disassemble the contents of section \n" msgstr "" -#: readelf.c:1130 -msgid " --histogram Display histogram of bucket list lengths\n" +#: readelf.c:1694 +msgid " -I or --histogram Display histogram of bucket list lengths\n" msgstr "" -#: readelf.c:1131 +#: readelf.c:1695 msgid " -v or --version Display the version number of readelf\n" msgstr "" -#: readelf.c:1132 +#: readelf.c:1696 msgid " -H or --help Display this information\n" msgstr "" -#: readelf.c:1150 +#: readelf.c:1714 msgid "Out of memory allocating dump request table." msgstr "" -#: readelf.c:1274 +#: readelf.c:1849 #, c-format msgid "Unrecognised debug option '%s'\n" msgstr "" -#: readelf.c:1299 +#: readelf.c:1874 #, c-format msgid "Invalid option '-%c'\n" msgstr "" -#: readelf.c:1312 +#: readelf.c:1887 msgid "Nothing to do.\n" msgstr "" -#: readelf.c:1323 readelf.c:1336 readelf.c:2459 +#: readelf.c:1900 readelf.c:1917 readelf.c:3484 msgid "none" msgstr "" -#: readelf.c:1324 +#: readelf.c:1901 msgid "ELF32" msgstr "" -#: readelf.c:1325 +#: readelf.c:1902 msgid "ELF64" msgstr "" -#: readelf.c:1326 readelf.c:1339 readelf.c:1352 -msgid "" +#: readelf.c:1904 readelf.c:1921 readelf.c:1940 +#, c-format +msgid "" msgstr "" -#: readelf.c:1337 -msgid "2's compilment, little endian" +#: readelf.c:1918 +msgid "2's complement, little endian" msgstr "" -#: readelf.c:1338 -msgid "2's compilment, big endian" +#: readelf.c:1919 +msgid "2's complement, big endian" msgstr "" -#: readelf.c:1349 +#: readelf.c:1934 msgid "UNIX - System V" msgstr "" -#: readelf.c:1350 +#: readelf.c:1935 msgid "UNIX - HP-UX" msgstr "" -#: readelf.c:1351 +#: readelf.c:1936 +msgid "UNIX - Linux" +msgstr "" + +#: readelf.c:1937 msgid "Standalone App" msgstr "" -#: readelf.c:1366 +#: readelf.c:1938 +msgid "ARM" +msgstr "" + +#: readelf.c:1955 msgid "Not an ELF file - it has the wrong magic bytes at the start\n" msgstr "" -#: readelf.c:1374 +#: readelf.c:1963 msgid "ELF Header:\n" msgstr "" -#: readelf.c:1375 +#: readelf.c:1964 msgid " Magic: " msgstr "" -#: readelf.c:1379 +#: readelf.c:1968 #, c-format msgid " Class: %s\n" msgstr "" -#: readelf.c:1381 readelf.c:1397 +#: readelf.c:1970 #, c-format msgid " Data: %s\n" msgstr "" -#: readelf.c:1383 +#: readelf.c:1972 #, c-format msgid " Version: %d %s\n" msgstr "" -#: readelf.c:1387 +#: readelf.c:1979 #, c-format msgid " OS/ABI: %s\n" msgstr "" -#: readelf.c:1389 +#: readelf.c:1981 #, c-format msgid " ABI Version: %d\n" msgstr "" -#: readelf.c:1391 +#: readelf.c:1983 #, c-format msgid " Type: %s\n" msgstr "" -#: readelf.c:1393 +#: readelf.c:1985 #, c-format msgid " Machine: %s\n" msgstr "" -#: readelf.c:1395 +#: readelf.c:1987 #, c-format msgid " Version: 0x%lx\n" msgstr "" -#: readelf.c:1399 -#, c-format -msgid " Entry point address: 0x%lx\n" +#: readelf.c:1990 +msgid " Entry point address: " msgstr "" -#: readelf.c:1401 -#, c-format -msgid " Start of program headers: %ld (bytes into file)\n" +#: readelf.c:1992 +msgid "" +"\n" +" Start of program headers: " msgstr "" -#: readelf.c:1403 -#, c-format -msgid " Start of section headers: %ld (bytes into file)\n" +#: readelf.c:1994 +msgid "" +" (bytes into file)\n" +" Start of section headers: " +msgstr "" + +#: readelf.c:1996 +msgid " (bytes into file)\n" msgstr "" -#: readelf.c:1405 +#: readelf.c:1998 #, c-format msgid " Flags: 0x%lx%s\n" msgstr "" -#: readelf.c:1408 +#: readelf.c:2001 #, c-format msgid " Size of this header: %ld (bytes)\n" msgstr "" -#: readelf.c:1410 +#: readelf.c:2003 #, c-format msgid " Size of program headers: %ld (bytes)\n" msgstr "" -#: readelf.c:1412 +#: readelf.c:2005 #, c-format msgid " Number of program headers: %ld\n" msgstr "" -#: readelf.c:1414 +#: readelf.c:2007 #, c-format msgid " Size of section headers: %ld (bytes)\n" msgstr "" -#: readelf.c:1416 +#: readelf.c:2009 #, c-format msgid " Number of section headers: %ld\n" msgstr "" -#: readelf.c:1418 +#: readelf.c:2011 #, c-format msgid " Section header string table index: %ld\n" msgstr "" -#: readelf.c:1428 -msgid "Not a 32 bit ELF file\n" -msgstr "" - -#: readelf.c:1448 +#: readelf.c:2096 msgid "" "\n" "There are no program headers in this file.\n" msgstr "" -#: readelf.c:1454 +#: readelf.c:2102 #, c-format msgid "" "\n" -"Elf file is %s\n" +"Elf file type is %s\n" msgstr "" -#: readelf.c:1455 -#, c-format -msgid "Entry point 0x%lx\n" +#: readelf.c:2103 +msgid "Entry point " msgstr "" -#: readelf.c:1456 +#: readelf.c:2105 #, c-format -msgid "There are %d program headers, starting at offset %lx:\n" +msgid "" +"\n" +"There are %d program headers, starting at offset " msgstr "" -#: readelf.c:1469 readelf.c:1619 readelf.c:1662 readelf.c:2018 readelf.c:2142 -#: readelf.c:3043 readelf.c:3057 +#: readelf.c:2116 readelf.c:2292 readelf.c:2334 readelf.c:2377 readelf.c:2418 +#: readelf.c:2926 readelf.c:2967 readelf.c:3143 readelf.c:4102 readelf.c:4116 +#: readelf.c:7014 readelf.c:7054 msgid "Out of memory\n" msgstr "" -#: readelf.c:1492 +#: readelf.c:2134 #, c-format msgid "" "\n" "Program Header%s:\n" msgstr "" -#: readelf.c:1494 +#: readelf.c:2138 msgid "" -" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n" +" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n" +msgstr "" + +#: readelf.c:2142 +msgid " Type Offset VirtAddr PhysAddr\n" +msgstr "" + +#: readelf.c:2144 +msgid " FileSiz MemSiz Flags Align\n" msgstr "" -#: readelf.c:1529 +#: readelf.c:2202 msgid "more than one dynamic segment\n" msgstr "" -#: readelf.c:1537 +#: readelf.c:2210 msgid "Unable to find program interpreter name\n" msgstr "" -#: readelf.c:1544 +#: readelf.c:2217 #, c-format msgid "" "\n" " [Requesting program interpreter: %s]" msgstr "" -#: readelf.c:1562 +#: readelf.c:2235 msgid "" "\n" " Section to Segment mapping:\n" msgstr "" -#: readelf.c:1563 +#: readelf.c:2236 msgid " Segment Sections...\n" msgstr "" -#: readelf.c:1697 +#: readelf.c:2499 msgid "" "\n" "There are no sections in this file.\n" msgstr "" -#: readelf.c:1703 +#: readelf.c:2505 #, c-format -msgid "There are %d section headers, starting at offset %lx:\n" +msgid "There are %d section headers, starting at offset 0x%lx:\n" msgstr "" -#: readelf.c:1737 +#: readelf.c:2545 msgid "File contains multiple dynamic symbol tables\n" msgstr "" -#: readelf.c:1750 +#: readelf.c:2558 msgid "File contains multiple dynamic string tables\n" msgstr "" -#: readelf.c:1777 +#: readelf.c:2585 #, c-format msgid "" "\n" "Section Header%s:\n" msgstr "" -#: readelf.c:1779 +#: readelf.c:2589 msgid "" " [Nr] Name Type Addr Off Size ES Flg Lk " "Inf Al\n" msgstr "" -#: readelf.c:1844 +#: readelf.c:2592 +msgid " [Nr] Name Type Address Offset\n" +msgstr "" + +#: readelf.c:2593 +msgid " Size EntSize Flags Link Info Align\n" +msgstr "" + +#: readelf.c:2640 +msgid "" +"Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings)\n" +msgstr "" + +#: readelf.c:2641 +msgid "" +" I (info), L (link order), O (extra OS processing required)\n" +msgstr "" + +#: readelf.c:2642 +msgid " o (os specific), p (processor specific) x (unknown)\n" +msgstr "" + +#: readelf.c:2700 #, c-format msgid "" "\n" "Relocation section at offset 0x%lx contains %ld bytes:\n" msgstr "" -#: readelf.c:1851 +#: readelf.c:2707 msgid "" "\n" "There are no dynamic relocations in this file.\n" msgstr "" -#: readelf.c:1877 +#: readelf.c:2735 msgid "" "\n" "Relocation section " msgstr "" -#: readelf.c:1884 +#: readelf.c:2742 #, c-format msgid " at offset 0x%lx contains %lu entries:\n" msgstr "" -#: readelf.c:1910 +#: readelf.c:2770 msgid "" "\n" "There are no relocations in this file.\n" msgstr "" -#: readelf.c:1998 +#: readelf.c:3020 msgid "" "\n" "There is no dynamic segment in this file.\n" msgstr "" -#: readelf.c:2056 +#: readelf.c:3054 msgid "Unable to seek to end of file!" msgstr "" -#: readelf.c:2062 +#: readelf.c:3063 msgid "Unable to determine the number of symbols to load\n" msgstr "" -#: readelf.c:2092 +#: readelf.c:3093 msgid "Unable to seek to end of file\n" msgstr "" -#: readelf.c:2098 +#: readelf.c:3099 msgid "Unable to determine the length of the dynamic string table\n" msgstr "" -#: readelf.c:2159 +#: readelf.c:3160 #, c-format msgid "" "\n" -"Dynamic segment at offset 0x%x contains %d entries:\n" +"Dynamic segment at offset 0x%x contains %ld entries:\n" msgstr "" -#: readelf.c:2162 +#: readelf.c:3163 msgid " Tag Type Name/Value\n" msgstr "" -#: readelf.c:2169 -#, c-format -msgid " 0x%-8.8lx (%s)%*s" -msgstr "" - -#: readelf.c:2182 +#: readelf.c:3191 msgid "Auxiliary library" msgstr "" -#: readelf.c:2184 +#: readelf.c:3193 msgid "Filter library" msgstr "" -#: readelf.c:2196 readelf.c:2217 readelf.c:2243 +#: readelf.c:3209 readelf.c:3230 readelf.c:3256 msgid "Flags:" msgstr "" -#: readelf.c:2198 readelf.c:2219 readelf.c:2245 +#: readelf.c:3211 readelf.c:3232 readelf.c:3258 msgid " None\n" msgstr "" -#: readelf.c:2348 +#: readelf.c:3361 #, c-format msgid "Shared library: [%s]" msgstr "" -#: readelf.c:2353 -msgid " program interpreter\n" +#: readelf.c:3364 +msgid " program interpreter" msgstr "" -#: readelf.c:2357 +#: readelf.c:3368 #, c-format -msgid "Library soname: [%s]\n" +msgid "Library soname: [%s]" msgstr "" -#: readelf.c:2361 +#: readelf.c:3372 #, c-format -msgid "Library rpath: [%s]\n" +msgid "Library rpath: [%s]" msgstr "" -#: readelf.c:2413 +#: readelf.c:3433 #, c-format msgid "Not needed object: [%s]\n" msgstr "" -#: readelf.c:2505 +#: readelf.c:3530 #, c-format msgid "" "\n" "Version definition section '%s' contains %ld entries:\n" msgstr "" -#: readelf.c:2508 +#: readelf.c:3533 msgid " Addr: 0x" msgstr "" -#: readelf.c:2510 readelf.c:2699 +#: readelf.c:3535 readelf.c:3723 #, c-format msgid " Offset: %#08lx Link: %lx (%s)\n" msgstr "" -#: readelf.c:2540 +#: readelf.c:3565 #, c-format msgid " %#06x: Rev: %d Flags: %s" msgstr "" -#: readelf.c:2543 +#: readelf.c:3568 #, c-format msgid " Index: %d Cnt: %d " msgstr "" -#: readelf.c:2554 +#: readelf.c:3579 #, c-format msgid "Name: %s\n" msgstr "" -#: readelf.c:2556 +#: readelf.c:3581 #, c-format msgid "Name index: %ld\n" msgstr "" -#: readelf.c:2571 +#: readelf.c:3596 #, c-format msgid " %#06x: Parent %d: %s\n" msgstr "" -#: readelf.c:2574 +#: readelf.c:3599 #, c-format msgid " %#06x: Parent %d, name index: %ld\n" msgstr "" -#: readelf.c:2593 +#: readelf.c:3618 #, c-format msgid "" "\n" "Version needs section '%s' contains %ld entries:\n" msgstr "" -#: readelf.c:2596 +#: readelf.c:3621 msgid " Addr: 0x" msgstr "" -#: readelf.c:2598 +#: readelf.c:3623 #, c-format msgid " Offset: %#08lx Link to section: %ld (%s)\n" msgstr "" -#: readelf.c:2624 +#: readelf.c:3649 #, c-format msgid " %#06x: Version: %d" msgstr "" -#: readelf.c:2627 +#: readelf.c:3652 #, c-format msgid " File: %s" msgstr "" -#: readelf.c:2629 +#: readelf.c:3654 #, c-format msgid " File: %lx" msgstr "" -#: readelf.c:2631 +#: readelf.c:3656 #, c-format msgid " Cnt: %d\n" msgstr "" -#: readelf.c:2649 +#: readelf.c:3674 #, c-format msgid " %#06x: Name: %s" msgstr "" -#: readelf.c:2652 +#: readelf.c:3677 #, c-format msgid " %#06x: Name index: %lx" msgstr "" -#: readelf.c:2655 +#: readelf.c:3680 #, c-format msgid " Flags: %s Version: %d\n" msgstr "" -#: readelf.c:2694 +#: readelf.c:3718 #, c-format msgid "" "\n" "Version symbols section '%s' contains %d entries:\n" msgstr "" -#: readelf.c:2697 +#: readelf.c:3721 msgid " Addr: " msgstr "" -#: readelf.c:2726 +#: readelf.c:3751 msgid " 0 (*local*) " msgstr "" -#: readelf.c:2730 +#: readelf.c:3755 msgid " 1 (*global*) " msgstr "" -#: readelf.c:2953 +#: readelf.c:3977 msgid "" "\n" "No version information found in this file.\n" msgstr "" -#: readelf.c:2966 -msgid "LOCAL" -msgstr "" - -#: readelf.c:2967 -msgid "GLOBAL" -msgstr "" - -#: readelf.c:2968 -msgid "WEAK" -msgstr "" - -#: readelf.c:2971 readelf.c:2995 +#: readelf.c:3995 readelf.c:4030 #, c-format msgid ": %d" msgstr "" -#: readelf.c:2973 readelf.c:2997 +#: readelf.c:3997 readelf.c:4042 #, c-format msgid ": %d" msgstr "" -#: readelf.c:2975 readelf.c:2999 +#: readelf.c:3999 readelf.c:4045 #, c-format msgid ": %d" msgstr "" -#: readelf.c:2988 -msgid "NOTYPE" -msgstr "" - -#: readelf.c:2989 -msgid "OBJECT" -msgstr "" - -#: readelf.c:2990 -msgid "FUNC" -msgstr "" - -#: readelf.c:2991 -msgid "SECTION" -msgstr "" - -#: readelf.c:2992 -msgid "FILE" -msgstr "" - -#: readelf.c:3049 +#: readelf.c:4108 msgid "Unable to read in dynamic data\n" msgstr "" -#: readelf.c:3091 +#: readelf.c:4150 msgid "Unable to seek to start of dynamic information" msgstr "" -#: readelf.c:3097 +#: readelf.c:4156 msgid "Failed to read in number of buckets\n" msgstr "" -#: readelf.c:3103 +#: readelf.c:4162 msgid "Failed to read in number of chains\n" msgstr "" -#: readelf.c:3123 +#: readelf.c:4182 msgid "" "\n" "Symbol table for image:\n" msgstr "" -#: readelf.c:3124 -msgid " Num Buc: Value Size Type Bind Ot Ndx Name\n" +#: readelf.c:4184 +msgid " Num Buc: Value Size Type Bind Vis Ndx Name\n" msgstr "" -#: readelf.c:3169 +#: readelf.c:4186 +msgid " Num Buc: Value Size Type Bind Vis Ndx Name\n" +msgstr "" + +#: readelf.c:4230 #, c-format msgid "" "\n" "Symbol table '%s' contains %lu entries:\n" msgstr "" -#: readelf.c:3172 -msgid " Num: Value Size Type Bind Ot Ndx Name\n" +#: readelf.c:4234 +msgid " Num: Value Size Type Bind Vis Ndx Name\n" +msgstr "" + +#: readelf.c:4236 +msgid " Num: Value Size Type Bind Vis Ndx Name\n" msgstr "" -#: readelf.c:3291 +#: readelf.c:4345 msgid "bad dynamic symbol" msgstr "" -#: readelf.c:3350 +#: readelf.c:4404 msgid "" "\n" "Dynamic symbol information is not available for displaying symbols.\n" msgstr "" -#: readelf.c:3362 +#: readelf.c:4416 #, c-format msgid "" "\n" "Histogram for bucket list length (total of %d buckets):\n" msgstr "" -#: readelf.c:3364 +#: readelf.c:4418 msgid " Length Number %% of total Coverage\n" msgstr "" -#: readelf.c:3369 readelf.c:3388 readelf.c:5271 readelf.c:5461 +#: readelf.c:4423 readelf.c:4442 readelf.c:6695 readelf.c:6888 msgid "Out of memory" msgstr "" -#: readelf.c:3434 +#: readelf.c:4491 #, c-format msgid "" "\n" "Dynamic info segment at offset 0x%lx contains %d entries:\n" msgstr "" -#: readelf.c:3437 +#: readelf.c:4494 msgid " Num: Name BoundTo Flags\n" msgstr "" -#: readelf.c:3485 +#: readelf.c:4542 #, c-format msgid "" "\n" "Assembly dump of section %s\n" msgstr "" -#: readelf.c:3508 +#: readelf.c:4565 #, c-format msgid "" "\n" "Section '%s' has no data to dump.\n" msgstr "" -#: readelf.c:3513 +#: readelf.c:4570 #, c-format msgid "" "\n" "Hex dump of section '%s':\n" msgstr "" -#: readelf.c:3663 +#: readelf.c:4722 msgid "badly formed extended line op encountered!" msgstr "" -#: readelf.c:3670 +#: readelf.c:4729 #, c-format msgid " Extended opcode %d: " msgstr "" -#: readelf.c:3675 +#: readelf.c:4734 msgid "" "End of Sequence\n" "\n" msgstr "" -#: readelf.c:3682 +#: readelf.c:4740 #, c-format msgid "set Address to 0x%lx\n" msgstr "" -#: readelf.c:3687 +#: readelf.c:4745 msgid " define new File Table entry\n" msgstr "" -#: readelf.c:3688 readelf.c:3806 +#: readelf.c:4746 readelf.c:4868 msgid " Entry\tDir\tTime\tSize\tName\n" msgstr "" -#: readelf.c:3690 +#: readelf.c:4748 #, c-format msgid " %d\t" msgstr "" -#: readelf.c:3693 readelf.c:3695 readelf.c:3697 readelf.c:3818 readelf.c:3820 -#: readelf.c:3822 +#: readelf.c:4751 readelf.c:4753 readelf.c:4755 readelf.c:4880 readelf.c:4882 +#: readelf.c:4884 #, c-format msgid "%lu\t" msgstr "" -#: readelf.c:3698 +#: readelf.c:4756 #, c-format msgid "" "%s\n" "\n" msgstr "" -#: readelf.c:3702 +#: readelf.c:4760 #, c-format msgid "UNKNOWN: length %d\n" msgstr "" -#: readelf.c:3724 +#: readelf.c:4786 #, c-format msgid "" "\n" @@ -2418,439 +2612,511 @@ msgid "" "\n" msgstr "" -#: readelf.c:3736 +#: readelf.c:4798 msgid "The line info appears to be corrupt - the section is too small\n" msgstr "" -#: readelf.c:3744 +#: readelf.c:4806 msgid "Only DWARF version 2 line info is currently supported.\n" msgstr "" -#: readelf.c:3759 +#: readelf.c:4821 #, c-format msgid " Length: %ld\n" msgstr "" -#: readelf.c:3760 +#: readelf.c:4822 #, c-format msgid " DWARF Version: %d\n" msgstr "" -#: readelf.c:3761 +#: readelf.c:4823 #, c-format msgid " Prolgue Length: %d\n" msgstr "" -#: readelf.c:3762 +#: readelf.c:4824 #, c-format msgid " Minimum Instruction Length: %d\n" msgstr "" -#: readelf.c:3763 +#: readelf.c:4825 #, c-format msgid " Initial value of 'is_stmt': %d\n" msgstr "" -#: readelf.c:3764 +#: readelf.c:4826 #, c-format msgid " Line Base: %d\n" msgstr "" -#: readelf.c:3765 +#: readelf.c:4827 #, c-format msgid " Line Range: %d\n" msgstr "" -#: readelf.c:3766 +#: readelf.c:4828 #, c-format msgid " Opcode Base: %d\n" msgstr "" -#: readelf.c:3775 +#: readelf.c:4837 msgid "" "\n" " Opcodes:\n" msgstr "" -#: readelf.c:3778 +#: readelf.c:4840 #, c-format msgid " Opcode %d has %d args\n" msgstr "" -#: readelf.c:3784 +#: readelf.c:4846 msgid "" "\n" " The Directory Table is empty.\n" msgstr "" -#: readelf.c:3787 +#: readelf.c:4849 msgid "" "\n" " The Directory Table:\n" msgstr "" -#: readelf.c:3791 +#: readelf.c:4853 #, c-format msgid " %s\n" msgstr "" -#: readelf.c:3802 +#: readelf.c:4864 msgid "" "\n" " The File Name Table is empty.\n" msgstr "" -#: readelf.c:3805 +#: readelf.c:4867 msgid "" "\n" " The File Name Table:\n" msgstr "" -#: readelf.c:3813 +#: readelf.c:4875 #, c-format msgid " %d\t" msgstr "" -#: readelf.c:3824 +#: readelf.c:4886 #, c-format msgid "%s\n" msgstr "" #. Now display the statements. -#: readelf.c:3832 +#: readelf.c:4894 msgid "" "\n" " Line Number Statements:\n" msgstr "" -#: readelf.c:3850 +#: readelf.c:4913 msgid " Copy\n" msgstr "" -#: readelf.c:3857 +#: readelf.c:4920 #, c-format msgid " Advance PC by %d to %lx\n" msgstr "" -#: readelf.c:3865 +#: readelf.c:4928 #, c-format msgid " Advance Line by %d to %d\n" msgstr "" -#: readelf.c:3872 +#: readelf.c:4935 #, c-format msgid " Set File Name to entry %d in the File Name Table\n" msgstr "" -#: readelf.c:3880 +#: readelf.c:4943 #, c-format msgid " Set column to %d\n" msgstr "" -#: readelf.c:3887 +#: readelf.c:4950 #, c-format msgid " Set is_stmt to %d\n" msgstr "" -#: readelf.c:3892 +#: readelf.c:4955 msgid " Set basic block\n" msgstr "" -#: readelf.c:3899 +#: readelf.c:4963 #, c-format msgid " Advance PC by constant %d to 0x%lx\n" msgstr "" -#: readelf.c:3907 +#: readelf.c:4971 #, c-format msgid " Advance PC by fixed size amount %d to 0x%lx\n" msgstr "" -#: readelf.c:3915 +#: readelf.c:4979 #, c-format msgid " Special opcode %d: advance Address by %d to 0x%lx" msgstr "" -#: readelf.c:3919 +#: readelf.c:4983 #, c-format msgid " and Line by %d to %d\n" msgstr "" -#: readelf.c:3942 readelf.c:4361 +#: readelf.c:5006 readelf.c:5428 #, c-format msgid "" "Contents of the %s section:\n" "\n" msgstr "" -#: readelf.c:3961 +#: readelf.c:5025 msgid "Only DWARF 2 pubnames are currently supported" msgstr "" -#: readelf.c:3965 +#: readelf.c:5029 #, c-format msgid " Length: %ld\n" msgstr "" -#: readelf.c:3967 +#: readelf.c:5031 #, c-format msgid " Version: %d\n" msgstr "" -#: readelf.c:3969 +#: readelf.c:5033 #, c-format msgid " Offset into .debug_info section: %ld\n" msgstr "" -#: readelf.c:3971 +#: readelf.c:5035 #, c-format msgid " Size of area in .debug_info section: %ld\n" msgstr "" -#: readelf.c:3974 +#: readelf.c:5038 msgid "" "\n" " Offset\tName\n" msgstr "" -#: readelf.c:4056 +#: readelf.c:5120 #, c-format msgid "Unknown TAG value: %lx" msgstr "" -#: readelf.c:4151 +#: readelf.c:5215 #, c-format msgid "Unknown AT value: %lx" msgstr "" -#: readelf.c:4188 +#: readelf.c:5252 #, c-format msgid "Unknown FORM value: %lx" msgstr "" -#: readelf.c:4367 +#: readelf.c:5434 msgid " Number TAG\n" msgstr "" -#: readelf.c:4373 +#: readelf.c:5440 #, c-format msgid " %ld %s [%s]\n" msgstr "" -#: readelf.c:4376 +#: readelf.c:5443 msgid "has children" msgstr "" -#: readelf.c:4376 +#: readelf.c:5443 msgid "no children" msgstr "" -#: readelf.c:4380 +#: readelf.c:5447 #, c-format msgid " %-18s %s\n" msgstr "" -#: readelf.c:4399 +#: readelf.c:5466 #, c-format msgid " %lu byte block: " msgstr "" -#: readelf.c:4568 +#: readelf.c:5930 msgid "(User defined location op)" msgstr "" -#: readelf.c:4570 +#: readelf.c:5932 msgid "(Unknown location op)" msgstr "" -#: readelf.c:4687 +#: readelf.c:6049 #, c-format msgid "Unable to handle FORM: %d" msgstr "" -#: readelf.c:4691 +#: readelf.c:6053 #, c-format msgid "Unrecognised form: %d" msgstr "" -#: readelf.c:4704 +#: readelf.c:6066 msgid "(not inlined)" msgstr "" -#: readelf.c:4705 +#: readelf.c:6067 msgid "(inlined)" msgstr "" -#: readelf.c:4706 +#: readelf.c:6068 msgid "(declared as inline but ignored)" msgstr "" -#: readelf.c:4707 +#: readelf.c:6069 msgid "(declared as inline and inlined)" msgstr "" -#: readelf.c:4708 +#: readelf.c:6070 #, c-format msgid " (Unknown inline attribute value: %lx)" msgstr "" -#: readelf.c:4838 readelf.c:4962 +#: readelf.c:6200 readelf.c:6324 #, c-format msgid "" "The section %s contains:\n" "\n" msgstr "" -#: readelf.c:4860 +#: readelf.c:6222 msgid "Only version 2 DWARF debug information is currently supported.\n" msgstr "" -#: readelf.c:4864 +#: readelf.c:6226 msgid " Compilation Unit:\n" msgstr "" -#: readelf.c:4865 +#: readelf.c:6227 #, c-format msgid " Length: %ld\n" msgstr "" -#: readelf.c:4866 +#: readelf.c:6228 #, c-format msgid " Version: %d\n" msgstr "" -#: readelf.c:4867 +#: readelf.c:6229 #, c-format msgid " Abbrev Offset: %ld\n" msgstr "" -#: readelf.c:4868 +#: readelf.c:6230 #, c-format msgid " Pointer Size: %d\n" msgstr "" -#: readelf.c:4888 +#: readelf.c:6250 msgid "Unable to locate .debug_abbrev section!\n" msgstr "" -#: readelf.c:4928 +#: readelf.c:6290 #, c-format -msgid "Unable to locate entry %d in the abbreviation table\n" +msgid "Unable to locate entry %lu in the abbreviation table\n" msgstr "" -#: readelf.c:4933 +#: readelf.c:6295 #, c-format -msgid " <%d><%x>: Abbrev Number: %d (%s)\n" +msgid " <%d><%x>: Abbrev Number: %lu (%s)\n" msgstr "" -#: readelf.c:4980 +#: readelf.c:6343 #, c-format msgid " Length: %ld\n" msgstr "" -#: readelf.c:4981 +#: readelf.c:6344 #, c-format msgid " Version: %d\n" msgstr "" -#: readelf.c:4982 +#: readelf.c:6345 #, c-format msgid " Offset into .debug_info: %lx\n" msgstr "" -#: readelf.c:4983 +#: readelf.c:6346 #, c-format msgid " Pointer Size: %d\n" msgstr "" -#: readelf.c:4984 +#: readelf.c:6347 #, c-format msgid " Segment Size: %d\n" msgstr "" -#: readelf.c:4986 +#: readelf.c:6349 msgid "" "\n" " Address Length\n" msgstr "" -#: readelf.c:5021 +#: readelf.c:6390 #, c-format msgid "Displaying the debug contents of section %s is not yet supported.\n" msgstr "" -#: readelf.c:5063 +#: readelf.c:6452 #, c-format msgid "" "\n" "Section '%s' has no debugging data.\n" msgstr "" -#: readelf.c:5079 +#: readelf.c:6468 #, c-format msgid "Unrecognised debug section: %s\n" msgstr "" -#: readelf.c:5118 +#: readelf.c:6540 msgid "Some sections were not dumped because they do not exist!\n" msgstr "" -#: readelf.c:5293 +#: readelf.c:6719 #, c-format msgid "" "\n" "Section '%s' contains %d entries:\n" msgstr "" -#: readelf.c:5454 +#: readelf.c:6881 msgid "conflict list with without table" msgstr "" -#: readelf.c:5482 +#: readelf.c:6909 #, c-format msgid "" "\n" "Section '.conflict' contains %d entries:\n" msgstr "" -#: readelf.c:5483 +#: readelf.c:6910 msgid " Num: Index Value Name" msgstr "" -#: readelf.c:5560 +#: readelf.c:6935 +msgid "NT_PRSTATUS (prstatus structure)" +msgstr "" + +#: readelf.c:6936 +msgid "NT_FPREGSET (floating point registers)" +msgstr "" + +#: readelf.c:6937 +msgid "NT_PRPSINFO (prpsinfo structure)" +msgstr "" + +#: readelf.c:6938 +msgid "NT_TASKSTRUCT (task structure)" +msgstr "" + +#: readelf.c:6939 +msgid "NT_PRXFPREG (user_xfpregs structure)" +msgstr "" + +#: readelf.c:6940 +msgid "NT_PSTATUS (pstatus structure)" +msgstr "" + +#: readelf.c:6941 +msgid "NT_FPREGS (floating point registers)" +msgstr "" + +#: readelf.c:6942 +msgid "NT_PSINFO (psinfo structure)" +msgstr "" + +#: readelf.c:6943 +msgid "NT_LWPSTATUS (lwpstatus_t structure)" +msgstr "" + +#: readelf.c:6944 +msgid "NT_LWPSINFO (lwpsinfo_t structure)" +msgstr "" + +#: readelf.c:6945 +msgid "NT_WIN32PSTATUS (win32_pstatus strcuture)" +msgstr "" + +#: readelf.c:6947 +#, c-format +msgid "Unknown note type: (0x%08x)" +msgstr "" + +#: readelf.c:6985 +#, c-format +msgid "" +"\n" +"Notes at offset 0x%08lx with length 0x%08lx:\n" +msgstr "" + +#: readelf.c:6988 +msgid " Owner\t\tData size\tDescription\n" +msgstr "" + +#: readelf.c:7099 +msgid "No note segments present in the core file.\n" +msgstr "" + +#: readelf.c:7177 +msgid "This instance of readelf has been built without support for a\n" +msgstr "" + +#: readelf.c:7178 +msgid "64 bit data type and so it cannot read 64 bit ELF files.\n" +msgstr "" + +#: readelf.c:7213 #, c-format msgid "Cannot stat input file %s.\n" msgstr "" -#: readelf.c:5567 +#: readelf.c:7220 #, c-format msgid "Input file %s not found.\n" msgstr "" -#: readelf.c:5573 +#: readelf.c:7226 #, c-format msgid "%s: Failed to read file header\n" msgstr "" -#: readelf.c:5587 +#: readelf.c:7240 #, c-format msgid "" "\n" "File: %s\n" msgstr "" -#: rename.c:121 +#: rename.c:131 #, c-format msgid "%s: cannot set time: %s" msgstr "" #. We have to clean up here. -#: rename.c:160 rename.c:193 +#: rename.c:170 rename.c:203 #, c-format msgid "%s: rename: %s" msgstr "" -#: rename.c:201 +#: rename.c:211 #, c-format msgid "%s: simple_copy: %s" msgstr "" @@ -3125,51 +3391,95 @@ msgstr "" msgid "filename required for COFF output" msgstr "" -#: rescoff.c:729 +#: rescoff.c:740 msgid "can't get BFD_RELOC_RVA relocation type" msgstr "" -#: resrc.c:150 +#: resrc.c:240 resrc.c:312 +#, c-format +msgid "can't open temporary file `%s': %s" +msgstr "" + +#: resrc.c:246 +#, c-format +msgid "can't redirect stdout: `%s': %s" +msgstr "" + +#: resrc.c:262 +#, c-format +msgid "%s %s: %s" +msgstr "" + +#: resrc.c:283 +#, c-format +msgid "%s exited with status %d" +msgstr "" + +#: resrc.c:308 +#, c-format +msgid "can't execute `%s': %s" +msgstr "" + +#: resrc.c:317 +#, c-format +msgid "Using temporary file `%s' to read preprocessor output\n" +msgstr "" + +#: resrc.c:324 #, c-format msgid "can't popen `%s': %s" msgstr "" -#: resrc.c:163 +#: resrc.c:326 +msgid "Using popen to read preprocessor output\n" +msgstr "" + +#: resrc.c:369 +#, c-format +msgid "Tried `%s'\n" +msgstr "" + +#: resrc.c:380 #, c-format -msgid "%s: warning: preprocessor failed\n" +msgid "Using `%s'\n" msgstr "" -#: resrc.c:208 +#: resrc.c:544 +#, c-format +msgid "%s:%d: %s\n" +msgstr "" + +#: resrc.c:553 #, c-format msgid "%s: unexpected EOF" msgstr "" -#: resrc.c:265 +#: resrc.c:610 #, c-format msgid "%s: read of %lu returned %lu" msgstr "" -#: resrc.c:307 resrc.c:538 resrc.c:811 resrc.c:965 +#: resrc.c:652 resrc.c:883 resrc.c:1156 resrc.c:1310 #, c-format msgid "stat failed on bitmap file `%s': %s" msgstr "" -#: resrc.c:360 +#: resrc.c:705 #, c-format msgid "cursor file `%s' does not contain cursor data" msgstr "" -#: resrc.c:392 resrc.c:682 +#: resrc.c:737 resrc.c:1027 #, c-format msgid "%s: fseek to %lu failed: %s" msgstr "" -#: resrc.c:651 +#: resrc.c:996 #, c-format msgid "icon file `%s' does not contain icon data" msgstr "" -#: resrc.c:1170 +#: resrc.c:1515 #, c-format msgid "can't open `%s' for output: %s" msgstr "" @@ -3214,7 +3524,7 @@ msgstr "" msgid "%s: unable to open output file %s\n" msgstr "" -#: stabs.c:349 stabs.c:1762 +#: stabs.c:349 stabs.c:1769 msgid "numeric overflow" msgstr "" @@ -3248,64 +3558,64 @@ msgstr "" #. Does this actually ever happen? Is that why we are worrying #. about dealing with it rather than just calling error_type? -#: stabs.c:1854 +#: stabs.c:1861 msgid "missing index type" msgstr "" -#: stabs.c:2181 +#: stabs.c:2188 msgid "unknown virtual character for baseclass" msgstr "" -#: stabs.c:2199 +#: stabs.c:2206 msgid "unknown visibility character for baseclass" msgstr "" -#: stabs.c:2391 +#: stabs.c:2398 msgid "unnamed $vb type" msgstr "" -#: stabs.c:2397 +#: stabs.c:2404 msgid "unrecognized C++ abbreviation" msgstr "" -#: stabs.c:2477 +#: stabs.c:2484 msgid "unknown visibility character for field" msgstr "" -#: stabs.c:2733 +#: stabs.c:2740 msgid "const/volatile indicator missing" msgstr "" -#: stabs.c:2973 +#: stabs.c:2980 #, c-format msgid "No mangling for \"%s\"\n" msgstr "" -#: stabs.c:3286 +#: stabs.c:3293 msgid "Undefined N_EXCL" msgstr "" -#: stabs.c:3374 +#: stabs.c:3381 #, c-format msgid "Type file number %d out of range\n" msgstr "" -#: stabs.c:3379 +#: stabs.c:3386 #, c-format msgid "Type index number %d out of range\n" msgstr "" -#: stabs.c:3466 +#: stabs.c:3473 #, c-format msgid "Unrecognized XCOFF type %d\n" msgstr "" -#: stabs.c:3765 +#: stabs.c:3772 #, c-format msgid "bad mangled name `%s'\n" msgstr "" -#: stabs.c:3861 +#: stabs.c:3868 msgid "no argument types in mangled string\n" msgstr "" @@ -3347,50 +3657,50 @@ msgid "" "the GNU General Public License. This program has absolutely no warranty.\n" msgstr "" -#: windres.c:228 +#: windres.c:237 #, c-format msgid "can't open %s `%s': %s" msgstr "" -#: windres.c:407 +#: windres.c:416 msgid ": expected to be a directory\n" msgstr "" -#: windres.c:419 +#: windres.c:428 msgid ": expected to be a leaf\n" msgstr "" -#: windres.c:428 +#: windres.c:437 #, c-format msgid "%s: warning: " msgstr "" -#: windres.c:430 +#: windres.c:439 msgid ": duplicate value\n" msgstr "" -#: windres.c:593 +#: windres.c:602 #, c-format msgid "%s: unknown format type `%s'\n" msgstr "" -#: windres.c:594 +#: windres.c:603 #, c-format msgid "%s: supported formats:" msgstr "" #. Otherwise, we give up. -#: windres.c:681 +#: windres.c:690 #, c-format msgid "can not determine type of file `%s'; use the -I option" msgstr "" -#: windres.c:695 +#: windres.c:704 #, c-format msgid "Usage: %s [options] [input-file] [output-file]\n" msgstr "" -#: windres.c:697 +#: windres.c:706 msgid "" "Options:\n" " -i FILE, --input FILE Name input file\n" @@ -3402,28 +3712,33 @@ msgid "" " -F TARGET, --target TARGET Specify COFF target\n" " --preprocessor PROGRAM Program to use to preprocess rc file\n" " --include-dir DIR Include directory when preprocessing rc file\n" -" --define SYM[=VAL] Define SYM when preprocessing rc file\n" +" -DSYM[=VAL], --define SYM[=VAL]\n" +" Define SYM when preprocessing rc file\n" +" -v Verbose - tells you what it's doing\n" " --language VAL Set language when reading rc file\n" +" --use-temp-file Use a temporary file instead of popen to read\n" +" the preprocessor output\n" +" --no-use-temp-file Use popen (default)\n" msgstr "" -#: windres.c:711 +#: windres.c:725 msgid " --yydebug Turn on parser debugging\n" msgstr "" -#: windres.c:714 +#: windres.c:728 msgid "" " --help Print this help message\n" " --version Print version information\n" msgstr "" -#: windres.c:717 +#: windres.c:731 msgid "" "FORMAT is one of rc, res, or coff, and is deduced from the file name\n" "extension if not specified. A single file name is an input file.\n" "No input-file is stdin, default rc. No output-file is stdout, default rc.\n" msgstr "" -#: windres.c:918 +#: windres.c:980 msgid "no resources" msgstr "" diff --git a/binutils/prdbg.c b/binutils/prdbg.c index 958cbd2..abd684d 100644 --- a/binutils/prdbg.c +++ b/binutils/prdbg.c @@ -1,5 +1,5 @@ /* prdbg.c -- Print out generic debugging information. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -985,7 +985,7 @@ pr_fix_visibility (info, visibility) struct pr_handle *info; enum debug_visibility visibility; { - const char *s; + const char *s = NULL; char *t; unsigned int len; @@ -1602,7 +1602,7 @@ pr_typdef (p, name) static boolean pr_tag (p, name) PTR p; - const char *name; + const char *name ATTRIBUTE_UNUSED; { struct pr_handle *info = (struct pr_handle *) p; char *t; @@ -1856,7 +1856,7 @@ pr_end_block (p, addr) /*ARGSUSED*/ static boolean pr_end_function (p) - PTR p; + PTR p ATTRIBUTE_UNUSED; { return true; } diff --git a/binutils/rclex.l b/binutils/rclex.l index 06a6607..47b479b 100644 --- a/binutils/rclex.l +++ b/binutils/rclex.l @@ -37,6 +37,23 @@ static int rcdata_mode; +/* Whether we are supressing lines from cpp (including windows.h or + headers from your C sources may bring in externs and typedefs). + When active, we return IGNORED_TOKEN, which lets us ignore these + outside of resource constructs. Thus, it isn't required to protect + all the non-preprocessor lines in your header files with #ifdef + RC_INVOKED. It also means your RC file can't include other RC + files if they're named "*.h". Sorry. Name them *.rch or whatever. */ + +static int suppress_cpp_data; + +#define MAYBE_RETURN(x) return suppress_cpp_data ? IGNORED_TOKEN : (x) + +/* The first filename we detect in the cpp output. We use this to + tell included files from the original file. */ + +static char *initial_fn; + /* List of allocated strings. */ struct alloc_string @@ -57,82 +74,82 @@ static char *get_string PARAMS ((int)); %% -"BEGIN" { return BEG; } -"{" { return BEG; } -"END" { return END; } -"}" { return END; } -"ACCELERATORS" { return ACCELERATORS; } -"VIRTKEY" { return VIRTKEY; } -"ASCII" { return ASCII; } -"NOINVERT" { return NOINVERT; } -"SHIFT" { return SHIFT; } -"CONTROL" { return CONTROL; } -"ALT" { return ALT; } -"BITMAP" { return BITMAP; } -"CURSOR" { return CURSOR; } -"DIALOG" { return DIALOG; } -"DIALOGEX" { return DIALOGEX; } -"EXSTYLE" { return EXSTYLE; } -"CAPTION" { return CAPTION; } -"CLASS" { return CLASS; } -"STYLE" { return STYLE; } -"AUTO3STATE" { return AUTO3STATE; } -"AUTOCHECKBOX" { return AUTOCHECKBOX; } -"AUTORADIOBUTTON" { return AUTORADIOBUTTON; } -"CHECKBOX" { return CHECKBOX; } -"COMBOBOX" { return COMBOBOX; } -"CTEXT" { return CTEXT; } -"DEFPUSHBUTTON" { return DEFPUSHBUTTON; } -"EDITTEXT" { return EDITTEXT; } -"GROUPBOX" { return GROUPBOX; } -"LISTBOX" { return LISTBOX; } -"LTEXT" { return LTEXT; } -"PUSHBOX" { return PUSHBOX; } -"PUSHBUTTON" { return PUSHBUTTON; } -"RADIOBUTTON" { return RADIOBUTTON; } -"RTEXT" { return RTEXT; } -"SCROLLBAR" { return SCROLLBAR; } -"STATE3" { return STATE3; } -"USERBUTTON" { return USERBUTTON; } -"BEDIT" { return BEDIT; } -"HEDIT" { return HEDIT; } -"IEDIT" { return IEDIT; } -"FONT" { return FONT; } -"ICON" { return ICON; } -"LANGUAGE" { return LANGUAGE; } -"CHARACTERISTICS" { return CHARACTERISTICS; } -"VERSION" { return VERSIONK; } -"MENU" { return MENU; } -"MENUEX" { return MENUEX; } -"MENUITEM" { return MENUITEM; } -"SEPARATOR" { return SEPARATOR; } -"POPUP" { return POPUP; } -"CHECKED" { return CHECKED; } -"GRAYED" { return GRAYED; } -"HELP" { return HELP; } -"INACTIVE" { return INACTIVE; } -"MENUBARBREAK" { return MENUBARBREAK; } -"MENUBREAK" { return MENUBREAK; } -"MESSAGETABLE" { return MESSAGETABLE; } -"RCDATA" { return RCDATA; } -"STRINGTABLE" { return STRINGTABLE; } -"VERSIONINFO" { return VERSIONINFO; } -"FILEVERSION" { return FILEVERSION; } -"PRODUCTVERSION" { return PRODUCTVERSION; } -"FILEFLAGSMASK" { return FILEFLAGSMASK; } -"FILEFLAGS" { return FILEFLAGS; } -"FILEOS" { return FILEOS; } -"FILETYPE" { return FILETYPE; } -"FILESUBTYPE" { return FILESUBTYPE; } -"VALUE" { return VALUE; } -"MOVEABLE" { return MOVEABLE; } -"FIXED" { return FIXED; } -"PURE" { return PURE; } -"IMPURE" { return IMPURE; } -"PRELOAD" { return PRELOAD; } -"LOADONCALL" { return LOADONCALL; } -"DISCARDABLE" { return DISCARDABLE; } -"NOT" { return NOT; } +"BEGIN" { MAYBE_RETURN (BEG); } +"{" { MAYBE_RETURN (BEG); } +"END" { MAYBE_RETURN (END); } +"}" { MAYBE_RETURN (END); } +"ACCELERATORS" { MAYBE_RETURN (ACCELERATORS); } +"VIRTKEY" { MAYBE_RETURN (VIRTKEY); } +"ASCII" { MAYBE_RETURN (ASCII); } +"NOINVERT" { MAYBE_RETURN (NOINVERT); } +"SHIFT" { MAYBE_RETURN (SHIFT); } +"CONTROL" { MAYBE_RETURN (CONTROL); } +"ALT" { MAYBE_RETURN (ALT); } +"BITMAP" { MAYBE_RETURN (BITMAP); } +"CURSOR" { MAYBE_RETURN (CURSOR); } +"DIALOG" { MAYBE_RETURN (DIALOG); } +"DIALOGEX" { MAYBE_RETURN (DIALOGEX); } +"EXSTYLE" { MAYBE_RETURN (EXSTYLE); } +"CAPTION" { MAYBE_RETURN (CAPTION); } +"CLASS" { MAYBE_RETURN (CLASS); } +"STYLE" { MAYBE_RETURN (STYLE); } +"AUTO3STATE" { MAYBE_RETURN (AUTO3STATE); } +"AUTOCHECKBOX" { MAYBE_RETURN (AUTOCHECKBOX); } +"AUTORADIOBUTTON" { MAYBE_RETURN (AUTORADIOBUTTON); } +"CHECKBOX" { MAYBE_RETURN (CHECKBOX); } +"COMBOBOX" { MAYBE_RETURN (COMBOBOX); } +"CTEXT" { MAYBE_RETURN (CTEXT); } +"DEFPUSHBUTTON" { MAYBE_RETURN (DEFPUSHBUTTON); } +"EDITTEXT" { MAYBE_RETURN (EDITTEXT); } +"GROUPBOX" { MAYBE_RETURN (GROUPBOX); } +"LISTBOX" { MAYBE_RETURN (LISTBOX); } +"LTEXT" { MAYBE_RETURN (LTEXT); } +"PUSHBOX" { MAYBE_RETURN (PUSHBOX); } +"PUSHBUTTON" { MAYBE_RETURN (PUSHBUTTON); } +"RADIOBUTTON" { MAYBE_RETURN (RADIOBUTTON); } +"RTEXT" { MAYBE_RETURN (RTEXT); } +"SCROLLBAR" { MAYBE_RETURN (SCROLLBAR); } +"STATE3" { MAYBE_RETURN (STATE3); } +"USERBUTTON" { MAYBE_RETURN (USERBUTTON); } +"BEDIT" { MAYBE_RETURN (BEDIT); } +"HEDIT" { MAYBE_RETURN (HEDIT); } +"IEDIT" { MAYBE_RETURN (IEDIT); } +"FONT" { MAYBE_RETURN (FONT); } +"ICON" { MAYBE_RETURN (ICON); } +"LANGUAGE" { MAYBE_RETURN (LANGUAGE); } +"CHARACTERISTICS" { MAYBE_RETURN (CHARACTERISTICS); } +"VERSION" { MAYBE_RETURN (VERSIONK); } +"MENU" { MAYBE_RETURN (MENU); } +"MENUEX" { MAYBE_RETURN (MENUEX); } +"MENUITEM" { MAYBE_RETURN (MENUITEM); } +"SEPARATOR" { MAYBE_RETURN (SEPARATOR); } +"POPUP" { MAYBE_RETURN (POPUP); } +"CHECKED" { MAYBE_RETURN (CHECKED); } +"GRAYED" { MAYBE_RETURN (GRAYED); } +"HELP" { MAYBE_RETURN (HELP); } +"INACTIVE" { MAYBE_RETURN (INACTIVE); } +"MENUBARBREAK" { MAYBE_RETURN (MENUBARBREAK); } +"MENUBREAK" { MAYBE_RETURN (MENUBREAK); } +"MESSAGETABLE" { MAYBE_RETURN (MESSAGETABLE); } +"RCDATA" { MAYBE_RETURN (RCDATA); } +"STRINGTABLE" { MAYBE_RETURN (STRINGTABLE); } +"VERSIONINFO" { MAYBE_RETURN (VERSIONINFO); } +"FILEVERSION" { MAYBE_RETURN (FILEVERSION); } +"PRODUCTVERSION" { MAYBE_RETURN (PRODUCTVERSION); } +"FILEFLAGSMASK" { MAYBE_RETURN (FILEFLAGSMASK); } +"FILEFLAGS" { MAYBE_RETURN (FILEFLAGS); } +"FILEOS" { MAYBE_RETURN (FILEOS); } +"FILETYPE" { MAYBE_RETURN (FILETYPE); } +"FILESUBTYPE" { MAYBE_RETURN (FILESUBTYPE); } +"VALUE" { MAYBE_RETURN (VALUE); } +"MOVEABLE" { MAYBE_RETURN (MOVEABLE); } +"FIXED" { MAYBE_RETURN (FIXED); } +"PURE" { MAYBE_RETURN (PURE); } +"IMPURE" { MAYBE_RETURN (IMPURE); } +"PRELOAD" { MAYBE_RETURN (PRELOAD); } +"LOADONCALL" { MAYBE_RETURN (LOADONCALL); } +"DISCARDABLE" { MAYBE_RETURN (DISCARDABLE); } +"NOT" { MAYBE_RETURN (NOT); } "BLOCK"[ \t\n]*"\""[^\#\n]*"\"" { char *s, *send; @@ -146,11 +163,11 @@ static char *get_string PARAMS ((int)); if (strncmp (s, "StringFileInfo", sizeof "StringFileInfo" - 1) == 0 && s + sizeof "StringFileInfo" - 1 == send) - return BLOCKSTRINGFILEINFO; + MAYBE_RETURN (BLOCKSTRINGFILEINFO); else if (strncmp (s, "VarFileInfo", sizeof "VarFileInfo" - 1) == 0 && s + sizeof "VarFileInfo" - 1 == send) - return BLOCKVARFILEINFO; + MAYBE_RETURN (BLOCKVARFILEINFO); else { char *r; @@ -159,7 +176,7 @@ static char *get_string PARAMS ((int)); strncpy (r, s, send - s); r[send - s] = '\0'; yylval.s = r; - return BLOCK; + MAYBE_RETURN (BLOCK); } } @@ -170,13 +187,13 @@ static char *get_string PARAMS ((int)); [0-9][x0-9A-Fa-f]*L { yylval.i.val = strtoul (yytext, 0, 0); yylval.i.dword = 1; - return NUMBER; + MAYBE_RETURN (NUMBER); } [0-9][x0-9A-Fa-f]* { yylval.i.val = strtoul (yytext, 0, 0); yylval.i.dword = 0; - return NUMBER; + MAYBE_RETURN (NUMBER); } ("\""[^\"\n]*"\""[ \t]*)+ { @@ -187,13 +204,13 @@ static char *get_string PARAMS ((int)); if (! rcdata_mode) { yylval.s = s; - return QUOTEDSTRING; + MAYBE_RETURN (QUOTEDSTRING); } else { yylval.ss.length = length; yylval.ss.s = s; - return SIZEDSTRING; + MAYBE_RETURN (SIZEDSTRING); } } @@ -209,12 +226,12 @@ static char *get_string PARAMS ((int)); s = get_string (strlen (yytext) + 1); strcpy (s, yytext); yylval.s = s; - return STRING; + MAYBE_RETURN (STRING); } [\n] { ++rc_lineno; } [ \t\r]+ { /* ignore whitespace */ } -. { return *yytext; } +. { MAYBE_RETURN (*yytext); } %% #ifndef yywrap @@ -263,6 +280,20 @@ cpp_line (s) free (rc_filename); rc_filename = fn; + + if (!initial_fn) + { + initial_fn = xmalloc (strlen (fn) + 1); + strcpy(initial_fn, fn); + } + + /* Allow the initial file, regardless of name. Suppress all other + files if they end in ".h" (this allows included "*.rc") */ + if (strcmp (initial_fn, fn) == 0 + || strcmp (fn + strlen (fn) - 2, ".h") != 0) + suppress_cpp_data = 0; + else + suppress_cpp_data = 1; } /* Handle a quoted string. The quotes are stripped. A pair of quotes diff --git a/binutils/rcparse.y b/binutils/rcparse.y index 67079a5..03cbbdc 100644 --- a/binutils/rcparse.y +++ b/binutils/rcparse.y @@ -122,6 +122,7 @@ static unsigned long class; %token QUOTEDSTRING STRING %token NUMBER %token SIZEDSTRING +%token IGNORED_TOKEN %type acc_entries %type acc_entry acc_event @@ -167,6 +168,7 @@ input: | input newcmd stringtable | input newcmd user | input newcmd versioninfo + | input newcmd IGNORED_TOKEN ; newcmd: diff --git a/binutils/rdcoff.c b/binutils/rdcoff.c index ee68bc6..d1ee6e6 100644 --- a/binutils/rdcoff.c +++ b/binutils/rdcoff.c @@ -1,5 +1,5 @@ /* stabs.c -- Parse COFF debugging information - Copyright (C) 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -498,7 +498,7 @@ static debug_type parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle) bfd *abfd; struct coff_symbols *symbols; - struct coff_types *types; + struct coff_types *types ATTRIBUTE_UNUSED; union internal_auxent *pauxent; PTR dhandle; { @@ -569,7 +569,7 @@ parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle) static boolean parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type, within_function) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct coff_types *types; asymbol *sym; long coff_symno; diff --git a/binutils/rddbg.c b/binutils/rddbg.c index 9428c37..e26056e 100644 --- a/binutils/rddbg.c +++ b/binutils/rddbg.c @@ -185,7 +185,17 @@ read_section_stabs_debugging_info (abfd, syms, symcount, dhandle, pfound) char *f, *s; f = NULL; + + if (stroff + strx > strsize) + { + fprintf (stderr, "%s: %s: stab entry %d is corrupt, strx = 0x%x, type = %d\n", + bfd_get_filename (abfd), names[i].secname, + (stab - stabs) / 12, strx, type); + continue; + } + s = (char *) strings + stroff + strx; + while (s[strlen (s) - 1] == '\\' && stab + 12 < stabs + stabsize) { diff --git a/binutils/readelf.c b/binutils/readelf.c index 549bf1a..cd1e127 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -1,5 +1,5 @@ /* readelf.c -- display contents of an ELF format file - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2000 Free Software Foundation, Inc. Originally developed by Eric Youngdale Modifications by Nick Clifton @@ -23,10 +23,19 @@ #include +#include #include #include #include +#if __GNUC__ >= 2 +/* Define BFD64 here, even if our default architecture is 32 bit ELF + as this will allow us to read in and parse 64bit and 32bit ELF files. + Only do this if we belive that the compiler can support a 64 bit + data type. For now we only rely on GCC being able to do this. */ +#define BFD64 +#endif + #include "bfd.h" #include "elf/common.h" @@ -58,6 +67,9 @@ #include "elf/arc.h" #include "elf/fr30.h" #include "elf/mcore.h" +#include "elf/i960.h" +#include "elf/pj.h" +#include "elf/avr.h" #include "bucomm.h" #include "getopt.h" @@ -70,11 +82,12 @@ char * program_name = "readelf"; unsigned int dynamic_addr; -unsigned int dynamic_size; +bfd_size_type dynamic_size; unsigned int rela_addr; unsigned int rela_size; char * dynamic_strings; char * string_table; +unsigned long num_dynamic_syms; Elf_Internal_Sym * dynamic_symbols; Elf_Internal_Syminfo * dynamic_syminfo; unsigned long dynamic_syminfo_offset; @@ -103,7 +116,9 @@ int do_debug_abbrevs; int do_debug_lines; int do_debug_pubnames; int do_debug_aranges; -int binary_class; +int do_arch; +int do_notes; +int is_32bit_elf; /* A dynamic array of flags indicating which sections require dumping. */ char * dump_sects = NULL; @@ -113,39 +128,67 @@ unsigned int num_dump_sects = 0; #define DISASS_DUMP (1 << 1) #define DEBUG_DUMP (1 << 2) +/* How to rpint a vma value. */ +typedef enum print_mode +{ + HEX, + DEC, + DEC_5, + UNSIGNED, + PREFIX_HEX, + FULL_HEX, + LONG_HEX +} +print_mode; + /* Forward declarations for dumb compilers. */ -static unsigned long (* byte_get) PARAMS ((unsigned char *, int)); -static const char * get_mips_dynamic_type PARAMS ((unsigned long type)); -static const char * get_dynamic_type PARAMS ((unsigned long type)); -static int dump_relocations PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym *, char *)); -static char * get_file_type PARAMS ((unsigned e_type)); -static char * get_machine_name PARAMS ((unsigned e_machine)); -static char * get_machine_data PARAMS ((unsigned e_data)); -static char * get_machine_flags PARAMS ((unsigned, unsigned e_machine)); -static const char * get_mips_segment_type PARAMS ((unsigned long type)); -static const char * get_segment_type PARAMS ((unsigned long p_type)); -static const char * get_mips_section_type_name PARAMS ((unsigned int sh_type)); -static const char * get_section_type_name PARAMS ((unsigned int sh_type)); -static char * get_symbol_binding PARAMS ((unsigned int binding)); -static char * get_symbol_type PARAMS ((unsigned int type)); +static void print_vma PARAMS ((bfd_vma, print_mode)); +static bfd_vma (* byte_get) PARAMS ((unsigned char *, int)); +static bfd_vma byte_get_little_endian PARAMS ((unsigned char *, int)); +static bfd_vma byte_get_big_endian PARAMS ((unsigned char *, int)); +static const char * get_mips_dynamic_type PARAMS ((unsigned long)); +static const char * get_sparc64_dynamic_type PARAMS ((unsigned long)); +static const char * get_parisc_dynamic_type PARAMS ((unsigned long)); +static const char * get_dynamic_type PARAMS ((unsigned long)); +static int dump_relocations PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym *, unsigned long, char *, int)); +static char * get_file_type PARAMS ((unsigned)); +static char * get_machine_name PARAMS ((unsigned)); +static char * get_machine_flags PARAMS ((unsigned, unsigned)); +static const char * get_mips_segment_type PARAMS ((unsigned long)); +static const char * get_parisc_segment_type PARAMS ((unsigned long)); +static const char * get_segment_type PARAMS ((unsigned long)); +static const char * get_mips_section_type_name PARAMS ((unsigned int)); +static const char * get_parisc_section_type_name PARAMS ((unsigned int)); +static const char * get_section_type_name PARAMS ((unsigned int)); +static const char * get_symbol_binding PARAMS ((unsigned int)); +static const char * get_symbol_type PARAMS ((unsigned int)); +static const char * get_symbol_visibility PARAMS ((unsigned int)); +static const char * get_symbol_index_type PARAMS ((unsigned int)); +static const char * get_dynamic_flags PARAMS ((bfd_vma)); static void usage PARAMS ((void)); -static void parse_args PARAMS ((int argc, char ** argv)); +static void parse_args PARAMS ((int, char **)); static int process_file_header PARAMS ((void)); static int process_program_headers PARAMS ((FILE *)); static int process_section_headers PARAMS ((FILE *)); -static void dynamic_segment_mips_val PARAMS ((Elf_Internal_Dyn *entry)); +static void dynamic_segment_mips_val PARAMS ((Elf_Internal_Dyn *)); +static void dynamic_segment_parisc_val PARAMS ((Elf_Internal_Dyn *)); static int process_dynamic_segment PARAMS ((FILE *)); static int process_symbol_table PARAMS ((FILE *)); static int process_section_contents PARAMS ((FILE *)); -static void process_file PARAMS ((char * file_name)); +static void process_file PARAMS ((char *)); static int process_relocs PARAMS ((FILE *)); static int process_version_sections PARAMS ((FILE *)); -static char * get_ver_flags PARAMS ((unsigned int flags)); -static char * get_symbol_index_type PARAMS ((unsigned int type)); -static int get_section_headers PARAMS ((FILE * file)); -static int get_file_header PARAMS ((FILE * file)); -static Elf_Internal_Sym * get_elf_symbols PARAMS ((FILE * file, unsigned long offset, unsigned long number)); -static int * get_dynamic_data PARAMS ((FILE * file, unsigned int number)); +static char * get_ver_flags PARAMS ((unsigned int)); +static int get_32bit_section_headers PARAMS ((FILE *)); +static int get_64bit_section_headers PARAMS ((FILE *)); +static int get_32bit_program_headers PARAMS ((FILE *, Elf_Internal_Phdr *)); +static int get_64bit_program_headers PARAMS ((FILE *, Elf_Internal_Phdr *)); +static int get_file_header PARAMS ((FILE *)); +static Elf_Internal_Sym * get_32bit_elf_symbols PARAMS ((FILE *, unsigned long, unsigned long)); +static Elf_Internal_Sym * get_64bit_elf_symbols PARAMS ((FILE *, unsigned long, unsigned long)); +static int * get_dynamic_data PARAMS ((FILE *, unsigned int)); +static int get_32bit_dynamic_segment PARAMS ((FILE *)); +static int get_64bit_dynamic_segment PARAMS ((FILE *)); #ifdef SUPPORT_DISASSEMBLY static int disassemble_section PARAMS ((Elf32_Internal_Shdr *, FILE *)); #endif @@ -158,7 +201,7 @@ static int display_debug_abbrev PARAMS ((Elf32_Internal_Sh static int display_debug_aranges PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *)); static unsigned char * process_abbrev_section PARAMS ((unsigned char *, unsigned char *)); static unsigned long read_leb128 PARAMS ((unsigned char *, int *, int)); -static int process_extended_line_op PARAMS ((unsigned char *, int)); +static int process_extended_line_op PARAMS ((unsigned char *, int, int)); static void reset_state_machine PARAMS ((int)); static char * get_TAG_name PARAMS ((unsigned long)); static char * get_AT_name PARAMS ((unsigned long)); @@ -173,15 +216,41 @@ static void request_dump PARAMS ((unsigned int, char)); static const char * get_elf_class PARAMS ((unsigned char)); static const char * get_data_encoding PARAMS ((unsigned char)); static const char * get_osabi_name PARAMS ((unsigned char)); +static int guess_is_rela PARAMS ((unsigned long)); +static char * get_note_type PARAMS ((unsigned int)); +static int process_note PARAMS ((Elf32_Internal_Note *)); +static int process_corefile_note_segment PARAMS ((FILE *, bfd_vma, bfd_vma)); +static int process_corefile_note_segments PARAMS ((FILE *)); +static int process_corefile_contents PARAMS ((FILE *)); typedef int Elf32_Word; +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif +#define UNKNOWN -1 + #define SECTION_NAME(X) (string_table + (X)->sh_name) #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ #define BYTE_GET(field) byte_get (field, sizeof (field)) +/* If we can support a 64 bit data type then BFD64 should be defined + and sizeof (bfd_vma) == 8. In this case when translating from an + external 8 byte field to an internal field, we can assume that the + internal field is also 8 bytes wide and so we can extact all the data. + If, however, BFD64 is not defined, then we must assume that the + internal data structure only has 4 byte wide fields that are the + equivalent of the 8 byte wide external counterparts, and so we must + truncate the data. */ +#ifdef BFD64 +#define BYTE_GET8(field) byte_get (field, -8) +#else +#define BYTE_GET8(field) byte_get (field, 8) +#endif + #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0])) #define GET_DATA_ALLOC(offset, size, var, type, reason) \ @@ -220,6 +289,11 @@ typedef int Elf32_Word; return 0; \ } +#define GET_ELF_SYMBOLS(file, offset, size) \ + (is_32bit_elf ? get_32bit_elf_symbols (file, offset, size) \ + : get_64bit_elf_symbols (file, offset, size)) + + #ifdef ANSI_PROTOTYPES static void error (const char * message, ...) @@ -276,7 +350,7 @@ warn (va_alist) } #endif -static unsigned long int +static bfd_vma byte_get_little_endian (field, size) unsigned char * field; int size; @@ -290,19 +364,128 @@ byte_get_little_endian (field, size) return ((unsigned int) (field [0])) | (((unsigned int) (field [1])) << 8); + case 8: + /* We want to extract data from an 8 byte wide field and + place it into a 4 byte wide field. Since this is a little + endian source we can juts use the 4 byte extraction code. */ + /* Fall through. */ case 4: return ((unsigned long) (field [0])) | (((unsigned long) (field [1])) << 8) | (((unsigned long) (field [2])) << 16) | (((unsigned long) (field [3])) << 24); +#ifdef BFD64 + case -8: + /* This is a special case, generated by the BYTE_GET8 macro. + It means that we are loading an 8 byte value from a field + in an external structure into an 8 byte value in a field + in an internal strcuture. */ + return ((bfd_vma) (field [0])) + | (((bfd_vma) (field [1])) << 8) + | (((bfd_vma) (field [2])) << 16) + | (((bfd_vma) (field [3])) << 24) + | (((bfd_vma) (field [4])) << 32) + | (((bfd_vma) (field [5])) << 40) + | (((bfd_vma) (field [6])) << 48) + | (((bfd_vma) (field [7])) << 56); +#endif default: error (_("Unhandled data length: %d\n"), size); - abort(); + abort (); } } -static unsigned long int +/* Print a VMA value. */ +static void +print_vma (vma, mode) + bfd_vma vma; + print_mode mode; +{ +#ifdef BFD64 + if (is_32bit_elf) +#endif + { + switch (mode) + { + case FULL_HEX: printf ("0x"); /* drop through */ + case LONG_HEX: printf ("%8.8lx", (unsigned long) vma); break; + case PREFIX_HEX: printf ("0x"); /* drop through */ + case HEX: printf ("%lx", (unsigned long) vma); break; + case DEC: printf ("%ld", (unsigned long) vma); break; + case DEC_5: printf ("%5ld", (long) vma); break; + case UNSIGNED: printf ("%lu", (unsigned long) vma); break; + } + } +#ifdef BFD64 + else + { + switch (mode) + { + case FULL_HEX: + printf ("0x"); + /* drop through */ + + case LONG_HEX: + printf_vma (vma); + break; + + case PREFIX_HEX: + printf ("0x"); + /* drop through */ + + case HEX: +#if BFD_HOST_64BIT_LONG + printf ("%lx", vma); +#else + if (_bfd_int64_high (vma)) + printf ("%lx%lx", _bfd_int64_high (vma), _bfd_int64_low (vma)); + else + printf ("%lx", _bfd_int64_low (vma)); +#endif + break; + + case DEC: +#if BFD_HOST_64BIT_LONG + printf ("%ld", vma); +#else + if (_bfd_int64_high (vma)) + /* ugg */ + printf ("++%ld", _bfd_int64_low (vma)); + else + printf ("%ld", _bfd_int64_low (vma)); +#endif + break; + + case DEC_5: +#if BFD_HOST_64BIT_LONG + printf ("%5ld", vma); +#else + if (_bfd_int64_high (vma)) + /* ugg */ + printf ("++%ld", _bfd_int64_low (vma)); + else + printf ("%5ld", _bfd_int64_low (vma)); +#endif + break; + + case UNSIGNED: +#if BFD_HOST_64BIT_LONG + printf ("%lu", vma); +#else + if (_bfd_int64_high (vma)) + /* ugg */ + printf ("++%lu", _bfd_int64_low (vma)); + else + printf ("%lu", _bfd_int64_low (vma)); +#endif + break; + } + } +#endif +} + +static bfd_vma byte_get_big_endian (field, size) unsigned char * field; int size; @@ -321,66 +504,59 @@ byte_get_big_endian (field, size) | (((unsigned long) (field [1])) << 16) | (((unsigned long) (field [0])) << 24); + case 8: + /* Although we are extracing data from an 8 byte wide field, we + are returning only 4 bytes of data. */ + return ((unsigned long) (field [7])) + | (((unsigned long) (field [6])) << 8) + | (((unsigned long) (field [5])) << 16) + | (((unsigned long) (field [4])) << 24); + +#ifdef BFD64 + case -8: + /* This is a special case, generated by the BYTE_GET8 macro. + It means that we are loading an 8 byte value from a field + in an external structure into an 8 byte value in a field + in an internal strcuture. */ + return ((bfd_vma) (field [7])) + | (((bfd_vma) (field [6])) << 8) + | (((bfd_vma) (field [5])) << 16) + | (((bfd_vma) (field [4])) << 24) + | (((bfd_vma) (field [3])) << 32) + | (((bfd_vma) (field [2])) << 40) + | (((bfd_vma) (field [1])) << 48) + | (((bfd_vma) (field [0])) << 56); +#endif + default: error (_("Unhandled data length: %d\n"), size); - abort(); + abort (); } } -/* Display the contents of the relocation data - found at the specified offset. */ +/* Guess the relocation sized based on the sized commonly used by the specific machine. */ static int -dump_relocations (file, rel_offset, rel_size, symtab, strtab) - FILE * file; - unsigned long rel_offset; - unsigned long rel_size; - Elf_Internal_Sym * symtab; - char * strtab; +guess_is_rela (e_machine) + unsigned long e_machine; { - unsigned int i; - int is_rela; - Elf_Internal_Rel * rels; - Elf_Internal_Rela * relas; - - - /* Compute number of relocations and read them in. */ - switch (elf_header.e_machine) + switch (e_machine) { /* Targets that use REL relocations. */ case EM_ARM: case EM_386: case EM_486: + case EM_960: case EM_CYGNUS_M32R: case EM_CYGNUS_D10V: case EM_MIPS: case EM_MIPS_RS4_BE: - { - Elf32_External_Rel * erels; - - GET_DATA_ALLOC (rel_offset, rel_size, erels, - Elf32_External_Rel *, "relocs"); - - rel_size = rel_size / sizeof (Elf32_External_Rel); - - rels = (Elf_Internal_Rel *) malloc (rel_size * - sizeof (Elf_Internal_Rel)); - - for (i = 0; i < rel_size; i++) - { - rels[i].r_offset = BYTE_GET (erels[i].r_offset); - rels[i].r_info = BYTE_GET (erels[i].r_info); - } - - free (erels); - - is_rela = 0; - relas = (Elf_Internal_Rela *) rels; - } - break; + return FALSE; /* Targets that use RELA relocations. */ case EM_68K: + case EM_SPARC32PLUS: + case EM_SPARCV9: case EM_SPARC: case EM_PPC: case EM_CYGNUS_V850: @@ -391,34 +567,170 @@ dump_relocations (file, rel_offset, rel_size, symtab, strtab) case EM_SH: case EM_ALPHA: case EM_MCORE: - { - Elf32_External_Rela * erelas; + return TRUE; + + case EM_MMA: + case EM_PCP: + case EM_NCPU: + case EM_NDR1: + case EM_STARCORE: + case EM_ME16: + case EM_ST100: + case EM_TINYJ: + case EM_FX66: + case EM_ST9PLUS: + case EM_ST7: + case EM_68HC16: + case EM_68HC11: + case EM_68HC08: + case EM_68HC05: + case EM_SVX: + case EM_ST19: + case EM_VAX: + default: + warn (_("Don't know about relocations on this machine architecture\n")); + return FALSE; + } +} - GET_DATA_ALLOC (rel_offset, rel_size, erelas, - Elf32_External_Rela *, "relocs"); +/* Display the contents of the relocation data found at the specified offset. */ +static int +dump_relocations (file, rel_offset, rel_size, symtab, nsyms, strtab, is_rela) + FILE * file; + unsigned long rel_offset; + unsigned long rel_size; + Elf_Internal_Sym * symtab; + unsigned long nsyms; + char * strtab; + int is_rela; +{ + unsigned int i; + Elf_Internal_Rel * rels; + Elf_Internal_Rela * relas; - rel_size = rel_size / sizeof (Elf32_External_Rela); - relas = (Elf_Internal_Rela *) malloc (rel_size * - sizeof (Elf_Internal_Rela)); + if (is_rela == UNKNOWN) + is_rela = guess_is_rela (elf_header.e_machine); - for (i = 0; i < rel_size; i++) - { - relas[i].r_offset = BYTE_GET (erelas[i].r_offset); - relas[i].r_info = BYTE_GET (erelas[i].r_info); - relas[i].r_addend = BYTE_GET (erelas[i].r_addend); - } + if (is_rela) + { + if (is_32bit_elf) + { + Elf32_External_Rela * erelas; - free (erelas); + GET_DATA_ALLOC (rel_offset, rel_size, erelas, + Elf32_External_Rela *, "relocs"); - is_rela = 1; - rels = (Elf_Internal_Rel *) relas; - } - break; + rel_size = rel_size / sizeof (Elf32_External_Rela); - default: - warn (_("Don't know about relocations on this machine architecture\n")); - return 0; + relas = (Elf_Internal_Rela *) + malloc (rel_size * sizeof (Elf_Internal_Rela)); + + if (relas == NULL) + { + error(_("out of memory parsing relocs")); + return 0; + } + + for (i = 0; i < rel_size; i++) + { + relas[i].r_offset = BYTE_GET (erelas[i].r_offset); + relas[i].r_info = BYTE_GET (erelas[i].r_info); + relas[i].r_addend = BYTE_GET (erelas[i].r_addend); + } + + free (erelas); + + rels = (Elf_Internal_Rel *) relas; + } + else + { + Elf64_External_Rela * erelas; + + GET_DATA_ALLOC (rel_offset, rel_size, erelas, + Elf64_External_Rela *, "relocs"); + + rel_size = rel_size / sizeof (Elf64_External_Rela); + + relas = (Elf_Internal_Rela *) + malloc (rel_size * sizeof (Elf_Internal_Rela)); + + if (relas == NULL) + { + error(_("out of memory parsing relocs")); + return 0; + } + + for (i = 0; i < rel_size; i++) + { + relas[i].r_offset = BYTE_GET8 (erelas[i].r_offset); + relas[i].r_info = BYTE_GET8 (erelas[i].r_info); + relas[i].r_addend = BYTE_GET8 (erelas[i].r_addend); + } + + free (erelas); + + rels = (Elf_Internal_Rel *) relas; + } + } + else + { + if (is_32bit_elf) + { + Elf32_External_Rel * erels; + + GET_DATA_ALLOC (rel_offset, rel_size, erels, + Elf32_External_Rel *, "relocs"); + + rel_size = rel_size / sizeof (Elf32_External_Rel); + + rels = (Elf_Internal_Rel *) + malloc (rel_size * sizeof (Elf_Internal_Rel)); + + if (rels == NULL) + { + error(_("out of memory parsing relocs")); + return 0; + } + + for (i = 0; i < rel_size; i++) + { + rels[i].r_offset = BYTE_GET (erels[i].r_offset); + rels[i].r_info = BYTE_GET (erels[i].r_info); + } + + free (erels); + + relas = (Elf_Internal_Rela *) rels; + } + else + { + Elf64_External_Rel * erels; + + GET_DATA_ALLOC (rel_offset, rel_size, erels, + Elf64_External_Rel *, "relocs"); + + rel_size = rel_size / sizeof (Elf64_External_Rel); + + rels = (Elf_Internal_Rel *) + malloc (rel_size * sizeof (Elf_Internal_Rel)); + + if (rels == NULL) + { + error(_("out of memory parsing relocs")); + return 0; + } + + for (i = 0; i < rel_size; i++) + { + rels[i].r_offset = BYTE_GET8 (erels[i].r_offset); + rels[i].r_info = BYTE_GET8 (erels[i].r_info); + } + + free (erels); + + relas = (Elf_Internal_Rela *) rels; + } } if (is_rela) @@ -430,10 +742,11 @@ dump_relocations (file, rel_offset, rel_size, symtab, strtab) for (i = 0; i < rel_size; i++) { - const char * rtype; - unsigned long offset; - unsigned long info; - int symtab_index; + const char * rtype; + bfd_vma offset; + bfd_vma info; + bfd_vma symtab_index; + bfd_vma type; if (is_rela) { @@ -446,7 +759,30 @@ dump_relocations (file, rel_offset, rel_size, symtab, strtab) info = rels [i].r_info; } + if (is_32bit_elf) + { + type = ELF32_R_TYPE (info); + symtab_index = ELF32_R_SYM (info); + } + else + { + if (elf_header.e_machine == EM_SPARCV9) + type = ELF64_R_TYPE_ID (info); + else + type = ELF64_R_TYPE (info); + /* The #ifdef BFD64 below is to prevent a compile time warning. + We know that if we do not have a 64 bit data type that we + will never execute this code anyway. */ +#ifdef BFD64 + symtab_index = ELF64_R_SYM (info); +#endif + } + +#ifdef _bfd_int64_low + printf (" %8.8lx %5.5lx ", _bfd_int64_low (offset), _bfd_int64_low (info)); +#else printf (" %8.8lx %5.5lx ", offset, info); +#endif switch (elf_header.e_machine) { @@ -455,107 +791,143 @@ dump_relocations (file, rel_offset, rel_size, symtab, strtab) break; case EM_CYGNUS_M32R: - rtype = elf_m32r_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_m32r_reloc_type (type); break; case EM_386: case EM_486: - rtype = elf_i386_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_i386_reloc_type (type); break; case EM_68K: - rtype = elf_m68k_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_m68k_reloc_type (type); + break; + + case EM_960: + rtype = elf_i960_reloc_type (type); break; + case EM_AVR: + rtype = elf_avr_reloc_type (type); + break; + + case EM_OLD_SPARCV9: + case EM_SPARC32PLUS: + case EM_SPARCV9: case EM_SPARC: - rtype = elf_sparc_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_sparc_reloc_type (type); break; case EM_CYGNUS_V850: - rtype = v850_reloc_type (ELF32_R_TYPE (info)); + rtype = v850_reloc_type (type); break; case EM_CYGNUS_D10V: - rtype = elf_d10v_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_d10v_reloc_type (type); break; case EM_CYGNUS_D30V: - rtype = elf_d30v_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_d30v_reloc_type (type); break; case EM_SH: - rtype = elf_sh_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_sh_reloc_type (type); break; case EM_CYGNUS_MN10300: - rtype = elf_mn10300_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_mn10300_reloc_type (type); break; case EM_CYGNUS_MN10200: - rtype = elf_mn10200_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_mn10200_reloc_type (type); break; case EM_CYGNUS_FR30: - rtype = elf_fr30_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_fr30_reloc_type (type); break; case EM_MCORE: - rtype = elf_mcore_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_mcore_reloc_type (type); break; case EM_PPC: - rtype = elf_ppc_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_ppc_reloc_type (type); break; case EM_MIPS: case EM_MIPS_RS4_BE: - rtype = elf_mips_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_mips_reloc_type (type); break; case EM_ALPHA: - rtype = elf_alpha_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_alpha_reloc_type (type); break; case EM_ARM: - rtype = elf_arm_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_arm_reloc_type (type); break; case EM_CYGNUS_ARC: - rtype = elf_arc_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_arc_reloc_type (type); break; case EM_PARISC: - rtype = elf32_hppa_reloc_type (ELF32_R_TYPE (info)); + rtype = elf_hppa_reloc_type (type); + break; + + case EM_PJ: + rtype = elf_pj_reloc_type (type); break; } if (rtype == NULL) - printf (_("unrecognised: %-7lx"), ELF32_R_TYPE (info)); +#ifdef _bfd_int64_low + printf (_("unrecognised: %-7lx"), _bfd_int64_low (type)); +#else + printf (_("unrecognised: %-7lx"), type); +#endif else printf ("%-21.21s", rtype); - symtab_index = ELF32_R_SYM (info); - - if (symtab_index && symtab != NULL) + if (symtab_index) { - Elf_Internal_Sym * psym; + if (symtab != NULL) + { + if (symtab_index >= nsyms) + printf (" bad symbol index: %08lx", (unsigned long) symtab_index); + else + { + Elf_Internal_Sym * psym; - psym = symtab + symtab_index; + psym = symtab + symtab_index; - printf (" %08lx ", (unsigned long) psym->st_value); + printf (" "); + print_vma (psym->st_value, LONG_HEX); + printf (" "); - if (psym->st_name == 0) - printf ("%-25.25s", - SECTION_NAME (section_headers + psym->st_shndx)); - else if (strtab == NULL) - printf (_(""), psym->st_name); - else - printf ("%-25.25s", strtab + psym->st_name); + if (psym->st_name == 0) + printf ("%-25.25s", + SECTION_NAME (section_headers + psym->st_shndx)); + else if (strtab == NULL) + printf (_(""), psym->st_name); + else + printf ("%-25.25s", strtab + psym->st_name); - if (is_rela) - printf (" + %lx", (unsigned long) relas [i].r_addend); + if (is_rela) + printf (" + %lx", (unsigned long) relas [i].r_addend); + } + } + } + else if (is_rela) + { + printf ("%*c", is_32bit_elf ? 34 : 26, ' '); + print_vma (relas[i].r_addend, LONG_HEX); } + if (elf_header.e_machine == EM_SPARCV9 + && !strcmp (rtype, "R_SPARC_OLO10")) + printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info)); + putchar ('\n'); } @@ -619,6 +991,42 @@ get_mips_dynamic_type (type) } static const char * +get_sparc64_dynamic_type (type) + unsigned long type; +{ + switch (type) + { + case DT_SPARC_REGISTER: return "SPARC_REGISTER"; + default: + return NULL; + } +} + +static const char * +get_parisc_dynamic_type (type) + unsigned long type; +{ + switch (type) + { + case DT_HP_LOAD_MAP: return "HP_LOAD_MAP"; + case DT_HP_DLD_FLAGS: return "HP_DLD_FLAGS"; + case DT_HP_DLD_HOOK: return "HP_DLD_HOOK"; + case DT_HP_UX10_INIT: return "HP_UX10_INIT"; + case DT_HP_UX10_INITSZ: return "HP_UX10_INITSZ"; + case DT_HP_PREINIT: return "HP_PREINIT"; + case DT_HP_PREINITSZ: return "HP_PREINITSZ"; + case DT_HP_NEEDED: return "HP_NEEDED"; + case DT_HP_TIME_STAMP: return "HP_TIME_STAMP"; + case DT_HP_CHECKSUM: return "HP_CHECKSUM"; + case DT_HP_GST_SIZE: return "HP_GST_SIZE"; + case DT_HP_GST_VERSION: return "HP_GST_VERSION"; + case DT_HP_GST_HASHVAL: return "HP_GST_HASHVAL"; + default: + return NULL; + } +} + +static const char * get_dynamic_type (type) unsigned long type; { @@ -655,7 +1063,12 @@ get_dynamic_type (type) case DT_FINI_ARRAY: return "FINI_ARRAY"; case DT_INIT_ARRAYSZ: return "INIT_ARRAYSZ"; case DT_FINI_ARRAYSZ: return "FINI_ARRAYSZ"; - + case DT_RUNPATH: return "RUNPATH"; + case DT_FLAGS: return "FLAGS"; + + case DT_PREINIT_ARRAY: return "PREINIT_ARRAY"; + case DT_PREINIT_ARRAYSZ: return "PREINIT_ARRAYSZ"; + case DT_PLTPADSZ: return "PLTPADSZ"; case DT_MOVEENT: return "MOVEENT"; case DT_MOVESZ: return "MOVESZ"; @@ -663,12 +1076,12 @@ get_dynamic_type (type) case DT_POSFLAG_1: return "POSFLAG_1"; case DT_SYMINSZ: return "SYMINSZ"; case DT_SYMINENT: return "SYMINENT"; /* aka VALRNGHI */ - + case DT_ADDRRNGLO: return "ADDRRNGLO"; case DT_SYMINFO: return "SYMINFO"; /* aka ADDRRNGHI */ - + case DT_VERSYM: return "VERSYM"; - + case DT_RELACOUNT: return "RELACOUNT"; case DT_RELCOUNT: return "RELCOUNT"; case DT_FLAGS_1: return "FLAGS_1"; @@ -676,22 +1089,25 @@ get_dynamic_type (type) case DT_VERDEFNUM: return "VERDEFNUM"; case DT_VERNEED: return "VERNEED"; case DT_VERNEEDNUM: return "VERNEEDNUM"; - + case DT_AUXILIARY: return "AUXILARY"; case DT_USED: return "USED"; case DT_FILTER: return "FILTER"; - + default: if ((type >= DT_LOPROC) && (type <= DT_HIPROC)) { const char * result; - + switch (elf_header.e_machine) { case EM_MIPS: case EM_MIPS_RS4_BE: result = get_mips_dynamic_type (type); break; + case EM_SPARCV9: + result = get_sparc64_dynamic_type (type); + break; default: result = NULL; break; @@ -703,10 +1119,27 @@ get_dynamic_type (type) sprintf (buff, _("Processor Specific: %lx"), type); } else if ((type >= DT_LOOS) && (type <= DT_HIOS)) - sprintf (buff, _("Operating System specific: %lx"), type); + { + const char * result; + + switch (elf_header.e_machine) + { + case EM_PARISC: + result = get_parisc_dynamic_type (type); + break; + default: + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, _("Operating System specific: %lx"), type); + } else sprintf (buff, _(": %lx"), type); - + return buff; } } @@ -740,7 +1173,7 @@ static char * get_machine_name (e_machine) unsigned e_machine; { - static char buff [32]; + static char buff [64]; /* XXX */ switch (e_machine) { @@ -752,8 +1185,8 @@ get_machine_name (e_machine) case EM_88K: return "MC88000"; case EM_486: return "Intel 80486"; case EM_860: return "Intel 80860"; - case EM_MIPS: return "MIPS R3000 big-endian"; - case EM_S370: return "Amdahl"; + case EM_MIPS: return "MIPS R3000"; + case EM_S370: return "IBM System/370"; case EM_MIPS_RS4_BE: return "MIPS R4000 big-endian"; case EM_OLD_SPARCV9: return "Sparc v9 (old)"; case EM_PARISC: return "HPPA"; @@ -775,7 +1208,7 @@ get_machine_name (e_machine) case EM_H8_300H: return "Hitachi H8/300H"; case EM_H8S: return "Hitachi H8S"; case EM_H8_500: return "Hitachi H8/500"; - case EM_IA_64: return "Intel Merced"; + case EM_IA_64: return "Intel IA-64"; case EM_MIPS_X: return "Stanford MIPS-X"; case EM_COLDFIRE: return "Motorola Coldfire"; case EM_68HC12: return "Motorola M68HC12"; @@ -788,7 +1221,25 @@ get_machine_name (e_machine) case EM_CYGNUS_MN10300: return "mn10300"; case EM_CYGNUS_MN10200: return "mn10200"; case EM_CYGNUS_FR30: return "Fujitsu FR30"; - + case EM_PJ: return "picoJava"; + case EM_MMA: return "Fujitsu Multimedia Accelerator"; + case EM_PCP: return "Siemens PCP"; + case EM_NCPU: return "Sony nCPU embedded RISC processor"; + case EM_NDR1: return "Denso NDR1 microprocesspr"; + case EM_STARCORE: return "Motorola Star*Core processor"; + case EM_ME16: return "Toyota ME16 processor"; + case EM_ST100: return "STMicroelectronics ST100 processor"; + case EM_TINYJ: return "Advanced Logic Corp. TinyJ embedded processor"; + case EM_FX66: return "Siemens FX66 microcontroller"; + case EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller"; + case EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller"; + case EM_68HC16: return "Motorola MC68HC16 Microcontroller"; + case EM_68HC11: return "Motorola MC68HC11 Microcontroller"; + case EM_68HC08: return "Motorola MC68HC08 Microcontroller"; + case EM_68HC05: return "Motorola MC68HC05 Microcontroller"; + case EM_SVX: return "Silicon Graphics SVx"; + case EM_ST19: return "STMicroelectronics ST19 8-bit microcontroller"; + case EM_VAX: return "Digital VAX"; default: sprintf (buff, _(": %x"), e_machine); return buff; @@ -803,6 +1254,7 @@ get_machine_flags (e_flags, e_machine) static char buf [1024]; buf[0] = '\0'; + if (e_flags) { switch (e_machine) @@ -810,6 +1262,11 @@ get_machine_flags (e_flags, e_machine) default: break; + case EM_68K: + if (e_flags & EF_CPU32) + strcat (buf, ", cpu32"); + break; + case EM_PPC: if (e_flags & EF_PPC_EMB) strcat (buf, ", emb"); @@ -871,26 +1328,73 @@ get_machine_flags (e_flags, e_machine) if ((e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4) strcat (buf, ", mips4"); break; - } - } - return buf; -} + case EM_SPARCV9: + if (e_flags & EF_SPARC_32PLUS) + strcat (buf, ", v8+"); -static char * -get_machine_data (e_data) - unsigned e_data; -{ - static char buff [32]; + if (e_flags & EF_SPARC_SUN_US1) + strcat (buf, ", ultrasparcI"); - switch (e_data) - { - case ELFDATA2LSB: return _("ELFDATA2LSB (little endian)"); - case ELFDATA2MSB: return _("ELFDATA2MSB (big endian)"); - default: - sprintf (buff, _(": %x"), e_data); - return buff; + if (e_flags & EF_SPARC_SUN_US3) + strcat (buf, ", ultrasparcIII"); + + if (e_flags & EF_SPARC_HAL_R1) + strcat (buf, ", halr1"); + + if (e_flags & EF_SPARC_LEDATA) + strcat (buf, ", ledata"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_TSO) + strcat (buf, ", tso"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_PSO) + strcat (buf, ", pso"); + + if ((e_flags & EF_SPARCV9_MM) == EF_SPARCV9_RMO) + strcat (buf, ", rmo"); + break; + + case EM_PARISC: + switch (e_flags & EF_PARISC_ARCH) + { + case EFA_PARISC_1_0: + strcpy (buf, ", PA-RISC 1.0"); + break; + case EFA_PARISC_1_1: + strcpy (buf, ", PA-RISC 1.1"); + break; + case EFA_PARISC_2_0: + strcpy (buf, ", PA-RISC 2.0"); + break; + default: + break; + } + if (e_flags & EF_PARISC_TRAPNIL) + strcat (buf, ", trapnil"); + if (e_flags & EF_PARISC_EXT) + strcat (buf, ", ext"); + if (e_flags & EF_PARISC_LSB) + strcat (buf, ", lsb"); + if (e_flags & EF_PARISC_WIDE) + strcat (buf, ", wide"); + if (e_flags & EF_PARISC_NO_KABP) + strcat (buf, ", no kabp"); + if (e_flags & EF_PARISC_LAZYSWAP) + strcat (buf, ", lazyswap"); + break; + + case EM_PJ: + if ((e_flags & EF_PICOJAVA_NEWCALLS) == EF_PICOJAVA_NEWCALLS) + strcat (buf, ", new calling convention"); + + if ((e_flags & EF_PICOJAVA_GNUCALLS) == EF_PICOJAVA_GNUCALLS) + strcat (buf, ", gnu calling convention"); + break; + } } + + return buf; } static const char * @@ -913,6 +1417,33 @@ get_mips_segment_type (type) } static const char * +get_parisc_segment_type (type) + unsigned long type; +{ + switch (type) + { + case PT_HP_TLS: return "HP_TLS"; + case PT_HP_CORE_NONE: return "HP_CORE_NONE"; + case PT_HP_CORE_VERSION: return "HP_CORE_VERSION"; + case PT_HP_CORE_KERNEL: return "HP_CORE_KERNEL"; + case PT_HP_CORE_COMM: return "HP_CORE_COMM"; + case PT_HP_CORE_PROC: return "HP_CORE_PROC"; + case PT_HP_CORE_LOADABLE: return "HP_CORE_LOADABLE"; + case PT_HP_CORE_STACK: return "HP_CORE_STACK"; + case PT_HP_CORE_SHM: return "HP_CORE_SHM"; + case PT_HP_CORE_MMF: return "HP_CORE_MMF"; + case PT_HP_PARALLEL: return "HP_PARALLEL"; + case PT_HP_FASTBIND: return "HP_FASTBIND"; + case PT_PARISC_ARCHEXT: return "PARISC_ARCHEXT"; + case PT_PARISC_UNWIND: return "PARISC_UNWIND"; + default: + break; + } + + return NULL; +} + +static const char * get_segment_type (p_type) unsigned long p_type; { @@ -932,25 +1463,45 @@ get_segment_type (p_type) if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) { const char * result; - + switch (elf_header.e_machine) { case EM_MIPS: case EM_MIPS_RS4_BE: result = get_mips_segment_type (p_type); break; + case EM_PARISC: + result = get_parisc_segment_type (p_type); + break; default: result = NULL; break; } - + if (result != NULL) return result; - + sprintf (buff, "LOPROC+%lx", p_type - PT_LOPROC); } else if ((p_type >= PT_LOOS) && (p_type <= PT_HIOS)) - sprintf (buff, "LOOS+%lx", p_type - PT_LOOS); + { + const char * result; + + switch (elf_header.e_machine) + { + case EM_PARISC: + result = get_parisc_segment_type (p_type); + break; + default: + result = NULL; + break; + } + + if (result != NULL) + return result; + + sprintf (buff, "LOOS+%lx", p_type - PT_LOOS); + } else sprintf (buff, _(": %lx"), p_type); @@ -1010,6 +1561,21 @@ get_mips_section_type_name (sh_type) } static const char * +get_parisc_section_type_name (sh_type) + unsigned int sh_type; +{ + switch (sh_type) + { + case SHT_PARISC_EXT: return "PARISC_EXT"; + case SHT_PARISC_UNWIND: return "PARISC_UNWIND"; + case SHT_PARISC_DOC: return "PARISC_DOC"; + default: + break; + } + return NULL; +} + +static const char * get_section_type_name (sh_type) unsigned int sh_type; { @@ -1029,6 +1595,9 @@ get_section_type_name (sh_type) case SHT_REL: return "REL"; case SHT_SHLIB: return "SHLIB"; case SHT_DYNSYM: return "DYNSYM"; + case SHT_INIT_ARRAY: return "INIT_ARRAY"; + case SHT_FINI_ARRAY: return "FINI_ARRAY"; + case SHT_PREINIT_ARRAY: return "PREINIT_ARRAY"; case SHT_GNU_verdef: return "VERDEF"; case SHT_GNU_verneed: return "VERNEED"; case SHT_GNU_versym: return "VERSYM"; @@ -1048,6 +1617,9 @@ get_section_type_name (sh_type) case EM_MIPS_RS4_BE: result = get_mips_section_type_name (sh_type); break; + case EM_PARISC: + result = get_parisc_section_type_name (sh_type); + break; default: result = NULL; break; @@ -1064,7 +1636,7 @@ get_section_type_name (sh_type) sprintf (buff, "SHT_LOUSER+%x", sh_type - SHT_LOUSER); else sprintf (buff, _(": %x"), sh_type); - + return buff; } } @@ -1075,14 +1647,16 @@ struct option options [] = {"file-header", no_argument, 0, 'h'}, {"program-headers", no_argument, 0, 'l'}, {"headers", no_argument, 0, 'e'}, - {"histogram", no_argument, & do_histogram, 1}, + {"histogram", no_argument, 0, 'I'}, {"segments", no_argument, 0, 'l'}, {"sections", no_argument, 0, 'S'}, {"section-headers", no_argument, 0, 'S'}, {"symbols", no_argument, 0, 's'}, {"syms", no_argument, 0, 's'}, {"relocs", no_argument, 0, 'r'}, + {"notes", no_argument, 0, 'n'}, {"dynamic", no_argument, 0, 'd'}, + {"arch-specific", no_argument, 0, 'A'}, {"version-info", no_argument, 0, 'V'}, {"use-dynamic", no_argument, 0, 'D'}, {"hex-dump", required_argument, 0, 'x'}, @@ -1101,7 +1675,7 @@ usage () { fprintf (stdout, _("Usage: readelf {options} elf-file(s)\n")); fprintf (stdout, _(" Options are:\n")); - fprintf (stdout, _(" -a or --all Equivalent to: -h -l -S -s -r -d -V --histogram\n")); + fprintf (stdout, _(" -a or --all Equivalent to: -h -l -S -s -r -d -V -A -I\n")); fprintf (stdout, _(" -h or --file-header Display the ELF file header\n")); fprintf (stdout, _(" -l or --program-headers or --segments\n")); fprintf (stdout, _(" Display the program headers\n")); @@ -1109,9 +1683,11 @@ usage () fprintf (stdout, _(" Display the sections' header\n")); fprintf (stdout, _(" -e or --headers Equivalent to: -h -l -S\n")); fprintf (stdout, _(" -s or --syms or --symbols Display the symbol table\n")); + fprintf (stdout, _(" -n or --notes Display the core notes (if present)\n")); fprintf (stdout, _(" -r or --relocs Display the relocations (if present)\n")); fprintf (stdout, _(" -d or --dynamic Display the dynamic segment (if present)\n")); fprintf (stdout, _(" -V or --version-info Display the version sections (if present)\n")); + fprintf (stdout, _(" -A or --arch-specific Display architecture specific information (if any).\n")); fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n")); fprintf (stdout, _(" -x or --hex-dump=\n")); fprintf (stdout, _(" Dump the contents of section \n")); @@ -1121,7 +1697,7 @@ usage () fprintf (stdout, _(" -i or --instruction-dump=\n")); fprintf (stdout, _(" Disassemble the contents of section \n")); #endif - fprintf (stdout, _(" --histogram Display histogram of bucket list lengths\n")); + fprintf (stdout, _(" -I or --histogram Display histogram of bucket list lengths\n")); fprintf (stdout, _(" -v or --version Display the version number of readelf\n")); fprintf (stdout, _(" -H or --help Display this information\n")); fprintf (stdout, _("Report bugs to bug-gnu-utils@gnu.org\n")); @@ -1171,7 +1747,7 @@ parse_args (argc, argv) usage (); while ((c = getopt_long - (argc, argv, "ersahldSDw::x:i:vV", options, NULL)) != EOF) + (argc, argv, "ersahnldSDAIw::x:i:vV", options, NULL)) != EOF) { char * cp; int section; @@ -1194,12 +1770,17 @@ parse_args (argc, argv) do_segments ++; do_version ++; do_histogram ++; + do_arch ++; + do_notes ++; break; case 'e': do_header ++; do_sections ++; do_segments ++; break; + case 'A': + do_arch ++; + break; case 'D': do_using_dynamic ++; break; @@ -1221,6 +1802,12 @@ parse_args (argc, argv) case 'd': do_dynamic ++; break; + case 'I': + do_histogram ++; + break; + case 'n': + do_notes ++; + break; case 'x': do_dump ++; section = strtoul (optarg, & cp, 0); @@ -1299,7 +1886,7 @@ parse_args (argc, argv) if (!do_dynamic && !do_syms && !do_reloc && !do_sections && !do_segments && !do_header && !do_dump && !do_version - && !do_histogram && !do_debugging) + && !do_histogram && !do_debugging && !do_arch && !do_notes) usage (); else if (argc < 3) { @@ -1312,12 +1899,16 @@ static const char * get_elf_class (elf_class) unsigned char elf_class; { + static char buff [32]; + switch (elf_class) { case ELFCLASSNONE: return _("none"); case ELFCLASS32: return _("ELF32"); case ELFCLASS64: return _("ELF64"); - default: return _(""); + default: + sprintf (buff, _(""), elf_class); + return buff; } } @@ -1325,12 +1916,16 @@ static const char * get_data_encoding (encoding) unsigned char encoding; { + static char buff [32]; + switch (encoding) { case ELFDATANONE: return _("none"); - case ELFDATA2LSB: return _("2's compilment, little endian"); - case ELFDATA2MSB: return _("2's compilment, big endian"); - default: return _(""); + case ELFDATA2LSB: return _("2's complement, little endian"); + case ELFDATA2MSB: return _("2's complement, big endian"); + default: + sprintf (buff, _(""), encoding); + return buff; } } @@ -1338,12 +1933,18 @@ static const char * get_osabi_name (osabi) unsigned char osabi; { + static char buff [32]; + switch (osabi) { case ELFOSABI_SYSV: return _("UNIX - System V"); case ELFOSABI_HPUX: return _("UNIX - HP-UX"); + case ELFOSABI_LINUX: return _("UNIX - Linux"); case ELFOSABI_STANDALONE: return _("Standalone App"); - default: return _(""); + case ELFOSABI_ARM: return _("ARM"); + default: + sprintf (buff, _(""), osabi); + return buff; } } @@ -1376,8 +1977,11 @@ process_file_header () get_data_encoding (elf_header.e_ident [EI_DATA])); printf (_(" Version: %d %s\n"), elf_header.e_ident [EI_VERSION], - elf_header.e_ident [EI_VERSION] == EV_CURRENT ? "(current)" : - elf_header.e_ident [EI_VERSION] != EV_NONE ? "" : ""); + (elf_header.e_ident [EI_VERSION] == EV_CURRENT + ? "(current)" + : (elf_header.e_ident [EI_VERSION] != EV_NONE + ? "" + : ""))); printf (_(" OS/ABI: %s\n"), get_osabi_name (elf_header.e_ident [EI_OSABI])); printf (_(" ABI Version: %d\n"), @@ -1388,14 +1992,15 @@ process_file_header () get_machine_name (elf_header.e_machine)); printf (_(" Version: 0x%lx\n"), (unsigned long) elf_header.e_version); - printf (_(" Data: %s\n"), - get_machine_data (elf_header.e_ident [EI_DATA])); - printf (_(" Entry point address: 0x%lx\n"), - (unsigned long) elf_header.e_entry); - printf (_(" Start of program headers: %ld (bytes into file)\n"), - (long) elf_header.e_phoff); - printf (_(" Start of section headers: %ld (bytes into file)\n"), - (long) elf_header.e_shoff); + + printf (_(" Entry point address: ")); + print_vma ((bfd_vma) elf_header.e_entry, PREFIX_HEX); + printf (_("\n Start of program headers: ")); + print_vma ((bfd_vma) elf_header.e_phoff, DEC); + printf (_(" (bytes into file)\n Start of section headers: ")); + print_vma ((bfd_vma) elf_header.e_shoff, DEC); + printf (_(" (bytes into file)\n")); + printf (_(" Flags: 0x%lx%s\n"), (unsigned long) elf_header.e_flags, get_machine_flags (elf_header.e_flags, elf_header.e_machine)); @@ -1413,28 +2018,83 @@ process_file_header () (long) elf_header.e_shstrndx); } - /* Test class after dumping header so that at least the header can be - display on 64 bit binaries. */ - - binary_class = elf_header.e_ident [EI_CLASS]; - if (binary_class != ELFCLASS32) + return 1; +} + + +static int +get_32bit_program_headers (file, program_headers) + FILE * file; + Elf_Internal_Phdr * program_headers; +{ + Elf32_External_Phdr * phdrs; + Elf32_External_Phdr * external; + Elf32_Internal_Phdr * internal; + unsigned int i; + + GET_DATA_ALLOC (elf_header.e_phoff, + elf_header.e_phentsize * elf_header.e_phnum, + phdrs, Elf32_External_Phdr *, "program headers"); + + for (i = 0, internal = program_headers, external = phdrs; + i < elf_header.e_phnum; + i ++, internal ++, external ++) { - error (_("Not a 32 bit ELF file\n")); - return 0; + internal->p_type = BYTE_GET (external->p_type); + internal->p_offset = BYTE_GET (external->p_offset); + internal->p_vaddr = BYTE_GET (external->p_vaddr); + internal->p_paddr = BYTE_GET (external->p_paddr); + internal->p_filesz = BYTE_GET (external->p_filesz); + internal->p_memsz = BYTE_GET (external->p_memsz); + internal->p_flags = BYTE_GET (external->p_flags); + internal->p_align = BYTE_GET (external->p_align); } + free (phdrs); + return 1; } +static int +get_64bit_program_headers (file, program_headers) + FILE * file; + Elf_Internal_Phdr * program_headers; +{ + Elf64_External_Phdr * phdrs; + Elf64_External_Phdr * external; + Elf64_Internal_Phdr * internal; + unsigned int i; + + GET_DATA_ALLOC (elf_header.e_phoff, + elf_header.e_phentsize * elf_header.e_phnum, + phdrs, Elf64_External_Phdr *, "program headers"); + + for (i = 0, internal = program_headers, external = phdrs; + i < elf_header.e_phnum; + i ++, internal ++, external ++) + { + internal->p_type = BYTE_GET (external->p_type); + internal->p_flags = BYTE_GET (external->p_flags); + internal->p_offset = BYTE_GET8 (external->p_offset); + internal->p_vaddr = BYTE_GET8 (external->p_vaddr); + internal->p_paddr = BYTE_GET8 (external->p_paddr); + internal->p_filesz = BYTE_GET8 (external->p_filesz); + internal->p_memsz = BYTE_GET8 (external->p_memsz); + internal->p_align = BYTE_GET8 (external->p_align); + } + + free (phdrs); + + return 1; +} static int process_program_headers (file) FILE * file; { - Elf32_External_Phdr * phdrs; - Elf32_Internal_Phdr * program_headers; - Elf32_Internal_Phdr * segment; - unsigned int i; + Elf_Internal_Phdr * program_headers; + Elf_Internal_Phdr * segment; + unsigned int i; if (elf_header.e_phnum == 0) { @@ -1445,18 +2105,17 @@ process_program_headers (file) if (do_segments && !do_header) { - printf (_("\nElf file is %s\n"), get_file_type (elf_header.e_type)); - printf (_("Entry point 0x%lx\n"), (unsigned long) elf_header.e_entry); - printf (_("There are %d program headers, starting at offset %lx:\n"), - elf_header.e_phnum, (unsigned long) elf_header.e_phoff); + printf (_("\nElf file type is %s\n"), get_file_type (elf_header.e_type)); + printf (_("Entry point ")); + print_vma ((bfd_vma) elf_header.e_entry, PREFIX_HEX); + printf (_("\nThere are %d program headers, starting at offset "), + elf_header.e_phnum); + print_vma ((bfd_vma) elf_header.e_phoff, DEC); + printf ("\n"); } - GET_DATA_ALLOC (elf_header.e_phoff, - elf_header.e_phentsize * elf_header.e_phnum, - phdrs, Elf32_External_Phdr *, "program headers"); - - program_headers = (Elf32_Internal_Phdr *) malloc - (elf_header.e_phnum * sizeof (Elf32_Internal_Phdr)); + program_headers = (Elf_Internal_Phdr *) malloc + (elf_header.e_phnum * sizeof (Elf_Internal_Phdr)); if (program_headers == NULL) { @@ -1464,32 +2123,37 @@ process_program_headers (file) return 0; } - for (i = 0, segment = program_headers; - i < elf_header.e_phnum; - i ++, segment ++) + if (is_32bit_elf) + i = get_32bit_program_headers (file, program_headers); + else + i = get_64bit_program_headers (file, program_headers); + + if (i == 0) { - segment->p_type = BYTE_GET (phdrs[i].p_type); - segment->p_offset = BYTE_GET (phdrs[i].p_offset); - segment->p_vaddr = BYTE_GET (phdrs[i].p_vaddr); - segment->p_paddr = BYTE_GET (phdrs[i].p_paddr); - segment->p_filesz = BYTE_GET (phdrs[i].p_filesz); - segment->p_memsz = BYTE_GET (phdrs[i].p_memsz); - segment->p_flags = BYTE_GET (phdrs[i].p_flags); - segment->p_align = BYTE_GET (phdrs[i].p_align); + free (program_headers); + return 0; } - free (phdrs); - if (do_segments) { printf (_("\nProgram Header%s:\n"), elf_header.e_phnum > 1 ? "s" : ""); - printf - (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n")); + + if (is_32bit_elf) + printf + (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n")); + else + { + printf + (_(" Type Offset VirtAddr PhysAddr\n")); + printf + (_(" FileSiz MemSiz Flags Align\n")); + } } loadaddr = -1; dynamic_addr = 0; + dynamic_size = 0; for (i = 0, segment = program_headers; i < elf_header.e_phnum; @@ -1497,17 +2161,38 @@ process_program_headers (file) { if (do_segments) { - printf (" %-11.11s ", get_segment_type (segment->p_type)); - printf ("0x%6.6lx ", (unsigned long) segment->p_offset); - printf ("0x%8.8lx ", (unsigned long) segment->p_vaddr); - printf ("0x%8.8lx ", (unsigned long) segment->p_paddr); - printf ("0x%5.5lx ", (unsigned long) segment->p_filesz); - printf ("0x%5.5lx ", (unsigned long) segment->p_memsz); - printf ("%c%c%c ", - (segment->p_flags & PF_R ? 'R' : ' '), - (segment->p_flags & PF_W ? 'W' : ' '), - (segment->p_flags & PF_X ? 'E' : ' ')); - printf ("%#lx", (unsigned long) segment->p_align); + printf (" %-14.14s ", get_segment_type (segment->p_type)); + + if (is_32bit_elf) + { + printf ("0x%6.6lx ", (unsigned long) segment->p_offset); + printf ("0x%8.8lx ", (unsigned long) segment->p_vaddr); + printf ("0x%8.8lx ", (unsigned long) segment->p_paddr); + printf ("0x%5.5lx ", (unsigned long) segment->p_filesz); + printf ("0x%5.5lx ", (unsigned long) segment->p_memsz); + printf ("%c%c%c ", + (segment->p_flags & PF_R ? 'R' : ' '), + (segment->p_flags & PF_W ? 'W' : ' '), + (segment->p_flags & PF_X ? 'E' : ' ')); + printf ("%#lx", (unsigned long) segment->p_align); + } + else + { + print_vma (segment->p_offset, FULL_HEX); + putchar (' '); + print_vma (segment->p_vaddr, FULL_HEX); + putchar (' '); + print_vma (segment->p_paddr, FULL_HEX); + printf ("\n "); + print_vma (segment->p_filesz, FULL_HEX); + putchar (' '); + print_vma (segment->p_memsz, FULL_HEX); + printf (" %c%c%c ", + (segment->p_flags & PF_R ? 'R' : ' '), + (segment->p_flags & PF_W ? 'W' : ' '), + (segment->p_flags & PF_X ? 'E' : ' ')); + print_vma (segment->p_align, HEX); + } } switch (segment->p_type) @@ -1527,7 +2212,7 @@ process_program_headers (file) break; case PT_INTERP: - if (fseek (file, segment->p_offset, SEEK_SET)) + if (fseek (file, (long) segment->p_offset, SEEK_SET)) error (_("Unable to find program interpreter name\n")); else { @@ -1560,8 +2245,8 @@ process_program_headers (file) for (i = 0; i < elf_header.e_phnum; i++) { - int j; - Elf32_Internal_Shdr * section; + int j; + Elf_Internal_Shdr * section; segment = program_headers + i; section = section_headers; @@ -1577,7 +2262,7 @@ process_program_headers (file) ? (section->sh_addr >= segment->p_vaddr && section->sh_addr + section->sh_size <= segment->p_vaddr + segment->p_memsz) - : (section->sh_offset >= segment->p_offset + : ((bfd_vma) section->sh_offset >= segment->p_offset && (section->sh_offset + section->sh_size <= segment->p_offset + segment->p_filesz)))) printf ("%s ", SECTION_NAME (section)); @@ -1594,7 +2279,7 @@ process_program_headers (file) static int -get_section_headers (file) +get_32bit_section_headers (file) FILE * file; { Elf32_External_Shdr * shdrs; @@ -1605,8 +2290,8 @@ get_section_headers (file) elf_header.e_shentsize * elf_header.e_shnum, shdrs, Elf32_External_Shdr *, "section headers"); - section_headers = (Elf32_Internal_Shdr *) malloc - (elf_header.e_shnum * sizeof (Elf32_Internal_Shdr)); + section_headers = (Elf_Internal_Shdr *) malloc + (elf_header.e_shnum * sizeof (Elf_Internal_Shdr)); if (section_headers == NULL) { @@ -1635,8 +2320,50 @@ get_section_headers (file) return 1; } +static int +get_64bit_section_headers (file) + FILE * file; +{ + Elf64_External_Shdr * shdrs; + Elf64_Internal_Shdr * internal; + unsigned int i; + + GET_DATA_ALLOC (elf_header.e_shoff, + elf_header.e_shentsize * elf_header.e_shnum, + shdrs, Elf64_External_Shdr *, "section headers"); + + section_headers = (Elf_Internal_Shdr *) malloc + (elf_header.e_shnum * sizeof (Elf_Internal_Shdr)); + + if (section_headers == NULL) + { + error (_("Out of memory\n")); + return 0; + } + + for (i = 0, internal = section_headers; + i < elf_header.e_shnum; + i ++, internal ++) + { + internal->sh_name = BYTE_GET (shdrs[i].sh_name); + internal->sh_type = BYTE_GET (shdrs[i].sh_type); + internal->sh_flags = BYTE_GET8 (shdrs[i].sh_flags); + internal->sh_addr = BYTE_GET8 (shdrs[i].sh_addr); + internal->sh_size = BYTE_GET8 (shdrs[i].sh_size); + internal->sh_entsize = BYTE_GET8 (shdrs[i].sh_entsize); + internal->sh_link = BYTE_GET (shdrs[i].sh_link); + internal->sh_info = BYTE_GET (shdrs[i].sh_info); + internal->sh_offset = BYTE_GET (shdrs[i].sh_offset); + internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign); + } + + free (shdrs); + + return 1; +} + static Elf_Internal_Sym * -get_elf_symbols (file, offset, number) +get_32bit_elf_symbols (file, offset, number) FILE * file; unsigned long offset; unsigned long number; @@ -1676,12 +2403,99 @@ get_elf_symbols (file, offset, number) return isyms; } +static Elf_Internal_Sym * +get_64bit_elf_symbols (file, offset, number) + FILE * file; + unsigned long offset; + unsigned long number; +{ + Elf64_External_Sym * esyms; + Elf_Internal_Sym * isyms; + Elf_Internal_Sym * psym; + unsigned int j; + + GET_DATA_ALLOC (offset, number * sizeof (Elf64_External_Sym), + esyms, Elf64_External_Sym *, "symbols"); + + isyms = (Elf_Internal_Sym *) malloc (number * sizeof (Elf_Internal_Sym)); + + if (isyms == NULL) + { + error (_("Out of memory\n")); + free (esyms); + + return NULL; + } + + for (j = 0, psym = isyms; + j < number; + j ++, psym ++) + { + psym->st_name = BYTE_GET (esyms[j].st_name); + psym->st_info = BYTE_GET (esyms[j].st_info); + psym->st_other = BYTE_GET (esyms[j].st_other); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + psym->st_value = BYTE_GET8 (esyms[j].st_value); + psym->st_size = BYTE_GET8 (esyms[j].st_size); + } + + free (esyms); + + return isyms; +} + +static const char * +get_elf_section_flags (sh_flags) + bfd_vma sh_flags; +{ + static char buff [32]; + + * buff = 0; + + while (sh_flags) + { + bfd_vma flag; + + flag = sh_flags & - sh_flags; + sh_flags &= ~ flag; + + switch (flag) + { + case SHF_WRITE: strcat (buff, "W"); break; + case SHF_ALLOC: strcat (buff, "A"); break; + case SHF_EXECINSTR: strcat (buff, "X"); break; + case SHF_MERGE: strcat (buff, "M"); break; + case SHF_STRINGS: strcat (buff, "S"); break; + case SHF_INFO_LINK: strcat (buff, "I"); break; + case SHF_LINK_ORDER: strcat (buff, "L"); break; + case SHF_OS_NONCONFORMING: strcat (buff, "O"); break; + + default: + if (flag & SHF_MASKOS) + { + strcat (buff, "o"); + sh_flags &= ~ SHF_MASKOS; + } + else if (flag & SHF_MASKPROC) + { + strcat (buff, "p"); + sh_flags &= ~ SHF_MASKPROC; + } + else + strcat (buff, "x"); + break; + } + } + + return buff; +} + static int process_section_headers (file) FILE * file; { - Elf32_Internal_Shdr * section; - int i; + Elf_Internal_Shdr * section; + int i; section_headers = NULL; @@ -1694,10 +2508,15 @@ process_section_headers (file) } if (do_sections && !do_header) - printf (_("There are %d section headers, starting at offset %lx:\n"), + printf (_("There are %d section headers, starting at offset 0x%lx:\n"), elf_header.e_shnum, (unsigned long) elf_header.e_shoff); - if (! get_section_headers (file)) + if (is_32bit_elf) + { + if (! get_32bit_section_headers (file)) + return 0; + } + else if (! get_64bit_section_headers (file)) return 0; /* Read in the string table, so that we have names to display. */ @@ -1718,6 +2537,7 @@ process_section_headers (file) dynamic_symbols = NULL; dynamic_strings = NULL; dynamic_syminfo = NULL; + for (i = 0, section = section_headers; i < elf_header.e_shnum; i ++, section ++) @@ -1732,9 +2552,9 @@ process_section_headers (file) continue; } - dynamic_symbols = get_elf_symbols - (file, section->sh_offset, - section->sh_size / section->sh_entsize); + num_dynamic_syms = section->sh_size / section->sh_entsize; + dynamic_symbols = + GET_ELF_SYMBOLS (file, section->sh_offset, num_dynamic_syms); } else if (section->sh_type == SHT_STRTAB && strcmp (name, ".dynstr") == 0) @@ -1769,8 +2589,15 @@ process_section_headers (file) return 1; printf (_("\nSection Header%s:\n"), elf_header.e_shnum > 1 ? "s" : ""); - printf - (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n")); + + if (is_32bit_elf) + printf + (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n")); + else + { + printf (_(" [Nr] Name Type Address Offset\n")); + printf (_(" Size EntSize Flags Link Info Align\n")); + } for (i = 0, section = section_headers; i < elf_header.e_shnum; @@ -1781,21 +2608,45 @@ process_section_headers (file) SECTION_NAME (section), get_section_type_name (section->sh_type)); - printf ( "%8.8lx %6.6lx %6.6lx %2.2lx", - (unsigned long) section->sh_addr, - (unsigned long) section->sh_offset, - (unsigned long) section->sh_size, - (unsigned long) section->sh_entsize); - - printf (" %c%c%c %2ld %3lx %ld\n", - (section->sh_flags & SHF_WRITE ? 'W' : ' '), - (section->sh_flags & SHF_ALLOC ? 'A' : ' '), - (section->sh_flags & SHF_EXECINSTR ? 'X' : ' '), - (unsigned long) section->sh_link, - (unsigned long) section->sh_info, - (unsigned long) section->sh_addralign); + if (is_32bit_elf) + { + print_vma (section->sh_addr, LONG_HEX); + + printf ( " %6.6lx %6.6lx %2.2lx", + (unsigned long) section->sh_offset, + (unsigned long) section->sh_size, + (unsigned long) section->sh_entsize); + + printf (" %3s ", get_elf_section_flags (section->sh_flags)); + + printf (" %2ld %3lx %ld\n", + (unsigned long) section->sh_link, + (unsigned long) section->sh_info, + (unsigned long) section->sh_addralign); + } + else + { + putchar (' '); + print_vma (section->sh_addr, LONG_HEX); + printf (" %8.8lx", section->sh_offset); + printf ("\n "); + print_vma (section->sh_size, LONG_HEX); + printf (" "); + print_vma (section->sh_entsize, LONG_HEX); + + printf (" %3s ", get_elf_section_flags (section->sh_flags)); + + printf (" %2ld %3lx %ld\n", + (unsigned long) section->sh_link, + (unsigned long) section->sh_info, + (unsigned long) section->sh_addralign); + } } + printf (_("Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings)\n")); + printf (_(" I (info), L (link order), O (extra OS processing required)\n")); + printf (_(" o (os specific), p (processor specific) x (unknown)\n")); + return 1; } @@ -1813,6 +2664,8 @@ process_relocs (file) if (do_using_dynamic) { + int is_rela = FALSE; + rel_size = 0; rel_offset = 0; @@ -1820,16 +2673,31 @@ process_relocs (file) { rel_offset = dynamic_info[DT_REL]; rel_size = dynamic_info[DT_RELSZ]; + is_rela = FALSE; } else if (dynamic_info [DT_RELA]) { rel_offset = dynamic_info[DT_RELA]; rel_size = dynamic_info[DT_RELASZ]; + is_rela = TRUE; } else if (dynamic_info[DT_JMPREL]) { rel_offset = dynamic_info[DT_JMPREL]; rel_size = dynamic_info[DT_PLTRELSZ]; + + switch (dynamic_info[DT_PLTREL]) + { + case DT_REL: + is_rela = FALSE; + break; + case DT_RELA: + is_rela = TRUE; + break; + default: + is_rela = UNKNOWN; + break; + } } if (rel_size) @@ -1839,7 +2707,7 @@ process_relocs (file) rel_offset, rel_size); dump_relocations (file, rel_offset - loadaddr, rel_size, - dynamic_symbols, dynamic_strings); + dynamic_symbols, num_dynamic_syms, dynamic_strings, is_rela); } else printf (_("\nThere are no dynamic relocations in this file.\n")); @@ -1867,6 +2735,8 @@ process_relocs (file) Elf32_Internal_Shdr * symsec; Elf_Internal_Sym * symtab; char * strtab; + int is_rela; + unsigned long nsyms; printf (_("\nRelocation section ")); @@ -1880,8 +2750,8 @@ process_relocs (file) symsec = section_headers + section->sh_link; - symtab = get_elf_symbols (file, symsec->sh_offset, - symsec->sh_size / symsec->sh_entsize); + nsyms = symsec->sh_size / symsec->sh_entsize; + symtab = GET_ELF_SYMBOLS (file, symsec->sh_offset, nsyms); if (symtab == NULL) continue; @@ -1891,7 +2761,9 @@ process_relocs (file) GET_DATA_ALLOC (strsec->sh_offset, strsec->sh_size, strtab, char *, "string table"); - dump_relocations (file, rel_offset, rel_size, symtab, strtab); + is_rela = section->sh_type == SHT_RELA; + + dump_relocations (file, rel_offset, rel_size, symtab, nsyms, strtab, is_rela); free (strtab); free (symtab); @@ -1938,7 +2810,7 @@ dynamic_segment_mips_val (entry) puts (""); } break; - + case DT_MIPS_IVERSION: if (dynamic_strings != NULL) printf ("Interface Version: %s\n", @@ -1946,7 +2818,7 @@ dynamic_segment_mips_val (entry) else printf ("%ld\n", (long) entry->d_un.d_ptr); break; - + case DT_MIPS_TIME_STAMP: { char timebuf[20]; @@ -1955,7 +2827,7 @@ dynamic_segment_mips_val (entry) printf ("Time Stamp: %s\n", timebuf); } break; - + case DT_MIPS_RLD_VERSION: case DT_MIPS_LOCAL_GOTNO: case DT_MIPS_CONFLICTNO: @@ -1971,37 +2843,126 @@ dynamic_segment_mips_val (entry) case DT_MIPS_COMPACT_SIZE: printf ("%ld\n", (long) entry->d_un.d_ptr); break; + + default: + printf ("%#lx\n", (long) entry->d_un.d_ptr); + } +} + + +static void +dynamic_segment_parisc_val (entry) + Elf_Internal_Dyn * entry; +{ + switch (entry->d_tag) + { + case DT_HP_DLD_FLAGS: + { + static struct + { + long int bit; + const char * str; + } + flags[] = + { + { DT_HP_DEBUG_PRIVATE, "HP_DEBUG_PRIVATE" }, + { DT_HP_DEBUG_CALLBACK, "HP_DEBUG_CALLBACK" }, + { DT_HP_DEBUG_CALLBACK_BOR, "HP_DEBUG_CALLBACK_BOR" }, + { DT_HP_NO_ENVVAR, "HP_NO_ENVVAR" }, + { DT_HP_BIND_NOW, "HP_BIND_NOW" }, + { DT_HP_BIND_NONFATAL, "HP_BIND_NONFATAL" }, + { DT_HP_BIND_VERBOSE, "HP_BIND_VERBOSE" }, + { DT_HP_BIND_RESTRICTED, "HP_BIND_RESTRICTED" }, + { DT_HP_BIND_SYMBOLIC, "HP_BIND_SYMBOLIC" }, + { DT_HP_RPATH_FIRST, "HP_RPATH_FIRST" }, + { DT_HP_BIND_DEPTH_FIRST, "HP_BIND_DEPTH_FIRST" } + }; + int first = 1; + size_t cnt; + bfd_vma val = entry->d_un.d_val; + + for (cnt = 0; cnt < sizeof (flags) / sizeof (flags[0]); ++cnt) + if (val & flags[cnt].bit) + { + if (! first) + putchar (' '); + fputs (flags[cnt].str, stdout); + first = 0; + val ^= flags[cnt].bit; + } + + if (val != 0 || first) + { + if (! first) + putchar (' '); + print_vma (val, HEX); + } + } + break; default: - printf ("%#lx\n", (long) entry->d_un.d_ptr); + print_vma (entry->d_un.d_ptr, PREFIX_HEX); + break; } } -/* Parse the dynamic segment */ static int -process_dynamic_segment (file) +get_32bit_dynamic_segment (file) FILE * file; { - Elf_Internal_Dyn * entry; - Elf32_External_Dyn * edyn; - unsigned int i; + Elf32_External_Dyn * edyn; + Elf_Internal_Dyn * entry; + bfd_size_type i; - if (dynamic_size == 0) + GET_DATA_ALLOC (dynamic_addr, dynamic_size, + edyn, Elf32_External_Dyn *, "dynamic segment"); + + /* SGI's ELF has more than one section in the DYNAMIC segment. Determine + how large this .dynamic is now. We can do this even before the byte + swapping since the DT_NULL tag is recognizable. */ + dynamic_size = 0; + while (*(Elf32_Word *) edyn [dynamic_size++].d_tag != DT_NULL) + ; + + dynamic_segment = (Elf_Internal_Dyn *) + malloc (dynamic_size * sizeof (Elf_Internal_Dyn)); + + if (dynamic_segment == NULL) { - if (do_dynamic) - printf (_("\nThere is no dynamic segment in this file.\n")); + error (_("Out of memory\n")); + free (edyn); + return 0; + } - return 1; + for (i = 0, entry = dynamic_segment; + i < dynamic_size; + i ++, entry ++) + { + entry->d_tag = BYTE_GET (edyn [i].d_tag); + entry->d_un.d_val = BYTE_GET (edyn [i].d_un.d_val); } + free (edyn); + + return 1; +} + +static int +get_64bit_dynamic_segment (file) + FILE * file; +{ + Elf64_External_Dyn * edyn; + Elf_Internal_Dyn * entry; + bfd_size_type i; + GET_DATA_ALLOC (dynamic_addr, dynamic_size, - edyn, Elf32_External_Dyn *, "dynamic segment"); - + edyn, Elf64_External_Dyn *, "dynamic segment"); + /* SGI's ELF has more than one section in the DYNAMIC segment. Determine - how large .dynamic is now. We can do this even before the byte + how large this .dynamic is now. We can do this even before the byte swapping since the DT_NULL tag is recognizable. */ dynamic_size = 0; - while (*(Elf32_Word *) edyn[dynamic_size++].d_tag != DT_NULL) + while (*(bfd_vma *) edyn [dynamic_size ++].d_tag != DT_NULL) ; dynamic_segment = (Elf_Internal_Dyn *) @@ -2018,12 +2979,63 @@ process_dynamic_segment (file) i < dynamic_size; i ++, entry ++) { - entry->d_tag = BYTE_GET (edyn [i].d_tag); - entry->d_un.d_val = BYTE_GET (edyn [i].d_un.d_val); + entry->d_tag = BYTE_GET8 (edyn [i].d_tag); + entry->d_un.d_val = BYTE_GET8 (edyn [i].d_un.d_val); } free (edyn); + return 1; +} + +static const char * +get_dynamic_flags (flags) + bfd_vma flags; +{ + static char buff [64]; + while (flags) + { + bfd_vma flag; + + flag = flags & - flags; + flags &= ~ flag; + + switch (flag) + { + case DF_ORIGIN: strcat (buff, "ORIGIN "); break; + case DF_SYMBOLIC: strcat (buff, "SYMBOLIC "); break; + case DF_TEXTREL: strcat (buff, "TEXTREL "); break; + case DF_BIND_NOW: strcat (buff, "BIND_NOW "); break; + default: strcat (buff, "unknown "); break; + } + } + return buff; +} + +/* Parse and display the contents of the dynamic segment. */ +static int +process_dynamic_segment (file) + FILE * file; +{ + Elf_Internal_Dyn * entry; + bfd_size_type i; + + if (dynamic_size == 0) + { + if (do_dynamic) + printf (_("\nThere is no dynamic segment in this file.\n")); + + return 1; + } + + if (is_32bit_elf) + { + if (! get_32bit_dynamic_segment (file)) + return 0; + } + else if (! get_64bit_dynamic_segment (file)) + return 0; + /* Find the appropriate symbol table. */ if (dynamic_symbols == NULL) { @@ -2032,7 +3044,6 @@ process_dynamic_segment (file) ++i, ++ entry) { unsigned long offset; - long num_syms; if (entry->d_tag != DT_SYMTAB) continue; @@ -2043,21 +3054,23 @@ process_dynamic_segment (file) we default to reading in the entire file (!) and processing that. This is overkill, I know, but it should work. */ - offset = entry->d_un.d_val - loadaddr; if (fseek (file, 0, SEEK_END)) error (_("Unable to seek to end of file!")); - num_syms = (ftell (file) - offset) / sizeof (Elf32_External_Sym); + if (is_32bit_elf) + num_dynamic_syms = (ftell (file) - offset) / sizeof (Elf32_External_Sym); + else + num_dynamic_syms = (ftell (file) - offset) / sizeof (Elf64_External_Sym); - if (num_syms < 1) + if (num_dynamic_syms < 1) { error (_("Unable to determine the number of symbols to load\n")); continue; } - dynamic_symbols = get_elf_symbols (file, offset, num_syms); + dynamic_symbols = GET_ELF_SYMBOLS (file, offset, num_dynamic_syms); } } @@ -2123,8 +3136,8 @@ process_dynamic_segment (file) if (dynamic_syminfo_offset != 0 && syminsz != 0) { - Elf_External_Syminfo *extsyminfo; - Elf_Internal_Syminfo *syminfo; + Elf_External_Syminfo * extsyminfo; + Elf_Internal_Syminfo * syminfo; /* There is a syminfo section. Read the data. */ GET_DATA_ALLOC (dynamic_syminfo_offset, syminsz, extsyminfo, @@ -2150,8 +3163,8 @@ process_dynamic_segment (file) } if (do_dynamic && dynamic_addr) - printf (_("\nDynamic segment at offset 0x%x contains %d entries:\n"), - dynamic_addr, dynamic_size); + printf (_("\nDynamic segment at offset 0x%x contains %ld entries:\n"), + dynamic_addr, (long) dynamic_size); if (do_dynamic) printf (_(" Tag Type Name/Value\n")); @@ -2160,14 +3173,25 @@ process_dynamic_segment (file) i++, entry ++) { if (do_dynamic) - printf (_(" 0x%-8.8lx (%s)%*s"), - (unsigned long) entry->d_tag, - get_dynamic_type (entry->d_tag), - 27 - strlen (get_dynamic_type (entry->d_tag)), - " "); + { + const char *dtype; + + putchar (' '); + print_vma (entry->d_tag, FULL_HEX); + dtype = get_dynamic_type (entry->d_tag); + printf (" (%s)%*s", dtype, + ((is_32bit_elf ? 27 : 19) + - (int) strlen (dtype)), + " "); + } switch (entry->d_tag) { + case DT_FLAGS: + if (do_dynamic) + printf ("%s", get_dynamic_flags (entry->d_un.d_val)); + break; + case DT_AUXILIARY: case DT_FILTER: if (do_dynamic) @@ -2180,7 +3204,11 @@ process_dynamic_segment (file) if (dynamic_strings) printf (": [%s]\n", dynamic_strings + entry->d_un.d_val); else - printf (": %#lx\n", (long) entry->d_un.d_val); + { + printf (": "); + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); + } } break; @@ -2341,26 +3369,27 @@ process_dynamic_segment (file) case DT_NEEDED: printf (_("Shared library: [%s]"), name); - if (strcmp (name, program_interpreter)) - printf ("\n"); - else - printf (_(" program interpreter\n")); + if (strcmp (name, program_interpreter) == 0) + printf (_(" program interpreter")); break; case DT_SONAME: - printf (_("Library soname: [%s]\n"), name); + printf (_("Library soname: [%s]"), name); break; case DT_RPATH: - printf (_("Library rpath: [%s]\n"), name); + printf (_("Library rpath: [%s]"), name); break; default: - printf ("%#lx\n", (long) entry->d_un.d_val); + print_vma (entry->d_un.d_val, PREFIX_HEX); + break; } } else - printf ("%#lx\n", (long) entry->d_un.d_val); + print_vma (entry->d_un.d_val, PREFIX_HEX); + + putchar ('\n'); } break; @@ -2377,7 +3406,10 @@ process_dynamic_segment (file) case DT_INIT_ARRAYSZ: case DT_FINI_ARRAYSZ: if (do_dynamic) - printf ("%lu (bytes)\n", (unsigned long) entry->d_un.d_val); + { + print_vma (entry->d_un.d_val, UNSIGNED); + printf (" (bytes)\n"); + } break; case DT_VERDEFNUM: @@ -2385,7 +3417,10 @@ process_dynamic_segment (file) case DT_RELACOUNT: case DT_RELCOUNT: if (do_dynamic) - printf ("%lu\n", (unsigned long) entry->d_un.d_val); + { + print_vma (entry->d_un.d_val, UNSIGNED); + putchar ('\n'); + } break; case DT_SYMINSZ: @@ -2408,15 +3443,16 @@ process_dynamic_segment (file) break; } } - - printf ("%#lx\n", (long) entry->d_un.d_val); + + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); } break; case DT_BIND_NOW: /* The value of this entry is ignored. */ break; - + default: if ((entry->d_tag >= DT_VERSYM) && (entry->d_tag <= DT_VERNEEDNUM)) version_info [DT_VERSIONTAGIDX (entry->d_tag)] = @@ -2430,8 +3466,12 @@ process_dynamic_segment (file) case EM_MIPS_RS4_BE: dynamic_segment_mips_val (entry); break; + case EM_PARISC: + dynamic_segment_parisc_val (entry); + break; default: - printf ("%#lx\n", (long) entry->d_un.d_ptr); + print_vma (entry->d_un.d_val, PREFIX_HEX); + putchar ('\n'); } } break; @@ -2502,7 +3542,7 @@ process_version_sections (file) printf (_(" Addr: 0x")); printf_vma (section->sh_addr); printf (_(" Offset: %#08lx Link: %lx (%s)\n"), - section->sh_offset, section->sh_link, + (unsigned long) section->sh_offset, section->sh_link, SECTION_NAME (section_headers + section->sh_link)); GET_DATA_ALLOC (section->sh_offset, section->sh_size, @@ -2518,7 +3558,7 @@ process_version_sections (file) Elf_Internal_Verdaux aux; int j; int isum; - + vstart = ((char *) edefs) + idx; edef = (Elf_External_Verdef *) vstart; @@ -2575,7 +3615,7 @@ process_version_sections (file) free (edefs); } break; - + case SHT_GNU_verneed: { Elf_External_Verneed * eneed; @@ -2590,7 +3630,7 @@ process_version_sections (file) printf (_(" Addr: 0x")); printf_vma (section->sh_addr); printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"), - section->sh_offset, section->sh_link, + (unsigned long) section->sh_offset, section->sh_link, SECTION_NAME (section_headers + section->sh_link)); GET_DATA_ALLOC (section->sh_offset, section->sh_size, @@ -2655,7 +3695,7 @@ process_version_sections (file) idx += ent.vn_next; } - + free (eneed); } break; @@ -2676,9 +3716,8 @@ process_version_sections (file) found = 1; - symbols = get_elf_symbols - (file, link_section->sh_offset, - link_section->sh_size / link_section->sh_entsize); + symbols = GET_ELF_SYMBOLS (file, link_section->sh_offset, + link_section->sh_size / link_section->sh_entsize); string_sec = section_headers + link_section->sh_link; @@ -2691,7 +3730,7 @@ process_version_sections (file) printf (_(" Addr: ")); printf_vma (section->sh_addr); printf (_(" Offset: %#08lx Link: %lx (%s)\n"), - section->sh_offset, section->sh_link, + (unsigned long) section->sh_offset, section->sh_link, SECTION_NAME (link_section)); GET_DATA_ALLOC (version_info [DT_VERSIONTAGIDX (DT_VERSYM)] @@ -2710,6 +3749,7 @@ process_version_sections (file) for (cnt = 0; cnt < total; cnt += 4) { int j, nn; + char *name; printf (" %03x:", cnt); @@ -2770,10 +3810,10 @@ process_version_sections (file) { ivna.vna_name = BYTE_GET (evna.vna_name); + name = strtab + ivna.vna_name; nn += printf ("(%s%-*s", - strtab + ivna.vna_name, - 12 - strlen (strtab - + ivna.vna_name), + name, + 12 - (int) strlen (name), ")"); break; } @@ -2816,12 +3856,11 @@ process_version_sections (file) ivda.vda_name = BYTE_GET (evda.vda_name); + name = strtab + ivda.vda_name; nn += printf ("(%s%-*s", - strtab + ivda.vda_name, - 12 - - strlen (strtab - + ivda.vda_name), + name, + 12 - (int) strlen (name), ")"); } } @@ -2872,10 +3911,10 @@ process_version_sections (file) { ivna.vna_name = BYTE_GET (evna.vna_name); + name = strtab + ivna.vna_name; nn += printf ("(%s%-*s", - strtab + ivna.vna_name, - 12 - strlen (strtab - + ivna.vna_name), + name, + 12 - (int) strlen (name), ")"); break; } @@ -2917,10 +3956,10 @@ process_version_sections (file) ivda.vda_name = BYTE_GET (evda.vda_name); + name = strtab + ivda.vda_name; nn += printf ("(%s%-*s", - strtab + ivda.vda_name, - 12 - strlen (strtab - + ivda.vda_name), + name, + 12 - (int) strlen (name), ")"); } } @@ -2937,7 +3976,7 @@ process_version_sections (file) free (symbols); } break; - + default: break; } @@ -2949,7 +3988,7 @@ process_version_sections (file) return 1; } -static char * +static const char * get_symbol_binding (binding) unsigned int binding; { @@ -2957,9 +3996,9 @@ get_symbol_binding (binding) switch (binding) { - case STB_LOCAL: return _("LOCAL"); - case STB_GLOBAL: return _("GLOBAL"); - case STB_WEAK: return _("WEAK"); + case STB_LOCAL: return "LOCAL"; + case STB_GLOBAL: return "GLOBAL"; + case STB_WEAK: return "WEAK"; default: if (binding >= STB_LOPROC && binding <= STB_HIPROC) sprintf (buff, _(": %d"), binding); @@ -2971,7 +4010,7 @@ get_symbol_binding (binding) } } -static char * +static const char * get_symbol_type (type) unsigned int type; { @@ -2979,23 +4018,59 @@ get_symbol_type (type) switch (type) { - case STT_NOTYPE: return _("NOTYPE"); - case STT_OBJECT: return _("OBJECT"); - case STT_FUNC: return _("FUNC"); - case STT_SECTION: return _("SECTION"); - case STT_FILE: return _("FILE"); + case STT_NOTYPE: return "NOTYPE"; + case STT_OBJECT: return "OBJECT"; + case STT_FUNC: return "FUNC"; + case STT_SECTION: return "SECTION"; + case STT_FILE: return "FILE"; + case STT_COMMON: return "COMMON"; default: if (type >= STT_LOPROC && type <= STT_HIPROC) - sprintf (buff, _(": %d"), type); + { + if (elf_header.e_machine == EM_ARM && type == STT_ARM_TFUNC) + return "THUMB_FUNC"; + + if (elf_header.e_machine == EM_SPARCV9 && type == STT_REGISTER) + return "REGISTER"; + + if (elf_header.e_machine == EM_PARISC && type == STT_PARISC_MILLI) + return "PARISC_MILLI"; + + sprintf (buff, _(": %d"), type); + } else if (type >= STT_LOOS && type <= STT_HIOS) - sprintf (buff, _(": %d"), type); + { + if (elf_header.e_machine == EM_PARISC) + { + if (type == STT_HP_OPAQUE) + return "HP_OPAQUE"; + if (type == STT_HP_STUB) + return "HP_STUB"; + } + + sprintf (buff, _(": %d"), type); + } else sprintf (buff, _(": %d"), type); return buff; } } -static char * +static const char * +get_symbol_visibility (visibility) + unsigned int visibility; +{ + switch (visibility) + { + case STV_DEFAULT: return "DEFAULT"; + case STV_INTERNAL: return "INTERNAL"; + case STV_HIDDEN: return "HIDDEN"; + case STV_PROTECTED: return "PROTECTED"; + default: abort (); + } +} + +static const char * get_symbol_index_type (type) unsigned int type; { @@ -3021,7 +4096,6 @@ get_symbol_index_type (type) } } - static int * get_dynamic_data (file, number) FILE * file; @@ -3069,8 +4143,8 @@ process_symbol_table (file) Elf32_Internal_Shdr * section; char nb [4]; char nc [4]; - int nbuckets; - int nchains; + int nbuckets = 0; + int nchains = 0; int * buckets = NULL; int * chains = NULL; @@ -3115,29 +4189,31 @@ process_symbol_table (file) int si; printf (_("\nSymbol table for image:\n")); - printf (_(" Num Buc: Value Size Type Bind Ot Ndx Name\n")); + if (is_32bit_elf) + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); + else + printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n")); for (hn = 0; hn < nbuckets; hn++) { if (! buckets [hn]) continue; - for (si = buckets [hn]; si; si = chains [si]) + for (si = buckets [hn]; si < nchains && si > 0; si = chains [si]) { Elf_Internal_Sym * psym; psym = dynamic_symbols + si; - printf (" %3d %3d: %8lx %5ld %6s %6s %2d ", - si, hn, - (unsigned long) psym->st_value, - (unsigned long) psym->st_size, - get_symbol_type (ELF_ST_TYPE (psym->st_info)), - get_symbol_binding (ELF_ST_BIND (psym->st_info)), - psym->st_other); - - printf ("%3.3s", get_symbol_index_type (psym->st_shndx)); - + printf (" %3d %3d: ", si, hn); + print_vma (psym->st_value, LONG_HEX); + putchar (' ' ); + print_vma (psym->st_size, DEC_5); + + printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym->st_info))); + printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym->st_info))); + printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other))); + printf (" %3.3s", get_symbol_index_type (psym->st_shndx)); printf (" %s\n", dynamic_strings + psym->st_name); } } @@ -3163,10 +4239,12 @@ process_symbol_table (file) printf (_("\nSymbol table '%s' contains %lu entries:\n"), SECTION_NAME (section), (unsigned long) (section->sh_size / section->sh_entsize)); - fputs (_(" Num: Value Size Type Bind Ot Ndx Name\n"), - stdout); + if (is_32bit_elf) + printf (_(" Num: Value Size Type Bind Vis Ndx Name\n")); + else + printf (_(" Num: Value Size Type Bind Vis Ndx Name\n")); - symtab = get_elf_symbols (file, section->sh_offset, + symtab = GET_ELF_SYMBOLS (file, section->sh_offset, section->sh_size / section->sh_entsize); if (symtab == NULL) continue; @@ -3187,23 +4265,14 @@ process_symbol_table (file) si < section->sh_size / section->sh_entsize; si ++, psym ++) { - printf (" %3d: %8lx %5ld %-7s %-6s %2d ", - si, - (unsigned long) psym->st_value, - (unsigned long) psym->st_size, - get_symbol_type (ELF_ST_TYPE (psym->st_info)), - get_symbol_binding (ELF_ST_BIND (psym->st_info)), - psym->st_other); - - if (psym->st_shndx == 0) - fputs (" UND", stdout); - else if ((psym->st_shndx & 0xffff) == 0xfff1) - fputs (" ABS", stdout); - else if ((psym->st_shndx & 0xffff) == 0xfff2) - fputs (" COM", stdout); - else - printf ("%4x", psym->st_shndx); - + printf ("%6d: ", si); + print_vma (psym->st_value, LONG_HEX); + putchar (' '); + print_vma (psym->st_size, DEC_5); + printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym->st_info))); + printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym->st_info))); + printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other))); + printf (" %4s", get_symbol_index_type (psym->st_shndx)); printf (" %s", strtab + psym->st_name); if (section->sh_type == SHT_DYNSYM && @@ -3368,11 +4437,11 @@ process_symbol_table (file) if (! buckets [hn]) continue; - for (si = buckets[hn]; si; si = chains[si]) + for (si = buckets[hn]; si > 0 && si < nchains; si = chains[si]) { - ++nsyms; + ++ nsyms; if (maxlength < ++lengths[hn]) - ++maxlength; + ++ maxlength; } } @@ -3386,14 +4455,17 @@ process_symbol_table (file) for (hn = 0; hn < nbuckets; ++hn) ++ counts [lengths [hn]]; - printf (" 0 %-10d (%5.1f%%)\n", - counts[0], (counts[0] * 100.0) / nbuckets); - for (si = 1; si <= maxlength; ++si) + if (nbuckets > 0) { - nzero_counts += counts[si] * si; - printf ("%7d %-10d (%5.1f%%) %5.1f%%\n", - si, counts[si], (counts[si] * 100.0) / nbuckets, - (nzero_counts * 100.0) / nsyms); + printf (" 0 %-10d (%5.1f%%)\n", + counts[0], (counts[0] * 100.0) / nbuckets); + for (si = 1; si <= maxlength; ++si) + { + nzero_counts += counts[si] * si; + printf ("%7d %-10d (%5.1f%%) %5.1f%%\n", + si, counts[si], (counts[si] * 100.0) / nbuckets, + (nzero_counts * 100.0) / nsyms); + } } free (counts); @@ -3411,9 +4483,9 @@ process_symbol_table (file) static int process_syminfo (file) - FILE * file; + FILE * file ATTRIBUTE_UNUSED; { - int i; + unsigned int i; if (dynamic_syminfo == NULL || !do_dynamic) @@ -3490,8 +4562,8 @@ dump_section (section, file) Elf32_Internal_Shdr * section; FILE * file; { - int bytes; - int addr; + bfd_size_type bytes; + bfd_vma addr; unsigned char * data; unsigned char * start; @@ -3521,10 +4593,11 @@ dump_section (section, file) lbytes = (bytes > 16 ? 16 : bytes); - printf (" 0x%8.8x ", addr); + printf (" 0x%8.8lx ", (unsigned long) addr); switch (elf_header.e_ident [EI_DATA]) { + default: case ELFDATA2LSB: for (j = 15; j >= 0; j --) { @@ -3639,16 +4712,17 @@ reset_state_machine (is_stmt) /* Handled an extend line op. Returns true if this is the end of sequence. */ static int -process_extended_line_op (data, is_stmt) +process_extended_line_op (data, is_stmt, pointer_size) unsigned char * data; int is_stmt; + int pointer_size; { unsigned char op_code; int bytes_read; unsigned int len; unsigned char * name; unsigned long adr; - + len = read_leb128 (data, & bytes_read, 0); data += bytes_read; @@ -3662,7 +4736,7 @@ process_extended_line_op (data, is_stmt) op_code = * data ++; printf (_(" Extended opcode %d: "), op_code); - + switch (op_code) { case DW_LNE_end_sequence: @@ -3671,8 +4745,7 @@ process_extended_line_op (data, is_stmt) break; case DW_LNE_set_address: - /* XXX - assumption here that address size is 4! */ - adr = byte_get (data, 4); + adr = byte_get (data, pointer_size); printf (_("set Address to 0x%lx\n"), adr); state_machine_regs.address = adr; break; @@ -3680,7 +4753,7 @@ process_extended_line_op (data, is_stmt) case DW_LNE_define_file: printf (_(" define new File Table entry\n")); printf (_(" Entry\tDir\tTime\tSize\tName\n")); - + printf (_(" %d\t"), ++ state_machine_regs.last_file_entry); name = data; data += strlen (data) + 1; @@ -3700,12 +4773,16 @@ process_extended_line_op (data, is_stmt) return len; } +/* Size of pointers in the .debug_line section. This information is not + really present in that section. It's obtained before dumping the debug + sections by doing some pre-scan of the .debug_info section. */ +static int debug_line_pointer_size = 4; static int display_debug_lines (section, start, file) Elf32_Internal_Shdr * section; unsigned char * start; - FILE * file; + FILE * file ATTRIBUTE_UNUSED; { DWARF2_External_LineInfo * external; DWARF2_Internal_LineInfo info; @@ -3730,7 +4807,7 @@ display_debug_lines (section, start, file) (_("The line info appears to be corrupt - the section is too small\n")); return 0; } - + /* Check its version number. */ info.li_version = BYTE_GET (external->li_version); if (info.li_version != 2) @@ -3738,18 +4815,18 @@ display_debug_lines (section, start, file) warn (_("Only DWARF version 2 line info is currently supported.\n")); return 0; } - + info.li_prologue_length = BYTE_GET (external->li_prologue_length); info.li_min_insn_length = BYTE_GET (external->li_min_insn_length); info.li_default_is_stmt = BYTE_GET (external->li_default_is_stmt); info.li_line_base = BYTE_GET (external->li_line_base); info.li_line_range = BYTE_GET (external->li_line_range); info.li_opcode_base = BYTE_GET (external->li_opcode_base); - + /* Sign extend the line base field. */ info.li_line_base <<= 24; info.li_line_base >>= 24; - + printf (_(" Length: %ld\n"), info.li_length); printf (_(" DWARF Version: %d\n"), info.li_version); printf (_(" Prolgue Length: %d\n"), info.li_prologue_length); @@ -3762,35 +4839,35 @@ display_debug_lines (section, start, file) end_of_sequence = data + info.li_length + sizeof (info.li_length); reset_state_machine (info.li_default_is_stmt); - + /* Display the contents of the Opcodes table. */ standard_opcodes = data + sizeof (* external); - + printf (_("\n Opcodes:\n")); - + for (i = 1; i < info.li_opcode_base; i++) - printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i]); - + printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]); + /* Display the contents of the Directory table. */ data = standard_opcodes + info.li_opcode_base - 1; - + if (* data == 0) printf (_("\n The Directory Table is empty.\n")); else { printf (_("\n The Directory Table:\n")); - + while (* data != 0) { printf (_(" %s\n"), data); - + data += strlen (data) + 1; } } - + /* Skip the NUL at the end of the table. */ data ++; - + /* Display the contents of the File Name table. */ if (* data == 0) printf (_("\n The File Name Table is empty.\n")); @@ -3798,17 +4875,17 @@ display_debug_lines (section, start, file) { printf (_("\n The File Name Table:\n")); printf (_(" Entry\tDir\tTime\tSize\tName\n")); - + while (* data != 0) { char * name; int bytes_read; - + printf (_(" %d\t"), ++ state_machine_regs.last_file_entry); name = data; - + data += strlen (data) + 1; - + printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0)); data += bytes_read; printf (_("%lu\t"), read_leb128 (data, & bytes_read, 0)); @@ -3818,32 +4895,33 @@ display_debug_lines (section, start, file) printf (_("%s\n"), name); } } - + /* Skip the NUL at the end of the table. */ data ++; - + /* Now display the statements. */ printf (_("\n Line Number Statements:\n")); - - + + while (data < end_of_sequence) { unsigned char op_code; int adv; int bytes_read; - + op_code = * data ++; - + switch (op_code) { case DW_LNS_extended_op: - data += process_extended_line_op (data, info.li_default_is_stmt); + data += process_extended_line_op (data, info.li_default_is_stmt, + debug_line_pointer_size); break; - + case DW_LNS_copy: printf (_(" Copy\n")); break; - + case DW_LNS_advance_pc: adv = info.li_min_insn_length * read_leb128 (data, & bytes_read, 0); data += bytes_read; @@ -3851,7 +4929,7 @@ display_debug_lines (section, start, file) printf (_(" Advance PC by %d to %lx\n"), adv, state_machine_regs.address); break; - + case DW_LNS_advance_line: adv = read_leb128 (data, & bytes_read, 1); data += bytes_read; @@ -3859,7 +4937,7 @@ display_debug_lines (section, start, file) printf (_(" Advance Line by %d to %d\n"), adv, state_machine_regs.line); break; - + case DW_LNS_set_file: adv = read_leb128 (data, & bytes_read, 0); data += bytes_read; @@ -3867,33 +4945,34 @@ display_debug_lines (section, start, file) adv); state_machine_regs.file = adv; break; - + case DW_LNS_set_column: adv = read_leb128 (data, & bytes_read, 0); data += bytes_read; printf (_(" Set column to %d\n"), adv); state_machine_regs.column = adv; break; - + case DW_LNS_negate_stmt: adv = state_machine_regs.is_stmt; adv = ! adv; printf (_(" Set is_stmt to %d\n"), adv); state_machine_regs.is_stmt = adv; break; - + case DW_LNS_set_basic_block: printf (_(" Set basic block\n")); state_machine_regs.basic_block = 1; break; - + case DW_LNS_const_add_pc: - adv = (255 - info.li_opcode_base) / info.li_line_range; + adv = (((255 - info.li_opcode_base) / info.li_line_range) + * info.li_min_insn_length); state_machine_regs.address += adv; printf (_(" Advance PC by constant %d to 0x%lx\n"), adv, state_machine_regs.address); break; - + case DW_LNS_fixed_advance_pc: adv = byte_get (data, 2); data += 2; @@ -3901,14 +4980,14 @@ display_debug_lines (section, start, file) printf (_(" Advance PC by fixed size amount %d to 0x%lx\n"), adv, state_machine_regs.address); break; - + default: op_code -= info.li_opcode_base; adv = (op_code / info.li_line_range) * info.li_min_insn_length; state_machine_regs.address += adv; printf (_(" Special opcode %d: advance Address by %d to 0x%lx"), op_code, adv, state_machine_regs.address); - adv += (op_code % info.li_line_range) + info.li_line_base; + adv = (op_code % info.li_line_range) + info.li_line_base; state_machine_regs.line += adv; printf (_(" and Line by %d to %d\n"), adv, state_machine_regs.line); @@ -3917,7 +4996,7 @@ display_debug_lines (section, start, file) } printf ("\n"); } - + return 1; } @@ -3925,7 +5004,7 @@ static int display_debug_pubnames (section, start, file) Elf32_Internal_Shdr * section; unsigned char * start; - FILE * file; + FILE * file ATTRIBUTE_UNUSED; { DWARF2_External_PubNames * external; DWARF2_Internal_PubNames pubnames; @@ -4313,8 +5392,11 @@ process_abbrev_section (start, end) entry = read_leb128 (start, & bytes_read, 0); start += bytes_read; + /* A single zero is supposed to end the section according + to the standard. If there's more, then signal that to + the caller. */ if (entry == 0) - return start; + return start == end ? NULL : start; tag = read_leb128 (start, & bytes_read, 0); start += bytes_read; @@ -4347,7 +5429,7 @@ static int display_debug_abbrev (section, start, file) Elf32_Internal_Shdr * section; unsigned char * start; - FILE * file; + FILE * file ATTRIBUTE_UNUSED; { abbrev_entry * entry; unsigned char * end = start + section->sh_size; @@ -4393,7 +5475,7 @@ display_block (data, length) printf (_(" %lu byte block: "), length); while (length --) - printf ("%lx ", byte_get (data ++, 1)); + printf ("%lx ", (unsigned long) byte_get (data ++, 1)); return data; } @@ -4405,156 +5487,451 @@ decode_location_expression (data, pointer_size) { unsigned char op; int bytes_read; + unsigned long uvalue; op = * data ++; switch (op) { - case DW_OP_addr: printf ("DW_OP_addr: %lx", byte_get (data, pointer_size)); break; - case DW_OP_deref: printf ("DW_OP_deref"); break; - case DW_OP_const1u: printf ("DW_OP_const1u: %lu", byte_get (data, 1)); break; - case DW_OP_const1s: printf ("DW_OP_const1s: %ld", (long) byte_get (data, 1)); break; - case DW_OP_const2u: printf ("DW_OP_const2u: %lu", byte_get (data, 2)); break; - case DW_OP_const2s: printf ("DW_OP_const2s: %ld", (long) byte_get (data, 2)); break; - case DW_OP_const4u: printf ("DW_OP_const4u: %lu", byte_get (data, 4)); break; - case DW_OP_const4s: printf ("DW_OP_const4s: %ld", (long) byte_get (data, 4)); break; - case DW_OP_const8u: printf ("DW_OP_const8u: %lu %lu", byte_get (data, 4), byte_get (data + 4, 4)); break; - case DW_OP_const8s: printf ("DW_OP_const8s: %ld %ld", byte_get (data, 4), byte_get (data + 4, 4)); break; - case DW_OP_constu: printf ("DW_OP_constu: %lu", read_leb128 (data, NULL, 0)); break; - case DW_OP_consts: printf ("DW_OP_consts: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_dup: printf ("DW_OP_dup"); break; - case DW_OP_drop: printf ("DW_OP_drop"); break; - case DW_OP_over: printf ("DW_OP_over"); break; - case DW_OP_pick: printf ("DW_OP_pick: %ld", byte_get (data, 1)); break; - case DW_OP_swap: printf ("DW_OP_swap"); break; - case DW_OP_rot: printf ("DW_OP_rot"); break; - case DW_OP_xderef: printf ("DW_OP_xderef"); break; - case DW_OP_abs: printf ("DW_OP_abs"); break; - case DW_OP_and: printf ("DW_OP_and"); break; - case DW_OP_div: printf ("DW_OP_div"); break; - case DW_OP_minus: printf ("DW_OP_minus"); break; - case DW_OP_mod: printf ("DW_OP_mod"); break; - case DW_OP_mul: printf ("DW_OP_mul"); break; - case DW_OP_neg: printf ("DW_OP_neg"); break; - case DW_OP_not: printf ("DW_OP_not"); break; - case DW_OP_or: printf ("DW_OP_or"); break; - case DW_OP_plus: printf ("DW_OP_plus"); break; - case DW_OP_plus_uconst: printf ("DW_OP_plus_uconst: %lu", read_leb128 (data, NULL, 0)); break; - case DW_OP_shl: printf ("DW_OP_shl"); break; - case DW_OP_shr: printf ("DW_OP_shr"); break; - case DW_OP_shra: printf ("DW_OP_shra"); break; - case DW_OP_xor: printf ("DW_OP_xor"); break; - case DW_OP_bra: printf ("DW_OP_bra: %ld", byte_get (data, 2)); break; - case DW_OP_eq: printf ("DW_OP_eq"); break; - case DW_OP_ge: printf ("DW_OP_ge"); break; - case DW_OP_gt: printf ("DW_OP_gt"); break; - case DW_OP_le: printf ("DW_OP_le"); break; - case DW_OP_lt: printf ("DW_OP_lt"); break; - case DW_OP_ne: printf ("DW_OP_ne"); break; - case DW_OP_skip: printf ("DW_OP_skip: %ld", byte_get (data, 2)); break; - case DW_OP_lit0: printf ("DW_OP_lit0"); break; - case DW_OP_lit1: printf ("DW_OP_lit1"); break; - case DW_OP_lit2: printf ("DW_OP_lit2"); break; - case DW_OP_lit3: printf ("DW_OP_lit3"); break; - case DW_OP_lit4: printf ("DW_OP_lit4"); break; - case DW_OP_lit5: printf ("DW_OP_lit5"); break; - case DW_OP_lit6: printf ("DW_OP_lit6"); break; - case DW_OP_lit7: printf ("DW_OP_lit7"); break; - case DW_OP_lit8: printf ("DW_OP_lit8"); break; - case DW_OP_lit9: printf ("DW_OP_lit9"); break; - case DW_OP_lit10: printf ("DW_OP_lit10"); break; - case DW_OP_lit11: printf ("DW_OP_lit11"); break; - case DW_OP_lit12: printf ("DW_OP_lit12"); break; - case DW_OP_lit13: printf ("DW_OP_lit13"); break; - case DW_OP_lit14: printf ("DW_OP_lit14"); break; - case DW_OP_lit15: printf ("DW_OP_lit15"); break; - case DW_OP_lit16: printf ("DW_OP_lit16"); break; - case DW_OP_lit17: printf ("DW_OP_lit17"); break; - case DW_OP_lit18: printf ("DW_OP_lit18"); break; - case DW_OP_lit19: printf ("DW_OP_lit19"); break; - case DW_OP_lit20: printf ("DW_OP_lit20"); break; - case DW_OP_lit21: printf ("DW_OP_lit21"); break; - case DW_OP_lit22: printf ("DW_OP_lit22"); break; - case DW_OP_lit23: printf ("DW_OP_lit23"); break; - case DW_OP_lit24: printf ("DW_OP_lit24"); break; - case DW_OP_lit25: printf ("DW_OP_lit25"); break; - case DW_OP_lit26: printf ("DW_OP_lit26"); break; - case DW_OP_lit27: printf ("DW_OP_lit27"); break; - case DW_OP_lit28: printf ("DW_OP_lit28"); break; - case DW_OP_lit29: printf ("DW_OP_lit29"); break; - case DW_OP_lit30: printf ("DW_OP_lit30"); break; - case DW_OP_lit31: printf ("DW_OP_lit31"); break; - case DW_OP_reg0: printf ("DW_OP_reg0"); break; - case DW_OP_reg1: printf ("DW_OP_reg1"); break; - case DW_OP_reg2: printf ("DW_OP_reg2"); break; - case DW_OP_reg3: printf ("DW_OP_reg3"); break; - case DW_OP_reg4: printf ("DW_OP_reg4"); break; - case DW_OP_reg5: printf ("DW_OP_reg5"); break; - case DW_OP_reg6: printf ("DW_OP_reg6"); break; - case DW_OP_reg7: printf ("DW_OP_reg7"); break; - case DW_OP_reg8: printf ("DW_OP_reg8"); break; - case DW_OP_reg9: printf ("DW_OP_reg9"); break; - case DW_OP_reg10: printf ("DW_OP_reg10"); break; - case DW_OP_reg11: printf ("DW_OP_reg11"); break; - case DW_OP_reg12: printf ("DW_OP_reg12"); break; - case DW_OP_reg13: printf ("DW_OP_reg13"); break; - case DW_OP_reg14: printf ("DW_OP_reg14"); break; - case DW_OP_reg15: printf ("DW_OP_reg15"); break; - case DW_OP_reg16: printf ("DW_OP_reg16"); break; - case DW_OP_reg17: printf ("DW_OP_reg17"); break; - case DW_OP_reg18: printf ("DW_OP_reg18"); break; - case DW_OP_reg19: printf ("DW_OP_reg19"); break; - case DW_OP_reg20: printf ("DW_OP_reg20"); break; - case DW_OP_reg21: printf ("DW_OP_reg21"); break; - case DW_OP_reg22: printf ("DW_OP_reg22"); break; - case DW_OP_reg23: printf ("DW_OP_reg23"); break; - case DW_OP_reg24: printf ("DW_OP_reg24"); break; - case DW_OP_reg25: printf ("DW_OP_reg25"); break; - case DW_OP_reg26: printf ("DW_OP_reg26"); break; - case DW_OP_reg27: printf ("DW_OP_reg27"); break; - case DW_OP_reg28: printf ("DW_OP_reg28"); break; - case DW_OP_reg29: printf ("DW_OP_reg29"); break; - case DW_OP_reg30: printf ("DW_OP_reg30"); break; - case DW_OP_reg31: printf ("DW_OP_reg31"); break; - case DW_OP_breg0: printf ("DW_OP_breg0: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg1: printf ("DW_OP_breg1: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg2: printf ("DW_OP_breg2: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg3: printf ("DW_OP_breg3: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg4: printf ("DW_OP_breg4: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg5: printf ("DW_OP_breg5: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg6: printf ("DW_OP_breg6: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg7: printf ("DW_OP_breg7: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg8: printf ("DW_OP_breg8: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg9: printf ("DW_OP_breg9: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg10: printf ("DW_OP_breg10: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg11: printf ("DW_OP_breg11: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg12: printf ("DW_OP_breg12: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg13: printf ("DW_OP_breg13: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg14: printf ("DW_OP_breg14: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg15: printf ("DW_OP_breg15: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg16: printf ("DW_OP_breg16: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg17: printf ("DW_OP_breg17: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg18: printf ("DW_OP_breg18: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg19: printf ("DW_OP_breg19: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg20: printf ("DW_OP_breg20: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg21: printf ("DW_OP_breg21: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg22: printf ("DW_OP_breg22: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg23: printf ("DW_OP_breg23: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg24: printf ("DW_OP_breg24: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg25: printf ("DW_OP_breg25: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg26: printf ("DW_OP_breg26: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg27: printf ("DW_OP_breg27: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg28: printf ("DW_OP_breg28: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg29: printf ("DW_OP_breg29: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg30: printf ("DW_OP_breg30: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_breg31: printf ("DW_OP_breg31: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_regx: printf ("DW_OP_regx: %lu", read_leb128 (data, NULL, 0)); break; - case DW_OP_fbreg: printf ("DW_OP_fbreg: %ld", read_leb128 (data, NULL, 1)); break; - case DW_OP_bregx: printf ("DW_OP_bregx: %lu %ld", read_leb128 (data, & bytes_read, 0), read_leb128 (data + bytes_read, NULL, 1)); break; - case DW_OP_piece: printf ("DW_OP_piece: %lu", read_leb128 (data, NULL, 0)); break; - case DW_OP_deref_size: printf ("DW_OP_deref_size: %ld", byte_get (data, 1)); break; - case DW_OP_xderef_size: printf ("DW_OP_xderef_size: %ld", byte_get (data, 1)); break; - case DW_OP_nop: printf ("DW_OP_nop"); break; + case DW_OP_addr: + printf ("DW_OP_addr: %lx", (unsigned long) byte_get (data, pointer_size)); + break; + case DW_OP_deref: + printf ("DW_OP_deref"); + break; + case DW_OP_const1u: + printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data, 1)); + break; + case DW_OP_const1s: + printf ("DW_OP_const1s: %ld", (long) byte_get (data, 1)); + break; + case DW_OP_const2u: + printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2)); + break; + case DW_OP_const2s: + printf ("DW_OP_const2s: %ld", (long) byte_get (data, 2)); + break; + case DW_OP_const4u: + printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4)); + break; + case DW_OP_const4s: + printf ("DW_OP_const4s: %ld", (long) byte_get (data, 4)); + break; + case DW_OP_const8u: + printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4), + (unsigned long) byte_get (data + 4, 4)); + break; + case DW_OP_const8s: + printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4), + (long) byte_get (data + 4, 4)); + break; + case DW_OP_constu: + printf ("DW_OP_constu: %lu", read_leb128 (data, NULL, 0)); + break; + case DW_OP_consts: + printf ("DW_OP_consts: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_dup: + printf ("DW_OP_dup"); + break; + case DW_OP_drop: + printf ("DW_OP_drop"); + break; + case DW_OP_over: + printf ("DW_OP_over"); + break; + case DW_OP_pick: + printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data, 1)); + break; + case DW_OP_swap: + printf ("DW_OP_swap"); + break; + case DW_OP_rot: + printf ("DW_OP_rot"); + break; + case DW_OP_xderef: + printf ("DW_OP_xderef"); + break; + case DW_OP_abs: + printf ("DW_OP_abs"); + break; + case DW_OP_and: + printf ("DW_OP_and"); + break; + case DW_OP_div: + printf ("DW_OP_div"); + break; + case DW_OP_minus: + printf ("DW_OP_minus"); + break; + case DW_OP_mod: + printf ("DW_OP_mod"); + break; + case DW_OP_mul: + printf ("DW_OP_mul"); + break; + case DW_OP_neg: + printf ("DW_OP_neg"); + break; + case DW_OP_not: + printf ("DW_OP_not"); + break; + case DW_OP_or: + printf ("DW_OP_or"); + break; + case DW_OP_plus: + printf ("DW_OP_plus"); + break; + case DW_OP_plus_uconst: + printf ("DW_OP_plus_uconst: %lu", read_leb128 (data, NULL, 0)); + break; + case DW_OP_shl: + printf ("DW_OP_shl"); + break; + case DW_OP_shr: + printf ("DW_OP_shr"); + break; + case DW_OP_shra: + printf ("DW_OP_shra"); + break; + case DW_OP_xor: + printf ("DW_OP_xor"); + break; + case DW_OP_bra: + printf ("DW_OP_bra: %ld", (long) byte_get (data, 2)); + break; + case DW_OP_eq: + printf ("DW_OP_eq"); + break; + case DW_OP_ge: + printf ("DW_OP_ge"); + break; + case DW_OP_gt: + printf ("DW_OP_gt"); + break; + case DW_OP_le: + printf ("DW_OP_le"); + break; + case DW_OP_lt: + printf ("DW_OP_lt"); + break; + case DW_OP_ne: + printf ("DW_OP_ne"); + break; + case DW_OP_skip: + printf ("DW_OP_skip: %ld", (long) byte_get (data, 2)); + break; + case DW_OP_lit0: + printf ("DW_OP_lit0"); + break; + case DW_OP_lit1: + printf ("DW_OP_lit1"); + break; + case DW_OP_lit2: + printf ("DW_OP_lit2"); + break; + case DW_OP_lit3: + printf ("DW_OP_lit3"); + break; + case DW_OP_lit4: + printf ("DW_OP_lit4"); + break; + case DW_OP_lit5: + printf ("DW_OP_lit5"); + break; + case DW_OP_lit6: + printf ("DW_OP_lit6"); + break; + case DW_OP_lit7: + printf ("DW_OP_lit7"); + break; + case DW_OP_lit8: + printf ("DW_OP_lit8"); + break; + case DW_OP_lit9: + printf ("DW_OP_lit9"); + break; + case DW_OP_lit10: + printf ("DW_OP_lit10"); + break; + case DW_OP_lit11: + printf ("DW_OP_lit11"); + break; + case DW_OP_lit12: + printf ("DW_OP_lit12"); + break; + case DW_OP_lit13: + printf ("DW_OP_lit13"); + break; + case DW_OP_lit14: + printf ("DW_OP_lit14"); + break; + case DW_OP_lit15: + printf ("DW_OP_lit15"); + break; + case DW_OP_lit16: + printf ("DW_OP_lit16"); + break; + case DW_OP_lit17: + printf ("DW_OP_lit17"); + break; + case DW_OP_lit18: + printf ("DW_OP_lit18"); + break; + case DW_OP_lit19: + printf ("DW_OP_lit19"); + break; + case DW_OP_lit20: + printf ("DW_OP_lit20"); + break; + case DW_OP_lit21: + printf ("DW_OP_lit21"); + break; + case DW_OP_lit22: + printf ("DW_OP_lit22"); + break; + case DW_OP_lit23: + printf ("DW_OP_lit23"); + break; + case DW_OP_lit24: + printf ("DW_OP_lit24"); + break; + case DW_OP_lit25: + printf ("DW_OP_lit25"); + break; + case DW_OP_lit26: + printf ("DW_OP_lit26"); + break; + case DW_OP_lit27: + printf ("DW_OP_lit27"); + break; + case DW_OP_lit28: + printf ("DW_OP_lit28"); + break; + case DW_OP_lit29: + printf ("DW_OP_lit29"); + break; + case DW_OP_lit30: + printf ("DW_OP_lit30"); + break; + case DW_OP_lit31: + printf ("DW_OP_lit31"); + break; + case DW_OP_reg0: + printf ("DW_OP_reg0"); + break; + case DW_OP_reg1: + printf ("DW_OP_reg1"); + break; + case DW_OP_reg2: + printf ("DW_OP_reg2"); + break; + case DW_OP_reg3: + printf ("DW_OP_reg3"); + break; + case DW_OP_reg4: + printf ("DW_OP_reg4"); + break; + case DW_OP_reg5: + printf ("DW_OP_reg5"); + break; + case DW_OP_reg6: + printf ("DW_OP_reg6"); + break; + case DW_OP_reg7: + printf ("DW_OP_reg7"); + break; + case DW_OP_reg8: + printf ("DW_OP_reg8"); + break; + case DW_OP_reg9: + printf ("DW_OP_reg9"); + break; + case DW_OP_reg10: + printf ("DW_OP_reg10"); + break; + case DW_OP_reg11: + printf ("DW_OP_reg11"); + break; + case DW_OP_reg12: + printf ("DW_OP_reg12"); + break; + case DW_OP_reg13: + printf ("DW_OP_reg13"); + break; + case DW_OP_reg14: + printf ("DW_OP_reg14"); + break; + case DW_OP_reg15: + printf ("DW_OP_reg15"); + break; + case DW_OP_reg16: + printf ("DW_OP_reg16"); + break; + case DW_OP_reg17: + printf ("DW_OP_reg17"); + break; + case DW_OP_reg18: + printf ("DW_OP_reg18"); + break; + case DW_OP_reg19: + printf ("DW_OP_reg19"); + break; + case DW_OP_reg20: + printf ("DW_OP_reg20"); + break; + case DW_OP_reg21: + printf ("DW_OP_reg21"); + break; + case DW_OP_reg22: + printf ("DW_OP_reg22"); + break; + case DW_OP_reg23: + printf ("DW_OP_reg23"); + break; + case DW_OP_reg24: + printf ("DW_OP_reg24"); + break; + case DW_OP_reg25: + printf ("DW_OP_reg25"); + break; + case DW_OP_reg26: + printf ("DW_OP_reg26"); + break; + case DW_OP_reg27: + printf ("DW_OP_reg27"); + break; + case DW_OP_reg28: + printf ("DW_OP_reg28"); + break; + case DW_OP_reg29: + printf ("DW_OP_reg29"); + break; + case DW_OP_reg30: + printf ("DW_OP_reg30"); + break; + case DW_OP_reg31: + printf ("DW_OP_reg31"); + break; + case DW_OP_breg0: + printf ("DW_OP_breg0: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg1: + printf ("DW_OP_breg1: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg2: + printf ("DW_OP_breg2: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg3: + printf ("DW_OP_breg3: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg4: + printf ("DW_OP_breg4: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg5: + printf ("DW_OP_breg5: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg6: + printf ("DW_OP_breg6: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg7: + printf ("DW_OP_breg7: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg8: + printf ("DW_OP_breg8: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg9: + printf ("DW_OP_breg9: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg10: + printf ("DW_OP_breg10: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg11: + printf ("DW_OP_breg11: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg12: + printf ("DW_OP_breg12: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg13: + printf ("DW_OP_breg13: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg14: + printf ("DW_OP_breg14: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg15: + printf ("DW_OP_breg15: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg16: + printf ("DW_OP_breg16: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg17: + printf ("DW_OP_breg17: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg18: + printf ("DW_OP_breg18: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg19: + printf ("DW_OP_breg19: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg20: + printf ("DW_OP_breg20: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg21: + printf ("DW_OP_breg21: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg22: + printf ("DW_OP_breg22: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg23: + printf ("DW_OP_breg23: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg24: + printf ("DW_OP_breg24: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg25: + printf ("DW_OP_breg25: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg26: + printf ("DW_OP_breg26: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg27: + printf ("DW_OP_breg27: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg28: + printf ("DW_OP_breg28: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg29: + printf ("DW_OP_breg29: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg30: + printf ("DW_OP_breg30: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_breg31: + printf ("DW_OP_breg31: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_regx: + printf ("DW_OP_regx: %lu", read_leb128 (data, NULL, 0)); + break; + case DW_OP_fbreg: + printf ("DW_OP_fbreg: %ld", read_leb128 (data, NULL, 1)); + break; + case DW_OP_bregx: + uvalue = read_leb128 (data, &bytes_read, 0); + printf ("DW_OP_bregx: %lu %ld", uvalue, + read_leb128 (data + bytes_read, NULL, 1)); + break; + case DW_OP_piece: + printf ("DW_OP_piece: %lu", read_leb128 (data, NULL, 0)); + break; + case DW_OP_deref_size: + printf ("DW_OP_deref_size: %ld", (long) byte_get (data, 1)); + break; + case DW_OP_xderef_size: + printf ("DW_OP_xderef_size: %ld", (long) byte_get (data, 1)); + break; + case DW_OP_nop: + printf ("DW_OP_nop"); + break; default: if (op >= DW_OP_lo_user @@ -4574,8 +5951,8 @@ read_and_display_attr (attribute, form, data, pointer_size) unsigned char * data; unsigned long pointer_size; { - unsigned long uvalue; - unsigned char * block_start; + unsigned long uvalue = 0; + unsigned char * block_start = NULL; int bytes_read; int is_ref = 0; @@ -4597,7 +5974,7 @@ read_and_display_attr (attribute, form, data, pointer_size) case DW_FORM_ref_addr: case DW_FORM_addr: uvalue = byte_get (data, pointer_size); - printf (is_ref ? " <%x>" : " %#x", uvalue); + printf (is_ref ? " <%lx>" : " %#lx", uvalue); data += pointer_size; break; @@ -4605,28 +5982,28 @@ read_and_display_attr (attribute, form, data, pointer_size) case DW_FORM_flag: case DW_FORM_data1: uvalue = byte_get (data ++, 1); - printf (is_ref ? " <%x>" : " %d", uvalue); + printf (is_ref ? " <%lx>" : " %ld", uvalue); break; case DW_FORM_ref2: case DW_FORM_data2: uvalue = byte_get (data, 2); data += 2; - printf (is_ref ? " <%x>" : " %d", uvalue); + printf (is_ref ? " <%lx>" : " %ld", uvalue); break; case DW_FORM_ref4: case DW_FORM_data4: uvalue = byte_get (data, 4); data += 4; - printf (is_ref ? " <%x>" : " %d", uvalue); + printf (is_ref ? " <%lx>" : " %ld", uvalue); break; case DW_FORM_ref8: case DW_FORM_data8: uvalue = byte_get (data, 4); printf (" %lx", uvalue); - printf (" %lx", byte_get (data + 4, 4)); + printf (" %lx", (unsigned long) byte_get (data + 4, 4)); data += 8; break; @@ -4896,7 +6273,7 @@ display_debug_info (section, start, file) while (tags < start) { int bytes_read; - int abbrev_number; + unsigned long abbrev_number; abbrev_entry * entry; abbrev_attr * attr; @@ -4919,12 +6296,12 @@ display_debug_info (section, start, file) if (entry == NULL) { - warn (_("Unable to locate entry %d in the abbreviation table\n"), + warn (_("Unable to locate entry %lu in the abbreviation table\n"), abbrev_number); return 0; } - printf (_(" <%d><%x>: Abbrev Number: %d (%s)\n"), + printf (_(" <%d><%x>: Abbrev Number: %lu (%s)\n"), level, tags - section_begin - bytes_read, abbrev_number, get_TAG_name (entry->tag)); @@ -4949,7 +6326,7 @@ static int display_debug_aranges (section, start, file) Elf32_Internal_Shdr * section; unsigned char * start; - FILE * file; + FILE * file ATTRIBUTE_UNUSED; { unsigned char * end = start + section->sh_size; @@ -4962,6 +6339,7 @@ display_debug_aranges (section, start, file) unsigned char * ranges; unsigned long length; unsigned long address; + int excess; external = (DWARF2_External_ARange *) start; @@ -4981,19 +6359,25 @@ display_debug_aranges (section, start, file) ranges = start + sizeof (* external); + /* Must pad to an alignment boundary that is twice the pointer size. */ + excess = sizeof (*external) % (2 * arange.ar_pointer_size); + if (excess) + ranges += (2 * arange.ar_pointer_size) - excess; + for (;;) { address = byte_get (ranges, arange.ar_pointer_size); - if (address == 0) - break; - ranges += arange.ar_pointer_size; length = byte_get (ranges, arange.ar_pointer_size); ranges += arange.ar_pointer_size; + /* A pair of zeros marks the end of the list. */ + if (address == 0 && length == 0) + break; + printf (" %8.8lx %lu\n", address, length); } @@ -5009,8 +6393,8 @@ display_debug_aranges (section, start, file) static int display_debug_not_supported (section, start, file) Elf32_Internal_Shdr * section; - unsigned char * start; - FILE * file; + unsigned char * start ATTRIBUTE_UNUSED; + FILE * file ATTRIBUTE_UNUSED; { printf (_("Displaying the debug contents of section %s is not yet supported.\n"), SECTION_NAME (section)); @@ -5018,27 +6402,47 @@ display_debug_not_supported (section, start, file) return 1; } +/* Pre-scan the .debug_info section to record the size of address. + When dumping the .debug_line, we use that size information, assuming + that all compilation units have the same address size. */ +static int +prescan_debug_info (section, start, file) + Elf32_Internal_Shdr * section ATTRIBUTE_UNUSED; + unsigned char * start; + FILE * file ATTRIBUTE_UNUSED; +{ + DWARF2_External_CompUnit * external; + + external = (DWARF2_External_CompUnit *) start; + + debug_line_pointer_size = BYTE_GET (external->cu_pointer_size); + return 0; +} + /* A structure containing the name of a debug section and a pointer - to a function that can decode it. */ + to a function that can decode it. The third field is a prescan + function to be run over the section before displaying any of the + sections. */ struct { char * name; - int (* display) PARAMS((Elf32_Internal_Shdr *, unsigned char *, FILE *)); + int (* display) PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *)); + int (* prescan) PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *)); } debug_displays[] = { - { ".debug_info", display_debug_info }, - { ".debug_abbrev", display_debug_abbrev }, - { ".debug_line", display_debug_lines }, - { ".debug_aranges", display_debug_aranges }, - { ".debug_pubnames", display_debug_pubnames }, - { ".debug_macinfo", display_debug_not_supported }, - { ".debug_frame", display_debug_not_supported }, - { ".debug_str", display_debug_not_supported }, - { ".debug_static_func", display_debug_not_supported }, - { ".debug_static_vars", display_debug_not_supported }, - { ".debug_types", display_debug_not_supported }, - { ".debug_weaknames", display_debug_not_supported } + { ".debug_info", display_debug_info, prescan_debug_info }, + { ".debug_abbrev", display_debug_abbrev, NULL }, + { ".debug_line", display_debug_lines, NULL }, + { ".debug_aranges", display_debug_aranges, NULL }, + { ".debug_pubnames", display_debug_pubnames, NULL }, + { ".debug_macinfo", display_debug_not_supported, NULL }, + { ".debug_frame", display_debug_not_supported, NULL }, + { ".debug_str", display_debug_not_supported, NULL }, + { ".debug_static_func", display_debug_not_supported, NULL }, + { ".debug_static_vars", display_debug_not_supported, NULL }, + { ".debug_types", display_debug_not_supported, NULL }, + { ".debug_weaknames", display_debug_not_supported, NULL } }; static int @@ -5086,15 +6490,48 @@ static int process_section_contents (file) FILE * file; { - Elf32_Internal_Shdr * section; - unsigned int i; + Elf32_Internal_Shdr * section; + unsigned int i; if (! do_dump) return 1; + /* Pre-scan the debug sections to find some debug information not + present in some of them. For the .debug_line, we must find out the + size of address (specified in .debug_info and .debug_aranges). */ + for (i = 0, section = section_headers; + i < elf_header.e_shnum && i < num_dump_sects; + i ++, section ++) + { + char * name = SECTION_NAME (section); + int j; + + if (section->sh_size == 0) + continue; + + /* See if there is some pre-scan operation for this section. */ + for (j = NUM_ELEM (debug_displays); j--;) + if (strcmp (debug_displays[j].name, name) == 0) + { + if (debug_displays[j].prescan != NULL) + { + bfd_size_type length; + unsigned char * start; + + length = section->sh_size; + GET_DATA_ALLOC (section->sh_offset, length, start, unsigned char *, + "debug section data"); + + debug_displays[j].prescan (section, start, file); + free (start); + } + + break; + } + } + for (i = 0, section = section_headers; - i < elf_header.e_shnum - && i < num_dump_sects; + i < elf_header.e_shnum && i < num_dump_sects; i ++, section ++) { #ifdef SUPPORT_DISASSEMBLY @@ -5138,9 +6575,9 @@ process_mips_fpe_exception (mask) static int process_mips_specific (file) - FILE *file; + FILE * file; { - Elf_Internal_Dyn *entry; + Elf_Internal_Dyn * entry; size_t liblist_offset = 0; size_t liblistno = 0; size_t conflictsno = 0; @@ -5176,13 +6613,14 @@ process_mips_specific (file) if (liblist_offset != 0 && liblistno != 0 && do_dynamic) { - Elf32_External_Lib *elib; + Elf32_External_Lib * elib; size_t cnt; GET_DATA_ALLOC (liblist_offset, liblistno * sizeof (Elf32_External_Lib), elib, Elf32_External_Lib *, "liblist"); - printf ("\nSection '.liblist' contains %d entries:\n", liblistno); + printf ("\nSection '.liblist' contains %lu entries:\n", + (unsigned long) liblistno); fputs (" Library Time Stamp Checksum Version Flags\n", stdout); @@ -5200,7 +6638,7 @@ process_mips_specific (file) strftime (timebuf, 20, "%Y-%m-%dT%H:%M:%S", gmtime (&time)); - printf ("%3d: %-20s %s %#10lx %-7ld", cnt, + printf ("%3lu: %-20s %s %#10lx %-7ld", (unsigned long) cnt, dynamic_strings + liblist.l_name, timebuf, liblist.l_checksum, liblist.l_version); @@ -5210,19 +6648,20 @@ process_mips_specific (file) { static const struct { - const char *name; + const char * name; int bit; - } l_flags_vals[] = - { - { " EXACT_MATCH", LL_EXACT_MATCH }, - { " IGNORE_INT_VER", LL_IGNORE_INT_VER }, - { " REQUIRE_MINOR", LL_REQUIRE_MINOR }, - { " EXPORTS", LL_EXPORTS }, - { " DELAY_LOAD", LL_DELAY_LOAD }, - { " DELTA", LL_DELTA } - }; + } + l_flags_vals[] = + { + { " EXACT_MATCH", LL_EXACT_MATCH }, + { " IGNORE_INT_VER", LL_IGNORE_INT_VER }, + { " REQUIRE_MINOR", LL_REQUIRE_MINOR }, + { " EXPORTS", LL_EXPORTS }, + { " DELAY_LOAD", LL_DELAY_LOAD }, + { " DELTA", LL_DELTA } + }; int flags = liblist.l_flags; - int fcnt; + size_t fcnt; for (fcnt = 0; fcnt < sizeof (l_flags_vals) / sizeof (l_flags_vals[0]); @@ -5244,16 +6683,16 @@ process_mips_specific (file) if (options_offset != 0) { - Elf_External_Options *eopt; - Elf_Internal_Shdr *sect = section_headers; - Elf_Internal_Options *iopt; - Elf_Internal_Options *option; + Elf_External_Options * eopt; + Elf_Internal_Shdr * sect = section_headers; + Elf_Internal_Options * iopt; + Elf_Internal_Options * option; size_t offset; int cnt; /* Find the section header so that we get the size. */ while (sect->sh_type != SHT_MIPS_OPTIONS) - ++sect; + ++ sect; GET_DATA_ALLOC (options_offset, sect->sh_size, eopt, Elf_External_Options *, "options"); @@ -5268,9 +6707,10 @@ process_mips_specific (file) offset = cnt = 0; option = iopt; + while (offset < sect->sh_size) { - Elf_External_Options *eoption; + Elf_External_Options * eoption; eoption = (Elf_External_Options *) ((char *) eopt + offset); @@ -5280,6 +6720,7 @@ process_mips_specific (file) option->info = BYTE_GET (eoption->info); offset += option->size; + ++option; ++cnt; } @@ -5288,6 +6729,7 @@ process_mips_specific (file) string_table + sect->sh_name, cnt); option = iopt; + while (cnt-- > 0) { size_t len; @@ -5324,16 +6766,16 @@ process_mips_specific (file) else { /* 64 bit form. */ - Elf64_External_RegInfo *ereg; + Elf64_External_RegInfo * ereg; Elf64_Internal_RegInfo reginfo; ereg = (Elf64_External_RegInfo *) (option + 1); - reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask); + reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask); reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]); reginfo.ri_cprmask[1] = BYTE_GET (ereg->ri_cprmask[1]); reginfo.ri_cprmask[2] = BYTE_GET (ereg->ri_cprmask[2]); reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]); - reginfo.ri_gp_value = BYTE_GET (ereg->ri_gp_value); + reginfo.ri_gp_value = BYTE_GET8 (ereg->ri_gp_value); printf ("GPR %08lx GP 0x", reginfo.ri_gprmask); @@ -5438,9 +6880,9 @@ process_mips_specific (file) if (conflicts_offset != 0 && conflictsno != 0) { - Elf32_External_Conflict *econf32; - Elf64_External_Conflict *econf64; - Elf32_Conflict *iconf; + Elf32_External_Conflict * econf32; + Elf64_External_Conflict * econf64; + Elf32_Conflict * iconf; size_t cnt; if (dynamic_symbols == NULL) @@ -5456,7 +6898,7 @@ process_mips_specific (file) return 0; } - if (binary_class == ELFCLASS32) + if (is_32bit_elf) { GET_DATA_ALLOC (conflicts_offset, conflictsno * sizeof (*econf32), econf32, Elf32_External_Conflict *, "conflict"); @@ -5478,24 +6920,205 @@ process_mips_specific (file) for (cnt = 0; cnt < conflictsno; ++cnt) { - Elf_Internal_Sym *psym = &dynamic_symbols[iconf[cnt]]; + Elf_Internal_Sym * psym = &dynamic_symbols[iconf[cnt]]; - printf ("%5u: %8lu %#10lx %s\n", - cnt, iconf[cnt], (unsigned long) psym->st_value, - dynamic_strings + psym->st_name); + printf ("%5lu: %8lu ", (unsigned long) cnt, iconf[cnt]); + print_vma (psym->st_value, FULL_HEX); + printf (" %s\n", dynamic_strings + psym->st_name); } - free (iconf); } return 1; } +static char * +get_note_type (e_type) + unsigned e_type; +{ + static char buff[64]; + + switch (e_type) + { + case NT_PRSTATUS: return _("NT_PRSTATUS (prstatus structure)"); + case NT_FPREGSET: return _("NT_FPREGSET (floating point registers)"); + case NT_PRPSINFO: return _("NT_PRPSINFO (prpsinfo structure)"); + case NT_TASKSTRUCT: return _("NT_TASKSTRUCT (task structure)"); + case NT_PRXFPREG: return _("NT_PRXFPREG (user_xfpregs structure)"); + case NT_PSTATUS: return _("NT_PSTATUS (pstatus structure)"); + case NT_FPREGS: return _("NT_FPREGS (floating point registers)"); + case NT_PSINFO: return _("NT_PSINFO (psinfo structure)"); + case NT_LWPSTATUS: return _("NT_LWPSTATUS (lwpstatus_t structure)"); + case NT_LWPSINFO: return _("NT_LWPSINFO (lwpsinfo_t structure)"); + case NT_WIN32PSTATUS: return _("NT_WIN32PSTATUS (win32_pstatus strcuture)"); + default: + sprintf (buff, _("Unknown note type: (0x%08x)"), e_type); + return buff; + } +} + +/* Note that by the ELF standard, the name field is already null byte + terminated, and namesz includes the terminating null byte. + I.E. the value of namesz for the name "FSF" is 4. + + If the value of namesz is zero, there is no name present. */ +static int +process_note (pnote) + Elf32_Internal_Note * pnote; +{ + printf (" %s\t\t0x%08lx\t%s\n", + pnote->namesz ? pnote->namedata : "(NONE)", + pnote->descsz, get_note_type (pnote->type)); + return 1; +} + + +static int +process_corefile_note_segment (file, offset, length) + FILE * file; + bfd_vma offset; + bfd_vma length; +{ + Elf_External_Note * pnotes; + Elf_External_Note * external; + int res = 1; + + if (length <= 0) + return 0; + + GET_DATA_ALLOC (offset, length, pnotes, Elf_External_Note *, "notes"); + + external = pnotes; + + printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"), + (unsigned long) offset, + (unsigned long) length); + printf (_(" Owner\t\tData size\tDescription\n")); + + while (external < (Elf_External_Note *)((char *) pnotes + length)) + { + Elf32_Internal_Note inote; + char * temp = NULL; + + inote.type = BYTE_GET (external->type); + inote.namesz = BYTE_GET (external->namesz); + inote.namedata = external->name; + inote.descsz = BYTE_GET (external->descsz); + inote.descdata = inote.namedata + align_power (inote.namesz, 2); + inote.descpos = offset + (inote.descdata - (char *) pnotes); + + external = (Elf_External_Note *)(inote.descdata + align_power (inote.descsz, 2)); + + /* Verify that name is null terminated. It appears that at least + one version of Linux (RedHat 6.0) generates corefiles that don't + comply with the ELF spec by failing to include the null byte in + namesz. */ + if (inote.namedata[inote.namesz] != '\0') + { + temp = malloc (inote.namesz + 1); + + if (temp == NULL) + { + error (_("Out of memory\n")); + res = 0; + break; + } + + strncpy (temp, inote.namedata, inote.namesz); + temp[inote.namesz] = 0; + + /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */ + inote.namedata = temp; + } + + res &= process_note (& inote); + + if (temp != NULL) + { + free (temp); + temp = NULL; + } + } + + free (pnotes); + + return res; +} + +static int +process_corefile_note_segments (file) + FILE * file; +{ + Elf_Internal_Phdr * program_headers; + Elf_Internal_Phdr * segment; + unsigned int i; + int res = 1; + + program_headers = (Elf_Internal_Phdr *) malloc + (elf_header.e_phnum * sizeof (Elf_Internal_Phdr)); + + if (program_headers == NULL) + { + error (_("Out of memory\n")); + return 0; + } + + if (is_32bit_elf) + i = get_32bit_program_headers (file, program_headers); + else + i = get_64bit_program_headers (file, program_headers); + + if (i == 0) + { + free (program_headers); + return 0; + } + + for (i = 0, segment = program_headers; + i < elf_header.e_phnum; + i ++, segment ++) + { + if (segment->p_type == PT_NOTE) + res &= process_corefile_note_segment (file, + (bfd_vma) segment->p_offset, + (bfd_vma) segment->p_filesz); + } + + free (program_headers); + + return res; +} + +static int +process_corefile_contents (file) + FILE * file; +{ + /* If we have not been asked to display the notes then do nothing. */ + if (! do_notes) + return 1; + + /* If file is not a core file then exit. */ + if (elf_header.e_type != ET_CORE) + return 1; + + /* No program headers means no NOTE segment. */ + if (elf_header.e_phnum == 0) + { + printf (_("No note segments present in the core file.\n")); + return 1; + } + + return process_corefile_note_segments (file); +} + static int process_arch_specific (file) - FILE *file; + FILE * file; { + if (! do_arch) + return 1; + switch (elf_header.e_machine) { case EM_MIPS: @@ -5512,31 +7135,76 @@ static int get_file_header (file) FILE * file; { - Elf32_External_Ehdr ehdr; - - if (fread (& ehdr, sizeof (ehdr), 1, file) != 1) + /* Read in the identity array. */ + if (fread (elf_header.e_ident, EI_NIDENT, 1, file) != 1) return 0; - memcpy (elf_header.e_ident, ehdr.e_ident, EI_NIDENT); + /* Determine how to read the rest of the header. */ + switch (elf_header.e_ident [EI_DATA]) + { + default: /* fall through */ + case ELFDATANONE: /* fall through */ + case ELFDATA2LSB: byte_get = byte_get_little_endian; break; + case ELFDATA2MSB: byte_get = byte_get_big_endian; break; + } + + /* For now we only support 32 bit and 64 bit ELF files. */ + is_32bit_elf = (elf_header.e_ident [EI_CLASS] != ELFCLASS64); + + /* Read in the rest of the header. */ + if (is_32bit_elf) + { + Elf32_External_Ehdr ehdr32; + + if (fread (ehdr32.e_type, sizeof (ehdr32) - EI_NIDENT, 1, file) != 1) + return 0; - if (elf_header.e_ident [EI_DATA] == ELFDATA2LSB) - byte_get = byte_get_little_endian; + elf_header.e_type = BYTE_GET (ehdr32.e_type); + elf_header.e_machine = BYTE_GET (ehdr32.e_machine); + elf_header.e_version = BYTE_GET (ehdr32.e_version); + elf_header.e_entry = BYTE_GET (ehdr32.e_entry); + elf_header.e_phoff = BYTE_GET (ehdr32.e_phoff); + elf_header.e_shoff = BYTE_GET (ehdr32.e_shoff); + elf_header.e_flags = BYTE_GET (ehdr32.e_flags); + elf_header.e_ehsize = BYTE_GET (ehdr32.e_ehsize); + elf_header.e_phentsize = BYTE_GET (ehdr32.e_phentsize); + elf_header.e_phnum = BYTE_GET (ehdr32.e_phnum); + elf_header.e_shentsize = BYTE_GET (ehdr32.e_shentsize); + elf_header.e_shnum = BYTE_GET (ehdr32.e_shnum); + elf_header.e_shstrndx = BYTE_GET (ehdr32.e_shstrndx); + } else - byte_get = byte_get_big_endian; - - elf_header.e_entry = BYTE_GET (ehdr.e_entry); - elf_header.e_phoff = BYTE_GET (ehdr.e_phoff); - elf_header.e_shoff = BYTE_GET (ehdr.e_shoff); - elf_header.e_version = BYTE_GET (ehdr.e_version); - elf_header.e_flags = BYTE_GET (ehdr.e_flags); - elf_header.e_type = BYTE_GET (ehdr.e_type); - elf_header.e_machine = BYTE_GET (ehdr.e_machine); - elf_header.e_ehsize = BYTE_GET (ehdr.e_ehsize); - elf_header.e_phentsize = BYTE_GET (ehdr.e_phentsize); - elf_header.e_phnum = BYTE_GET (ehdr.e_phnum); - elf_header.e_shentsize = BYTE_GET (ehdr.e_shentsize); - elf_header.e_shnum = BYTE_GET (ehdr.e_shnum); - elf_header.e_shstrndx = BYTE_GET (ehdr.e_shstrndx); + { + Elf64_External_Ehdr ehdr64; + + /* If we have been compiled with sizeof (bfd_vma) == 4, then + we will not be able to cope with the 64bit data found in + 64 ELF files. Detect this now and abort before we start + overwritting things. */ + if (sizeof (bfd_vma) < 8) + { + error (_("This instance of readelf has been built without support for a\n")); + error (_("64 bit data type and so it cannot read 64 bit ELF files.\n")); + return 0; + } + + if (fread (ehdr64.e_type, sizeof (ehdr64) - EI_NIDENT, 1, file) != 1) + return 0; + + elf_header.e_type = BYTE_GET (ehdr64.e_type); + elf_header.e_machine = BYTE_GET (ehdr64.e_machine); + elf_header.e_version = BYTE_GET (ehdr64.e_version); + elf_header.e_entry = BYTE_GET8 (ehdr64.e_entry); + elf_header.e_phoff = BYTE_GET8 (ehdr64.e_phoff); + elf_header.e_shoff = BYTE_GET8 (ehdr64.e_shoff); + elf_header.e_flags = BYTE_GET (ehdr64.e_flags); + elf_header.e_ehsize = BYTE_GET (ehdr64.e_ehsize); + elf_header.e_phentsize = BYTE_GET (ehdr64.e_phentsize); + elf_header.e_phnum = BYTE_GET (ehdr64.e_phnum); + elf_header.e_shentsize = BYTE_GET (ehdr64.e_shentsize); + elf_header.e_shnum = BYTE_GET (ehdr64.e_shnum); + elf_header.e_shstrndx = BYTE_GET (ehdr64.e_shstrndx); + } return 1; } @@ -5602,6 +7270,8 @@ process_file (file_name) process_section_contents (file); + process_corefile_contents (file); + process_arch_specific (file); fclose (file); @@ -5628,6 +7298,7 @@ process_file (file_name) { free (dynamic_symbols); dynamic_symbols = NULL; + num_dynamic_syms = 0; } if (dynamic_syminfo) @@ -5639,8 +7310,8 @@ process_file (file_name) #ifdef SUPPORT_DISASSEMBLY /* Needed by the i386 disassembler. For extra credit, someone could -fix this so that we insert symbolic addresses here, esp for GOT/PLT -symbols */ + fix this so that we insert symbolic addresses here, esp for GOT/PLT + symbols */ void print_address (unsigned int addr, FILE * outfile) diff --git a/binutils/rename.c b/binutils/rename.c index fdc7263..78ea9fd 100644 --- a/binutils/rename.c +++ b/binutils/rename.c @@ -31,6 +31,12 @@ #endif /* HAVE_UTIMES */ #endif /* ! HAVE_GOOD_UTIME_H */ +/* We need to open the file in binary modes on system where that makes + a difference. */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + static int simple_copy PARAMS ((const char *, const char *)); /* The number of bytes to copy at once. */ @@ -48,10 +54,14 @@ simple_copy (from, to) int saved; char buf[COPY_BUF]; - fromfd = open (from, O_RDONLY); + fromfd = open (from, O_RDONLY | O_BINARY); if (fromfd < 0) return -1; +#ifdef O_CREAT + tofd = open (to, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0777); +#else tofd = creat (to, 0777); +#endif if (tofd < 0) { saved = errno; @@ -139,17 +149,17 @@ smart_rename (from, to, preserve_dates) const char *to; int preserve_dates; { - int exists; + boolean exists; struct stat s; int ret = 0; - exists = lstat (to, &s); + exists = lstat (to, &s) == 0; #if defined (_WIN32) && !defined (__CYGWIN32__) /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but fail instead. Also, chown is not present. */ - if (exists == 0) + if (exists) remove (to); ret = rename (from, to); @@ -163,7 +173,7 @@ smart_rename (from, to, preserve_dates) #else /* Use rename only if TO is not a symbolic link and has only one hard link. */ - if (exists < 0 || (!S_ISLNK (s.st_mode) && s.st_nlink == 1)) + if (! exists || (!S_ISLNK (s.st_mode) && s.st_nlink == 1)) { ret = rename (from, to); if (ret == 0) diff --git a/binutils/rescoff.c b/binutils/rescoff.c index 9a028c7..64cf572 100644 --- a/binutils/rescoff.c +++ b/binutils/rescoff.c @@ -1,5 +1,5 @@ /* rescoff.c -- read and write resources in Windows COFF files. - Copyright 1997, 1998 Free Software Foundation, Inc. + Copyright 1997, 1998, 2000 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -447,9 +447,20 @@ write_coff_file (filename, target, resources) if (! bfd_set_format (abfd, bfd_object)) bfd_fatal ("bfd_set_format"); +#if defined DLLTOOL_SH + if (! bfd_set_arch_mach (abfd, bfd_arch_sh, 0)) + bfd_fatal ("bfd_set_arch_mach(sh)"); +#elif defined DLLTOOL_MIPS + if (! bfd_set_arch_mach (abfd, bfd_arch_mips, 0)) + bfd_fatal ("bfd_set_arch_mach(mips)"); +#elif defined DLLTOOL_ARM + if (! bfd_set_arch_mach (abfd, bfd_arch_arm, 0)) + bfd_fatal ("bfd_set_arch_mach(arm)"); +#else /* FIXME: This is obviously i386 specific. */ if (! bfd_set_arch_mach (abfd, bfd_arch_i386, 0)) - bfd_fatal ("bfd_set_arch_mach"); + bfd_fatal ("bfd_set_arch_mach(i386)"); +#endif if (! bfd_set_file_flags (abfd, HAS_SYMS | HAS_RELOC)) bfd_fatal ("bfd_set_file_flags"); diff --git a/binutils/resrc.c b/binutils/resrc.c index 9ba3c11..8c3c9a7 100644 --- a/binutils/resrc.c +++ b/binutils/resrc.c @@ -1,5 +1,5 @@ /* resrc.c -- read and write Windows rc files. - Copyright 1997, 1998 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -29,9 +29,49 @@ #include #include +#include #include +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#else /* ! HAVE_SYS_WAIT_H */ +#if ! defined (_WIN32) || defined (__CYGWIN__) +#ifndef WIFEXITED +#define WIFEXITED(w) (((w)&0377) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0177) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) >> 8) & 0377) +#endif +#else /* defined (_WIN32) && ! defined (__CYGWIN__) */ +#ifndef WIFEXITED +#define WIFEXITED(w) (((w) & 0xff) == 0) +#endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(w) (((w) & 0xff) != 0 && ((w) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(w) ((w) & 0x7f) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(w) (((w) & 0xff00) >> 8) +#endif +#endif /* defined (_WIN32) && ! defined (__CYGWIN__) */ +#endif /* ! HAVE_SYS_WAIT_H */ -#if defined (_WIN32) && ! defined (__CYGWIN32__) +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#if defined (_WIN32) && ! defined (__CYGWIN__) #define popen _popen #define pclose _pclose #endif @@ -86,6 +126,15 @@ int rc_lineno; static FILE *cpp_pipe; +/* The temporary file used if we're not using popen, so we can delete it + if we exit. */ + +static char *cpp_temp_file; + +/* Input stream is either a file or a pipe. */ + +static enum {ISTREAM_PIPE, ISTREAM_FILE} istream_type; + /* As we read the rc file, we attach information to this structure. */ static struct res_directory *resources; @@ -112,7 +161,11 @@ static int icons; /* Local functions. */ -static void close_pipe PARAMS ((void)); +static int run_cmd PARAMS ((char *, const char *)); +static FILE *open_input_stream PARAMS ((char *)); +static FILE *look_for_default PARAMS ((char *, const char *, int, + const char *, const char *)); +static void close_input_stream PARAMS ((void)); static void unexpected_eof PARAMS ((const char *)); static int get_word PARAMS ((FILE *, const char *)); static unsigned long get_long PARAMS ((FILE *, const char *)); @@ -120,37 +173,307 @@ static void get_data PARAMS ((FILE *, unsigned char *, unsigned long, const char *)); static void define_fontdirs PARAMS ((void)); +/* Run `cmd' and redirect the output to `redir'. */ + +static int +run_cmd (cmd, redir) + char *cmd; + const char *redir; +{ + char *s; + int pid, wait_status, retcode; + int i; + const char **argv; + char *errmsg_fmt, *errmsg_arg; + char *temp_base = choose_temp_base (); + int in_quote; + char sep; + int redir_handle = -1; + int stdout_save = -1; + + /* Count the args. */ + i = 0; + + for (s = cmd; *s; s++) + if (*s == ' ') + i++; + + i++; + argv = alloca (sizeof (char *) * (i + 3)); + i = 0; + s = cmd; + + while (1) + { + while (*s == ' ' && *s != 0) + s++; + + if (*s == 0) + break; + + in_quote = (*s == '\'' || *s == '"'); + sep = (in_quote) ? *s++ : ' '; + argv[i++] = s; + + while (*s != sep && *s != 0) + s++; + + if (*s == 0) + break; + + *s++ = 0; + + if (in_quote) + s++; + } + argv[i++] = NULL; + + /* Setup the redirection. We can't use the usual fork/exec and redirect + since we may be running on non-POSIX Windows host. */ + + fflush (stdout); + fflush (stderr); + + /* Open temporary output file. */ + redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0666); + if (redir_handle == -1) + fatal (_("can't open temporary file `%s': %s"), redir, + strerror (errno)); + + /* Duplicate the stdout file handle so it can be restored later. */ + stdout_save = dup (STDOUT_FILENO); + if (stdout_save == -1) + fatal (_("can't redirect stdout: `%s': %s"), redir, strerror (errno)); + + /* Redirect stdout to our output file. */ + dup2 (redir_handle, STDOUT_FILENO); + + pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base, + &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH); + + /* Restore stdout to its previous setting. */ + dup2 (stdout_save, STDOUT_FILENO); + + /* Close reponse file. */ + close (redir_handle); + + if (pid == -1) + { + fatal (_("%s %s: %s"), errmsg_fmt, errmsg_arg, strerror (errno)); + return 1; + } + + retcode = 0; + pid = pwait (pid, &wait_status, 0); + + if (pid == -1) + { + fatal (_("wait: %s"), strerror (errno)); + retcode = 1; + } + else if (WIFSIGNALED (wait_status)) + { + fatal (_("subprocess got fatal signal %d"), WTERMSIG (wait_status)); + retcode = 1; + } + else if (WIFEXITED (wait_status)) + { + if (WEXITSTATUS (wait_status) != 0) + { + fatal (_("%s exited with status %d"), cmd, + WEXITSTATUS (wait_status)); + retcode = 1; + } + } + else + retcode = 1; + + return retcode; +} + +static FILE * +open_input_stream (cmd) + char *cmd; +{ + if (istream_type == ISTREAM_FILE) + { + char *fileprefix; + + fileprefix = choose_temp_base (); + cpp_temp_file = (char *) xmalloc (strlen (fileprefix) + 5); + sprintf (cpp_temp_file, "%s.irc", fileprefix); + free (fileprefix); + + if (run_cmd (cmd, cpp_temp_file)) + fatal (_("can't execute `%s': %s"), cmd, strerror (errno)); + + cpp_pipe = fopen (cpp_temp_file, FOPEN_RT);; + if (cpp_pipe == NULL) + fatal (_("can't open temporary file `%s': %s"), + cpp_temp_file, strerror (errno)); + + if (verbose) + fprintf (stderr, + _("Using temporary file `%s' to read preprocessor output\n"), + cpp_temp_file); + } + else + { + cpp_pipe = popen (cmd, FOPEN_RT); + if (cpp_pipe == NULL) + fatal (_("can't popen `%s': %s"), cmd, strerror (errno)); + if (verbose) + fprintf (stderr, _("Using popen to read preprocessor output\n")); + } + + xatexit (close_input_stream); + return cpp_pipe; +} + +/* look for the preprocessor program */ + +static FILE * +look_for_default (cmd, prefix, end_prefix, preprocargs, filename) + char *cmd; + const char *prefix; + int end_prefix; + const char *preprocargs; + const char *filename; +{ + char *space; + int found; + struct stat s; + + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s", DEFAULT_PREPROCESSOR); + space = strchr (cmd + end_prefix, ' '); + if (space) + *space = 0; + + if ( +#if defined (__DJGPP__) || defined (__CYGWIN__) || defined (_WIN32) + strchr (cmd, '\\') || +#endif + strchr (cmd, '/')) + { + found = (stat (cmd, &s) == 0 +#ifdef HAVE_EXECUTABLE_SUFFIX + || stat (strcat (cmd, EXECUTABLE_SUFFIX), &s) == 0 +#endif + ); + + if (! found) + { + if (verbose) + fprintf (stderr, _("Tried `%s'\n"), cmd); + return NULL; + } + } + + strcpy (cmd, prefix); + + sprintf (cmd + end_prefix, "%s %s %s", + DEFAULT_PREPROCESSOR, preprocargs, filename); + + if (verbose) + fprintf (stderr, _("Using `%s'\n"), cmd); + + cpp_pipe = open_input_stream (cmd); + return cpp_pipe; +} + /* Read an rc file. */ struct res_directory * -read_rc_file (filename, preprocessor, preprocargs, language) +read_rc_file (filename, preprocessor, preprocargs, language, use_temp_file) const char *filename; const char *preprocessor; const char *preprocargs; int language; + int use_temp_file; { char *cmd; - if (preprocessor == NULL) - preprocessor = DEFAULT_PREPROCESSOR; + istream_type = (use_temp_file) ? ISTREAM_FILE : ISTREAM_PIPE; if (preprocargs == NULL) preprocargs = ""; if (filename == NULL) filename = "-"; - cmd = xmalloc (strlen (preprocessor) - + strlen (preprocargs) - + strlen (filename) - + 10); - sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename); + if (preprocessor) + { + cmd = xmalloc (strlen (preprocessor) + + strlen (preprocargs) + + strlen (filename) + + 10); + sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename); - cpp_pipe = popen (cmd, FOPEN_RT); - if (cpp_pipe == NULL) - fatal (_("can't popen `%s': %s"), cmd, strerror (errno)); - free (cmd); + cpp_pipe = open_input_stream (cmd); + } + else + { + char *dash, *slash, *cp; - xatexit (close_pipe); + preprocessor = DEFAULT_PREPROCESSOR; + + cmd = xmalloc (strlen (program_name) + + strlen (preprocessor) + + strlen (preprocargs) + + strlen (filename) +#ifdef HAVE_EXECUTABLE_SUFFIX + + strlen (EXECUTABLE_SUFFIX) +#endif + + 10); + + + dash = slash = 0; + for (cp = program_name; *cp; cp++) + { + if (*cp == '-') + dash = cp; + if ( +#if defined (__DJGPP__) || defined (__CYGWIN__) || defined(_WIN32) + *cp == ':' || *cp == '\\' || +#endif + *cp == '/') + { + slash = cp; + dash = 0; + } + } + + cpp_pipe = 0; + + if (dash) + { + /* First, try looking for a prefixed gcc in the windres + directory, with the same prefix as windres */ + + cpp_pipe = look_for_default (cmd, program_name, dash-program_name+1, + preprocargs, filename); + } + + if (slash && !cpp_pipe) + { + /* Next, try looking for a gcc in the same directory as + that windres */ + + cpp_pipe = look_for_default (cmd, program_name, slash-program_name+1, + preprocargs, filename); + } + + if (!cpp_pipe) + { + /* Sigh, try the default */ + + cpp_pipe = look_for_default (cmd, "", 0, preprocargs, filename); + } + + } + + free (cmd); rc_filename = xstrdup (filename); rc_lineno = 1; @@ -159,10 +482,8 @@ read_rc_file (filename, preprocessor, preprocargs, language) yyin = cpp_pipe; yyparse (); - if (pclose (cpp_pipe) != 0) - fprintf (stderr, _("%s: warning: preprocessor failed\n"), program_name); - cpp_pipe = NULL; - + close_input_stream (); + if (fontdirs != NULL) define_fontdirs (); @@ -172,13 +493,37 @@ read_rc_file (filename, preprocessor, preprocargs, language) return resources; } -/* Close the pipe if it is open. This is called via xatexit. */ +/* Close the input stream if it is open. */ -void -close_pipe () +static void +close_input_stream () { if (cpp_pipe != NULL) pclose (cpp_pipe); + + if (istream_type == ISTREAM_FILE) + { + if (cpp_pipe != NULL) + fclose (cpp_pipe); + + if (cpp_temp_file != NULL) + { + int errno_save = errno; + + unlink (cpp_temp_file); + errno = errno_save; + free (cpp_temp_file); + } + } + else + { + if (cpp_pipe != NULL) + pclose (cpp_pipe); + } + + /* Since this is also run via xatexit, safeguard. */ + cpp_pipe = NULL; + cpp_temp_file = NULL; } /* Report an error while reading an rc file. */ @@ -196,7 +541,7 @@ void rcparse_warning (msg) const char *msg; { - fprintf (stderr, "%s:%d: %s\n", rc_filename, rc_lineno, msg); + fprintf (stderr, _("%s:%d: %s\n"), rc_filename, rc_lineno, msg); } /* Die if we get an unexpected end of file. */ @@ -2044,60 +2389,100 @@ write_rc_rcdata (e, rcdata, ind) for (i = 0; i + 3 < ri->u.buffer.length; i += 4) { unsigned long l; + int j; + if (! first) + indent (e, ind + 2); l = ((((((ri->u.buffer.data[i + 3] << 8) | ri->u.buffer.data[i + 2]) << 8) | ri->u.buffer.data[i + 1]) << 8) | ri->u.buffer.data[i]); - if (first) - first = 0; - else + fprintf (e, "%luL", l); + if (i + 4 < ri->u.buffer.length || ri->next != NULL) + fprintf (e, ","); + for (j = 0; j < 4; ++j) + if (! isprint (ri->u.buffer.data[i + j]) + && ri->u.buffer.data[i + j] != 0) + break; + if (j >= 4) { - fprintf (e, ",\n"); - indent (e, ind + 2); + fprintf (e, "\t// "); + for (j = 0; j < 4; ++j) + { + if (! isprint (ri->u.buffer.data[i + j])) + fprintf (e, "\\%03o", ri->u.buffer.data[i + j]); + else + { + if (ri->u.buffer.data[i + j] == '\\') + fprintf (e, "\\"); + fprintf (e, "%c", ri->u.buffer.data[i + j]); + } + } } - fprintf (e, "%luL", l); + fprintf (e, "\n"); + first = 0; } if (i + 1 < ri->u.buffer.length) { - int i; - - i = (ri->u.buffer.data[i + 1] << 8) | ri->u.buffer.data[i]; - if (first) - first = 0; - else + int s; + int j; + + if (! first) + indent (e, ind + 2); + s = (ri->u.buffer.data[i + 1] << 8) | ri->u.buffer.data[i]; + fprintf (e, "%d", s); + if (i + 2 < ri->u.buffer.length || ri->next != NULL) + fprintf (e, ","); + for (j = 0; j < 2; ++j) + if (! isprint (ri->u.buffer.data[i + j]) + && ri->u.buffer.data[i + j] != 0) + break; + if (j >= 2) { - fprintf (e, ",\n"); - indent (e, ind + 2); + fprintf (e, "\t// "); + for (j = 0; j < 2; ++j) + { + if (! isprint (ri->u.buffer.data[i + j])) + fprintf (e, "\\%03o", ri->u.buffer.data[i + j]); + else + { + if (ri->u.buffer.data[i + j] == '\\') + fprintf (e, "\\"); + fprintf (e, "%c", ri->u.buffer.data[i + j]); + } + } } - fprintf (e, "%d", i); + fprintf (e, "\n"); i += 2; + first = 0; } if (i < ri->u.buffer.length) { - if (first) - first = 0; - else - { - fprintf (e, ",\n"); - indent (e, ind + 2); - } + if (! first) + indent (e, ind + 2); if ((ri->u.buffer.data[i] & 0x7f) == ri->u.buffer.data[i] && isprint (ri->u.buffer.data[i])) fprintf (e, "\"%c\"", ri->u.buffer.data[i]); else - fprintf (e, "\"\%03o\"", ri->u.buffer.data[i]); + fprintf (e, "\"\\%03o\"", ri->u.buffer.data[i]); + if (ri->next != NULL) + fprintf (e, ","); + fprintf (e, "\n"); + first = 0; } break; } } - if (ri->next != NULL) - fprintf (e, ","); - fprintf (e, "\n"); + if (ri->type != RCDATA_BUFFER) + { + if (ri->next != NULL) + fprintf (e, ","); + fprintf (e, "\n"); + } } indent (e, ind); diff --git a/binutils/resres.c b/binutils/resres.c index 39264f4..6a860eb 100644 --- a/binutils/resres.c +++ b/binutils/resres.c @@ -1,5 +1,4 @@ /* resres.c: read_res_file and write_res_file implementation for windres. - Copyright 1998, 1999 Free Software Foundation, Inc. Written by Anders Norlander . @@ -20,6 +19,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* FIXME: This file does not work correctly in a cross configuration. + It assumes that it can use fread and fwrite to read and write + integers. It does no swapping. */ + #include "bfd.h" #include "bucomm.h" #include "libiberty.h" @@ -216,7 +219,7 @@ write_res_directory (rd, type, name, language, level) /* If we're at level 3, then this key represents a language. Use it to update the current language. */ if (!re->id.named - && re->id.u.id != *language + && re->id.u.id != (unsigned long) *language && (re->id.u.id & 0xffff) == re->id.u.id) { *language = re->id.u.id; @@ -256,7 +259,7 @@ write_res_resource (type, name, res, language) const struct res_id *type; const struct res_id *name; const struct res_resource *res; - int *language; + int *language ATTRIBUTE_UNUSED; { int rt; @@ -328,7 +331,7 @@ write_res_resource (type, name, res, language) if (rt != 0 && type != NULL - && (type->named || type->u.id != rt)) + && (type->named || type->u.id != (unsigned long) rt)) { fprintf (stderr, "// Unexpected resource type mismatch: "); res_id_print (stderr, *type, 1); @@ -403,8 +406,8 @@ write_res_data (data, size, count) size_t size; int count; { - if (fwrite (data, size, count, fres) != count) - fatal ("%s: %s: could not write to file", program_name, filename); + if (fwrite (data, size, count, fres) != (size_t) count) + fatal ("%s: could not write to file", filename); } /* Read data from file, abort on failure */ @@ -414,8 +417,8 @@ read_res_data (data, size, count) size_t size; int count; { - if (fread (data, size, count, fres) != count) - fatal ("%s: %s: unexpected end of file", program_name, filename); + if (fread (data, size, count, fres) != (size_t) count) + fatal ("%s: unexpected end of file", filename); } /* Write a resource id */ diff --git a/binutils/size.c b/binutils/size.c index f57c7ed..c93850c 100644 --- a/binutils/size.c +++ b/binutils/size.c @@ -366,9 +366,9 @@ static bfd_size_type textsize; static void berkeley_sum (abfd, sec, ignore) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; sec_ptr sec; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { flagword flags; bfd_size_type size; @@ -433,9 +433,9 @@ int svi_sizelen = 0; static void sysv_internal_sizer (file, sec, ignore) - bfd *file; + bfd *file ATTRIBUTE_UNUSED; sec_ptr sec; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { bfd_size_type size = bfd_section_size (file, sec); if (!bfd_is_abs_section (sec) @@ -454,9 +454,9 @@ sysv_internal_sizer (file, sec, ignore) static void sysv_internal_printer (file, sec, ignore) - bfd *file; + bfd *file ATTRIBUTE_UNUSED; sec_ptr sec; - PTR ignore; + PTR ignore ATTRIBUTE_UNUSED; { bfd_size_type size = bfd_section_size (file, sec); if (!bfd_is_abs_section (sec) diff --git a/binutils/stabs.c b/binutils/stabs.c index a47b3bd..8c20ed3 100644 --- a/binutils/stabs.c +++ b/binutils/stabs.c @@ -1,5 +1,5 @@ /* stabs.c -- Parse stabs debugging information - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -375,7 +375,7 @@ warn_stab (p, err) /*ARGSUSED*/ PTR start_stab (dhandle, abfd, sections, syms, symcount) - PTR dhandle; + PTR dhandle ATTRIBUTE_UNUSED; bfd *abfd; boolean sections; asymbol **syms; @@ -1316,14 +1316,21 @@ parse_stab_type (dhandle, info, typename, pp, slotp) bad_stab (orig); return DEBUG_TYPE_NULL; } - while (q1 != NULL && p > q1 && p[1] == ':') + if (q1 != NULL && p > q1 && p[1] == ':') { - q2 = strchr (q1, '>'); - if (q2 == NULL || q2 < p) - break; - p += 2; - p = strchr (p, ':'); - if (p == NULL) + int nest = 0; + + for (q2 = q1; *q2 != '\0'; ++q2) + { + if (*q2 == '<') + ++nest; + else if (*q2 == '>') + --nest; + else if (*q2 == ':' && nest == 0) + break; + } + p = q2; + if (*p != ':') { bad_stab (orig); return DEBUG_TYPE_NULL; @@ -1632,7 +1639,7 @@ parse_stab_type (dhandle, info, typename, pp, slotp) if (size != -1) { if (! debug_record_type_size (dhandle, dtype, (unsigned int) size)) - return false; + return DEBUG_TYPE_NULL; } return dtype; @@ -1811,7 +1818,7 @@ parse_stab_range_type (dhandle, info, typename, pp, typenums) return debug_make_int_type (dhandle, 1, true); else if (n3 == 0xffff) return debug_make_int_type (dhandle, 2, true); - else if (n3 == 0xffffffff) + else if (n3 == (bfd_signed_vma) 0xffffffff) return debug_make_int_type (dhandle, 4, true); #ifdef BFD64 else if (n3 == ((((bfd_vma) 0xffffffff) << 32) | 0xffffffff)) @@ -3124,7 +3131,7 @@ parse_stab_array_type (dhandle, info, pp, stringp) /* If the index type is type 0, we take it as int. */ p = *pp; if (! parse_stab_type_number (&p, typenums)) - return false; + return DEBUG_TYPE_NULL; if (typenums[0] == 0 && typenums[1] == 0 && **pp != '=') { index_type = debug_find_named_type (dhandle, "int"); @@ -3132,7 +3139,7 @@ parse_stab_array_type (dhandle, info, pp, stringp) { index_type = debug_make_int_type (dhandle, 4, false); if (index_type == DEBUG_TYPE_NULL) - return false; + return DEBUG_TYPE_NULL; } *pp = p; } @@ -3161,7 +3168,7 @@ parse_stab_array_type (dhandle, info, pp, stringp) if (**pp != ';') { bad_stab (orig); - return false; + return DEBUG_TYPE_NULL; } ++*pp; @@ -3175,14 +3182,14 @@ parse_stab_array_type (dhandle, info, pp, stringp) if (**pp != ';') { bad_stab (orig); - return false; + return DEBUG_TYPE_NULL; } ++*pp; element_type = parse_stab_type (dhandle, info, (const char *) NULL, pp, (debug_type **) NULL); if (element_type == DEBUG_TYPE_NULL) - return false; + return DEBUG_TYPE_NULL; if (adjustable) { @@ -3432,7 +3439,7 @@ stab_find_type (dhandle, info, typenums) static boolean stab_record_type (dhandle, info, typenums, type) - PTR dhandle; + PTR dhandle ATTRIBUTE_UNUSED; struct stab_handle *info; const int *typenums; debug_type type; @@ -4506,7 +4513,7 @@ stab_demangle_template (minfo, pp, pname) static boolean stab_demangle_class (minfo, pp, pstart) - struct stab_demangle_info *minfo; + struct stab_demangle_info *minfo ATTRIBUTE_UNUSED; const char **pp; const char **pstart; { @@ -4785,6 +4792,7 @@ stab_demangle_type (minfo, pp, ptype) case 'O': { boolean memberp, constp, volatilep; + debug_type class_type = DEBUG_TYPE_NULL; debug_type *args; boolean varargs; unsigned int n; @@ -4797,19 +4805,40 @@ stab_demangle_type (minfo, pp, ptype) varargs = false; ++*pp; - if (! isdigit ((unsigned char) **pp)) + if (isdigit ((unsigned char) **pp)) { - stab_bad_demangle (orig); - return false; + n = stab_demangle_count (pp); + if (strlen (*pp) < n) + { + stab_bad_demangle (orig); + return false; + } + name = *pp; + *pp += n; + + if (ptype != NULL) + { + class_type = stab_find_tagged_type (minfo->dhandle, + minfo->info, + name, (int) n, + DEBUG_KIND_CLASS); + if (class_type == DEBUG_TYPE_NULL) + return false; + } } - n = stab_demangle_count (pp); - if (strlen (*pp) < n) + else if (**pp == 'Q') + { + if (! stab_demangle_qualified (minfo, pp, + (ptype == NULL + ? (debug_type *) NULL + : &class_type))) + return false; + } + else { stab_bad_demangle (orig); return false; } - name = *pp; - *pp += n; if (memberp) { @@ -4851,14 +4880,6 @@ stab_demangle_type (minfo, pp, ptype) if (ptype != NULL) { - debug_type class_type; - - class_type = stab_find_tagged_type (minfo->dhandle, minfo->info, - name, (int) n, - DEBUG_KIND_CLASS); - if (class_type == DEBUG_TYPE_NULL) - return false; - if (! memberp) *ptype = debug_make_offset_type (minfo->dhandle, class_type, *ptype); diff --git a/binutils/strings.1 b/binutils/strings.1 index 408de29..f0e46e5 100644 --- a/binutils/strings.1 +++ b/binutils/strings.1 @@ -90,7 +90,7 @@ on the standard output and exit. .TP .B "\-\fImin\-len\fP" .TP -.B "\-bytes=\fImin\-len\fP" +.B "\-\-bytes=\fImin\-len\fP" Print sequences of characters that are at least .I min\-len characters long, instead of the default 4. diff --git a/binutils/strings.c b/binutils/strings.c index 8ffe6a1..fb139fa 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -203,7 +203,7 @@ main (argc, argv) default: if (string_min < 0) - string_min = optc; + string_min = optc - '0'; else string_min = string_min * 10 + optc - '0'; break; diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 15a0577..078f8d5 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,59 @@ +2000-03-13 Nick Clifton + + * binutils-all/readelf.s: Adjust to match noew format of readelf + output. + * binutils-all/readelf.ss: Adjust to match noew format of readelf + output. + +1999-11-01 Nick Clifton + + * binutils-all/objcopy.exp: Expect simple objcopy test for fail + for COFF based ARM and Thumb ports. + +Tue Sep 14 00:28:17 1999 Jeffrey A Law (law@cygnus.com) + + * binutils-all/hppa/objdump.exp: Do not run for PA64. + +1999-09-04 Steve Chamberlain + + * binutils-all/objdump.exp: Add pj to cpus_expected. + +Sat Aug 28 00:24:27 1999 Jerry Quinn + + * binutils-all/hppa/freg.s: New file. + * binutils-all/hppa/objdump.exp: Add freg.s test. + +1999-08-09 Ian Lance Taylor + + * binutils-all/objcopy.exp: Add setup_xfail for simple copy test + for i*86-*-msdos*. + +1999-07-21 H.J. Lu + + * binutils-all/testprog.c: Include . + +1999-06-29 Nick Clifton + + * binutils-all/objdump.exp: Add fr30 and MCore to expected cpus + list. + + * binutils-all/readelf.r: Do not assume a fixed number of spaces + in the output. + +1999-06-10 Nick Clifton + + * binutils-all/readelf.wi: Update to match latest output. + * binutils-all/readelf.h: Update to match latest output. + +Wed Jun 9 11:59:22 1999 Andreas Schwab + + * binutils-all/objdump.exp: Tighten regexp to match `objdump -i' + output to avoid massive exponential behaviour. + +1999-05-28 Ian Lance Taylor + + * binutils-all/readelf.h: Update for changes of 1999-04-08. + 1999-03-12 Nick Clifton * binutils-all/readelf.wi: Remove FR30 specific componnts. diff --git a/binutils/testsuite/binutils-all/hppa/freg.s b/binutils/testsuite/binutils-all/hppa/freg.s new file mode 100644 index 0000000..501e10f --- /dev/null +++ b/binutils/testsuite/binutils-all/hppa/freg.s @@ -0,0 +1,23 @@ + .LEVEL 2.0 + .SPACE $PRIVATE$ + .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31 + .SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82 + .SPACE $TEXT$ + .SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44 + .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY + .IMPORT $global$,DATA + .IMPORT $$dyncall,MILLICODE +; gcc_compiled.: + .SPACE $TEXT$ + .SUBSPA $CODE$ + + .align 4 + .NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY + .EXPORT main,ENTRY,PRIV_LEV=3,RTNVAL=GR +main + .PROC + .CALLINFO FRAME=64,CALLS,SAVE_RP + .ENTRY + fmpyfadd,sgl %fr4L,%fr4R,%fr5R,%fr5L + .EXIT + .PROCEND diff --git a/binutils/testsuite/binutils-all/hppa/objdump.exp b/binutils/testsuite/binutils-all/hppa/objdump.exp index a46b289..2e2155e 100644 --- a/binutils/testsuite/binutils-all/hppa/objdump.exp +++ b/binutils/testsuite/binutils-all/hppa/objdump.exp @@ -24,6 +24,11 @@ if ![istarget hppa*-*-*] then { return } +# These tests are not suitable for wide mode. +if [istarget hppa*w-*-*] then { + return +} + if {[which $OBJDUMP] == 0} then { perror "$OBJDUMP does not exist" return @@ -57,3 +62,29 @@ if [regexp $want $got] then { } else { fail "addendbug test" } + +########################### +# Set up the test of freg.s +########################### + +if {![binutils_assemble $srcdir/$subdir/freg.s tmpdir/freg.o]} then { + return +} + +if [is_remote host] { + set objfile [remote_download host tmpdir/freg.o] +} else { + set objfile tmpdir/freg.o +} + +# Make sure that we get R float regs like we're supposed to + +set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] + +set want "fmpyfadd,sgl fr4,fr4R,fr5R,fr5" + +if [regexp $want $got] then { + pass "freg test" +} else { + fail "freg test" +} diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 78972f1..1c40e0a 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -74,7 +74,7 @@ if ![string match "" $got] then { setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv*" setup_xfail "i*86-*-linuxaout*" "i*86-*-aout*" setup_xfail "i*86-*-sysv3" "i*86-*-isc*" "i*86-*-sco*" "i*86-*-coff" - setup_xfail "i*86-*-aix*" "i*86-*-go32*" + setup_xfail "i*86-*-aix*" "i*86-*-go32*" "i*86-*-msdos*" setup_xfail "a29k-*-udi" "a29k-*-coff" "a29k-*-vxworks*" setup_xfail "i960-*-coff" setup_xfail "h8300-*-hms" "h8300-*-coff" @@ -473,6 +473,11 @@ proc copy_executable { prog flags test1 test2 } { # mips_elf_sym_is_global. setup_xfail "mips*-*-elf" + setup_xfail "arm*-*-coff" + setup_xfail "arm*-*-pe" + setup_xfail "thumb*-*-coff" + setup_xfail "thumb*-*-pe" + fail $test1 } diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp index 7c50f02..89040fc 100644 --- a/binutils/testsuite/binutils-all/objdump.exp +++ b/binutils/testsuite/binutils-all/objdump.exp @@ -33,14 +33,14 @@ send_user "Version [binutil_version $OBJDUMP]" set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"] -set cpus_expected "(a29k|alliant|alpha|arc|arm|convex|d10v|d30v|h8|hppa|i386|i860|i960|m32r|m68k|m88k|mips|mn10200|mn10300|ns32k|powerpc|pyramid|romp|rs6000|sh|sparc|tahoe|v850|vax|we32k|z8k|z8001|z8002)" +set cpus_expected "(a29k|alliant|alpha|arc|arm|convex|d10v|d30v|fr30|h8|hppa|i386|i860|i960|m32r|m68k|m88k|MCore|mips|mn10200|mn10300|ns32k|pj|powerpc|pyramid|romp|rs6000|sh|sparc|tahoe|v850|vax|we32k|z8k|z8001|z8002)" # Make sure the target CPU shows up in the list. if ![regexp $cpus_expected $target_cpu] { regsub "^\[(\]" "$cpus_expected" "(${target_cpu}|" cpus_expected; } -set want "BFD header file version.*srec.*header .* endian.*, data .* endian.*$cpus_expected" +set want "BFD header file version.*srec\[^\n\]*\n\[^\n\]*header \[^\n\]*endian\[^\n\]*, data \[^\n\]*endian.*$cpus_expected" if [regexp $want $got] then { pass "objdump -i" diff --git a/binutils/testsuite/binutils-all/readelf.h b/binutils/testsuite/binutils-all/readelf.h index 555afe9..810eab5 100644 --- a/binutils/testsuite/binutils-all/readelf.h +++ b/binutils/testsuite/binutils-all/readelf.h @@ -1,9 +1,13 @@ ELF Header: - Magic: 7f 45 4c 46 0[12] 0[12] 01 00 00 00 00 00 00 00 00 00 + Magic: 7f 45 4c 46 0[12] 0[12] 01 .. 00 00 00 00 00 00 00 00 + Class: ELF[36][24] + Data: 2's complement,.* endian + Version: 1 \(current\) + OS/ABI: .* + ABI Version: .* Type: REL \(Relocatable file\) Machine: .* Version: 0x1 - Data: ELFDATA.* endian\) Entry point address: 0x0 Start of program headers: 0 \(bytes into file\) Start of section headers: .* \(bytes into file\) diff --git a/binutils/testsuite/binutils-all/readelf.r b/binutils/testsuite/binutils-all/readelf.r index 4bea721..1349659 100644 --- a/binutils/testsuite/binutils-all/readelf.r +++ b/binutils/testsuite/binutils-all/readelf.r @@ -1,4 +1,4 @@ Relocation section '.rel.*text' at offset 0x.* contains 1 entries: Offset Info Type Symbol's Value Symbol's Name.* - 00000004 00.* R_.* 00000000 external_symbol.* + 00000004 00.* R_.*00000000 external_symbol.* diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s index 58b1245..89ae0fc 100644 --- a/binutils/testsuite/binutils-all/readelf.s +++ b/binutils/testsuite/binutils-all/readelf.s @@ -2,12 +2,15 @@ There are .* section headers, starting at offset .*: Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al - \[ 0\] NULL 00000000 000000 000000 00 0 0 0 - \[ 1\] .text PROGBITS 00000000 000034 000008 00 AX 0 0 . - \[ 2\] .rel.+text +REL. +0+ 0+.* 00000. 0. . 1 4 - \[ 3\] .data PROGBITS 00000000 00003c 000004 00 WA 0 0 . - \[ 4\] .bss NOBITS 00000000 000040 000000 00 WA 0 0 . - \[ 5\] .shstrtab STRTAB 00000000 000040 0000.* 00 0 0 . - \[ 6\] .symtab SYMTAB 00000000 0+.* 0+.* 10 7 6 4 - \[ 7\] .strtab STRTAB 00000000 0+.* 0+.* 00 0 0 1 + \[ 0\] NULL 00000000 000000 000000 00 0 0 0 + \[ 1\] .text PROGBITS 00000000 000034 000008 00 AX 0 0 . + \[ 2\] .rel.+text +REL. +0+ 0+.* 00000. 0. . 1 4 + \[ 3\] .data PROGBITS 00000000 00003c 000004 00 WA 0 0 . + \[ 4\] .bss NOBITS 00000000 000040 000000 00 WA 0 0 . + \[ .\] .shstrtab STRTAB 00000000 000040 0000.* 00 0 0 . + \[ .\] .symtab SYMTAB 00000000 0+.* 0+.* 10 7 6 4 + \[ .\] .strtab STRTAB 00000000 0+.* 0+.* 00 0 0 1 +Key to Flags: W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\) + I \(info\), L \(link order\), O \(extra OS processing required\) + o \(os specific\), p \(processor specific\) x \(unknown\) diff --git a/binutils/testsuite/binutils-all/readelf.ss b/binutils/testsuite/binutils-all/readelf.ss index 3760b38..926612d 100644 --- a/binutils/testsuite/binutils-all/readelf.ss +++ b/binutils/testsuite/binutils-all/readelf.ss @@ -1,13 +1,13 @@ Symbol table '.symtab' contains .* entries: - Num: Value Size Type Bind Ot Ndx Name - 0: 0 0 NOTYPE LOCAL 0 UND - 1: 0 0 SECTION LOCAL 0 1 - 2: 0 0 SECTION LOCAL 0 3 - 3: 0 0 SECTION LOCAL 0 4 - 4: 0 0 NOTYPE LOCAL 0 1 static_text_symbol - 5: 0 0 NOTYPE LOCAL 0 3 static_data_symbol - .: 0 0 NOTYPE GLOBAL 0 1 text_symbol - .: 0 0 NOTYPE GLOBAL 0 UND external_symbol - .*: 0 0 NOTYPE GLOBAL 0 3 data_symbol - .*: 4 4 OBJECT GLOBAL 0 COM common_symbol + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00000000 0 SECTION LOCAL DEFAULT 1 + 2: 00000000 0 SECTION LOCAL DEFAULT 3 + 3: 00000000 0 SECTION LOCAL DEFAULT 4 + 4: 00000000 0 NOTYPE LOCAL DEFAULT 1 static_text_symbol + 5: 00000000 0 NOTYPE LOCAL DEFAULT 3 static_data_symbol +.* .: 00000000 0 NOTYPE GLOBAL DEFAULT 1 text_symbol + .: 00000000 0 NOTYPE GLOBAL DEFAULT UND external_symbol + .: 00000000 0 NOTYPE GLOBAL DEFAULT 3 data_symbol + .: 00000004 4 OBJECT GLOBAL DEFAULT COM common_symbol diff --git a/binutils/testsuite/binutils-all/readelf.wi b/binutils/testsuite/binutils-all/readelf.wi index 3cb2ecc..e022fff 100644 --- a/binutils/testsuite/binutils-all/readelf.wi +++ b/binutils/testsuite/binutils-all/readelf.wi @@ -5,7 +5,7 @@ The section .debug_info contains: Version: 2 Abbrev Offset: 0 Pointer Size: 4 - Abbrev Number: 1 \(DW_TAG_compile_unit\) + <.><.*>: Abbrev Number: 1 \(DW_TAG_compile_unit\) DW_AT_name : .*/testprog.c DW_AT_comp_dir : .*/binutils DW_AT_producer : GNU C .* @@ -13,66 +13,64 @@ The section .debug_info contains: DW_AT_low_pc : 0 DW_AT_high_pc : .* DW_AT_stmt_list : 0 - Abbrev Number: 2 \(DW_TAG_subprogram\) + <.><.*>: Abbrev Number: 2 \(DW_TAG_subprogram\) DW_AT_external : 1 DW_AT_name : fn DW_AT_decl_file : 1 - DW_AT_decl_line : a + DW_AT_decl_line : 10 DW_AT_type : .* DW_AT_low_pc : 0 DW_AT_high_pc : .* DW_AT_frame_base : 1 byte block: .* - Abbrev Number: 3 \(DW_TAG_base_type\) + <.><.*>: Abbrev Number: 3 \(DW_TAG_base_type\) DW_AT_name : int DW_AT_byte_size : 4 DW_AT_encoding : 5 \(signed\) - Abbrev Number: 4 \(DW_TAG_subprogram\) + <.><.*>: Abbrev Number: 4 \(DW_TAG_subprogram\) DW_AT_sibling : .* DW_AT_external : 1 DW_AT_name : main DW_AT_decl_file : 1 - DW_AT_decl_line : 10 + DW_AT_decl_line : 16 DW_AT_type : .* DW_AT_low_pc : .* DW_AT_high_pc : .* DW_AT_frame_base : 1 byte block: .* - Abbrev Number: 5 \(DW_TAG_lexical_block\) + <.><.*>: Abbrev Number: 5 \(DW_TAG_lexical_block\) DW_AT_low_pc : .* DW_AT_high_pc : .* - - Extra data at end of comp unit: - .*: Abbrev Number: 6 \(DW_TAG_variable\) + <.><.*>: Abbrev Number: 6 \(DW_TAG_variable\) DW_AT_name : common DW_AT_decl_file : 1 DW_AT_decl_line : 3 - DW_AT_type : .* + DW_AT_type : <.*> DW_AT_external : 1 - DW_AT_location : 5 byte block: 3 . 0 0 0 \(DW_OP_addr: 0\) - .*: Abbrev Number: 6 \(DW_TAG_variable\) + DW_AT_location : 5 byte block: 3 0 0 0 0 \(DW_OP_addr: 0\) + <.><.*>: Abbrev Number: 6 \(DW_TAG_variable\) DW_AT_name : global DW_AT_decl_file : 1 DW_AT_decl_line : 4 - DW_AT_type : .* + DW_AT_type : <.*> DW_AT_external : 1 - DW_AT_location : 5 byte block: 3 . 0 0 0 \(DW_OP_addr: 0\) - .*: Abbrev Number: 7 \(DW_TAG_variable\) + DW_AT_location : 5 byte block: 3 0 0 0 0 \(DW_OP_addr: 0\) + <.><.*>: Abbrev Number: 7 \(DW_TAG_variable\) DW_AT_name : local DW_AT_decl_file : 1 DW_AT_decl_line : 5 - DW_AT_type : .* + DW_AT_type : <.*> DW_AT_location : 5 byte block: 3 . 0 0 . \(DW_OP_addr: .\) - .*: Abbrev Number: 8 \(DW_TAG_array_type\) - DW_AT_sibling : .* - DW_AT_type : .* - .*: Abbrev Number: 9 \(DW_TAG_subrange_type\) + <.><.*>: Abbrev Number: 8 \(DW_TAG_array_type\) + DW_AT_sibling : <.*> + DW_AT_type : <.*> + <.><.*>: Abbrev Number: 9 \(DW_TAG_subrange_type\) DW_AT_upper_bound : 6 - .*: Abbrev Number: 3 \(DW_TAG_base_type\) + <.><.*>: Abbrev Number: 3 \(DW_TAG_base_type\) DW_AT_name : char DW_AT_byte_size : 1 - DW_AT_encoding : . \(.* char\) - .*: Abbrev Number: 7 \(DW_TAG_variable\) + DW_AT_encoding : 8 \(unsigned char\) + <.><.*>: Abbrev Number: 7 \(DW_TAG_variable\) DW_AT_name : string DW_AT_decl_file : 1 DW_AT_decl_line : 6 - DW_AT_type : .* + DW_AT_type : <.*> DW_AT_location : 5 byte block: 3 . 0 0 . \(DW_OP_addr: .\) diff --git a/binutils/testsuite/binutils-all/testprog.c b/binutils/testsuite/binutils-all/testprog.c index 210656b..c2b1856 100644 --- a/binutils/testsuite/binutils-all/testprog.c +++ b/binutils/testsuite/binutils-all/testprog.c @@ -1,5 +1,7 @@ /* This program is used to test objcopy and strip. */ +#include + int common; int global = 1; static int local = 2; diff --git a/binutils/windres.c b/binutils/windres.c index 7de28c2..3b24b47 100644 --- a/binutils/windres.c +++ b/binutils/windres.c @@ -46,6 +46,10 @@ #include #include +/* used by resrc.c at least */ + +int verbose = 0; + /* An enumeration of format types. */ enum res_format @@ -109,7 +113,9 @@ static struct include_dir *include_dirs; #define OPTION_INCLUDE_DIR (OPTION_HELP + 1) #define OPTION_LANGUAGE (OPTION_INCLUDE_DIR + 1) #define OPTION_PREPROCESSOR (OPTION_LANGUAGE + 1) -#define OPTION_VERSION (OPTION_PREPROCESSOR + 1) +#define OPTION_USE_TEMP_FILE (OPTION_PREPROCESSOR + 1) +#define OPTION_NO_USE_TEMP_FILE (OPTION_USE_TEMP_FILE + 1) +#define OPTION_VERSION (OPTION_NO_USE_TEMP_FILE + 1) #define OPTION_YYDEBUG (OPTION_VERSION + 1) static const struct option long_options[] = @@ -122,6 +128,9 @@ static const struct option long_options[] = {"output-format", required_argument, 0, 'O'}, {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR}, {"target", required_argument, 0, 'F'}, + {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE}, + {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE}, + {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, OPTION_VERSION}, {"yydebug", no_argument, 0, OPTION_YYDEBUG}, {0, no_argument, 0, 0} @@ -705,8 +714,13 @@ Options:\n\ -F TARGET, --target TARGET Specify COFF target\n\ --preprocessor PROGRAM Program to use to preprocess rc file\n\ --include-dir DIR Include directory when preprocessing rc file\n\ - --define SYM[=VAL] Define SYM when preprocessing rc file\n\ - --language VAL Set language when reading rc file\n")); + -DSYM[=VAL], --define SYM[=VAL]\n\ + Define SYM when preprocessing rc file\n\ + -v Verbose - tells you what it's doing\n\ + --language VAL Set language when reading rc file\n\ + --use-temp-file Use a temporary file instead of popen to read\n\ + the preprocessor output\n\ + --no-use-temp-file Use popen (default)\n")); #ifdef YYDEBUG fprintf (stream, _("\ --yydebug Turn on parser debugging\n")); @@ -724,6 +738,34 @@ No input-file is stdin, default rc. No output-file is stdout, default rc.\n")); exit (status); } +/* Quote characters that will confuse the shell when we run the preprocessor */ +static const char *quot (string) + const char *string; +{ + static char *buf = 0; + static int buflen = 0; + int slen = strlen (string); + const char *src; + char *dest; + + if ((buflen < slen * 2 + 2) || !buf) + { + buflen = slen * 2 + 2; + if (buf) + free (buf); + buf = (char *) xmalloc (buflen); + } + + for (src=string, dest=buf; *src; src++, dest++) + { + if (*src == '(' || *src == ')' || *src == ' ') + *dest++ = '\\'; + *dest = *src; + } + *dest = 0; + return buf; +} + /* The main function. */ int @@ -739,8 +781,10 @@ main (argc, argv) char *target; char *preprocessor; char *preprocargs; + const char *quotedarg; int language; struct res_directory *resources; + int use_temp_file; #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) setlocale (LC_MESSAGES, ""); @@ -764,8 +808,9 @@ main (argc, argv) preprocessor = NULL; preprocargs = NULL; language = -1; + use_temp_file = 0; - while ((c = getopt_long (argc, argv, "i:o:I:O:F:", long_options, + while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:v", long_options, (int *) 0)) != EOF) { switch (c) @@ -794,35 +839,44 @@ main (argc, argv) preprocessor = optarg; break; + case 'D': case OPTION_DEFINE: if (preprocargs == NULL) { - preprocargs = xmalloc (strlen (optarg) + 3); - sprintf (preprocargs, "-D%s", optarg); + quotedarg = quot (optarg); + preprocargs = xmalloc (strlen (quotedarg) + 3); + sprintf (preprocargs, "-D%s", quotedarg); } else { char *n; - n = xmalloc (strlen (preprocargs) + strlen (optarg) + 4); - sprintf (n, "%s -D%s", preprocargs, optarg); + quotedarg = quot (optarg); + n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4); + sprintf (n, "%s -D%s", preprocargs, quotedarg); free (preprocargs); preprocargs = n; } break; + case 'v': + verbose ++; + break; + case OPTION_INCLUDE_DIR: if (preprocargs == NULL) { - preprocargs = xmalloc (strlen (optarg) + 3); - sprintf (preprocargs, "-I%s", optarg); + quotedarg = quot (optarg); + preprocargs = xmalloc (strlen (quotedarg) + 3); + sprintf (preprocargs, "-I%s", quotedarg); } else { char *n; - n = xmalloc (strlen (preprocargs) + strlen (optarg) + 4); - sprintf (n, "%s -I%s", preprocargs, optarg); + quotedarg = quot (optarg); + n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4); + sprintf (n, "%s -I%s", preprocargs, quotedarg); free (preprocargs); preprocargs = n; } @@ -845,6 +899,14 @@ main (argc, argv) language = strtol (optarg, (char **) NULL, 16); break; + case OPTION_USE_TEMP_FILE: + use_temp_file = 1; + break; + + case OPTION_NO_USE_TEMP_FILE: + use_temp_file = 0; + break; + #ifdef YYDEBUG case OPTION_YYDEBUG: yydebug = 1; @@ -904,7 +966,7 @@ main (argc, argv) abort (); case RES_FORMAT_RC: resources = read_rc_file (input_filename, preprocessor, preprocargs, - language); + language, use_temp_file); break; case RES_FORMAT_RES: resources = read_res_file (input_filename); diff --git a/binutils/windres.h b/binutils/windres.h index a3c789a..ba73612 100644 --- a/binutils/windres.h +++ b/binutils/windres.h @@ -742,10 +742,12 @@ struct bindata unsigned char *data; }; +extern int verbose; + /* Function declarations. */ extern struct res_directory *read_rc_file - PARAMS ((const char *, const char *, const char *, int)); + PARAMS ((const char *, const char *, const char *, int, int)); extern struct res_directory *read_res_file PARAMS ((const char *)); extern struct res_directory *read_coff_rsrc PARAMS ((const char *, const char *)); diff --git a/binutils/wrstabs.c b/binutils/wrstabs.c index e428174..8b51587 100644 --- a/binutils/wrstabs.c +++ b/binutils/wrstabs.c @@ -1,5 +1,5 @@ /* wrstabs.c -- Output stabs debugging information - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of GNU Binutils. @@ -984,7 +984,7 @@ static boolean stab_function_type (p, argcount, varargs) PTR p; int argcount; - boolean varargs; + boolean varargs ATTRIBUTE_UNUSED; { struct stab_write_handle *info = (struct stab_write_handle *) p; int i; @@ -2383,7 +2383,7 @@ stab_end_block (p, addr) /*ARGSUSED*/ static boolean stab_end_function (p) - PTR p; + PTR p ATTRIBUTE_UNUSED; { return true; } diff --git a/config.guess b/config.guess index 3c75a80..20c971a 100755 --- a/config.guess +++ b/config.guess @@ -1,6 +1,7 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# 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 @@ -22,7 +23,7 @@ # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . -# The master version of this file is at the FSF in /home/gd/gnu/lib. +# Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and @@ -35,6 +36,20 @@ # (but try to keep the structure clean). # +# Use $HOST_CC if defined. $CC may point to a cross-compiler +if test x"$CC_FOR_BUILD" = x; then + if test x"$HOST_CC" != x; then + CC_FOR_BUILD="$HOST_CC" + else + if test x"$CC" != x; then + CC_FOR_BUILD="$CC" + else + CC_FOR_BUILD=cc + fi + fi +fi + + # 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 @@ -46,11 +61,49 @@ 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 +dummy=dummy-$$ +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 + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-cbm ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format. + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -59,56 +112,69 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # 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 <dummy.s + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text .globl main + .align 4 .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 + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit .end main EOF - ${CC-cc} dummy.s -o dummy 2>/dev/null + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; - 15) + 1-0) UNAME_MACHINE="alphaev5" ;; - 14) + 1-1) UNAME_MACHINE="alphaev56" ;; - 10) + 1-101) UNAME_MACHINE="alphapca56" ;; - 16) + 2-303) UNAME_MACHINE="alphaev6" ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; esac fi - rm -f dummy.s dummy + rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + 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 ;; @@ -133,16 +199,16 @@ EOF wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + 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*:*:*) + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-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 @@ -150,7 +216,7 @@ EOF echo pyramid-pyramid-bsd fi exit 0 ;; - NILE:*:*:dcosx) + NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) @@ -195,21 +261,38 @@ EOF 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} + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${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 ;; @@ -231,12 +314,17 @@ EOF VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; - 2020:CLIX:*:*) + 2020:CLIX:*:* | 2430: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; { + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); @@ -251,10 +339,10 @@ EOF 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 + $CC_FOR_BUILD $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:*:*) @@ -272,15 +360,18 @@ EOF 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 + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then echo m88k-dg-dgux${UNAME_RELEASE} - else + else echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} fi - else echo i586-dg-dgux${UNAME_RELEASE} - fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 @@ -306,7 +397,7 @@ EOF exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - sed 's/^ //' << EOF >dummy.c + sed 's/^ //' << EOF >$dummy.c #include main() @@ -317,8 +408,8 @@ EOF exit(0); } EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy + $CC_FOR_BUILD $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 @@ -327,7 +418,8 @@ EOF fi exit 0 ;; *:AIX:*:4) - if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -345,7 +437,7 @@ EOF ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) @@ -360,33 +452,29 @@ EOF 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 + 9000/[678][0-9][0-9]) + sed 's/^ //' << EOF >$dummy.c #include #include - + int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); - #endif + #endif long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) + + 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: + case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) - switch (bits) + switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; @@ -394,20 +482,20 @@ EOF } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; - #endif + #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 + (CCOPTS= $CC_FOR_BUILD $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 + sed 's/^ //' << EOF >$dummy.c #include int main () @@ -432,8 +520,8 @@ EOF exit (0); } EOF - ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 - rm -f dummy.c dummy + $CC_FOR_BUILD $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:*:* ) @@ -442,6 +530,9 @@ EOF 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; @@ -491,7 +582,13 @@ EOF -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos @@ -504,15 +601,18 @@ EOF 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:*:*) + i?86:BSD/386:*:* | i?86:BSD/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; *:FreeBSD:*:*) if test -x /usr/bin/objformat; then if test "elf" = "`/usr/bin/objformat`"; then @@ -520,32 +620,28 @@ EOF 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/[-_].*/\./'` + echo ${UNAME_MACHINE}-unknown-freebsd`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 + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin 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? + # How do we know it's Interix rather than the 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? + # 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 + echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -554,16 +650,11 @@ EOF 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` + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_help_string=`cd /; ld --help 2>&1` ld_supported_emulations=`echo $ld_help_string \ | sed -ne '/supported emulations:/!d s/[ ][ ]*/ /g @@ -571,14 +662,41 @@ EOF 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) + *ia64) + echo "${UNAME_MACHINE}-unknown-linux" + exit 0 + ;; + 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 + ;; + elf32arm*) + echo "${UNAME_MACHINE}-unknown-linux-gnuoldld" + exit 0 + ;; + armelf_linux*) + echo "${UNAME_MACHINE}-unknown-linux-gnu" + exit 0 + ;; + m68klinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + elf32ppc | elf32ppclinux) # Determine Lib Version - cat >dummy.c <$dummy.c < #if defined(__GLIBC__) extern char __libc_version[]; @@ -597,71 +715,85 @@ main(argc, argv) } EOF LIBC="" - ${CC-cc} dummy.c -o dummy 2>/dev/null + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null if test "$?" = 0 ; then - ./dummy | grep 1\.99 > /dev/null + ./$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 ;; + rm -f $dummy.c $dummy + echo powerpc-unknown-linux-gnu${LIBC} + exit 0 + ;; esac if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <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 + cat <$dummy.s + .data + \$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main + main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main EOF LIBC="" - ${CC-cc} dummy.s -o dummy 2>/dev/null + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then - ./dummy - case "$?" in - 7) + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; - 15) + 1-0) UNAME_MACHINE="alphaev5" ;; - 14) + 1-1) UNAME_MACHINE="alphaev56" ;; - 10) + 1-101) UNAME_MACHINE="alphapca56" ;; - 16) + 2-303) UNAME_MACHINE="alphaev6" ;; - esac + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac - objdump --private-headers dummy | \ + objdump --private-headers $dummy | \ grep ld.so.1 > /dev/null if test "$?" = 0 ; then LIBC="libc1" fi - fi - rm -f dummy.s dummy + fi + rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 elif test "${UNAME_MACHINE}" = "mips" ; then - cat >dummy.c <$dummy.c < /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif #ifdef __MIPSEB__ printf ("%s-unknown-linux-gnu\n", argv[1]); #endif @@ -671,8 +803,10 @@ main(argc, argv) 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 + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + elif test "${UNAME_MACHINE}" = "s390"; then + echo s390-ibm-linux && exit 0 else # Either a pre-BFD a.out linker (linux-gnuoldld) # or one that does not give us useful --help. @@ -691,12 +825,14 @@ EOF ;; esac # Determine whether the default compiler is a.out or elf - cat >dummy.c <$dummy.c < -main(argc, argv) - int argc; - char *argv[]; -{ +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 @@ -713,8 +849,8 @@ main(argc, argv) 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 + $CC_FOR_BUILD $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. @@ -730,24 +866,22 @@ EOF echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i?86:*:5:7*) + # Fixed at (any) Pentium or better + UNAME_MACHINE=i586 + if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then + echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} + 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' /dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*PentII' >/dev/null) \ + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pent II' >/dev/null) \ + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/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 ;; + i?86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; pc:*:*:*) + # Left here for compatibility: # 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 @@ -809,7 +945,7 @@ EOF mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i?86:LynxOS:2.*:*) + i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) @@ -821,6 +957,9 @@ EOF SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; @@ -851,7 +990,7 @@ EOF news*:NEWS-OS:*:6*) echo mips-sony-newsos6 exit 0 ;; - R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*) + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else @@ -867,12 +1006,33 @@ EOF BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + Power*:Mac*OS:*:*) + echo powerpc-apple-macos${UNAME_RELEASE} + exit 0 ;; + *:Mac*OS:*:*) + echo ${UNAME_MACHINE}-apple-macos${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-qnx-qnx${UNAME_VERSION} + 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 <$dummy.c < # include @@ -910,7 +1070,10 @@ main () #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); + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif @@ -970,8 +1133,8 @@ main () } EOF -${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 -rm -f dummy.c dummy +$CC_FOR_BUILD $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. diff --git a/config.sub b/config.sub index 3d4f5fd..5d75624 100755 --- a/config.sub +++ b/config.sub @@ -1,6 +1,8 @@ #! /bin/sh # Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# 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. @@ -25,6 +27,9 @@ # 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 . +# Please send patches to . +# # 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. @@ -64,18 +69,6 @@ case $1 in ;; 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/'` @@ -110,14 +103,14 @@ case $os in os= basic_machine=$1 ;; - -sim | -cisco | -oki | -wec | -winbond ) # EGCS LOCAL + -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; - -scout) # EGCS LOCAL + -scout) ;; - -wrs) # EGCS LOCAL - os=vxworks + -wrs) + os=-vxworks basic_machine=$1 ;; -hiux*) @@ -168,74 +161,34 @@ case $os in -psos*) os=-psos ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; 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 \ + tahoe | i860 | ia64 | 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] \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ | 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) + | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | miprs64vr5000el | mcore \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ + | thumb | d10v | fr30 | avr) basic_machine=$basic_machine-unknown ;; - tic30) # CYGNUS LOCAL ian/tic30 - basic_machine=$basic_machine-unknown - ;; - c30) # CYGNUS LOCAL ian/tic30 - basic_machine=tic30-unknown + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl) ;; - 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. @@ -248,57 +201,29 @@ case $basic_machine in exit 1 ;; # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | 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-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ + | 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 + | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f301-* | armv*-* | s390-* | sv1-* | t3e-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* ) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) # EGCS LOCAL + 386bsd) basic_machine=i386-unknown os=-bsd ;; @@ -308,11 +233,11 @@ case $basic_machine in 3b*) basic_machine=we32k-att ;; - a29khif) # EGCS LOCAL + a29khif) basic_machine=a29k-amd os=-udi ;; - adobe68k) # EGCS LOCAL + adobe68k) basic_machine=m68010-adobe os=-scout ;; @@ -345,7 +270,7 @@ case $basic_machine in basic_machine=m68k-apollo os=-sysv ;; - apollo68bsd) # EGCS LOCAL + apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; @@ -425,7 +350,7 @@ case $basic_machine in encore | umax | mmax) basic_machine=ns32k-encore ;; - es1800 | OSE68k | ose68k | ose | OSE) # EGCS LOCAL + es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; @@ -447,11 +372,11 @@ case $basic_machine in basic_machine=h8300-hitachi os=-hms ;; - h8300xray) # EGCS LOCAL + h8300xray) basic_machine=h8300-hitachi os=-xray ;; - h8500hms) # EGCS LOCAL + h8500hms) basic_machine=h8500-hitachi os=-hms ;; @@ -470,22 +395,6 @@ case $basic_machine in 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 ;; @@ -495,22 +404,21 @@ case $basic_machine in hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9] ) + 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] ) + hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; - hp9k78[0-9] | hp78[0-9] ) + 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 ) + 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] ) + hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) @@ -519,13 +427,16 @@ case $basic_machine in hppa-next) os=-nextstep3 ;; - hppaosf) # EGCS LOCAL + hppaosf) basic_machine=hppa1.1-hp os=-osf ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; i370-ibm* | ibm*) basic_machine=i370-ibm - os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i[34567]86v32) @@ -544,15 +455,15 @@ case $basic_machine in basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; - i386mach) # EGCS LOCAL + i386mach) basic_machine=i386-mach os=-mach ;; - i386-vsta | vsta) # EGCS LOCAL + i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; - i386-go32 | go32) # EGCS LOCAL + i386-go32 | go32) basic_machine=i386-unknown os=-go32 ;; @@ -560,6 +471,9 @@ case $basic_machine in basic_machine=i386-unknown os=-mingw32 ;; + i386-qnx | qnx) + basic_machine=i386-qnx + ;; iris | iris4d) basic_machine=mips-sgi case $os in @@ -588,6 +502,10 @@ case $basic_machine in miniframe) basic_machine=m68000-convergent ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu @@ -602,24 +520,32 @@ case $basic_machine in mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; - monitor) # EGCS LOCAL + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) basic_machine=m68k-rom68k os=-coff ;; - msdos) # EGCS LOCAL - basic_machine=i386-unknown + msdos) + basic_machine=i386-unknown os=-msdos ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) - basic_machine=i386-unknown # EGCS LOCAL + basic_machine=i386-unknown os=-netbsd ;; netwinder) - basic_machine=armv4l-corel + basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) @@ -634,7 +560,7 @@ case $basic_machine in basic_machine=mips-sony os=-newsos ;; - necv70) # EGCS LOCAL + necv70) basic_machine=v70-nec os=-sysv ;; @@ -663,18 +589,22 @@ case $basic_machine in basic_machine=i960-intel os=-nindy ;; - mon960) # EGCS LOCAL + mon960) basic_machine=i960-intel os=-mon960 ;; np1) basic_machine=np1-gould ;; - OSE68000 | ose68000) # EGCS LOCAL + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; - os68k) # EGCS LOCAL + os68k) basic_machine=m68k-none os=-os68k ;; @@ -695,19 +625,19 @@ case $basic_machine in pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | k5 | nexen) + pentium | p5 | k5 | k6 | nexen) basic_machine=i586-pc ;; - pentiumpro | p6 | k6 | 6x86) + pentiumpro | p6 | 6x86) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i786-pc ;; - pentium-* | p5-* | k5-* | nexen-*) + pentium-* | p5-* | k5-* | k6-* | nexen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumpro-* | p6-* | k6-* | 6x86-*) + pentiumpro-* | p6-* | 6x86-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) @@ -731,7 +661,7 @@ case $basic_machine in ps2) basic_machine=i386-ibm ;; - rom68k) # EGCS LOCAL + rom68k) basic_machine=m68k-rom68k os=-coff ;; @@ -741,7 +671,7 @@ case $basic_machine in rtpc | rtpc-*) basic_machine=romp-ibm ;; - sa29200) # EGCS LOCAL + sa29200) basic_machine=a29k-amd os=-udi ;; @@ -752,7 +682,7 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; - sparclite-wrs) # EGCS LOCAL + sparclite-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -763,10 +693,10 @@ case $basic_machine in spur) basic_machine=spur-unknown ;; - st2000) # EGCS LOCAL + st2000) basic_machine=m68k-tandem ;; - stratus) # EGCS LOCAL + stratus) basic_machine=i860-stratus os=-sysv4 ;; @@ -810,10 +740,18 @@ case $basic_machine in sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; symmetry) basic_machine=i386-sequent os=-dynix ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; tx39) basic_machine=mipstx39-unknown ;; @@ -831,7 +769,7 @@ case $basic_machine in basic_machine=a29k-nyu os=-sym1 ;; - v810 | necv810) # EGCS LOCAL + v810 | necv810) basic_machine=v810-nec os=-none ;; @@ -858,9 +796,13 @@ case $basic_machine in basic_machine=a29k-wrs os=-vxworks ;; - w65*) # EGCS LOCAL - basic_machine=w65-wdc - os=-none + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf ;; xmp) basic_machine=xmp-cray @@ -869,7 +811,7 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; - z8k-*-coff) # EGCS LOCAL + z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; @@ -880,13 +822,13 @@ case $basic_machine in # 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 + w89k) basic_machine=hppa1.1-winbond ;; - op50n) # EGCS LOCAL + op50n) basic_machine=hppa1.1-oki ;; - op60c) # EGCS LOCAL + op60c) basic_machine=hppa1.1-oki ;; mips) @@ -923,16 +865,16 @@ case $basic_machine in orion105) basic_machine=clipper-highlevel ;; - mac | mpw | mac-mpw) # EGCS LOCAL + mac | mpw | mac-mpw) basic_machine=m68k-apple ;; - pmac | pmac-mpw) # EGCS LOCAL + pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 @@ -991,18 +933,16 @@ case $os in | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* ) + | -interix* | -uwin* | -rhapsody* | -opened* | -openstep* | -oskit*) # 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* ) + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; - # END EGCS LOCAL -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; @@ -1012,6 +952,12 @@ case $os in -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; -osfrose*) os=-osfrose ;; @@ -1027,7 +973,7 @@ case $os in -acis*) os=-aos ;; - -386bsd) # EGCS LOCAL + -386bsd) os=-bsd ;; -ctix* | -uts*) @@ -1049,6 +995,9 @@ case $os in -oss*) os=-sysv3 ;; + -qnx) + os=-qnx4 + ;; -svr4) os=-sysv4 ;; @@ -1061,15 +1010,18 @@ case $os in # This must come after -sysvr4. -sysv*) ;; - -ose*) # EGCS LOCAL + -ose*) os=-ose ;; - -es1800*) # EGCS LOCAL + -es1800*) os=-ose ;; -xenix) os=-xenix ;; + -*mint | -*MiNT) + os=-mint + ;; -none) ;; *) @@ -1095,7 +1047,7 @@ case $basic_machine in *-acorn) os=-riscix1.2 ;; - arm*-corel) + arm*-rebel) os=-linux ;; arm*-semi) @@ -1119,15 +1071,15 @@ case $basic_machine in # default. # os=-sunos4 ;; - m68*-cisco) # EGCS LOCAL + m68*-cisco) os=-aout ;; - mips*-cisco) # EGCS LOCAL + mips*-cisco) + os=-elf + ;; + mips*-*) os=-elf ;; - mips*-*) # EGCS LOCAL - os=-elf - ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; @@ -1140,13 +1092,13 @@ case $basic_machine in *-ibm) os=-aix ;; - *-wec) # EGCS LOCAL + *-wec) os=-proelf ;; - *-winbond) # EGCS LOCAL + *-winbond) os=-proelf ;; - *-oki) # EGCS LOCAL + *-oki) os=-proelf ;; *-hp) @@ -1212,15 +1164,18 @@ case $basic_machine in f301-fujitsu) os=-uxpv ;; - *-rom68k) # EGCS LOCAL + *-rom68k) os=-coff ;; - *-*bug) # EGCS LOCAL + *-*bug) os=-coff ;; - *-apple) # EGCS LOCAL + *-apple) os=-macos ;; + *-atari*) + os=-mint + ;; *) os=-none ;; @@ -1266,7 +1221,7 @@ case $basic_machine in -genix*) vendor=ns ;; - -mvs*) + -mvs* | -opened*) vendor=ibm ;; -ptx*) @@ -1278,12 +1233,15 @@ case $basic_machine in -aux*) vendor=apple ;; - -hms*) # EGCS LOCAL + -hms*) vendor=hitachi ;; - -mpw* | -macos*) # EGCS LOCAL + -mpw* | -macos*) vendor=apple ;; + -*mint | -*MiNT) + vendor=atari + ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; diff --git a/config/ChangeLog b/config/ChangeLog index 7d6fc60..b5746b1 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,17 @@ +2000-02-23 Linas Vepstas + + * mh-i370pic: New file. + * mt-i370pic: New file. + +2000-02-22 Nick Clifton + + * config/mt-wince: new file: Makefile fragment for WinCE targets. + +2000-01-06 Geoff Keating + + * mh-aix43: Delete, move to mt-aix43. + * mt-aix43: New file. + 1999-04-07 Michael Meissner * mt-d30v: New file, pass -g -Os -Wa,-C as default options. diff --git a/config/mh-i370pic b/config/mh-i370pic new file mode 100644 index 0000000..35cf2c8 --- /dev/null +++ b/config/mh-i370pic @@ -0,0 +1 @@ +PICFLAG=-fPIC diff --git a/config/mh-aix43 b/config/mt-aix43 similarity index 100% rename from config/mh-aix43 rename to config/mt-aix43 diff --git a/config/mt-i370pic b/config/mt-i370pic new file mode 100644 index 0000000..35b8c9e --- /dev/null +++ b/config/mt-i370pic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fPIC diff --git a/config/mt-wince b/config/mt-wince new file mode 100644 index 0000000..cc7d67b --- /dev/null +++ b/config/mt-wince @@ -0,0 +1,10 @@ +# For Windows CE, we need to build the program that converts, copies, +# and renames the platform SDK files into gcc directories. + +EXTRA_TARGET_HOST_ALL_MODULES:=$(EXTRA_TARGET_HOST_ALL_MODULES) all-utils +EXTRA_TARGET_HOST_INSTALL_MODULES:=$(EXTRA_TARGET_HOST_INSTALL_MODULES) install-utils + +all-utils : all-libiberty + +install-utils : all-libiberty + diff --git a/configure b/configure index cad60b7..c5f0291 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ ### 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 +# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -587,12 +587,12 @@ esac # 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}` + gcc_version=`grep version_string ${with_gcc_version_trigger} | sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/'` 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}` + gcc_version=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/'` case "$arguments" in *--with-gcc-version-trigger=$gcc_version_trigger* ) ;; @@ -655,8 +655,8 @@ case "${TMPDIR}" in *) ;; esac -# keep this filename short for &%*%$*# 14 char file names -tmpfile=${TMPDIR}/cONf$$ +# keep this filename short for &%*%$*# 14 char file names and 8+3 file names +tmpfile=${TMPDIR}/cNf$$ # 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 @@ -902,6 +902,9 @@ do test -n "$DEFAULT_LEX" && break done +# BINUTILS LOCAL: This is included in the default CFLAGS when using gcc. +warn_cflags="-W -Wall" + 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. @@ -935,7 +938,7 @@ t loop AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as} BISON=${BISON-bison} CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O2 ${warn_cflags}"} CXX=${CXX-${host_alias}-c++} CXXFLAGS=${CXXFLAGS-"-g -O2"} CC_FOR_BUILD=${CC_FOR_BUILD-gcc} @@ -1015,10 +1018,10 @@ else CC="gcc" echo 'void f(){}' > conftest.c if test -z "`${CC} -g -c conftest.c 2>&1`"; then - CFLAGS=${CFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O2 ${warn_cflags}"} CXXFLAGS=${CXXFLAGS-"-g -O2"} else - CFLAGS=${CFLAGS-"-O2"} + CFLAGS=${CFLAGS-"-O2 ${warn_cflags}"} CXXFLAGS=${CXXFLAGS-"-O2"} fi rm -f conftest* @@ -1035,10 +1038,10 @@ else *gcc) echo 'void f(){}' > conftest.c if test -z "`${CC} -g -c conftest.c 2>&1`"; then - CFLAGS=${CFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O2 ${warn_cflags}"} CXXFLAGS=${CXXFLAGS-"-g -O2"} else - CFLAGS=${CFLAGS-"-O2"} + CFLAGS=${CFLAGS-"-O2 ${warn_cflags}"} CXXFLAGS=${CXXFLAGS-"-O2"} fi rm -f conftest* @@ -1057,6 +1060,21 @@ export CXX export CFLAGS export CXXFLAGS +# FIXME: This should be in configure.in, not configure +case "$host" in + *go32*) + enable_gdbtk=no ;; + *msdosdjgpp*) + enable_gdbtk=no ;; +esac + +# FIXME: This should be in configure.in, not configure +# Determine whether gdb needs tk/tcl or not. +if [ "$enable_gdbtk" != "no" ]; then + GDB_TK="all-tcl all-tk all-itcl all-tix all-libgui" +else + GDB_TK="" +fi for subdir in . ${subdirs} ; do @@ -1398,6 +1416,8 @@ EOF -e "s:^DEFAULT_M4[ ]*=.*$:DEFAULT_M4 = ${DEFAULT_M4}:" \ ${subdir}/Makefile.tem >> ${Makefile} + sed -e "s:^GDB_TK[ ]*=.*$:GDB_TK = ${GDB_TK}:" ${Makefile} >${Makefile}.tem + mv -f ${Makefile}.tem ${Makefile} # If this is a Canadian Cross, preset the values of many more # tools. diff --git a/configure.bat b/configure.bat deleted file mode 100644 index d76a37e..0000000 --- a/configure.bat +++ /dev/null @@ -1,17 +0,0 @@ -@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 index e4e5c43..ca1b04f 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,7 @@ ## 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. +# Copyright (C) 1992-99, 2000 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 @@ -223,9 +223,6 @@ case "${host}" in *-*-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" ;; @@ -291,6 +288,9 @@ if [ x${shared} = xyes ]; then i[3456]86-*-*) host_makefile_frag="${host_makefile_frag} config/mh-x86pic" ;; + i370-*-*) + host_makefile_frag="${host_makefile_frag} config/mh-i370pic" + ;; sparc64-*-*) host_makefile_frag="${host_makefile_frag} config/mh-sparcpic" ;; @@ -329,9 +329,15 @@ case "${target}" in powerpc-*-netware*) target_makefile_frag="${target_makefile_frag} config/mt-netware" ;; - *-*-linux-gnu) + *-*-linux-gnu*) target_makefile_frag="${target_makefile_frag} config/mt-linux" ;; + *-*-aix4.[3456789]* | *-*-aix[56789].*) + target_makefile_frag="${target_makefile_frag} config/mt-aix43" + ;; + mips*-*-pe | sh*-*-pe | *arm-wince-pe) + target_makefile_frag="${target_makefile_frag} config/mt-wince" + ;; esac # If --enable-target-optspace always use -Os instead of -O2 to build @@ -341,7 +347,6 @@ 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" ;; @@ -523,13 +528,13 @@ case "${host}" in ;; 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" + noconfigdirs="expect dejagnu cvs autoconf automake send-pr 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" + noconfigdirs="autoconf automake send-pr rcs guile perl texinfo apache inet" ;; *-*-netbsd*) noconfigdirs="rcs" @@ -569,6 +574,21 @@ case "${target}" in # newlib is not 64 bit ready noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; + sh*-*-pe|mips*-*-pe|*arm-wince-pe) + noconfigdirs="$noconfigdirs target-libjava target-libffi target-zlib" + noconfigdirs="$noconfigdirs target-boehm-gc target-qthreads target-examples" + noconfigdirs="$noconfigdirs target-librx target-libiberty texinfo send-pr" + noconfigdirs="$noconfigdirs tcl tix tk itcl libgui sim" + noconfigdirs="$noconfigdirs expect dejagnu" + # the C++ libraries don't build on top of CE's C libraries + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio" + skipdirs="$skipdirs target-newlib" + case "${host}" in + *-*-cygwin*) ;; # keep gdb and readline + *) noconfigdirs="$noconfigdirs gdb readline target-libio target-libstdc++ target-libg++" + ;; + esac + ;; arc-*-*) noconfigdirs="$noconfigdirs target-libgloss" ;; @@ -596,15 +616,12 @@ case "${target}" in 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 @@ -617,8 +634,7 @@ case "${target}" in target_configdirs="${target_configdirs} target-bsp target-cygmon" fi ;; -# END CYGNUS LOCAL - thumb-*-pe) # CYGNUS LOCAL nickc/thumb + thumb-*-pe) noconfigdirs="$noconfigdirs target-libgloss" ;; arm-*-riscix*) @@ -627,24 +643,21 @@ case "${target}" in 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*-*-linux-gnu* | \ hppa*-*-lites*) - # Do configure ld/binutils/gas for this case. + # Do configure ld/binutils/gas for the above cases. ;; hppa*-*-*) # HP's C compiler doesn't handle Emacs correctly (but on BSD and Mach @@ -665,10 +678,6 @@ case "${target}" in # 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" @@ -743,8 +752,11 @@ case "${target}" in ;; powerpc-*-aix*) # copied from rs6000-*-* entry - noconfigdirs="$noconfigdirs gprof cvssrc target-libgloss" - # This is needed until gcc and ld are fixed to work together. + # The configure and build of ld are currently disabled because + # GNU ld is known to be broken for AIX 4.2 and 4.3 (at least) + # The symptom is that GDBtk 4.18 fails at startup with a segfault + # if linked by GNU ld, but not if linked by the native ld. + noconfigdirs="$noconfigdirs gprof cvssrc target-libgloss ld" use_gnu_ld=no ;; powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe) @@ -768,8 +780,11 @@ case "${target}" in noconfigdirs="$noconfigdirs target-newlib gprof cvssrc" ;; rs6000-*-aix*) - noconfigdirs="$noconfigdirs gprof" - # This is needed until gcc and ld are fixed to work together. + # The configure and build of ld are currently disabled because + # GNU ld is known to be broken for AIX 4.2 and 4.3 (at least) + # The symptom is that GDBtk 4.18 fails at startup with a segfault + # if linked by GNU ld, but not if linked by the native ld. + noconfigdirs="$noconfigdirs gprof ld" use_gnu_ld=no ;; rs6000-*-*) @@ -784,9 +799,14 @@ case "${target}" in noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss" ;; mips*-*-irix6*) - # The GNU assembler and linker do not support IRIX 6. + # The GNU assembler does 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" + noconfigdirs="$noconfigdirs gas gprof emacs target-libgloss" + ;; + mips*-*-linux*) + noconfigdirs="$noconfigdirs gprof" + # linux has rx in libc + skipdirs="$skipdirs target-librx" ;; mips*-dec-bsd*) noconfigdirs="$noconfigdirs gprof target-libgloss" @@ -841,18 +861,22 @@ case "${target}" in v850-*-*) noconfigdirs="$noconfigdirs target-libgloss" ;; - v850e-*-*) # CYGNUS LOCAL v850e + 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" ;; + *-*-linux*) + # linux has rx in libc + skipdirs="$skipdirs target-librx" + ;; *-*-lynxos*) # Newlib makes problems for libg++ in crosses. noconfigdirs="$noconfigdirs target-newlib target-libgloss" diff --git a/gas/ChangeLog b/gas/ChangeLog index 852b6c7..b69efd3 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,2439 @@ +2000-04-02 Richard Henderson + + * config/tc-d30v.c (check_range): Allow signed or unsigned 32-bit + quantities. Correct right shift sign extension. + (build_insn): Make `number' unsigned long. Mask top 6 bits of + 32-bit value when shifting into place. + +2000-04-01 Ian Lance Taylor + + * app.c: Add ATTRIBUTE_UNUSED as needed. + * config/tc-ppc.c: Likewise. + (ppc_size): Make unsigned long. + (ppc_insert_operand): Add casts to avoid warnings. + +2000-03-31 Nick Clifton + + * config/tc-d10v.h (md_flush_pending_output): Define. + +2000-03-29 Nick Clifton + + * config/tc-sh.h (SEG_NAME): New macro: return the name of a + segment. Works for both BFD_ASSEMBLER and others. + (SUB_SEGMENT_ALIGN): Use SEG_NAME. + +2000-03-29 Nick Clifton + + * listing.c (LISTING_LHS_WIDTH): Default depends on + LISTING_WORD_SIZE. + (LISTING_LHS_WIDTH_SECOND): Default to LISTING_LHS_WIDTH. + +2000-03-27 Ian Lance Taylor + + * config/tc-sh.c (md_show_usage): Use backslash before newline in + string literal. + +2000-03-27 Alan Modra + + * config/tc-avr.h (TC_HANDLES_FX_DONE): Define. + + * config/tc-avr.c (mcu_types): Add missing initialiser. + (md_pcrel_from_section): Add prototype. + (avr_operand): Remove redundant test of unsigned < 0. + (avr_cons_fix_new): Ensure exp_mod_pm zero on function exit. + +2000-03-27 Denis Chertykov + + * config/tc-avr.c: New file for AVR support. + * config/tc-avr.h: Likewise. + * configure.in: Add AVR support. + * configure: Regenerate. + +2000-03-26 Timothy Wall + + * gasp.c (macro_op): Add new argument to check_macro call. + Macro structure definitions moved to macro.h + * sb.h: Add argument to prototype for input_scrub_include_sb. + * input-scrub.c (input_scrub_include_sb): Allow disabling of sb + nesting checks with an additional flag. + (struct input_save): Add flag to indicate whether current sb + should be checked for proper macro/conditional nesting. + (input_scrub_push/pop): Save/restore nest check flag. + (input_scrub_next_buffer): Ditto. Also call end of macro hook if + defined. + * macro.c (check_macro): Allow caller to retrieve parsed macro + information if a pointer is provided. This information may be + used by the new macro hooks. + * macro.h: Update prototype for check_macro. Macro struct + definitions moved here from macro.c/gasp.c. + * read.c (read_a_source_file): Add parameter to check_macro call, + and pass macro info to the macro hook, if defined. + (input_scrub_insert_line): New. Allow insertion of a line of + characters into the input stream. + (input_scrub_insert_file): New. Allow insertion of an arbitrary + file into the input stream. + (s_include): Use input_scrub_insert_file. + * internals.texi: Document new macro hooks. + * as.h: New prototypes added. + +2000-03-26 Alan Modra + + * config/tc-i386.c: Don't start any as_bad or as_warn message with + an initial capital letter. + (i386_index_check): Reindent. + +2000-03-19 Nick Clifton + + * config/tc-arm.c (md_apply_fix3): Fix bug detectng overflow of pc + relative branches. + +2000-03-17 Thomas de Lellis + + * config/tc-arm.c (do_t_adr): Flag "adr Rd,label" + instruction operand bad if Rd > 7 when generating + thumb instructions. Prevents for example, + "adr r12,label" from silently failing and generating + the wrong instruction. + +2000-03-17 Nick Clifton + + * config/tc-arm.c (md_apply_fix3): Handle same-section relocations + that have a destingation >= 0x400000. + Fix compile time warning messages. + +Thu Mar 16 23:45:16 2000 J"orn Rennecke + + * config/tc-sh.c (md_begin): When encountering insn that are + not supported by the current arch, only change the name if + its contents are the same as prev_name. + (get_specific): If the the architecture doesn't match, fail. + +Thu Mar 16 21:18:13 2000 J"orn Rennecke + + * config/tc-sh.c (IDENT_CHAR): Define. + (parse_reg): Use it instead of isalnum. Put r[0..7]_bank operand + matching back where it came from. + +Thu Mar 16 20:58:10 2000 J"orn Rennecke + + * config/tc-sh.c (md_show_usage): Add description of -dsp. + +2000-03-15 Jonathan Larmour + + * config/tc-sh.c (parse_reg): Match r[0..7]_bank operands before + normal operands. + +2000-03-15 Kazu Hirata + + * config/tc-h8300.c: Add ATTRIBUTE_UNUSED as appropriate. + +Mon Mar 13 22:02:59 2000 Hans-Peter Nilsson + + * expr.c (operand) [case 'f']: When testing if '0f' can start a + floating-point-number, make sure 'f' is in FLT_CHARS. + +Sat Mar 11 00:01:39 2000 Hans-Peter Nilsson + + * read.c (TC_IMPLICIT_LCOMM_ALIGNMENT): New default-definition. + (s_lcomm_internal): Use it. + * doc/internals.texi (CPU backend): Document it. + * config/obj-evax.h (TC_IMPLICIT_LCOMM_ALIGNMENT): Set to 2**3 + bytes. + +2000-03-10 Geoffrey Keating + + * config/tc-mips.c (mips_ip): Don't put stuff in .rodata + when embedded-pic. + + * config/tc-mips.c (SWITCH_TABLE): The ELF embedded-pic + implementation doesn't have special handling for switch + statements. + (macro_build): Allow for code in sections other than .text. + (macro): Likewise. + (mips_ip): Likewise. + (md_apply_fix): Do pc-relative relocation madness for MIPS ELF. + Don't perform relocs if we will be outputting them. + (tc_gen_reloc): For ELF, just use fx_addnumber for pc-relative + relocations. Allow BFD_RELOC_16_PCREL_S2 relocs when + embedded-pic. + +2000-03-09 Catherine Moore + + * config/tc-m32r.c (m32r_fix_adjustable): Look up the + relocation type based on the entry in the fixup structure. + +2000-03-08 H.J. Lu (hjl@gnu.org) + + * Makefile.am (install-exec-tooldir): Depend on + install-exec-bindir for parallel make. + * Makefile.in: Regenerated. + +2000-03-06 Nick Clifton + + * config/tc-m32r.c (struct md_longopts): Add -m32r command line + switch. + (md_parse_option): Parse -m32r command line switch - disable m32rx + compatability. + (md_show_usage): Document new option. + + * doc/Makefile.am (CPU_DOCS): Add c-m32r.texi. + * doc/Makefile.in: Regenerate. + * doc/c-m32r.texi (M32R-Opts): Document new command line switch. + +2000-03-02 Michael Meissner + + * config/tc-d30v.c (check_range): Remove code that incorrectly + sign extended values where bits < 32. + +2000-03-02 H.J. Lu (hjl@gnu.org) + + * configure.in: Support --enable-targets=all on ia32. + * configure: Regenerated. + +2000-03-01 Nick Clifton + + * gasp.c (do_align): Remove bogus check of alignment value. + +2000-02-27 Thomas de Lellis + + * config/obj-elf.c (elf_frob_symbol): Remove code which when + TC_PPC was defined forced the type of a symbol with no other type + to be BSF_OBJECT. + +2000-02-27 Hans-Peter Nilsson + + * doc/internals.texi (CPU backend): Mention that + line_separator_chars do not break up comments. Fix typos for + LEX_AT and LEX_NAME descriptions. Document operands for + TC_EQUAL_IN_INSN, md_operand and md_section_align. Correct + description of md_create_short_jump usage. Document argument for + md_undefined_symbol. + +2000-02-27 Jakub Jelinek + + * config/tc-sparc.c (OPTION_UNDECLARED_REGS): New option. + (md_parse_option): Handle it. + (md_show_usage): Document it. + +2000-02-27 Ian Lance Taylor + + * config/tc-alpha.c (md_assemble): Accept `1' and `9' in an + opcode, for the instruction `pal19'. From Andrea Arcangeli + . + +2000-02-26 Alan Modra + + * config/tc-i386.c (i386_immediate): Move constant operand sizing + from here.. + (md_assemble): To here, before template operands are matched. + Also ensure a constant immediate is sign extended when we know the + size is at most 16 bits. This is to catch cases like "add + $0xffc0,%ax" where we don't know the size, and thus that the + immediate can be represented as Imm8S until after parsing the + register operand. + (i386_displacement): Similarly sign extend 16 bit constant + displacements. + (md_assemble): Relax 16-bit jump constant range check to suit sign + extended displacements. + +2000-02-26 Andreas Jaeger + + * doc/c-mips.texi (MIPS Opts): Fix typo in last patch. + +2000-02-25 Alan Modra + + * config/tc-i386.c (md_assemble): Don't swap intersegment jmp and + call operands when intel_syntax. + (intel_float_operand): Return 2 for "fi...". + (i386_operand_modifier): Change "DWORD PTR" test to suit above. + Return SHORT_MNEM_SUFFIX for "WORD PTR" when "fi...". Revert + earlier "SHORT" change. + (md_assemble): When determining suffix from Regs, exclude + InOutPortReg. + +2000-02-24 Nick Clifton + + * configure: Add arm-wince, mips-pe and sh-pe targets. + * configure: Regenerate. + + * config/obj-coff.h (COFF_WITH_PE): Define for mips-pe and + sh-pe targets. + (TARGET_FORMAT): Set to "pe-shl" for the sh-pe target and to + "pe-mips" for the mips-pe target. + + * config/tc-arm.c (insns): Change displacement encoded in BL + and B instructions if the target port is arm-wince. + (do_ldst): Do not bias the relocation offset if the target + port is arm-wince. + (md_pcrel_from): Add in missing relocation offset bias if the + target os arm-wince. + + * config/tc-mips.c (mips_target_format): Support COFF flavour. + (md_begin): Disable -G support for mips-pe target. + (md_apply_fix): Treat BFD_RELOC_RVA reloc as BFD_RELOC_32. + * config/tc-mips.h (USE_GLOBAL_POINTER_OPT): Add support for + COFF flavour. + + * config/tc-sh.c (md_begin): sh-pe target is little endian. + * config/tc-sh.h (SUB_SEGMENT_ALIGN): If using a BFD + assembler, just set the alignment to 4. + + * config/te-wince-pe.h: New file for WinCE targets. Define + TE_WINCE. + +2000-02-25 Alan Modra + + * config/tc-i386.c (md_assemble): Swap segments too for intel mode + string instructions. + (i386_operand_modifier): Set i.suffix = WORD_MNEM_SUFFIX for SHORT. + (i386_intel_memory_operand): After finding a segment override, + check again for no `[' before looking for a displacement. Bomb if + more than one displacement rather than silently discarding the + second and subsequent ones. Free strings malloc'd by + build_displacement_string. + +2000-02-24 Catherine Moore + + * config/obj-som.c (obj_pseudo_table): Add "weak". + (obj_som_weak): New routine. + +2000-02-24 Alan Modra + + * config/tc-i386.c (union i386_op): New. + (struct _i386_insn): Delete disps[], imms[], regs[]. Add op[]. + Throughout file replace occurences of disps[n], imms[n], regs[n] + with equivalent op[n].disps, op[n].imms, op[n].regs. Simplify + intel mode operand swapping. Add assert in regKludge and + fake_zero_displacement code. Test i.types[n] when outputting + displacements and immediates. Combine output of Disp16 with + Disp32. + (md_assemble): Don't try to fix broken UNIXWARE_COMPAT opcodes + when in intel mode by (not) reversing fsub and fdiv operands + before the template search. This fails for single operand + shorthand forms of the instruction, and if UNIXWARE_COMPAT is + undefined. Instead fix the base_opcode after we've found the + template. Move base_opcode xor with found_reverse_match from + opcode output code to before this fix so we test for the correct + opcodes. + (md_assemble): Don't use strcmp when deciding to ignore the suffix + check in intel mode. Instead compare opcodes. + + * config/tc-i386.h (TC_RELOC): Delete. + * config/tc-i386.c (TC_RELOC): Delete. Replace usage of TC_RELOC + with equivalent call to reloc. + + * as.h (flag_m68k_mri): Move declaration after target include, and + only declare when TC_M68K defined. Define as zero otherwise. + (LABELS_WITHOUT_COLONS, NO_PSEUDO_DOT): If undefined, define as 0. + * app.c (scrub_m68k_mri): Declare only when TC_M68K defined. + Define as zero otherwise. + (do_scrub_begin): Use m68k_mri parameter only when TC_M68K defined. + (struct app_save): Declare scrub_m68k_mri only when TC_M68K. + (app_push, app_pop): Save scrub_m68k_mri only when TC_M68K. + (do_scrub_chars): Use LABELS_WITHOUT_COLONS directly rather than + testing whether defined. + * cond.c (ignore_input): Use NO_PSEUDO_DOT directly. + * expr.c (operand): #ifdef unused case labels when TC_M68K undefined. + * read.c: Use LABELS_WITHOUT_COLONS and NO_PSEUDO_DOT directly + rather than testing whether defined. + (s_mri): Set flag_m68k_mri only when TC_M68K defined. + (parse_mri_cons): Declare and use only when TC_M68K. + * config/tc-hppa.h (LABELS_WITHOUT_COLONS): Define as 1. + * config/tc-m68k.h (NO_PSEUDO_DOT): Define as 1. + * config/tc-m88k.h (NO_PSEUDO_DOT): Define as 1. + + * NEWS: Mention IBM 370 support. + +2000-02-23 Richard Henderson + + * config/tc-i386.c (md_assemble): When swapping operands for + intel_syntax, assume everything that's not Imm or Disp is a + register. + +2000-02-23 Linas Vepstas + + * config/tc-i370.c, config/tc-i370.h: New files. + * Makefile.am: Add support for Linux/IBM 370. + * configure.in: Likewise. + * app.c (do_scrub_begin): Don't lex single quote when TC_I370. + * config/obj-elf.c: Include elf/i370.h + (obj_elf_section): Don't do anything special for flag_mri if TC_I370. + + * Makefile.in: Regenerate. + * configure: Regenerate. + + * doc/c-i370.texi: New file. + * doc/all.texi: Include it. + * doc/as.texinfo: And here. + * doc/Makefile.am(CPU_DOCS): Add c-i370.texi. + * doc/Makefile.in: Regenerate. + +2000-02-19 Michael Meissner + + * config/tc-d30v.c (parallel_ok): Use FLAG_NOT_WITH_ADDSUBppp to + determine if an instruction can be used in parallel with an ADDppp + or SUBppp instruction. + +2000-02-22 Andrew Haley + + * doc/c-mips.texi (MIPS Opts): Document -mgp32 and -mgp64. + +1999-12-30 Andrew Haley + + * config/tc-mips.c (mips_gp32): New variable. + (macro_build) Use mips_gp32. + (mips_ip): Ditto. + (md_longopts): Add "-mgp32" and "-mgp64". + (md_parse_option): Add OPTION_GP32 and OPTION_GP64. + +2000-02-22 Alexandre Oliva + + * config/obj-coff.c (add_lineno): Accept non-positive lineno with + warning, and bump it to 1. + +2000-02-22 Ian Lance Taylor + + From Brad Lucier : + * dwarf2dbg.c (print_stats): Add cast to force printf argument to + match format. + +2000-02-21 Catherine Moore + + * config/tc-mips.c (MF_HILO_INSN): Define. + (mips_7000_hilo_fix): Declare. + (append_insn): Conditionally insert nops after an mfhi/mflo insn. + (md_parse_option): Check for 7000_HILO_FIX options. + (OPTION_M7000_HILO_FIX): Define. + (OPTION_NO_M7000_HILO_FIX): Define. + * doc/c-mips.texi (-mfix7000): Describe. + +2000-02-21 Alan Modra + + * listing.c (print_lines): Remove unused variable `end'. + + * config/tc-i386.c (md_assemble): Use `reloc()' to select reloc + type for JumpInterSegment output. Use enum bfd_reloc_code_real for + reloc_type when BFD_ASSEMBLER. + (md_estimate_size_before_relax): Use enum bfd_reloc_code_real for + reloc_type when BFD_ASSEMBLER. Move common code out of switch + statement and quell signed vs. unsigned comparison warning. + +2000-02-18 Nick Clifton + + * config/tc-d10v.c (find_opcode): Add a symbol's value to + the computed frag offset, rather than overwriting it. + +Thu Feb 17 00:11:08 2000 J"orn Rennecke + + * config/tc-sh.c ("elf/sh.h"): Include. + (sh_dsp, valid_arch, reg_x, reg_y, reg_efg): New static variables. + (md.begin): Initialize target_arch. + Only include opcodes in has table that match selected architecture. + (parse_reg): Recognize register names for sh-dsp. + (parse_at): Recognize post-modify addressing. + (get_operands): The leading space is now optional. + (get_specific): Remove FDREG_N support. Add support for sh-dsp + arguments. Update valid_arch. + (build_Mytes): Add support for SDT_REG_N. + (find_cooked_opcode): New function, broken out of md_assemble. + (assemble_ppi, sh_elf_final_processing): New functions. + (md_assemble): Use find_cooked_opcode and assemble_ppi. + (md_longopts, md_parse_option): New option: -dsp. + * config/tc-sh.h (elf_tc_final_processing): Define. + (sh_elf_final_processing): Declare. + +Fri Feb 11 14:21:51 2000 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_build_unwind_subspace): Use subseg_new to create + the unwinder subspace. Save the current seg/subseg before creating + the new seg/subseg. + +2000-02-10 Nick Clifton + + * config/tc-mcore.c (INST_BYTE0): Redefine to handle big and + little endian targets. + (INST_BYTE1): Redefine to handle big and little endian + targets. + (cpu_type): New type: Select between M340 and M210. + (parse_psrmod): New function: Parse the PSRCLR and PSRSET + instructions of the M340. + (md_assemble): Add support for the MULSH and OPSR classes of + instructions. + (md_atof): Add support for little endian targets. + (md_parse_option): Add support for -EL, -EB and -mcpu command + line switches. + (md_convert_frag): Add support for little endian targets. + (md_apply_fix3): Add support for little endian targets. + (md_number_to_chars): Add support for little endian targets. + +2000-02-10 Timothy Wall + + * read.c (read_a_source_file): If TC_START_LABEL_WITHOUT_COLON is + defined, use it to verify the symbol just read should be a label. + +2000-02-10 Timothy Wall + + * app.c (do_scrub_chars): Handle "||" for parallel instructions + when DOUBLEBAR_PARALLEL is defined. Avoid stripping whitespace + around colons when KEEP_WHITE_AROUND_COLON is defined. + * doc/internals.texi (CPU backend): Document DOUBLEBAR_PARALLEL + and KEEP_WHITE_AROUND_COLON. + +2000-02-08 Timothy Wall + + * read.c (s_rept): Call do_repeat, which abstracts the repeat + logic. + (do_repeat): New. Abstract repeat logic so that a "break" can be + implemented. + (end_repeat): New. Provide support for a "break" out of the + repeat loop. + * read.h: Add prototypes for new functions. + +2000-02-08 Timothy Wall + + * doc/internals.texi: Document NUMBERS_WITH_SUFFIX macro. + * as.h: Provide a default NUMBERS_WITH_SUFFIX definition (zero). + * expr.c: Handle numbers with suffixes if NUMBERS_WITH_SUFFIX is + non-zero. + +2000-02-08 Timothy Wall + + * read.c: Added elseif to directives table. + * read.h: Added prototype for s_elseif. + * doc/as.texinfo: Added description for elseif. + * cond.c (s_elseif): New function + +2000-02-04 Timothy Wall + + * listing.c (print_lines): Remove conditionals causing bug in + listings. + +2000-02-03 Timothy Wall + + * as.h: Define OCTETS_PER_BYTE and OCTETS_PER_BYTE_POWER + default values. + * frags.c (frag_new): Calculate fr_fix in octets + (frag_now_fix) Return offset as target address offset (bytes). + (frag_now_fix_octets) New - Return offset in octets (8-bit + quantities). + * frags.h: Added prototype for frag_now_fix_octets(). + Distinguish between octets and bytes in field descriptions. + * listing.c (calc_hex): Account for octets vs bytes when + printing addresses/offsets. + (print_lines) Ditto. Also, if LISTING_WORD_SIZE is not 1, and + target is little-endian, print the octets in a word in big-endian + order so that the display looks like a proper hexadecimal number, + instead of having the octets reversed. + * read.c (do_align): When recording alignment, alignment power + should be in terms of target bytes (minimum addressible unit) + instead of octets. + (do_org) Convert ORG target address (byte) argument into an + octet offset when generating a variable fragment. + * symbols.c (resolve_symbol_value): Symbol final value + converted to a target address offset (bytes) from its octet offset. + * config/obj-coff.c (coff_frob_symbol): Symbol target address + offset (bytes) is adjusted by the frag offset (octets) converted + to bytes. + (coff_frob_section) Section alignment power is in terms of bytes; + convert it to an octet alignment power when calculating size (and + size mask) in octets. Don't modify the section size in order to + "align" it for TI COFF, since that format has a different method + for storing alignment information. + +2000-02-01 Timothy Wall + + * stabs.c (generate_asm_file): Escape backslashes in stabs file + entries, matching the way GCC generates them. If not escaped, the + filename is encoded incorrectly. + +2000-01-31 Nick Clifton + * config/tc-arm.c (reg_table): Add support for ATPCS register + naming conventions. + +2000-01-31 Geoff Keating + + * config/obj-coff.h (OBJ_COPY_SYMBOL_ATTRIBUTES): Don't define if + already defined. + * config/tc-ppc.h [OBJ_XCOFF] (OBJ_COPY_SYMBOL_ATTRIBUTES): + New macro. + * config/tc-ppc.c (ppc_fix_adjustable): Don't look at the frag + of a symbol when we really care about its value. + +2000-01-19 Chandra Chavva + + * config/tc-mcore.c (md_assemble): Give warning message if + operands passes to instruction are more than the spec. + +2000-01-27 Thomas de Lellis + + * config/tc-arm.c (armadjust_symtab): If the assembler is in + Thumb mode but the label seen was not declared as '.thumb_func' + then set the ST_INFO type to STT_ARM_16BIT mode. This allows + correct disassembly of Thumb code bounded by non function labels. + +2000-01-27 Alan Modra + + * Makefile.am (MULTI_CFILES): Add config/e-i386aout.c + Add dependencies for e-i386aout.o. Fix 2 comment lines. + + * Makefile.in: Same here. + Update copyright. + + * configure.in: Set bfd_gas for i386-aout when primary target + is bfd. Handle i386aout emulation. Don't use te_file=multi, as + we may need the primary te_file. Remove incorrect comment. + + * configure: Regenerate. + + * config/e-i386aout.c: New file. + + * as.c (USE_EMULATIONS): Move to before print_version_id. + (struct emulation): Add i386aout. + (show_usage): Split text strings. Reformat -a text. Add --em + help. + Update copyright. + + * obj.h (struct format_ops): Add s_get_other and s_get_desc. + (aout_format_ops): New. + Update copyright. + + * read.c (s_lcomm_internal): Rewrite OBJ_AOUT,OBJ_BOUT + preprocessor conditional and add aout USE_EMULATIONS tests. + (read_a_source_file): Don't pass error strings to printf as + format arg. + Update copyright. + + * gasp.c (exp_get_abs): Don't pass error strings to printf as + format arg. + (do_data): Same here. + (process_file): And here. + Update copyright. + + * symbols.c (colon): Rewrite "already defined" fatal message + code for aout with USE_EMULATIONS. + Update copyright. + + * config/obj-aout.c (OBJ_HEADER): Define. + (obj_pseudo_table): Rename to aout_pseudo_table. Init all + fields of sentinel. + (obj_aout_frob_symbol): Expand S_GET_DESC, S_GET_TYPE, + S_GET_OTHER, S_SET_TYPE macros since we don't need obj-multi + forms here. + (obj_aout_type): Expand S_SET_OTHER here too. + (obj_read_begin_hook): Remove. + (aout_pop_insert): New. + (obj_aout_s_get_other): New. + (obj_aout_s_get_desc): New. + (aout_format_ops): New. + Update copyright. + + * config/obj-aout.h (obj_pop_insert): Define so non-multi usage + gets aout_pseudo_table. + (aout_pseudo_table): Declare. + (obj_read_begin_hook): Define. + Update copyright. + + * config/obj-coff.c (obj_pseudo_table): Rename to + coff_pseudo_table. + (coff_pop_insert): Use coff_pseudo_table. + (coff_sec_sym_ok_for_reloc): Remove. + (coff_format_ops): Add 0 entries for s_get_size, s_set_size, + and comment all zero entries and remove #if 0 code. + Update copyright. + + * config/obj-coff.h (obj_pop_insert): Define. + (coff_pseudo_table): Declare. + Update copyright. + + * config/obj-ecoff.c (ecoff_format_ops): Add 0 entries for + s_get_size, s_set_size. Comment all zero entries. + Update copyright. + + * config/obj-elf.c (elf_s_get_other): New function. + (obj_read_begin_hook): Rename to elf_obj_read_begin_hook. + (obj_symbol_new_hook): Rename to elf_obj_symbol_new_hook. + (elf_format_ops): Add elf_s_get_other, 0 s_get_size entry, and + comment. + (obj_elf_parse_section_letters): Don't pass error strings to + printf as format arg. + Update copyright. + + * config/obj-elf.h (ECOFF_DEBUGGING): Define when + OBJ_MAYBE_ECOFF. + (elf_s_get_other): Declare. + (S_GET_OTHER) Define as elf_s_get_other if not already + defined. + (S_SET_OTHER): Only define when not already defined. + (elf_obj_read_begin_hook): Declare. + (obj_read_begin_hook): Define. + (elf_obj_symbol_new_hook): Declare. + (obj_symbol_new_hook): Define. + Update copyright. + + * config/obj-multi.h: Add copyright header and protect against + multiple inclusion. Add * to all function pointers. + (OBJ_HEADER): If defined, include it rather than other defines + in this file. + (obj_frob_file_after_relocs): Test for NULL. + (obj_symbol_new_hook): Here too. + (obj_sec_sym_ok_for_reloc): And here. + (S_GET_OTHER): Define. + (S_GET_DESC): Define. + (ECOFF_DEBUGGING): Remove as it's done in obj-elf.h + (OBJ_MAYBE_ELF): Update comment. + + * config/tc-i386.c (i386_immediate): Add OBJ_MAYBE_AOUT to + OBJ_AOUT preprocessor conditional and handle emulation by + testing OUTPUT_FLAVOR. + (i386_displacement): Here too. + (md_section_align): Similarly here. + (i386_target_format): Conditionally compile when more than one + of OBJ_MAYBE_{ELF,COFF,AOUT} defined. Add aout case. + (i386_immediate): Fix error message for aout BFD_ASSMBLER. + (i386_displacement): Here too. + Update copyright. + + * config/tc-i386.h (AOUT_TARGET_FORMAT): Define for each TE_*. + Define TARGET_FORMAT for aout only when not multi. + Update copyright. + + * config/te-multi.h: Delete file as it's identical to te-generic.h + +2000-01-15 Alan Modra + + * config/tc-i386.h (DWORD_MNEM_SUFFIX): Delete. + * config/tc-i386.c (DWORD_MNEM_SUFFIX): Rename all occurrences to + LONG_MNEM_SUFFIX. + + * config/tc-i386.h (INTEL_DWORD_MNEM_SUFFIX): Rename to + DWORD_MNEM_SUFFIX. + * config/tc-i386.c (INTEL_DWORD_MNEM_SUFFIX): Here too. Fix some + comments. + +2000-01-13 Clinton Popetz + + * config/tc-mips.c (mips_do_align): New function. + * config/tc-mips.h (md_do_align): Define. + +2000-01-10 Philip Blundell + + * doc/c-arm.texi (ARM Options): Fix typo. + (ARM-Chars): Correct description of `#'. Mention that `;' is a + line separator for Linux. + * doc/as.texinfo (Comments): Mention the ARM. + +2000-01-10 Philip Blundell + + * configure.in (arm*-*-conix*): New target. + (arm*-*-linux-gnu*): Match instead of arm-*-linux* and + armv*-*-linux-gnu. + * configure: Regenerate. + +2000-01-03 Martin v. Loewis + + * config/obj-elf.c (elf_pseudo_table): Define visibility pseudos. + (obj_elf_visibility): New function. + + * doc/as.texinfo (Visibility): New node: document visibility + pseudo ops. + +1999-12-27 Alan Modra + + * config/tc-i386.c (MATCH): Relax JumpAbsolute check. Emit a + warning for absolute jump/call without `*' in non-intel mode. No + need to set i.types[0] JumpAbsolute in intel mode. + +1999-12-22 Philip Blundell + + * config/tc-arm.c (arm_s_text): If OBJ_ELF, call the appropriate + hook function when changing sections. + (arm_s_data): Likewise. + +1999-12-14 Nick Clifton + + * config/tc-arm.c (md_parse_option): Add support for -marm720 + command line switch. + +Tue Nov 30 22:59:00 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-mn10300.c (md_pseudo_table): Add ".am33" pseudo-op. + (r_registers, xr_registers): Define. + (r_register_name, xr_register_name): New functions. + (md_assemble): Handle new am33 operand types and instruction + formats. + (mn10300_insert_operand, check_operand): Likewise. + +1999-11-29 Nick Clifton + + * config/tc-arm.c (thumb_mode): Turn into a tristate variable. + (s_force_thumb): Set thumb_mode to 2. + (md_assemble): Do not complain about thumb instructions on a + non-thumb target if thumb_mode is set to 2. + +1999-11-28 Michael Meissner + + * config/tc-alpha.c (toplevel): Include struc-symbol.h. + (alpha_macro_arg): Add MACRO_{LITERAL,BASE,BYTOFF,JSR} cases. + (O_...): Add new machine dependent expressions if we are handling + explicit relocations. + (alpha_reloc_op): New static table holding the explicit relocation + information. + (alpha_literal_hash): New static to hold the hash table for + explicit relocations. + (alpha_macros): Add support for explicit relocations. + (md_begin): If explicit relocations, initialize hash table. + (md_assemble): Don't print a second error if tokenize_arguments + already printed an error message. + (md_apply_fix): Add support for explicit relocations. + (alpha_force_relocation): Ditto. + (alpha_fix_adjustable): Ditto. + (alpha_adjust_symtab): New function to support explicit + relocations. + (alpha_adjust_symtab_relocs): Ditto. + (debug_exp): Debug stub compiled if DEBUG_ALPHA is defined. + (tokenize_arguments): Add debug code if DEBUG_ALPHA is defined. + Add support for explicit relocations. Return -2 if an error + message was already printed. + (find_macro_match): Add support for explicit relocations. Comment + each of the cases. + (emit_insn): Add support for explicit relocations. + (assemble_tokens): Ditto. + (emit_ldgp): Ditto. + (load_expression): Ditto. + (emit_lda): Ditto. + (emit_ldah): Ditto. + (emit_ir_load): Ditto. + (emit_loadstore): Ditto. + (emit_ldXu): Ditto. + (emit_ldil): Ditto. + (emit_sextX): Ditto. + (emit_division): Ditto. + (emit_jsrjmp): Ditto. + (emit_retjcr): Ditto. + + * config/tc-alpha.h (RELOC_OP_P): Enable explicit relocations if + ELF object format. + (tc_adjust_symtab): If explicit relocations, call the function + alpha_adjust_symtab. + (TC_FIX_TYPE): Add fields to be able to move explicit lituse + relocations next to the literal relocation they reference. + (TC_INIT_FIX_DATA): Initialize the new fields. + (TC_FIX_DATA_PRINT): Print the new fields if DEBUG5 is defined. + +Wed Nov 24 20:27:58 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Handle PA2.0 unit completers. Handle + 'B' operand for PA2.0 bb instruction. + +1999-11-18 Nick Clifton + + * config/tc-mcore.h (TC_FORCE_RELOCATION): Define for Mcore-pe + target. + + * config/tc-mcore.c (tc_gen_reloc): Support generation of RVA + relocs. + (mcore_force_relocation): Force relocations to be generated for + RVA relocs. + +1999-11-16 Alan Modra + + * config/tc-i386.c (i386_immediate): Disallow O_big immediates. + (i386_displacement): Disallow O_big displacements. + +Mon Nov 15 20:12:43 1999 Donald Lindsay + + * config/tc-arm.c (do_mia,do_mar,do_mra,do_pld,do_ldrl,do_co_reg): Small + improvements in error checking. + (md_assemble): Support for unconditional ARM instructions. + (md_parse_option): Support for -m[arm]v5e flag. + +1999-11-12 Nick Clifton + + * macro.c (buffer_and_nest): Do not check beyond the end of the + buffer. + +1999-11-11 Nick Clifton + + * macro.c (buffer_and_nest): Look for seperator after TO and + FROM tokens. + +1999-11-08 Andrew Haley + + * app.c (do_scrub_chars): When in State 10, treat backslash + characters in the same way as as symbol characters. + +1999-11-07 Richard Henderson + + * config/tc-alpha.c (alpha_align): Check, don't assert, that + the previous label was in the current section before playing + with auto-alignment. + +1999-11-06 Nick Clifton + + * config/tc-v850.c (v850_force_relocation): Force relocation + for weak symbols. + (v850_pcrel_from_selection): Do not compute a pcrel offset if + the symbol is weak. + +1999-11-05 Michael Meissner + + * expr.h (operatorT): Increase machine dependent operators to 16. + * expr.c (op_rank): Ditto. + +1999-11-03 Ian Lance Taylor + + * read.c (pseudo_set): Reject attempts to set the value of a + section symbol. + + * config/obj-elf.c (obj_elf_ident): Call md_flush_pending_output + if it is defined. + + * config/obj-elf.c (elf_set_index): Add ATTRIBUTE_UNUSED. + + * config/obj-elf.c (elf_frob_file_after_relocs): Don't pass NULL + to bfd_set_section_contents. + +1999-11-03 Nick Clifton + + * config/tc-mcore.h (TARGET_BYTES_BIG_ENDIAN): Change to false. + +1999-11-01 Gavin Romig-Koch + + * config/tc-mips.c (macro_build): Use OPCODE_IS_MEMBER. + (mips_ip): Use OPCODE_IS_MEMBER. + +Wed Oct 27 16:50:44 1999 Don Lindsay + + * config/tc-arm.c (reg_required_here): Improve comments. + + * config/tc-arm.c (thumb_opcode): Add "variants" field. + (tinsns): Initialize variants field. + + * config/tc-arm.c (bad_args, bad_pc): Renamed to BAD_ARGS and + BAD_PC respectively. + +1999-10-27 Scott Bambrough + + * config/tc-arm.c (reloc_map[]): Fix compiler warning. + * config/tc-arm.h: Fix compile time warnings. + +Mon Oct 18 18:11:10 MDT 1999 Diego Novillo + + * tc_d10v.c (find_opcode): Allow ATSIGN to match expressions of the + form @abs16, @(abs16) and @(abs16 + imm). + +1999-10-21 Gavin Romig-Koch + + * config/tc-mips.c (ISA_HAS_COPROC_DELAYS) : New. + (ISA_HAS_64_BIT_REGS) New. + (gpr_interlocks,md_begin,reg_needs_delay,append_insn, + mips_emit_delays,macro_build,load_register,load_addresss, + macro,macro2,mips_ip,s_cprestore,s_cpadd): Simplify + and/or use new ISA_xxx macros in expressions involving + ISA, particularly mips_opts.isa. + +1999-10-18 Michael Meissner + + * expr.h (operatorT): Add machine dependent operators md1..md8. + (expressionS): Make X_op 8 bits instead of 7. Add a X_md field + for the machine dependent operators to use. + + * expr.c (op_rank): Add machine dependent operators. + + * config/tc-alpha.c (O_pregister): Define as a machine dependent + operator. + (O_cpregister): Ditto. + (md_begin): Change X_op test that field is wide enough to use + O_max instead of O_alpha_max. + (cpu_types): Fill in missing initializer. + (alpha_num_macros): Make unsigned. + (md_assemble): Make opnamelen be size_t. + (md_apply_fix): Cast alpha_num_operands to int before testing. + (alpha_force_relocation): Ditto. + (alpha_fix_adjustable): Ditto. + (alpha_fix_adjustable): Mark unused arguments ATTRIBUTE_UNUSED. + (tc_gen_reloc): Ditto. + (tc_get_register): Ditto. + (emit_ldgp): Ditto. + (emit_lda): Ditto. + (emit_ldah): Ditto. + (emit_ldil): Ditto. + (s_alpha_ent): Ditto. + (s_alpha_end): Ditto. + (s_alpha_frame): Ditto. + (s_alpha_prologue): Ditto. + (s_alpha_file): Ditto. + (s_alpha_gprel32): Ditto. + (s_alpha_proc): Ditto. + (s_alpha_set): Ditto. + (s_alpha_base): Ditto. + (s_alpha_align): Ditto. + (s_alpha_arch): Ditto. + (alpha_align): Ditto. + (assemble_insn): Suppress unused variable warning. + (emit_insn): Ditto. + (assemble_insn): Don't assume X_op and X_unsigned are in a given + order in the structure. + (s_alpha_coff_wrapper): Avoid int/unsigned comparison. + +Sun Oct 17 17:15:58 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (md_apply_fix): Make "fmt" an int. + +1999-10-12 Alan Modra + + * config/tc-i386.c (i386_index_check): Correct #endif location. + +Mon Oct 11 14:02:40 1999 Geoffrey Keating + + * as.c (show_usage): Document new options. + (parse_args): Add --no-warn, --warn, --fatal-warnings, + which become 'W', OPTION_WARN, and OPTION_WARN_FATAL. + (parse_args): Parse the new options. + (main): If there were warnings, and --fatal-warnings + was specified, print an error. + * as.h: New variable, flag_fatal_warnings, for new option. + +Sun Oct 10 01:47:23 1999 Jerry Quinn + + * config/tc-hppa.c (pa_ip): Add new codes 'cc', 'cd', 'cC', 'co', + '@'. Change autoincrement completers to fall through to cache control + completers. + + * config/tc-hppa.c (pa_ip): Remove unused args. Add code to '?W' + arg. + (pa_parse_addb_64_cmpltr): New function. + + * config/tc-hppa.c (pa_ip): Change error message. + (pa_ip,pa_parse_cmpb_64_cmpltr,pa_parse_cmpib_64_cmpltr) Fix '?N' and + '?Q' args to allow falling through. + + * configtc-hppa.c (pa_ip): Implement conditional codes "?N", "?Q". + Remove unused conditional codes. + (pa_parse_cmpb_64_cmpltr,pa_parse_cmpib_64_cmpltr): New. + +Thu Oct 7 00:23:53 MDT 1999 Diego Novillo + + * config/tc-d30v.c (CHAR_BIT): Define. + (check_range): Fix bit operations to support integers bigger than + 32 bits. + +Thu Oct 7 00:11:50 MDT 1999 Diego Novillo + + * config/tc-d10v.c (check_range): Check range for RESTRICTED_NUM3 + operands. + +Mon Oct 4 17:24:23 1999 Nick Clifton + Doug Evans + + Add support for m32rx. + * config/tc-m32r.c (enable_m32rx): New static global. + (enable_special,warn_explicit_parallel_conflicts,optimize): Ditto. + (allow_m32rx): New function. + (M32R_SHORTOPTS): Add `O'. + (md_longopts): Add --m32rx plus several warning options. + (md_parse_option): Handle new options. + (md_show_usage): Print them. + (md_begin): Enable m32rx. + (OPERAND_IS_COND_BIT): New macro. + (first_writes_to_seconds_operands): New function. + (writes_to_pc,can_make_parallel,make_parallel): New functions. + (target_make_parallel,assemble_two_insns): New functions. + (md_assemble): Recognize "insn1 -> insn2" and "insn1 || insn2". + If optimizing and m32rx, try to make consecutive insns parallel. + +Tue Sep 28 14:06:44 1999 Geoffrey Keating + + * config/tc-mips.c (nopic_need_relax): Allow for the + .sdata.foo sections generated by -fdata-sections, + and for the .gnu.linkonce.s sections generated by C++. + +Thu Sep 23 07:13:45 1999 Jerry Quinn + + * config/tc-hppa.c (pa_ip): Replace 'B', 'M', 'l' and 'g' handling + with cleaner code using completer prefixes. Add 'Y'. + + * config/tc-hppa.c (pa_ip): Add parens to silence compiler. + +Wed Sep 22 09:37:19 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Avoid ANSI specific initialization. + (pa_ip, case 'm'): Failure to get a CBIT specifier just means the + insn does not match and we should try the next insn in the table. + +1999-09-22 Nick Clifton + + * config/tc-arm.c (MULTI_SET_PSR): Rename to LDM_TYPE_2_OR_3. + +Mon Sep 20 04:01:41 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Fix thinkos in recent cleanup + of PA2.0 support. + +1999-09-19 Alexandre Oliva + + * config/tc-i386.c (md_shortopts): Check OBJ_MAYBE_ELF as well as + OBJ_ELF. If ELF, add "sq". + (md_parse_option): If ELF, ignore -s and -q. + (md_show_usage): Mention ELF options. + +Sun Sep 19 10:43:31 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Handle 'J', 'K' and 'cc' + operands. + + * config/tc-hppa.c (pa_ip); Handle "fe", and 'cJ'. + + * config/tc-hppa.c (pa_ip): Handle 'd', '#' and 'cq'. + + * config/tc-hppa.c (struct pa_it): New field "trunc". + (pa_ip): Hadnle 'h', 'm', '=', '{', and '_' operands. + (pa_parse_ftest_gfx_completer): New function + (pa_parse_fp_cnv_format): New function. + + * config/tc-hppa.c (pa_ip): Handle 'X' operand. + (md_apply_fix): Handle 22bit pc-rel branches. + + * config/tc-hppa.c (pa_ip): Handle 'B' operand. + + * config/tc-hppa.c (pa_ip): Handle 'L' and 'M' operands. + + * config/tc-hppa.c (pa_ip): Handle 'l' operand. + + * config/tc-hppa.c (pa_ip): Handle 'g' operand. + +at Sep 18 12:13:28 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (md_assemble): Fix dwarf2 line handling. + (pa_ip): Handle 'fX'. + +Sat Sep 18 12:13:28 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (md_assemble): Fix dwarf2 line handling. + (pa_ip): Handle 'fX'. + +Fri Sep 17 11:57:34 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_build_unwind_subspace): Do not build + unwinds unless the function is in the text space. + (pa_type_args): Set BSF_FUNCTION for an exproted data symbol. + +Wed Sep 15 05:14:32 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Move dwarf2 stuff from here. + (md_assemble): To here. Tweak address generation. + + * config/tc-hppa.c: Include dwarf2dbg.h if OBJ_ELF. Declare + debug_line. + (md_pseudo_table): Add .file and .line pseudo-ops for OBJ_ELF. + (md_assemble): Call dwarf2_where for OBJ_ELF. + (pa_ip): Call dwarf2_gen_line_info for OBJ_ELF. + (pa_end_of_source): New function. + * tc-hppa.h (md_end): Define for OBJ_ELF. + +1999-09-14 Michael Meissner + + * configure.in (Canonicalization of target names): Remove adding + ${CONFIG_SHELL} in front of $ac_config_sub, since autoconfig 2.14 + generates $ac_config_sub with a ${CONFIG_SHELL} already. + * configure: Regenerate. + +1999-09-14 Donn Terry + + * config/te-interix.h (GLOBAL_OFFSET_TABLE_NAME): Define. + +1999-09-13 Alan Modra + + * config/tc-i386.c (md_assemble): Handle "jmp/call constant" as a + pc-relative jmp/call to an absolute symbol. + (md_apply_fix3): When OBJ_ELF, don't add the values in twice for + absolute section symbols. + + * config/tc-i386.c (md_assemble): Correct frag_var size. Tidy + jump handling code and comments. + +1999-09-12 Ian Lance Taylor + + * config/tc-i386.c (md_apply_fix3): Add horrible adjustments to + the value if TE_PE and a global defined symbol. + +1999-09-11 Ian Lance Taylor + + * write.c (dump_section_relocs): Call print_symbol_value_1 to + print the symbol, rather than printing it here. + +1999-09-11 Donn Terry + + * config/tc-i386.c (tc_i386_fix_adjustable): Don't adjust + BFD_RELOC_RVA relocations. + + * config/tc-i386.c (md_undefined_symbol): Compare the name against + the macro GLOBAL_OFFSET_TABLE_NAME, rather than assuming that it + starts with "_G". + + * write.c (write_relocs): Call SET_SECTION_RELOCS if it is + defined. + * config/obj-coff.h (SET_SECTION_RELOCS): Define. + * doc/internals.texi (Object format backend): Document + SET_SECTION_RELOCS. + + * config/tc-i386.c (tc_i386_fix_adjustable): Don't adjust + relocations against global symbols if TE_PE. + + * config/obj-coff.c (obj_coff_ident): Add BFD_ASSEMBLER version. + (obj_pseudo_table): Always handle ".ident" with obj-coff_ident. + + * config/obj-coff.c (coff_frob_symbol): Prohibit weak common + symbols. + + * config/obj-coff.c (obj_coff_endef): Don't merge labels, or + symbols which do not have a constant value, or tags with + non-tags. Remove the symbol from the list before adding it at the + end. + + * config/obj-coff.c (obj_coff_endef) [BFD_ASSEMBLER]: Handle .ef + C_FCN symbol differently if TE_PE. + (obj_coff_line) [BFD_ASSEMBLER]: Always use the line number which + appears in the pseudo-op, rather coff_line_base which is only set + for a .bf symbol. + + * config/obj-coff.c (obj_coff_loc): New static function. + (obj_pseudo_table): Add "loc". + + * config/obj-coff.c (add_lineno): Check that the line number is + positive. + + * config/atof-ieee.c (atof_ieee): Change what_kind to int. + * config/atof-vax.c (flonum_gen2vax): Change format_letter to + int. + (md_atof): Return NULL rather than 0. + * config/tc-i386.c (md_atof): Change type to int. + * expr.c (expr): Change first parameter to int. + * config/obj-coff.c: Add declarations for static functions. + (coff_frob_symbol): Use SYM_AUXENT. + * config/tc-i386.h (flag_16bit_code): Don't declare. + + * config/obj-coff.c (obj_coff_section): Default to setting + SEC_LOAD. Don't set SEC_DATA for 'w' modifier. + + * write.c (adjust_reloc_syms): Print adjusted fixup. + + * expr.c (integer_constant): Correct too_many_digits calculation + in base 10 case. + +1999-09-09 Andreas Schwab + + * doc/c-arm.texi: Fix arguments of @var to not contain + punctuation. + +1999-09-08 Philip Blundell + + * config/tc-arm.c (s_thumb_set): Only support interworking for ELF + and COFF targets. + (md_parse_option): Only support -k flag for ELF and COFF targets. + +Tue Sep 7 13:28:59 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Put strict register checks before + call to pa_parse_number. + + * config/tc-hppa.c (pa_ip): Support 'Z' argument. + +1999-09-06 Ian Lance Taylor + + * config/obj-coff.c: Add ATTRIBUTE_UNUSED as needed for + BFD_ASSEMBLER code. + +1999-09-06 Donn Terry + + * as.c (perform_an_assembly_pass): Set SEC_DATA for data_section. + +Mon Sep 6 04:26:56 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Get strict/non-strict mode from the + candidate instruction. Require registers for register arguments + when in strict mode. Require assemble-time constants for + constants when in strict mode. + (pa_get_absolute_expression): Require a constant when in strict + mode. + +1999-09-06 Nick Clifton + + * config/tc-m32r.c (md_longopts): Fix value for -Wnuh. + +1999-09-04 Steve Chamberlain + + * config/tc-pj.c: New file, supports picoJava in ELF. + * config/tc-pj.h: Ditto. + * configure.in (pjl*, pj*): New targets. + * Makefile.am: Rebuild dependencies. + (CPU_TYPES): Add pj. + (TARGET_CPU_CFILES): Add config/tc-pj.c. + (TARGET_CPU_HFILES): Add config/tc-pj.h. + * doc/c-pj.texi: New file. + * doc/as.texinfo: Add some PJ specifics. + * doc/all.texi: Add PJ to the list of all architectures, sort them + all alphabetically. + * doc/Makefile.in (CPU_DOCS): Add c-pj.texi. + * configure, Makefile.in, doc/Makefile.in: Rebuild. + +1999-09-02 Alan Modra + + * config/obj-multi.h: Include obj-elf.h if OBJ_MAYBE_ELF. Reformat. + (obj_frob_file): Test for null pointer. + (OBJ_COPY_SYMBOL_ATTRIBUTES): Here too. + (OBJ_PROCESS_STAB): And here. + (elf_obj_sy): Remove + + * config/obj-elf.h: #ifndef everything defined in obj-multi.h, + except OBJ_PROCESS_STAB, which we #undef for ecoff. + (elf_obj_sy): Remove #ifndef OBJ_SYMFIELD_TYPE. + + * config/obj-coff.c (no_func): Remove. + (coff_format_ops): Change occurrences of no_func to 0, as we test + for 0 in obj-multi.h. + + * configure.in: Enable bfd for i386-coff when primary target is + bfd. Enable i386 elf,coff emulation support. Don't set + USE_EMULATIONS=1 or te_file=multi unless there is more than one + emulation to support. + *configure: Regenerate. + +1999-09-02 Nick Clifton + + * config/tc-mcore.c (mcore_s_section): Do not dump literals if a + .section .line directive is encountered. + +1999-09-01 Nick Clifton + + * config/tc-arm.c (md_section_align): Do not align sections in ELF + format. + + * as.c (show_usage): Add --gdwarf2 to list of options displayed. + * as.texinfo: Document --gdwarf2 command line option. + Add additional documentation of ARM command line switches. + +1999-08-30 Alan Modra + + * config/tc-i386.c (i386_intel_memory_operand): Combine + i386_is_reg and parse_register calls. Remove END_STRING_AND_SAVE + and RESTORE_END_STRING around parse_register calls. + (i386_operand): Here too. + (i386_is_reg): Remove. + (parse_register): Move as_bad calls from within this function to + callers. + +1999-08-29 Alan Modra + + Based on a patch from H.J. Lu + * config/tc-i386.c (parse_register): Handle FP regs specially. + (md_begin): Remove '(' and ')' from register_chars. + +1999-08-29 Doug Evans + + * config/tc-m32r.c (md_parse_option): Delete unrecognized option + error message (done elsewhere). + +Sat Aug 28 01:23:11 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Do not allow '*' in 32bit completers. + +Sat Aug 28 00:26:26 1999 Jerry Quinn + + * config/tc-hppa.c (pa_ip): Replace 'f' by 'v'. Prefix float register + args by 'f'. + + * config/tc-hppa.c (pa_ip): Add args q, %, and |. + + * config/tc-hppa.c (pa_ip): Absorb white space in instructions + between args. + Add new completers. Fix bug in 64 bit condition handling. + + * config/tc-hppa.c (pa_ip): Add completer codes 'a', 'ch', 'cH', + 'cS', and 'c*'. + + * config/tc-hppa.c (pa_ip): Place completers behind prefix 'c'. + + * config/tc-hppa.c (pa_ip): Add cases for '.', '~'. '$'. and '!' + + * config/tc-hppa.c (pa_ip): Add case for 'I'. + +1999-08-27 Jim Wilson + + * dwarf2dbg.c (MAX_SPECIAL_ADDR_DELTA): Correct typo in comment. + (struct ls): Add frag field. Initialize it to zero. + (out_end_sequence): New local text_frag. Set it while in text section. + Replace address check with frag check. Set ls.frag to text_frag if + out_set_addr called. + (dwarf2_gen_line_info): Add explanatory comment. New local saved_frag. + Set it before switching sections. Replace address check with frag + check. Set ls.frag to saved_frag if out_set_addr called. + +1999-08-26 David Mosberger + + * dwarf2dbg.c (out_end_sequence): If address changed, directly + output "advance_pc" opcode instead of calling gen_addr_line(). + The latter has the undesired side-effect of creating a new row + in the debug line info matrix. + +1999-08-26 Jim Wilson + + * dwarf2dbg.c (out_end_sequence): Correct comments. Set last to + ls.last_filename if last is less than zero. Set ls.last_filename + when allocating new entry. + (dwarf2_gen_line_info): Save seg and subseg info before subseg_new + call. + +1999-08-20 Alan Modra + + * config/tc-i386.c (i386_index_check): Fix the displacement size + when INFER_ADDR_PREFIX. + +1999-08-18 Nick Clifton + + * config/tc-arm.c (md_apply_fix3): If an offset is invalid, + display its value. + +1999-08-17 Ian Lance Taylor + + * config/tc-ppc.c (md_assemble): Trim @ha constant to 16 bits, to + handle 0xffffNNNN constants correctly. + +1999-08-16 Nick Clifton + + * config/tc-arm.c (do_ldst): Look for register conflicts on stores + as well as loads. + +1999-08-13 Nick Clifton + + * config/tc-arm.c (validate_offset_imm): Work on unsigned values. + (md_apply_fix3): Always pass positive values to + validate_offset_imm. + +1999-08-12 Nick Clifton + + * config/tc-arm.c (skip_whitespace): New macro. + Formatting tidy ups. + + (md_apply_fix3): Store relocation offset in addend for ELF based + relocs. + (arm_force_relocation): Always generate relocs for Thumb function + calls. + +1999-08-11 Alan Modra + + * config/tc-i386.c (md_assemble): Remove dead code. intel_syntax + LONG_DOUBLE_MNEM_SUFFIX floating point is done in opcode/i386.h + +Tue Aug 10 12:58:31 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_build_unwind_subspace): Use sane section + flags for the unwind subspace. + + * config/tc-hppa.c (UNWIND_SECTION_NAME): Define for ELF. + (pa_build_unwind_subspace): Remove #if 0 wrapper. Select a + suitable relocation based on the size of the target's pointer. + Always Use subsegment zero for the unwinders. + (pa_level): Handle "2.0w". + +Mon Aug 9 20:02:22 1998 J"orn Rennecke + + * config/tc-d30v.c (write_2_short): Don't group repeat instructions + with the following instruction unless this was specified. + +1999-08-09 Ian Lance Taylor + + * config/tc-i386.h (SUB_SEGMENT_ALIGN): If TE_GO32, return 4 for + certain sections, to match BFD changes. + +1999-08-08 Mumit Khan + + * Makefile.am (noinst_SCRIPTS): Change .gdbinit to $(GDBINIT). + (EXTRA_SCRIPTS): Define to keep automake happy. + * Makefile.in: Rebuild. + +1999-08-08 Ian Lance Taylor + + * Makefile.am: Rename .dep* files to DEP*. + (MKDEP): Rename from DEP. Change all uses. Use $${srcdir} rather + than $(srcdir). Rename TCDEP targets to DEPTC. Rename OBJDEP + targets to DEPOBJ. + * Makefile.in: Rebuild. + +1999-08-08 Jakub Jelinek + + * config/tc-sparc.c (sparc_ip): Allow assembly of %lo()+%reg. + +1999-08-08 Ian Lance Taylor + + * Makefile.am: Change all uses of itbl-test-ops to itbl-tops to + avoid problems on DOS filesystems. + * Makefile.in: Rebuild. + + * doc/as.texinfo (Section): Document 's' flag for COFF version. + +1999-08-08 Mumit Khan + + * config/obj-coff.c (obj_coff_section): Handle 's' (shared) + section flag. + +1999-08-08 Ian Lance Taylor + + * configure.in: Define and substitute GDBINIT. Change AC_OUTPUT + line to create ${GDBINIT} rather than .gdbinit. + * configure, Makefile.in, doc/Makefile.in: Rebuild. + +Fri Aug 6 12:12:44 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip, case '?'): Add missing break. + +Fri Aug 6 09:46:35 1999 Jerry Quinn + + * config/tc-hppa.c (pa_ip): Add 64 bit condition completers. + +1999-08-06 Jakub Jelinek + + * config/tc-sparc.h (tc_fix_adjustable): Fix check for PIC local + non-adjustable symbols. + +Thu Aug 5 16:52:51 1999 Jerry Quinn + + * config/tc-hppa.c (pa_ip): Change condition args to have '?' prefix. + +Thu Aug 5 23:05:56 1999 J"orn Rennecke + + * config/tc-sh.c (md_assemble): Call as_bad when there are excess + operands. + +1999-08-05 Donn Terry + + * config/te-interix.h: New file. + * configure.in (i386-*-interix*): New target. + * configure: Rebuild. + +Wed Aug 4 13:12:17 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_chk_field_selector): Allow 3 byte + selectors for ELF too. + (selector_table): Add "ltp" and "rtp" selectors. + +1999-08-04 Alan Modra + + * config/tc-i386.c (i386_operand): No need to change + operand_string pointer in segment reg case before goto + do_memory_reference. Initialise displacement_string_start and + displacement_string_end after do_memory_reference label. + (i386_index_check): Add operand_string param, and print error + message on failure here. + (i386_intel_memory_operand): Instead of here. + (i386_operand): And here. + (INFER_ADDR_PREFIX): Enable. + + * doc/c-i386.texi (i386-16bit): Document .code16gcc. + + * config/tc-i386.h (DefaultSize): Define. Renumber following + opcode_modifier defines. + + From Etienne Lorrain + * config/tc-i386.c (stackop_size): New variable. + (set_16bit_code_flag): Clear it here. + (set_16bit_gcc_code_flag): New function. + (md_pseudo_table): Add "code16gcc" entry. + (md_assemble): Set i.suffix for insns with DefaultSize modifier. + +1999-08-03 Ian Lance Taylor + + * config/obj-coff.c (coff_frob_symbol): Always update set_end with + next_set_end even if the end symbol is being discarded. + + * gasp.c: Add ATTRIBUTE_UNUSED as needed for non-BFD_ASSEMBLER. + * output-file.c, symbols.c, config/tc-i386.c: Likewise. + * config/obj-coff.c: Likewise. + (seg_info_type): Remove. + (seg_info_off_by_4): Change to array of segT. + (s_get_segment): Adjust accordingly. + (obj_pseudo_table): Fully initialize sentinel entry. + + * config/tc-mips.c (append_insn): Correct INSN_SYNC test. From + Ralf Baechle . + +1999-08-03 Etienne Lorrain + + * config/tc-i386.c (f16_3): New. Fixes 16 bit 3 byte nop. + +1999-08-03 Alan Modra + + * config/tc-i386.c: Indentation and white space changes. + (i386_index_check): New function. Add INFER_ADDR_PREFIX code, but + don't enable it by default. + (i386_intel_operand): Remove redundant prototype. + Move check on number of memory operands, and i.mem_operands++ + (i386_intel_memory_operand): To here. + Remove i386_immediate code from here. Remove special case code + for input and output using (%dx). Remove base/index checks and + call i386_index_check instead. Save initial operand_string + argument for error message. + (i386_operand): Remove redundant prototype. Move base/index + checks to i386_index_check. + (i386_displacement): Move intel mode check for non-zero + i.disp_operand + (i386_intel_memory_operand): To here. + +1999-07-30 Jakub Jelinek + + * config/tc-sparc.c (md_longopts): Add --no-undeclared-regs option. + (sparc_ip): Warn if %g2 or %g3 register is used and not covered + by .register pseudo-op if -64 and --no-undeclared-regs. + (s_register, sparc_adjust_symtab): New functions. + * config/tc-sparc.h (tc_adjust_symtab, sparc_adjust_symtab): + Declare sparc_adjust_symtab as tc_adjust_symtab. + * doc/c-sparc.texi: Add description of #ignore special literal + for .register pseudo-op. + +1999-07-30 Catherine Moore + + * config/tc-arm.c (tc_gen_reloc): Record the vtable entry in + the relocation's section offset. + +1999-07-29 Alan Modra + + * write.c (fixup_segment): Fix generic error check overflow test. + + * config/tc-i386.c (pe): Change %d to %ld, %x to %lx, and cast + X_add_number to long. + +Wed Jul 28 02:04:24 1999 "Jerry Quinn" + + * config/tc-hppa.c (pa_ip): Add 'J' and 'K' code + processing. + +1999-07-27 Ian Lance Taylor + + * config/tc-sparc.h (tc_fix_adjustable): Don't adjust GOT, PLT, or + VTABLE relocations. + +1999-07-21 Mark Elbrecht + + * config/te-go32.h (COFF_LONG_SECTION_NAMES): Define. + + * configure.bat: Remove; obsolete. + * config/go32.cfg: Likewise. + +1999-07-21 Brad M. Garcia + + * configure.in (i386-*-vxworks*): New target. + * configure: Rebuild. + +1999-07-16 Jakub Jelinek + + * doc/c-sparc.texi: Document .register and .nword pseudo-ops. + +1999-07-16 Jakub Jelinek + + * config/tc-sparc.c (sparc_ip): Allow OLO10 relocations + on -64 and not pic. + (output_insn): Put OLO10's secondary addend into tc_fix_data. + (md_apply_fix3): Handle BFD_RELOC_SPARC_OLO10. + (tc_gen_reloc): Return two relocs for OLO10, LO10 and SPARC13. + * config/tc-sparc.h (RELOC_EXPANSION_POSSIBLE, + MAX_RELOC_EXPANSION): Define. + (TC_FIX_TYPE, TC_INIT_FIX_DATA, TC_FIX_DATA_PRINT): Likewise. + +1999-07-16 Alan Modra + + * config/tc-i386.c (intel_float_operand): Add prototype, make static. + (md_assemble): Localize *exp variable to if (fake_zero_displacement) + block. Print a warning if an 8-bit or 16-bit constant + displacement or immediate is truncated on output. + (i386_immediate): Ensure Imm16 is always legal for a 16-bit mode + immediate. + (i386_operand): Disallow immediate jump absolute operand. + +1999-07-15 Ian Lance Taylor + + * configure.in: Bump version number to 2.9.5. + * configure: Rebuild. + + * dwarf2dbg.c (dwarf2_gen_line_info): Don't assume that long long + or %llx work. + +Thu Jul 15 02:45:30 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (md_pseudo_table): Add ".dword" pseudo-op. + (cons_fix_new_hppa): Derive size of fixup from size of the object. + +1999-07-14 Philip Blundell + + * symbols.c (dollar_label_name): Prepend LOCAL_LABEL_PREFIX if it + is defined. + * config/tc-arm.h (LOCAL_LABEL_PREFIX): Define to '.' for ELF. + + * config/tc-arm.c (md_begin): Set F_SOFTFLOAT in the output file + if -mno-fpu was given. + (tc_gen_reloc): Fix typo. Delete bogus code related to GOTPC + relocs. + (cons_fix_new_arm): Remove misleading comments. + +1999-07-14 Ian Lance Taylor + + * write.c (cvt_frag_to_fill): Use frag file and line in rs_org + error message. + (relax_segment): Likewise. After giving a rs_org error, convert + the frag to rs_align to avoid cascading errors. + +1999-07-12 Andreas Schwab + + * config/tc-m68k.c: Add some ATTRIBUTE_UNUSED. + +1999-07-11 Ian Lance Taylor + + * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSED + as appropriate. Fill in structure initializations. Add variable + initializations. Add casts. + * dwarf2dbg.c (print_stats): Change i to size_t. + * listing.c (listing_listing): Change list_line to unsigned int. + +1999-07-10 Ian Lance Taylor + + * config/tc-ppc.h (tc_fix_adjustable) [OBJ_ELF]: Call S_IS_LOCAL + rather than checking for \001 and \002 in symbol name. + * config/tc-sparc.h (tc_fix_adjustable) [OBJ_ELF]: Likewise. + +Thu Jul 8 12:32:23 1999 John David Anglin + + * configure.in (hppa*-linux-gnu*): New target. + * configure: Rebuilt. + +1999-07-08 Nick Clifton + + * doc/c-arm.texi (ARM Directives): Document .thumb_set directive. + +1999-07-07 Nick Clifton + + * config/tc-v850.c (v850_comm): Use symbol_get_obj() rather than + accessing symbolP directly. + +Tue Jul 6 10:41:42 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.h (tc_frob_symbol): Always punt "$global$" symbol + for ELF. + +1999-07-05 Nick Clifton + + * config/tc-arm.c (ARM_EXT_V5): Define. + (ARM_ARCH_V5, ARM_ARCH_V5T): Define. + (md_begin): Detect ARM v5 architectures. + (md_parse_option): Accept arm v5 specification. + (md_show_usage): Documment -marmv5 switch. + + * doc/c-arm.texi: Document -marmv5 command line option. + + * config/tc-arm.c (do_adrl): New function. Implement ADRL pseudo + op. + (validate_immediate_twopart): New function. Determine if a + constant can be computed by two ADD instructions. + (output_inst): Remove its command line parameter - it was never + used. + (md_apply_fix3): Support BFD_RELOC_ARM_ADRL_IMMEDIATE, used to + implememt the ADRL pseudo op. + (tc_gen_reloc): Generate a suitable error message if an ADRL + instruction tries to generate a real reloc. + + * doc/c-arm.texi: Document NOP, ADR and ADRL pseudo ops. + +Thu Jul 1 15:33:10 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (pa_ip): Convert the opcode and all completers + into lower case. + +1999-06-27 H.J. Lu + + * subsegs.c (subseg_text_p): Use 1/0 instead of true/false for + non BFD_ASSEMBLER case. + +1999-06-26 Mumit Khan + + * config/obj-coff.c (obj_coff_section): Mark writable sections as + data. + +1999-06-26 David Mosberger + + * dwarf2dbg.c (dwarf2_gen_line_info): Don't call + out_end_sequence() when the address decreases due to a new frag. + (gen_dir_list): Set ls.file[i].dir to j + 1 (not j) because file + numbering starts with 1. + +1999-06-23 Nick Clifton + + * config/tc-mcore.c (md_pseudo_table): Add .comm for ELF and allow + .section for COFF. + (mcore_s_text): Call obj_elf_text for ELF target. + (mcore_s_data): Call obj_elf_data for ELF target. + (mcore_s_section): No longer ELF specific. Call obj_coff_section + for COFF target. + (mcore_s_bss): New function: Dump literal table before changing + sections. + (mcore_s_comm): New function: Dump literal table before changing + sections. + + * config/obj-elf.c (obj_elf_common, obj_elf_data, obj_elf_text): + No longer static functions. + * config/obj-elf.h (obj_elf_common, obj_elf_data, obj_elf_text): + Provide prototypes for these functions. + +1999-06-22 Ian Lance Taylor + + * subsegs.c (subseg_text_p): Rewrite non BFD_ASSEMBLER case to use + a list of names, to try obj_segment_name, and to try abbreviated + names when using COFF without long section names. + + * config/tc-alpha.c: More use of symbol accessor functions. + * config/tc-arc.c: Likewise. + * config/tc-d30v.c: Likewise. + * config/tc-fr30.c: Likewise. + * config/tc-i860.c: Likewise. + * config/tc-m88k.c: Likewise. + * config/tc-mcore.c: Likewise. + * config/tc-ns32k.c: Likewise. + * config/tc-sparc.c: Likewise. + * config/tc-v850.c: Likewise. + + * config/tc-arc.c (get_arc_exp_reloc_type): Change uses of + sy_value with appropriate accessor functions. + * config/tc-arm.c (md_apply_fix3): Likewise. + * config/tc-d10v.c (AT_WORD_P): Likewise. + * config/tc-v850.c (reg_name_search): Likewise. + + * config/obj-ecoff.c (obj_ecoff_set_ext): Change uses of bsym to + use symbol_get_bfdsym instead. + * config/tc-ppc.c (md_assemble): Likewise. + * config/tc-v850.c (v850_comm): Likewise. + +1999-06-22 Jonathan Larmour + + * config/tc-arc.c (tc_gen_reloc): Use symbol_get_bfdsym to get at + the symbol, rather than accessing the bsym member. + * config/tc-d10v.c (tc_gen_reloc): Likewise. + * config/tc-d30v.c (tc_gen_reloc): Likewise. + * config/tc-mcore.c (tc_gen_reloc): Likewise. + * config/tc-mn10200.c (tc_gen_reloc): Likewise. + * config/tc-mn10300.c (tc_gen_reloc): Likewise. + * config/tc-ns32k.c (tc_gen_reloc): Likewise. + * config/tc-tic30.c (tc_gen_reloc): Likewise. + * config/tc-v850.c (tc_gen_reloc): Likewise. + +Mon Jun 21 16:45:19 1999 Jeffrey A Law (law@cygnus.com) + + * tc-hppa.c (elf_hppa_reloc_type): Renamed from elf32_hppa_reloc_type. + (hppa_gen_reloc_type): Conditionalize on BFD64. + (tc_gen_reloc): Re-enable ELF relocations. + * tc-hppa.h (TARGET_FORMAT): Handle elf64-hppa format. + +1999-06-21 Ian Lance Taylor + + * config/tc-arm.c (ldst_extend): Add parentheses to avoid + warning. + (do_ldst): Move assignment out of if condition. + (md_apply_fix3): Add casts to avoid printf format warnings. Add + parentheses to avoid warning. + +1999-06-21 Nick Clifton + + * config/tc-arm.c (arm_adjust_symtab): Use symbol_get_bfdsym() + macro to get at the BFD symbol associated with a GAS symbol. + +1999-06-19 Ian Lance Taylor + + * config/tc-ppc.c: Update for symbol handling changes. + * config/obj-coff.c: Likewise. + +Fri Jun 18 14:34:18 1999 Jeffrey A Law (law@cygnus.com) + + * tc-hppa.c: General cleanups of ELF support. No more spaces + and subspaces for ELF. + (GDB_DEBUG_SPACE_NAME): Delete definition for ELF. + (GDB_STRINGS_SUBSPACE_NAME): Likewise. + (GDB_SYMBOLS_SUBSPACE_NAME): Likewise + (UNWIND_SECTION_NAME): Likewise. + (space/subspace related structures): Conditionalize definitions + on OBJ_SOM. + (space/subspace directives and support routines): Conditionalize + definitions and references/uses on OBJ_SOM. + (label_symbol_struct): For ELF, track the symbol's segment. For + SOM track its space. + (pa_define_label, pa_undefine_label, pa_get_label): Corresponding + changes. + (USE_ALIASES): Kill for both SOM & ELF. + (pa_def_subspaces, pa_def_spaces): Corresponding changes. + (pa_space, pa_subspace): Corresponding changes. + (pa_spaces_begin): Corresponding chagnes. + (md_begin): Do not muck around with space/subspace stuff for + OBJ_ELF. + (md_apply_fix): Temporarily disable argument relocation stuff + for OBJ_ELF. + (tc_gen_reloc): Temporarily disable relocation generation for + OBJ_ELF + (pa_build_unwind_subspace): Similarly. + +1999-06-16 Nick Clifton + + * config/tc-arm.c (thumb_set): New pseudo op. + (text, data, section): Override these pseudo ops with ARM + specific versions. + (s_thumb_set): New function: Perform the same as a .set pseudo + op, but also mark the alias'ed symbol as being a Thumb + function. + (arm_s_text): New function: Perform the same as the .text + pseudo op, but dump the literal pool before changing + sections. + (arm_s_data): New function: Perform the same as the .data + pseudo op, but dump the literal pool before changing + sections. + (arm_s_section): New function: Perform the same as the + .section pseudo op, but dump the literal pool before changing + sections. + (arm_cleanup): Do not reset the current section before dumping + the literal pool. + +1999-06-17 Nick Clifton + + * config/tc-m32r.c (md_longopts): Fix OPTION_WARN_UNMATCHED and + OPTION_NO_WARN_UNMATCHED entries. + (md_parse_option): Generate a warning message if an unrecognised + option is encountered. + + * config/tc-d10v.c (do_not_ignore_hash): New variable. + (get_operands): When parsing an expression after an '@' symbol + has been detected, do not ignore '#' symbols. + (md_operand): Only ignore '#' symbols if do_not_ignore_hash is + false. + +1999-06-13 Ian Lance Taylor + + From K. Richard Pixley : + * configure.in (ppc-*-vxworks*): New target. + * configure: Rebuild. + +1999-06-12 Philip Blundell + + * config/tc-arm.c (tc_gen_reloc): Fix handling of GOTPC relocs. + +1999-06-13 Ian Lance Taylor + + * write.c (adjust_reloc_syms): Rather than never reducing reloc + which refer to symbols in linkonce sections, permit reducing the + relocs if the symbol is local. + +1999-06-12 Ian Lance Taylor + + * subsegs.c (subseg_text_p): New function. + * as.h (subseg_text_p): Declare. + * read.c (do_align): Use subseg_text_p to set the default fill. + * write.c (subsegs_finish): Likewise. + * config/obj-coff.c (write_object_file): Likewise. + * config/tc-i386.h (md_maybe_text): Don't define. + (md_do_align): Use subseg_text_p to set the default fill. + * config/tc-m32r.c (m32r_do_align): Likewise. + * config/tc-sh.c (sh_do_align): Likewise. + * config/tc-sparc.h (md_do_align): Likewise. + +1999-06-12 David O'Brien + + * configure.in: (i[3456]86-*-freebsd*): Now defaults to ELF. + * configure: Rebuild. + +1999-06-12 Ian Lance Taylor + + * dwarf2dbg.c: Include elf/dwarf2.h with "", not <>. + * Makefile.am: Rebuild dependencies. + * Makefile.in: Rebuild. + + * config/tc-i386.c (i386_immediate): Remove unused label + seg_unimplemented. + + * struc-symbol.h: Put local_symbol code in ifdef BFD_ASSEMBLER. + * symbols.c: Likewise. + * config/obj-aout.c (obj_crawl_symbol_chain): Refer directly to + sy_next field when taking address, rather than symbol_next. + + * dwarf2dbg.c: Change bfd_vma to addressT and bfd_signed_vma to + offsetT. + (out_set_addr): Don't use BYTES_PER_ADDRESS. Instead, get the + value from the output file architecture. + (dwarf2_gen_line_info): Ifdef BFD_ASSEMBLER specific code. + * dwarf2dbg.h: Change bfd_vma to addressT. + +1999-06-11 Ian Lance Taylor + + * dwarf2dbg.h: Use PARAMS in function declarations. + +1999-06-11 Martin Dorey + + * write.c (fixup_segment): Don't add symbol value for i960 ELF. + * config/tc-i960.c (s_leafproc): Don't call tc_set_bal_of_cal if + OBJ_ELF. + (md_apply_fix): Simplify BFD_ASSEMBLER handling. + +1999-06-11 Ian Lance Taylor + + * config/tc-i386.c (md_apply_fix3): Add default case to switch. + + * config/tc-sparc.c (md_pseudo_table): Remove pushsection and + popsection. + + * config/tc-sparc.c (sparc_ip): Add default case to reloc switch. + + * read.c (read_a_source_file): Only declare inescape if + QUOTES_IN_INSN. + + * itbl-ops.c (itbl_disassemble): Change sprintf format strings to + match parameters. + (find_entry_byval): Add parens to avoid warning. + + * as.c: If HAVE_ITBL_CPU, include "itbl-ops.h". + + * symbols.c (resolve_symbol_value): Don't permit subtraction of + undefined symbols. + +1999-06-10 Jakub Jelinek + + * config/tc-sparc.c (sparc_ip): Don't use side-effect expression + with isoctal. + + * config/tc-sparc.c (synthetize_setuw, synthetize_setsw, + synthetize_setx): New functions. + (md_assemble): Broken the special cases into the above + functions. Make compiler happy if sizeof(bfd_vma)==4. + Fix sethi generated from set/setuw. If instructions have a relloc, + always clear the fields to be relocated in the opcode. + (sparc_ip): Remove special_case global variable. + +1999-06-10 Ian Lance Taylor + + Based on patches from John W. Woznack : + * itbl-ops.c (itbl_get_reg_val): Add pval parameter. Return + indication of success rather than a value. + (itbl_get_val): Likewise. + (itbl_get_field): Use strcspn. Change delimiters to include + parens. + * itbl-ops.h (itbl_get_reg_val): Update declaration. + (itbl_get_val): Likewise. + * config/tc-mips.c (mips_ip): Update call to itbl_get_reg_val. + + * symbols.c (copy_symbol_attributes): Convert local symbols to + regular symbols. + +1999-06-10 Nick Clifton + + * config/tc-arm.c (md_parse_option): Add support for ARM920 and + ARM920t. + +1999-06-07 Jakub Jelinek + + * config/tc-sparc.c (md_assemble): Fix up setx, support setsw. + Optimize set if sizeof(bfd_vma) == 64. + (sparc_ip): Fix sethi - without %hi() it should generate + R_SPARC_22 reloc, not R_SPARC_HI22. + (tc_gen_reloc): Handle BFD_RELOC_SPARC22. + +1999-06-07 Jakub Jelinek + + * config/tc-sparc.c (md_begin): Handle native wordsize aliases. + (s_ncons): New function. + (native_op_table): New table. + (sparc_ip): Be more strict on %hi() etc.; prepare assembler for + R_SPARC_OLO10 handling. + +Mon Jun 7 10:22:16 1999 Richard Henderson + + * expr.h (struct expressionS): Revert last change; widen X_op. + * config/tc-alpha.c (md_begin): Check the field is wide enough. + +Mon Jun 7 11:25:16 1999 Andreas Schwab + + * Makefile.am (TARGET_CPU_CFILES): Add config/tc-fr30.c. + (TARGET_CPU_HFILES): Add config/tc-fr30.h. + (TARG_ENV_HFILES): Add config/te-epoc-pe.h. + * Makefile.in: Regenerated. + + * config/obj-elf.c (obj_elf_common): In MRI mode if called as + `common' pass on to s_mri_common. + (elf_pseudo_table): Pass 1 to obj_elf_common for `common'. + +1999-06-06 Richard Henderson + + * config/obj-elf.c (obj_elf_section): Don't free the return + value of demand_copy_C_string. + +1999-06-05 Richard Henderson + + * dwarf2dbg.c (dwarf2_gen_line_info): Mirror the section symbol + creation logic from obj_elf_create_section. + + * config/obj-elf.c (elf_pseudo_tab): Add pushsection/popsection. + (section_stack): New. + (special_sections): Make const. + (obj_elf_section): Gut and rewrite parsing. + (obj_elf_change_section): New function broken out of obj_elf_section. + (obj_elf_parse_section_letters): Likewise. + (obj_elf_section_word): Likewise. + (obj_elf_section_type): Likewise. + (obj_elf_previous): Treat as a toggle. + (obj_elf_popsection): New. + * config/tc-ppc.c (ppc_section_word): Take str+len not ptr_str. + (ppc_section_type): Likewise. + * config/tc-ppc.h: Likewise. + + * expr.h (struct expressionS): Don't make X_op a bitfield. + * config/tc-alpha.c: Update for symbol handling changes. + (md_apply_fix) [case GPREL]: Use now_seg instead of absolute_section. + (load_expression, emit_ir_load, emit_loadstore, emit_jsrjmp): Likewise. + +1999-06-05 Richard Henderson + + * dwarf2dbg.c (*): Convert to K&R + prototypes. + (dwarf2_gen_line_info): Kill unused variables. + (dwarf2_finish): Likewise. + (dwarf2_where): Likewise. + (dwarf2_directive_file): If we've only got a string, + hand off to s_app_file. + * ecoff.c: Move the include of ecoff.h. + * symbols.h (S_IS_FUNCTION): Prototype. + + * read.c (LEX_HASH): Supply a default. + (lex_type): Use it. + (s_globl): Update `c' after skipping whitespace. + * read.h (LEX_END_NAME, is_name_ender): New. + * expr.c (get_symbol_end): Respect it. + +1999-06-04 Mark Klein + + * config/tc-hppa.c (md_begin): Convert local symbol dummy_symbol + to real if OBJ_SOM + (tc_gen_reloc): Still need bfd_abs_symbol in some relocs. + + * config/tc-hppa.c: Update for symbol handling changes. + +1999-06-03 Ian Lance Taylor + + * cgen.c: Update for symbol handling changes. + * config/tc-m32r.c: Likewise. + + * config/tc-hppa.h: Update for symbol handling changes. + * config/tc-hppa.c: Likewise. + + * config/tc-arm.h: Update for symbol handling changes. + * config/tc-arm.c: Likewise. + (symbol_make_empty): Remove. Just use symbol_create. + + * symbols.c (symbol_set_tc): Correct name. + + * Makefile.am: Rebuild dependencies. + ($(OBJS)): Don't depend upon struc-symbol.h. + (.dep1, .tcdep, .objdep): Create itbl-parse.h. + * dep-in.sed: Don't remove struc-symbol.h. + * Makefile.in: Rebuild. + + * doc/internals.texi (Symbols): Describe changes in symbol + handling. + +1999-06-03 Richard Henderson + + * dwarf2dbg.c (dwarf2_gen_line_info): Use section_symbol + instead of doing the work by hand. + +1999-06-03 David Mosberger + + * dwarf2dbg.c (INITIAL_STATE): New macro encapsulating initial + state of line state-machine. + (struct ls): Collect DWARF2 line state-machine state in new member + SM. Add member EMPTY_SEQUENCE to keep track if a code sequence + resulted in any DWARF2 directives. + (reset_state_machine): New function. + (out_end_sequence): Ditto. + (dwarf2_gen_line_info): When switching sections or switching to a + lower text address, call out_end_sequence() first to terminate the + previous code sequence as code sequences MUST have monotonically + increasing addresses. + (dwarf2_finish): Call out_end_sequence() instead of open coding it. + +1999-06-03 David Mosberger + + * as.c (parse_args): Add option -gdwarf2 to allow requesting + DWARF2 debug info (line information only, at this point). + * as.h: Update comment about supported debug formats. + * dwarf2dbg.c, dwarf2dbg.h: New files. + * Makefile.am (GAS_CFILES, HFILES, GENERIC_OBJS): Add them. + + * expr.c (operand): Don't use [ for parens if we want an index op. + (op_encoding): Switch [ into O_index, if desired. + (op_rank): Renumber with O_index on bottom. + (expr): If O_index, match closing bracket. + * expr.h (O_index): New. + + * read.c (read_a_source_file): Conditionally allow matched " + in lines passed to md_assemble. + + * config/obj-elf.c (elf_pseudo_table): Add `common'. + +1999-06-03 Ian Lance Taylor + + Add support for storing local symbols in a small structure to save + memory when assembling large files. + * as.h: Don't include struc-symbol.h. + (symbolS): Add typedef. + * symbols.c: Include struc-symbol.h. + (local_hash): New static variable. + (save_symbol_name): New static function, from symbol_create. + (symbol_create): Call save_symbol_name. + (local_symbol_count): New static variable. + (local_symbol_conversion_count): Likewise. + (LOCAL_SYMBOL_CHECK): Define. + (local_symbol_make): New static function. + (local_symbol_convert): New static function. + (colon): Handle local symbols. Create local symbol for local + label name. + (symbol_table_insert): Handle local symbols. + (symbol_find_or_make): Create local symbol for local label name. + (symbol_find_base): Check for local symbol. + (symbol_append, symbol_insert): Check for local symbols. + (symbol_clear_list_pointers, symbol_remove): Likewise. + (verify_symbol_chain): Likewise. + (copy_symbol_attributes): Likewise. + (resolve_symbol_value): Handle local symbols. + (resolve_local_symbol): New static function. + (resolve_local_symbol_values): New function. + (S_GET_VALUE, S_SET_VALUE): Handle local symbols. + (S_IS_FUNCTION, S_IS_EXTERNAL, S_IS_WEAK, S_IS_COMMON): Likewise. + (S_IS_DEFINED, S_IS_DEBUG, S_IS_LOCAL, S_GET_NAME): Likewise. + (S_GET_SEGMENT, S_SET_SEGMENT, S_SET_EXTERNAL): Likewise. + (S_CLEAR_EXTERNAL, S_SET_WEAK, S_SET_NAME): Likewise. + (symbol_previous, symbol_next): New functions. + (symbol_get_value_expression): Likewise. + (symbol_set_value_expression): Likewise. + (symbol_set_frag, symbol_get_frag): Likewise. + (symbol_mark_used, symbol_clear_used, symbol_used_p): Likewise. + (symbol_mark_used_in_reloc): Likewise. + (symbol_clear_used_in_reloc, symbol_used_in_reloc_p): Likewise. + (symbol_mark_mri_common, symbol_clear_mri_common): Likewise. + (symbol_mri_common_p): Likewise. + (symbol_mark_written, symbol_clear_written): Likewise. + (symbol_written_p): Likewise. + (symbol_mark_resolved, symbol_resolved_p): Likewise. + (symbol_section_p, symbol_equated_p): Likewise. + (symbol_constant_p): Likewise. + (symbol_get_bfdsym, symbol_set_bfdsym): Likewise. + (symbol_get_obj, symbol_set_obj): Likewise. + (symbol_get_tc, symbol_set_tc): Likewise. + (symbol_begin): Initialize local_hash. + (print_symbol_value_1): Handle local symbols. + (symbol_print_statistics): Print local symbol statistics. + * symbols.h: Include "struc-symbol.h" if not BFD_ASSEMBLER. + Declare new symbols.c functions. Move many declarations here from + struc-symbol.h. + (SYMBOLS_NEED_BACKPOINTERS): Define if needed. + * struc-symbol.h (SYMBOLS_NEED_BACKPOINTERS): Don't set. + (struct symbol): Move bsym to make it clearly the first field. + Remove TARGET_SYMBOL_FIELDS. + (symbolS): Don't typedef. + (struct broken_word): Remove. + (N_TYPE_seg, seg_N_TYPE): Move to symbol.h. + (SEGMENT_TO_SYMBOL_TYPE, N_REGISTER): Likewise. + (symbol_clear_list_pointers): Likewise. + (symbol_insert, symbol_remove): Likewise. + (symbol_previous, symbol_append): Likewise. + (verify_symbol_chain, verify_symbol_chain_2): Likewise. + (struct local_symbol): Define. + (local_symbol_converted_p, local_symbol_mark_converted): Define. + (local_symbol_resolved_p, local_symbol_mark_resolved): Define. + (local_symbol_get_frag, local_symbol_set_frag): Define. + (local_symbol_get_real_symbol): Define. + (local_symbol_set_real_symbol): Define. + Define. + * write.c (write_object_file): Call resolve_local_symbol_values. + * config/obj-ecoff.h (OBJ_SYMFIELD_TYPE): Define. + (TARGET_SYMBOL_FIELDS): Don't define. + * config/obj-elf.h (OBJ_SYMFIELD_TYPE): Add local field. If + ECOFF_DEBUGGING, add ECOFF fields. + (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. + * config/obj-multi.h (struct elf_obj_sy): Add local field. If + ECOFF_DEBUGGING, add ECOFF fields. + (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. + (ECOFF_DEBUG_TARGET_SYMBOL_FIELDS): Don't define. + * config/tc-mcore.h: Don't include struc-symbol.h. + (TARGET_SYMBOL_FIELDS): Don't define. + (struct mcore_tc_sy): Define. + (TC_SYMFIELD_TYPE): Define. + * Many files: Use symbolS instead of struct symbol. Use new + accessor functions rather than referring to symbolS fields + directly. + + * read.c (s_mri_common): Don't add in value of line_label. + + * config/tc-mips.c (md_apply_fix): Correct parenthesization when + checking for SEC_LINK_ONCE. + + * config/tc-sh.h (sh_fix_adjustable): Declare. + + * app.c (input_buffer): New static variable. + (app_push): Save saved_input in allocated buffer. + (app_pop): Restored saved_input. + (do_scrub_chars): Change get parameter to take char * and int as + arguments. Change GET macro to pass input_buffer to get + function. Don't save input into allocated buffer. + * as.h (do_scrub_chars): Update declaration. + * input-file.c (input_file_get): Change to take char * and int. + Read data into passed in buffer. Remove static buffer. + * read.c (scrub_from_string): Change to take char * and int. Copy + data into passed in buffer. + + * hash.h: Neaten. Declare hash_traverse. + * hash.c: Complete rewrite based on BFD hashing code. + * gasp.c (chunksize): New variable. + * macro.c (macro_expand_body): Call hash_jam with NULL rather than + hash_delete. + +1999-05-28 Nick Clifton + + * config/tc-arm.c (md_apply_fix3): Add pipeline offset into reloc + addend unless the target uses an old ABI. + +Mon May 24 13:36:55 1999 Doug Evans + + -Wchar-subscripts cleanup + * listing.c (listing_newline): Use unsigned char variable, so + calls to isascii,iscntrl are correct. + * atof-generic.c (atof_generic): Cast arg to isdigit, et. al. with + (unsigned char). + * ecoff.c (ecoff_directive_ent,ecoff_stab): Ditto. + * config/obj-elf.c (obj_elf_vtable_inherit): Ditto. + * config/tc-mips.c (mips_ip,mips16_ip): Ditto. + (my_getSmallExpression,get_number,s_mips_ent): Ditto. + +1999-05-28 Torbjorn Granlund + + * config/tc-m68k.c (m68k_ip): Check for disallowed index register + width for Coldfire. + (arch_coldfire_p): New #define. + (m68k_ip, m68k_init_after_args): Use arch_coldfire_p. + +1999-05-28 Linus Nordberg + + * config/tc-m68k.c (install_operand): Add places `n', `o'. + + * config/tc-m68k.c (m68k_ip): Add formats `E', `G', `H'. + (install_operand): Add place `N'. + (init_table): Add registers ACC, MACSR, MASK. + + * config/m68k-parse.h (m68k_register): Add ACC, MACSR, MASK. + + * config/tc-m68k.c: Change mcf5200 --> mcf. + (archs): Add mcf5206e, mcf5307. + (m68k_ip): Add format `u'. + (install_operand): Add place `m', `M', `h'. + (init_table): Add upper/lower registers. + + * config/m68k-parse.h (m68k_register): Add upper/lower registers. + +1999-05-28 Martin Dorey + + * config/tc-i960.c: Several minor changes to add ELF and + BFD_ASSEMBLER support. + * config/tc-i960.h: Likewise. + * configure.in (i960-*-elf*): New target. + * aclocal.m4, configure: Rebuild. + +1999-05-25 Alan Modra + + * config/tc-i386.c (md_apply_fix3): Only do 1999-05-17 fx_pcrel + reloc changes when defined(BFD_ASSEMBLER). + +1999-05-17 Alan Modra + + * config/tc-i386.c (tc_gen_reloc): Remove F and MAP macros. + + * write.c (write_print_statistics): Output to file, not stderr. + + * expr.c (generic_bignum_to_int32,64): Prototype. + + * read.c (s_lcomm_internal, sizeof_sleb128, sizeof_uleb128, + output_sleb128, output_uleb128, output_big_sleb128, + output_big_uleb128, output_big_leb128): Prototype. + (output_big_sleb128, output_big_uleb128): Make inline. + (output_big_leb128): Remove inline + + From Maciej W. Rozycki + * config/tc-i386.c (md_apply_fix3): Convert BFD_RELOC_16 with + fx_pcrel set to BFD_RELOC_16_PCREL. Similarly for BFD_RELOC_8. + Handle BFD_RELOC_16_PCREL and BFD_RELOC_8_PCREL. Return changed + value for correct overflow check in write.c:fixup_segment. + * write.c (fixup_segment): Move bitfield overflow checks to after + the md_apply_fix call. + * config/obj-coff.c (fixup_segment): Likewise. + * doc/internals.texi (CPU backend): Mention md_apply_fix modifying + valueT *val argument. + +Fri May 14 10:52:13 1999 Andreas Schwab + + * config/atof-ieee.c (gen_to_words): Correctly round a + denormalized number. Fix off-by-one in range checking for + exponent in a denormal. + +1999-05-10 Nick Clifton + + * config/tc-mcore.c (parse_reg): Accept 'sp' as a valid register + name. + +Thu May 13 09:46:59 1999 Joel Sherrill (joel@OARcorp.com) + + * configure.in (i386-*-rtemself*, sh-*-rtemself*): New targets. + +1999-05-12 Alan Modra + + * config/tc-i386.h (InvMem): New flag. Add to AnyMem. + (ReverseRegRegmem): Remove. + (ImmExt): New flag. Renumber some of the opcode_modifier bits. + * config/tc-i386.c (md_assemble): Test for PIII SIMD and AMD + 3DNow! via ImmExt opcode_modifier. Remove ReverseRegRegmem + kludge. + + From Doug Ledford + * config/tc-i386.h (RegXMM): New for P/III. + * config/tc-i386.c: Add support for P/III. + +Sat May 8 23:28:50 1999 Richard Henderson + + * config/tc-ppc.c (md_parse_option): Recognize -mppc64bridge. + (md_begin): Allow ppc32 insns in ppc64bridge mode. + (ppc_insert_operand): Accept SIGNOPT in ppc64 mode. + +Thu May 6 23:13:39 1999 Richard Henderson + + * config/tc-i386.c (i386_immediate): Skip whitespace before + complaining about junk after expression. + (i386_displacement): Likewise. + +Thu May 6 19:50:14 1999 Richard Henderson + + * symbols.c (symbol_find_base): Use memcpy instead of strcpy. + Don't copy before downcaseing. + +1999-05-05 Catherine Moore + + * tc-m68k.c: Include elf/m68k.h. + (m68k_elf_final_processing): New routine. + * tc-m68k.h (elf_tc_final_processing m68k_elf_final_processing): + Define. + +Mon May 3 10:26:03 1999 Jeffrey A Law (law@cygnus.com) + + * config/tc-hppa.c (md_apply_fix): Handle 22 bit fmt insn like a + 17 bit fmt insn. + 1999-04-30 Nick Clifton * config/tc-mcore.c (mcore_s_section): Dump literals before diff --git a/gas/Makefile.am b/gas/Makefile.am index 688f21c..a7ccf21 100644 --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -12,7 +12,7 @@ tooldir = $(exec_prefix)/$(target_alias) YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L../bison/bison ; else echo bison -y ; fi` LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi` -DEP = $(srcdir)/../mkdep +MKDEP = $${srcdir}/../mkdep TARG_CPU = @target_cpu_type@ TARG_CPU_C = $(srcdir)/config/tc-@target_cpu_type@.c @@ -44,6 +44,7 @@ CPU_TYPES = \ h8300 \ h8500 \ hppa \ + i370 \ i386 \ i860 \ i960 \ @@ -55,6 +56,7 @@ CPU_TYPES = \ mn10200 \ mn10300 \ ns32k \ + pj \ ppc \ sh \ sparc \ @@ -134,6 +136,7 @@ GAS_CFILES = \ bignum-copy.c \ cond.c \ depend.c \ + dwarf2dbg.c \ ecoff.c \ ehopt.c \ expr.c \ @@ -164,6 +167,7 @@ HFILES = \ bignum.h \ bit_fix.h \ cgen.h \ + dwarf2dbg.h \ ecoff.h \ emul-target.h \ emul.h \ @@ -194,9 +198,11 @@ TARGET_CPU_CFILES = \ config/tc-arm.c \ config/tc-d10v.c \ config/tc-d30v.c \ + config/tc-fr30.c \ config/tc-h8300.c \ config/tc-h8500.c \ config/tc-hppa.c \ + config/tc-i370.c \ config/tc-i386.c \ config/tc-i860.c \ config/tc-i960.c \ @@ -208,6 +214,7 @@ TARGET_CPU_CFILES = \ config/tc-mn10200.c \ config/tc-mn10300.c \ config/tc-ns32k.c \ + config/tc-pj.c \ config/tc-ppc.c \ config/tc-sh.c \ config/tc-sparc.c \ @@ -226,9 +233,11 @@ TARGET_CPU_HFILES = \ config/tc-arm.h \ config/tc-d10v.h \ config/tc-d30v.h \ + config/tc-fr30.h \ config/tc-h8300.h \ config/tc-h8500.h \ config/tc-hppa.h \ + config/tc-i370.h \ config/tc-i386.h \ config/tc-i860.h \ config/tc-i960.h \ @@ -240,6 +249,7 @@ TARGET_CPU_HFILES = \ config/tc-mn10200.h \ config/tc-mn10300.h \ config/tc-ns32k.h \ + config/tc-pj.h \ config/tc-ppc.h \ config/tc-sh.h \ config/tc-sparc.h \ @@ -286,6 +296,7 @@ TARG_ENV_HFILES = \ config/te-delt88.h \ config/te-dpx2.h \ config/te-dynix.h \ + config/te-epoc-pe.h \ config/te-generic.h \ config/te-go32.h \ config/te-hp300.h \ @@ -313,6 +324,7 @@ TARG_ENV_HFILES = \ # Multi files in config MULTI_CFILES = \ + config/e-i386aout.c \ config/e-i386coff.c \ config/e-i386elf.c \ config/e-mipsecoff.c \ @@ -331,6 +343,7 @@ GENERIC_OBJS = \ bignum-copy.o \ cond.o \ depend.o \ + dwarf2dbg.o \ ehopt.o \ expr.o \ flonum-konst.o \ @@ -363,7 +376,8 @@ po/POTFILES.in: @MAINT@ Makefile && mv tmp $(srcdir)/po/POTFILES.in noinst_PROGRAMS = as-new gasp-new -noinst_SCRIPTS = .gdbinit +noinst_SCRIPTS = $(GDBINIT) +EXTRA_SCRIPTS = .gdbinit $(srcdir)/make-gas.com: stamp-mk.com stamp-mk.com: vmsconf.sh Makefile @@ -416,7 +430,7 @@ as_new_DEPENDENCIES = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) \ # Stuff that every object file depends upon. If anything is removed # from this list, remove it from dep-in.sed as well. $(OBJS): config.h as.h $(TARG_ENV_H) $(OBJ_FORMAT_H) $(TARG_CPU_H) flonum.h \ - expr.h struc-symbol.h write.h frags.h hash.h read.h symbols.h tc.h \ + expr.h write.h frags.h hash.h read.h symbols.h tc.h \ obj.h listing.h bignum.h bit_fix.h $(INCDIR)/libiberty.h asintl.h gasp_new_SOURCES = gasp.c macro.c sb.c hash.c @@ -498,6 +512,8 @@ e-mipself.o : $(srcdir)/config/e-mipself.c $(COMPILE) -c $(srcdir)/config/e-mipself.c e-mipsecoff.o : $(srcdir)/config/e-mipsecoff.c $(COMPILE) -c $(srcdir)/config/e-mipsecoff.c +e-i386aout.o: $(srcdir)/config/e-i386aout.c + $(COMPILE) -c $(srcdir)/config/e-i386aout.c e-i386coff.o: $(srcdir)/config/e-i386coff.c $(COMPILE) -c $(srcdir)/config/e-i386coff.c e-i386elf.o: $(srcdir)/config/e-i386elf.c @@ -551,10 +567,10 @@ itbl-parse.c itbl-parse.h: $(srcdir)/itbl-parse.y EXTRA_PROGRAMS = itbl-test itbl_test_SOURCES = itbl-parse.y itbl-lex.l -itbl_test_LDADD = itbl-test-ops.o itbl-test.o $(GASLIBS) @LEXLIB@ +itbl_test_LDADD = itbl-tops.o itbl-test.o $(GASLIBS) @LEXLIB@ -itbl-test-ops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h - $(COMPILE) -o itbl-test-ops.o -DSTAND_ALONE -c $(srcdir)/itbl-ops.c +itbl-tops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h + $(COMPILE) -o itbl-tops.o -DSTAND_ALONE -c $(srcdir)/itbl-ops.c itbl-test.o: $(srcdir)/testsuite/gas/all/itbl-test.c $(srcdir)/itbl-ops.h $(COMPILE) -c -DSTAND_ALONE $(srcdir)/testsuite/gas/all/itbl-test.c @@ -574,7 +590,7 @@ MOSTLYCLEANFILES = $(STAGESTUFF) core stamp-mk.com \ testsuite/*.o testsuite/*.out testsuite/gas.log testsuite/gas.sum \ testsuite/site.exp site.bak site.exp stage stage1 stage2 -CLEANFILES = dep.sed .tcdep .objdep .dep2 .dep1 .depa .dep .depdir +CLEANFILES = dep.sed DEPTC DEPOBJ DEP2 DEP1 DEPA DEP DEPDIR .PHONY: install-exec-local install-data-local .PHONY: install-exec-bindir install-exec-tooldir @@ -590,7 +606,7 @@ install-exec-bindir: $(noinst_PROGRAMS) else :; fi; \ done -install-exec-tooldir: $(noinst_PROGRAMS) +install-exec-tooldir: install-exec-bindir $(noinst_PROGRAMS) $(mkinstalldirs) $(tooldir)/bin n=`echo as | sed '$(transform)'`; \ if [ "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/as$(EXEEXT)" ]; then \ @@ -685,41 +701,42 @@ de-stage3: DEP_FILE_DEPS = $(CFILES) $(HFILES) $(TARGET_CPU_CFILES) \ $(TARGET_CPU_HFILES) $(OBJ_FORMAT_CFILES) $(OBJ_FORMAT_HFILES) -.dep: dep.sed $(DEP_FILE_DEPS) .tcdep .objdep .dep2 - rm -f .dep1 +DEP: dep.sed $(DEP_FILE_DEPS) DEPTC DEPOBJ DEP2 + rm -f DEP1 srcdir=`cd $(srcdir); pwd`; \ - $(MAKE) DEP=$(DEP) srcdir=$${srcdir} VPATH=$${srcdir} .dep1 - rm -rf .depdir - sed -f dep.sed < .dep1 > .depa - sed -f dep.sed < .tcdep >> .depa - sed -f dep.sed < .objdep >> .depa - sed -f dep.sed < .dep2 >> .depa - echo '$$(OBJS): $$(DEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '$$(TARG_CPU_O): $$(TCDEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '$$(OBJ_FORMAT_O): $$(OBJDEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '# IF YOU PUT ANYTHING HERE IT WILL GO AWAY' >> .depa - $(SHELL) $(srcdir)/../move-if-change .depa .dep + $(MAKE) MKDEP=$(MKDEP) srcdir=$${srcdir} VPATH=$${srcdir} DEP1 + rm -rf DEPDIR + sed -f dep.sed < DEP1 > DEPA + sed -f dep.sed < DEPTC >> DEPA + sed -f dep.sed < DEPOBJ >> DEPA + sed -f dep.sed < DEP2 >> DEPA + echo '$$(OBJS): $$(DEP_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '$$(TARG_CPU_O): $$(DEPTC_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '$$(OBJ_FORMAT_O): $$(DEPOBJ_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '# IF YOU PUT ANYTHING HERE IT WILL GO AWAY' >> DEPA + $(SHELL) $(srcdir)/../move-if-change DEPA DEP # This rule needs a mkdep that runs "gcc -MM". -.dep1: $(CFILES) $(MULTI_CFILES) - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEP1: $(CFILES) $(MULTI_CFILES) + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ echo '' > targ-cpu.h; \ echo '' > obj-format.h; \ echo '' > targ-env.h; \ echo '' > itbl-cpu.h; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) $? - sed -e '/IF YOU PUT ANYTHING/,$$d' < .depdir/.dep > .dep1 - rm -f .depdir/.dep + echo '' > itbl-parse.h; \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) $? + sed -e '/IF YOU PUT ANYTHING/,$$d' < DEPDIR/DEP > DEP1 + rm -f DEPDIR/DEP # Work out the special dependencies for the tc-*.c files. -.tcdep: $(TARGET_CPU_CFILES) - rm -f .tcdepa - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEPTC: $(TARGET_CPU_CFILES) + rm -f DEPTCA + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ @@ -728,44 +745,45 @@ DEP_FILE_DEPS = $(CFILES) $(HFILES) $(TARGET_CPU_CFILES) \ echo '#include "obj-'"$${o}"'.h"' > obj-format.h; \ echo '#include "te-generic.h"' > targ-env.h; \ echo '' > itbl-cpu.h; \ + echo '' > itbl-parse.h; \ echo '#include "opcodes/'"$${c}"'-desc.h"' > cgen-desc.h; \ rm -f dummy.c; \ cp $${srcdir}/config/tc-$${c}.c dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ - sed -e "s/dummy.o: dummy.c/TCDEP_$${c}_$${o} =/" \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + sed -e "s/dummy.o: dummy.c/DEPTC_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.tcdepa; \ + -e '/^$$/d' < DEP >> ../DEPTCA; \ rm -f dummy.c; \ else true; fi; \ done; \ done - echo 'TCDEP_hppa_som = $$(srcdir)/config/tc-hppa.h subsegs.h \' >> .tcdepa - echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> .tcdepa - echo ' $$(INCDIR)/opcode/hppa.h $$(BFDDIR)/som.h' >> .tcdepa - # We don't try to handle all multi cases. + echo 'DEPTC_hppa_som = $$(srcdir)/config/tc-hppa.h subsegs.h \' >> DEPTCA + echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> DEPTCA + echo ' $$(INCDIR)/opcode/hppa.h $$(BFDDIR)/som.h' >> DEPTCA +# We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'TCDEP_'"$${c}"'_multi = \' >> .tcdepa; \ - echo '$$(TCDEP_'"$${c}"'_coff) \' >> .tcdepa; \ + echo 'DEPTC_'"$${c}"'_multi = \' >> DEPTCA; \ + echo '$$(DEPTC_'"$${c}"'_coff) \' >> DEPTCA; \ if [ x$${valid} = xyes ]; then \ - echo '$$(TCDEP_'"$${c}"'_ecoff) \' >> .tcdepa; \ + echo '$$(DEPTC_'"$${c}"'_ecoff) \' >> DEPTCA; \ else true; fi; \ - echo '$$(TCDEP_'"$${c}"'_elf)' >> .tcdepa; \ + echo '$$(DEPTC_'"$${c}"'_elf)' >> DEPTCA; \ else true; fi; \ done - mv -f .tcdepa .tcdep + mv -f DEPTCA DEPTC # Work out the special dependencies for the obj-*.c files. -.objdep: $(OBJ_FORMAT_CFILES) - rm -f .objdepa - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEPOBJ: $(OBJ_FORMAT_CFILES) + rm -f DEPOBJA + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ @@ -774,76 +792,77 @@ DEP_FILE_DEPS = $(CFILES) $(HFILES) $(TARGET_CPU_CFILES) \ echo '#include "obj-'"$${o}"'.h"' > obj-format.h; \ echo '#include "te-generic.h"' > targ-env.h; \ echo '' > itbl-cpu.h; \ + echo '' > itbl-parse.h; \ rm -f dummy.c; \ cp $${srcdir}/config/obj-$${o}.c dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ - sed -e "s/dummy.o: dummy.c/OBJDEP_$${c}_$${o} =/" \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + sed -e "s/dummy.o: dummy.c/DEPOBJ_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.objdepa; \ + -e '/^$$/d' < DEP >> ../DEPOBJA; \ rm -f dummy.c; \ else true; fi; \ done; \ done - echo 'OBJDEP_hppa_som = $$(srcdir)/config/obj-som.h subsegs.h \' >> .objdepa - echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> .objdepa - echo ' $$(BFDDIR)/som.h $$(INCDIR)/aout/stab_gnu.h \' >> .objdepa - echo ' $$(INCDIR)/aout/stab.def' >> .objdepa - # We don't try to handle all multi cases. + echo 'DEPOBJ_hppa_som = $$(srcdir)/config/obj-som.h subsegs.h \' >> DEPOBJA + echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> DEPOBJA + echo ' $$(BFDDIR)/som.h $$(INCDIR)/aout/stab_gnu.h \' >> DEPOBJA + echo ' $$(INCDIR)/aout/stab.def' >> DEPOBJA +# We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'OBJDEP_'"$${c}"'_multi = \' >> .objdepa; \ - echo '$$(OBJDEP_'"$${c}"'_coff) \' >> .objdepa; \ + echo 'DEPOBJ_'"$${c}"'_multi = \' >> DEPOBJA; \ + echo '$$(DEPOBJ_'"$${c}"'_coff) \' >> DEPOBJA; \ if [ x$${valid} = xyes ]; then \ - echo '$$(OBJDEP_'"$${c}"'_ecoff) \' >> .objdepa; \ + echo '$$(DEPOBJ_'"$${c}"'_ecoff) \' >> DEPOBJA; \ else true; fi; \ - echo '$$(OBJDEP_'"$${c}"'_elf)' >> .objdepa; \ + echo '$$(DEPOBJ_'"$${c}"'_elf)' >> DEPOBJA; \ else true; fi; \ done - mv -f .objdepa .objdep + mv -f DEPOBJA DEPOBJ # Work out the dependencies for each CPU/OBJ combination. # Note that SOM is a special case, because it only works native. -.dep2: $(TARGET_CPU_HFILES) $(OBJ_FORMAT_HFILES) - rm -f .dep2a - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEP2: $(TARGET_CPU_HFILES) $(OBJ_FORMAT_HFILES) + rm -f DEP2a + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ if [ x$${valid} = xyes ]; then \ echo '#include "tc-'"$${c}"'.h"' > targ-cpu.h; \ echo '#include "obj-'"$${o}"'.h"' > dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ sed -e "s/dummy.o: dummy.c/DEP_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.dep2a; \ + -e '/^$$/d' < DEP >> ../DEP2a; \ else true; fi; \ done; \ done - echo 'DEP_hppa_som = $$(BFDDIR)/som.h' >> .dep2a + echo 'DEP_hppa_som = $$(BFDDIR)/som.h' >> DEP2a # We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'DEP_'"$${c}"'_multi = \' >> .dep2a; \ - echo '$$(DEP_'"$${c}"'_coff) \' >> .dep2a; \ + echo 'DEP_'"$${c}"'_multi = \' >> DEP2a; \ + echo '$$(DEP_'"$${c}"'_coff) \' >> DEP2a; \ if [ x$${valid} = xyes ]; then \ - echo '$$(DEP_'"$${c}"'_ecoff) \' >> .dep2a; \ + echo '$$(DEP_'"$${c}"'_ecoff) \' >> DEP2a; \ else true; fi; \ - echo '$$(DEP_'"$${c}"'_elf)' >> .dep2a; \ + echo '$$(DEP_'"$${c}"'_elf)' >> DEP2a; \ else true; fi; \ done - mv -f .dep2a .dep2 + mv -f DEP2a DEP2 dep.sed: dep-in.sed config.status srcdir=`cd $(srcdir); pwd`; \ @@ -852,19 +871,19 @@ dep.sed: dep-in.sed config.status -e "s!@BFDDIR@!$${srcdir}/../bfd!" \ -e "s!@SRCDIR@!$${srcdir}!" -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am .PHONY: dep dep-in dep-am @@ -879,14 +898,16 @@ atof-generic.o: atof-generic.c bignum-copy.o: bignum-copy.c cond.o: cond.c macro.h sb.h $(INCDIR)/obstack.h depend.o: depend.c -ecoff.o: ecoff.c +dwarf2dbg.o: dwarf2dbg.c dwarf2dbg.h subsegs.h $(INCDIR)/obstack.h \ + $(INCDIR)/elf/dwarf2.h +ecoff.o: ecoff.c ecoff.h ehopt.o: ehopt.c subsegs.h $(INCDIR)/obstack.h $(INCDIR)/elf/dwarf2.h expr.o: expr.c $(INCDIR)/obstack.h flonum-copy.o: flonum-copy.c flonum-konst.o: flonum-konst.c flonum-mult.o: flonum-mult.c frags.o: frags.c subsegs.h $(INCDIR)/obstack.h -hash.o: hash.c +hash.o: hash.c $(INCDIR)/obstack.h input-file.o: input-file.c input-file.h input-scrub.o: input-scrub.c input-file.h sb.h listing.o: listing.c input-file.h subsegs.h @@ -900,9 +921,13 @@ sb.o: sb.c sb.h stabs.o: stabs.c $(INCDIR)/obstack.h subsegs.h ecoff.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def subsegs.o: subsegs.c subsegs.h $(INCDIR)/obstack.h -symbols.o: symbols.c $(INCDIR)/obstack.h subsegs.h +symbols.o: symbols.c $(INCDIR)/obstack.h subsegs.h \ + struc-symbol.h write.o: write.c subsegs.h $(INCDIR)/obstack.h output-file.h gasp.o: gasp.c sb.h macro.h +itbl-ops.o: itbl-ops.c itbl-ops.h itbl-parse.h +e-i386aout.o: $(srcdir)/config/e-i386aout.c emul.h \ + emul-target.h e-i386coff.o: $(srcdir)/config/e-i386coff.c emul.h \ emul-target.h e-i386elf.o: $(srcdir)/config/e-i386elf.c emul.h emul-target.h @@ -910,577 +935,591 @@ e-mipsecoff.o: $(srcdir)/config/e-mipsecoff.c emul.h \ emul-target.h e-mipself.o: $(srcdir)/config/e-mipself.c emul.h emul-target.h -TCDEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ +DEPTC_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/a29k.h -TCDEP_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ +DEPTC_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/a29k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/a29k.h -TCDEP_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-a29k.h $(INCDIR)/opcode/a29k.h -TCDEP_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h ecoff.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-alpha.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/opcode/alpha.h $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h \ subsegs.h $(INCDIR)/obstack.h ecoff.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ +DEPTC_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/arc.h \ $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h -TCDEP_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/arc.h $(INCDIR)/elf/arc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ +DEPTC_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h -TCDEP_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ +DEPTC_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/arm.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h -TCDEP_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h -TCDEP_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ +DEPTC_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/d10v.h \ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h -TCDEP_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d10v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/d10v.h $(INCDIR)/elf/ppc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ +DEPTC_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/d30v.h -TCDEP_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d30v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/d30v.h -TCDEP_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ +DEPTC_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/fr30-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/fr30-opc.h \ cgen.h -TCDEP_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-fr30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/fr30-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/fr30-opc.h \ cgen.h -TCDEP_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ +DEPTC_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8300.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/h8300.h -TCDEP_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/h8300.h -TCDEP_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ +DEPTC_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8500.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/h8500-opc.h -TCDEP_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8500.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/h8500-opc.h -TCDEP_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ +DEPTC_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(BFDDIR)/libbfd.h \ $(INCDIR)/opcode/hppa.h -TCDEP_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-hppa.h $(BFDDIR)/elf32-hppa.h \ $(BFDDIR)/libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \ subsegs.h $(INCDIR)/obstack.h $(BFDDIR)/libbfd.h $(INCDIR)/opcode/hppa.h -TCDEP_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ +DEPTC_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/i386.h -TCDEP_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ +DEPTC_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/i386.h -TCDEP_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i386.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/i386.h -TCDEP_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ +DEPTC_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/i860.h -TCDEP_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ +DEPTC_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/opcode/i860.h -TCDEP_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i860.h $(INCDIR)/opcode/i860.h -TCDEP_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ +DEPTC_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/i960.h -TCDEP_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ +DEPTC_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i960.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h $(INCDIR)/opcode/i960.h -TCDEP_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i960.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/i960.h -TCDEP_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ +DEPTC_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/m32r-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/m32r-opc.h \ cgen.h -TCDEP_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m32r.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/m32r-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/m32r-opc.h \ cgen.h -TCDEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ +DEPTC_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h \ subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h -TCDEP_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ +DEPTC_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m68k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h \ $(srcdir)/config/m68k-parse.h -TCDEP_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68k.h $(INCDIR)/obstack.h \ - subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h -TCDEP_m68k_hp300 = $(srcdir)/config/obj-hp300.h $(srcdir)/config/obj-aout.h \ + subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h \ + $(INCDIR)/elf/m68k.h $(INCDIR)/elf/reloc-macros.h +DEPTC_m68k_hp300 = $(srcdir)/config/obj-hp300.h $(srcdir)/config/obj-aout.h \ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h \ $(srcdir)/config/m68k-parse.h -TCDEP_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ +DEPTC_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m88k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/config/m88k-opcode.h -TCDEP_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m88k.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/config/m88k-opcode.h -TCDEP_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ +DEPTC_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/mcore.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/mcore-opc.h -TCDEP_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mcore.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/mcore-opc.h \ $(INCDIR)/elf/mcore.h $(INCDIR)/elf/reloc-macros.h -TCDEP_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/mips.h itbl-ops.h ecoff.h $(INCDIR)/coff/sym.h \ $(INCDIR)/coff/ecoff.h -TCDEP_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h \ itbl-ops.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h -TCDEP_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h \ itbl-ops.h -TCDEP_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mips.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h itbl-ops.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h ecoff.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h -TCDEP_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ +DEPTC_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10200.h -TCDEP_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10200.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10200.h -TCDEP_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ +DEPTC_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10300.h -TCDEP_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10300.h -TCDEP_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ +DEPTC_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/ns32k.h \ $(INCDIR)/obstack.h -TCDEP_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ +DEPTC_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/opcode/ns32k.h $(INCDIR)/obstack.h -TCDEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h $(INCDIR)/opcode/ns32k.h \ $(INCDIR)/obstack.h -TCDEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ +DEPTC_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/opcode/pj.h +DEPTC_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h $(INCDIR)/opcode/pj.h +DEPTC_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/ppc.h -TCDEP_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ppc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/ppc.h $(INCDIR)/elf/ppc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ +DEPTC_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sh.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/sh-opc.h -TCDEP_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sh.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/sh-opc.h -TCDEP_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ +DEPTC_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/sparc.h -TCDEP_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ +DEPTC_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sparc.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/sparc.h -TCDEP_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sparc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/sparc.h $(INCDIR)/elf/sparc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ +DEPTC_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/tahoe.h -TCDEP_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ +DEPTC_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/tahoe.h -TCDEP_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tahoe.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/tahoe.h -TCDEP_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ +DEPTC_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic30.h -TCDEP_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ +DEPTC_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic30.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic30.h -TCDEP_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic30.h $(INCDIR)/opcode/tic30.h -TCDEP_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ +DEPTC_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic80.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic80.h -TCDEP_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic80.h $(INCDIR)/opcode/tic80.h -TCDEP_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(srcdir)/config/vax-inst.h $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-vax.h $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ +DEPTC_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/w65.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/w65-opc.h -TCDEP_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-w65.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/w65-opc.h -TCDEP_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ +DEPTC_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/v850.h -TCDEP_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-v850.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/v850.h -TCDEP_z8k_coff = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-coff.h \ +DEPTC_z8k_coff = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-coff.h \ $(srcdir)/config/tc-z8k.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/z8k.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h -TCDEP_z8k_elf = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-elf.h \ +DEPTC_z8k_elf = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-elf.h \ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-z8k.h -TCDEP_hppa_som = $(srcdir)/config/tc-hppa.h subsegs.h \ +DEPTC_hppa_som = $(srcdir)/config/tc-hppa.h subsegs.h \ $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(INCDIR)/opcode/hppa.h \ $(BFDDIR)/som.h -TCDEP_i386_multi = $(TCDEP_i386_coff) $(TCDEP_i386_elf) -TCDEP_mips_multi = $(TCDEP_mips_coff) $(TCDEP_mips_ecoff) \ - $(TCDEP_mips_elf) -OBJDEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ +DEPTC_i386_multi = $(DEPTC_i386_coff) $(DEPTC_i386_elf) +DEPTC_mips_multi = $(DEPTC_mips_coff) $(DEPTC_mips_ecoff) \ + $(DEPTC_mips_elf) +DEPOBJ_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ +DEPOBJ_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/a29k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-a29k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ +DEPOBJ_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ +DEPOBJ_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(BFDDIR)/libecoff.h -OBJDEP_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-alpha.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/aout/aout64.h -OBJDEP_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h -OBJDEP_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ +DEPOBJ_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h +DEPOBJ_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ +DEPOBJ_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ +DEPOBJ_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/arm.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ +DEPOBJ_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d10v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ +DEPOBJ_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d30v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ +DEPOBJ_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-fr30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ +DEPOBJ_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8300.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ +DEPOBJ_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8500.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8500.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ +DEPOBJ_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-hppa.h $(BFDDIR)/elf32-hppa.h \ $(BFDDIR)/libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ +DEPOBJ_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ +DEPOBJ_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i386.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ +DEPOBJ_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ +DEPOBJ_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i860.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ +DEPOBJ_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/obstack.h -OBJDEP_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ +DEPOBJ_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i960.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i960.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ +DEPOBJ_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m32r.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ +DEPOBJ_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ +DEPOBJ_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m68k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m68k_hp300 = $(srcdir)/config/obj-aout.c $(srcdir)/config/obj-hp300.h \ +DEPOBJ_m68k_hp300 = $(srcdir)/config/obj-aout.c $(srcdir)/config/obj-hp300.h \ $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ +DEPOBJ_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m88k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m88k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ +DEPOBJ_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/mcore.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mcore.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(BFDDIR)/libecoff.h -OBJDEP_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mips.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/aout/aout64.h -OBJDEP_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ +DEPOBJ_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10200.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ +DEPOBJ_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ +DEPOBJ_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ +DEPOBJ_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ +DEPOBJ_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/obstack.h subsegs.h +DEPOBJ_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h subsegs.h \ + $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h +DEPOBJ_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ppc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/aout/aout64.h -OBJDEP_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ +DEPOBJ_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sh.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sh.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ +DEPOBJ_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ +DEPOBJ_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sparc.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sparc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ +DEPOBJ_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ +DEPOBJ_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tahoe.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ +DEPOBJ_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ +DEPOBJ_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic30.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ +DEPOBJ_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic80.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic80.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-vax.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def subsegs.h \ $(INCDIR)/obstack.h -OBJDEP_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ +DEPOBJ_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/w65.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-w65.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ +DEPOBJ_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-v850.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_z8k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-z8k.h \ +DEPOBJ_z8k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-z8k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/z8k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_z8k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_z8k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-z8k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_hppa_som = $(srcdir)/config/obj-som.h subsegs.h \ +DEPOBJ_hppa_som = $(srcdir)/config/obj-som.h subsegs.h \ $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(BFDDIR)/som.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def -OBJDEP_i386_multi = $(OBJDEP_i386_coff) $(OBJDEP_i386_elf) -OBJDEP_mips_multi = $(OBJDEP_mips_coff) $(OBJDEP_mips_ecoff) \ - $(OBJDEP_mips_elf) +DEPOBJ_i386_multi = $(DEPOBJ_i386_coff) $(DEPOBJ_i386_elf) +DEPOBJ_mips_multi = $(DEPOBJ_mips_coff) $(DEPOBJ_mips_ecoff) \ + $(DEPOBJ_mips_elf) DEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h DEP_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ @@ -1618,6 +1657,11 @@ DEP_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ DEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h +DEP_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h +DEP_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h DEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h @@ -1690,6 +1734,6 @@ DEP_i386_multi = $(DEP_i386_coff) $(DEP_i386_elf) DEP_mips_multi = $(DEP_mips_coff) $(DEP_mips_ecoff) \ $(DEP_mips_elf) $(OBJS): $(DEP_@target_cpu_type@_@obj_format@) -$(TARG_CPU_O): $(TCDEP_@target_cpu_type@_@obj_format@) -$(OBJ_FORMAT_O): $(OBJDEP_@target_cpu_type@_@obj_format@) +$(TARG_CPU_O): $(DEPTC_@target_cpu_type@_@obj_format@) +$(OBJ_FORMAT_O): $(DEPOBJ_@target_cpu_type@_@obj_format@) # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gas/Makefile.in b/gas/Makefile.in index 244fff2..3bcb551 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -72,6 +72,7 @@ CC = @CC@ DATADIRNAME = @DATADIRNAME@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ +GDBINIT = @GDBINIT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GT_NO = @GT_NO@ @@ -80,14 +81,13 @@ INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLOBJS = @INTLOBJS@ -LD = @LD@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ -NM = @NM@ +OBJDUMP = @OBJDUMP@ OPCODES_LIB = @OPCODES_LIB@ PACKAGE = @PACKAGE@ POFILES = @POFILES@ @@ -116,7 +116,7 @@ tooldir = $(exec_prefix)/$(target_alias) YACC = `if [ -f ../bison/bison ] ; then echo ../bison/bison -y -L../bison/bison ; else echo bison -y ; fi` LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi` -DEP = $(srcdir)/../mkdep +MKDEP = $${srcdir}/../mkdep TARG_CPU = @target_cpu_type@ TARG_CPU_C = $(srcdir)/config/tc-@target_cpu_type@.c @@ -148,6 +148,7 @@ CPU_TYPES = \ h8300 \ h8500 \ hppa \ + i370 \ i386 \ i860 \ i960 \ @@ -159,6 +160,7 @@ CPU_TYPES = \ mn10200 \ mn10300 \ ns32k \ + pj \ ppc \ sh \ sparc \ @@ -242,6 +244,7 @@ GAS_CFILES = \ bignum-copy.c \ cond.c \ depend.c \ + dwarf2dbg.c \ ecoff.c \ ehopt.c \ expr.c \ @@ -273,6 +276,7 @@ HFILES = \ bignum.h \ bit_fix.h \ cgen.h \ + dwarf2dbg.h \ ecoff.h \ emul-target.h \ emul.h \ @@ -304,9 +308,11 @@ TARGET_CPU_CFILES = \ config/tc-arm.c \ config/tc-d10v.c \ config/tc-d30v.c \ + config/tc-fr30.c \ config/tc-h8300.c \ config/tc-h8500.c \ config/tc-hppa.c \ + config/tc-i370.c \ config/tc-i386.c \ config/tc-i860.c \ config/tc-i960.c \ @@ -318,6 +324,7 @@ TARGET_CPU_CFILES = \ config/tc-mn10200.c \ config/tc-mn10300.c \ config/tc-ns32k.c \ + config/tc-pj.c \ config/tc-ppc.c \ config/tc-sh.c \ config/tc-sparc.c \ @@ -337,9 +344,11 @@ TARGET_CPU_HFILES = \ config/tc-arm.h \ config/tc-d10v.h \ config/tc-d30v.h \ + config/tc-fr30.h \ config/tc-h8300.h \ config/tc-h8500.h \ config/tc-hppa.h \ + config/tc-i370.h \ config/tc-i386.h \ config/tc-i860.h \ config/tc-i960.h \ @@ -351,6 +360,7 @@ TARGET_CPU_HFILES = \ config/tc-mn10200.h \ config/tc-mn10300.h \ config/tc-ns32k.h \ + config/tc-pj.h \ config/tc-ppc.h \ config/tc-sh.h \ config/tc-sparc.h \ @@ -400,6 +410,7 @@ TARG_ENV_HFILES = \ config/te-delt88.h \ config/te-dpx2.h \ config/te-dynix.h \ + config/te-epoc-pe.h \ config/te-generic.h \ config/te-go32.h \ config/te-hp300.h \ @@ -428,6 +439,7 @@ TARG_ENV_HFILES = \ # Multi files in config MULTI_CFILES = \ + config/e-i386aout.c \ config/e-i386coff.c \ config/e-i386elf.c \ config/e-mipsecoff.c \ @@ -448,6 +460,7 @@ GENERIC_OBJS = \ bignum-copy.o \ cond.o \ depend.o \ + dwarf2dbg.o \ ehopt.o \ expr.o \ flonum-konst.o \ @@ -479,7 +492,8 @@ POTFILES = $(MULTI_CFILES) $(TARGET_ENV_HFILES) $(OBJ_FORMAT_HFILES) \ noinst_PROGRAMS = as-new gasp-new -noinst_SCRIPTS = .gdbinit +noinst_SCRIPTS = $(GDBINIT) +EXTRA_SCRIPTS = .gdbinit EXTRA_DIST = make-gas.com @@ -545,7 +559,7 @@ EXTRA_as_new_SOURCES = config/m68k-parse.y EXTRA_PROGRAMS = itbl-test itbl_test_SOURCES = itbl-parse.y itbl-lex.l -itbl_test_LDADD = itbl-test-ops.o itbl-test.o $(GASLIBS) @LEXLIB@ +itbl_test_LDADD = itbl-tops.o itbl-test.o $(GASLIBS) @LEXLIB@ # CGEN interface. @@ -558,7 +572,7 @@ MOSTLYCLEANFILES = $(STAGESTUFF) core stamp-mk.com \ testsuite/site.exp site.bak site.exp stage stage1 stage2 -CLEANFILES = dep.sed .tcdep .objdep .dep2 .dep1 .depa .dep .depdir +CLEANFILES = dep.sed DEPTC DEPOBJ DEP2 DEP1 DEPA DEP DEPDIR against = stage2 @@ -570,737 +584,755 @@ DEP_FILE_DEPS = $(CFILES) $(HFILES) $(TARGET_CPU_CFILES) \ $(TARGET_CPU_HFILES) $(OBJ_FORMAT_CFILES) $(OBJ_FORMAT_HFILES) -TCDEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ +DEPTC_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/a29k.h -TCDEP_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ +DEPTC_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/a29k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/a29k.h -TCDEP_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-a29k.h $(INCDIR)/opcode/a29k.h -TCDEP_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h ecoff.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-alpha.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/opcode/alpha.h $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \ $(srcdir)/config/atof-vax.c -TCDEP_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h \ +DEPTC_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h \ subsegs.h $(INCDIR)/obstack.h ecoff.h $(INCDIR)/opcode/alpha.h \ $(srcdir)/config/atof-vax.c -TCDEP_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ +DEPTC_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/arc.h \ $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h -TCDEP_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/arc.h $(INCDIR)/elf/arc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ +DEPTC_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h -TCDEP_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ +DEPTC_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/arm.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h -TCDEP_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h -TCDEP_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ +DEPTC_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/d10v.h \ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h -TCDEP_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d10v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/d10v.h $(INCDIR)/elf/ppc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ +DEPTC_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/d30v.h -TCDEP_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d30v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/d30v.h -TCDEP_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ +DEPTC_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/fr30-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/fr30-opc.h \ cgen.h -TCDEP_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-fr30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/fr30-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/fr30-opc.h \ cgen.h -TCDEP_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ +DEPTC_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8300.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/h8300.h -TCDEP_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/h8300.h -TCDEP_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ +DEPTC_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8500.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/h8500-opc.h -TCDEP_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8500.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/h8500-opc.h -TCDEP_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ +DEPTC_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(BFDDIR)/libbfd.h \ $(INCDIR)/opcode/hppa.h -TCDEP_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-hppa.h $(BFDDIR)/elf32-hppa.h \ $(BFDDIR)/libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \ subsegs.h $(INCDIR)/obstack.h $(BFDDIR)/libbfd.h $(INCDIR)/opcode/hppa.h -TCDEP_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ +DEPTC_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/i386.h -TCDEP_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ +DEPTC_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/i386.h -TCDEP_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i386.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/i386.h -TCDEP_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ +DEPTC_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/i860.h -TCDEP_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ +DEPTC_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/opcode/i860.h -TCDEP_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i860.h $(INCDIR)/opcode/i860.h -TCDEP_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ +DEPTC_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/i960.h -TCDEP_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ +DEPTC_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i960.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h $(INCDIR)/opcode/i960.h -TCDEP_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i960.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/i960.h -TCDEP_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ +DEPTC_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/m32r-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/m32r-opc.h \ cgen.h -TCDEP_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m32r.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/symcat.h $(srcdir)/../opcodes/m32r-desc.h \ $(INCDIR)/opcode/cgen.h $(srcdir)/../opcodes/m32r-opc.h \ cgen.h -TCDEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ +DEPTC_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h \ subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h -TCDEP_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ +DEPTC_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m68k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h \ $(srcdir)/config/m68k-parse.h -TCDEP_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68k.h $(INCDIR)/obstack.h \ - subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h + subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h \ + $(INCDIR)/elf/m68k.h $(INCDIR)/elf/reloc-macros.h -TCDEP_m68k_hp300 = $(srcdir)/config/obj-hp300.h $(srcdir)/config/obj-aout.h \ +DEPTC_m68k_hp300 = $(srcdir)/config/obj-hp300.h $(srcdir)/config/obj-aout.h \ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h \ $(srcdir)/config/m68k-parse.h -TCDEP_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ +DEPTC_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m88k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/config/m88k-opcode.h -TCDEP_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m88k.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/config/m88k-opcode.h -TCDEP_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ +DEPTC_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/mcore.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/mcore-opc.h -TCDEP_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mcore.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/mcore-opc.h \ $(INCDIR)/elf/mcore.h $(INCDIR)/elf/reloc-macros.h -TCDEP_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/mips.h itbl-ops.h ecoff.h $(INCDIR)/coff/sym.h \ $(INCDIR)/coff/ecoff.h -TCDEP_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h \ itbl-ops.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h -TCDEP_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ +DEPTC_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h \ itbl-ops.h -TCDEP_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mips.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mips.h itbl-ops.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h ecoff.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h -TCDEP_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ +DEPTC_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10200.h -TCDEP_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10200.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10200.h -TCDEP_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ +DEPTC_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10300.h -TCDEP_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/mn10300.h -TCDEP_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ +DEPTC_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/ns32k.h \ $(INCDIR)/obstack.h -TCDEP_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ +DEPTC_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/opcode/ns32k.h $(INCDIR)/obstack.h -TCDEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h $(INCDIR)/opcode/ns32k.h \ $(INCDIR)/obstack.h -TCDEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ +DEPTC_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/opcode/pj.h + +DEPTC_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h $(INCDIR)/opcode/pj.h + +DEPTC_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/ppc.h -TCDEP_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ppc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/ppc.h $(INCDIR)/elf/ppc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ +DEPTC_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sh.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/sh-opc.h -TCDEP_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sh.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/sh-opc.h -TCDEP_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ +DEPTC_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/sparc.h -TCDEP_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ +DEPTC_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sparc.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/sparc.h -TCDEP_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sparc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/sparc.h $(INCDIR)/elf/sparc.h \ $(INCDIR)/elf/reloc-macros.h -TCDEP_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ +DEPTC_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/tahoe.h -TCDEP_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ +DEPTC_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/tahoe.h -TCDEP_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tahoe.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/tahoe.h -TCDEP_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ +DEPTC_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic30.h -TCDEP_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ +DEPTC_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic30.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic30.h -TCDEP_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic30.h $(INCDIR)/opcode/tic30.h -TCDEP_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ +DEPTC_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic80.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/opcode/tic80.h -TCDEP_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic80.h $(INCDIR)/opcode/tic80.h -TCDEP_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(srcdir)/config/vax-inst.h $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-vax.h $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ +DEPTC_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(srcdir)/config/vax-inst.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/vax.h -TCDEP_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ +DEPTC_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/w65.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h subsegs.h $(INCDIR)/obstack.h $(srcdir)/../opcodes/w65-opc.h -TCDEP_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-w65.h subsegs.h \ $(INCDIR)/obstack.h $(srcdir)/../opcodes/w65-opc.h -TCDEP_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ +DEPTC_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/opcode/v850.h -TCDEP_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPTC_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-v850.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/opcode/v850.h -TCDEP_z8k_coff = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-coff.h \ +DEPTC_z8k_coff = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-coff.h \ $(srcdir)/config/tc-z8k.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/z8k.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h -TCDEP_z8k_elf = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-elf.h \ +DEPTC_z8k_elf = $(srcdir)/../opcodes/z8k-opc.h $(srcdir)/config/obj-elf.h \ $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-z8k.h -TCDEP_hppa_som = $(srcdir)/config/tc-hppa.h subsegs.h \ +DEPTC_hppa_som = $(srcdir)/config/tc-hppa.h subsegs.h \ $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(INCDIR)/opcode/hppa.h \ $(BFDDIR)/som.h -TCDEP_i386_multi = $(TCDEP_i386_coff) $(TCDEP_i386_elf) -TCDEP_mips_multi = $(TCDEP_mips_coff) $(TCDEP_mips_ecoff) \ - $(TCDEP_mips_elf) +DEPTC_i386_multi = $(DEPTC_i386_coff) $(DEPTC_i386_elf) +DEPTC_mips_multi = $(DEPTC_mips_coff) $(DEPTC_mips_ecoff) \ + $(DEPTC_mips_elf) -OBJDEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ +DEPOBJ_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ +DEPOBJ_a29k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-a29k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/a29k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_a29k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-a29k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ +DEPOBJ_alpha_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-alpha.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ +DEPOBJ_alpha_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-alpha.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(BFDDIR)/libecoff.h -OBJDEP_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_alpha_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-alpha.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/elf/alpha.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/aout/aout64.h -OBJDEP_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h -OBJDEP_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ +DEPOBJ_alpha_evax = $(srcdir)/config/obj-evax.h $(srcdir)/config/tc-alpha.h +DEPOBJ_arc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arc.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_arc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ +DEPOBJ_arm_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-arm.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ +DEPOBJ_arm_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/arm.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_arm_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ +DEPOBJ_d10v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d10v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_d10v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d10v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ +DEPOBJ_d30v_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-d30v.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_d30v_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-d30v.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ +DEPOBJ_fr30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-fr30.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_fr30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-fr30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ +DEPOBJ_h8300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8300.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8300.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_h8300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ +DEPOBJ_h8500_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-h8500.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/h8500.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_h8500_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-h8500.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ +DEPOBJ_hppa_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-hppa.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_hppa_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-hppa.h $(BFDDIR)/elf32-hppa.h \ $(BFDDIR)/libhppa.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \ subsegs.h $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ +DEPOBJ_i386_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i386.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ +DEPOBJ_i386_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i386.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i386.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i386_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i386.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ +DEPOBJ_i860_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-i860.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ +DEPOBJ_i860_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i860.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i860_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i860.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ +DEPOBJ_i960_bout = $(srcdir)/config/obj-bout.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/obstack.h -OBJDEP_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ +DEPOBJ_i960_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-i960.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/i960.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_i960_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-i960.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ +DEPOBJ_m32r_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m32r.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m32r_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m32r.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ +DEPOBJ_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ +DEPOBJ_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m68k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m68k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_m68k_hp300 = $(srcdir)/config/obj-aout.c $(srcdir)/config/obj-hp300.h \ +DEPOBJ_m68k_hp300 = $(srcdir)/config/obj-aout.c $(srcdir)/config/obj-hp300.h \ $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ +DEPOBJ_m88k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m88k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/m88k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_m88k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m88k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ +DEPOBJ_mcore_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mcore.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/mcore.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mcore_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mcore.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-mips.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mips.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ +DEPOBJ_mips_ecoff = $(srcdir)/config/obj-ecoff.h $(srcdir)/config/tc-mips.h \ ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(BFDDIR)/libecoff.h -OBJDEP_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mips_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mips.h subsegs.h \ $(INCDIR)/obstack.h ecoff.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/aout/aout64.h -OBJDEP_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ +DEPOBJ_mn10200_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10200.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mn10200_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10200.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ +DEPOBJ_mn10300_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-mn10300.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_mn10300_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-mn10300.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ +DEPOBJ_ns32k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-ns32k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ +DEPOBJ_ns32k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ns32k.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ +DEPOBJ_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/obstack.h subsegs.h + +DEPOBJ_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h subsegs.h \ + $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h + +DEPOBJ_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_ppc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ppc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/aout/aout64.h -OBJDEP_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ +DEPOBJ_sh_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sh.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sh.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_sh_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sh.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ +DEPOBJ_sparc_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-sparc.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ +DEPOBJ_sparc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-sparc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/sparc.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_sparc_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-sparc.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ +DEPOBJ_tahoe_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tahoe.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ +DEPOBJ_tahoe_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tahoe.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tahoe_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tahoe.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ +DEPOBJ_tic30_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-tic30.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ +DEPOBJ_tic30_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic30.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic30.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tic30_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic30.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ +DEPOBJ_tic80_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-tic80.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/tic80.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_tic80_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-tic80.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-vax.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/obstack.h -OBJDEP_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_vax_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-vax.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ +DEPOBJ_vax_vms = $(srcdir)/config/obj-vms.h $(srcdir)/config/tc-vax.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def subsegs.h \ $(INCDIR)/obstack.h -OBJDEP_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ +DEPOBJ_w65_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-w65.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/w65.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_w65_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-w65.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ +DEPOBJ_v850_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-v850.h \ $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h \ $(INCDIR)/obstack.h subsegs.h -OBJDEP_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_v850_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-v850.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_z8k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-z8k.h \ +DEPOBJ_z8k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-z8k.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/z8k.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h $(INCDIR)/obstack.h subsegs.h -OBJDEP_z8k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ +DEPOBJ_z8k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-z8k.h subsegs.h \ $(INCDIR)/obstack.h $(INCDIR)/aout/aout64.h -OBJDEP_hppa_som = $(srcdir)/config/obj-som.h subsegs.h \ +DEPOBJ_hppa_som = $(srcdir)/config/obj-som.h subsegs.h \ $(INCDIR)/obstack.h $(BFDDIR)/libhppa.h $(BFDDIR)/som.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def -OBJDEP_i386_multi = $(OBJDEP_i386_coff) $(OBJDEP_i386_elf) -OBJDEP_mips_multi = $(OBJDEP_mips_coff) $(OBJDEP_mips_ecoff) \ - $(OBJDEP_mips_elf) +DEPOBJ_i386_multi = $(DEPOBJ_i386_coff) $(DEPOBJ_i386_elf) +DEPOBJ_mips_multi = $(DEPOBJ_mips_coff) $(DEPOBJ_mips_ecoff) \ + $(DEPOBJ_mips_elf) DEP_a29k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-a29k.h \ $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h @@ -1491,6 +1523,13 @@ DEP_ns32k_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-ns32k.h +DEP_pj_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-pj.h \ + $(INCDIR)/coff/internal.h $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h + +DEP_pj_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/bfdlink.h $(srcdir)/config/tc-pj.h + DEP_ppc_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-ppc.h \ $(INCDIR)/coff/internal.h $(INCDIR)/coff/rs6000.h $(BFDDIR)/libcoff.h \ $(INCDIR)/bfdlink.h @@ -1591,7 +1630,7 @@ DEP_mips_multi = $(DEP_mips_coff) $(DEP_mips_ecoff) \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = .gdbinit +CONFIG_CLEAN_FILES = ${GDBINIT} noinst_PROGRAMS = as-new$(EXEEXT) gasp-new$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) @@ -1601,14 +1640,14 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ itbl_test_OBJECTS = itbl-parse.o itbl-lex.o -itbl_test_DEPENDENCIES = itbl-test-ops.o itbl-test.o \ +itbl_test_DEPENDENCIES = itbl-tops.o itbl-test.o \ ../libiberty/libiberty.a itbl_test_LDFLAGS = as_new_OBJECTS = app.o as.o atof-generic.o bignum-copy.o cond.o \ -depend.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o \ -flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o \ -literal.o macro.o messages.o output-file.o read.o sb.o stabs.o \ -subsegs.o symbols.o write.o +depend.o dwarf2dbg.o ecoff.o ehopt.o expr.o flonum-copy.o \ +flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o \ +listing.o literal.o macro.o messages.o output-file.o read.o sb.o \ +stabs.o subsegs.o symbols.o write.o as_new_LDFLAGS = gasp_new_OBJECTS = gasp.o macro.o sb.o hash.o gasp_new_LDFLAGS = @@ -1629,7 +1668,7 @@ configure configure.in gdbinit.in itbl-lex.c itbl-parse.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(itbl_test_SOURCES) $(as_new_SOURCES) $(EXTRA_as_new_SOURCES) $(gasp_new_SOURCES) OBJECTS = $(itbl_test_OBJECTS) $(as_new_OBJECTS) $(gasp_new_OBJECTS) @@ -1679,7 +1718,7 @@ distclean-hdr: -rm -f config.h maintainer-clean-hdr: -.gdbinit: $(top_builddir)/config.status gdbinit.in +${GDBINIT}: $(top_builddir)/config.status gdbinit.in cd $(top_builddir) && CONFIG_FILES=$@:gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-noinstPROGRAMS: @@ -1878,7 +1917,7 @@ 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; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -2029,7 +2068,7 @@ $(OBJS): @ALL_OBJ_DEPS@ # Stuff that every object file depends upon. If anything is removed # from this list, remove it from dep-in.sed as well. $(OBJS): config.h as.h $(TARG_ENV_H) $(OBJ_FORMAT_H) $(TARG_CPU_H) flonum.h \ - expr.h struc-symbol.h write.h frags.h hash.h read.h symbols.h tc.h \ + expr.h write.h frags.h hash.h read.h symbols.h tc.h \ obj.h listing.h bignum.h bit_fix.h $(INCDIR)/libiberty.h asintl.h check-DEJAGNU: site.exp @@ -2098,6 +2137,8 @@ e-mipself.o : $(srcdir)/config/e-mipself.c $(COMPILE) -c $(srcdir)/config/e-mipself.c e-mipsecoff.o : $(srcdir)/config/e-mipsecoff.c $(COMPILE) -c $(srcdir)/config/e-mipsecoff.c +e-i386aout.o: $(srcdir)/config/e-i386aout.c + $(COMPILE) -c $(srcdir)/config/e-i386aout.c e-i386coff.o: $(srcdir)/config/e-i386coff.c $(COMPILE) -c $(srcdir)/config/e-i386coff.c e-i386elf.o: $(srcdir)/config/e-i386elf.c @@ -2143,8 +2184,8 @@ itbl-ops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h itbl-parse.c itbl-parse.h: $(srcdir)/itbl-parse.y $(SHELL) $(YLWRAP) "$(YACC)" $(srcdir)/itbl-parse.y y.tab.c itbl-parse.c y.tab.h itbl-parse.h -- -d -itbl-test-ops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h - $(COMPILE) -o itbl-test-ops.o -DSTAND_ALONE -c $(srcdir)/itbl-ops.c +itbl-tops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h + $(COMPILE) -o itbl-tops.o -DSTAND_ALONE -c $(srcdir)/itbl-ops.c itbl-test.o: $(srcdir)/testsuite/gas/all/itbl-test.c $(srcdir)/itbl-ops.h $(COMPILE) -c -DSTAND_ALONE $(srcdir)/testsuite/gas/all/itbl-test.c @@ -2168,7 +2209,7 @@ install-exec-bindir: $(noinst_PROGRAMS) else :; fi; \ done -install-exec-tooldir: $(noinst_PROGRAMS) +install-exec-tooldir: install-exec-bindir $(noinst_PROGRAMS) $(mkinstalldirs) $(tooldir)/bin n=`echo as | sed '$(transform)'`; \ if [ "$(bindir)/$$n$(EXEEXT)" != "$(tooldir)/bin/as$(EXEEXT)" ]; then \ @@ -2254,41 +2295,42 @@ de-stage3: - (cd stage3 ; rm -f as$(EXEEXT) ; mv -f * ..) - rmdir stage3 -.dep: dep.sed $(DEP_FILE_DEPS) .tcdep .objdep .dep2 - rm -f .dep1 +DEP: dep.sed $(DEP_FILE_DEPS) DEPTC DEPOBJ DEP2 + rm -f DEP1 srcdir=`cd $(srcdir); pwd`; \ - $(MAKE) DEP=$(DEP) srcdir=$${srcdir} VPATH=$${srcdir} .dep1 - rm -rf .depdir - sed -f dep.sed < .dep1 > .depa - sed -f dep.sed < .tcdep >> .depa - sed -f dep.sed < .objdep >> .depa - sed -f dep.sed < .dep2 >> .depa - echo '$$(OBJS): $$(DEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '$$(TARG_CPU_O): $$(TCDEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '$$(OBJ_FORMAT_O): $$(OBJDEP_@target''_cpu_type@_@obj''_format@)' >> .depa - echo '# IF YOU PUT ANYTHING HERE IT WILL GO AWAY' >> .depa - $(SHELL) $(srcdir)/../move-if-change .depa .dep + $(MAKE) MKDEP=$(MKDEP) srcdir=$${srcdir} VPATH=$${srcdir} DEP1 + rm -rf DEPDIR + sed -f dep.sed < DEP1 > DEPA + sed -f dep.sed < DEPTC >> DEPA + sed -f dep.sed < DEPOBJ >> DEPA + sed -f dep.sed < DEP2 >> DEPA + echo '$$(OBJS): $$(DEP_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '$$(TARG_CPU_O): $$(DEPTC_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '$$(OBJ_FORMAT_O): $$(DEPOBJ_@target''_cpu_type@_@obj''_format@)' >> DEPA + echo '# IF YOU PUT ANYTHING HERE IT WILL GO AWAY' >> DEPA + $(SHELL) $(srcdir)/../move-if-change DEPA DEP # This rule needs a mkdep that runs "gcc -MM". -.dep1: $(CFILES) $(MULTI_CFILES) - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEP1: $(CFILES) $(MULTI_CFILES) + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ echo '' > targ-cpu.h; \ echo '' > obj-format.h; \ echo '' > targ-env.h; \ echo '' > itbl-cpu.h; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) $? - sed -e '/IF YOU PUT ANYTHING/,$$d' < .depdir/.dep > .dep1 - rm -f .depdir/.dep + echo '' > itbl-parse.h; \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) $? + sed -e '/IF YOU PUT ANYTHING/,$$d' < DEPDIR/DEP > DEP1 + rm -f DEPDIR/DEP # Work out the special dependencies for the tc-*.c files. -.tcdep: $(TARGET_CPU_CFILES) - rm -f .tcdepa - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEPTC: $(TARGET_CPU_CFILES) + rm -f DEPTCA + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ @@ -2297,44 +2339,45 @@ de-stage3: echo '#include "obj-'"$${o}"'.h"' > obj-format.h; \ echo '#include "te-generic.h"' > targ-env.h; \ echo '' > itbl-cpu.h; \ + echo '' > itbl-parse.h; \ echo '#include "opcodes/'"$${c}"'-desc.h"' > cgen-desc.h; \ rm -f dummy.c; \ cp $${srcdir}/config/tc-$${c}.c dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ - sed -e "s/dummy.o: dummy.c/TCDEP_$${c}_$${o} =/" \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + sed -e "s/dummy.o: dummy.c/DEPTC_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.tcdepa; \ + -e '/^$$/d' < DEP >> ../DEPTCA; \ rm -f dummy.c; \ else true; fi; \ done; \ done - echo 'TCDEP_hppa_som = $$(srcdir)/config/tc-hppa.h subsegs.h \' >> .tcdepa - echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> .tcdepa - echo ' $$(INCDIR)/opcode/hppa.h $$(BFDDIR)/som.h' >> .tcdepa - # We don't try to handle all multi cases. + echo 'DEPTC_hppa_som = $$(srcdir)/config/tc-hppa.h subsegs.h \' >> DEPTCA + echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> DEPTCA + echo ' $$(INCDIR)/opcode/hppa.h $$(BFDDIR)/som.h' >> DEPTCA +# We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'TCDEP_'"$${c}"'_multi = \' >> .tcdepa; \ - echo '$$(TCDEP_'"$${c}"'_coff) \' >> .tcdepa; \ + echo 'DEPTC_'"$${c}"'_multi = \' >> DEPTCA; \ + echo '$$(DEPTC_'"$${c}"'_coff) \' >> DEPTCA; \ if [ x$${valid} = xyes ]; then \ - echo '$$(TCDEP_'"$${c}"'_ecoff) \' >> .tcdepa; \ + echo '$$(DEPTC_'"$${c}"'_ecoff) \' >> DEPTCA; \ else true; fi; \ - echo '$$(TCDEP_'"$${c}"'_elf)' >> .tcdepa; \ + echo '$$(DEPTC_'"$${c}"'_elf)' >> DEPTCA; \ else true; fi; \ done - mv -f .tcdepa .tcdep + mv -f DEPTCA DEPTC # Work out the special dependencies for the obj-*.c files. -.objdep: $(OBJ_FORMAT_CFILES) - rm -f .objdepa - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEPOBJ: $(OBJ_FORMAT_CFILES) + rm -f DEPOBJA + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ @@ -2343,76 +2386,77 @@ de-stage3: echo '#include "obj-'"$${o}"'.h"' > obj-format.h; \ echo '#include "te-generic.h"' > targ-env.h; \ echo '' > itbl-cpu.h; \ + echo '' > itbl-parse.h; \ rm -f dummy.c; \ cp $${srcdir}/config/obj-$${o}.c dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ - sed -e "s/dummy.o: dummy.c/OBJDEP_$${c}_$${o} =/" \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + sed -e "s/dummy.o: dummy.c/DEPOBJ_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.objdepa; \ + -e '/^$$/d' < DEP >> ../DEPOBJA; \ rm -f dummy.c; \ else true; fi; \ done; \ done - echo 'OBJDEP_hppa_som = $$(srcdir)/config/obj-som.h subsegs.h \' >> .objdepa - echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> .objdepa - echo ' $$(BFDDIR)/som.h $$(INCDIR)/aout/stab_gnu.h \' >> .objdepa - echo ' $$(INCDIR)/aout/stab.def' >> .objdepa - # We don't try to handle all multi cases. + echo 'DEPOBJ_hppa_som = $$(srcdir)/config/obj-som.h subsegs.h \' >> DEPOBJA + echo ' $$(INCDIR)/obstack.h $$(BFDDIR)/libhppa.h \' >> DEPOBJA + echo ' $$(BFDDIR)/som.h $$(INCDIR)/aout/stab_gnu.h \' >> DEPOBJA + echo ' $$(INCDIR)/aout/stab.def' >> DEPOBJA +# We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'OBJDEP_'"$${c}"'_multi = \' >> .objdepa; \ - echo '$$(OBJDEP_'"$${c}"'_coff) \' >> .objdepa; \ + echo 'DEPOBJ_'"$${c}"'_multi = \' >> DEPOBJA; \ + echo '$$(DEPOBJ_'"$${c}"'_coff) \' >> DEPOBJA; \ if [ x$${valid} = xyes ]; then \ - echo '$$(OBJDEP_'"$${c}"'_ecoff) \' >> .objdepa; \ + echo '$$(DEPOBJ_'"$${c}"'_ecoff) \' >> DEPOBJA; \ else true; fi; \ - echo '$$(OBJDEP_'"$${c}"'_elf)' >> .objdepa; \ + echo '$$(DEPOBJ_'"$${c}"'_elf)' >> DEPOBJA; \ else true; fi; \ done - mv -f .objdepa .objdep + mv -f DEPOBJA DEPOBJ # Work out the dependencies for each CPU/OBJ combination. # Note that SOM is a special case, because it only works native. -.dep2: $(TARGET_CPU_HFILES) $(OBJ_FORMAT_HFILES) - rm -f .dep2a - if [ -d .depdir ]; then true; else mkdir .depdir; fi +DEP2: $(TARGET_CPU_HFILES) $(OBJ_FORMAT_HFILES) + rm -f DEP2a + if [ -d DEPDIR ]; then true; else mkdir DEPDIR; fi srcdir=`cd $(srcdir); pwd`; \ - cd .depdir; \ + cd DEPDIR; \ for c in $(CPU_TYPES); do \ for o in $(OBJ_FORMATS); do \ $(CPU_OBJ_VALID) \ if [ x$${valid} = xyes ]; then \ echo '#include "tc-'"$${c}"'.h"' > targ-cpu.h; \ echo '#include "obj-'"$${o}"'.h"' > dummy.c; \ - echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep; \ - $(DEP) -f .dep -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP; \ + $(MKDEP) -f DEP -DBFD_ASSEMBLER -I. -I.. -I$${srcdir} -I../../bfd $(DEP_INCLUDES) dummy.c; \ sed -e "s/dummy.o: dummy.c/DEP_$${c}_$${o} =/" \ -e '1,/DO NOT PUT ANYTHING AFTER/d' \ -e '/IF YOU PUT ANYTHING/,$$d' \ - -e '/^$$/d' < .dep >> ../.dep2a; \ + -e '/^$$/d' < DEP >> ../DEP2a; \ else true; fi; \ done; \ done - echo 'DEP_hppa_som = $$(BFDDIR)/som.h' >> .dep2a + echo 'DEP_hppa_som = $$(BFDDIR)/som.h' >> DEP2a # We don't try to handle all multi cases. for c in $(CPU_TYPES); do \ $(CPU_MULTI_VALID) \ if [ x$${valid} = xyes ]; then \ o=ecoff; \ $(CPU_OBJ_VALID) \ - echo 'DEP_'"$${c}"'_multi = \' >> .dep2a; \ - echo '$$(DEP_'"$${c}"'_coff) \' >> .dep2a; \ + echo 'DEP_'"$${c}"'_multi = \' >> DEP2a; \ + echo '$$(DEP_'"$${c}"'_coff) \' >> DEP2a; \ if [ x$${valid} = xyes ]; then \ - echo '$$(DEP_'"$${c}"'_ecoff) \' >> .dep2a; \ + echo '$$(DEP_'"$${c}"'_ecoff) \' >> DEP2a; \ else true; fi; \ - echo '$$(DEP_'"$${c}"'_elf)' >> .dep2a; \ + echo '$$(DEP_'"$${c}"'_elf)' >> DEP2a; \ else true; fi; \ done - mv -f .dep2a .dep2 + mv -f DEP2a DEP2 dep.sed: dep-in.sed config.status srcdir=`cd $(srcdir); pwd`; \ @@ -2421,19 +2465,19 @@ dep.sed: dep-in.sed config.status -e "s!@BFDDIR@!$${srcdir}/../bfd!" \ -e "s!@SRCDIR@!$${srcdir}!" -dep: .dep +dep: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile - cat .dep >> tmp-Makefile + cat DEP >> tmp-Makefile $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile -dep-in: .dep +dep-in: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in - cat .dep >> tmp-Makefile.in + cat DEP >> tmp-Makefile.in $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in -dep-am: .dep +dep-am: DEP sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am - cat .dep >> tmp-Makefile.am + cat DEP >> tmp-Makefile.am $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am .PHONY: dep dep-in dep-am @@ -2448,14 +2492,16 @@ atof-generic.o: atof-generic.c bignum-copy.o: bignum-copy.c cond.o: cond.c macro.h sb.h $(INCDIR)/obstack.h depend.o: depend.c -ecoff.o: ecoff.c +dwarf2dbg.o: dwarf2dbg.c dwarf2dbg.h subsegs.h $(INCDIR)/obstack.h \ + $(INCDIR)/elf/dwarf2.h +ecoff.o: ecoff.c ecoff.h ehopt.o: ehopt.c subsegs.h $(INCDIR)/obstack.h $(INCDIR)/elf/dwarf2.h expr.o: expr.c $(INCDIR)/obstack.h flonum-copy.o: flonum-copy.c flonum-konst.o: flonum-konst.c flonum-mult.o: flonum-mult.c frags.o: frags.c subsegs.h $(INCDIR)/obstack.h -hash.o: hash.c +hash.o: hash.c $(INCDIR)/obstack.h input-file.o: input-file.c input-file.h input-scrub.o: input-scrub.c input-file.h sb.h listing.o: listing.c input-file.h subsegs.h @@ -2469,9 +2515,13 @@ sb.o: sb.c sb.h stabs.o: stabs.c $(INCDIR)/obstack.h subsegs.h ecoff.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def subsegs.o: subsegs.c subsegs.h $(INCDIR)/obstack.h -symbols.o: symbols.c $(INCDIR)/obstack.h subsegs.h +symbols.o: symbols.c $(INCDIR)/obstack.h subsegs.h \ + struc-symbol.h write.o: write.c subsegs.h $(INCDIR)/obstack.h output-file.h gasp.o: gasp.c sb.h macro.h +itbl-ops.o: itbl-ops.c itbl-ops.h itbl-parse.h +e-i386aout.o: $(srcdir)/config/e-i386aout.c emul.h \ + emul-target.h e-i386coff.o: $(srcdir)/config/e-i386coff.c emul.h \ emul-target.h e-i386elf.o: $(srcdir)/config/e-i386elf.c emul.h emul-target.h @@ -2479,8 +2529,8 @@ e-mipsecoff.o: $(srcdir)/config/e-mipsecoff.c emul.h \ emul-target.h e-mipself.o: $(srcdir)/config/e-mipself.c emul.h emul-target.h $(OBJS): $(DEP_@target_cpu_type@_@obj_format@) -$(TARG_CPU_O): $(TCDEP_@target_cpu_type@_@obj_format@) -$(OBJ_FORMAT_O): $(OBJDEP_@target_cpu_type@_@obj_format@) +$(TARG_CPU_O): $(DEPTC_@target_cpu_type@_@obj_format@) +$(OBJ_FORMAT_O): $(DEPOBJ_@target_cpu_type@_@obj_format@) # IF YOU PUT ANYTHING HERE IT WILL GO AWAY # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/gas/NEWS b/gas/NEWS index 0844076..03f554c 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -2,13 +2,31 @@ Changes in 2.10: -Support for the Motorolla MCore 210 processor added. +Support for ATMEL AVR. -A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386 assembly -programs with intel syntax. +Support for IBM 370 ELF. Somewhat experimental. + +Support for numbers with suffixes. + +Added support for breaking to the end of repeat loops. + +Added support for parallel instruction syntax (DOUBLEBAR_PARALLEL). + +New .elseif pseudo-op added. + +New --fatal-warnings option. + +picoJava architecture support added. + +Motorola MCore 210 processor support added. + +A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386 +assembly programs with intel syntax. New pseudo-ops .func,.endfunc to aid in debugging user-written assembler code. +Added -gdwarf2 option to generate DWARF 2 debugging information. + Full 16-bit mode support for i386. Greatly improved instruction operand checking for i386. This change will @@ -22,6 +40,8 @@ Mitsubishi D30V support added. Texas Instruments c80 (tms320c80) support added. +i960 ELF support added. + Changes in 2.9: Texas Instruments c30 (tms320c30) support added. diff --git a/gas/aclocal.m4 b/gas/aclocal.m4 index 1c6d60c..4b4ca84 100644 --- a/gas/aclocal.m4 +++ b/gas/aclocal.m4 @@ -160,33 +160,75 @@ 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 +# serial 40 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" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| 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([AM_PROG_LD])dnl -AC_REQUIRE([AM_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_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 + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac # Check for any special flags to pass to ltconfig. -libtool_flags= +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 "$silent" = yes && libtool_flags="$libtool_flags --silent" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" 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" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext @@ -208,37 +250,41 @@ case "$host" in *-*-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*) - AM_SYS_LIBTOOL_CYGWIN +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; - +]) 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]) +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) -# Redirect the config.log output again, so that the ltconfig log is not -# clobbered by the next message. -exec 5>>./config.log -]) +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) -# AM_ENABLE_SHARED - implement the --enable-shared flag -# Usage: AM_ENABLE_SHARED[(DEFAULT)] +# 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(AM_ENABLE_SHARED, -[define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_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], +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case "$enableval" in @@ -256,26 +302,22 @@ no) enable_shared=no ;; IFS="$ac_save_ifs" ;; esac], -enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl ]) -# AM_DISABLE_SHARED - set the default shared flag to --disable-shared -AC_DEFUN(AM_DISABLE_SHARED, -[AM_ENABLE_SHARED(no)]) +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_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)] +# 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(AM_ENABLE_STATIC, -[define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_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], +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case "$enableval" in @@ -293,28 +335,73 @@ no) enable_static=no ;; IFS="$ac_save_ifs" ;; esac], -enable_static=AM_ENABLE_STATIC_DEFAULT)dnl +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +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, [dnl +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_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) -# AM_PROG_LD - find the path to the GNU or non-GNU linker -AC_DEFUN(AM_PROG_LD, +# 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]) +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. + # Accept absolute paths. changequote(,)dnl - /* | [A-Za-z]:\\*) + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' changequote([,])dnl - test -z "$LD" && LD="$ac_prog" - ;; + # 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 @@ -331,10 +418,10 @@ else fi AC_CACHE_VAL(ac_cv_path_LD, [if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -342,7 +429,7 @@ AC_CACHE_VAL(ac_cv_path_LD, 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 + test "$with_gnu_ld" != yes && break fi fi done @@ -357,11 +444,10 @@ 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_PROG_LD_GNU ]) -AC_DEFUN(AM_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 &5; then @@ -371,29 +457,31 @@ else fi]) ]) -# AM_PROG_NM - find the path to a BSD-compatible name lister -AC_DEFUN(AM_PROG_NM, +# 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 /usr/ucb /usr/ccs/bin $PATH /bin; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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" + 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" + ac_cv_path_NM="$ac_dir/nm -p" + break else - ac_cv_path_NM="$ac_dir/nm" + 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 - break fi done IFS="$ac_save_ifs" @@ -401,15 +489,85 @@ else 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) +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# 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, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + 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 + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# 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_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + 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 + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, diff --git a/gas/app.c b/gas/app.c index 2a8df3a..2613e74 100644 --- a/gas/app.c +++ b/gas/app.c @@ -1,5 +1,5 @@ /* This is the Assembler Pre-Processor - Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -34,10 +34,14 @@ #endif #endif +#ifdef TC_M68K /* Whether we are scrubbing in m68k MRI mode. This is different from flag_m68k_mri, because the two flags will be affected by the .mri pseudo-op at different times. */ static int scrub_m68k_mri; +#else +#define scrub_m68k_mri 0 +#endif /* The pseudo-op which switches in and out of MRI mode. See the comment in do_scrub_chars. */ @@ -68,6 +72,9 @@ static const char symbol_chars[] = #define LEX_IS_DOUBLEDASH_1ST 12 #endif #ifdef TC_M32R +#define DOUBLEBAR_PARALLEL +#endif +#ifdef DOUBLEBAR_PARALLEL #define LEX_IS_DOUBLEBAR_1ST 13 #endif #define IS_SYMBOL_COMPONENT(c) (lex[c] == LEX_IS_SYMBOL_COMPONENT) @@ -85,13 +92,11 @@ static int process_escape PARAMS ((int)); void do_scrub_begin (m68k_mri) - int m68k_mri; + int m68k_mri ATTRIBUTE_UNUSED; { const char *p; int c; - scrub_m68k_mri = m68k_mri; - lex[' '] = LEX_IS_WHITESPACE; lex['\t'] = LEX_IS_WHITESPACE; lex['\r'] = LEX_IS_WHITESPACE; @@ -99,11 +104,16 @@ do_scrub_begin (m68k_mri) lex[';'] = LEX_IS_LINE_SEPARATOR; lex[':'] = LEX_IS_COLON; +#ifdef TC_M68K + scrub_m68k_mri = m68k_mri; + if (! m68k_mri) +#endif { lex['"'] = LEX_IS_STRINGQUOTE; -#ifndef TC_HPPA +#if ! defined (TC_HPPA) && ! defined (TC_I370) + /* I370 uses single-quotes to delimit integer, float constants */ lex['\''] = LEX_IS_ONECHAR_QUOTE; #endif @@ -161,6 +171,7 @@ do_scrub_begin (m68k_mri) lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; } +#ifdef TC_M68K if (m68k_mri) { lex['\''] = LEX_IS_STRINGQUOTE; @@ -170,11 +181,12 @@ do_scrub_begin (m68k_mri) then it can't be used in an expression. */ lex['!'] = LEX_IS_LINE_COMMENT_START; } +#endif #ifdef TC_V850 lex['-'] = LEX_IS_DOUBLEDASH_1ST; #endif -#ifdef TC_M32R +#ifdef DOUBLEBAR_PARALLEL lex['|'] = LEX_IS_DOUBLEBAR_1ST; #endif #ifdef TC_D30V @@ -191,6 +203,7 @@ static char out_buf[20]; static int add_newlines; static char *saved_input; static int saved_input_len; +static char input_buffer[32 * 1024]; static const char *mri_state; static char mri_last_ch; @@ -208,7 +221,9 @@ struct app_save int add_newlines; char * saved_input; int saved_input_len; +#ifdef TC_M68K int scrub_m68k_mri; +#endif const char * mri_state; char mri_last_ch; #if defined TC_ARM && defined OBJ_ELF @@ -227,9 +242,17 @@ app_push () saved->out_string = out_string; memcpy (saved->out_buf, out_buf, sizeof (out_buf)); saved->add_newlines = add_newlines; - saved->saved_input = saved_input; - saved->saved_input_len = saved_input_len; + if (saved_input == NULL) + saved->saved_input = NULL; + else + { + saved->saved_input = xmalloc (saved_input_len); + memcpy (saved->saved_input, saved_input, saved_input_len); + saved->saved_input_len = saved_input_len; + } +#ifdef TC_M68K saved->scrub_m68k_mri = scrub_m68k_mri; +#endif saved->mri_state = mri_state; saved->mri_last_ch = mri_last_ch; #if defined TC_ARM && defined OBJ_ELF @@ -256,9 +279,19 @@ app_pop (arg) out_string = saved->out_string; memcpy (out_buf, saved->out_buf, sizeof (out_buf)); add_newlines = saved->add_newlines; - saved_input = saved->saved_input; - saved_input_len = saved->saved_input_len; + if (saved->saved_input == NULL) + saved_input = NULL; + else + { + assert (saved->saved_input_len <= (int) (sizeof input_buffer)); + memcpy (input_buffer, saved->saved_input, saved->saved_input_len); + saved_input = input_buffer; + saved_input_len = saved->saved_input_len; + free (saved->saved_input); + } +#ifdef TC_M68K scrub_m68k_mri = saved->scrub_m68k_mri; +#endif mri_state = saved->mri_state; mri_last_ch = saved->mri_last_ch; #if defined TC_ARM && defined OBJ_ELF @@ -308,7 +341,7 @@ process_escape (ch) int do_scrub_chars (get, tostart, tolen) - int (*get) PARAMS ((char **)); + int (*get) PARAMS ((char *, int)); char *tostart; int tolen; { @@ -336,7 +369,7 @@ do_scrub_chars (get, tostart, tolen) #ifdef TC_V850 12: After seeing a dash, looking for a second dash as a start of comment. #endif -#ifdef TC_M32R +#ifdef DOUBLEBAR_PARALLEL 13: After seeing a vertical bar, looking for a second vertical bar as a parallel expression seperator. #endif */ @@ -357,18 +390,15 @@ do_scrub_chars (get, tostart, tolen) /* This macro gets the next input character. */ -#define GET() \ - (from < fromend \ - ? * (unsigned char *) (from++) \ - : ((saved_input != NULL \ - ? (free (saved_input), \ - saved_input = NULL, \ - 0) \ - : 0), \ - fromlen = (*get) (&from), \ - fromend = from + fromlen, \ - (fromlen == 0 \ - ? EOF \ +#define GET() \ + (from < fromend \ + ? * (unsigned char *) (from++) \ + : (saved_input = NULL, \ + fromlen = (*get) (input_buffer, sizeof input_buffer), \ + from = input_buffer, \ + fromend = from + fromlen, \ + (fromlen == 0 \ + ? EOF \ : * (unsigned char *) (from++)))) /* This macro pushes a character back on the input stream. */ @@ -400,9 +430,10 @@ do_scrub_chars (get, tostart, tolen) } else { - fromlen = (*get) (&from); + fromlen = (*get) (input_buffer, sizeof input_buffer); if (fromlen == 0) return 0; + from = input_buffer; fromend = from + fromlen; } @@ -748,6 +779,21 @@ do_scrub_chars (get, tostart, tolen) break; } +#ifdef KEEP_WHITE_AROUND_COLON + if (lex[ch] == LEX_IS_COLON) + { + /* only keep this white if there's no white *after* the colon */ + ch2 = GET (); + UNGET (ch2); + if (!IS_WHITESPACE (ch2)) + { + state = 9; + UNGET (ch); + PUT (' '); + break; + } + } +#endif if (IS_COMMENT (ch) || ch == '/' || IS_LINE_SEPARATOR (ch)) @@ -818,11 +864,7 @@ do_scrub_chars (get, tostart, tolen) state = 10; /* Sp after symbol char */ goto recycle; case 11: - if (flag_m68k_mri -#ifdef LABELS_WITHOUT_COLONS - || 1 -#endif - ) + if (LABELS_WITHOUT_COLONS || flag_m68k_mri) state = 1; else { @@ -957,10 +999,14 @@ do_scrub_chars (get, tostart, tolen) #endif case LEX_IS_COLON: +#ifdef KEEP_WHITE_AROUND_COLON + state = 9; +#else if (state == 9 || state == 10) state = 3; else if (state != 3) state = 1; +#endif PUT (ch); break; @@ -1000,7 +1046,7 @@ do_scrub_chars (get, tostart, tolen) PUT ('\n'); break; #endif -#ifdef TC_M32R +#ifdef DOUBLEBAR_PARALLEL case LEX_IS_DOUBLEBAR_1ST: ch2 = GET(); if (ch2 != '|') @@ -1214,6 +1260,23 @@ do_scrub_chars (get, tostart, tolen) } else if (state == 10) { + if (ch == '\\') + { + /* Special handling for backslash: a backslash may + be the beginning of a formal parameter (of a + macro) following another symbol character, with + whitespace in between. If that is the case, we + output a space before the parameter. Strictly + speaking, correct handling depends upon what the + macro parameter expands into; if the parameter + expands into something which does not start with + an operand character, then we don't want to keep + the space. We don't have enough information to + make the right choice, so here we are making the + choice which is more likely to be correct. */ + PUT (' '); + } + state = 3; } PUT (ch); @@ -1232,23 +1295,12 @@ do_scrub_chars (get, tostart, tolen) processed. */ if (fromend > from) { - char *save; - - save = (char *) xmalloc (fromend - from); - memcpy (save, from, fromend - from); - if (saved_input != NULL) - free (saved_input); - saved_input = save; + saved_input = from; saved_input_len = fromend - from; } else - { - if (saved_input != NULL) - { - free (saved_input); - saved_input = NULL; - } - } + saved_input = NULL; + return to - tostart; } diff --git a/gas/as.c b/gas/as.c index 0cdd357..647f4be 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1,5 +1,5 @@ /* as.c - GAS main program. - Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright (C) 1987, 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -44,7 +44,9 @@ #include "sb.h" #include "macro.h" -#ifndef HAVE_ITBL_CPU +#ifdef HAVE_ITBL_CPU +#include "itbl-ops.h" +#else #define itbl_parse(itbl_file) 1 #define itbl_init() #endif @@ -109,92 +111,12 @@ struct itbl_file_list static struct itbl_file_list *itbl_files; -void -print_version_id () -{ - static int printed; - if (printed) - return; - printed = 1; - -#ifdef BFD_ASSEMBLER - fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s"), - VERSION, TARGET_ALIAS, BFD_VERSION); -#else - fprintf (stderr, _("GNU assembler version %s (%s)"), VERSION, TARGET_ALIAS); -#endif - fprintf (stderr, "\n"); -} - -static void -show_usage (stream) - FILE *stream; -{ - fprintf (stream, _("Usage: %s [option...] [asmfile...]\n"), myname); - - fprintf (stream, _("\ -Options:\n\ - -a[sub-option...] turn on listings\n\ - Sub-options [default hls]:\n\ - c omit false conditionals\n\ - d omit debugging directives\n\ - h include high-level source\n\ - l include assembly\n\ - m include macro expansions\n\ - n omit forms processing\n\ - s include symbols\n\ - =file set listing file name (must be last sub-option)\n")); - - fprintf (stream, _("\ - -D produce assembler debugging messages\n\ - --defsym SYM=VAL define symbol SYM to given value\n\ - -f skip whitespace and comment preprocessing\n\ - --gstabs generate stabs debugging information\n\ - --help show this message and exit\n\ - -I DIR add DIR to search list for .include directives\n\ - -J don't warn about signed overflow\n\ - -K warn when differences altered for long displacements\n\ - -L,--keep-locals keep local symbols (e.g. starting with `L')\n")); - - fprintf (stream, _("\ - -M,--mri assemble in MRI compatibility mode\n\ - --MD FILE write dependency information in FILE (default none)\n\ - -nocpp ignored\n\ - -o OBJFILE name the object-file output OBJFILE (default a.out)\n\ - -R fold data section into text section\n\ - --statistics print various measured statistics from execution\n\ - --strip-local-absolute strip local absolute symbols\n\ - --traditional-format Use same format as native assembler when possible\n\ - --version print assembler version number and exit\n\ - -W suppress warnings\n\ - --itbl INSTTBL extend instruction set to include instructions\n\ - matching the specifications defined in file INSTTBL\n\ - -w ignored\n\ - -X ignored\n\ - -Z generate object file even after errors\n")); - - fprintf (stream, _("\ - --listing-lhs-width set the width in words of the output data column of\n\ - the listing\n\ - --listing-lhs-width2 set the width in words of the continuation lines\n\ - of the output data column; ignored if smaller than\n\ - the width of the first line\n\ - --listing-rhs-width set the max width in characters of the lines from\n\ - the source file\n\ - --listing-cont-lines set the maximum number of continuation lines used\n\ - for the output data column of the listing\n")); - - md_show_usage (stream); - - fprintf (stream, _("\nReport bugs to bug-gnu-utils@gnu.org\n")); -} - #ifdef USE_EMULATIONS #define EMULATION_ENVIRON "AS_EMULATION" extern struct emulation mipsbelf, mipslelf, mipself; extern struct emulation mipsbecoff, mipslecoff, mipsecoff; -extern struct emulation i386coff, i386elf; +extern struct emulation i386coff, i386elf, i386aout; static struct emulation *const emulations[] = { EMULATIONS }; static const int n_emulations = sizeof (emulations) / sizeof (emulations[0]); @@ -276,6 +198,133 @@ common_emul_init () } #endif +void +print_version_id () +{ + static int printed; + if (printed) + return; + printed = 1; + +#ifdef BFD_ASSEMBLER + fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s"), + VERSION, TARGET_ALIAS, BFD_VERSION); +#else + fprintf (stderr, _("GNU assembler version %s (%s)"), VERSION, TARGET_ALIAS); +#endif + fprintf (stderr, "\n"); +} + +static void +show_usage (stream) + FILE *stream; +{ + fprintf (stream, _("Usage: %s [option...] [asmfile...]\n"), myname); + + fprintf (stream, _("\ +Options:\n\ + -a[sub-option...] turn on listings\n\ + Sub-options [default hls]:\n\ + c omit false conditionals\n\ + d omit debugging directives\n\ + h include high-level source\n\ + l include assembly\n\ + m include macro expansions\n\ + n omit forms processing\n\ + s include symbols\n\ + L include line debug statistics (if applicable)\n\ + =FILE list to FILE (must be last sub-option)\n")); + + fprintf (stream, _("\ + -D produce assembler debugging messages\n")); + fprintf (stream, _("\ + --defsym SYM=VAL define symbol SYM to given value\n")); +#ifdef USE_EMULATIONS + { + int i; + char *def_em; + + fprintf (stream, "\ + --em=["); + for (i = 0; i < n_emulations-1; i++) + fprintf (stream, "%s | ", emulations[i]->name); + fprintf (stream, "%s]\n", emulations[i]->name); + + def_em = getenv (EMULATION_ENVIRON); + if (!def_em) + def_em = DEFAULT_EMULATION; + fprintf (stream, _("\ + emulate output (default %s)\n"), def_em); + } +#endif + fprintf (stream, _("\ + -f skip whitespace and comment preprocessing\n")); + fprintf (stream, _("\ + --gstabs generate stabs debugging information\n")); + fprintf (stream, _("\ + --gdwarf2 generate DWARF2 debugging information\n")); + fprintf (stream, _("\ + --help show this message and exit\n")); + fprintf (stream, _("\ + -I DIR add DIR to search list for .include directives\n")); + fprintf (stream, _("\ + -J don't warn about signed overflow\n")); + fprintf (stream, _("\ + -K warn when differences altered for long displacements\n")); + fprintf (stream, _("\ + -L,--keep-locals keep local symbols (e.g. starting with `L')\n")); + fprintf (stream, _("\ + -M,--mri assemble in MRI compatibility mode\n")); + fprintf (stream, _("\ + --MD FILE write dependency information in FILE (default none)\n")); + fprintf (stream, _("\ + -nocpp ignored\n")); + fprintf (stream, _("\ + -o OBJFILE name the object-file output OBJFILE (default a.out)\n")); + fprintf (stream, _("\ + -R fold data section into text section\n")); + fprintf (stream, _("\ + --statistics print various measured statistics from execution\n")); + fprintf (stream, _("\ + --strip-local-absolute strip local absolute symbols\n")); + fprintf (stream, _("\ + --traditional-format Use same format as native assembler when possible\n")); + fprintf (stream, _("\ + --version print assembler version number and exit\n")); + fprintf (stream, _("\ + -W --no-warn suppress warnings\n")); + fprintf (stream, _("\ + --warn don't suppress warnings\n")); + fprintf (stream, _("\ + --fatal-warnings treat warnings as errors\n")); + fprintf (stream, _("\ + --itbl INSTTBL extend instruction set to include instructions\n\ + matching the specifications defined in file INSTTBL\n")); + fprintf (stream, _("\ + -w ignored\n")); + fprintf (stream, _("\ + -X ignored\n")); + fprintf (stream, _("\ + -Z generate object file even after errors\n")); + fprintf (stream, _("\ + --listing-lhs-width set the width in words of the output data column of\n\ + the listing\n")); + fprintf (stream, _("\ + --listing-lhs-width2 set the width in words of the continuation lines\n\ + of the output data column; ignored if smaller than\n\ + the width of the first line\n")); + fprintf (stream, _("\ + --listing-rhs-width set the max width in characters of the lines from\n\ + the source file\n")); + fprintf (stream, _("\ + --listing-cont-lines set the maximum number of continuation lines used\n\ + for the output data column of the listing\n")); + + md_show_usage (stream); + + fprintf (stream, _("\nReport bugs to bug-gnu-utils@gnu.org\n")); +} + /* * Since it is easy to do here we interpret the special arg "-" * to mean "use stdin" and we set that argv[] pointing to "". @@ -365,7 +414,14 @@ parse_args (pargc, pargv) #define OPTION_STRIP_LOCAL_ABSOLUTE (OPTION_STD_BASE + 15) {"strip-local-absolute", no_argument, NULL, OPTION_STRIP_LOCAL_ABSOLUTE}, #define OPTION_TRADITIONAL_FORMAT (OPTION_STD_BASE + 16) - {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT} + {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT}, +#define OPTION_GDWARF2 (OPTION_STD_BASE + 17) + {"gdwarf2", no_argument, NULL, OPTION_GDWARF2}, + {"no-warn", no_argument, NULL, 'W'}, +#define OPTION_WARN (OPTION_STD_BASE + 18) + {"warn", no_argument, NULL, OPTION_WARN}, +#define OPTION_WARN_FATAL (OPTION_STD_BASE + 19) + {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL} }; /* Construct the option lists from the standard list and the @@ -546,6 +602,10 @@ the GNU General Public License. This program has absolutely no warranty.\n")); debug_type = DEBUG_STABS; break; + case OPTION_GDWARF2: + debug_type = DEBUG_DWARF2; + break; + case 'J': flag_signed_overflow_ok = 1; break; @@ -594,6 +654,16 @@ the GNU General Public License. This program has absolutely no warranty.\n")); flag_no_warnings = 1; break; + case OPTION_WARN: + flag_no_warnings = 0; + flag_fatal_warnings = 0; + break; + + case OPTION_WARN_FATAL: + flag_no_warnings = 0; + flag_fatal_warnings = 1; + break; + case 'Z': flag_always_generate_output = 1; break; @@ -824,6 +894,9 @@ main (argc, argv) output_file_close (out_file_name); #endif + if (flag_fatal_warnings && had_warnings() > 0 && had_errors () == 0) + as_bad (_("%d warnings, treating warnings as errors"), had_warnings()); + if (had_errors () > 0 && ! flag_always_generate_output) keep_it = 0; @@ -940,9 +1013,9 @@ perform_an_assembly_pass (argc, argv) bfd_set_section_flags (stdoutput, text_section, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_READONLY)); - /* @@ FIXME -- SEC_CODE seems to mean code only, rather than code possibly.*/ bfd_set_section_flags (stdoutput, data_section, - applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)); + applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC + | SEC_DATA)); bfd_set_section_flags (stdoutput, bss_section, applicable & SEC_ALLOC); seg_info (bss_section)->bss = 1; subseg_new (BFD_ABS_SECTION_NAME, 0); diff --git a/gas/as.h b/gas/as.h index a72dfad..4c4658a 100644 --- a/gas/as.h +++ b/gas/as.h @@ -1,5 +1,5 @@ /* as.h - global header file - Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -417,9 +417,6 @@ COMMON int flag_keep_locals; /* -L */ /* True if we are assembling in MRI mode. */ COMMON int flag_mri; -/* True if we are assembling in m68k MRI mode. */ -COMMON int flag_m68k_mri; - /* Should the data section be made read-only and appended to the text section? */ COMMON unsigned char flag_readonly_data_in_text; /* -R */ @@ -427,6 +424,9 @@ COMMON unsigned char flag_readonly_data_in_text; /* -R */ /* True if warnings should be inhibited. */ COMMON int flag_no_warnings; /* -W */ +/* True if warnings count as errors. */ +COMMON int flag_fatal_warnings; /* --fatal-warnings */ + /* True if we should attempt to generate output even if non-fatal errors are detected. */ COMMON unsigned char flag_always_generate_output; /* -Z */ @@ -457,7 +457,7 @@ COMMON int linkrelax; extern int listing; /* Type of debugging information we should generate. We currently - only support stabs and ECOFF. */ + support stabs, ECOFF, and DWARF2. */ enum debug_info_type { @@ -557,9 +557,11 @@ void print_version_id PARAMS ((void)); char *app_push PARAMS ((void)); char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words)); char *input_scrub_include_file PARAMS ((char *filename, char *position)); +extern void input_scrub_insert_line PARAMS((const char *line)); +extern void input_scrub_insert_file PARAMS((char *path)); char *input_scrub_new_file PARAMS ((char *filename)); char *input_scrub_next_buffer PARAMS ((char **bufp)); -int do_scrub_chars PARAMS ((int (*get) (char **), char *to, int tolen)); +int do_scrub_chars PARAMS ((int (*get) (char *, int), char *to, int tolen)); int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision, long exponent_bits)); int had_err PARAMS ((void)); @@ -585,6 +587,7 @@ void subseg_set PARAMS ((segT seg, subsegT subseg)); #ifdef BFD_ASSEMBLER segT subseg_get PARAMS ((const char *, int)); #endif +int subseg_text_p PARAMS ((segT)); void start_dependencies PARAMS ((char *)); void register_dependency PARAMS ((char *)); @@ -592,13 +595,13 @@ void print_dependencies PARAMS ((void)); struct expressionS; struct fix; -struct symbol; +typedef struct symbol symbolS; struct relax_type; typedef struct frag fragS; #ifdef BFD_ASSEMBLER /* literal.c */ -valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int)); +valueT add_to_literal_pool PARAMS ((symbolS *, valueT, segT, int)); #endif int check_eh_frame PARAMS ((struct expressionS *, unsigned int *)); @@ -611,7 +614,6 @@ void eh_frame_convert_frag PARAMS ((fragS *)); /* this one starts the chain of target dependant headers */ #include "targ-env.h" -#include "struc-symbol.h" #include "write.h" #include "frags.h" #include "hash.h" @@ -626,6 +628,17 @@ void eh_frame_convert_frag PARAMS ((fragS *)); #endif #include "listing.h" +#ifdef TC_M68K +/* True if we are assembling in m68k MRI mode. */ +COMMON int flag_m68k_mri; +#else +#define flag_m68k_mri 0 +#endif + +#ifndef NUMBERS_WITH_SUFFIX +#define NUMBERS_WITH_SUFFIX 0 +#endif + #ifndef LOCAL_LABELS_DOLLAR #define LOCAL_LABELS_DOLLAR 0 #endif @@ -634,12 +647,30 @@ void eh_frame_convert_frag PARAMS ((fragS *)); #define LOCAL_LABELS_FB 0 #endif +#ifndef LABELS_WITHOUT_COLONS +#define LABELS_WITHOUT_COLONS 0 +#endif + +#ifndef NO_PSEUDO_DOT +#define NO_PSEUDO_DOT 0 +#endif + #ifndef TEXT_SECTION_NAME #define TEXT_SECTION_NAME ".text" #define DATA_SECTION_NAME ".data" #define BSS_SECTION_NAME ".bss" #endif +#ifndef OCTETS_PER_BYTE_POWER +#define OCTETS_PER_BYTE_POWER 0 +#endif +#ifndef OCTETS_PER_BYTE +#define OCTETS_PER_BYTE (1<fx_pcrel == !reloc->howto->pc_relative); - reloc->sym_ptr_ptr = & fixP->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy); /* Use fx_offset for these cases */ if ( fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY diff --git a/gas/cond.c b/gas/cond.c index 71a2a8e..025ca51 100644 --- a/gas/cond.c +++ b/gas/cond.c @@ -1,5 +1,5 @@ /* cond.c - conditional assembly pseudo-ops, and .include - Copyright (C) 1990, 91, 92, 93, 95, 96, 97, 1998 + Copyright (C) 1990, 91, 92, 93, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -64,7 +64,7 @@ s_ifdef (arg) int arg; { register char *name; /* points to name of symbol */ - register struct symbol *symbolP; /* Points to symbol */ + register symbolS *symbolP; /* Points to symbol */ struct conditional_frame cframe; SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */ @@ -247,9 +247,89 @@ s_ifc (arg) } void -s_endif (arg) +s_elseif (arg) int arg; { + expressionS operand; + int t; + + if (current_cframe == NULL) + { + as_bad (_("\".elseif\" without matching \".if\" - ignored")); + + } + else if (current_cframe->else_seen) + { + as_bad (_("\".elseif\" after \".else\" - ignored")); + as_bad_where (current_cframe->else_file_line.file, + current_cframe->else_file_line.line, + _("here is the previous \"else\"")); + as_bad_where (current_cframe->if_file_line.file, + current_cframe->if_file_line.line, + _("here is the previous \"if\"")); + } + else + { + as_where (¤t_cframe->else_file_line.file, + ¤t_cframe->else_file_line.line); + + if (!current_cframe->dead_tree) + { + current_cframe->ignoring = !current_cframe->ignoring; + if (LISTING_SKIP_COND ()) + { + if (! current_cframe->ignoring) + listing_list (1); + else + listing_list (2); + } + } /* if not a dead tree */ + } /* if error else do it */ + + + SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */ + + if (current_cframe != NULL && current_cframe->ignoring) + { + operand.X_add_number = 0; + while (! is_end_of_line[(unsigned char) *input_line_pointer]) + ++input_line_pointer; + } + else + { + expression (&operand); + if (operand.X_op != O_constant) + as_bad (_("non-constant expression in \".elseif\" statement")); + } + + switch ((operatorT) arg) + { + case O_eq: t = operand.X_add_number == 0; break; + case O_ne: t = operand.X_add_number != 0; break; + case O_lt: t = operand.X_add_number < 0; break; + case O_le: t = operand.X_add_number <= 0; break; + case O_ge: t = operand.X_add_number >= 0; break; + case O_gt: t = operand.X_add_number > 0; break; + default: + abort (); + return; + } + + current_cframe->ignoring = current_cframe->dead_tree || ! t; + + if (LISTING_SKIP_COND () + && current_cframe->ignoring + && (current_cframe->previous_cframe == NULL + || ! current_cframe->previous_cframe->ignoring)) + listing_list (2); + + demand_empty_rest_of_line (); +} + +void +s_endif (arg) + int arg ATTRIBUTE_UNUSED; +{ struct conditional_frame *hold; if (current_cframe == NULL) @@ -280,7 +360,7 @@ s_endif (arg) void s_else (arg) - int arg; + int arg ATTRIBUTE_UNUSED; { if (current_cframe == NULL) { @@ -372,11 +452,7 @@ ignore_input () s = input_line_pointer; - if (flag_m68k_mri -#ifdef NO_PSEUDO_DOT - || 1 -#endif - ) + if (NO_PSEUDO_DOT || flag_m68k_mri) { if (s[-1] != '.') --s; diff --git a/gas/config/atof-ieee.c b/gas/config/atof-ieee.c index d586e3a..dcda1bc 100644 --- a/gas/config/atof-ieee.c +++ b/gas/config/atof-ieee.c @@ -1,5 +1,5 @@ /* atof_ieee.c - turn a Flonum into an IEEE floating point number - Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -160,7 +160,7 @@ make_invalid_floating_point_number (words) char * atof_ieee (str, what_kind, words) char *str; /* Text to convert to binary. */ - char what_kind; /* 'd', 'f', 'g', 'h' */ + int what_kind; /* 'd', 'f', 'g', 'h' */ LITTLENUM_TYPE *words; /* Build the binary here. */ { /* Extra bits for zeroed low-order bits. The 1st MAX_PRECISION are @@ -460,7 +460,7 @@ gen_to_words (words, precision, exponent_bits) /* Bigger than one littlenum */ num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits; *lp++ = word1; - if (num_bits + exponent_bits + 1 >= precision * LITTLENUM_NUMBER_OF_BITS) + if (num_bits + exponent_bits + 1 > precision * LITTLENUM_NUMBER_OF_BITS) { /* Exponent overflow */ make_invalid_floating_point_number (words); @@ -501,7 +501,7 @@ gen_to_words (words, precision, exponent_bits) if (next_bits (1)) { --lp; - if (prec_bits > LITTLENUM_NUMBER_OF_BITS) + if (prec_bits >= LITTLENUM_NUMBER_OF_BITS) { int n = 0; int tmp_bits; @@ -515,7 +515,19 @@ gen_to_words (words, precision, exponent_bits) --n; tmp_bits -= LITTLENUM_NUMBER_OF_BITS; } - if (tmp_bits > LITTLENUM_NUMBER_OF_BITS || (lp[n] & mask[tmp_bits]) != mask[tmp_bits]) + if (tmp_bits > LITTLENUM_NUMBER_OF_BITS + || (lp[n] & mask[tmp_bits]) != mask[tmp_bits] + || (prec_bits != (precision * LITTLENUM_NUMBER_OF_BITS + - exponent_bits - 1) +#ifdef TC_I386 + /* An extended precision float with only the integer + bit set would be invalid. That must be converted + to the smallest normalized number. */ + && !(precision == X_PRECISION + && prec_bits == (precision * LITTLENUM_NUMBER_OF_BITS + - exponent_bits - 2)) +#endif + )) { unsigned long carry; @@ -539,11 +551,18 @@ gen_to_words (words, precision, exponent_bits) << ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits)); *lp++ = word1; +#ifdef TC_I386 + /* Set the integer bit in the extended precision format. + This cannot happen on the m68k where the mantissa + just overflows into the integer bit above. */ + if (precision == X_PRECISION) + *lp++ = 1 << (LITTLENUM_NUMBER_OF_BITS - 1); +#endif while (lp < words_end) *lp++ = 0; } } - else if ((*lp & mask[prec_bits]) != mask[prec_bits]) + else *lp += 1; } diff --git a/gas/config/atof-vax.c b/gas/config/atof-vax.c index 45b90a8..76ff078 100644 --- a/gas/config/atof-vax.c +++ b/gas/config/atof-vax.c @@ -1,5 +1,6 @@ /* atof_vax.c - turn a Flonum into a VAX floating point number - Copyright (C) 1987, 1992, 93, 95, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1987, 1992, 93, 95, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -260,7 +261,7 @@ atof_vax (str, what_kind, words) int /* 0: OK. */ flonum_gen2vax (format_letter, f, words) - char format_letter; /* One of 'd' 'f' 'g' 'h'. */ + int format_letter; /* One of 'd' 'f' 'g' 'h'. */ FLONUM_TYPE *f; LITTLENUM_TYPE *words; /* Deliver answer here. */ { @@ -511,7 +512,7 @@ md_atof (what_statement_type, literalP, sizeP) }; *sizeP = number_of_chars; - return kind_of_float ? 0 : _("Bad call to md_atof()"); + return kind_of_float ? NULL : _("Bad call to md_atof()"); } /* end of atof-vax.c */ diff --git a/gas/config/e-i386aout.c b/gas/config/e-i386aout.c new file mode 100644 index 0000000..18fdf68 --- /dev/null +++ b/gas/config/e-i386aout.c @@ -0,0 +1,17 @@ +#include "as.h" +#include "emul.h" + +static const char * +i386aout_bfd_name () +{ + abort (); + return NULL; +} + +#define emul_bfd_name i386aout_bfd_name +#define emul_format &aout_format_ops + +#define emul_name "i386aout" +#define emul_struct_name i386aout +#define emul_default_endian 0 +#include "emul-target.h" diff --git a/gas/config/go32.cfg b/gas/config/go32.cfg deleted file mode 100644 index 4059395..0000000 --- a/gas/config/go32.cfg +++ /dev/null @@ -1,93 +0,0 @@ -/* config.h for go32 */ - -#define I386COFF 1 - -/* 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 and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - -/* Define as __inline if that's what the C compiler calls it. */ -#undef inline - -/* 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 - -/* Should gas use high-level BFD interfaces? */ -#undef BFD_ASSEMBLER - -/* If we aren't doing cross-assembling, some operations can be optimized, - since byte orders and value sizes don't need to be adjusted. */ -#undef CROSS_COMPILE - -/* Some gas code wants to know these parameters. */ -#define TARGET_ALIAS "i386" -#define TARGET_CPU "i386" -#define TARGET_CANONICAL "i386-i386" -#define TARGET_OS "djgpp" -#define TARGET_VENDOR "djgpp" - -/* Some operating systems, for example DOS, require the use of "wb" mode when - opening a binary file for writing. If only "w" is used, the file will not - be correct. However, some other systems reject such a mode. This indicates - which ../include/fopen-*.h header file we want to include, so that we can - get macros that'll do the right thing for this system. */ -#define WANT_FOPEN_BIN 1 - -/* Sometimes the system header files don't declare malloc and realloc. */ -#undef NEED_DECLARATION_MALLOC - -/* Sometimes the system header files don't declare free. */ -#undef NEED_DECLARATION_FREE - -/* Sometimes errno.h doesn't declare errno itself. */ -#undef NEED_DECLARATION_ERRNO - -#define MANY_SEGMENTS 1 - -/* Needed only for sparc configuration */ -#undef sparcv9 - -/* Define if you have the remove function. */ -#define HAVE_REMOVE 1 - -/* Define if you have the unlink function. */ -#define HAVE_UNLINK 1 - -/* Define if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -#undef HAVE_VARARGS_H diff --git a/gas/config/m68k-parse.h b/gas/config/m68k-parse.h index e131342..cdb5f60 100644 --- a/gas/config/m68k-parse.h +++ b/gas/config/m68k-parse.h @@ -1,5 +1,6 @@ /* m68k-parse.h -- header file for m68k assembler - Copyright (C) 1987, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1987, 91, 92, 93, 94, 95, 96, 1999 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -83,6 +84,9 @@ enum m68k_register ZPC, /* Hack for Program space, but 0 addressing */ SR, /* Status Reg */ CCR, /* Condition code Reg */ + ACC, /* Accumulator Reg */ + MACSR, /* MAC Status Reg */ + MASK, /* Modulus Reg */ /* These have to be grouped together for the movec instruction to work. */ USP, /* User Stack Pointer */ @@ -165,6 +169,44 @@ enum m68k_register ZADDR5, ZADDR6, ZADDR7, + + /* Upper and lower half of data and address registers. Order *must* + be DATAxL, ADDRxL, DATAxU, ADDRxU. */ + DATA0L, /* lower half of data registers */ + DATA1L, + DATA2L, + DATA3L, + DATA4L, + DATA5L, + DATA6L, + DATA7L, + + ADDR0L, /* lower half of address registers */ + ADDR1L, + ADDR2L, + ADDR3L, + ADDR4L, + ADDR5L, + ADDR6L, + ADDR7L, + + DATA0U, /* upper half of data registers */ + DATA1U, + DATA2U, + DATA3U, + DATA4U, + DATA5U, + DATA6U, + DATA7U, + + ADDR0U, /* upper half of address registers */ + ADDR1U, + ADDR2U, + ADDR3U, + ADDR4U, + ADDR5U, + ADDR6U, + ADDR7U, }; /* Size information. */ diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c index b519347..eabbe92 100644 --- a/gas/config/obj-aout.c +++ b/gas/config/obj-aout.c @@ -1,5 +1,5 @@ /* a.out object file format - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1996 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -14,9 +14,12 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 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. */ +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. */ + +#define OBJ_HEADER "obj-aout.h" #include "as.h" #ifdef BFD_ASSEMBLER @@ -66,7 +69,7 @@ static void obj_aout_line PARAMS ((int)); static void obj_aout_weak PARAMS ((int)); static void obj_aout_type PARAMS ((int)); -const pseudo_typeS obj_pseudo_table[] = +const pseudo_typeS aout_pseudo_table[] = { {"line", obj_aout_line, 0}, /* source code line number */ {"ln", obj_aout_line, 0}, /* coff line number that we use anyway */ @@ -93,8 +96,8 @@ const pseudo_typeS obj_pseudo_table[] = /* other stuff */ {"ABORT", s_abort, 0}, - {NULL} /* end sentinel */ -}; /* obj_pseudo_table */ + {NULL, NULL, 0} /* end sentinel */ +}; /* aout_pseudo_table */ #ifdef BFD_ASSEMBLER @@ -108,18 +111,21 @@ obj_aout_frob_symbol (sym, punt) asection *sec; int desc, type, other; - flags = sym->bsym->flags; - desc = S_GET_DESC (sym); - type = S_GET_TYPE (sym); - other = S_GET_OTHER (sym); - sec = sym->bsym->section; + flags = symbol_get_bfdsym (sym)->flags; + desc = aout_symbol (symbol_get_bfdsym (sym))->desc; + type = aout_symbol (symbol_get_bfdsym (sym))->type; + other = aout_symbol (symbol_get_bfdsym (sym))->other; + sec = S_GET_SEGMENT (sym); /* Only frob simple symbols this way right now. */ if (! (type & ~ (N_TYPE | N_EXT))) { if (type == (N_UNDF | N_EXT) && sec == &bfd_abs_section) - sym->bsym->section = sec = bfd_und_section_ptr; + { + sec = bfd_und_section_ptr; + S_SET_SEGMENT (sym, sec); + } if ((type & N_TYPE) != N_INDR && (type & N_TYPE) != N_SETA @@ -141,7 +147,7 @@ obj_aout_frob_symbol (sym, punt) case N_SETB: /* Set the debugging flag for constructor symbols so that BFD leaves them alone. */ - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; /* You can't put a common symbol in a set. The way a set element works is that the symbol has a definition and a @@ -164,29 +170,29 @@ obj_aout_frob_symbol (sym, punt) break; case N_INDR: /* Put indirect symbols in the indirect section. */ - sym->bsym->section = bfd_ind_section_ptr; - sym->bsym->flags |= BSF_INDIRECT; + S_SET_SEGMENT (sym, bfd_ind_section_ptr); + symbol_get_bfdsym (sym)->flags |= BSF_INDIRECT; if (type & N_EXT) { - sym->bsym->flags |= BSF_EXPORT; - sym->bsym->flags &=~ BSF_LOCAL; + symbol_get_bfdsym (sym)->flags |= BSF_EXPORT; + symbol_get_bfdsym (sym)->flags &=~ BSF_LOCAL; } break; case N_WARNING: /* Mark warning symbols. */ - sym->bsym->flags |= BSF_WARNING; + symbol_get_bfdsym (sym)->flags |= BSF_WARNING; break; } } else { - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; } - S_SET_TYPE (sym, type); + aout_symbol (symbol_get_bfdsym (sym))->type = type; /* Double check weak symbols. */ - if (sym->bsym->flags & BSF_WEAK) + if (S_IS_WEAK (sym)) { if (S_IS_COMMON (sym)) as_bad (_("Symbol `%s' can not be both weak and common"), @@ -215,7 +221,7 @@ obj_aout_frob_file () assert (x == true); } -#else +#else /* ! BFD_ASSEMBLER */ /* Relocation. */ @@ -291,7 +297,7 @@ obj_header_append (where, headers) #endif /* CROSS_COMPILE */ } -#endif +#endif /* ! defined (obj_header_append) */ void obj_symbol_to_chars (where, symbolP) @@ -416,9 +422,17 @@ obj_aout_type (ignore) { ++input_line_pointer; if (strncmp (input_line_pointer, "object", 6) == 0) +#ifdef BFD_ASSEMBLER + aout_symbol (symbol_get_bfdsym (sym))->other = 1; +#else S_SET_OTHER (sym, 1); +#endif else if (strncmp (input_line_pointer, "function", 8) == 0) +#ifdef BFD_ASSEMBLER + aout_symbol (symbol_get_bfdsym (sym))->other = 2; +#else S_SET_OTHER (sym, 2); +#endif } } } @@ -427,11 +441,6 @@ obj_aout_type (ignore) s_ignore (0); } -void -obj_read_begin_hook () -{ -} - #ifndef BFD_ASSEMBLER void @@ -508,7 +517,7 @@ obj_crawl_symbol_chain (headers) } else /* .Stabd case. */ symbolP->sy_name_offset = 0; - symbolPP = &(symbol_next (symbolP)); + symbolPP = &symbolP->sy_next; } else { @@ -626,4 +635,58 @@ DEFUN_VOID (s_sect) #endif /* ! BFD_ASSEMBLER */ +#ifdef BFD_ASSEMBLER + +/* Support for an AOUT emulation. */ + +static void aout_pop_insert PARAMS ((void)); +static int obj_aout_s_get_other PARAMS ((symbolS *)); +static int obj_aout_s_get_desc PARAMS ((symbolS *)); + +static void +aout_pop_insert () +{ + pop_insert (aout_pseudo_table); +} + +static int +obj_aout_s_get_other (sym) + symbolS *sym; +{ + return aout_symbol (symbol_get_bfdsym (sym))->other; +} + +static int +obj_aout_s_get_desc (sym) + symbolS *sym; +{ + return aout_symbol (symbol_get_bfdsym (sym))->desc; +} + + +const struct format_ops aout_format_ops = +{ + bfd_target_aout_flavour, + 1, /* dfl_leading_underscore */ + 0, /* emit_section_symbols */ + obj_aout_frob_symbol, + obj_aout_frob_file, + 0, /* frob_file_after_relocs */ + 0, /* s_get_size */ + 0, /* s_set_size */ + 0, /* s_get_align */ + 0, /* s_set_align */ + obj_aout_s_get_other, + obj_aout_s_get_desc, + 0, /* copy_symbol_attributes */ + 0, /* generate_asm_lineno */ + 0, /* process_stab */ + 0, /* sec_sym_ok_for_reloc */ + aout_pop_insert, + 0, /* ecoff_set_ext */ + 0, /* read_begin_hook */ + 0 /* symbol_new_hook */ +}; +#endif BFD_ASSEMBLER + /* end of obj-aout.c */ diff --git a/gas/config/obj-aout.h b/gas/config/obj-aout.h index 339070e..d08302a 100644 --- a/gas/config/obj-aout.h +++ b/gas/config/obj-aout.h @@ -1,5 +1,5 @@ /* obj-aout.h, a.out object file format for gas, the assembler. - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1998 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -51,6 +51,12 @@ extern const segT N_TYPE_seg[]; #endif /* ! BFD_ASSEMBLER */ +extern const pseudo_typeS aout_pseudo_table[]; + +#ifndef obj_pop_insert +#define obj_pop_insert() pop_insert (aout_pseudo_table) +#endif + /* SYMBOL TABLE */ /* Symbol table entry data type */ @@ -60,18 +66,24 @@ typedef struct nlist obj_symbol_type; /* Symbol table entry */ #ifdef BFD_ASSEMBLER -#define S_SET_OTHER(S,V) (aout_symbol((S)->bsym)->other = (V)) -#define S_SET_TYPE(S,T) (aout_symbol((S)->bsym)->type = (T)) -#define S_SET_DESC(S,D) (aout_symbol((S)->bsym)->desc = (D)) -#define S_GET_OTHER(S) (aout_symbol((S)->bsym)->other) -#define S_GET_TYPE(S) (aout_symbol((S)->bsym)->type) -#define S_GET_DESC(S) (aout_symbol((S)->bsym)->desc) +#define S_SET_OTHER(S,V) \ + (aout_symbol (symbol_get_bfdsym (S))->other = (V)) +#define S_SET_TYPE(S,T) \ + (aout_symbol (symbol_get_bfdsym (S))->type = (T)) +#define S_SET_DESC(S,D) \ + (aout_symbol (symbol_get_bfdsym (S))->desc = (D)) +#define S_GET_OTHER(S) \ + (aout_symbol (symbol_get_bfdsym (S))->other) +#define S_GET_TYPE(S) \ + (aout_symbol (symbol_get_bfdsym (S))->type) +#define S_GET_DESC(S) \ + (aout_symbol (symbol_get_bfdsym (S))->desc) asection *text_section, *data_section, *bss_section; #define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT) #define obj_frob_file() obj_aout_frob_file () -extern void obj_aout_frob_symbol PARAMS ((struct symbol *, int *)); +extern void obj_aout_frob_symbol PARAMS ((symbolS *, int *)); extern void obj_aout_frob_file PARAMS ((void)); #define obj_sec_sym_ok_for_reloc(SEC) (1) @@ -230,6 +242,7 @@ void tc_aout_fix_to_chars PARAMS ((char *where, struct fix *fixP, relax_addressT #endif +#define obj_read_begin_hook() {;} #define obj_symbol_new_hook(s) {;} #define EMIT_SECTION_SYMBOLS 0 diff --git a/gas/config/obj-bout.c b/gas/config/obj-bout.c index c9b80f5..dc79718 100644 --- a/gas/config/obj-bout.c +++ b/gas/config/obj-bout.c @@ -14,9 +14,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR 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. */ + 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. */ #include "as.h" #include "obstack.h" diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index 5639fbe..d750868 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1,5 +1,5 @@ /* coff object file format - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS. @@ -32,8 +32,24 @@ static void obj_coff_bss PARAMS ((int)); const char *s_get_name PARAMS ((symbolS * s)); -static symbolS *def_symbol_in_progress; +static void obj_coff_ln PARAMS ((int)); +static void obj_coff_def PARAMS ((int)); +static void obj_coff_endef PARAMS ((int)); +static void obj_coff_dim PARAMS ((int)); +static void obj_coff_line PARAMS ((int)); +static void obj_coff_size PARAMS ((int)); +static void obj_coff_scl PARAMS ((int)); +static void obj_coff_tag PARAMS ((int)); +static void obj_coff_val PARAMS ((int)); +static void obj_coff_type PARAMS ((int)); +static void obj_coff_ident PARAMS ((int)); +#ifdef BFD_ASSEMBLER +static void obj_coff_loc PARAMS((int)); +#endif +/* This is used to hold the symbol built by a sequence of pseudo-ops + from .def and .endef. */ +static symbolS *def_symbol_in_progress; /* stack stuff */ typedef struct @@ -171,7 +187,7 @@ tag_find_or_make (name) static void obj_coff_bss (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (*input_line_pointer == '\n') subseg_new (".bss", get_absolute_expression ()); @@ -183,7 +199,7 @@ obj_coff_bss (ignore) static void obj_coff_weak (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -249,8 +265,8 @@ SA_SET_SYM_ENDNDX (sym, val) { combined_entry_type *entry, *p; - entry = &coffsymbol (sym->bsym)->native[1]; - p = coffsymbol (val->bsym)->native; + entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1]; + p = coffsymbol (symbol_get_bfdsym (val))->native; entry->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = p; entry->fix_end = 1; } @@ -262,8 +278,8 @@ SA_SET_SYM_TAGNDX (sym, val) { combined_entry_type *entry, *p; - entry = &coffsymbol (sym->bsym)->native[1]; - p = coffsymbol (val->bsym)->native; + entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1]; + p = coffsymbol (symbol_get_bfdsym (val))->native; entry->u.auxent.x_sym.x_tagndx.p = p; entry->fix_tag = 1; } @@ -272,7 +288,7 @@ static int S_GET_DATA_TYPE (sym) symbolS *sym; { - return coffsymbol (sym->bsym)->native->u.syment.n_type; + return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type; } int @@ -280,7 +296,7 @@ S_SET_DATA_TYPE (sym, val) symbolS *sym; int val; { - coffsymbol (sym->bsym)->native->u.syment.n_type = val; + coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type = val; return val; } @@ -288,7 +304,7 @@ int S_GET_STORAGE_CLASS (sym) symbolS *sym; { - return coffsymbol (sym->bsym)->native->u.syment.n_sclass; + return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass; } int @@ -296,7 +312,7 @@ S_SET_STORAGE_CLASS (sym, val) symbolS *sym; int val; { - coffsymbol (sym->bsym)->native->u.syment.n_sclass = val; + coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass = val; return val; } @@ -334,12 +350,14 @@ c_dot_file_symbol (filename) { symbolS *symbolP; + /* BFD converts filename to a .file symbol with an aux entry. It + also handles chaining. */ symbolP = symbol_new (filename, bfd_abs_section_ptr, 0, &zero_address_frag); S_SET_STORAGE_CLASS (symbolP, C_FILE); S_SET_NUMBER_AUXILIARY (symbolP, 1); - symbolP->bsym->flags = BSF_DEBUGGING; + symbol_get_bfdsym (symbolP)->flags = BSF_DEBUGGING; #ifndef NO_LISTING { @@ -385,7 +403,7 @@ coff_obj_symbol_new_hook (symbolP) char * s = (char *) xmalloc (sz); memset (s, 0, sz); - coffsymbol (symbolP->bsym)->native = (combined_entry_type *) s; + coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s; S_SET_DATA_TYPE (symbolP, T_NULL); S_SET_STORAGE_CLASS (symbolP, 0); @@ -420,6 +438,12 @@ add_lineno (frag, offset, num) { abort (); } + if (num <= 0) + { + /* Zero is used as an end marker in the file. */ + as_warn (_("Line numbers must be positive integers\n")); + num = 1; + } new_line->next = line_nos; new_line->frag = frag; new_line->l.line_number = num; @@ -434,7 +458,8 @@ coff_add_linesym (sym) { if (line_nos) { - coffsymbol (current_lineno_sym->bsym)->lineno = (alent *) line_nos; + coffsymbol (symbol_get_bfdsym (current_lineno_sym))->lineno = + (alent *) line_nos; coff_n_line_nos++; line_nos = 0; } @@ -479,6 +504,84 @@ obj_coff_ln (appline) demand_empty_rest_of_line (); } +/* .loc is essentially the same as .ln; parse it for assembler + compatibility. */ + +static void +obj_coff_loc (ignore) + int ignore ATTRIBUTE_UNUSED; +{ + int lineno; + + /* FIXME: Why do we need this check? We need it for ECOFF, but why + do we need it for COFF? */ + if (now_seg != text_section) + { + as_warn (_(".loc outside of .text")); + demand_empty_rest_of_line (); + return; + } + + if (def_symbol_in_progress != NULL) + { + as_warn (_(".loc pseudo-op inside .def/.endef: ignored.")); + demand_empty_rest_of_line (); + return; + } + + /* Skip the file number. */ + SKIP_WHITESPACE (); + get_absolute_expression (); + SKIP_WHITESPACE (); + + lineno = get_absolute_expression (); + +#ifndef NO_LISTING + { + extern int listing; + + if (listing) + { + lineno += coff_line_base - 1; + listing_source_line (lineno); + } + } +#endif + + demand_empty_rest_of_line (); + + add_lineno (frag_now, frag_now_fix (), lineno); +} + +/* Handle the .ident pseudo-op. */ + +static void +obj_coff_ident (ignore) + int ignore ATTRIBUTE_UNUSED; +{ + segT current_seg = now_seg; + subsegT current_subseg = now_subseg; + +#ifdef TE_PE + { + segT sec; + + /* We could put it in .comment, but that creates an extra section + that shouldn't be loaded into memory, which requires linker + changes... For now, until proven otherwise, use .rdata. */ + sec = subseg_new (".rdata$zzz", 0); + bfd_set_section_flags (stdoutput, sec, + ((SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA) + & bfd_applicable_section_flags (stdoutput))); + } +#else + subseg_new (".comment", 0); +#endif + + stringer (1); + subseg_set (current_seg, current_subseg); +} + /* * def() * @@ -500,7 +603,7 @@ obj_coff_ln (appline) static void obj_coff_def (what) - int what; + int what ATTRIBUTE_UNUSED; { char name_end; /* Char after the end of name */ char *symbol_name; /* Name of the debug symbol */ @@ -532,7 +635,7 @@ obj_coff_def (what) /* Initialize the new symbol */ def_symbol_in_progress = symbol_make (symbol_name_copy); - def_symbol_in_progress->sy_frag = &zero_address_frag; + symbol_set_frag (def_symbol_in_progress, &zero_address_frag); S_SET_VALUE (def_symbol_in_progress, 0); if (S_IS_STRING (def_symbol_in_progress)) @@ -547,7 +650,7 @@ unsigned int dim_index; static void obj_coff_endef (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { symbolS *symbolP; @@ -585,15 +688,31 @@ obj_coff_endef (ignore) CONST char *name; S_SET_SEGMENT (def_symbol_in_progress, text_section); - name = bfd_asymbol_name (def_symbol_in_progress->bsym); - if (name[1] == 'b' && name[2] == 'f') - { - if (! in_function ()) - as_warn (_("`%s' symbol without preceding function"), name); -/* SA_SET_SYM_LNNO (def_symbol_in_progress, 12345);*/ - /* Will need relocating */ - SF_SET_PROCESS (def_symbol_in_progress); - clear_function (); + name = S_GET_NAME (def_symbol_in_progress); + if (name[0] == '.' && name[2] == 'f' && name[3] == '\0') + { + switch (name[1]) + { + case 'b': + /* .bf */ + if (! in_function ()) + as_warn (_("`%s' symbol without preceding function"), name); + /* Will need relocating. */ + SF_SET_PROCESS (def_symbol_in_progress); + clear_function (); + break; +#ifdef TE_PE + case 'e': + /* .ef */ + /* The MS compilers output the actual endline, not the + function-relative one... we want to match without + changing the assembler input. */ + SA_SET_SYM_LNNO (def_symbol_in_progress, + (SA_GET_SYM_LNNO (def_symbol_in_progress) + + coff_line_base)); + break; +#endif + } } } break; @@ -638,7 +757,10 @@ obj_coff_endef (ignore) /* Now that we have built a debug symbol, try to find if we should merge with an existing symbol or not. If a symbol is C_EFCN or - SEG_ABSOLUTE or untagged SEG_DEBUG it never merges. */ + absolute_section or untagged SEG_DEBUG it never merges. We also + don't merge labels, which are in a different namespace, nor + symbols which have not yet been defined since they are typically + unique, nor do we merge tags with non-tags. */ /* Two cases for functions. Either debug followed by definition or definition followed by debug. For definition first, we will @@ -653,16 +775,24 @@ obj_coff_endef (ignore) time. */ if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN + || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_LABEL || (!strcmp (bfd_get_section_name (stdoutput, S_GET_SEGMENT (def_symbol_in_progress)), "*DEBUG*") && !SF_GET_TAG (def_symbol_in_progress)) || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section - || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP)) == NULL) + || ! symbol_constant_p (def_symbol_in_progress) + || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), + DO_NOT_STRIP)) == NULL + || SF_GET_TAG (def_symbol_in_progress) != SF_GET_TAG (symbolP)) { + /* If it already is at the end of the symbol list, do nothing */ if (def_symbol_in_progress != symbol_lastP) - symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, - &symbol_lastP); + { + symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP); + symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, + &symbol_lastP); + } } else { @@ -727,7 +857,7 @@ obj_coff_endef (ignore) static void obj_coff_dim (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int dim_index; @@ -767,7 +897,7 @@ obj_coff_dim (ignore) static void obj_coff_line (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int this_base; @@ -783,7 +913,7 @@ obj_coff_line (ignore) coff_line_base = this_base; S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1); - SA_SET_SYM_LNNO (def_symbol_in_progress, coff_line_base); + SA_SET_SYM_LNNO (def_symbol_in_progress, this_base); demand_empty_rest_of_line (); @@ -793,14 +923,14 @@ obj_coff_line (ignore) extern int listing; if (listing) - listing_source_line ((unsigned int) coff_line_base); + listing_source_line ((unsigned int) this_base); } #endif } static void obj_coff_size (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -816,7 +946,7 @@ obj_coff_size (ignore) static void obj_coff_scl (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -831,7 +961,7 @@ obj_coff_scl (ignore) static void obj_coff_tag (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *symbol_name; char name_end; @@ -868,7 +998,7 @@ obj_coff_tag (ignore) static void obj_coff_type (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -890,7 +1020,7 @@ obj_coff_type (ignore) static void obj_coff_val (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -909,24 +1039,33 @@ obj_coff_val (ignore) #endif if (!strcmp (symbol_name, ".")) { - def_symbol_in_progress->sy_frag = frag_now; + symbol_set_frag (def_symbol_in_progress, frag_now); S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ()); /* If the .val is != from the .def (e.g. statics) */ } else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name)) { - def_symbol_in_progress->sy_value.X_op = O_symbol; - def_symbol_in_progress->sy_value.X_add_symbol = - symbol_find_or_make (symbol_name); - def_symbol_in_progress->sy_value.X_op_symbol = NULL; - def_symbol_in_progress->sy_value.X_add_number = 0; + expressionS exp; + + exp.X_op = O_symbol; + exp.X_add_symbol = symbol_find_or_make (symbol_name); + exp.X_op_symbol = NULL; + exp.X_add_number = 0; + symbol_set_value_expression (def_symbol_in_progress, &exp); /* If the segment is undefined when the forward reference is resolved, then copy the segment id from the forward symbol. */ SF_SET_GET_SEGMENT (def_symbol_in_progress); + + /* FIXME: gcc can generate address expressions here in + unusual cases (search for "obscure" in sdbout.c). We + just ignore the offset here, thus generating incorrect + debugging information. We ignore the rest of the line + just below. */ } - /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */ + /* Otherwise, it is the name of a non debug symbol and its value + will be calculated later. */ *input_line_pointer = name_end; } else @@ -1034,7 +1173,7 @@ coff_frob_symbol (symp, punt) coff_last_function = symp; if (S_GET_NUMBER_AUXILIARY (symp) < 1) S_SET_NUMBER_AUXILIARY (symp, 1); - auxp = &coffsymbol (symp->bsym)->native[1].u.auxent; + auxp = SYM_AUXENT (symp); memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0, sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen)); } @@ -1055,11 +1194,16 @@ coff_frob_symbol (symp, punt) *punt = 1; if (SF_GET_FUNCTION (symp)) - symp->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION; /* more ... */ } + /* Double check weak symbols. */ + if (S_IS_WEAK (symp) && S_IS_COMMON (symp)) + as_bad (_("Symbol `%s' can not be both weak and common"), + S_GET_NAME (symp)); + if (SF_GET_TAG (symp)) last_tagP = symp; else if (S_GET_STORAGE_CLASS (symp) == C_EOS) @@ -1068,17 +1212,17 @@ coff_frob_symbol (symp, punt) #ifdef OBJ_XCOFF /* This is pretty horrible, but we have to set *punt correctly in order to call SA_SET_SYM_ENDNDX correctly. */ - if (! symp->sy_used_in_reloc - && ((symp->bsym->flags & BSF_SECTION_SYM) != 0 + if (! symbol_used_in_reloc_p (symp) + && ((symbol_get_bfdsym (symp)->flags & BSF_SECTION_SYM) != 0 || (! S_IS_EXTERNAL (symp) - && ! symp->sy_tc.output + && ! symbol_get_tc (symp)->output && S_GET_STORAGE_CLASS (symp) != C_FILE))) *punt = 1; #endif if (set_end != (symbolS *) NULL && ! *punt - && ((symp->bsym->flags & BSF_NOT_AT_END) != 0 + && ((symbol_get_bfdsym (symp)->flags & BSF_NOT_AT_END) != 0 || (S_IS_DEFINED (symp) && ! S_IS_COMMON (symp) && (! S_IS_EXTERNAL (symp) || SF_GET_FUNCTION (symp))))) @@ -1087,9 +1231,13 @@ coff_frob_symbol (symp, punt) set_end = NULL; } - if (next_set_end != NULL - && ! *punt) - set_end = next_set_end; + if (next_set_end != NULL) + { + if (set_end != NULL) + as_warn ("Warning: internal error: forgetting to set endndx of %s", + S_GET_NAME (set_end)); + set_end = next_set_end; + } if (! *punt && S_GET_STORAGE_CLASS (symp) == C_FCN @@ -1100,28 +1248,28 @@ coff_frob_symbol (symp, punt) coff_last_bf = symp; } - if (coffsymbol (symp->bsym)->lineno) + if (coffsymbol (symbol_get_bfdsym (symp))->lineno) { int i; struct line_no *lptr; alent *l; - lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno; + lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno; for (i = 0; lptr; lptr = lptr->next) i++; - lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno; + lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno; /* We need i entries for line numbers, plus 1 for the first entry which BFD will override, plus 1 for the last zero entry (a marker for BFD). */ l = (alent *) xmalloc ((i + 2) * sizeof (alent)); - coffsymbol (symp->bsym)->lineno = l; + coffsymbol (symbol_get_bfdsym (symp))->lineno = l; l[i + 1].line_number = 0; l[i + 1].u.sym = NULL; for (; i > 0; i--) { if (lptr->frag) - lptr->l.u.offset += lptr->frag->fr_address; + lptr->l.u.offset += lptr->frag->fr_address / OCTETS_PER_BYTE; l[i] = lptr->l; lptr = lptr->next; } @@ -1130,9 +1278,9 @@ coff_frob_symbol (symp, punt) void coff_adjust_section_syms (abfd, sec, x) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; asection *sec; - PTR x; + PTR x ATTRIBUTE_UNUSED; { symbolS *secsym; segment_info_type *seginfo = seg_info (sec); @@ -1166,6 +1314,8 @@ coff_adjust_section_syms (abfd, sec, x) && sec != bss_section) return; secsym = section_symbol (sec); + /* This is an estimate; we'll plug in the real value using + SET_SECTION_RELOCS later */ SA_SET_SCN_NRELOC (secsym, nrelocs); SA_SET_SCN_NLINNO (secsym, nlnno); } @@ -1189,13 +1339,14 @@ coff_frob_file_after_relocs () * 'd' (apparently m88k for data) * 'x' for text * 'r' for read-only data + * 's' for shared data (PE) * But if the argument is not a quoted string, treat it as a * subsegment number. */ void obj_coff_section (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* Strip out the section name */ char *section_name; @@ -1224,7 +1375,7 @@ obj_coff_section (ignore) SKIP_WHITESPACE (); exp = 0; - flags = SEC_NO_FLAGS; + flags = SEC_LOAD; if (*input_line_pointer == ',') { @@ -1242,10 +1393,11 @@ obj_coff_section (ignore) { case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break; case 'n': flags &=~ SEC_LOAD; break; - case 'd': + case 'd': flags |= SEC_DATA | SEC_LOAD; /* fall through */ case 'w': flags &=~ SEC_READONLY; break; - case 'x': flags |= SEC_CODE; break; + case 'x': flags |= SEC_CODE | SEC_LOAD; break; case 'r': flags |= SEC_READONLY; break; + case 's': flags |= SEC_SHARED; break; case 'i': /* STYP_INFO */ case 'l': /* STYP_LIB */ @@ -1301,25 +1453,32 @@ coff_frob_section (sec) char *p; fragS *fragp; bfd_vma size, n_entries, mask; + bfd_vma align_power = (bfd_vma)sec->alignment_power + OCTETS_PER_BYTE_POWER; /* The COFF back end in BFD requires that all section sizes be - rounded up to multiples of the corresponding section alignments. - Seems kinda silly to me, but that's the way it is. */ + rounded up to multiples of the corresponding section alignments, + supposedly because standard COFF has no other way of encoding alignment + for sections. If your COFF flavor has a different way of encoding + section alignment, then skip this step, as TICOFF does. */ size = bfd_get_section_size_before_reloc (sec); - mask = ((bfd_vma) 1 << (bfd_vma) sec->alignment_power) - 1; + mask = ((bfd_vma) 1 << align_power) - 1; +#if !defined(TICOFF) if (size & mask) { size = (size + mask) & ~mask; bfd_set_section_size (stdoutput, sec, size); } +#endif /* If the section size is non-zero, the section symbol needs an aux entry associated with it, indicating the size. We don't know all the values yet; coff_frob_symbol will fill them in later. */ +#ifndef TICOFF if (size != 0 || sec == text_section || sec == data_section || sec == bss_section) +#endif { symbolS *secsym = section_symbol (sec); @@ -1430,9 +1589,10 @@ symbol_dump () #define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v)) #define MIN(a,b) ((a) < (b)? (a) : (b)) -/* This vector is used to turn an internal segment into a section # - suitable for insertion into a coff symbol table - */ + +/* This vector is used to turn a gas internal segment number into a + section number suitable for insertion into a coff symbol table. + This must correspond to seg_info_off_by_4. */ const short seg_N_TYPE[] = { /* in: segT out: N_TYPE bits */ @@ -1505,53 +1665,43 @@ static void adjust_stab_section PARAMS ((bfd *abfd, segT seg)); static void obj_coff_lcomm PARAMS ((int)); static void obj_coff_text PARAMS ((int)); static void obj_coff_data PARAMS ((int)); -static void obj_coff_ident PARAMS ((int)); void obj_coff_section PARAMS ((int)); -/* Section stuff - - We allow more than just the standard 3 sections, infact, we allow - 40 sections, (though the usual three have to be there). - - This structure performs the mappings for us: -*/ - +/* When not using BFD_ASSEMBLER, we permit up to 40 sections. -typedef struct -{ - segT seg_t; - int i; -} seg_info_type; + This array maps a COFF section number into a gas section number. + Because COFF uses negative section numbers, you must add 4 to the + COFF section number when indexing into this array; this is done via + the SEG_INFO_FROM_SECTION_NUMBER macro. This must correspond to + seg_N_TYPE. */ -static const seg_info_type seg_info_off_by_4[] = +static const segT seg_info_off_by_4[] = { - {SEG_PTV, }, - {SEG_NTV, }, - {SEG_DEBUG, }, - {SEG_ABSOLUTE, }, - {SEG_UNKNOWN, }, - {SEG_E0}, {SEG_E1}, {SEG_E2}, {SEG_E3}, {SEG_E4}, - {SEG_E5}, {SEG_E6}, {SEG_E7}, {SEG_E8}, {SEG_E9}, - {SEG_E10},{SEG_E11},{SEG_E12},{SEG_E13},{SEG_E14}, - {SEG_E15},{SEG_E16},{SEG_E17},{SEG_E18},{SEG_E19}, - {SEG_E20},{SEG_E21},{SEG_E22},{SEG_E23},{SEG_E24}, - {SEG_E25},{SEG_E26},{SEG_E27},{SEG_E28},{SEG_E29}, - {SEG_E30},{SEG_E31},{SEG_E32},{SEG_E33},{SEG_E34}, - {SEG_E35},{SEG_E36},{SEG_E37},{SEG_E38},{SEG_E39}, - {(segT)40}, - {(segT)41}, - {(segT)42}, - {(segT)43}, - {(segT)44}, - {(segT)45}, - {(segT)0}, - {(segT)0}, - {(segT)0}, - {SEG_REGISTER} + SEG_PTV, + SEG_NTV, + SEG_DEBUG, + SEG_ABSOLUTE, + SEG_UNKNOWN, + SEG_E0, SEG_E1, SEG_E2, SEG_E3, SEG_E4, + SEG_E5, SEG_E6, SEG_E7, SEG_E8, SEG_E9, + SEG_E10, SEG_E11, SEG_E12, SEG_E13, SEG_E14, + SEG_E15, SEG_E16, SEG_E17, SEG_E18, SEG_E19, + SEG_E20, SEG_E21, SEG_E22, SEG_E23, SEG_E24, + SEG_E25, SEG_E26, SEG_E27, SEG_E28, SEG_E29, + SEG_E30, SEG_E31, SEG_E32, SEG_E33, SEG_E34, + SEG_E35, SEG_E36, SEG_E37, SEG_E38, SEG_E39, + (segT) 40, + (segT) 41, + (segT) 42, + (segT) 43, + (segT) 44, + (segT) 45, + (segT) 0, + (segT) 0, + (segT) 0, + SEG_REGISTER }; - - #define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4]) static relax_addressT @@ -1572,14 +1722,14 @@ segT s_get_segment (x) symbolS * x; { - return SEG_INFO_FROM_SECTION_NUMBER (x->sy_symbol.ost_entry.n_scnum).seg_t; + return SEG_INFO_FROM_SECTION_NUMBER (x->sy_symbol.ost_entry.n_scnum); } /* calculate the size of the frag chain and fill in the section header to contain all of it, also fill in the addr of the sections */ static unsigned int size_section (abfd, idx) - bfd * abfd; + bfd *abfd ATTRIBUTE_UNUSED; unsigned int idx; { @@ -1843,7 +1993,7 @@ do_relocs_for (abfd, h, file_cursor) static void fill_section (abfd, h, file_cursor) bfd * abfd; - object_headers *h; + object_headers *h ATTRIBUTE_UNUSED; unsigned long *file_cursor; { @@ -2158,7 +2308,7 @@ obj_coff_ln (appline) static void obj_coff_def (what) - int what; + int what ATTRIBUTE_UNUSED; { char name_end; /* Char after the end of name */ char *symbol_name; /* Name of the debug symbol */ @@ -2213,7 +2363,7 @@ unsigned int dim_index; static void obj_coff_endef (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { symbolS *symbolP = 0; /* DIM BUG FIX sac@cygnus.com */ @@ -2396,7 +2546,7 @@ obj_coff_endef (ignore) static void obj_coff_dim (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int dim_index; @@ -2436,7 +2586,7 @@ obj_coff_dim (ignore) static void obj_coff_line (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int this_base; const char *name; @@ -2481,7 +2631,7 @@ obj_coff_line (ignore) static void obj_coff_size (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -2497,7 +2647,7 @@ obj_coff_size (ignore) static void obj_coff_scl (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -2512,7 +2662,7 @@ obj_coff_scl (ignore) static void obj_coff_tag (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *symbol_name; char name_end; @@ -2548,7 +2698,7 @@ obj_coff_tag (ignore) static void obj_coff_type (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -2570,7 +2720,7 @@ obj_coff_type (ignore) static void obj_coff_val (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (def_symbol_in_progress == NULL) { @@ -2607,12 +2757,11 @@ obj_coff_val (ignore) symbol. */ SF_SET_GET_SEGMENT (def_symbol_in_progress); - /* FIXME: gcc can generate address expressions - here in unusual cases (search for "obscure" - in sdbout.c). We just ignore the offset - here, thus generating incorrect debugging - information. We ignore the rest of the - line just below. */ + /* FIXME: gcc can generate address expressions here in + unusual cases (search for "obscure" in sdbout.c). We + just ignore the offset here, thus generating incorrect + debugging information. We ignore the rest of the line + just below. */ } /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */ @@ -2997,7 +3146,7 @@ tie_tags () static void crawl_symbols (h, abfd) object_headers *h; - bfd * abfd; + bfd *abfd ATTRIBUTE_UNUSED; { unsigned int i; @@ -3231,6 +3380,7 @@ write_object_file () at the next frag. */ subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg); + #ifndef SUB_SEGMENT_ALIGN #define SUB_SEGMENT_ALIGN(SEG) 1 #endif @@ -3238,7 +3388,9 @@ write_object_file () md_do_align (SUB_SEGMENT_ALIGN (now_seg), (char *) NULL, 0, 0, alignment_done); #endif - frag_align (SUB_SEGMENT_ALIGN (now_seg), NOP_OPCODE, 0); + frag_align (SUB_SEGMENT_ALIGN (now_seg), + subseg_text_p (now_seg) ? NOP_OPCODE : 0, + 0); #ifdef md_do_align alignment_done: #endif @@ -3453,7 +3605,7 @@ obj_coff_add_segment (name) void obj_coff_section (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* Strip out the section name */ char *section_name, *name; @@ -3534,7 +3686,7 @@ obj_coff_section (ignore) static void obj_coff_text (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { subseg_new (".text", get_absolute_expression ()); } @@ -3542,7 +3694,7 @@ obj_coff_text (ignore) static void obj_coff_data (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (flag_readonly_data_in_text) subseg_new (".text", get_absolute_expression () + 1000); @@ -3552,7 +3704,7 @@ obj_coff_data (ignore) static void obj_coff_ident (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { segT current_seg = now_seg; /* save current seg */ subsegT current_subseg = now_subseg; @@ -3811,7 +3963,7 @@ w_symbols (abfd, where, symbol_rootP) static void obj_coff_lcomm (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { s_lcomm(0); return; @@ -4258,6 +4410,12 @@ fixup_segment (segP, this_segment_type) #endif } /* if pcrel */ +#ifdef MD_APPLY_FIX3 + md_apply_fix3 (fixP, (valueT *) &add_number, this_segment_type); +#else + md_apply_fix (fixP, add_number); +#endif + if (!fixP->fx_bit_fixP && ! fixP->fx_no_overflow) { #ifndef TC_M88K @@ -4294,13 +4452,6 @@ fixup_segment (segP, this_segment_type) (unsigned long) (fragP->fr_address + where)); #endif } /* not a bit fix */ - /* Once this fix has been applied, we don't have to output - anything nothing more need be done. */ -#ifdef MD_APPLY_FIX3 - md_apply_fix3 (fixP, (valueT *) &add_number, this_segment_type); -#else - md_apply_fix (fixP, add_number); -#endif } /* For each fixS in this segment. */ } /* fixup_segment() */ @@ -4383,13 +4534,16 @@ adjust_stab_section(abfd, seg) #endif /* not BFD_ASSEMBLER */ -const pseudo_typeS obj_pseudo_table[] = +const pseudo_typeS coff_pseudo_table[] = { {"def", obj_coff_def, 0}, {"dim", obj_coff_dim, 0}, {"endef", obj_coff_endef, 0}, {"line", obj_coff_line, 0}, {"ln", obj_coff_ln, 0}, +#ifdef BFD_ASSEMBLER + {"loc", obj_coff_loc, 0}, +#endif {"appline", obj_coff_ln, 1}, {"scl", obj_coff_scl, 0}, {"size", obj_coff_size, 0}, @@ -4405,15 +4559,14 @@ const pseudo_typeS obj_pseudo_table[] = earlier versions of gas. */ {"bss", obj_coff_bss, 0}, {"weak", obj_coff_weak, 0}, + {"ident", obj_coff_ident, 0}, #ifndef BFD_ASSEMBLER {"use", obj_coff_section, 0}, {"text", obj_coff_text, 0}, {"data", obj_coff_data, 0}, {"lcomm", obj_coff_lcomm, 0}, - {"ident", obj_coff_ident, 0}, #else {"optim", s_ignore, 0}, /* For sun386i cc (?) */ - {"ident", s_ignore, 0}, /* we don't yet handle this. */ #endif {"version", s_ignore, 0}, {"ABORT", s_abort, 0}, @@ -4421,62 +4574,43 @@ const pseudo_typeS obj_pseudo_table[] = /* The m88k uses sdef instead of def. */ {"sdef", obj_coff_def, 0}, #endif - {NULL} /* end sentinel */ -}; /* obj_pseudo_table */ + {NULL, NULL, 0} /* end sentinel */ +}; /* coff_pseudo_table */ #ifdef BFD_ASSEMBLER /* Support for a COFF emulation. */ -static void -coff_pop_insert () -{ - pop_insert (obj_pseudo_table); -} - -static int -coff_sec_sym_ok_for_reloc (sec) - asection *sec; -{ - return 0; -} +static void coff_pop_insert PARAMS ((void)); static void -no_func () +coff_pop_insert () { - abort (); + pop_insert (coff_pseudo_table); } const struct format_ops coff_format_ops = { bfd_target_coff_flavour, - 0, - 1, + 0, /* dfl_leading_underscore */ + 1, /* emit_section_symbols */ coff_frob_symbol, - no_func, + 0, /* frob_file */ coff_frob_file_after_relocs, - 0, 0, - 0, 0, - 0, -#if 0 - obj_generate_asm_lineno, -#else - no_func, -#endif -#if 0 - obj_stab, -#else - no_func, -#endif - coff_sec_sym_ok_for_reloc, + 0, /* s_get_size */ + 0, /* s_set_size */ + 0, /* s_get_align */ + 0, /* s_set_align */ + 0, /* s_get_other */ + 0, /* s_get_desc */ + 0, /* copy_symbol_attributes */ + 0, /* generate_asm_lineno */ + 0, /* process_stab */ + 0, /* sec_sym_ok_for_reloc */ coff_pop_insert, -#if 0 - obj_set_ext, -#else - no_func, -#endif + 0, /* ecoff_set_ext */ coff_obj_read_begin_hook, - coff_obj_symbol_new_hook, + coff_obj_symbol_new_hook }; #endif diff --git a/gas/config/obj-coff.h b/gas/config/obj-coff.h index 4650477..f60ae36 100644 --- a/gas/config/obj-coff.h +++ b/gas/config/obj-coff.h @@ -1,5 +1,5 @@ /* coff object file format - Copyright (C) 1989, 90, 91, 92, 94, 95, 96, 97, 98, 1999 + Copyright (C) 1989, 90, 91, 92, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS. @@ -110,12 +110,29 @@ #endif #ifdef TC_SH + +#ifdef TE_PE +#define COFF_WITH_PE +#endif + #include "coff/sh.h" + +#ifdef TE_PE +#define TARGET_FORMAT "pe-shl" +#else #define TARGET_FORMAT \ (shl \ ? (sh_small ? "coff-shl-small" : "coff-shl") \ : (sh_small ? "coff-sh-small" : "coff-sh")) #endif +#endif + +#ifdef TC_MIPS +#define COFF_WITH_PE +#include "coff/mipspe.h" +#undef TARGET_FORMAT +#define TARGET_FORMAT "pe-mips" +#endif #ifdef TC_M88K #include "coff/m88k.h" @@ -154,7 +171,7 @@ #define OBJ_COFF_MAX_AUXENTRIES 1 #endif /* OBJ_COFF_MAX_AUXENTRIES */ -extern void coff_obj_symbol_new_hook PARAMS ((struct symbol *)); +extern void coff_obj_symbol_new_hook PARAMS ((symbolS *)); #define obj_symbol_new_hook coff_obj_symbol_new_hook extern void coff_obj_read_begin_hook PARAMS ((void)); @@ -211,32 +228,35 @@ extern void coff_obj_read_begin_hook PARAMS ((void)); /* Alter the field names, for now, until we've fixed up the other references to use the new name. */ #ifdef TC_I960 -#define TC_SYMFIELD_TYPE struct symbol * +#define TC_SYMFIELD_TYPE symbolS * #define sy_tc bal #endif #define OBJ_SYMFIELD_TYPE unsigned long #define sy_obj sy_flags -#define SYM_AUXENT(S) (&coffsymbol ((S)->bsym)->native[1].u.auxent) -#define SYM_AUXINFO(S) (&coffsymbol ((S)->bsym)->native[1]) +#define SYM_AUXENT(S) \ + (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent) +#define SYM_AUXINFO(S) \ + (&coffsymbol (symbol_get_bfdsym (S))->native[1]) #define DO_NOT_STRIP 0 extern void obj_coff_section PARAMS ((int)); /* The number of auxiliary entries */ -#define S_GET_NUMBER_AUXILIARY(s) (coffsymbol((s)->bsym)->native->u.syment.n_numaux) +#define S_GET_NUMBER_AUXILIARY(s) \ + (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux) /* The number of auxiliary entries */ #define S_SET_NUMBER_AUXILIARY(s,v) (S_GET_NUMBER_AUXILIARY (s) = (v)) /* True if a symbol name is in the string table, i.e. its length is > 8. */ #define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0) -extern int S_SET_DATA_TYPE PARAMS ((struct symbol *, int)); -extern int S_SET_STORAGE_CLASS PARAMS ((struct symbol *, int)); -extern int S_GET_STORAGE_CLASS PARAMS ((struct symbol *)); -extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *)); +extern int S_SET_DATA_TYPE PARAMS ((symbolS *, int)); +extern int S_SET_STORAGE_CLASS PARAMS ((symbolS *, int)); +extern int S_GET_STORAGE_CLASS PARAMS ((symbolS *)); +extern void SA_SET_SYM_ENDNDX PARAMS ((symbolS *, symbolS *)); /* Auxiliary entry macros. SA_ stands for symbol auxiliary */ /* Omit the tv related fields */ @@ -298,9 +318,9 @@ extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *)); /* All other bits are unused. */ /* Accessors */ -#define SF_GET(s) ((s)->sy_flags) -#define SF_GET_DEBUG(s) ((s)->bsym->flags & BSF_DEBUGGING) -#define SF_SET_DEBUG(s) ((s)->bsym->flags |= BSF_DEBUGGING) +#define SF_GET(s) (*symbol_get_obj (s)) +#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING) +#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING) #define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK) #define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK) #define SF_GET_FILE(s) (SF_GET (s) & SF_FILE) @@ -346,13 +366,13 @@ extern int coff_line_base; extern int coff_n_line_nos; #define obj_emit_lineno(WHERE,LINE,FILE_START) abort () -extern void coff_add_linesym PARAMS ((struct symbol *)); +extern void coff_add_linesym PARAMS ((symbolS *)); void c_dot_file_symbol PARAMS ((char *filename)); #define obj_app_file c_dot_file_symbol -extern void coff_frob_symbol PARAMS ((struct symbol *, int *)); +extern void coff_frob_symbol PARAMS ((symbolS *, int *)); extern void coff_adjust_symtab PARAMS ((void)); extern void coff_frob_section PARAMS ((segT)); extern void coff_adjust_section_syms PARAMS ((bfd *, asection *, PTR)); @@ -364,10 +384,11 @@ extern void coff_frob_file_after_relocs PARAMS ((void)); #define obj_frob_section(S) coff_frob_section (S) #define obj_frob_file_after_relocs() coff_frob_file_after_relocs () -extern struct symbol *coff_last_function; +extern symbolS *coff_last_function; /* Forward the segment of a forwarded symbol, handle assignments that just copy symbol values, etc. */ +#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES #ifndef TE_I386AIX #define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src) \ (SF_GET_GET_SEGMENT (dest) \ @@ -379,6 +400,7 @@ extern struct symbol *coff_last_function; ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \ : 0) #endif +#endif /* sanity check */ @@ -778,7 +800,7 @@ extern void c_dot_file_symbol PARAMS ((char *filename)); #define obj_app_file c_dot_file_symbol extern void obj_extra_stuff PARAMS ((object_headers * headers)); -extern segT s_get_segment PARAMS ((struct symbol * ptr)); +extern segT s_get_segment PARAMS ((symbolS *ptr)); extern void c_section_header PARAMS ((struct internal_scnhdr * header, char *name, @@ -792,7 +814,7 @@ extern void c_section_header PARAMS ((struct internal_scnhdr * header, long alignment)); #ifndef tc_coff_symbol_emit_hook -void tc_coff_symbol_emit_hook PARAMS ((struct symbol *)); +void tc_coff_symbol_emit_hook PARAMS ((symbolS *)); #endif /* sanity check */ @@ -818,6 +840,12 @@ extern void obj_coff_pe_handle_link_once (); #endif /* not BFD_ASSEMBLER */ +extern const pseudo_typeS coff_pseudo_table[]; + +#ifndef obj_pop_insert +#define obj_pop_insert() pop_insert (coff_pseudo_table) +#endif + /* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK to redefine the symbol later on. This can happen if C symbols use a prefix, and a symbol is defined both with and without the prefix, @@ -838,4 +866,8 @@ extern void obj_coff_pe_handle_link_once (); extern void obj_coff_init_stab_section PARAMS ((segT)); #define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg) +/* Store the number of relocations in the section aux entry. */ +#define SET_SECTION_RELOCS(sec, relocs, n) \ + SA_SET_SCN_NRELOC (section_symbol (sec), n) + #endif /* OBJ_FORMAT_H */ diff --git a/gas/config/obj-ecoff.c b/gas/config/obj-ecoff.c index ec3ce88..767dc58 100644 --- a/gas/config/obj-ecoff.c +++ b/gas/config/obj-ecoff.c @@ -1,5 +1,6 @@ /* ECOFF object file format. - Copyright (C) 1993, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. Contributed by Cygnus Support. This file was put together by Ian Lance Taylor . @@ -260,8 +261,9 @@ obj_ecoff_set_ext (sym, ext) = &ecoff_backend (stdoutput)->debug_swap; ecoff_symbol_type *esym; - know (bfd_asymbol_flavour (sym->bsym) == bfd_target_ecoff_flavour); - esym = ecoffsymbol (sym->bsym); + know (bfd_asymbol_flavour (symbol_get_bfdsym (sym)) + == bfd_target_ecoff_flavour); + esym = ecoffsymbol (symbol_get_bfdsym (sym)); esym->local = false; esym->native = xmalloc (debug_swap->external_ext_size); (*debug_swap->swap_ext_out) (stdoutput, ext, esym->native); @@ -291,14 +293,18 @@ ecoff_pop_insert () const struct format_ops ecoff_format_ops = { bfd_target_ecoff_flavour, - 0, - 1, + 0, /* dfl_leading_underscore */ + 1, /* emit_section_symbols */ obj_ecoff_frob_symbol, ecoff_frob_file, - 0, - 0, 0, - 0, 0, - 0, + 0, /* frob_file_after_relocs */ + 0, /* s_get_size */ + 0, /* s_set_size */ + 0, /* s_get_align */ + 0, /* s_set_align */ + 0, /* s_get_other */ + 0, /* s_get_desc */ + 0, /* copy_symbol_attributes */ ecoff_generate_asm_lineno, ecoff_stab, ecoff_sec_sym_ok_for_reloc, diff --git a/gas/config/obj-ecoff.h b/gas/config/obj-ecoff.h index 427e619..8bca254 100644 --- a/gas/config/obj-ecoff.h +++ b/gas/config/obj-ecoff.h @@ -36,10 +36,14 @@ symbols is undefined (this last is needed to distinguish a .extern symbols from a .comm symbol). */ -#define TARGET_SYMBOL_FIELDS \ - struct efdr *ecoff_file; \ - struct localsym *ecoff_symbol; \ +struct ecoff_sy_obj +{ + struct efdr *ecoff_file; + struct localsym *ecoff_symbol; valueT ecoff_extern_size; +}; + +#define OBJ_SYMFIELD_TYPE struct ecoff_sy_obj /* Modify the ECOFF symbol. */ #define obj_frob_symbol(symp, punt) ecoff_frob_symbol (symp) @@ -64,4 +68,4 @@ extern void ecoff_frob_file PARAMS ((void)); #define obj_sec_sym_ok_for_reloc(SEC) 1 #define obj_ecoff_set_ext ecoff_set_ext -extern void obj_ecoff_set_ext PARAMS ((struct symbol *, EXTR *)); +extern void obj_ecoff_set_ext PARAMS ((symbolS *, EXTR *)); diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index f50c4b7..21fd0fa 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1,5 +1,6 @@ /* ELF object file format - Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -45,6 +46,10 @@ #include "elf/ppc.h" #endif +#ifdef TC_I370 +#include "elf/i370.h" +#endif + static bfd_vma elf_s_get_size PARAMS ((symbolS *)); static void elf_s_set_size PARAMS ((symbolS *, bfd_vma)); static bfd_vma elf_s_get_align PARAMS ((symbolS *)); @@ -65,17 +70,17 @@ static void obj_elf_type PARAMS ((int)); static void obj_elf_ident PARAMS ((int)); static void obj_elf_weak PARAMS ((int)); static void obj_elf_local PARAMS ((int)); -static void obj_elf_common PARAMS ((int)); +static void obj_elf_visibility PARAMS ((int)); static void obj_elf_symver PARAMS ((int)); static void obj_elf_vtable_inherit PARAMS ((int)); static void obj_elf_vtable_entry PARAMS ((int)); -static void obj_elf_data PARAMS ((int)); -static void obj_elf_text PARAMS ((int)); static void obj_elf_subsection PARAMS ((int)); +static void obj_elf_popsection PARAMS ((int)); static const pseudo_typeS elf_pseudo_table[] = { {"comm", obj_elf_common, 0}, + {"common", obj_elf_common, 1}, {"ident", obj_elf_ident, 0}, {"local", obj_elf_local, 0}, {"previous", obj_elf_previous, 0}, @@ -83,11 +88,18 @@ static const pseudo_typeS elf_pseudo_table[] = {"section.s", obj_elf_section, 0}, {"sect", obj_elf_section, 0}, {"sect.s", obj_elf_section, 0}, + {"pushsection", obj_elf_section, 1}, + {"popsection", obj_elf_popsection, 0}, {"size", obj_elf_size, 0}, {"type", obj_elf_type, 0}, {"version", obj_elf_version, 0}, {"weak", obj_elf_weak, 0}, + /* These define symbol visibility. */ + {"internal", obj_elf_visibility, STV_INTERNAL}, + {"hidden", obj_elf_visibility, STV_HIDDEN}, + {"protected", obj_elf_visibility, STV_PROTECTED}, + /* These are used for stabs-in-elf configurations. */ {"line", obj_elf_line, 0}, @@ -111,7 +123,7 @@ static const pseudo_typeS elf_pseudo_table[] = {"text", obj_elf_text, 0}, /* End sentinel. */ - {NULL}, + {NULL, NULL, 0}, }; static const pseudo_typeS ecoff_debug_pseudo_table[] = @@ -156,7 +168,7 @@ static const pseudo_typeS ecoff_debug_pseudo_table[] = { "vreg", s_ignore, 0 }, #endif - {NULL} /* end sentinel */ + {NULL, NULL, 0} /* end sentinel */ }; #undef NO_RELOC @@ -214,6 +226,13 @@ elf_s_set_align (sym, align) S_SET_ALIGN (sym, align); } +int +elf_s_get_other (sym) + symbolS *sym; +{ + return elf_symbol (symbol_get_bfdsym (sym))->internal_elf_sym.st_other; +} + static void elf_copy_symbol_attributes (dest, src) symbolS *dest, *src; @@ -235,8 +254,8 @@ elf_file_symbol (s) symbolS *sym; sym = symbol_new (s, absolute_section, (valueT) 0, (struct frag *) 0); - sym->sy_frag = &zero_address_frag; - sym->bsym->flags |= BSF_FILE; + symbol_set_frag (sym, &zero_address_frag); + symbol_get_bfdsym (sym)->flags |= BSF_FILE; if (symbol_rootP != sym) { @@ -252,9 +271,9 @@ elf_file_symbol (s) #endif } -static void -obj_elf_common (ignore) - int ignore; +void +obj_elf_common (is_common) + int is_common; { char *name; char c; @@ -263,6 +282,12 @@ obj_elf_common (ignore) symbolS *symbolP; int have_align; + if (flag_mri && is_common) + { + s_mri_common (0); + return; + } + name = input_line_pointer; c = get_symbol_end (); /* just after name is now '\0' */ @@ -294,7 +319,7 @@ obj_elf_common (ignore) } if (S_GET_VALUE (symbolP) != 0) { - if (S_GET_VALUE (symbolP) != size) + if (S_GET_VALUE (symbolP) != (valueT) size) { as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %d."), S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size); @@ -322,7 +347,7 @@ obj_elf_common (ignore) as_warn (_("Common alignment negative; 0 assumed")); } } - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec; int old_subsec; @@ -350,8 +375,8 @@ obj_elf_common (ignore) if (align) frag_align (align, 0, 0); if (S_GET_SEGMENT (symbolP) == bss_section) - symbolP->sy_frag->fr_symbol = 0; - symbolP->sy_frag = frag_now; + symbol_get_frag (symbolP)->fr_symbol = 0; + symbol_set_frag (symbolP, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, (offsetT) size, (char *) 0); *pfrag = 0; @@ -389,7 +414,7 @@ obj_elf_common (ignore) goto allocate_common; } - symbolP->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; demand_empty_rest_of_line (); return; @@ -411,7 +436,7 @@ obj_elf_common (ignore) static void obj_elf_local (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -425,7 +450,7 @@ obj_elf_local (ignore) *input_line_pointer = c; SKIP_WHITESPACE (); S_CLEAR_EXTERNAL (symbolP); - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; if (c == ',') { input_line_pointer++; @@ -440,7 +465,7 @@ obj_elf_local (ignore) static void obj_elf_weak (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -454,7 +479,7 @@ obj_elf_weak (ignore) *input_line_pointer = c; SKIP_WHITESPACE (); S_SET_WEAK (symbolP); - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; if (c == ',') { input_line_pointer++; @@ -467,9 +492,61 @@ obj_elf_weak (ignore) demand_empty_rest_of_line (); } +static void +obj_elf_visibility (visibility) + int visibility; +{ + char *name; + int c; + symbolS *symbolP; + asymbol *bfdsym; + elf_symbol_type *elfsym; + + do + { + name = input_line_pointer; + c = get_symbol_end (); + symbolP = symbol_find_or_make (name); + *input_line_pointer = c; + + SKIP_WHITESPACE (); + + bfdsym = symbol_get_bfdsym (symbolP); + elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym); + + assert (elfsym); + + elfsym->internal_elf_sym.st_other = visibility; + + if (c == ',') + { + input_line_pointer ++; + + SKIP_WHITESPACE (); + + if (*input_line_pointer == '\n') + c = '\n'; + } + } + while (c == ','); + + demand_empty_rest_of_line (); +} + + static segT previous_section; static int previous_subsection; +struct section_stack +{ + struct section_stack *next; + segT seg, prev_seg; + int subseg, prev_subseg; +}; + +static struct section_stack *section_stack; + + /* Handle the .section pseudo-op. This code supports two different syntaxes. @@ -497,7 +574,7 @@ struct special_section int attributes; }; -static struct special_section special_sections[] = +static struct special_section const special_sections[] = { { ".bss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, { ".comment", SHT_PROGBITS, 0 }, @@ -536,25 +613,198 @@ static struct special_section special_sections[] = }; void -obj_elf_section (xxx) - int xxx; +obj_elf_change_section (name, type, attr, push) + char *name; + int type, attr, push; { - char *string; int new_sec; segT sec; - int type, attr; - int i; - flagword flags; - symbolS *secsym; #ifdef md_flush_pending_output md_flush_pending_output (); #endif + /* Switch to the section, creating it if necessary. */ + if (push) + { + struct section_stack *elt; + elt = xmalloc (sizeof (struct section_stack)); + elt->next = section_stack; + elt->seg = now_seg; + elt->prev_seg = previous_section; + elt->subseg = now_subseg; + elt->prev_subseg = previous_subsection; + section_stack = elt; + } + previous_section = now_seg; + previous_subsection = now_subseg; + + new_sec = bfd_get_section_by_name (stdoutput, name) == NULL; + sec = subseg_new (name, 0); + + if (new_sec) + { + flagword flags; + symbolS *secsym; + int i; + + /* See if this is one of the special sections. */ + for (i = 0; special_sections[i].name != NULL; i++) + if (strcmp (name, special_sections[i].name) == 0) + { + if (type == SHT_NULL) + type = special_sections[i].type; + else if (type != special_sections[i].type) + as_warn (_("Setting incorrect section type for %s"), name); + + if ((attr &~ special_sections[i].attributes) != 0) + { + /* As a GNU extension, we permit a .note section to be + allocatable. If the linker sees an allocateable .note + section, it will create a PT_NOTE segment in the output + file. */ + if (strcmp (name, ".note") != 0 + || attr != SHF_ALLOC) + as_warn (_("Setting incorrect section attributes for %s"), + name); + } + attr |= special_sections[i].attributes; + break; + } + + /* Convert ELF type and flags to BFD flags. */ + flags = (SEC_RELOC + | ((attr & SHF_WRITE) ? 0 : SEC_READONLY) + | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0) + | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0) + | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0)); +#ifdef md_elf_section_flags + flags = md_elf_section_flags (flags, attr, type); +#endif + + /* Prevent SEC_HAS_CONTENTS from being inadvertently set. */ + if (type == SHT_NOBITS) + seg_info (sec)->bss = 1; + + bfd_set_section_flags (stdoutput, sec, flags); + + /* Add a symbol for this section to the symbol table. */ + secsym = symbol_find (name); + if (secsym != NULL) + symbol_set_bfdsym (secsym, sec->symbol); + else + symbol_table_insert (section_symbol (sec)); + } + +#ifdef md_elf_section_change_hook + md_elf_section_change_hook (); +#endif +} + +int +obj_elf_parse_section_letters (str, len) + char *str; + size_t len; +{ + int attr = 0; + + while (len > 0) + { + switch (*str) + { + case 'a': + attr |= SHF_ALLOC; + break; + case 'w': + attr |= SHF_WRITE; + break; + case 'x': + attr |= SHF_EXECINSTR; + break; + default: + { + char *bad_msg = _("Unrecognized .section attribute: want a,w,x"); +#ifdef md_elf_section_letter + int md_attr = md_elf_section_letter (*str, &bad_msg); + if (md_attr >= 0) + attr |= md_attr; + else +#endif + { + as_warn ("%s", bad_msg); + attr = -1; + } + } + break; + } + str++, len--; + } + + return attr; +} + +int +obj_elf_section_word (str, len) + char *str; + size_t len; +{ + if (len == 5 && strncmp (str, "write", 5) == 0) + return SHF_WRITE; + if (len == 5 && strncmp (str, "alloc", 5) == 0) + return SHF_ALLOC; + if (len == 9 && strncmp (str, "execinstr", 9) == 0) + return SHF_EXECINSTR; + +#ifdef md_elf_section_word + { + int md_attr = md_elf_section_word (str, len); + if (md_attr >= 0) + return md_attr; + } +#endif + + as_warn (_("Unrecognized section attribute")); + return 0; +} + +int +obj_elf_section_type (str, len) + char *str; + size_t len; +{ + if (len == 8 && strncmp (str, "progbits", 8) == 0) + return SHT_PROGBITS; + if (len == 6 && strncmp (str, "nobits", 6) == 0) + return SHT_NOBITS; + +#ifdef md_elf_section_type + { + int md_type = md_elf_section_type (str, len); + if (md_type >= 0) + return md_type; + } +#endif + + as_warn (_("Unrecognized section type")); + return 0; +} + +void +obj_elf_section (push) + int push; +{ + char *name, *beg, *end; + int type, attr, dummy; + +#ifndef TC_I370 if (flag_mri) { char mri_type; +#ifdef md_flush_pending_output + md_flush_pending_output (); +#endif + previous_section = now_seg; previous_subsection = now_subseg; @@ -566,13 +816,14 @@ obj_elf_section (xxx) return; } +#endif /* ! defined (TC_I370) */ /* Get name of section. */ SKIP_WHITESPACE (); if (*input_line_pointer == '"') { - string = demand_copy_C_string (&xxx); - if (string == NULL) + name = demand_copy_C_string (&dummy); + if (name == NULL) { ignore_rest_of_line (); return; @@ -580,46 +831,21 @@ obj_elf_section (xxx) } else { - char *p = input_line_pointer; - char c; - while (0 == strchr ("\n\t,; ", *p)) - p++; - if (p == input_line_pointer) + end = input_line_pointer; + while (0 == strchr ("\n\t,; ", *end)) + end++; + if (end == input_line_pointer) { as_warn (_("Missing section name")); ignore_rest_of_line (); return; } - c = *p; - *p = 0; - string = xmalloc ((unsigned long) (p - input_line_pointer + 1)); - strcpy (string, input_line_pointer); - *p = c; - input_line_pointer = p; - } - - /* Switch to the section, creating it if necessary. */ - previous_section = now_seg; - previous_subsection = now_subseg; - - new_sec = bfd_get_section_by_name (stdoutput, string) == NULL; - sec = subseg_new (string, 0); - - /* If this section already existed, we don't bother to change the - flag values. */ - if (! new_sec) - { - while (! is_end_of_line[(unsigned char) *input_line_pointer]) - ++input_line_pointer; - ++input_line_pointer; - -#ifdef md_elf_section_change_hook - md_elf_section_change_hook (); -#endif - return; + name = xmalloc (end - input_line_pointer + 1); + memcpy (name, input_line_pointer, end - input_line_pointer); + name[end - input_line_pointer] = '\0'; + input_line_pointer = end; } - SKIP_WHITESPACE (); type = SHT_NULL; @@ -629,81 +855,41 @@ obj_elf_section (xxx) { /* Skip the comma. */ ++input_line_pointer; - SKIP_WHITESPACE (); if (*input_line_pointer == '"') { - /* Pick up a string with a combination of a, w, x. */ - ++input_line_pointer; - while (*input_line_pointer != '"') + beg = demand_copy_C_string (&dummy); + if (beg == NULL) { - switch (*input_line_pointer) - { - case 'a': - attr |= SHF_ALLOC; - break; - case 'w': - attr |= SHF_WRITE; - break; - case 'x': - attr |= SHF_EXECINSTR; - break; - default: - { - char *bad_msg = _("Bad .section directive: want a,w,x in string"); -#ifdef md_elf_section_letter - int md_attr = md_elf_section_letter (*input_line_pointer, &bad_msg); - if (md_attr) - attr |= md_attr; - else -#endif - { - as_warn (bad_msg); - ignore_rest_of_line (); - return; - } - } - } - ++input_line_pointer; + ignore_rest_of_line (); + return; } - - /* Skip the closing quote. */ - ++input_line_pointer; + attr |= obj_elf_parse_section_letters (beg, strlen (beg)); SKIP_WHITESPACE (); if (*input_line_pointer == ',') { + char c; ++input_line_pointer; SKIP_WHITESPACE (); - if (*input_line_pointer == '@' || *input_line_pointer == '%') + c = *input_line_pointer; + if (c == '"') { - ++input_line_pointer; - if (strncmp (input_line_pointer, "progbits", - sizeof "progbits" - 1) == 0) - { - type = SHT_PROGBITS; - input_line_pointer += sizeof "progbits" - 1; - } - else if (strncmp (input_line_pointer, "nobits", - sizeof "nobits" - 1) == 0) + beg = demand_copy_C_string (&dummy); + if (beg == NULL) { - type = SHT_NOBITS; - input_line_pointer += sizeof "nobits" - 1; - } - else - { -#ifdef md_elf_section_type - int md_type = md_elf_section_type (&input_line_pointer); - if (md_type) - type = md_type; - else -#endif - { - as_warn (_("Unrecognized section type")); - ignore_rest_of_line (); - } + ignore_rest_of_line (); + return; } + type = obj_elf_section_type (beg, strlen (beg)); + } + else if (c == '@' || c == '%') + { + beg = ++input_line_pointer; + c = get_symbol_end (); + *input_line_pointer = c; + type = obj_elf_section_type (beg, input_line_pointer - beg); } } } @@ -711,6 +897,8 @@ obj_elf_section (xxx) { do { + char c; + SKIP_WHITESPACE (); if (*input_line_pointer != '#') { @@ -718,39 +906,12 @@ obj_elf_section (xxx) ignore_rest_of_line (); return; } - ++input_line_pointer; - if (strncmp (input_line_pointer, "write", - sizeof "write" - 1) == 0) - { - attr |= SHF_WRITE; - input_line_pointer += sizeof "write" - 1; - } - else if (strncmp (input_line_pointer, "alloc", - sizeof "alloc" - 1) == 0) - { - attr |= SHF_ALLOC; - input_line_pointer += sizeof "alloc" - 1; - } - else if (strncmp (input_line_pointer, "execinstr", - sizeof "execinstr" - 1) == 0) - { - attr |= SHF_EXECINSTR; - input_line_pointer += sizeof "execinstr" - 1; - } - else - { -#ifdef md_elf_section_word - int md_attr = md_elf_section_word (&input_line_pointer); - if (md_attr) - attr |= md_attr; - else -#endif - { - as_warn (_("Unrecognized section attribute")); - ignore_rest_of_line (); - return; - } - } + beg = ++input_line_pointer; + c = get_symbol_end (); + *input_line_pointer = c; + + attr |= obj_elf_section_word (beg, input_line_pointer - beg); + SKIP_WHITESPACE (); } while (*input_line_pointer++ == ','); @@ -758,77 +919,14 @@ obj_elf_section (xxx) } } - /* See if this is one of the special sections. */ - for (i = 0; special_sections[i].name != NULL; i++) - { - if (string[1] == special_sections[i].name[1] - && strcmp (string, special_sections[i].name) == 0) - { - if (type == SHT_NULL) - type = special_sections[i].type; - else if (type != special_sections[i].type) - as_warn (_("Setting incorrect section type for %s"), string); - - if ((attr &~ special_sections[i].attributes) != 0) - { - /* As a GNU extension, we permit a .note section to be - allocatable. If the linker sees an allocateable - .note section, it will create a PT_NOTE segment in - the output file. */ - if (strcmp (string, ".note") != 0 - || attr != SHF_ALLOC) - as_warn (_("Setting incorrect section attributes for %s"), - string); - } - attr |= special_sections[i].attributes; - - break; - } - } - - flags = (SEC_RELOC - | ((attr & SHF_WRITE) ? 0 : SEC_READONLY) - | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0) - | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0) - | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0)); - if (special_sections[i].name == NULL) - { - if (type == SHT_PROGBITS) - flags |= SEC_ALLOC | SEC_LOAD; - else if (type == SHT_NOBITS) - { - flags |= SEC_ALLOC; - flags &=~ SEC_LOAD; - } - -#ifdef md_elf_section_flags - flags = md_elf_section_flags (flags, attr, type); -#endif - } - - /* Prevent SEC_HAS_CONTENTS from being inadvertently set. */ - if (type == SHT_NOBITS) - seg_info (sec)->bss = 1; - - bfd_set_section_flags (stdoutput, sec, flags); - - /* Add a symbol for this section to the symbol table. */ - secsym = symbol_find (string); - if (secsym != NULL) - secsym->bsym = sec->symbol; - else - symbol_table_insert (section_symbol (sec)); - -#ifdef md_elf_section_change_hook - md_elf_section_change_hook (); -#endif - demand_empty_rest_of_line (); + + obj_elf_change_section (name, type, attr, push); } /* Change to the .data section. */ -static void +void obj_elf_data (i) int i; { @@ -847,7 +945,7 @@ obj_elf_data (i) /* Change to the .text section. */ -static void +void obj_elf_text (i) int i; { @@ -866,7 +964,7 @@ obj_elf_text (i) static void obj_elf_subsection (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { register int temp; @@ -898,8 +996,11 @@ obj_elf_section_change_hook () void obj_elf_previous (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { + segT new_section; + int new_subsection; + if (previous_section == 0) { as_bad (_(".previous without corresponding .section; ignored")); @@ -910,8 +1011,38 @@ obj_elf_previous (ignore) md_flush_pending_output (); #endif - subseg_set (previous_section, previous_subsection); - previous_section = 0; + new_section = previous_section; + new_subsection = previous_subsection; + previous_section = now_seg; + previous_subsection = now_subseg; + subseg_set (new_section, new_subsection); + +#ifdef md_elf_section_change_hook + md_elf_section_change_hook (); +#endif +} + +static void +obj_elf_popsection (xxx) + int xxx ATTRIBUTE_UNUSED; +{ + struct section_stack *top = section_stack; + + if (top == NULL) + { + as_bad (_(".popsection without corresponding .pushsection; ignored")); + return; + } + +#ifdef md_flush_pending_output + md_flush_pending_output (); +#endif + + section_stack = top->next; + previous_section = top->prev_seg; + previous_subsection = top->prev_subseg; + subseg_set (top->seg, top->subseg); + free (top); #ifdef md_elf_section_change_hook md_elf_section_change_hook (); @@ -920,7 +1051,7 @@ obj_elf_previous (ignore) static void obj_elf_line (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* Assume delimiter is part of expression. BSD4.2 as fails with delightful bug, so we are not being incompatible here. */ @@ -936,7 +1067,7 @@ obj_elf_line (ignore) static void obj_elf_symver (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char c; @@ -949,7 +1080,7 @@ obj_elf_symver (ignore) *input_line_pointer = c; - if (sym->sy_obj.versioned_name != NULL) + if (symbol_get_obj (sym)->versioned_name != NULL) { as_bad (_("multiple .symver directives for symbol `%s'"), S_GET_NAME (sym)); @@ -975,14 +1106,14 @@ obj_elf_symver (ignore) *input_line_pointer++ = c; } - sym->sy_obj.versioned_name = xstrdup (name); + symbol_get_obj (sym)->versioned_name = xstrdup (name); *input_line_pointer = c; - if (strchr (sym->sy_obj.versioned_name, ELF_VER_CHR) == NULL) + if (strchr (symbol_get_obj (sym)->versioned_name, ELF_VER_CHR) == NULL) { as_bad (_("missing version name in `%s' for symbol `%s'"), - sym->sy_obj.versioned_name, S_GET_NAME (sym)); + symbol_get_obj (sym)->versioned_name, S_GET_NAME (sym)); ignore_rest_of_line (); return; } @@ -996,6 +1127,7 @@ obj_elf_symver (ignore) static void obj_elf_vtable_inherit (ignore) + int ignore ATTRIBUTE_UNUSED; { char *cname, *pname; symbolS *csym, *psym; @@ -1012,7 +1144,7 @@ obj_elf_vtable_inherit (ignore) the same child symbol. Also, we can currently only do this if the child symbol is already exists and is placed in a fragment. */ - if (csym == NULL || csym->sy_frag == NULL) + if (csym == NULL || symbol_get_frag (csym) == NULL) { as_bad ("expected `%s' to have already been set for .vtable_inherit", cname); @@ -1037,7 +1169,7 @@ obj_elf_vtable_inherit (ignore) if (input_line_pointer[0] == '0' && (input_line_pointer[1] == '\0' - || isspace(input_line_pointer[1]))) + || isspace ((unsigned char) input_line_pointer[1]))) { psym = section_symbol (absolute_section); ++input_line_pointer; @@ -1055,17 +1187,19 @@ obj_elf_vtable_inherit (ignore) if (bad) return; - assert (csym->sy_value.X_op == O_constant); - fix_new (csym->sy_frag, csym->sy_value.X_add_number, 0, psym, 0, 0, + assert (symbol_get_value_expression (csym)->X_op == O_constant); + fix_new (symbol_get_frag (csym), + symbol_get_value_expression (csym)->X_add_number, 0, psym, 0, 0, BFD_RELOC_VTABLE_INHERIT); } - + /* This handles the .vtable_entry pseudo-op, which is used to indicate to the linker that a vtable slot was used. The syntax is ".vtable_entry tablename, offset". */ static void obj_elf_vtable_entry (ignore) + int ignore ATTRIBUTE_UNUSED; { char *name; symbolS *sym; @@ -1101,7 +1235,7 @@ obj_elf_vtable_entry (ignore) } void -obj_read_begin_hook () +elf_obj_read_begin_hook () { #ifdef NEED_ECOFF_DEBUG if (ECOFF_DEBUGGING) @@ -1110,11 +1244,14 @@ obj_read_begin_hook () } void -obj_symbol_new_hook (symbolP) +elf_obj_symbol_new_hook (symbolP) symbolS *symbolP; { - symbolP->sy_obj.size = NULL; - symbolP->sy_obj.versioned_name = NULL; + struct elf_obj_sy *sy_obj; + + sy_obj = symbol_get_obj (symbolP); + sy_obj->size = NULL; + sy_obj->versioned_name = NULL; #ifdef NEED_ECOFF_DEBUG if (ECOFF_DEBUGGING) @@ -1124,7 +1261,7 @@ obj_symbol_new_hook (symbolP) void obj_elf_version (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; unsigned int c; @@ -1191,7 +1328,7 @@ obj_elf_version (ignore) static void obj_elf_size (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name = input_line_pointer; char c = get_symbol_end (); @@ -1225,15 +1362,16 @@ obj_elf_size (ignore) S_SET_SIZE (sym, exp.X_add_number); else { - sym->sy_obj.size = (expressionS *) xmalloc (sizeof (expressionS)); - *sym->sy_obj.size = exp; + symbol_get_obj (sym)->size = + (expressionS *) xmalloc (sizeof (expressionS)); + *symbol_get_obj (sym)->size = exp; } demand_empty_rest_of_line (); } /* Handle the ELF .type pseudo-op. This sets the type of a symbol. There are four syntaxes: - + The first (used on Solaris) is .type SYM,#function The second (used on UnixWare) is @@ -1246,7 +1384,7 @@ obj_elf_size (ignore) static void obj_elf_type (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char c; @@ -1284,19 +1422,23 @@ obj_elf_type (ignore) *input_line_pointer = c; - sym->bsym->flags |= type; + symbol_get_bfdsym (sym)->flags |= type; demand_empty_rest_of_line (); } static void obj_elf_ident (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { static segT comment_section; segT old_section = now_seg; int old_subsection = now_subseg; +#ifdef md_flush_pending_output + md_flush_pending_output (); +#endif + if (!comment_section) { char *p; @@ -1351,7 +1493,7 @@ static void adjust_stab_sections (abfd, sec, xxx) bfd *abfd; asection *sec; - PTR xxx; + PTR xxx ATTRIBUTE_UNUSED; { char *name; asection *strsec; @@ -1393,7 +1535,7 @@ elf_ecoff_set_ext (sym, ext) symbolS *sym; struct ecoff_extr *ext; { - sym->bsym->udata.p = (PTR) ext; + symbol_get_bfdsym (sym)->udata.p = (PTR) ext; } /* This function is called by bfd_ecoff_debug_externals. It is @@ -1417,8 +1559,8 @@ elf_get_extr (sym, ext) /*ARGSUSED*/ static void elf_set_index (sym, indx) - asymbol *sym; - bfd_size_type indx; + asymbol *sym ATTRIBUTE_UNUSED; + bfd_size_type indx ATTRIBUTE_UNUSED; { } @@ -1429,35 +1571,39 @@ elf_frob_symbol (symp, puntp) symbolS *symp; int *puntp; { + struct elf_obj_sy *sy_obj; + #ifdef NEED_ECOFF_DEBUG if (ECOFF_DEBUGGING) ecoff_frob_symbol (symp); #endif - if (symp->sy_obj.size != NULL) + sy_obj = symbol_get_obj (symp); + + if (sy_obj->size != NULL) { - switch (symp->sy_obj.size->X_op) + switch (sy_obj->size->X_op) { case O_subtract: S_SET_SIZE (symp, - (S_GET_VALUE (symp->sy_obj.size->X_add_symbol) - + symp->sy_obj.size->X_add_number - - S_GET_VALUE (symp->sy_obj.size->X_op_symbol))); + (S_GET_VALUE (sy_obj->size->X_add_symbol) + + sy_obj->size->X_add_number + - S_GET_VALUE (sy_obj->size->X_op_symbol))); break; case O_constant: S_SET_SIZE (symp, - (S_GET_VALUE (symp->sy_obj.size->X_add_symbol) - + symp->sy_obj.size->X_add_number)); + (S_GET_VALUE (sy_obj->size->X_add_symbol) + + sy_obj->size->X_add_number)); break; default: as_bad (_(".size expression too complicated to fix up")); break; } - free (symp->sy_obj.size); - symp->sy_obj.size = NULL; + free (sy_obj->size); + sy_obj->size = NULL; } - if (symp->sy_obj.versioned_name != NULL) + if (sy_obj->versioned_name != NULL) { /* This symbol was given a new name with the .symver directive. @@ -1477,15 +1623,15 @@ elf_frob_symbol (symp, puntp) /* Verify that the name isn't using the @@ syntax--this is reserved for definitions of the default version to link against. */ - p = strchr (symp->sy_obj.versioned_name, ELF_VER_CHR); + p = strchr (sy_obj->versioned_name, ELF_VER_CHR); know (p != NULL); if (p[1] == ELF_VER_CHR) { as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"), - symp->sy_obj.versioned_name); + sy_obj->versioned_name); *puntp = true; } - S_SET_NAME (symp, symp->sy_obj.versioned_name); + S_SET_NAME (symp, sy_obj->versioned_name); } else { @@ -1497,7 +1643,7 @@ elf_frob_symbol (symp, puntp) where the loop will still see it. It would probably be better to do this in obj_frob_file_before_adjust. */ - symp2 = symbol_find_or_make (symp->sy_obj.versioned_name); + symp2 = symbol_find_or_make (sy_obj->versioned_name); /* Now we act as though we saw symp2 = sym. */ @@ -1505,9 +1651,11 @@ elf_frob_symbol (symp, puntp) /* Subtracting out the frag address here is a hack because we are in the middle of the final loop. */ - S_SET_VALUE (symp2, S_GET_VALUE (symp) - symp->sy_frag->fr_address); + S_SET_VALUE (symp2, + (S_GET_VALUE (symp) + - symbol_get_frag (symp)->fr_address)); - symp2->sy_frag = symp->sy_frag; + symbol_set_frag (symp2, symbol_get_frag (symp)); /* This will copy over the size information. */ copy_symbol_attributes (symp2, symp); @@ -1521,7 +1669,7 @@ elf_frob_symbol (symp, puntp) } /* Double check weak symbols. */ - if (symp->bsym->flags & BSF_WEAK) + if (S_IS_WEAK (symp)) { if (S_IS_COMMON (symp)) as_bad (_("Symbol `%s' can not be both weak and common"), @@ -1537,19 +1685,23 @@ elf_frob_symbol (symp, puntp) .global directives to mark functions. */ if (S_IS_COMMON (symp)) - symp->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; if (strstr (TARGET_OS, "irix") != NULL - && (! S_IS_DEFINED (symp) && ((symp->bsym->flags & BSF_FUNCTION) == 0))) - symp->bsym->flags |= BSF_OBJECT; + && ! S_IS_DEFINED (symp) + && (symbol_get_bfdsym (symp)->flags & BSF_FUNCTION) == 0) + symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; #endif -#ifdef TC_PPC - /* Frob the PowerPC, so that the symbol always has object type - if it is not some other type. VxWorks needs this. */ - if ((symp->bsym->flags & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0 +#if 0 /* TC_PPC */ + /* If TC_PPC is defined, we used to force the type of a symbol to be + BSF_OBJECT if it was otherwise unset. This was required by some + version of VxWorks. Thomas de Lellis says + that this is no longer needed, so it is now commented out. */ + if ((symbol_get_bfdsym (symp)->flags + & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0 && S_IS_DEFINED (symp)) - symp->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; #endif } @@ -1621,7 +1773,11 @@ elf_frob_file_after_relocs () this? */ sec->_raw_size = bfd_ecoff_debug_size (stdoutput, &debug, debug_swap); - if (! bfd_set_section_contents (stdoutput, sec, (PTR) NULL, + /* Pass BUF to bfd_set_section_contents because this will + eventually become a call to fwrite, and ISO C prohibits + passing a NULL pointer to a stdio function even if the + pointer will not be used. */ + if (! bfd_set_section_contents (stdoutput, sec, (PTR) buf, (file_ptr) 0, (bfd_size_type) 0)) as_fatal (_("Can't start writing .mdebug section: %s"), bfd_errmsg (bfd_get_error ())); @@ -1652,14 +1808,14 @@ elf_frob_file_after_relocs () SCO OpenServer 5 identifies it's ELF modules with a standard ELF .note section. - int_32 namesz = 4 ; Name size - int_32 descsz = 12 ; Descriptive information - int_32 type = 1 ; - char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL + int_32 namesz = 4 ; Name size + int_32 descsz = 12 ; Descriptive information + int_32 type = 1 ; + char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL int_32 version = (major ver # << 16) | version of tools ; int_32 source = (tool_id << 16 ) | 1 ; int_32 info = 0 ; These are set by the SCO tools, but we - don't know enough about the source + don't know enough about the source environment to set them. SCO ld currently ignores them, and recommends we set them to zero. */ @@ -1691,7 +1847,7 @@ sco_id () /* process the version string */ - i_note.namesz = 4; + i_note.namesz = 4; i_note.descsz = 12; /* 12 descriptive bytes */ i_note.type = NT_VERSION; /* Contains a version string */ @@ -1705,7 +1861,7 @@ sco_id () md_number_to_chars (p, (valueT) i_note.type, 4); p = frag_more (4); - strcpy (p, "SCO"); + strcpy (p, "SCO"); /* Note: this is the version number of the ELF we're representing */ p = frag_more (4); @@ -1722,7 +1878,7 @@ sco_id () and just set them to zero. */ p = frag_more (4); md_number_to_chars (p, 0x0000, 4); - + frag_align (2, 0, 0); /* We probably can't restore the current segment, for there likely @@ -1737,28 +1893,30 @@ sco_id () const struct format_ops elf_format_ops = { bfd_target_elf_flavour, - 0, - 1, + 0, /* dfl_leading_underscore */ + 1, /* emit_section_symbols */ elf_frob_symbol, elf_frob_file, elf_frob_file_after_relocs, elf_s_get_size, elf_s_set_size, elf_s_get_align, elf_s_set_align, + elf_s_get_other, + 0, /* s_get_desc */ elf_copy_symbol_attributes, #ifdef NEED_ECOFF_DEBUG ecoff_generate_asm_lineno, ecoff_stab, #else - 0, - 0, /* process_stab */ + 0, /* generate_asm_lineno */ + 0, /* process_stab */ #endif elf_sec_sym_ok_for_reloc, elf_pop_insert, #ifdef NEED_ECOFF_DEBUG elf_ecoff_set_ext, #else - 0, + 0, /* ecoff_set_ext */ #endif - obj_read_begin_hook, - obj_symbol_new_hook, + elf_obj_read_begin_hook, + elf_obj_symbol_new_hook, }; diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h index 2f4bc5f..722c5fd 100644 --- a/gas/config/obj-elf.h +++ b/gas/config/obj-elf.h @@ -1,5 +1,6 @@ /* ELF object file format. - Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -27,39 +28,61 @@ #define OBJ_ELF 1 +#ifndef OUTPUT_FLAVOR #define OUTPUT_FLAVOR bfd_target_elf_flavour +#endif #include #define BYTES_IN_WORD 4 /* for now */ #include "bfd/elf-bfd.h" -/* Additional information we keep for each symbol. */ +#include "targ-cpu.h" + +#ifdef TC_ALPHA +#define ECOFF_DEBUGGING alpha_flag_mdebug +extern int alpha_flag_mdebug; +#endif + +/* For now, always set ECOFF_DEBUGGING for a MIPS target. */ +#ifdef TC_MIPS +#ifdef MIPS_STABS_ELF +#define ECOFF_DEBUGGING 0 +#else +#define ECOFF_DEBUGGING 1 +#endif /* MIPS_STABS_ELF */ +#endif /* TC_MIPS */ + +#ifdef OBJ_MAYBE_ECOFF +#ifndef ECOFF_DEBUGGING +#define ECOFF_DEBUGGING 1 +#endif +#endif -/* FIXME: For some reason, this structure is needed both here and in - obj-multi.h. */ -#ifndef OBJ_SYMFIELD_TYPE +/* Additional information we keep for each symbol. */ struct elf_obj_sy { + /* Whether the symbol has been marked as local. */ + int local; + /* Use this to keep track of .size expressions that involve differences that we can't compute yet. */ expressionS *size; /* The name specified by the .symver directive. */ char *versioned_name; -}; + +#ifdef ECOFF_DEBUGGING + /* If we are generating ECOFF debugging information, we need some + additional fields for each symbol. */ + struct efdr *ecoff_file; + struct localsym *ecoff_symbol; + valueT ecoff_extern_size; #endif +}; #define OBJ_SYMFIELD_TYPE struct elf_obj_sy -/* Symbol fields used by the ELF back end. */ -#define ELF_TARGET_SYMBOL_FIELDS int local:1; - -/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead. */ -#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS - -#include "targ-cpu.h" - #ifndef FALSE #define FALSE 0 #define TRUE !FALSE @@ -71,24 +94,43 @@ extern void elf_begin PARAMS ((void)); /* should be conditional on address size! */ #define elf_symbol(asymbol) ((elf_symbol_type *)(&(asymbol)->the_bfd)) -#define S_GET_SIZE(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_size) +#ifndef S_GET_SIZE +#define S_GET_SIZE(S) \ + (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size) +#endif +#ifndef S_SET_SIZE #define S_SET_SIZE(S,V) \ - (elf_symbol((S)->bsym)->internal_elf_sym.st_size = (V)) + (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V)) +#endif -#define S_GET_ALIGN(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_value) +#ifndef S_GET_ALIGN +#define S_GET_ALIGN(S) \ + (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value) +#endif +#ifndef S_SET_ALIGN #define S_SET_ALIGN(S,V) \ - (elf_symbol ((S)->bsym)->internal_elf_sym.st_value = (V)) + (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V)) +#endif -#define S_GET_OTHER(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_other) +int elf_s_get_other PARAMS ((symbolS *)); +#ifndef S_GET_OTHER +#define S_GET_OTHER(S) (elf_s_get_other (S)) +#endif +#ifndef S_SET_OTHER #define S_SET_OTHER(S,V) \ - (elf_symbol ((S)->bsym)->internal_elf_sym.st_other = (V)) + (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V)) +#endif extern asection *gdb_section; +#ifndef obj_frob_file #define obj_frob_file elf_frob_file +#endif extern void elf_frob_file PARAMS ((void)); +#ifndef obj_frob_file_after_relocs #define obj_frob_file_after_relocs elf_frob_file_after_relocs +#endif extern void elf_frob_file_after_relocs PARAMS ((void)); #define obj_app_file elf_file_symbol @@ -99,34 +141,53 @@ extern void obj_elf_section_change_hook PARAMS ((void)); extern void obj_elf_section PARAMS ((int)); extern void obj_elf_previous PARAMS ((int)); extern void obj_elf_version PARAMS ((int)); +extern void obj_elf_common PARAMS ((int)); +extern void obj_elf_data PARAMS ((int)); +extern void obj_elf_text PARAMS ((int)); /* BFD wants to write the udata field, which is a no-no for the globally defined sections. */ +#ifndef obj_sec_sym_ok_for_reloc #define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0) +#endif + +void elf_obj_read_begin_hook PARAMS ((void)); +#ifndef obj_read_begin_hook +#define obj_read_begin_hook elf_obj_read_begin_hook +#endif + +void elf_obj_symbol_new_hook PARAMS ((symbolS *)); +#ifndef obj_symbol_new_hook +#define obj_symbol_new_hook elf_obj_symbol_new_hook +#endif /* When setting one symbol equal to another, by default we probably want them to have the same "size", whatever it means in the current context. */ +#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST,SRC) \ do \ { \ - if ((SRC)->sy_obj.size) \ + struct elf_obj_sy *srcelf = symbol_get_obj (SRC); \ + struct elf_obj_sy *destelf = symbol_get_obj (DEST); \ + if (srcelf->size) \ { \ - if ((DEST)->sy_obj.size == NULL) \ - (DEST)->sy_obj.size = \ + if (destelf->size == NULL) \ + destelf->size = \ (expressionS *) xmalloc (sizeof (expressionS)); \ - *(DEST)->sy_obj.size = *(SRC)->sy_obj.size; \ + *destelf->size = *srcelf->size; \ } \ else \ { \ - if ((DEST)->sy_obj.size != NULL) \ - free ((DEST)->sy_obj.size); \ - (DEST)->sy_obj.size = NULL; \ + if (destelf->size != NULL) \ + free (destelf->size); \ + destelf->size = NULL; \ } \ S_SET_SIZE ((DEST), S_GET_SIZE (SRC)); \ S_SET_OTHER ((DEST), S_GET_OTHER (SRC)); \ } \ while (0) +#endif /* Stabs go in a separate section. */ #define SEPARATE_STAB_SECTIONS 1 @@ -136,30 +197,7 @@ while (0) extern void obj_elf_init_stab_section PARAMS ((segT)); #define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg) -#ifdef TC_ALPHA -#define ECOFF_DEBUGGING alpha_flag_mdebug -extern int alpha_flag_mdebug; -#endif - -/* For now, always set ECOFF_DEBUGGING for a MIPS target. */ -#ifdef TC_MIPS -#ifdef MIPS_STABS_ELF -#define ECOFF_DEBUGGING 0 -#else -#define ECOFF_DEBUGGING 1 -#endif /* MIPS_STABS_ELF */ -#endif /* TC_MIPS */ - #ifdef ECOFF_DEBUGGING -/* If we are generating ECOFF debugging information, we need some - additional fields for each symbol. */ -#undef TARGET_SYMBOL_FIELDS -#define TARGET_SYMBOL_FIELDS \ - ELF_TARGET_SYMBOL_FIELDS \ - struct efdr *ecoff_file; \ - struct localsym *ecoff_symbol; \ - valueT ecoff_extern_size; - /* We smuggle stabs in ECOFF rather than using a separate section. The Irix linker can not handle a separate stabs section. */ @@ -170,25 +208,28 @@ extern int alpha_flag_mdebug; #define INIT_STAB_SECTION(seg) \ ((void)(ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0))) +#undef OBJ_PROCESS_STAB #define OBJ_PROCESS_STAB(seg, what, string, type, other, desc) \ if (ECOFF_DEBUGGING) \ ecoff_stab ((seg), (what), (string), (type), (other), (desc)) #endif /* ECOFF_DEBUGGING */ -extern void elf_frob_symbol PARAMS ((struct symbol *, int *)); +extern void elf_frob_symbol PARAMS ((symbolS *, int *)); #ifndef obj_frob_symbol #define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt) #endif extern void elf_pop_insert PARAMS ((void)); +#ifndef obj_pop_insert #define obj_pop_insert() elf_pop_insert() +#endif #ifndef OBJ_MAYBE_ELF #define obj_ecoff_set_ext elf_ecoff_set_ext #ifdef ANSI_PROTOTYPES struct ecoff_extr; #endif -extern void elf_ecoff_set_ext PARAMS ((struct symbol *, struct ecoff_extr *)); +extern void elf_ecoff_set_ext PARAMS ((symbolS *, struct ecoff_extr *)); #endif #endif /* _OBJ_ELF_H */ diff --git a/gas/config/obj-evax.h b/gas/config/obj-evax.h index 1d9db19..745b1fe 100644 --- a/gas/config/obj-evax.h +++ b/gas/config/obj-evax.h @@ -1,5 +1,5 @@ /* This file is obj-evax.h - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 2000 Free Software Foundation, Inc. Contributed by Klaus Kämpf (kkaempf@progis.de) of proGIS Software, Aachen, Germany. @@ -85,6 +85,8 @@ typedef void *object_headers; #define LKP_S_K_SIZE 16 +#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 3 + /* * Local Variables: * comment-column: 0 diff --git a/gas/config/obj-multi.h b/gas/config/obj-multi.h index fe8d98d..42b7eb3 100644 --- a/gas/config/obj-multi.h +++ b/gas/config/obj-multi.h @@ -1,50 +1,104 @@ -/* hi */ +/* Multiple object format emulation. + Copyright (C) 1995, 96, 97, 99, 2000 + 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. */ + +#ifndef _OBJ_MULTI_H +#define _OBJ_MULTI_H + +#ifdef OBJ_HEADER +#include OBJ_HEADER +#else #include "emul.h" #include "targ-cpu.h" -#define OUTPUT_FLAVOR (this_format->flavor) -#define obj_frob_symbol(S,P) (this_format->frob_symbol)(S,&(P)) -#define obj_frob_file (this_format->frob_file) -#define obj_frob_file_after_relocs (this_format->frob_file_after_relocs) -#define obj_ecoff_set_ext (this_format->ecoff_set_ext) -#define obj_pop_insert (this_format->pop_insert) -#define obj_read_begin_hook() (this_format->read_begin_hook?this_format->read_begin_hook():(void)0) -#define obj_symbol_new_hook (this_format->symbol_new_hook) -#define obj_sec_sym_ok_for_reloc (this_format->sec_sym_ok_for_reloc) -#define S_GET_SIZE (this_format->s_get_size) -#define S_SET_SIZE (this_format->s_set_size) -#define S_GET_ALIGN (this_format->s_get_align) -#define S_SET_ALIGN (this_format->s_set_align) -#define OBJ_COPY_SYMBOL_ATTRIBUTES (this_format->copy_symbol_attributes) -#define OBJ_PROCESS_STAB (this_format->process_stab) - -#if defined (OBJ_MAYBE_ECOFF) || (defined (OBJ_MAYBE_ELF) && defined (TC_MIPS)) -#define ECOFF_DEBUGGING 1 -#endif +#define OUTPUT_FLAVOR \ + (this_format->flavor) -/* FIXME: What's the story here? Why do we have to define - OBJ_SYMFIELD_TYPE both here and in obj-elf.h? */ -#ifdef OBJ_MAYBE_ELF -struct elf_obj_sy -{ - expressionS *size; - char *versioned_name; -}; -#define OBJ_SYMFIELD_TYPE struct elf_obj_sy -#define ELF_TARGET_SYMBOL_FIELDS int local:1; -#else -#define ELF_TARGET_SYMBOL_FIELDS -#endif +#define obj_frob_symbol(S,P) \ + (*this_format->frob_symbol) (S, &(P)) -#ifdef ECOFF_DEBUGGING -struct efdr; -struct localsym; -#define ECOFF_DEBUG_TARGET_SYMBOL_FIELDS struct efdr *ecoff_file; struct localsym *ecoff_symbol; valueT ecoff_extern_size; -#else -#define ECOFF_DEBUG_TARGET_SYMBOL_FIELDS +#define obj_frob_file() \ + (this_format->frob_file \ + ? (*this_format->frob_file) () \ + : (void) 0) + +#define obj_frob_file_after_relocs() \ + (this_format->frob_file_after_relocs \ + ? (*this_format->frob_file_after_relocs) () \ + : (void) 0) + +#define obj_ecoff_set_ext \ + (*this_format->ecoff_set_ext) + +#define obj_pop_insert \ + (*this_format->pop_insert) + +#define obj_read_begin_hook() \ + (this_format->read_begin_hook \ + ? (*this_format->read_begin_hook) () \ + : (void) 0) + +#define obj_symbol_new_hook(S) \ + (this_format->symbol_new_hook \ + ? (*this_format->symbol_new_hook) (S) \ + : (void) 0) + +#define obj_sec_sym_ok_for_reloc(A) \ + (this_format->sec_sym_ok_for_reloc \ + ? (*this_format->sec_sym_ok_for_reloc) (A) \ + : 0) + +#define S_GET_SIZE \ + (*this_format->s_get_size) + +#define S_SET_SIZE \ + (*this_format->s_set_size) + +#define S_GET_ALIGN \ + (*this_format->s_get_align) + +#define S_SET_ALIGN \ + (*this_format->s_set_align) + +#define S_GET_OTHER \ + (*this_format->s_get_other) + +#define S_GET_DESC \ + (*this_format->s_get_desc) + +#define OBJ_COPY_SYMBOL_ATTRIBUTES(d,s) \ + (this_format->copy_symbol_attributes \ + ? (*this_format->copy_symbol_attributes) (d, s) \ + : (void) 0) + +#define OBJ_PROCESS_STAB(SEG,W,S,T,O,D) \ + (this_format->process_stab \ + ? (*this_format->process_stab) (SEG,W,S,T,O,D) \ + : (void) 0) + +#ifdef OBJ_MAYBE_ELF +/* We need OBJ_SYMFIELD_TYPE so that symbol_get_obj is defined in symbol.c + We also need various STAB defines for stab.c */ +#include "obj-elf.h" #endif -#define TARGET_SYMBOL_FIELDS \ - ELF_TARGET_SYMBOL_FIELDS \ - ECOFF_DEBUG_TARGET_SYMBOL_FIELDS +#endif /* !OBJ_HEADER */ +#endif /* _OBJ_MULTI_H */ diff --git a/gas/config/obj-som.c b/gas/config/obj-som.c index 80af18f..65d4ada 100644 --- a/gas/config/obj-som.c +++ b/gas/config/obj-som.c @@ -26,11 +26,11 @@ #include "aout/stab_gnu.h" #include "obstack.h" -/* SOM does not need any pseudo-ops. */ +static void obj_som_weak PARAMS ((int)); const pseudo_typeS obj_pseudo_table[] = { - {NULL} + {"weak", obj_som_weak, 0} }; static int version_seen = 0; @@ -305,3 +305,35 @@ som_frob_file () { bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0); } + +static void +obj_som_weak (ignore) + int ignore ATTRIBUTE_UNUSED; +{ + char *name; + int c; + symbolS *symbolP; + + do + { + name = input_line_pointer; + c = get_symbol_end (); + symbolP = symbol_find_or_make (name); + *input_line_pointer = c; + SKIP_WHITESPACE (); + S_SET_WEAK (symbolP); +#if 0 + symbol_get_obj (symbolP)->local = 1; +#endif + if (c == ',') + { + input_line_pointer++; + SKIP_WHITESPACE (); + if (*input_line_pointer == '\n') + c = '\n'; + } + } + while (c == ','); + demand_empty_rest_of_line (); +} + diff --git a/gas/config/obj-vms.h b/gas/config/obj-vms.h index ac0c1fb..ad8fdce 100644 --- a/gas/config/obj-vms.h +++ b/gas/config/obj-vms.h @@ -1,5 +1,5 @@ /* VMS object file format - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -214,18 +214,17 @@ typedef struct nlist obj_symbol_type; /* Symbol table entry */ /* Force structure tags into scope so that their use in prototypes will never be their first occurance. */ struct fix; -struct symbol; struct frag; /* obj-vms routines visible to the rest of gas. */ extern void tc_aout_fix_to_chars PARAMS ((char *,struct fix *,relax_addressT)); -extern int vms_resolve_symbol_redef PARAMS ((struct symbol *)); +extern int vms_resolve_symbol_redef PARAMS ((symbolS *)); #define RESOLVE_SYMBOL_REDEFINITION(X) vms_resolve_symbol_redef(X) /* Compiler-generated label "__vax_g_doubles" is used to augment .stabs. */ -extern void vms_check_for_special_label PARAMS ((struct symbol *)); +extern void vms_check_for_special_label PARAMS ((symbolS *)); #define obj_frob_label(X) vms_check_for_special_label(X) extern void vms_check_for_main PARAMS ((void)); diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index 568617f..61dba4b 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -4,7 +4,7 @@ Written by Alessandro Forin, based on earlier gas-1.38 target CPU files. Modified by Ken Raeburn for gas-2.x and ECOFF support. Modified by Richard Henderson for ELF support. - Modified by Klaus K"ampf for EVAX (openVMS/Alpha) support. + Modified by Klaus K"ampf for EVAX (OpenVMS/Alpha) support. This file is part of GAS, the GNU Assembler. @@ -51,6 +51,7 @@ #include "as.h" #include "subsegs.h" +#include "struc-symbol.h" #include "ecoff.h" #include "opcode/alpha.h" @@ -64,6 +65,9 @@ /* Local types */ +#define TOKENIZE_ERROR -1 +#define TOKENIZE_ERROR_REPORT -2 + #define MAX_INSN_FIXUPS 2 #define MAX_INSN_ARGS 5 @@ -78,11 +82,22 @@ struct alpha_insn unsigned insn; int nfixups; struct alpha_fixup fixups[MAX_INSN_FIXUPS]; + unsigned sequence[MAX_INSN_FIXUPS]; }; enum alpha_macro_arg { - MACRO_EOA = 1, MACRO_IR, MACRO_PIR, MACRO_CPIR, MACRO_FPR, MACRO_EXP + MACRO_EOA = 1, + MACRO_IR, + MACRO_PIR, + MACRO_OPIR, + MACRO_CPIR, + MACRO_FPR, + MACRO_EXP, + MACRO_LITERAL, + MACRO_BASE, + MACRO_BYTOFF, + MACRO_JSR }; struct alpha_macro @@ -93,11 +108,25 @@ struct alpha_macro enum alpha_macro_arg argsets[16]; }; -/* Two extra symbols we want to see in our input. This is a blatent - misuse of the expressionS.X_op field. */ +/* Extra expression types. */ + +#define O_pregister O_md1 /* O_register, in parentheses */ +#define O_cpregister O_md2 /* + a leading comma */ + +#ifdef RELOC_OP_P +/* Note, the alpha_reloc_op table below depends on the ordering + of O_literal .. O_gprelow. */ +#define O_literal O_md3 /* !literal relocation */ +#define O_lituse_base O_md4 /* !lituse_base relocation */ +#define O_lituse_bytoff O_md5 /* !lituse_bytoff relocation */ +#define O_lituse_jsr O_md6 /* !lituse_jsr relocation */ +#define O_gpdisp O_md7 /* !gpdisp relocation */ +#define O_gprelhigh O_md8 /* !gprelhigh relocation */ +#define O_gprellow O_md9 /* !gprellow relocation */ + +#define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_gprellow) +#endif -#define O_pregister (O_max+1) /* O_register, but in parentheses */ -#define O_cpregister (O_pregister+1) /* + a leading comma */ /* Macros for extracting the type and number of encoded register tokens */ @@ -181,7 +210,8 @@ static void assemble_tokens PARAMS ((const char *, const expressionS *, int, int)); static int load_expression - PARAMS ((int, const expressionS *, int *, expressionS *)); + PARAMS ((int, const expressionS *, int *, expressionS *, + const expressionS *)); static void emit_ldgp PARAMS ((const expressionS *, int, const PTR)); static void emit_division PARAMS ((const expressionS *, int, const PTR)); @@ -236,6 +266,10 @@ static void select_gp_value PARAMS ((void)); #endif static void alpha_align PARAMS ((int, char *, symbolS *, int)); +#ifdef RELOC_OP_P +static void alpha_adjust_symtab_relocs PARAMS ((bfd *, asection *, PTR)); +#endif + /* Generic assembler global variables which must be defined by all targets. */ @@ -433,6 +467,110 @@ static int alpha_flag_show_after_trunc = 0; /* -H */ #endif +#ifdef RELOC_OP_P +/* A table to map the spelling of a relocation operand into an appropriate + bfd_reloc_code_real_type type. The table is assumed to be ordered such + that op-O_literal indexes into it. */ + +#define ALPHA_RELOC_TABLE(op) \ +&alpha_reloc_op[ ((!USER_RELOC_P (op)) \ + ? (abort (), 0) \ + : (int)(op) - (int)O_literal) ] + +#define LITUSE_BASE 1 +#define LITUSE_BYTOFF 2 +#define LITUSE_JSR 3 + +static const struct alpha_reloc_op_tag { + const char *name; /* string to lookup */ + size_t length; /* size of the string */ + bfd_reloc_code_real_type reloc; /* relocation before frob */ + operatorT op; /* which operator to use */ + int lituse; /* addened to specify lituse */ +} alpha_reloc_op[] = { + + { + "literal", /* name */ + sizeof ("literal")-1, /* length */ + BFD_RELOC_ALPHA_USER_LITERAL, /* reloc */ + O_literal, /* op */ + 0, /* lituse */ + }, + + { + "lituse_base", /* name */ + sizeof ("lituse_base")-1, /* length */ + BFD_RELOC_ALPHA_USER_LITUSE_BASE, /* reloc */ + O_lituse_base, /* op */ + LITUSE_BASE, /* lituse */ + }, + + { + "lituse_bytoff", /* name */ + sizeof ("lituse_bytoff")-1, /* length */ + BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, /* reloc */ + O_lituse_bytoff, /* op */ + LITUSE_BYTOFF, /* lituse */ + }, + + { + "lituse_jsr", /* name */ + sizeof ("lituse_jsr")-1, /* length */ + BFD_RELOC_ALPHA_USER_LITUSE_JSR, /* reloc */ + O_lituse_jsr, /* op */ + LITUSE_JSR, /* lituse */ + }, + + { + "gpdisp", /* name */ + sizeof ("gpdisp")-1, /* length */ + BFD_RELOC_ALPHA_USER_GPDISP, /* reloc */ + O_gpdisp, /* op */ + 0, /* lituse */ + }, + + { + "gprelhigh", /* name */ + sizeof ("gprelhigh")-1, /* length */ + BFD_RELOC_ALPHA_USER_GPRELHIGH, /* reloc */ + O_gprelhigh, /* op */ + 0, /* lituse */ + }, + + { + "gprellow", /* name */ + sizeof ("gprellow")-1, /* length */ + BFD_RELOC_ALPHA_USER_GPRELLOW, /* reloc */ + O_gprellow, /* op */ + 0, /* lituse */ + }, +}; + +static const int alpha_num_reloc_op + = sizeof(alpha_reloc_op) / sizeof(*alpha_reloc_op); + +/* Maximum # digits needed to hold the largest sequence # */ +#define ALPHA_RELOC_DIGITS 25 + +/* Whether a sequence number is valid. */ +#define ALPHA_RELOC_SEQUENCE_OK(X) ((X) > 0 && ((unsigned)(X)) == (X)) + +/* Structure to hold explict sequence information. */ +struct alpha_literal_tag +{ + fixS *lituse; /* head of linked list of !literals */ + segT segment; /* segment relocs are in or undefined_section*/ + int multi_section_p; /* True if more than one section was used */ + unsigned sequence; /* sequence # */ + unsigned n_literals; /* # of literals */ + unsigned n_lituses; /* # of lituses */ + char string[1]; /* printable form of sequence to hash with */ +}; + +/* Hash table to link up literals with the appropriate lituse */ +static struct hash_control *alpha_literal_hash; +#endif + /* A table of CPU names and opcode sets. */ static const struct cpu_type @@ -466,7 +604,7 @@ static const struct cpu_type { "ev6", AXP_OPCODE_BASE|AXP_OPCODE_BWX|AXP_OPCODE_MAX|AXP_OPCODE_CIX }, { "all", AXP_OPCODE_BASE }, - { 0 } + { 0, 0 } }; /* The macro table */ @@ -474,67 +612,48 @@ static const struct cpu_type static const struct alpha_macro alpha_macros[] = { /* Load/Store macros */ { "lda", emit_lda, NULL, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_LITERAL, MACRO_BASE, MACRO_EOA } }, { "ldah", emit_ldah, NULL, { MACRO_IR, MACRO_EXP, MACRO_EOA } }, { "ldl", emit_ir_load, "ldl", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldl_l", emit_ir_load, "ldl_l", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldq", emit_ir_load, "ldq", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_LITERAL, MACRO_EOA } }, { "ldq_l", emit_ir_load, "ldq_l", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldq_u", emit_ir_load, "ldq_u", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldf", emit_loadstore, "ldf", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldg", emit_loadstore, "ldg", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "lds", emit_loadstore, "lds", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldt", emit_loadstore, "ldt", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldb", emit_ldX, (PTR)0, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldbu", emit_ldXu, (PTR)0, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldw", emit_ldX, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldwu", emit_ldXu, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "uldw", emit_uldX, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "uldwu", emit_uldXu, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "uldl", emit_uldX, (PTR)2, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "uldlu", emit_uldXu, (PTR)2, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "uldq", emit_uldXu, (PTR)3, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ldgp", emit_ldgp, NULL, { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA } }, @@ -559,48 +678,34 @@ static const struct alpha_macro alpha_macros[] = { #endif { "stl", emit_loadstore, "stl", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stl_c", emit_loadstore, "stl_c", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stq", emit_loadstore, "stq", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stq_c", emit_loadstore, "stq_c", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stq_u", emit_loadstore, "stq_u", - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stf", emit_loadstore, "stf", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stg", emit_loadstore, "stg", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "sts", emit_loadstore, "sts", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stt", emit_loadstore, "stt", - { MACRO_FPR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_FPR, MACRO_EXP, MACRO_EOA } }, + { MACRO_FPR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stb", emit_stX, (PTR)0, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "stw", emit_stX, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ustw", emit_ustX, (PTR)1, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ustl", emit_ustX, (PTR)2, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, { "ustq", emit_ustX, (PTR)3, - { MACRO_IR, MACRO_EXP, MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA } }, + { MACRO_IR, MACRO_EXP, MACRO_OPIR, MACRO_BASE, MACRO_EOA } }, /* Arithmetic macros */ #if 0 @@ -663,15 +768,15 @@ static const struct alpha_macro alpha_macros[] = { MACRO_IR, MACRO_EXP, MACRO_EOA */ } }, { "jsr", emit_jsrjmp, "jsr", - { MACRO_PIR, MACRO_EXP, MACRO_EOA, - MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA, - MACRO_EXP, MACRO_EOA } }, + { MACRO_PIR, MACRO_EXP, MACRO_JSR, MACRO_EOA, + MACRO_PIR, MACRO_JSR, MACRO_EOA, + MACRO_IR, MACRO_EXP, MACRO_JSR, MACRO_EOA, + MACRO_EXP, MACRO_JSR, MACRO_EOA } }, { "jmp", emit_jsrjmp, "jmp", - { MACRO_PIR, MACRO_EXP, MACRO_EOA, - MACRO_PIR, MACRO_EOA, - MACRO_IR, MACRO_EXP, MACRO_EOA, - MACRO_EXP, MACRO_EOA } }, + { MACRO_PIR, MACRO_EXP, MACRO_JSR, MACRO_EOA, + MACRO_PIR, MACRO_JSR, MACRO_EOA, + MACRO_IR, MACRO_EXP, MACRO_JSR, MACRO_EOA, + MACRO_EXP, MACRO_JSR, MACRO_EOA } }, { "ret", emit_retjcr, "ret", { MACRO_IR, MACRO_EXP, MACRO_EOA, MACRO_IR, MACRO_EOA, @@ -695,7 +800,7 @@ static const struct alpha_macro alpha_macros[] = { MACRO_EOA } }, }; -static const int alpha_num_macros +static const unsigned int alpha_num_macros = sizeof(alpha_macros) / sizeof(*alpha_macros); /* Public interface functions */ @@ -709,6 +814,13 @@ md_begin () { unsigned int i; + /* Verify that X_op field is wide enough. */ + { + expressionS e; + e.X_op = O_max; + assert (e.X_op == O_max); + } + /* Create the opcode hash table */ alpha_opcode_hash = hash_new (); @@ -806,6 +918,11 @@ md_begin () #endif /* OBJ_ELF */ subseg_set(text_section, 0); + +#ifdef RELOC_OP_P + /* Create literal lookup hash table. */ + alpha_literal_hash = hash_new(); +#endif } /* The public interface to the instruction assembler. */ @@ -816,10 +933,11 @@ md_assemble (str) { char opname[32]; /* current maximum is 13 */ expressionS tok[MAX_INSN_ARGS]; - int ntok, opnamelen, trunclen; + int ntok, trunclen; + size_t opnamelen; /* split off the opcode */ - opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/468"); + opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/46819"); trunclen = (opnamelen < sizeof (opname) - 1 ? opnamelen : sizeof (opname) - 1); @@ -829,7 +947,9 @@ md_assemble (str) /* tokenize the rest of the line */ if ((ntok = tokenize_arguments (str + opnamelen, tok, MAX_INSN_ARGS)) < 0) { - as_bad (_("syntax error")); + if (ntok != TOKENIZE_ERROR_REPORT) + as_bad (_("syntax error")); + return; } @@ -1081,7 +1201,7 @@ md_apply_fix (fixP, valueP) #endif do_reloc_gp: - fixP->fx_addsy = section_symbol (absolute_section); + fixP->fx_addsy = section_symbol (now_seg); md_number_to_chars (fixpos, value, 2); break; @@ -1157,6 +1277,19 @@ md_apply_fix (fixP, valueP) return 1; #endif +#ifdef RELOC_OP_P + case BFD_RELOC_ALPHA_USER_LITERAL: + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + return 1; + + case BFD_RELOC_ALPHA_USER_GPDISP: + case BFD_RELOC_ALPHA_USER_GPRELHIGH: + case BFD_RELOC_ALPHA_USER_GPRELLOW: + abort (); +#endif + default: { const struct alpha_operand *operand; @@ -1165,7 +1298,7 @@ md_apply_fix (fixP, valueP) as_fatal (_("unhandled relocation type %s"), bfd_get_reloc_code_name (fixP->fx_r_type)); - assert (-(int)fixP->fx_r_type < alpha_num_operands); + assert (-(int)fixP->fx_r_type < (int)alpha_num_operands); operand = &alpha_operands[-(int)fixP->fx_r_type]; /* The rest of these fixups only exist internally during symbol @@ -1173,7 +1306,7 @@ md_apply_fix (fixP, valueP) Therefore they must be completely resolved as constants. */ if (fixP->fx_addsy != 0 - && fixP->fx_addsy->bsym->section != absolute_section) + && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section) as_bad_where (fixP->fx_file, fixP->fx_line, _("non-absolute expression in constant field")); @@ -1317,6 +1450,15 @@ alpha_force_relocation (f) case BFD_RELOC_ALPHA_LINKAGE: case BFD_RELOC_ALPHA_CODEADDR: #endif +#ifdef RELOC_OP_P + case BFD_RELOC_ALPHA_USER_LITERAL: + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + case BFD_RELOC_ALPHA_USER_GPDISP: + case BFD_RELOC_ALPHA_USER_GPRELHIGH: + case BFD_RELOC_ALPHA_USER_GPRELLOW: +#endif return 1; case BFD_RELOC_23_PCREL_S2: @@ -1326,7 +1468,7 @@ alpha_force_relocation (f) return 0; default: - assert((int)f->fx_r_type < 0 && -(int)f->fx_r_type < alpha_num_operands); + assert((int)f->fx_r_type < 0 && -(int)f->fx_r_type < (int)alpha_num_operands); return 0; } } @@ -1358,6 +1500,9 @@ alpha_fix_adjustable (f) #ifdef OBJ_ELF case BFD_RELOC_ALPHA_ELF_LITERAL: #endif +#ifdef RELOC_OP_P + case BFD_RELOC_ALPHA_USER_LITERAL: +#endif #ifdef OBJ_EVAX case BFD_RELOC_ALPHA_LINKAGE: case BFD_RELOC_ALPHA_CODEADDR: @@ -1365,6 +1510,14 @@ alpha_fix_adjustable (f) return 1; case BFD_RELOC_ALPHA_LITUSE: +#ifdef RELOC_OP_P + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + case BFD_RELOC_ALPHA_USER_GPDISP: + case BFD_RELOC_ALPHA_USER_GPRELHIGH: + case BFD_RELOC_ALPHA_USER_GPRELLOW: +#endif return 0; case BFD_RELOC_GPREL32: @@ -1376,7 +1529,7 @@ alpha_fix_adjustable (f) default: assert ((int)f->fx_r_type < 0 - && - (int)f->fx_r_type < alpha_num_operands); + && - (int)f->fx_r_type < (int)alpha_num_operands); return 1; } /*NOTREACHED*/ @@ -1387,13 +1540,14 @@ alpha_fix_adjustable (f) arelent * tc_gen_reloc (sec, fixp) - asection *sec; + asection *sec ATTRIBUTE_UNUSED; fixS *fixp; { arelent *reloc; reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; /* Make sure none of our internal relocations make it this far. @@ -1435,7 +1589,7 @@ tc_gen_reloc (sec, fixp) */ if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy)) && !S_IS_COMMON(fixp->fx_addsy)) - reloc->addend -= fixp->fx_addsy->bsym->value; + reloc->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value; #endif } @@ -1450,7 +1604,7 @@ tc_gen_reloc (sec, fixp) int tc_get_register (frame) - int frame; + int frame ATTRIBUTE_UNUSED; { int framereg = AXP_REG_SP; @@ -1491,6 +1645,250 @@ alpha_frob_file_before_adjust () #endif /* OBJ_ECOFF */ +#ifdef RELOC_OP_P + +/* Before the relocations are written, reorder them, so that user supplied + !lituse relocations follow the appropriate !literal relocations. Also + convert the gas-internal relocations to the appropriate linker relocations. + */ + +void +alpha_adjust_symtab () +{ + if (alpha_literal_hash) + { +#ifdef DEBUG2_ALPHA + fprintf (stderr, "alpha_adjust_symtab called\n"); +#endif + + /* Go over each section, reordering the relocations so that all of the + explicit LITUSE's are adjacent to the explicit LITERAL's */ + bfd_map_over_sections (stdoutput, alpha_adjust_symtab_relocs, (char *) 0); + } +} + + +/* Inner function to move LITUSE's next to the LITERAL. */ + +static void +alpha_adjust_symtab_relocs (abfd, sec, ptr) + bfd *abfd; + asection *sec; + PTR ptr; +{ + segment_info_type *seginfo = seg_info (sec); + fixS **prevP; + fixS *fixp; + fixS *next; + fixS *lituse; + int n_lituses = 0; + +#ifdef DEBUG2_ALPHA + int n = 0; + int n_literals = 0; + int n_dup_literals = 0; +#endif + + /* If seginfo is NULL, we did not create this section; don't do anything with + it. By using a pointer to a pointer, we can update the links in place. */ + if (seginfo == NULL) + return; + + /* If there are no relocations, skip the section. */ + if (! seginfo->fix_root) + return; + + /* First rebuild the fixup chain without the expicit lituse's. */ + prevP = &(seginfo->fix_root); + for (fixp = seginfo->fix_root; fixp; fixp = next) + { + next = fixp->fx_next; + fixp->fx_next = (fixS *)0; +#ifdef DEBUG2_ALPHA + n++; +#endif + + switch (fixp->fx_r_type) + { + default: + *prevP = fixp; + prevP = &(fixp->fx_next); +#ifdef DEBUG2_ALPHA + fprintf (stderr, + "alpha_adjust_symtab_relocs: 0x%lx, other relocation %s\n", + (long)fixp, + bfd_get_reloc_code_name (fixp->fx_r_type)); +#endif + break; + + case BFD_RELOC_ALPHA_USER_LITERAL: + *prevP = fixp; + prevP = &(fixp->fx_next); + /* prevent assembler from trying to adjust the offset */ +#ifdef DEBUG2_ALPHA + n_literals++; + if (fixp->tc_fix_data.info->n_literals != 1) + n_dup_literals++; + fprintf (stderr, + "alpha_adjust_symtab_relocs: 0x%lx, !literal!%.6d, # literals = %2d\n", + (long)fixp, + fixp->tc_fix_data.info->sequence, + fixp->tc_fix_data.info->n_literals); +#endif + break; + + /* do not link in lituse's */ + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + n_lituses++; + if (fixp->tc_fix_data.info->n_literals == 0) + as_bad_where (fixp->fx_file, fixp->fx_line, + _("No !literal!%d was found"), + fixp->tc_fix_data.info->sequence); +#ifdef DEBUG2_ALPHA + fprintf (stderr, + "alpha_adjust_symtab_relocs: 0x%lx, !lituse !%.6d, # lituses = %2d, next_lituse = 0x%lx\n", + (long)fixp, + fixp->tc_fix_data.info->sequence, + fixp->tc_fix_data.info->n_lituses, + (long)fixp->tc_fix_data.next_lituse); +#endif + break; + } + } + + /* If there were any lituses, go and add them to the chain, unless there is + more than one !literal for a given sequence number. They are linked + through the next_lituse field in reverse order, so as we go through the + next_lituse chain, we effectively reverse the chain once again. If there + was more than one !literal, we fall back to loading up the address w/o + optimization. Also, if the !literals/!lituses are spread in different + segments (happens in the Linux kernel semaphores), suppress the + optimization. */ + if (n_lituses) + { + for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next) + { + switch (fixp->fx_r_type) + { + default: + break; + + case BFD_RELOC_ALPHA_USER_LITERAL: +#ifdef OBJ_ELF + fixp->fx_r_type = BFD_RELOC_ALPHA_ELF_LITERAL; +#else + fixp->fx_r_type = BFD_RELOC_ALPHA_LITERAL; /* XXX check this */ +#endif + if (fixp->tc_fix_data.info->n_literals == 1 + && ! fixp->tc_fix_data.info->multi_section_p) + { + for (lituse = fixp->tc_fix_data.info->lituse; + lituse != (fixS *)0; + lituse = lituse->tc_fix_data.next_lituse) + { + lituse->fx_next = fixp->fx_next; + fixp->fx_next = lituse; + } + } + break; + + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + fixp->fx_r_type = BFD_RELOC_ALPHA_LITUSE; + break; + } + } + } + +#ifdef DEBUG2_ALPHA + fprintf (stderr, "alpha_adjust_symtab_relocs: %s, %d literal%s, %d duplicate literal%s, %d lituse%s\n\n", + sec->name, + n_literals, (n_literals == 1) ? "" : "s", + n_dup_literals, (n_dup_literals == 1) ? "" : "s", + n_lituses, (n_lituses == 1) ? "" : "s"); +#endif +} + +#endif /* RELOC_OP_P */ + + +#ifdef DEBUG_ALPHA +static void +debug_exp (tok, ntok) + expressionS tok[]; + int ntok; +{ + int i; + + fprintf (stderr, "debug_exp: %d tokens", ntok); + for (i = 0; i < ntok; i++) + { + expressionS *t = &tok[i]; + const char *name; + switch (t->X_op) + { + default: name = "unknown"; break; + case O_illegal: name = "O_illegal"; break; + case O_absent: name = "O_absent"; break; + case O_constant: name = "O_constant"; break; + case O_symbol: name = "O_symbol"; break; + case O_symbol_rva: name = "O_symbol_rva"; break; + case O_register: name = "O_register"; break; + case O_big: name = "O_big"; break; + case O_uminus: name = "O_uminus"; break; + case O_bit_not: name = "O_bit_not"; break; + case O_logical_not: name = "O_logical_not"; break; + case O_multiply: name = "O_multiply"; break; + case O_divide: name = "O_divide"; break; + case O_modulus: name = "O_modulus"; break; + case O_left_shift: name = "O_left_shift"; break; + case O_right_shift: name = "O_right_shift"; break; + case O_bit_inclusive_or: name = "O_bit_inclusive_or"; break; + case O_bit_or_not: name = "O_bit_or_not"; break; + case O_bit_exclusive_or: name = "O_bit_exclusive_or"; break; + case O_bit_and: name = "O_bit_and"; break; + case O_add: name = "O_add"; break; + case O_subtract: name = "O_subtract"; break; + case O_eq: name = "O_eq"; break; + case O_ne: name = "O_ne"; break; + case O_lt: name = "O_lt"; break; + case O_le: name = "O_le"; break; + case O_ge: name = "O_ge"; break; + case O_gt: name = "O_gt"; break; + case O_logical_and: name = "O_logical_and"; break; + case O_logical_or: name = "O_logical_or"; break; + case O_index: name = "O_index"; break; + case O_pregister: name = "O_pregister"; break; + case O_cpregister: name = "O_cpregister"; break; + case O_literal: name = "O_literal"; break; + case O_lituse_base: name = "O_lituse_base"; break; + case O_lituse_bytoff: name = "O_lituse_bytoff"; break; + case O_lituse_jsr: name = "O_lituse_jsr"; break; + case O_gpdisp: name = "O_gpdisp"; break; + case O_gprelhigh: name = "O_gprelhigh"; break; + case O_gprellow: name = "O_gprellow"; break; + case O_md10: name = "O_md10"; break; + case O_md11: name = "O_md11"; break; + case O_md12: name = "O_md12"; break; + case O_md13: name = "O_md13"; break; + case O_md14: name = "O_md14"; break; + case O_md15: name = "O_md15"; break; + case O_md16: name = "O_md16"; break; + } + + fprintf (stderr, ", %s(%s, %s, %d)", name, + (t->X_add_symbol) ? S_GET_NAME (t->X_add_symbol) : "--", + (t->X_op_symbol) ? S_GET_NAME (t->X_op_symbol) : "--", + (int)t->X_add_number); + } + fprintf (stderr, "\n"); + fflush (stderr); +} +#endif + /* Parse the arguments to an opcode. */ static int @@ -1502,6 +1900,16 @@ tokenize_arguments (str, tok, ntok) expressionS *end_tok = tok + ntok; char *old_input_line_pointer; int saw_comma = 0, saw_arg = 0; +#ifdef DEBUG_ALPHA + expressionS *orig_tok = tok; +#endif +#ifdef RELOC_OP_P + char *p; + const struct alpha_reloc_op_tag *r; + int c, i; + size_t len; + int reloc_found_p = 0; +#endif memset (tok, 0, sizeof (*tok) * ntok); @@ -1517,6 +1925,72 @@ tokenize_arguments (str, tok, ntok) case '\0': goto fini; +#ifdef RELOC_OP_P + case '!': + /* A relocation operand can be placed after the normal operand on an + assembly language statement, and has the following form: + !relocation_type!sequence_number. */ + if (reloc_found_p) + { /* only support one relocation op per insn */ + as_bad (_("More than one relocation op per insn")); + goto err_report; + } + + if (!saw_arg) + goto err; + + for (p = ++input_line_pointer; + ((c = *p) != '!' && c != ';' && c != '#' && c != ',' + && !is_end_of_line[c]); + p++) + ; + + /* Parse !relocation_type */ + len = p - input_line_pointer; + if (len == 0) + { + as_bad (_("No relocation operand")); + goto err_report; + } + + if (c != '!') + { + as_bad (_("No !sequence-number after !%s"), input_line_pointer); + goto err_report; + } + + r = &alpha_reloc_op[0]; + for (i = alpha_num_reloc_op-1; i >= 0; i--, r++) + { + if (len == r->length + && memcmp (input_line_pointer, r->name, len) == 0) + break; + } + if (i < 0) + { + as_bad (_("Unknown relocation operand: !%s"), input_line_pointer); + goto err_report; + } + + input_line_pointer = ++p; + + /* Parse !sequence_number */ + memset (tok, '\0', sizeof (expressionS)); + expression (tok); + + if (tok->X_op != O_constant + || ! ALPHA_RELOC_SEQUENCE_OK (tok->X_add_number)) + { + as_bad (_("Bad sequence number: !%s!%s"), r->name, input_line_pointer); + goto err_report; + } + + tok->X_op = r->op; + reloc_found_p = 1; + ++tok; + break; +#endif + case ',': ++input_line_pointer; if (saw_comma || !saw_arg) @@ -1547,6 +2021,7 @@ tokenize_arguments (str, tok, ntok) default: if (saw_arg && !saw_comma) goto err; + expression (tok); if (tok->X_op == O_illegal || tok->X_op == O_absent) goto err; @@ -1562,11 +2037,22 @@ fini: if (saw_comma) goto err; input_line_pointer = old_input_line_pointer; + +#ifdef DEBUG_ALPHA + debug_exp (orig_tok, ntok - (end_tok - tok)); +#endif + return ntok - (end_tok - tok); err: input_line_pointer = old_input_line_pointer; - return -1; + return TOKENIZE_ERROR; + +#ifdef RELOC_OP_P +err_report: + input_line_pointer = old_input_line_pointer; + return TOKENIZE_ERROR_REPORT; +#endif } /* Search forward through all variants of an opcode looking for a @@ -1704,24 +2190,38 @@ find_macro_match(first_macro, tok, pntok) tokidx = 0; break; + /* index register */ case MACRO_IR: if (tokidx >= ntok || tok[tokidx].X_op != O_register || !is_ir_num(tok[tokidx].X_add_number)) goto match_failed; ++tokidx; break; + + /* parenthesized index register */ case MACRO_PIR: if (tokidx >= ntok || tok[tokidx].X_op != O_pregister || !is_ir_num(tok[tokidx].X_add_number)) goto match_failed; ++tokidx; break; + + /* optional parenthesized index register */ + case MACRO_OPIR: + if (tokidx < ntok && tok[tokidx].X_op == O_pregister + && is_ir_num(tok[tokidx].X_add_number)) + ++tokidx; + break; + + /* leading comma with a parenthesized index register */ case MACRO_CPIR: if (tokidx >= ntok || tok[tokidx].X_op != O_cpregister || !is_ir_num(tok[tokidx].X_add_number)) goto match_failed; ++tokidx; break; + + /* floating point register */ case MACRO_FPR: if (tokidx >= ntok || tok[tokidx].X_op != O_register || !is_fpr_num(tok[tokidx].X_add_number)) @@ -1729,6 +2229,7 @@ find_macro_match(first_macro, tok, pntok) ++tokidx; break; + /* normal expression */ case MACRO_EXP: if (tokidx >= ntok) goto match_failed; @@ -1739,6 +2240,15 @@ find_macro_match(first_macro, tok, pntok) case O_register: case O_pregister: case O_cpregister: +#ifdef RELOC_OP_P + case O_literal: + case O_lituse_base: + case O_lituse_bytoff: + case O_lituse_jsr: + case O_gpdisp: + case O_gprelhigh: + case O_gprellow: +#endif goto match_failed; default: @@ -1747,6 +2257,38 @@ find_macro_match(first_macro, tok, pntok) ++tokidx; break; + /* optional !literal! */ + case MACRO_LITERAL: +#ifdef RELOC_OP_P + if (tokidx < ntok && tok[tokidx].X_op == O_literal) + tokidx++; +#endif + break; + + /* optional !lituse_base! */ + case MACRO_BASE: +#ifdef RELOC_OP_P + if (tokidx < ntok && tok[tokidx].X_op == O_lituse_base) + tokidx++; +#endif + break; + + /* optional !lituse_bytoff! */ + case MACRO_BYTOFF: +#ifdef RELOC_OP_P + if (tokidx < ntok && tok[tokidx].X_op == O_lituse_bytoff) + tokidx++; +#endif + break; + + /* optional !lituse_jsr! */ + case MACRO_JSR: +#ifdef RELOC_OP_P + if (tokidx < ntok && tok[tokidx].X_op == O_lituse_jsr) + tokidx++; +#endif + break; + match_failed: while (*arg != MACRO_EOA) ++arg; @@ -1837,7 +2379,7 @@ assemble_insn(opcode, tok, ntok, insn) for (argidx = opcode->operands; *argidx; ++argidx) { const struct alpha_operand *operand = &alpha_operands[*argidx]; - const expressionS *t; + const expressionS *t = (const expressionS *)0; if (operand->flags & AXP_OPERAND_FAKE) { @@ -1858,8 +2400,10 @@ assemble_insn(opcode, tok, ntok, insn) break; case AXP_OPERAND_DEFAULT_ZERO: { - static const expressionS zero_exp = { 0, 0, 0, O_constant, 1 }; + static expressionS zero_exp; t = &zero_exp; + zero_exp.X_op = O_constant; + zero_exp.X_unsigned = 1; } break; default: @@ -1926,10 +2470,14 @@ emit_insn (insn) /* Apply the fixups in order */ for (i = 0; i < insn->nfixups; ++i) { - const struct alpha_operand *operand; + const struct alpha_operand *operand = (const struct alpha_operand *)0; struct alpha_fixup *fixup = &insn->fixups[i]; int size, pcrel; fixS *fixP; +#ifdef RELOC_OP_P + char buffer[ALPHA_RELOC_DIGITS]; + struct alpha_literal_tag *info; +#endif /* Some fixups are only used internally and so have no howto */ if ((int)fixup->reloc < 0) @@ -1938,29 +2486,48 @@ emit_insn (insn) size = 4; pcrel = ((operand->flags & AXP_OPERAND_RELATIVE) != 0); } -#ifdef OBJ_ELF - /* These relocation types are only used internally. */ - else if (fixup->reloc == BFD_RELOC_ALPHA_GPDISP_HI16 - || fixup->reloc == BFD_RELOC_ALPHA_GPDISP_LO16) + else switch (fixup->reloc) { - size = 2, pcrel = 0; - } +#ifdef OBJ_ELF + /* These relocation types are only used internally. */ + case BFD_RELOC_ALPHA_GPDISP_HI16: + case BFD_RELOC_ALPHA_GPDISP_LO16: + size = 2; + pcrel = 0; + break; +#endif +#ifdef RELOC_OP_P + /* and these also are internal only relocations */ + case BFD_RELOC_ALPHA_USER_LITERAL: + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + case BFD_RELOC_ALPHA_USER_GPDISP: + case BFD_RELOC_ALPHA_USER_GPRELHIGH: + case BFD_RELOC_ALPHA_USER_GPRELLOW: + size = 2; + pcrel = 0; + break; #endif - else - { - reloc_howto_type *reloc_howto - = bfd_reloc_type_lookup (stdoutput, fixup->reloc); - assert (reloc_howto); - size = bfd_get_reloc_size (reloc_howto); - pcrel = reloc_howto->pc_relative; + default: + { + reloc_howto_type *reloc_howto + = bfd_reloc_type_lookup (stdoutput, fixup->reloc); + assert (reloc_howto); + + size = bfd_get_reloc_size (reloc_howto); + pcrel = reloc_howto->pc_relative; + } + assert (size >= 1 && size <= 4); + break; } - assert (size >= 1 && size <= 4); fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, size, &fixup->exp, pcrel, fixup->reloc); - /* Turn off complaints that the addend is too large for some fixups */ + /* Turn off complaints that the addend is too large for some fixups, + and copy in the sequence number for the explicit relocations. */ switch (fixup->reloc) { case BFD_RELOC_ALPHA_GPDISP_LO16: @@ -1974,6 +2541,69 @@ emit_insn (insn) fixP->fx_no_overflow = 1; break; +#ifdef RELOC_OP_P + case BFD_RELOC_ALPHA_USER_LITERAL: + fixP->fx_no_overflow = 1; + sprintf (buffer, "!%u", insn->sequence[i]); + info = ((struct alpha_literal_tag *) + hash_find (alpha_literal_hash, buffer)); + + if (! info) + { + size_t len = strlen (buffer); + const char *errmsg; + + info = ((struct alpha_literal_tag *) + xcalloc (sizeof (struct alpha_literal_tag) + len, 1)); + + info->segment = now_seg; + info->sequence = insn->sequence[i]; + strcpy (info->string, buffer); + errmsg = hash_insert (alpha_literal_hash, info->string, (PTR)info); + if (errmsg) + as_bad (errmsg); + } + + ++info->n_literals; + + if (info->segment != now_seg) + info->multi_section_p = 1; + + fixP->tc_fix_data.info = info; + break; + + case BFD_RELOC_ALPHA_USER_LITUSE_BASE: + case BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF: + case BFD_RELOC_ALPHA_USER_LITUSE_JSR: + sprintf (buffer, "!%u", insn->sequence[i]); + info = ((struct alpha_literal_tag *) + hash_find (alpha_literal_hash, buffer)); + + if (! info) + { + size_t len = strlen (buffer); + const char *errmsg; + + info = ((struct alpha_literal_tag *) + xcalloc (sizeof (struct alpha_literal_tag) + len, 1)); + + info->segment = now_seg; + info->sequence = insn->sequence[i]; + strcpy (info->string, buffer); + errmsg = hash_insert (alpha_literal_hash, info->string, (PTR)info); + if (errmsg) + as_bad (errmsg); + } + info->n_lituses++; + fixP->tc_fix_data.info = info; + fixP->tc_fix_data.next_lituse = info->lituse; + info->lituse = fixP; + if (info->segment != now_seg) + info->multi_section_p = 1; + + break; +#endif + default: if ((int)fixup->reloc < 0) { @@ -2053,6 +2683,17 @@ assemble_tokens (opname, tok, ntok, local_macros_on) } } +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, opname); + ntok--; + } +#endif + /* search opcodes */ opcode = (const struct alpha_opcode *) hash_find (alpha_opcode_hash, opname); if (opcode) @@ -2096,8 +2737,8 @@ static const char * const ldXu_op[] = { "ldbu", "ldwu", NULL, NULL }; static void emit_ldgp (tok, ntok, unused) const expressionS *tok; - int ntok; - const PTR unused; + int ntok ATTRIBUTE_UNUSED; + const PTR unused ATTRIBUTE_UNUSED; { #ifdef OBJ_AOUT FIXME @@ -2109,8 +2750,16 @@ FIXME expressionS newtok[3]; expressionS addend; - /* We're going to need this symbol in md_apply_fix(). */ - (void) section_symbol (absolute_section); +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, "ldgp"); + ntok--; + } +#endif #ifdef OBJ_ECOFF if (regno (tok[2].X_add_number) == AXP_REG_PV) @@ -2175,7 +2824,7 @@ add_to_link_pool (basesym, sym, addend) segment_info_type *seginfo = seg_info (alpha_link_section); fixS *fixp; - offset = -basesym->sy_obj; + offset = - *symbol_get_obj (basesym); /* @@ This assumes all entries in a given section will be of the same size... Probably correct, but unwise to rely on. */ @@ -2225,15 +2874,19 @@ add_to_link_pool (basesym, sym, addend) i.e. "ldq $targ, LIT($gp); addq $targ, $0, $targ". Odd, perhaps, but this is what OSF/1 does. + If explicit relocations of the form !literal! are allowed, + and used, then explict_reloc with be an expression pointer. + Finally, the return value is true if the calling macro may emit a LITUSE reloc if otherwise appropriate. */ static int -load_expression (targreg, exp, pbasereg, poffset) +load_expression (targreg, exp, pbasereg, poffset, explicit_reloc) int targreg; const expressionS *exp; int *pbasereg; expressionS *poffset; + const expressionS *explicit_reloc; { int emit_lituse = 0; offsetT addend = exp->X_add_number; @@ -2285,6 +2938,7 @@ load_expression (targreg, exp, pbasereg, poffset) assemble_tokens_to_insn ("ldq", newtok, 3, &insn); + assert (explicit_reloc == (const expressionS *)0); assert (insn.nfixups == 1); insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITERAL; #endif /* OBJ_ECOFF */ @@ -2322,13 +2976,25 @@ load_expression (targreg, exp, pbasereg, poffset) assemble_tokens_to_insn ("ldq", newtok, 3, &insn); assert (insn.nfixups == 1); - insn.fixups[0].reloc = BFD_RELOC_ALPHA_ELF_LITERAL; + if (!explicit_reloc) + insn.fixups[0].reloc = BFD_RELOC_ALPHA_ELF_LITERAL; + else + { +#ifdef RELOC_OP_P + insn.fixups[0].reloc + = (ALPHA_RELOC_TABLE (explicit_reloc->X_op))->reloc; + insn.sequence[0] = explicit_reloc->X_add_number; +#else + abort (); +#endif + } #endif /* OBJ_ELF */ #ifdef OBJ_EVAX offsetT link; /* Find symbol or symbol pointer in link section. */ + assert (explicit_reloc == (const expressionS *)0); if (exp->X_add_symbol == alpha_evax_proc.symbol) { if (range_signed_16 (addend)) @@ -2387,12 +3053,14 @@ load_expression (targreg, exp, pbasereg, poffset) break; case O_constant: + assert (explicit_reloc == (const expressionS *)0); break; case O_subtract: /* Assume that this difference expression will be resolved to an absolute value and that that value will fit in 16 bits. */ + assert (explicit_reloc == (const expressionS *)0); set_tok_reg (newtok[0], targreg); newtok[1] = *exp; set_tok_preg (newtok[2], basereg); @@ -2498,8 +3166,9 @@ load_expression (targreg, exp, pbasereg, poffset) } insn.nfixups++; insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE; - insn.fixups[0].exp.X_op = O_constant; - insn.fixups[0].exp.X_add_number = 1; + insn.fixups[0].exp.X_op = O_symbol; + insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[0].exp.X_add_number = LITUSE_BASE; emit_lituse = 0; emit_insn (&insn); @@ -2579,19 +3248,66 @@ load_expression (targreg, exp, pbasereg, poffset) large constants. */ static void -emit_lda (tok, ntok, unused) +emit_lda (tok, ntok, opname) const expressionS *tok; int ntok; - const PTR unused; + const PTR opname; { int basereg; + const expressionS *reloc = (const expressionS *)0; + +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const struct alpha_reloc_op_tag *r; + + reloc = &tok[ntok-1]; + r = ALPHA_RELOC_TABLE (reloc->X_op); + switch (reloc->X_op) + { + default: + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc->X_add_number, (const char *)opname); + + reloc = (const expressionS *)0; + ntok--; + break; + + case O_literal: + ntok--; + break; + + /* For lda $x,0($x)!lituse_base!y, don't use load_expression, since + it is really too general for our needs. Instead just generate the + lda directly. */ + case O_lituse_base: + if (ntok != 4 + || tok[0].X_op != O_register + || !is_ir_num(tok[0].X_add_number) + || tok[1].X_op != O_constant + || tok[2].X_op != O_pregister + || !is_ir_num(tok[2].X_add_number)) + { + as_bad (_("bad instruction format for lda !%s!%d"), r->name, + reloc->X_add_number); + + reloc = (const expressionS *)0; + ntok--; + break; + } + + emit_loadstore (tok, ntok, "lda"); + return; + } + } +#endif if (ntok == 2) basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register); else basereg = tok[2].X_add_number; - (void) load_expression (tok[0].X_add_number, &tok[1], &basereg, NULL); + (void) load_expression (tok[0].X_add_number, &tok[1], &basereg, NULL, reloc); } /* The ldah macro differs from the ldah instruction in that it has $31 @@ -2600,11 +3316,22 @@ emit_lda (tok, ntok, unused) static void emit_ldah (tok, ntok, unused) const expressionS *tok; - int ntok; - const PTR unused; + int ntok ATTRIBUTE_UNUSED; + const PTR unused ATTRIBUTE_UNUSED; { expressionS newtok[3]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, "ldah"); + ntok--; + } +#endif + newtok[0] = tok[0]; newtok[1] = tok[1]; set_tok_preg (newtok[2], AXP_REG_ZERO); @@ -2626,19 +3353,66 @@ emit_ir_load (tok, ntok, opname) expressionS newtok[3]; struct alpha_insn insn; +#ifdef RELOC_OP_P + const expressionS *reloc = (const expressionS *)0; + + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const struct alpha_reloc_op_tag *r; + + reloc = &tok[ntok-1]; + switch (reloc->X_op) + { + case O_lituse_base: + ntok--; + break; + + case O_literal: + if (strcmp ((const char *)opname, "ldq") == 0) + { + emit_lda (tok, ntok, opname); + return; + } + + /* fall through */ + default: + ntok--; + r = ALPHA_RELOC_TABLE (reloc->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc->X_add_number, (const char *)opname); + } + } +#endif + if (ntok == 2) basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register); else basereg = tok[2].X_add_number; lituse = load_expression (tok[0].X_add_number, &tok[1], &basereg, - &newtok[1]); + &newtok[1], (const expressionS *)0); newtok[0] = tok[0]; set_tok_preg (newtok[2], basereg); assemble_tokens_to_insn ((const char *)opname, newtok, 3, &insn); +#ifdef RELOC_OP_P + if (reloc) + { + int nfixups = insn.nfixups; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc->X_op); + + assert (nfixups < MAX_INSN_FIXUPS); + insn.fixups[nfixups].reloc = r->reloc; + insn.fixups[nfixups].exp.X_op = O_symbol; + insn.fixups[nfixups].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[nfixups].exp.X_add_number = r->lituse; + insn.sequence[nfixups] = reloc->X_add_number; + insn.nfixups++; + } +#endif + if (lituse) { assert (insn.nfixups < MAX_INSN_FIXUPS); @@ -2649,8 +3423,9 @@ emit_ir_load (tok, ntok, opname) } insn.nfixups++; insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE; - insn.fixups[0].exp.X_op = O_constant; - insn.fixups[0].exp.X_add_number = 1; + insn.fixups[0].exp.X_op = O_symbol; + insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[0].exp.X_add_number = LITUSE_BASE; } emit_insn (&insn); @@ -2669,6 +3444,21 @@ emit_loadstore (tok, ntok, opname) expressionS newtok[3]; struct alpha_insn insn; +#ifdef RELOC_OP_P + const expressionS *reloc = (const expressionS *)0; + + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + reloc = &tok[--ntok]; + if (reloc->X_op != O_lituse_base) + { + const struct alpha_reloc_op_tag *r = &alpha_reloc_op[ reloc->X_md ]; + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc->X_add_number, (const char *)opname); + } + } +#endif + if (ntok == 2) basereg = (tok[1].X_op == O_constant ? AXP_REG_ZERO : alpha_gp_register); else @@ -2679,7 +3469,8 @@ emit_loadstore (tok, ntok, opname) if (alpha_noat_on) as_bad (_("macro requires $at register while noat in effect")); - lituse = load_expression (AXP_REG_AT, &tok[1], &basereg, &newtok[1]); + lituse = load_expression (AXP_REG_AT, &tok[1], &basereg, &newtok[1], + (const expressionS *)0); } else { @@ -2692,6 +3483,22 @@ emit_loadstore (tok, ntok, opname) assemble_tokens_to_insn ((const char *)opname, newtok, 3, &insn); +#ifdef RELOC_OP_P + if (reloc) + { + int nfixups = insn.nfixups; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc->X_op); + + assert (nfixups < MAX_INSN_FIXUPS); + insn.fixups[nfixups].reloc = r->reloc; + insn.fixups[nfixups].exp.X_op = O_symbol; + insn.fixups[nfixups].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[nfixups].exp.X_add_number = r->lituse; + insn.sequence[nfixups] = reloc->X_add_number; + insn.nfixups++; + } +#endif + if (lituse) { assert (insn.nfixups < MAX_INSN_FIXUPS); @@ -2702,8 +3509,9 @@ emit_loadstore (tok, ntok, opname) } insn.nfixups++; insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE; - insn.fixups[0].exp.X_op = O_constant; - insn.fixups[0].exp.X_add_number = 1; + insn.fixups[0].exp.X_op = O_symbol; + insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[0].exp.X_add_number = LITUSE_BASE; } emit_insn (&insn); @@ -2723,6 +3531,19 @@ emit_ldXu (tok, ntok, vlgsize) { expressionS newtok[3]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r + = ALPHA_RELOC_TABLE (reloc_exp->X_op); + + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, "ldbu/ldwu"); + ntok--; + } +#endif + if (alpha_noat_on) as_bad (_("macro requires $at register while noat in effect")); @@ -2834,10 +3655,21 @@ static void emit_ldil (tok, ntok, unused) const expressionS *tok; int ntok; - const PTR unused; + const PTR unused ATTRIBUTE_UNUSED; { expressionS newtok[2]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, "ldil"); + ntok--; + } +#endif + memcpy (newtok, tok, sizeof(newtok)); newtok[1].X_add_number = sign_extend_32 (tok[1].X_add_number); @@ -3002,6 +3834,19 @@ emit_sextX (tok, ntok, vlgsize) int bitshift = 64 - 8 * (1 << lgsize); expressionS newtok[3]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r + = ALPHA_RELOC_TABLE (reloc_exp->X_op); + + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, "setxt"); + ntok--; + } +#endif + /* emit "sll src,bits,dst" */ newtok[0] = tok[0]; @@ -3048,6 +3893,17 @@ emit_division (tok, ntok, symname) symbolS *sym; expressionS newtok[3]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, (char char *)symname); + ntok--; + } +#endif + xr = regno (tok[0].X_add_number); yr = regno (tok[1].X_add_number); @@ -3147,6 +4003,17 @@ emit_division (tok, ntok, symname) symbolS *sym; expressionS newtok[3]; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, (const char *)symname); + ntok--; + } +#endif + xr = regno (tok[0].X_add_number); yr = regno (tok[1].X_add_number); @@ -3243,6 +4110,17 @@ emit_jsrjmp (tok, ntok, vopname) expressionS newtok[3]; int r, tokidx = 0, lituse = 0; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, opname); + ntok--; + } +#endif + if (tokidx < ntok && tok[tokidx].X_op == O_register) r = regno (tok[tokidx++].X_add_number); else @@ -3259,7 +4137,8 @@ emit_jsrjmp (tok, ntok, vopname) else { int basereg = alpha_gp_register; - lituse = load_expression (r = AXP_REG_PV, &tok[tokidx], &basereg, NULL); + lituse = load_expression (r = AXP_REG_PV, &tok[tokidx], &basereg, NULL, + (const expressionS *)0); } #endif @@ -3287,8 +4166,9 @@ emit_jsrjmp (tok, ntok, vopname) } insn.nfixups++; insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE; - insn.fixups[0].exp.X_op = O_constant; - insn.fixups[0].exp.X_add_number = 3; + insn.fixups[0].exp.X_op = O_symbol; + insn.fixups[0].exp.X_add_symbol = section_symbol (now_seg); + insn.fixups[0].exp.X_add_number = LITUSE_JSR; } emit_insn (&insn); @@ -3307,6 +4187,17 @@ emit_retjcr (tok, ntok, vopname) expressionS newtok[3]; int r, tokidx = 0; +#ifdef RELOC_OP_P + if (ntok && USER_RELOC_P (tok[ntok-1].X_op)) + { + const expressionS *reloc_exp = &tok[ntok-1]; + const struct alpha_reloc_op_tag *r = ALPHA_RELOC_TABLE (reloc_exp->X_op); + as_bad (_("Cannot use !%s!%d with %s"), r->name, + (int)reloc_exp->X_add_number, opname); + ntok--; + } +#endif + if (tokidx < ntok && tok[tokidx].X_op == O_register) r = regno (tok[tokidx++].X_add_number); else @@ -3457,7 +4348,7 @@ s_alpha_comm (ignore) p = frag_more (temp); new_seg->flags |= SEC_IS_COMMON; if (! S_IS_DEFINED (symbolP)) - symbolP->bsym->section = new_seg; + S_SET_SEGMENT (symbolP, new_seg); #else S_SET_VALUE (symbolP, (valueT) temp); #endif @@ -3468,7 +4359,7 @@ s_alpha_comm (ignore) subseg_set (current_section, current_subsec); #endif - know (symbolP->sy_frag == &zero_address_frag); + know (symbol_get_frag (symbolP) == &zero_address_frag); demand_empty_rest_of_line (); } @@ -3534,7 +4425,7 @@ s_alpha_section (ignore) static void s_alpha_ent (dummy) - int dummy; + int dummy ATTRIBUTE_UNUSED; { if (ECOFF_DEBUGGING) ecoff_directive_ent (0); @@ -3557,7 +4448,7 @@ s_alpha_ent (dummy) as_warn (_("nested .ent directives")); sym = symbol_find_or_make (name); - sym->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; alpha_cur_ent_sym = sym; /* The .ent directive is sometimes followed by a number. Not sure @@ -3578,7 +4469,7 @@ s_alpha_ent (dummy) static void s_alpha_end (dummy) - int dummy; + int dummy ATTRIBUTE_UNUSED; { if (ECOFF_DEBUGGING) ecoff_directive_end (0); @@ -3604,12 +4495,13 @@ s_alpha_end (dummy) /* Create an expression to calculate the size of the function. */ if (sym) { - sym->sy_obj.size = (expressionS *) xmalloc (sizeof (expressionS)); - sym->sy_obj.size->X_op = O_subtract; - sym->sy_obj.size->X_add_symbol + symbol_get_obj (sym)->size = + (expressionS *) xmalloc (sizeof (expressionS)); + symbol_get_obj (sym)->size->X_op = O_subtract; + symbol_get_obj (sym)->size->X_add_symbol = symbol_new ("L0\001", now_seg, frag_now_fix (), frag_now); - sym->sy_obj.size->X_op_symbol = sym; - sym->sy_obj.size->X_add_number = 0; + symbol_get_obj (sym)->size->X_op_symbol = sym; + symbol_get_obj (sym)->size->X_add_number = 0; } alpha_cur_ent_sym = NULL; @@ -3637,7 +4529,7 @@ s_alpha_mask (fp) static void s_alpha_frame (dummy) - int dummy; + int dummy ATTRIBUTE_UNUSED; { if (ECOFF_DEBUGGING) ecoff_directive_frame (0); @@ -3647,7 +4539,7 @@ s_alpha_frame (dummy) static void s_alpha_prologue (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { symbolS *sym; int arg; @@ -3695,7 +4587,7 @@ s_alpha_coff_wrapper (which) ecoff_directive_loc, }; - assert (which >= 0 && which < sizeof(fns)/sizeof(*fns)); + assert (which >= 0 && which < (int)(sizeof(fns)/sizeof(*fns))); if (ECOFF_DEBUGGING) (*fns[which])(0); @@ -3765,7 +4657,7 @@ s_alpha_ent (ignore) } symbol = make_expr_symbol (&symexpr); - symbol->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbol)->flags |= BSF_FUNCTION; alpha_evax_proc.symbol = symbol; demand_empty_rest_of_line (); @@ -3837,7 +4729,8 @@ s_alpha_pdesc (ignore) return; } - alpha_evax_proc.symbol->sy_obj = (valueT)seginfo->literal_pool_size; + *symbol_get_obj (alpha_evax_proc.symbol) = + (valueT) seginfo->literal_pool_size; expression (&exp); if (exp.X_op != O_symbol) @@ -3849,7 +4742,8 @@ s_alpha_pdesc (ignore) entry_sym = make_expr_symbol (&exp); /* Save bfd symbol of proc desc in function symbol. */ - alpha_evax_proc.symbol->bsym->udata.p = (PTR)entry_sym->bsym; + symbol_get_bfdsym (alpha_evax_proc.symbol)->udata.p + = symbol_get_bfdsym (entry_sym); SKIP_WHITESPACE (); if (*input_line_pointer++ != ',') @@ -4140,14 +5034,14 @@ s_alpha_file (ignore) extern char *demand_copy_string PARAMS ((int *lenP)); sprintf (case_hack, "", - alpha_flag_hash_long_names, alpha_flag_show_after_trunc); + alpha_flag_hash_long_names, alpha_flag_show_after_trunc); s = symbol_find_or_make (case_hack); - s->bsym->flags |= BSF_FILE; + symbol_get_bfdsym (s)->flags |= BSF_FILE; get_absolute_expression (); s = symbol_find_or_make (demand_copy_string (&length)); - s->bsym->flags |= BSF_FILE; + symbol_get_bfdsym (s)->flags |= BSF_FILE; demand_empty_rest_of_line (); return; @@ -4158,7 +5052,7 @@ s_alpha_file (ignore) static void s_alpha_gprel32 (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { expressionS e; char *p; @@ -4253,7 +5147,7 @@ s_alpha_float_cons (type) static void s_alpha_proc (is_static) - int is_static; + int is_static ATTRIBUTE_UNUSED; { char *name; char c; @@ -4282,7 +5176,7 @@ s_alpha_proc (is_static) input_line_pointer++; temp = get_absolute_expression (); } - /* symbolP->sy_other = (signed char) temp; */ + /* *symbol_get_obj (symbolP) = (signed char) temp; */ as_warn (_("unhandled: .proc %s,%d"), name, temp); demand_empty_rest_of_line (); } @@ -4292,7 +5186,7 @@ s_alpha_proc (is_static) static void s_alpha_set (x) - int x; + int x ATTRIBUTE_UNUSED; { char *name, ch, *s; int yesno = 1; @@ -4329,7 +5223,7 @@ s_alpha_set (x) static void s_alpha_base (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { #if 0 if (first_32bit_quadrant) @@ -4364,7 +5258,7 @@ s_alpha_base (ignore) static void s_alpha_align (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int align; char fill, *pfill; @@ -4462,7 +5356,7 @@ s_alpha_ucons (bytes) static void s_alpha_arch (ignored) - int ignored; + int ignored ATTRIBUTE_UNUSED; { char *name, ch; const struct cpu_type *p; @@ -4706,7 +5600,7 @@ alpha_align (n, pfill, label, force) int n; char *pfill; symbolS *label; - int force; + int force ATTRIBUTE_UNUSED; { if (alpha_current_align >= n) return; @@ -4742,14 +5636,13 @@ alpha_align (n, pfill, label, force) alpha_current_align = n; - if (label != NULL) + if (label != NULL && S_GET_SEGMENT (label) == now_seg) { - assert (S_GET_SEGMENT (label) == now_seg); - label->sy_frag = frag_now; + symbol_set_frag (label, frag_now); S_SET_VALUE (label, (valueT) frag_now_fix ()); } - record_alignment(now_seg, n); + record_alignment (now_seg, n); /* ??? if alpha_flag_relax && force && elf, record the requested alignment in a reloc for the linker to see. */ diff --git a/gas/config/tc-alpha.h b/gas/config/tc-alpha.h index ca6903a..632b04e 100644 --- a/gas/config/tc-alpha.h +++ b/gas/config/tc-alpha.h @@ -85,7 +85,7 @@ extern int tc_get_register PARAMS ((int frame)); extern void alpha_frob_ecoff_data PARAMS ((void)); #define tc_frob_label(sym) alpha_define_label (sym) -extern void alpha_define_label PARAMS ((struct symbol *)); +extern void alpha_define_label PARAMS ((symbolS *)); #define md_cons_align(nbytes) alpha_cons_align (nbytes) extern void alpha_cons_align PARAMS ((int)); @@ -102,3 +102,47 @@ extern void alpha_frob_file_before_adjust PARAMS ((void)); { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, \ { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, #endif + +/* Whether to add support for explict !relocation_op!sequence_number. At the + moment, only do this for ELF, though ECOFF could use it as well. */ + +#ifdef OBJ_ELF +#define RELOC_OP_P +#endif + +#ifdef RELOC_OP_P +/* Before the relocations are written, reorder them, so that user supplied + !lituse relocations follow the appropriate !literal relocations. Also + convert the gas-internal relocations to the appropriate linker relocations. + */ +#define tc_adjust_symtab() alpha_adjust_symtab () +extern void alpha_adjust_symtab PARAMS ((void)); + +/* New fields for supporting explicit relocations (such as !literal to mark + where a pointer is loaded from the global table, and !lituse_base to track + all of the normal uses of that pointer). */ + +#define TC_FIX_TYPE struct alpha_fix_tag + +struct alpha_fix_tag +{ + struct fix *next_lituse; /* next !lituse */ + struct alpha_literal_tag *info; /* other members with same sequence */ +}; + +/* Initialize the TC_FIX_TYPE field. */ +#define TC_INIT_FIX_DATA(fixP) \ +do { \ + fixP->tc_fix_data.next_lituse = (struct fix *)0; \ + fixP->tc_fix_data.info = (struct alpha_literal_tag *)0; \ +} while (0) + +/* Work with DEBUG5 to print fields in tc_fix_type. */ +#define TC_FIX_DATA_PRINT(stream,fixP) \ +do { \ + if (fixP->tc_fix_data.info) \ + fprintf (stderr, "\tinfo = 0x%lx, next_lituse = 0x%lx\n", \ + (long)fixP->tc_fix_data.info, \ + (long)fixP->tc_fix_data.next_lituse); \ +} while (0) +#endif diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c index c07c2d7..3aafea3 100644 --- a/gas/config/tc-arc.c +++ b/gas/config/tc-arc.c @@ -1,5 +1,5 @@ /* tc-arc.c -- Assembler for the ARC - Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1997, 1998, 1999 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of GAS, the GNU Assembler. @@ -15,8 +15,9 @@ 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. */ + 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. */ #include #include @@ -797,7 +798,7 @@ arc_common (ignore) S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size); } } - assert (symbolP->sy_frag == &zero_address_frag); + assert (symbol_get_frag (symbolP) == &zero_address_frag); if (*input_line_pointer != ',') { as_bad (_("expected comma after common length")); @@ -830,8 +831,8 @@ arc_common (ignore) if (align) frag_align (align, 0, 0); if (S_GET_SEGMENT (symbolP) == bss_section) - symbolP->sy_frag->fr_symbol = 0; - symbolP->sy_frag = frag_now; + symbol_get_frag (symbolP)->fr_symbol = 0; + symbol_set_frag (symbolP, frag_now); p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, (offsetT) size, (char *) 0); *p = 0; @@ -966,7 +967,7 @@ arc_rename (ignore) new = (char *) xmalloc (strlen (name) + 1); strcpy (new, name); *input_line_pointer = c; - sym->sy_tc.real_name = new; + symbol_get_tc (sym)->real_name = new; demand_empty_rest_of_line (); } @@ -1241,13 +1242,13 @@ get_arc_exp_reloc_type (data_p, default_type, exp, expnew) if (exp->X_op == O_right_shift && exp->X_op_symbol != NULL - && exp->X_op_symbol->sy_value.X_op == O_constant - && exp->X_op_symbol->sy_value.X_add_number == 2 + && symbol_constant_p (exp->X_op_symbol) + && S_GET_VALUE (exp->X_op_symbol) == 2 && exp->X_add_number == 0) { if (exp->X_add_symbol != NULL - && (exp->X_add_symbol->sy_value.X_op == O_constant - || exp->X_add_symbol->sy_value.X_op == O_symbol)) + && (symbol_constant_p (exp->X_add_symbol) + || symbol_equated_p (exp->X_add_symbol))) { *expnew = *exp; expnew->X_op = O_symbol; @@ -1255,9 +1256,10 @@ get_arc_exp_reloc_type (data_p, default_type, exp, expnew) return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J']; } else if (exp->X_add_symbol != NULL - && exp->X_add_symbol->sy_value.X_op == O_subtract) + && (symbol_get_value_expression (exp->X_add_symbol)->X_op + == O_subtract)) { - *expnew = exp->X_add_symbol->sy_value; + *expnew = *symbol_get_value_expression (exp->X_add_symbol); return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J']; } } @@ -1445,7 +1447,8 @@ tc_gen_reloc (section, fixP) reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixP->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy); reloc->address = fixP->fx_frag->fr_address + fixP->fx_where; reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type); if (reloc->howto == (reloc_howto_type *) NULL) @@ -1473,8 +1476,8 @@ int arc_frob_symbol (sym) symbolS *sym; { - if (sym->sy_tc.real_name != (char *) NULL) - S_SET_NAME (sym, sym->sy_tc.real_name); + if (symbol_get_tc (sym)->real_name != (char *) NULL) + S_SET_NAME (sym, symbol_get_tc (sym)->real_name); return 0; } diff --git a/gas/config/tc-arc.h b/gas/config/tc-arc.h index 6a95ff4..5066201 100644 --- a/gas/config/tc-arc.h +++ b/gas/config/tc-arc.h @@ -1,5 +1,5 @@ /* tc-arc.h - Macros and type defines for the ARC. - Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1997, 1999 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of GAS, the GNU Assembler. @@ -66,6 +66,6 @@ struct arc_tc_sy #define TC_SYMFIELD_TYPE struct arc_tc_sy /* Finish up the symbol. */ -extern int arc_frob_symbol PARAMS ((struct symbol *)); +extern int arc_frob_symbol PARAMS ((symbolS *)); #define tc_frob_symbol(sym, punt) punt = arc_frob_symbol (sym) #endif diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index d898bf0..4779b3d 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -1,5 +1,5 @@ /* tc-arm.c -- Assemble for the ARM - Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) Modified by David Taylor (dtaylor@armltd.co.uk) @@ -51,12 +51,18 @@ #define ARM_LONGMUL 0x00000010 /* allow long multiplies */ #define ARM_HALFWORD 0x00000020 /* allow half word loads */ #define ARM_THUMB 0x00000040 /* allow BX instruction */ +#define ARM_EXT_V5 0x00000080 /* allow CLZ etc */ +#define ARM_EXT_V5E 0x00000200 /* "El Segundo" */ -#define ARM_ARCHv4 (ARM_7 | ARM_LONGMUL | ARM_HALFWORD) +/* Architectures are the sum of the base and extensions. */ +#define ARM_ARCH_V4 (ARM_7 | ARM_LONGMUL | ARM_HALFWORD) +#define ARM_ARCH_V4T (ARM_ARCH_V4 | ARM_THUMB) +#define ARM_ARCH_V5 (ARM_ARCH_V4 | ARM_EXT_V5) +#define ARM_ARCH_V5T (ARM_ARCH_V5 | ARM_THUMB) /* Some useful combinations: */ #define ARM_ANY 0x00ffffff -#define ARM_2UP 0x00fffffe +#define ARM_2UP (ARM_ANY - ARM_1) #define ARM_ALL ARM_2UP /* Not arm1 only */ #define ARM_3UP 0x00fffffc #define ARM_6UP 0x00fffff8 /* Includes ARM7 */ @@ -73,7 +79,7 @@ #ifndef CPU_DEFAULT #if defined __thumb__ -#define CPU_DEFAULT (ARM_ARCHv4 | ARM_THUMB) +#define CPU_DEFAULT (ARM_ARCH_V4 | ARM_THUMB) #else #define CPU_DEFAULT ARM_ALL #endif @@ -83,7 +89,8 @@ #define FPU_DEFAULT FPU_ALL #endif -#define streq(a,b) (strcmp (a, b) == 0) +#define streq(a, b) (strcmp (a, b) == 0) +#define skip_whitespace(str) while (* (str) == ' ') ++ (str) static unsigned long cpu_variant = CPU_DEFAULT | FPU_DEFAULT; static int target_oabi = 0; @@ -97,16 +104,16 @@ static boolean pic_code = false; #endif /* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ + pre-processor is disabled, these aren't very useful. */ CONST char comment_chars[] = "@"; /* This array holds the chars that only start a comment at the beginning of a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ + .line and .file directives will appear in the pre-processed output. */ /* Note that input_file.c hand checks for '#' at the beginning of the first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments like this one will always work. */ + #NO_APP at the beginning of its output. */ +/* Also note that comments like this one will always work. */ CONST char line_comment_chars[] = "#"; #ifdef TE_LINUX @@ -115,7 +122,8 @@ CONST char line_separator_chars[] = ";"; CONST char line_separator_chars[] = ""; #endif -/* Chars that can be used to separate mant from exp in floating point nums */ +/* Chars that can be used to separate mant + from exp in floating point numbers. */ CONST char EXP_CHARS[] = "eE"; /* Chars that mean this number is a floating point constant */ @@ -132,10 +140,11 @@ CONST char FLT_CHARS[] = "rRsSfFdDxXeEpP"; symbolS * GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */ #endif -CONST int md_reloc_size = 8; /* Size of relocation record */ - -static int thumb_mode = 0; /* non-zero if assembling thumb instructions */ +CONST int md_reloc_size = 8; /* Size of relocation record */ +static int thumb_mode = 0; /* 0: assemble for ARM, 1: assemble for Thumb, + 2: assemble for Thumb even though target cpu + does not support thumb instructions. */ typedef struct arm_fix { int thumb_mode; @@ -189,7 +198,7 @@ CONST char * fp_const[] = "0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0 }; -/* Number of littlenums required to hold an extended precision number */ +/* Number of littlenums required to hold an extended precision number. */ #define MAX_LITTLENUMS 6 LITTLENUM_TYPE fp_values[NUM_FLOAT_VALS][MAX_LITTLENUMS]; @@ -218,7 +227,7 @@ struct asm_cond unsigned long value; }; -/* This is to save a hash look-up in the common case */ +/* This is to save a hash look-up in the common case. */ #define COND_ALWAYS 0xe0000000 static CONST struct asm_cond conds[] = @@ -243,7 +252,7 @@ static CONST struct asm_cond conds[] = /* Warning: If the top bit of the set_bits is set, then the standard instruction bitmask is ignored, and the new bitmask is taken from - the set_bits: */ + the set_bits: */ struct asm_flg { CONST char * template; /* Basic flag string */ @@ -408,54 +417,54 @@ static CONST struct asm_psr psrs[] = {"spsr_ctl", SPSR_CTL} }; -/* Functions called by parser */ +/* Functions called by parser. */ /* ARM instructions */ -static void do_arit PARAMS ((char *operands, unsigned long flags)); -static void do_cmp PARAMS ((char *operands, unsigned long flags)); -static void do_mov PARAMS ((char *operands, unsigned long flags)); -static void do_ldst PARAMS ((char *operands, unsigned long flags)); -static void do_ldmstm PARAMS ((char *operands, unsigned long flags)); -static void do_branch PARAMS ((char *operands, unsigned long flags)); -static void do_swi PARAMS ((char *operands, unsigned long flags)); -/* Pseudo Op codes */ -static void do_adr PARAMS ((char *operands, unsigned long flags)); -static void do_nop PARAMS ((char *operands, unsigned long flags)); -/* ARM 2 */ -static void do_mul PARAMS ((char *operands, unsigned long flags)); -static void do_mla PARAMS ((char *operands, unsigned long flags)); -/* ARM 3 */ -static void do_swap PARAMS ((char *operands, unsigned long flags)); -/* ARM 6 */ -static void do_msr PARAMS ((char *operands, unsigned long flags)); -static void do_mrs PARAMS ((char *operands, unsigned long flags)); -/* ARM 7M */ -static void do_mull PARAMS ((char *operands, unsigned long flags)); -/* ARM THUMB */ -static void do_bx PARAMS ((char *operands, unsigned long flags)); - -/* Coprocessor Instructions */ -static void do_cdp PARAMS ((char *operands, unsigned long flags)); -static void do_lstc PARAMS ((char *operands, unsigned long flags)); -static void do_co_reg PARAMS ((char *operands, unsigned long flags)); -static void do_fp_ctrl PARAMS ((char *operands, unsigned long flags)); -static void do_fp_ldst PARAMS ((char *operands, unsigned long flags)); -static void do_fp_ldmstm PARAMS ((char *operands, unsigned long flags)); -static void do_fp_dyadic PARAMS ((char *operands, unsigned long flags)); -static void do_fp_monadic PARAMS ((char *operands, unsigned long flags)); -static void do_fp_cmp PARAMS ((char *operands, unsigned long flags)); -static void do_fp_from_reg PARAMS ((char *operands, unsigned long flags)); -static void do_fp_to_reg PARAMS ((char *operands, unsigned long flags)); - -static void fix_new_arm PARAMS ((fragS *frag, int where, - short int size, expressionS *exp, - int pc_rel, int reloc)); -static int arm_reg_parse PARAMS ((char **ccp)); -static int arm_psr_parse PARAMS ((char **ccp)); -static void symbol_locate PARAMS ((symbolS *, CONST char *, segT, - valueT, fragS *)); +static void do_arit PARAMS ((char *, unsigned long)); +static void do_cmp PARAMS ((char *, unsigned long)); +static void do_mov PARAMS ((char *, unsigned long)); +static void do_ldst PARAMS ((char *, unsigned long)); +static void do_ldmstm PARAMS ((char *, unsigned long)); +static void do_branch PARAMS ((char *, unsigned long)); +static void do_swi PARAMS ((char *, unsigned long)); +/* Pseudo Op codes */ +static void do_adr PARAMS ((char *, unsigned long)); +static void do_adrl PARAMS ((char *, unsigned long)); +static void do_nop PARAMS ((char *, unsigned long)); +/* ARM 2 */ +static void do_mul PARAMS ((char *, unsigned long)); +static void do_mla PARAMS ((char *, unsigned long)); +/* ARM 3 */ +static void do_swap PARAMS ((char *, unsigned long)); +/* ARM 6 */ +static void do_msr PARAMS ((char *, unsigned long)); +static void do_mrs PARAMS ((char *, unsigned long)); +/* ARM 7M */ +static void do_mull PARAMS ((char *, unsigned long)); +/* ARM THUMB */ +static void do_bx PARAMS ((char *, unsigned long)); + + +/* Coprocessor Instructions */ +static void do_cdp PARAMS ((char *, unsigned long)); +static void do_lstc PARAMS ((char *, unsigned long)); +static void do_co_reg PARAMS ((char *, unsigned long)); +static void do_fp_ctrl PARAMS ((char *, unsigned long)); +static void do_fp_ldst PARAMS ((char *, unsigned long)); +static void do_fp_ldmstm PARAMS ((char *, unsigned long)); +static void do_fp_dyadic PARAMS ((char *, unsigned long)); +static void do_fp_monadic PARAMS ((char *, unsigned long)); +static void do_fp_cmp PARAMS ((char *, unsigned long)); +static void do_fp_from_reg PARAMS ((char *, unsigned long)); +static void do_fp_to_reg PARAMS ((char *, unsigned long)); + +static void fix_new_arm PARAMS ((fragS *, int, short, expressionS *, int, int)); +static int arm_reg_parse PARAMS ((char **)); +static int arm_psr_parse PARAMS ((char **)); +static void symbol_locate PARAMS ((symbolS *, CONST char *, segT, valueT, fragS *)); static int add_to_lit_pool PARAMS ((void)); -static unsigned validate_immediate PARAMS ((unsigned)); -static int validate_offset_imm PARAMS ((int, int)); +static unsigned validate_immediate PARAMS ((unsigned)); +static unsigned validate_immediate_twopart PARAMS ((unsigned int, unsigned int *)); +static int validate_offset_imm PARAMS ((unsigned int, int)); static void opcode_select PARAMS ((int)); static void end_of_line PARAMS ((char *)); static int reg_required_here PARAMS ((char **, int)); @@ -469,8 +478,7 @@ static int cp_address_required_here PARAMS ((char **)); static int my_get_float_expression PARAMS ((char **)); static int skip_past_comma PARAMS ((char **)); static int walk_no_bignums PARAMS ((symbolS *)); -static int negate_data_op PARAMS ((unsigned long *, - unsigned long)); +static int negate_data_op PARAMS ((unsigned long *, unsigned long)); static int data_op2 PARAMS ((char **)); static int fp_op2 PARAMS ((char **)); static long reg_list PARAMS ((char **)); @@ -484,27 +492,30 @@ static void thumb_mov_compare PARAMS ((char *, int)); static void set_constant_flonums PARAMS ((void)); static valueT md_chars_to_number PARAMS ((char *, int)); static void insert_reg_alias PARAMS ((char *, int)); -static void output_inst PARAMS ((char *)); +static void output_inst PARAMS ((void)); #ifdef OBJ_ELF -static bfd_reloc_code_real_type arm_parse_reloc(void); +static bfd_reloc_code_real_type arm_parse_reloc PARAMS ((void)); #endif /* ARM instructions take 4bytes in the object file, Thumb instructions - take 2: */ + take 2: */ #define INSN_SIZE 4 /* LONGEST_INST is the longest basic instruction name without conditions or - * flags. - * ARM7M has 4 of length 5 - */ + flags. ARM7M has 4 of length 5. */ #define LONGEST_INST 5 + struct asm_opcode { CONST char * template; /* Basic string to match */ unsigned long value; /* Basic instruction code */ - CONST char * comp_suffix; /* Compulsory suffix that must follow conds */ + + /* Compulsory suffix that must follow conds. If "", then the + instruction is not conditional and must have no suffix. */ + CONST char * comp_suffix; + CONST struct asm_flg * flags; /* Bits to toggle if flag 'n' set */ unsigned long variants; /* Which CPU variants this exists for */ /* Function to call to parse args */ @@ -535,11 +546,17 @@ static CONST struct asm_opcode insns[] = {"stm", 0x08000000, NULL, stm_flags, ARM_ANY, do_ldmstm}, {"ldm", 0x08100000, NULL, ldm_flags, ARM_ANY, do_ldmstm}, {"swi", 0x0f000000, NULL, NULL, ARM_ANY, do_swi}, +#ifdef TE_WINCE + {"bl", 0x0b000000, NULL, NULL, ARM_ANY, do_branch}, + {"b", 0x0a000000, NULL, NULL, ARM_ANY, do_branch}, +#else {"bl", 0x0bfffffe, NULL, NULL, ARM_ANY, do_branch}, {"b", 0x0afffffe, NULL, NULL, ARM_ANY, do_branch}, - +#endif + /* Pseudo ops */ {"adr", 0x028f0000, NULL, NULL, ARM_ANY, do_adr}, + {"adrl", 0x028f0000, NULL, NULL, ARM_ANY, do_adrl}, {"nop", 0x01a00000, NULL, NULL, ARM_ANY, do_nop}, /* ARM 2 multiplies */ @@ -613,7 +630,7 @@ static CONST struct asm_opcode insns[] = {"flt", 0x0e000110, "sde", round_flags, FPU_ALL, do_fp_from_reg}, {"fix", 0x0e100110, NULL, fix_flags, FPU_ALL, do_fp_to_reg}, -/* Generic copressor instructions */ +/* Generic copressor instructions. */ {"cdp", 0x0e000000, NULL, NULL, ARM_2UP, do_cdp}, {"ldc", 0x0c100000, NULL, cplong_flag, ARM_2UP, do_lstc}, {"stc", 0x0c000000, NULL, cplong_flag, ARM_2UP, do_lstc}, @@ -621,8 +638,7 @@ static CONST struct asm_opcode insns[] = {"mrc", 0x0e100010, NULL, NULL, ARM_2UP, do_co_reg}, }; -/* defines for various bits that we will want to toggle */ - +/* Defines for various bits that we will want to toggle. */ #define INST_IMMEDIATE 0x02000000 #define OFFSET_REG 0x02000000 #define HWOFFSET_IMM 0x00400000 @@ -630,15 +646,14 @@ static CONST struct asm_opcode insns[] = #define PRE_INDEX 0x01000000 #define INDEX_UP 0x00800000 #define WRITE_BACK 0x00200000 -#define MULTI_SET_PSR 0x00400000 +#define LDM_TYPE_2_OR_3 0x00400000 #define LITERAL_MASK 0xf000f000 #define COND_MASK 0xf0000000 #define OPCODE_MASK 0xfe1fffff #define DATA_OP_SHIFT 21 -/* Codes to distinguish the arithmetic instructions */ - +/* Codes to distinguish the arithmetic instructions. */ #define OPCODE_AND 0 #define OPCODE_EOR 1 #define OPCODE_SUB 2 @@ -656,30 +671,30 @@ static CONST struct asm_opcode insns[] = #define OPCODE_BIC 14 #define OPCODE_MVN 15 -static void do_t_nop PARAMS ((char *operands)); -static void do_t_arit PARAMS ((char *operands)); -static void do_t_add PARAMS ((char *operands)); -static void do_t_asr PARAMS ((char *operands)); -static void do_t_branch9 PARAMS ((char *operands)); -static void do_t_branch12 PARAMS ((char *operands)); -static void do_t_branch23 PARAMS ((char *operands)); -static void do_t_bx PARAMS ((char *operands)); -static void do_t_compare PARAMS ((char *operands)); -static void do_t_ldmstm PARAMS ((char *operands)); -static void do_t_ldr PARAMS ((char *operands)); -static void do_t_ldrb PARAMS ((char *operands)); -static void do_t_ldrh PARAMS ((char *operands)); -static void do_t_lds PARAMS ((char *operands)); -static void do_t_lsl PARAMS ((char *operands)); -static void do_t_lsr PARAMS ((char *operands)); -static void do_t_mov PARAMS ((char *operands)); -static void do_t_push_pop PARAMS ((char *operands)); -static void do_t_str PARAMS ((char *operands)); -static void do_t_strb PARAMS ((char *operands)); -static void do_t_strh PARAMS ((char *operands)); -static void do_t_sub PARAMS ((char *operands)); -static void do_t_swi PARAMS ((char *operands)); -static void do_t_adr PARAMS ((char *operands)); +static void do_t_nop PARAMS ((char *)); +static void do_t_arit PARAMS ((char *)); +static void do_t_add PARAMS ((char *)); +static void do_t_asr PARAMS ((char *)); +static void do_t_branch9 PARAMS ((char *)); +static void do_t_branch12 PARAMS ((char *)); +static void do_t_branch23 PARAMS ((char *)); +static void do_t_bx PARAMS ((char *)); +static void do_t_compare PARAMS ((char *)); +static void do_t_ldmstm PARAMS ((char *)); +static void do_t_ldr PARAMS ((char *)); +static void do_t_ldrb PARAMS ((char *)); +static void do_t_ldrh PARAMS ((char *)); +static void do_t_lds PARAMS ((char *)); +static void do_t_lsl PARAMS ((char *)); +static void do_t_lsr PARAMS ((char *)); +static void do_t_mov PARAMS ((char *)); +static void do_t_push_pop PARAMS ((char *)); +static void do_t_str PARAMS ((char *)); +static void do_t_strb PARAMS ((char *)); +static void do_t_strh PARAMS ((char *)); +static void do_t_sub PARAMS ((char *)); +static void do_t_swi PARAMS ((char *)); +static void do_t_adr PARAMS ((char *)); #define T_OPCODE_MUL 0x4340 #define T_OPCODE_TST 0x4200 @@ -735,7 +750,7 @@ static void do_t_adr PARAMS ((char *operands)); static int thumb_reg PARAMS ((char ** str, int hi_lo)); -#define THUMB_SIZE 2 /* Size of thumb instruction */ +#define THUMB_SIZE 2 /* Size of thumb instruction. */ #define THUMB_REG_LO 0x1 #define THUMB_REG_HI 0x2 #define THUMB_REG_ANY 0x3 @@ -755,7 +770,7 @@ static int thumb_reg PARAMS ((char ** str, int hi_lo)); #define THUMB_PP_PC_LR 0x0100 -/* These three are used for immediate shifts, do not alter */ +/* These three are used for immediate shifts, do not alter. */ #define THUMB_WORD 2 #define THUMB_HALFWORD 1 #define THUMB_BYTE 0 @@ -765,68 +780,70 @@ struct thumb_opcode CONST char * template; /* Basic string to match */ unsigned long value; /* Basic instruction code */ int size; + unsigned long variants; /* Which CPU variants this exists for */ void (* parms) PARAMS ((char *)); /* Function to call to parse args */ }; static CONST struct thumb_opcode tinsns[] = { - {"adc", 0x4140, 2, do_t_arit}, - {"add", 0x0000, 2, do_t_add}, - {"and", 0x4000, 2, do_t_arit}, - {"asr", 0x0000, 2, do_t_asr}, - {"b", T_OPCODE_BRANCH, 2, do_t_branch12}, - {"beq", 0xd0fe, 2, do_t_branch9}, - {"bne", 0xd1fe, 2, do_t_branch9}, - {"bcs", 0xd2fe, 2, do_t_branch9}, - {"bhs", 0xd2fe, 2, do_t_branch9}, - {"bcc", 0xd3fe, 2, do_t_branch9}, - {"bul", 0xd3fe, 2, do_t_branch9}, - {"blo", 0xd3fe, 2, do_t_branch9}, - {"bmi", 0xd4fe, 2, do_t_branch9}, - {"bpl", 0xd5fe, 2, do_t_branch9}, - {"bvs", 0xd6fe, 2, do_t_branch9}, - {"bvc", 0xd7fe, 2, do_t_branch9}, - {"bhi", 0xd8fe, 2, do_t_branch9}, - {"bls", 0xd9fe, 2, do_t_branch9}, - {"bge", 0xdafe, 2, do_t_branch9}, - {"blt", 0xdbfe, 2, do_t_branch9}, - {"bgt", 0xdcfe, 2, do_t_branch9}, - {"ble", 0xddfe, 2, do_t_branch9}, - {"bic", 0x4380, 2, do_t_arit}, - {"bl", 0xf7fffffe, 4, do_t_branch23}, - {"bx", 0x4700, 2, do_t_bx}, - {"cmn", T_OPCODE_CMN, 2, do_t_arit}, - {"cmp", 0x0000, 2, do_t_compare}, - {"eor", 0x4040, 2, do_t_arit}, - {"ldmia", 0xc800, 2, do_t_ldmstm}, - {"ldr", 0x0000, 2, do_t_ldr}, - {"ldrb", 0x0000, 2, do_t_ldrb}, - {"ldrh", 0x0000, 2, do_t_ldrh}, - {"ldrsb", 0x5600, 2, do_t_lds}, - {"ldrsh", 0x5e00, 2, do_t_lds}, - {"ldsb", 0x5600, 2, do_t_lds}, - {"ldsh", 0x5e00, 2, do_t_lds}, - {"lsl", 0x0000, 2, do_t_lsl}, - {"lsr", 0x0000, 2, do_t_lsr}, - {"mov", 0x0000, 2, do_t_mov}, - {"mul", T_OPCODE_MUL, 2, do_t_arit}, - {"mvn", T_OPCODE_MVN, 2, do_t_arit}, - {"neg", T_OPCODE_NEG, 2, do_t_arit}, - {"orr", 0x4300, 2, do_t_arit}, - {"pop", 0xbc00, 2, do_t_push_pop}, - {"push", 0xb400, 2, do_t_push_pop}, - {"ror", 0x41c0, 2, do_t_arit}, - {"sbc", 0x4180, 2, do_t_arit}, - {"stmia", 0xc000, 2, do_t_ldmstm}, - {"str", 0x0000, 2, do_t_str}, - {"strb", 0x0000, 2, do_t_strb}, - {"strh", 0x0000, 2, do_t_strh}, - {"swi", 0xdf00, 2, do_t_swi}, - {"sub", 0x0000, 2, do_t_sub}, - {"tst", T_OPCODE_TST, 2, do_t_arit}, + {"adc", 0x4140, 2, ARM_THUMB, do_t_arit}, + {"add", 0x0000, 2, ARM_THUMB, do_t_add}, + {"and", 0x4000, 2, ARM_THUMB, do_t_arit}, + {"asr", 0x0000, 2, ARM_THUMB, do_t_asr}, + {"b", T_OPCODE_BRANCH, 2, ARM_THUMB, do_t_branch12}, + {"beq", 0xd0fe, 2, ARM_THUMB, do_t_branch9}, + {"bne", 0xd1fe, 2, ARM_THUMB, do_t_branch9}, + {"bcs", 0xd2fe, 2, ARM_THUMB, do_t_branch9}, + {"bhs", 0xd2fe, 2, ARM_THUMB, do_t_branch9}, + {"bcc", 0xd3fe, 2, ARM_THUMB, do_t_branch9}, + {"bul", 0xd3fe, 2, ARM_THUMB, do_t_branch9}, + {"blo", 0xd3fe, 2, ARM_THUMB, do_t_branch9}, + {"bmi", 0xd4fe, 2, ARM_THUMB, do_t_branch9}, + {"bpl", 0xd5fe, 2, ARM_THUMB, do_t_branch9}, + {"bvs", 0xd6fe, 2, ARM_THUMB, do_t_branch9}, + {"bvc", 0xd7fe, 2, ARM_THUMB, do_t_branch9}, + {"bhi", 0xd8fe, 2, ARM_THUMB, do_t_branch9}, + {"bls", 0xd9fe, 2, ARM_THUMB, do_t_branch9}, + {"bge", 0xdafe, 2, ARM_THUMB, do_t_branch9}, + {"blt", 0xdbfe, 2, ARM_THUMB, do_t_branch9}, + {"bgt", 0xdcfe, 2, ARM_THUMB, do_t_branch9}, + {"ble", 0xddfe, 2, ARM_THUMB, do_t_branch9}, + {"bal", 0xdefe, 2, ARM_THUMB, do_t_branch9}, + {"bic", 0x4380, 2, ARM_THUMB, do_t_arit}, + {"bl", 0xf7fffffe, 4, ARM_THUMB, do_t_branch23}, + {"bx", 0x4700, 2, ARM_THUMB, do_t_bx}, + {"cmn", T_OPCODE_CMN, 2, ARM_THUMB, do_t_arit}, + {"cmp", 0x0000, 2, ARM_THUMB, do_t_compare}, + {"eor", 0x4040, 2, ARM_THUMB, do_t_arit}, + {"ldmia", 0xc800, 2, ARM_THUMB, do_t_ldmstm}, + {"ldr", 0x0000, 2, ARM_THUMB, do_t_ldr}, + {"ldrb", 0x0000, 2, ARM_THUMB, do_t_ldrb}, + {"ldrh", 0x0000, 2, ARM_THUMB, do_t_ldrh}, + {"ldrsb", 0x5600, 2, ARM_THUMB, do_t_lds}, + {"ldrsh", 0x5e00, 2, ARM_THUMB, do_t_lds}, + {"ldsb", 0x5600, 2, ARM_THUMB, do_t_lds}, + {"ldsh", 0x5e00, 2, ARM_THUMB, do_t_lds}, + {"lsl", 0x0000, 2, ARM_THUMB, do_t_lsl}, + {"lsr", 0x0000, 2, ARM_THUMB, do_t_lsr}, + {"mov", 0x0000, 2, ARM_THUMB, do_t_mov}, + {"mul", T_OPCODE_MUL, 2, ARM_THUMB, do_t_arit}, + {"mvn", T_OPCODE_MVN, 2, ARM_THUMB, do_t_arit}, + {"neg", T_OPCODE_NEG, 2, ARM_THUMB, do_t_arit}, + {"orr", 0x4300, 2, ARM_THUMB, do_t_arit}, + {"pop", 0xbc00, 2, ARM_THUMB, do_t_push_pop}, + {"push", 0xb400, 2, ARM_THUMB, do_t_push_pop}, + {"ror", 0x41c0, 2, ARM_THUMB, do_t_arit}, + {"sbc", 0x4180, 2, ARM_THUMB, do_t_arit}, + {"stmia", 0xc000, 2, ARM_THUMB, do_t_ldmstm}, + {"str", 0x0000, 2, ARM_THUMB, do_t_str}, + {"strb", 0x0000, 2, ARM_THUMB, do_t_strb}, + {"strh", 0x0000, 2, ARM_THUMB, do_t_strh}, + {"swi", 0xdf00, 2, ARM_THUMB, do_t_swi}, + {"sub", 0x0000, 2, ARM_THUMB, do_t_sub}, + {"tst", T_OPCODE_TST, 2, ARM_THUMB, do_t_arit}, /* Pseudo ops: */ - {"adr", 0x0000, 2, do_t_adr}, - {"nop", 0x46C0, 2, do_t_nop}, /* mov r8,r8 */ + {"adr", 0x0000, 2, ARM_THUMB, do_t_adr}, + {"nop", 0x46C0, 2, ARM_THUMB, do_t_nop}, /* mov r8,r8 */ }; struct reg_entry @@ -843,20 +860,22 @@ struct reg_entry #define REG_LR 14 #define REG_SP 13 -/* These are the standard names; Users can add aliases with .req */ +/* These are the standard names. Users can add aliases with .req */ static CONST struct reg_entry reg_table[] = { - /* Processor Register Numbers */ + /* Processor Register Numbers. */ {"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", REG_SP},{"r14", REG_LR},{"r15", REG_PC}, - /* APCS conventions */ + /* APCS conventions. */ {"a1", 0}, {"a2", 1}, {"a3", 2}, {"a4", 3}, {"v1", 4}, {"v2", 5}, {"v3", 6}, {"v4", 7}, {"v5", 8}, {"v6", 9}, {"sb", 9}, {"v7", 10}, {"sl", 10}, {"fp", 11}, {"ip", 12}, {"sp", REG_SP},{"lr", REG_LR},{"pc", REG_PC}, - /* FP Registers */ + /* ATPCS additions to APCS conventions. */ + {"wr", 7}, {"v8", 11}, + /* FP Registers. */ {"f0", 16}, {"f1", 17}, {"f2", 18}, {"f3", 19}, {"f4", 20}, {"f5", 21}, {"f6", 22}, {"f7", 23}, {"c0", 32}, {"c1", 33}, {"c2", 34}, {"c3", 35}, @@ -867,11 +886,20 @@ static CONST struct reg_entry reg_table[] = {"cr4", 36}, {"cr5", 37}, {"cr6", 38}, {"cr7", 39}, {"cr8", 40}, {"cr9", 41}, {"cr10", 42}, {"cr11", 43}, {"cr12", 44}, {"cr13", 45}, {"cr14", 46}, {"cr15", 47}, + /* ATPCS additions to float register names. */ + {"s0",16}, {"s1",17}, {"s2",18}, {"s3",19}, + {"s4",20}, {"s5",21}, {"s6",22}, {"s7",23}, + {"d0",16}, {"d1",17}, {"d2",18}, {"d3",19}, + {"d4",20}, {"d5",21}, {"d6",22}, {"d7",23}, + /* FIXME: At some point we need to add VFP register names. */ + /* Array terminator. */ {NULL, 0} }; -#define bad_args _("Bad arguments to instruction"); -#define bad_pc _("r15 not allowed here"); +#define BAD_ARGS _("Bad arguments to instruction") +#define BAD_PC _("r15 not allowed here") +#define BAD_FLAGS _("Instruction should not have flags") +#define BAD_COND _("Instruction is not conditional") static struct hash_control * arm_ops_hsh = NULL; static struct hash_control * arm_tops_hsh = NULL; @@ -882,10 +910,9 @@ static struct hash_control * arm_psr_hsh = NULL; /* This table describes all the machine specific pseudo-ops the assembler has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ + pseudo-op name without dot + function to call to execute this pseudo-op + Integer arg to pass to the function. */ static void s_req PARAMS ((int)); static void s_align PARAMS ((int)); @@ -897,7 +924,11 @@ static void s_thumb PARAMS ((int)); static void s_code PARAMS ((int)); static void s_force_thumb PARAMS ((int)); static void s_thumb_func PARAMS ((int)); +static void s_thumb_set PARAMS ((int)); +static void arm_s_text PARAMS ((int)); +static void arm_s_data PARAMS ((int)); #ifdef OBJ_ELF +static void arm_s_section PARAMS ((int)); static void s_arm_elf_cons PARAMS ((int)); #endif @@ -905,27 +936,35 @@ static int my_get_expression PARAMS ((expressionS *, char **)); CONST pseudo_typeS md_pseudo_table[] = { - {"req", s_req, 0}, /* Never called becasue '.req' does not start line */ - {"bss", s_bss, 0}, - {"align", s_align, 0}, - {"arm", s_arm, 0}, - {"thumb", s_thumb, 0}, - {"code", s_code, 0}, - {"force_thumb", s_force_thumb, 0}, - {"thumb_func", s_thumb_func, 0}, - {"even", s_even, 0}, - {"ltorg", s_ltorg, 0}, - {"pool", s_ltorg, 0}, + { "req", s_req, 0 }, /* Never called becasue '.req' does not start line */ + { "bss", s_bss, 0 }, + { "align", s_align, 0 }, + { "arm", s_arm, 0 }, + { "thumb", s_thumb, 0 }, + { "code", s_code, 0 }, + { "force_thumb", s_force_thumb, 0 }, + { "thumb_func", s_thumb_func, 0 }, + { "thumb_set", s_thumb_set, 0 }, + { "even", s_even, 0 }, + { "ltorg", s_ltorg, 0 }, + { "pool", s_ltorg, 0 }, + /* Allow for the effect of section changes. */ + { "text", arm_s_text, 0 }, + { "data", arm_s_data, 0 }, #ifdef OBJ_ELF - {"word", s_arm_elf_cons, 4}, - {"long", s_arm_elf_cons, 4}, + { "section", arm_s_section, 0 }, + { "section.s", arm_s_section, 0 }, + { "sect", arm_s_section, 0 }, + { "sect.s", arm_s_section, 0 }, + { "word", s_arm_elf_cons, 4 }, + { "long", s_arm_elf_cons, 4 }, #else - {"word", cons, 4}, + { "word", cons, 4}, #endif - {"extend", float_cons, 'x'}, - {"ldouble", float_cons, 'x'}, - {"packed", float_cons, 'p'}, - {0, 0, 0} + { "extend", float_cons, 'x' }, + { "ldouble", float_cons, 'x' }, + { "packed", float_cons, 'p' }, + { 0, 0, 0 } }; /* Stuff needed to resolve the label ambiguity @@ -955,7 +994,6 @@ literalT literals[MAX_LITERAL_POOL_SIZE]; int next_literal_pool_place = 0; /* Next free entry in the pool */ int lit_pool_num = 1; /* Next literal pool number */ symbolS * current_poolP = NULL; -symbolS * symbol_make_empty PARAMS ((void)); static int add_to_lit_pool () @@ -963,14 +1001,16 @@ add_to_lit_pool () int lit_count = 0; if (current_poolP == NULL) - current_poolP = symbol_make_empty (); + current_poolP = symbol_create (FAKE_LABEL_NAME, undefined_section, + (valueT) 0, &zero_address_frag); - /* Check if this literal value is already in the pool: */ + /* Check if this literal value is already in the pool: */ while (lit_count < next_literal_pool_place) { if (literals[lit_count].exp.X_op == inst.reloc.exp.X_op && inst.reloc.exp.X_op == O_constant - && literals[lit_count].exp.X_add_number == inst.reloc.exp.X_add_number + && literals[lit_count].exp.X_add_number + == inst.reloc.exp.X_add_number && literals[lit_count].exp.X_unsigned == inst.reloc.exp.X_unsigned) break; lit_count++; @@ -1027,7 +1067,7 @@ symbol_locate (symbolP, name, segment, valu, frag) S_SET_VALUE (symbolP, valu); symbol_clear_list_pointers(symbolP); - symbolP->sy_frag = frag; + symbol_set_frag (symbolP, frag); /* Link to end of symbol chain. */ { @@ -1049,25 +1089,8 @@ symbol_locate (symbolP, name, segment, valu, frag) #endif /* DEBUG_SYMS */ } -symbolS * -symbol_make_empty () -{ - symbolS * symbolP; - - symbolP = (symbolS *) obstack_alloc (¬es, sizeof (symbolS)); - - /* symbol must be born in some fixed state. This seems as good as any. */ - memset (symbolP, 0, sizeof (symbolS)); - - symbolP->bsym = bfd_make_empty_symbol (stdoutput); - assert (symbolP->bsym != 0); - symbolP->bsym->udata.p = (PTR) symbolP; - - return symbolP; -} - -/* Check that an immediate is valid, and if so, convert it to the right format. */ - +/* Check that an immediate is valid, and if so, + convert it to the right format. */ static unsigned int validate_immediate (val) unsigned int val; @@ -1084,13 +1107,52 @@ validate_immediate (val) return FAIL; } +/* Check to see if an immediate can be computed as two seperate immediate + values, added together. We already know that this value cannot be + computed by just one ARM instruction. */ +static unsigned int +validate_immediate_twopart (val, highpart) + unsigned int val; + unsigned int * highpart; +{ + unsigned int a; + unsigned int i; + + for (i = 0; i < 32; i += 2) + if (((a = rotate_left (val, i)) & 0xff) != 0) + { + if (a & 0xff00) + { + if (a & ~ 0xffff) + continue; + * highpart = (a >> 8) | ((i + 24) << 7); + } + else if (a & 0xff0000) + { + if (a & 0xff000000) + continue; + + * highpart = (a >> 16) | ((i + 16) << 7); + } + else + { + assert (a & 0xff000000); + + * highpart = (a >> 24) | ((i + 8) << 7); + } + + return (a & 0xff) | (i << 7); + } + + return FAIL; +} + static int validate_offset_imm (val, hwse) - int val; + unsigned int val; int hwse; { - if ((hwse && (val < -255 || val > 255)) - || (val < -4095 || val > 4095)) + if ((hwse && val > 255) || val > 4095) return FAIL; return val; } @@ -1098,14 +1160,14 @@ validate_offset_imm (val, hwse) static void s_req (a) - int a; + int a ATTRIBUTE_UNUSED; { as_bad (_("Invalid syntax for .req directive.")); } static void s_bss (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* We don't support putting frags in the BSS segment, we fake it by marking in_bss, then looking at s_skip for clues?.. */ @@ -1115,7 +1177,7 @@ s_bss (ignore) static void s_even (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (!need_pass_2) /* Never make frag if expect extra pass. */ frag_align (1, 0, 0); @@ -1126,19 +1188,14 @@ s_even (ignore) } static void -s_ltorg (internal) - int internal; +s_ltorg (ignored) + int ignored ATTRIBUTE_UNUSED; { int lit_count = 0; char sym_name[20]; if (current_poolP == NULL) - { - /* Nothing to do */ - if (!internal) - as_tsktsk (_("Nothing to put in the pool\n")); - return; - } + return; /* Align pool as you have word accesses */ /* Only make a frag if we have to ... */ @@ -1147,9 +1204,6 @@ s_ltorg (internal) record_alignment (now_seg, 2); - if (internal) - as_tsktsk (_("Inserting implicit pool at change of section")); - sprintf (sym_name, "$$lit_\002%x", lit_pool_num++); symbol_locate (current_poolP, sym_name, now_seg, @@ -1163,7 +1217,7 @@ s_ltorg (internal) #endif while (lit_count < next_literal_pool_place) - /* First output the expression in the instruction to the pool */ + /* First output the expression in the instruction to the pool. */ emit_expr (&(literals[lit_count++].exp), 4); /* .word */ next_literal_pool_place = 0; @@ -1172,7 +1226,7 @@ s_ltorg (internal) static void s_align (unused) /* Same as s_align_ptwo but align 0 => align 2 */ - int unused; + int unused ATTRIBUTE_UNUSED; { register int temp; register long temp_fill; @@ -1208,7 +1262,7 @@ s_align (unused) /* Same as s_align_ptwo but align 0 => align 2 */ static void s_force_thumb (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* If we are not already in thumb mode go into it, EVEN if the target processor does not support thumb instructions. @@ -1218,7 +1272,7 @@ s_force_thumb (ignore) if (! thumb_mode) { - thumb_mode = 1; + thumb_mode = 2; record_alignment (now_seg, 1); } @@ -1228,7 +1282,7 @@ s_force_thumb (ignore) static void s_thumb_func (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* The following label is the name/address of the start of a Thumb function. We need to know this for the interworking support. */ @@ -1238,6 +1292,145 @@ s_thumb_func (ignore) demand_empty_rest_of_line (); } +/* Perform a .set directive, but also mark the alias as + being a thumb function. */ + +static void +s_thumb_set (equiv) + int equiv; +{ + /* XXX the following is a duplicate of the code for s_set() in read.c + We cannot just call that code as we need to get at the symbol that + is created. */ + register char * name; + register char delim; + register char * end_name; + register symbolS * symbolP; + + /* + * Especial apologies for the random logic: + * this just grew, and could be parsed much more simply! + * Dean in haste. + */ + name = input_line_pointer; + delim = get_symbol_end (); + end_name = input_line_pointer; + *end_name = delim; + + SKIP_WHITESPACE (); + + if (*input_line_pointer != ',') + { + *end_name = 0; + as_bad (_("Expected comma after name \"%s\""), name); + *end_name = delim; + ignore_rest_of_line (); + return; + } + + input_line_pointer++; + *end_name = 0; + + if (name[0] == '.' && name[1] == '\0') + { + /* XXX - this should not happen to .thumb_set */ + abort (); + } + + if ((symbolP = symbol_find (name)) == NULL + && (symbolP = md_undefined_symbol (name)) == NULL) + { +#ifndef NO_LISTING + /* When doing symbol listings, play games with dummy fragments living + outside the normal fragment chain to record the file and line info + for this symbol. */ + if (listing & LISTING_SYMBOLS) + { + extern struct list_info_struct * listing_tail; + fragS * dummy_frag = (fragS *) xmalloc (sizeof(fragS)); + memset (dummy_frag, 0, sizeof(fragS)); + dummy_frag->fr_type = rs_fill; + dummy_frag->line = listing_tail; + symbolP = symbol_new (name, undefined_section, 0, dummy_frag); + dummy_frag->fr_symbol = symbolP; + } + else +#endif + symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag); + +#ifdef OBJ_COFF + /* "set" symbols are local unless otherwise specified. */ + SF_SET_LOCAL (symbolP); +#endif /* OBJ_COFF */ + } /* make a new symbol */ + + symbol_table_insert (symbolP); + + * end_name = delim; + + if (equiv + && S_IS_DEFINED (symbolP) + && S_GET_SEGMENT (symbolP) != reg_section) + as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP)); + + pseudo_set (symbolP); + + demand_empty_rest_of_line (); + + /* XXX Now we come to the Thumb specific bit of code. */ + + THUMB_SET_FUNC (symbolP, 1); + ARM_SET_THUMB (symbolP, 1); +#if defined OBJ_ELF || defined OBJ_COFF + ARM_SET_INTERWORK (symbolP, support_interwork); +#endif +} + +/* If we change section we must dump the literal pool first. */ +static void +arm_s_text (ignore) + int ignore; +{ + if (now_seg != text_section) + s_ltorg (0); + +#ifdef OBJ_ELF + obj_elf_text (ignore); +#else + s_text (ignore); +#endif +} + +static void +arm_s_data (ignore) + int ignore; +{ + if (flag_readonly_data_in_text) + { + if (now_seg != text_section) + s_ltorg (0); + } + else if (now_seg != data_section) + s_ltorg (0); + +#ifdef OBJ_ELF + obj_elf_data (ignore); +#else + s_data (ignore); +#endif +} + +#ifdef OBJ_ELF +static void +arm_s_section (ignore) + int ignore; +{ + s_ltorg (0); + + obj_elf_section (ignore); +} +#endif + static void opcode_select (width) int width; @@ -1275,7 +1468,7 @@ opcode_select (width) static void s_arm (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { opcode_select (32); demand_empty_rest_of_line (); @@ -1283,7 +1476,7 @@ s_arm (ignore) static void s_thumb (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { opcode_select (16); demand_empty_rest_of_line (); @@ -1291,7 +1484,7 @@ s_thumb (ignore) static void s_code (unused) - int unused; + int unused ATTRIBUTE_UNUSED; { register int temp; @@ -1312,10 +1505,9 @@ static void end_of_line (str) char * str; { - while (*str == ' ') - str++; + skip_whitespace (str); - if (*str != '\0') + if (* str != '\0') inst.error = _("Garbage following instruction"); } @@ -1340,9 +1532,10 @@ skip_past_comma (str) return comma ? SUCCESS : FAIL; } -/* A standard register must be given at this point. Shift is the place to - put it in the instruction. */ - +/* A standard register must be given at this point. + Shift is the place to put it in inst.instruction. + Restores input start point on err. + Returns the reg#, or FAIL. */ static int reg_required_here (str, shift) char ** str; @@ -1363,7 +1556,7 @@ reg_required_here (str, shift) *str = start; /* In the few cases where we might be able to accept something else - this error can be overridden */ + this error can be overridden. */ sprintf (buff, _("Register expected, not '%.100s'"), start); inst.error = buff; @@ -1389,7 +1582,7 @@ psr_required_here (str, cpsr, spsr) } /* In the few cases where we might be able to accept something else - this error can be overridden */ + this error can be overridden. */ inst.error = _(" expected"); /* Restore the start point. */ @@ -1399,12 +1592,11 @@ psr_required_here (str, cpsr, spsr) static int co_proc_number (str) - char **str; + char ** str; { int processor, pchar; - while (**str == ' ') - (*str)++; + skip_whitespace (* str); /* The data sheet seems to imply that just a number on its own is valid here, but the RISC iX assembler seems to accept a prefix 'p'. We will @@ -1444,8 +1636,7 @@ cp_opc_expr (str, where, length) { expressionS expr; - while (**str == ' ') - (*str)++; + skip_whitespace (* str); memset (&expr, '\0', sizeof (expr)); @@ -1483,10 +1674,10 @@ cp_reg_required_here (str, where) } /* In the few cases where we might be able to accept something else - this error can be overridden */ + this error can be overridden. */ inst.error = _("Co-processor register expected"); - /* Restore the start point */ + /* Restore the start point. */ *str = start; return FAIL; } @@ -1507,10 +1698,10 @@ fp_reg_required_here (str, where) } /* In the few cases where we might be able to accept something else - this error can be overridden */ + this error can be overridden. */ inst.error = _("Floating point register expected"); - /* Restore the start point */ + /* Restore the start point. */ *str = start; return FAIL; } @@ -1521,8 +1712,7 @@ cp_address_offset (str) { int offset; - while (**str == ' ') - (*str)++; + skip_whitespace (* str); if (! is_immediate_prefix (**str)) { @@ -1577,14 +1767,12 @@ cp_address_required_here (str) int reg; p++; - while (*p == ' ') - p++; + skip_whitespace (p); if ((reg = reg_required_here (& p, 16)) == FAIL) return FAIL; - while (*p == ' ') - p++; + skip_whitespace (p); if (*p == ']') { @@ -1622,8 +1810,7 @@ cp_address_required_here (str) if (cp_address_offset (& p) == FAIL) return FAIL; - while (*p == ' ') - p++; + skip_whitespace (p); if (*p++ != ']') { @@ -1631,8 +1818,7 @@ cp_address_required_here (str) return FAIL; } - while (*p == ' ') - p++; + skip_whitespace (p); if (*p == '!') { @@ -1669,8 +1855,8 @@ do_nop (str, flags) char * str; unsigned long flags; { - /* Do nothing really */ - inst.instruction |= flags; /* This is pointless */ + /* Do nothing really. */ + inst.instruction |= flags; /* This is pointless. */ end_of_line (str); return; } @@ -1680,13 +1866,12 @@ do_mrs (str, flags) char *str; unsigned long flags; { - /* Only one syntax */ - while (*str == ' ') - str++; + /* Only one syntax. */ + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -1702,7 +1887,7 @@ do_mrs (str, flags) return; } -/* Three possible forms: ", Rm", ", Rm", ", #expression" */ +/* Three possible forms: ", Rm", ", Rm", ", #expression". */ static void do_msr (str, flags) char * str; @@ -1710,8 +1895,7 @@ do_msr (str, flags) { int reg; - while (*str == ' ') - str ++; + skip_whitespace (str); if (psr_required_here (&str, CPSR_ALL, SPSR_ALL) == SUCCESS) { @@ -1721,7 +1905,7 @@ do_msr (str, flags) if (skip_past_comma (&str) == FAIL || (reg = reg_required_here (&str, 0)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } } @@ -1733,13 +1917,13 @@ do_msr (str, flags) inst.instruction |= PSR_CONTROL; else { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (skip_past_comma (&str) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -1747,7 +1931,7 @@ do_msr (str, flags) if ((reg = reg_required_here (& str, 0)) != FAIL) ; - /* Immediate expression */ + /* Immediate expression. */ else if (is_immediate_prefix (* str)) { str ++; @@ -1767,7 +1951,7 @@ do_msr (str, flags) else { unsigned value = validate_immediate (inst.reloc.exp.X_add_number); - if (value == FAIL) + if (value == (unsigned) FAIL) { inst.error = _("Invalid constant"); return; @@ -1804,27 +1988,26 @@ do_mull (str, flags) { int rdlo, rdhi, rm, rs; - /* only one format "rdlo, rdhi, rm, rs" */ - while (*str == ' ') - str++; + /* Only one format "rdlo, rdhi, rm, rs" */ + skip_whitespace (str); if ((rdlo = reg_required_here (&str, 12)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (skip_past_comma (&str) == FAIL || (rdhi = reg_required_here (&str, 16)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (skip_past_comma (&str) == FAIL || (rm = reg_required_here (&str, 0)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -1835,13 +2018,13 @@ do_mull (str, flags) if (skip_past_comma (&str) == FAIL || (rs = reg_required_here (&str, 8)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rdhi == REG_PC || rdhi == REG_PC || rdhi == REG_PC || rdhi == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } @@ -1857,32 +2040,31 @@ do_mul (str, flags) { int rd, rm; - /* only one format "rd, rm, rs" */ - while (*str == ' ') - str++; + /* Only one format "rd, rm, rs" */ + skip_whitespace (str); if ((rd = reg_required_here (&str, 16)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rd == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } if (skip_past_comma (&str) == FAIL || (rm = reg_required_here (&str, 0)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rm == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } @@ -1892,13 +2074,13 @@ do_mul (str, flags) if (skip_past_comma (&str) == FAIL || (rm = reg_required_here (&str, 8)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rm == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } @@ -1914,32 +2096,31 @@ do_mla (str, flags) { int rd, rm; - /* only one format "rd, rm, rs, rn" */ - while (*str == ' ') - str++; + /* Only one format "rd, rm, rs, rn" */ + skip_whitespace (str); if ((rd = reg_required_here (&str, 16)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rd == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } if (skip_past_comma (&str) == FAIL || (rm = reg_required_here (&str, 0)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rm == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } @@ -1951,13 +2132,13 @@ do_mla (str, flags) || skip_past_comma (&str) == FAIL || (rm = reg_required_here (&str, 12)) == FAIL) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (rd == REG_PC || rm == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } @@ -2039,14 +2220,14 @@ static int walk_no_bignums (sp) symbolS * sp; { - if (sp->sy_value.X_op == O_big) + if (symbol_get_value_expression (sp)->X_op == O_big) return 1; - if (sp->sy_value.X_add_symbol) + if (symbol_get_value_expression (sp)->X_add_symbol) { - return (walk_no_bignums (sp->sy_value.X_add_symbol) - || (sp->sy_value.X_op_symbol - && walk_no_bignums (sp->sy_value.X_op_symbol))); + return (walk_no_bignums (symbol_get_value_expression (sp)->X_add_symbol) + || (symbol_get_value_expression (sp)->X_op_symbol + && walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol))); } return 0; @@ -2110,8 +2291,7 @@ decode_shift (str, unrestrict) char * p; char c; - while (**str == ' ') - (*str)++; + skip_whitespace (* str); for (p = *str; isalpha (*p); p++) ; @@ -2136,9 +2316,8 @@ decode_shift (str, unrestrict) return SUCCESS; } - while (*p == ' ') - p++; - + skip_whitespace (p); + if (unrestrict && reg_required_here (&p, 8) != FAIL) { inst.instruction |= shft->value | SHIFT_BY_REG; @@ -2281,7 +2460,7 @@ negate_data_op (instruction, value) return FAIL; } - if (value == FAIL) + if (value == (unsigned) FAIL) return FAIL; *instruction &= OPCODE_MASK; @@ -2296,16 +2475,14 @@ data_op2 (str) int value; expressionS expr; - while (**str == ' ') - (*str)++; + skip_whitespace (* str); if (reg_required_here (str, 0) != FAIL) { if (skip_past_comma (str) == SUCCESS) - { - /* Shift operation on register */ - return decode_shift (str, NO_SHIFT_RESTRICT); - } + /* Shift operation on register. */ + return decode_shift (str, NO_SHIFT_RESTRICT); + return SUCCESS; } else @@ -2315,6 +2492,7 @@ data_op2 (str) { (*str)++; inst.error = NULL; + if (my_get_expression (&inst.reloc.exp, str)) return FAIL; @@ -2384,8 +2562,7 @@ static int fp_op2 (str) char ** str; { - while (**str == ' ') - (*str)++; + skip_whitespace (* str); if (fp_reg_required_here (str, 0) != FAIL) return SUCCESS; @@ -2397,8 +2574,8 @@ fp_op2 (str) int i; inst.error = NULL; - while (**str == ' ') - (*str)++; + + skip_whitespace (* str); /* First try and match exact strings, this is to guarantee that some formats will work even for cross assembly */ @@ -2442,8 +2619,7 @@ do_arit (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL || skip_past_comma (&str) == FAIL @@ -2452,7 +2628,7 @@ do_arit (str, flags) || data_op2 (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2467,23 +2643,22 @@ do_adr (str, flags) unsigned long flags; { /* This is a pseudo-op of the form "adr rd, label" to be converted - into a relative address of the form "add rd, pc, #label-.-8" */ - - while (*str == ' ') - str++; + into a relative address of the form "add rd, pc, #label-.-8". */ + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL || skip_past_comma (&str) == FAIL || my_get_expression (&inst.reloc.exp, &str)) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } + /* Frag hacking will turn this into a sub instruction if the offset turns out to be negative. */ inst.reloc.type = BFD_RELOC_ARM_IMMEDIATE; - inst.reloc.exp.X_add_number -= 8; /* PC relative adjust */ + inst.reloc.exp.X_add_number -= 8; /* PC relative adjust. */ inst.reloc.pc_rel = 1; inst.instruction |= flags; end_of_line (str); @@ -2491,17 +2666,50 @@ do_adr (str, flags) } static void +do_adrl (str, flags) + char * str; + unsigned long flags; +{ + /* This is a pseudo-op of the form "adrl rd, label" to be converted + into a relative address of the form: + add rd, pc, #low(label-.-8)" + add rd, rd, #high(label-.-8)" */ + + skip_whitespace (str); + + if (reg_required_here (& str, 12) == FAIL + || skip_past_comma (& str) == FAIL + || my_get_expression (& inst.reloc.exp, & str)) + { + if (!inst.error) + inst.error = BAD_ARGS; + return; + } + + end_of_line (str); + + /* Frag hacking will turn this into a sub instruction if the offset turns + out to be negative. */ + inst.reloc.type = BFD_RELOC_ARM_ADRL_IMMEDIATE; + inst.reloc.exp.X_add_number -= 8; /* PC relative adjust */ + inst.reloc.pc_rel = 1; + inst.instruction |= flags; + inst.size = INSN_SIZE * 2; + + return; +} + +static void do_cmp (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); if (reg_required_here (&str, 16) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2509,7 +2717,7 @@ do_cmp (str, flags) || data_op2 (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2526,13 +2734,12 @@ do_mov (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2540,7 +2747,7 @@ do_mov (str, flags) || data_op2 (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2584,7 +2791,7 @@ ldst_extend (str, hwse) /* Halfword and signextension instructions have the immediate value split across bits 11..8 and bits 3..0 */ if (hwse) - inst.instruction |= add | HWOFFSET_IMM | (value >> 4) << 8 | value & 0xF; + inst.instruction |= add | HWOFFSET_IMM | ((value >> 4) << 8) | (value & 0xF); else inst.instruction |= add | value; } @@ -2635,7 +2842,8 @@ do_ldst (str, flags) /* This is not ideal, but it is the simplest way of dealing with the ARM7T halfword instructions (since they use a different encoding, but the same mnemonic): */ - if (halfword = ((flags & 0x80000000) != 0)) + halfword = (flags & 0x80000000) != 0; + if (halfword) { /* This is actually a load/store of a halfword, or a signed-extension load */ @@ -2652,13 +2860,12 @@ do_ldst (str, flags) flags = 0; } - while (*str == ' ') - str++; + skip_whitespace (str); if ((conflict_reg = reg_required_here (& str, 12)) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -2673,29 +2880,29 @@ do_ldst (str, flags) int reg; str++; - while (*str == ' ') - str++; + + skip_whitespace (str); if ((reg = reg_required_here (&str, 16)) == FAIL) return; - conflict_reg = (((conflict_reg == reg) - && (inst.instruction & LOAD_BIT)) - ? 1 : 0); + /* Conflicts can occur on stores as well as loads. */ + conflict_reg = (conflict_reg == reg); - while (*str == ' ') - str++; + skip_whitespace (str); if (*str == ']') { - str++; + str ++; + if (skip_past_comma (&str) == SUCCESS) { /* [Rn],... (post inc) */ if (ldst_extend (&str, halfword) == FAIL) return; if (conflict_reg) - as_warn (_("destination register same as write-back base\n")); + as_warn (_("%s register same as write-back base"), + (inst.instruction & LOAD_BIT) ? _("destination") : _("source") ); } else { @@ -2703,13 +2910,13 @@ do_ldst (str, flags) if (halfword) inst.instruction |= HWOFFSET_IMM; - while (*str == ' ') - str++; + skip_whitespace (str); if (*str == '!') { if (conflict_reg) - as_warn (_("destination register same as write-back base\n")); + as_warn (_("%s register same as write-back base"), + (inst.instruction & LOAD_BIT) ? _("destination") : _("source") ); str++; inst.instruction |= WRITE_BACK; } @@ -2732,8 +2939,7 @@ do_ldst (str, flags) if (ldst_extend (&str, halfword) == FAIL) return; - while (*str == ' ') - str++; + skip_whitespace (str); if (*str++ != ']') { @@ -2741,13 +2947,13 @@ do_ldst (str, flags) return; } - while (*str == ' ') - str++; + skip_whitespace (str); if (*str == '!') { if (conflict_reg) - as_tsktsk (_("destination register same as write-back base\n")); + as_warn (_("%s register same as write-back base"), + (inst.instruction & LOAD_BIT) ? _("destination") : _("source") ); str++; inst.instruction |= WRITE_BACK; } @@ -2758,8 +2964,7 @@ do_ldst (str, flags) /* Parse an "ldr Rd, =expr" instruction; this is another pseudo op */ str++; - while (*str == ' ') - str++; + skip_whitespace (str); if (my_get_expression (&inst.reloc.exp, &str)) return; @@ -2816,7 +3021,9 @@ do_ldst (str, flags) } else inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM; +#ifndef TE_WINCE inst.reloc.exp.X_add_number -= 8; /* PC rel adjust */ +#endif inst.reloc.pc_rel = 1; inst.instruction |= (REG_PC << 16); pre_inc = 1; @@ -2853,8 +3060,7 @@ reg_list (strp) { int reg; - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = reg_required_here (& str, -1)) == FAIL) return FAIL; @@ -2892,8 +3098,7 @@ reg_list (strp) } while (skip_past_comma (&str) != FAIL || (in_range = 1, *str++ == '-')); str--; - while (*str == ' ') - str++; + skip_whitespace (str); if (*str++ != '}') { @@ -2944,8 +3149,7 @@ reg_list (strp) } } - while (*str == ' ') - str++; + skip_whitespace (str); if (*str == '|' || *str == '+') { @@ -2966,8 +3170,7 @@ do_ldmstm (str, flags) int base_reg; long range; - while (*str == ' ') - str++; + skip_whitespace (str); if ((base_reg = reg_required_here (&str, 16)) == FAIL) return; @@ -2978,8 +3181,8 @@ do_ldmstm (str, flags) return; } - while (*str == ' ') - str++; + skip_whitespace (str); + if (*str == '!') { flags |= WRITE_BACK; @@ -2990,14 +3193,14 @@ do_ldmstm (str, flags) || (range = reg_list (&str)) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } if (*str == '^') { str++; - flags |= MULTI_SET_PSR; + flags |= LDM_TYPE_2_OR_3; } inst.instruction |= flags | range; @@ -3010,8 +3213,7 @@ do_swi (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); /* Allow optional leading '#'. */ if (is_immediate_prefix (*str)) @@ -3036,8 +3238,7 @@ do_swap (str, flags) { int reg; - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = reg_required_here (&str, 12)) == FAIL) return; @@ -3052,7 +3253,7 @@ do_swap (str, flags) || (reg = reg_required_here (&str, 0)) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3065,24 +3266,22 @@ do_swap (str, flags) if (skip_past_comma (&str) == FAIL || *str++ != '[') { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = reg_required_here (&str, 16)) == FAIL) return; if (reg == REG_PC) { - inst.error = bad_pc; + inst.error = BAD_PC; return; } - while (*str == ' ') - str++; + skip_whitespace (str); if (*str++ != ']') { @@ -3098,7 +3297,7 @@ do_swap (str, flags) static void do_branch (str, flags) char * str; - unsigned long flags; + unsigned long flags ATTRIBUTE_UNUSED; { if (my_get_expression (&inst.reloc.exp, &str)) return; @@ -3144,37 +3343,37 @@ do_branch (str, flags) static void do_bx (str, flags) char * str; - unsigned long flags; + unsigned long flags ATTRIBUTE_UNUSED; { int reg; - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = reg_required_here (&str, 0)) == FAIL) - return; + { + inst.error = BAD_ARGS; + return; + } if (reg == REG_PC) - as_tsktsk (_("Use of r15 in bx has undefined behaviour")); + inst.error = BAD_PC; end_of_line (str); - return; } static void do_cdp (str, flags) char * str; - unsigned long flags; + unsigned long flags ATTRIBUTE_UNUSED; { /* Co-processor data operation. Format: CDP{cond} CP#,,CRd,CRn,CRm{,} */ - while (*str == ' ') - str++; + skip_whitespace (str); if (co_proc_number (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3182,7 +3381,7 @@ do_cdp (str, flags) || cp_opc_expr (&str, 20,4) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3190,7 +3389,7 @@ do_cdp (str, flags) || cp_reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3198,7 +3397,7 @@ do_cdp (str, flags) || cp_reg_required_here (&str, 16) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3206,7 +3405,7 @@ do_cdp (str, flags) || cp_reg_required_here (&str, 0) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3215,7 +3414,7 @@ do_cdp (str, flags) if (cp_opc_expr (&str, 5, 3) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } } @@ -3232,13 +3431,12 @@ do_lstc (str, flags) /* Co-processor register load/store. Format: */ - while (*str == ' ') - str++; + skip_whitespace (str); if (co_proc_number (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3246,7 +3444,7 @@ do_lstc (str, flags) || cp_reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3254,7 +3452,7 @@ do_lstc (str, flags) || cp_address_required_here (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3271,13 +3469,12 @@ do_co_reg (str, flags) /* Co-processor register transfer. Format: {cond} CP#,,Rd,CRn,CRm{,} */ - while (*str == ' ') - str++; + skip_whitespace (str); if (co_proc_number (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3285,7 +3482,7 @@ do_co_reg (str, flags) || cp_opc_expr (&str, 21, 3) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3293,7 +3490,7 @@ do_co_reg (str, flags) || reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3301,7 +3498,7 @@ do_co_reg (str, flags) || cp_reg_required_here (&str, 16) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3309,7 +3506,7 @@ do_co_reg (str, flags) || cp_reg_required_here (&str, 0) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3318,10 +3515,14 @@ do_co_reg (str, flags) if (cp_opc_expr (&str, 5, 3) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } } + if (flags) + { + inst.error = BAD_COND; + } end_of_line (str); return; @@ -3330,18 +3531,17 @@ do_co_reg (str, flags) static void do_fp_ctrl (str, flags) char * str; - unsigned long flags; + unsigned long flags ATTRIBUTE_UNUSED; { /* FP control registers. Format: {cond} Rn */ - while (*str == ' ') - str++; + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3352,10 +3552,9 @@ do_fp_ctrl (str, flags) static void do_fp_ldst (str, flags) char * str; - unsigned long flags; + unsigned long flags ATTRIBUTE_UNUSED; { - while (*str == ' ') - str++; + skip_whitespace (str); switch (inst.suffix) { @@ -3377,7 +3576,7 @@ do_fp_ldst (str, flags) if (fp_reg_required_here (&str, 12) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3385,7 +3584,7 @@ do_fp_ldst (str, flags) || cp_address_required_here (&str) == FAIL) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3399,13 +3598,12 @@ do_fp_ldmstm (str, flags) { int num_regs; - while (*str == ' ') - str++; + skip_whitespace (str); if (fp_reg_required_here (&str, 12) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3463,23 +3661,21 @@ do_fp_ldmstm (str, flags) || *str != '[') { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } str++; - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = reg_required_here (&str, 16)) == FAIL) return; - while (*str == ' ') - str++; + skip_whitespace (str); if (*str != ']') { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3527,7 +3723,7 @@ do_fp_ldmstm (str, flags) || cp_address_required_here (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3539,8 +3735,7 @@ do_fp_dyadic (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); switch (inst.suffix) { @@ -3559,7 +3754,7 @@ do_fp_dyadic (str, flags) if (fp_reg_required_here (&str, 12) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3567,7 +3762,7 @@ do_fp_dyadic (str, flags) || fp_reg_required_here (&str, 16) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3575,7 +3770,7 @@ do_fp_dyadic (str, flags) || fp_op2 (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3589,8 +3784,7 @@ do_fp_monadic (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); switch (inst.suffix) { @@ -3609,7 +3803,7 @@ do_fp_monadic (str, flags) if (fp_reg_required_here (&str, 12) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3617,7 +3811,7 @@ do_fp_monadic (str, flags) || fp_op2 (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3631,13 +3825,12 @@ do_fp_cmp (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); if (fp_reg_required_here (&str, 16) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3645,7 +3838,7 @@ do_fp_cmp (str, flags) || fp_op2 (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3659,8 +3852,7 @@ do_fp_from_reg (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); switch (inst.suffix) { @@ -3679,7 +3871,7 @@ do_fp_from_reg (str, flags) if (fp_reg_required_here (&str, 16) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3687,7 +3879,7 @@ do_fp_from_reg (str, flags) || reg_required_here (&str, 12) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3701,8 +3893,7 @@ do_fp_to_reg (str, flags) char * str; unsigned long flags; { - while (*str == ' ') - str++; + skip_whitespace (str); if (reg_required_here (&str, 12) == FAIL) return; @@ -3711,7 +3902,7 @@ do_fp_to_reg (str, flags) || fp_reg_required_here (&str, 0) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3771,14 +3962,13 @@ thumb_add_sub (str, subtract) { int Rd, Rs, Rn = FAIL; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rd = thumb_reg (&str, THUMB_REG_ANY)) == FAIL || skip_past_comma (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3929,6 +4119,7 @@ thumb_add_sub (str, subtract) } } } + end_of_line (str); } @@ -3939,14 +4130,13 @@ thumb_shift (str, shift) { int Rd, Rs, Rn = FAIL; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rd = thumb_reg (&str, THUMB_REG_LO)) == FAIL || skip_past_comma (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -3954,7 +4144,7 @@ thumb_shift (str, shift) { /* Two operand immediate format, set Rs to Rd. */ Rs = Rd; - str++; + str ++; if (my_get_expression (&inst.reloc.exp, &str)) return; } @@ -4039,6 +4229,7 @@ thumb_shift (str, shift) inst.instruction |= Rd | (Rs << 3); } + end_of_line (str); } @@ -4049,14 +4240,13 @@ thumb_mov_compare (str, move) { int Rd, Rs = FAIL; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rd = thumb_reg (&str, THUMB_REG_ANY)) == FAIL || skip_past_comma (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -4139,14 +4329,13 @@ thumb_load_store (str, load_store, size) { int Rd, Rb, Ro = FAIL; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rd = thumb_reg (&str, THUMB_REG_LO)) == FAIL || skip_past_comma (&str) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -4185,8 +4374,7 @@ thumb_load_store (str, load_store, size) /* Parse an "ldr Rd, =expr" instruction; this is another pseudo op */ str++; - while (*str == ' ') - str++; + skip_whitespace (str); if (my_get_expression (& inst.reloc.exp, & str)) return; @@ -4350,18 +4538,14 @@ do_t_arit (str) { int Rd, Rs, Rn; - while (*str == ' ') - str++; - - if ((Rd = thumb_reg (&str, THUMB_REG_LO)) == FAIL) - return; + skip_whitespace (str); - if (skip_past_comma (&str) == FAIL + if ((Rd = thumb_reg (&str, THUMB_REG_LO)) == FAIL + || skip_past_comma (&str) == FAIL || (Rs = thumb_reg (&str, THUMB_REG_LO)) == FAIL) { - if (! inst.error) - inst.error = bad_args; - return; + inst.error = BAD_ARGS; + return; } if (skip_past_comma (&str) != FAIL) @@ -4374,7 +4558,7 @@ do_t_arit (str) || inst.instruction == T_OPCODE_NEG || inst.instruction == T_OPCODE_MVN) { - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -4443,7 +4627,7 @@ find_real_start (symbolP) const char * name = S_GET_NAME (symbolP); symbolS * new_target; - /* This definitonmust agree with the one in gcc/config/arm/thumb.c */ + /* This definiton must agree with the one in gcc/config/arm/thumb.c */ #define STUB_NAME ".real_start_of" if (name == NULL) @@ -4476,8 +4660,9 @@ static void do_t_branch23 (str) char * str; { - if (my_get_expression (&inst.reloc.exp, &str)) + if (my_get_expression (& inst.reloc.exp, & str)) return; + inst.reloc.type = BFD_RELOC_THUMB_PCREL_BRANCH23; inst.reloc.pc_rel = 1; end_of_line (str); @@ -4499,8 +4684,7 @@ do_t_bx (str) { int reg; - while (*str == ' ') - str++; + skip_whitespace (str); if ((reg = thumb_reg (&str, THUMB_REG_ANY)) == FAIL) return; @@ -4529,8 +4713,7 @@ do_t_ldmstm (str) int Rb; long range; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rb = thumb_reg (&str, THUMB_REG_LO)) == FAIL) return; @@ -4544,7 +4727,7 @@ do_t_ldmstm (str) || (range = reg_list (&str)) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -4593,8 +4776,7 @@ do_t_lds (str) { int Rd, Rb, Ro; - while (*str == ' ') - str++; + skip_whitespace (str); if ((Rd = thumb_reg (&str, THUMB_REG_LO)) == FAIL || skip_past_comma (&str) == FAIL @@ -4640,13 +4822,12 @@ do_t_push_pop (str) { long range; - while (*str == ' ') - str++; + skip_whitespace (str); if ((range = reg_list (&str)) == FAIL) { if (! inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } @@ -4711,8 +4892,7 @@ static void do_t_swi (str) char * str; { - while (*str == ' ') - str++; + skip_whitespace (str); if (my_get_expression (&inst.reloc.exp, &str)) return; @@ -4726,24 +4906,28 @@ static void do_t_adr (str) char * str; { + int reg; + /* This is a pseudo-op of the form "adr rd, label" to be converted - into a relative address of the form "add rd, pc, #label-.-4" */ - while (*str == ' ') - str++; + into a relative address of the form "add rd, pc, #label-.-4". */ + skip_whitespace (str); - if (reg_required_here (&str, 4) == FAIL /* Store Rd in temporary location inside instruction. */ + /* Store Rd in temporary location inside instruction. */ + if ((reg = reg_required_here (&str, 4)) == FAIL + || (reg > 7) /* For Thumb reg must be r0..r7. */ || skip_past_comma (&str) == FAIL || my_get_expression (&inst.reloc.exp, &str)) { if (!inst.error) - inst.error = bad_args; + inst.error = BAD_ARGS; return; } inst.reloc.type = BFD_RELOC_ARM_THUMB_ADD; - inst.reloc.exp.X_add_number -= 4; /* PC relative adjust */ + inst.reloc.exp.X_add_number -= 4; /* PC relative adjust. */ inst.reloc.pc_rel = 1; - inst.instruction |= REG_PC; /* Rd is already placed into the instruction */ + inst.instruction |= REG_PC; /* Rd is already placed into the instruction. */ + end_of_line (str); } @@ -4800,7 +4984,8 @@ set_constant_flonums () void md_begin () { - int i; + unsigned mach; + unsigned int i; if ( (arm_ops_hsh = hash_new ()) == NULL || (arm_tops_hsh = hash_new ()) == NULL @@ -4830,53 +5015,54 @@ md_begin () { unsigned int flags = 0; - /* Set the flags in the private structure */ + /* Set the flags in the private structure. */ if (uses_apcs_26) flags |= F_APCS26; if (support_interwork) flags |= F_INTERWORK; if (uses_apcs_float) flags |= F_APCS_FLOAT; if (pic_code) flags |= F_PIC; + if ((cpu_variant & FPU_ALL) == FPU_NONE) flags |= F_SOFT_FLOAT; bfd_set_private_flags (stdoutput, flags); } #endif - { - unsigned mach; - - /* Record the CPU type as well */ - switch (cpu_variant & ARM_CPU_MASK) - { - case ARM_2: - mach = bfd_mach_arm_2; - break; - - case ARM_3: /* also ARM_250 */ - mach = bfd_mach_arm_2a; - break; - - default: - case ARM_6 | ARM_3 | ARM_2: /* Actually no CPU type defined */ + /* Record the CPU type as well. */ + switch (cpu_variant & ARM_CPU_MASK) + { + case ARM_2: + mach = bfd_mach_arm_2; + break; + + case ARM_3: /* Also ARM_250. */ + mach = bfd_mach_arm_2a; + break; + + default: + case ARM_6 | ARM_3 | ARM_2: /* Actually no CPU type defined. */ + mach = bfd_mach_arm_4; + break; + + case ARM_7: /* Also ARM_6. */ + mach = bfd_mach_arm_3; + break; + } + + /* Catch special cases. */ + if (cpu_variant != (FPU_DEFAULT | CPU_DEFAULT)) + { + if (cpu_variant & (ARM_EXT_V5 & ARM_THUMB)) + mach = bfd_mach_arm_5T; + else if (cpu_variant & ARM_EXT_V5) + mach = bfd_mach_arm_5; + else if (cpu_variant & ARM_THUMB) + mach = bfd_mach_arm_4T; + else if ((cpu_variant & ARM_ARCH_V4) == ARM_ARCH_V4) mach = bfd_mach_arm_4; - break; - - case ARM_7: /* also ARM_6 */ - mach = bfd_mach_arm_3; - break; - } - - /* Catch special cases */ - if (cpu_variant != (FPU_DEFAULT | CPU_DEFAULT)) - { - if (cpu_variant & ARM_THUMB) - mach = bfd_mach_arm_4T; - else if ((cpu_variant & ARM_ARCHv4) == ARM_ARCHv4) - mach = bfd_mach_arm_4; - else if (cpu_variant & ARM_LONGMUL) - mach = bfd_mach_arm_3M; - } - - bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach); - } + else if (cpu_variant & ARM_LONGMUL) + mach = bfd_mach_arm_3M; + } + + bfd_set_arch_mach (stdoutput, TARGET_ARCH, mach); } /* Turn an integer of n bytes (in val) into a stream of bytes appropriate @@ -4884,8 +5070,7 @@ md_begin () This knows about the endian-ness of the target machine and does THE RIGHT THING, whatever it is. Possible values for n are 1 (byte) 2 (short) and 4 (long) Floating numbers are put out as a series of - LITTLENUMS (shorts, here at least) - */ + LITTLENUMS (shorts, here at least). */ void md_number_to_chars (buf, val, n) char * buf; @@ -5010,8 +5195,7 @@ md_atof (type, litP, sizeP) return 0; } -/* The knowledge of the PC's pipeline offset is built into the relocs - for the ELF port and into the insns themselves for the COFF port. */ +/* The knowledge of the PC's pipeline offset is built into the insns themselves. */ long md_pcrel_from (fixP) fixS * fixP; @@ -5025,26 +5209,31 @@ md_pcrel_from (fixP) { /* PC relative addressing on the Thumb is slightly odd as the bottom two bits of the PC are forced to zero - for the calculation */ + for the calculation. */ return (fixP->fx_where + fixP->fx_frag->fr_address) & ~3; } - + +#ifdef TE_WINCE + /* The pattern was adjusted to accomodate CE's off-by-one fixups, + so we un-adjust here to compensate for the accomodation. */ + return fixP->fx_where + fixP->fx_frag->fr_address + 8; +#else return fixP->fx_where + fixP->fx_frag->fr_address; +#endif } /* Round up a section size to the appropriate boundary. */ valueT md_section_align (segment, size) - segT segment; + segT segment ATTRIBUTE_UNUSED; valueT size; { #ifdef OBJ_ELF - /* Don't align the dwarf2 debug sections */ - if (!strncmp (segment->name, ".debug", 5)) - return size; -#endif + return size; +#else /* Round all sects to multiple of 4 */ return (size + 3) & ~3; +#endif } /* Under ELF we need to default _GLOBAL_OFFSET_TABLE. Otherwise @@ -5163,7 +5352,7 @@ md_apply_fix3 (fixP, val, seg) /* Note whether this will delete the relocation. */ #if 0 /* patch from REarnshaw to JDavis (disabled for the moment, since it doesn't work fully) */ - if ((fixP->fx_addsy == 0 || fixP->fx_addsy->sy_value.X_op == O_constant) + if ((fixP->fx_addsy == 0 || symbol_constant_p (fixP->fx_addsy)) && !fixP->fx_pcrel) #else if (fixP->fx_addsy == 0 && !fixP->fx_pcrel) @@ -5179,14 +5368,16 @@ md_apply_fix3 (fixP, val, seg) && S_IS_DEFINED (fixP->fx_addsy) && S_GET_SEGMENT (fixP->fx_addsy) != seg) { - if (fixP->fx_r_type == BFD_RELOC_ARM_PCREL_BRANCH) + if (target_oabi + && (fixP->fx_r_type == BFD_RELOC_ARM_PCREL_BRANCH + )) value = 0; else value += md_pcrel_from (fixP); } } - fixP->fx_addnumber = value; /* Remember value for emit_reloc */ + fixP->fx_addnumber = value; /* Remember value for emit_reloc. */ switch (fixP->fx_r_type) { @@ -5200,7 +5391,8 @@ md_apply_fix3 (fixP, val, seg) && (newimm = negate_data_op (&temp, value)) == (unsigned int) FAIL) { as_bad_where (fixP->fx_file, fixP->fx_line, - _("invalid constant (%x) after fixup\n"), value); + _("invalid constant (%lx) after fixup"), + (unsigned long) value); break; } @@ -5208,15 +5400,62 @@ md_apply_fix3 (fixP, val, seg) md_number_to_chars (buf, (valueT) newimm, INSN_SIZE); break; - case BFD_RELOC_ARM_OFFSET_IMM: + case BFD_RELOC_ARM_ADRL_IMMEDIATE: + { + unsigned int highpart = 0; + unsigned int newinsn = 0xe1a00000; /* nop */ + newimm = validate_immediate (value); + temp = md_chars_to_number (buf, INSN_SIZE); + + /* If the instruction will fail, see if we can fix things up by + changing the opcode. */ + if (newimm == (unsigned int) FAIL + && (newimm = negate_data_op (& temp, value)) == (unsigned int) FAIL) + { + /* No ? OK - try using two ADD instructions to generate the value. */ + newimm = validate_immediate_twopart (value, & highpart); + + /* Yes - then make sure that the second instruction is also an add. */ + if (newimm != (unsigned int) FAIL) + newinsn = temp; + /* Still No ? Try using a negated value. */ + else if (validate_immediate_twopart (- value, & highpart) != (unsigned int) FAIL) + temp = newinsn = (temp & OPCODE_MASK) | OPCODE_SUB << DATA_OP_SHIFT; + /* Otherwise - give up. */ + else + { + as_bad_where (fixP->fx_file, fixP->fx_line, + _("Unable to compute ADRL instructions for PC offset of 0x%x"), value); + break; + } + + /* Replace the first operand in the 2nd instruction (which is the PC) + with the destination register. We have already added in the PC in the + first instruction and we do not want to do it again. */ + newinsn &= ~ 0xf0000; + newinsn |= ((newinsn & 0x0f000) << 4); + } + + newimm |= (temp & 0xfffff000); + md_number_to_chars (buf, (valueT) newimm, INSN_SIZE); + + highpart |= (newinsn & 0xfffff000); + md_number_to_chars (buf + INSN_SIZE, (valueT) highpart, INSN_SIZE); + } + break; + + case BFD_RELOC_ARM_OFFSET_IMM: sign = value >= 0; - if ((value = validate_offset_imm (value, 0)) == FAIL) + + if (value < 0) + value = - value; + + if (validate_offset_imm (value, 0) == FAIL) { - as_bad (_("bad immediate value for offset (%d)"), val); + as_bad_where (fixP->fx_file, fixP->fx_line, + _("bad immediate value for offset (%ld)"), (long) value); break; } - if (value < 0) - value = -value; newval = md_chars_to_number (buf, INSN_SIZE); newval &= 0xff7ff000; @@ -5227,34 +5466,37 @@ md_apply_fix3 (fixP, val, seg) case BFD_RELOC_ARM_OFFSET_IMM8: case BFD_RELOC_ARM_HWLITERAL: sign = value >= 0; - if ((value = validate_offset_imm (value, 1)) == FAIL) + + if (value < 0) + value = - value; + + if (validate_offset_imm (value, 1) == FAIL) { if (fixP->fx_r_type == BFD_RELOC_ARM_HWLITERAL) as_bad_where (fixP->fx_file, fixP->fx_line, - _("invalid literal constant: pool needs to be closer\n")); + _("invalid literal constant: pool needs to be closer")); else - as_bad (_("bad immediate value for offset (%d)"), value); + as_bad (_("bad immediate value for half-word offset (%ld)"), + (long) value); break; } - if (value < 0) - value = -value; - newval = md_chars_to_number (buf, INSN_SIZE); newval &= 0xff7ff0f0; - newval |= ((value >> 4) << 8) | value & 0xf | (sign ? INDEX_UP : 0); + newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0); md_number_to_chars (buf, newval, INSN_SIZE); break; case BFD_RELOC_ARM_LITERAL: sign = value >= 0; + if (value < 0) - value = -value; + value = - value; - if ((value = validate_offset_imm (value, 0)) == FAIL) + if (validate_offset_imm (value, 0) == FAIL) { as_bad_where (fixP->fx_file, fixP->fx_line, - _("invalid literal constant: pool needs to be closer\n")); + _("invalid literal constant: pool needs to be closer")); break; } @@ -5315,19 +5557,67 @@ md_apply_fix3 (fixP, val, seg) case BFD_RELOC_ARM_PCREL_BRANCH: newval = md_chars_to_number (buf, INSN_SIZE); + + /* Sign-extend a 24-bit number. */ +#define SEXT24(x) ((((x) & 0xffffff) ^ (~ 0x7fffff)) + 0x800000) + #ifdef OBJ_ELF - newval &= 0xff000000; if (! target_oabi) - value = fixP->fx_offset; - else -#else - value = (value >> 2) & 0x00ffffff; + value = fixP->fx_offset; +#endif + + /* We are going to store value (shifted right by two) in the + instruction, in a 24 bit, signed field. Thus we need to check + that none of the top 8 bits of the shifted value (top 7 bits of + the unshifted, unsigned value) are set, or that they are all set. */ + if ((value & 0xfe000000UL) != 0 + && ((value & 0xfe000000UL) != 0xfe000000UL)) + { +#ifdef OBJ_ELF + /* Normally we would be stuck at this point, since we cannot store + the absolute address that is the destination of the branch in the + 24 bits of the branch instruction. If however, we happen to know + that the destination of the branch is in the same section as the + branch instruciton itself, then we can compute the relocation for + ourselves and not have to bother the linker with it. + + FIXME: The tests for OBJ_ELF and ! target_oabi are only here + because I have not worked out how to do this for OBJ_COFF or + target_oabi. */ + if (! target_oabi + && fixP->fx_addsy != NULL + && S_IS_DEFINED (fixP->fx_addsy) + && S_GET_SEGMENT (fixP->fx_addsy) == seg) + { + /* Get pc relative value to go into the branch. */ + value = * val; + + /* Permit a backward branch provided that enough bits are set. + Allow a forwards branch, provided that enough bits are clear. */ + if ((value & 0xfe000000UL) == 0xfe000000UL + || (value & 0xfe000000UL) == 0) + fixP->fx_done = 1; + } + + if (! fixP->fx_done) #endif - value = (value + (newval & 0x00ffffff)) & 0x00ffffff; - newval = value | (newval & 0xff000000); + as_bad_where (fixP->fx_file, fixP->fx_line, + _("gas can't handle same-section branch dest >= 0x04000000")); + } + + value >>= 2; + value += SEXT24 (newval); + + if ((value & 0xff000000UL) != 0 + && ((value & 0xff000000UL) != 0xff000000UL)) + as_bad_where (fixP->fx_file, fixP->fx_line, + _("out of range branch")); + + newval = (value & 0x00ffffff) | (newval & 0xff000000); md_number_to_chars (buf, newval, INSN_SIZE); break; + case BFD_RELOC_THUMB_PCREL_BRANCH9: /* conditional branch */ newval = md_chars_to_number (buf, THUMB_SIZE); { @@ -5370,6 +5660,9 @@ md_apply_fix3 (fixP, val, seg) diff = ((newval & 0x7ff) << 12) | ((newval2 & 0x7ff) << 1); if (diff & 0x400000) diff |= ~0x3fffff; +#ifdef OBJ_ELF + value = fixP->fx_offset; +#endif value += diff; if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff)) as_bad_where (fixP->fx_file, fixP->fx_line, @@ -5468,7 +5761,7 @@ md_apply_fix3 (fixP, val, seg) if ((value + 2) & ~0x3fe) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid offset")); + _("Invalid offset, value too big (0x%08X)"), value); /* Round up, since pc will be rounded down. */ newval |= (value + 2) >> 2; @@ -5477,34 +5770,35 @@ md_apply_fix3 (fixP, val, seg) case 9: /* SP load/store */ if (value & ~0x3fc) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid offset")); + _("Invalid offset, value too big (0x%08X)"), value); newval |= value >> 2; break; case 6: /* Word load/store */ if (value & ~0x7c) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid offset")); + _("Invalid offset, value too big (0x%08X)"), value); newval |= value << 4; /* 6 - 2 */ break; case 7: /* Byte load/store */ if (value & ~0x1f) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid offset")); + _("Invalid offset, value too big (0x%08X)"), value); newval |= value << 6; break; case 8: /* Halfword load/store */ if (value & ~0x3e) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid offset")); + _("Invalid offset, value too big (0x%08X)"), value); newval |= value << 5; /* 6 - 1 */ break; default: as_bad_where (fixP->fx_file, fixP->fx_line, - "Unable to process relocation for thumb opcode: %x", newval); + "Unable to process relocation for thumb opcode: %lx", + (unsigned long) newval); break; } md_number_to_chars (buf, newval, THUMB_SIZE); @@ -5543,7 +5837,8 @@ md_apply_fix3 (fixP, val, seg) if (subtract || value & ~0x3fc) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid immediate for address calculation (value = 0x%08X)"), value); + _("Invalid immediate for address calculation (value = 0x%08lX)"), + (unsigned long) value); newval = (rs == REG_PC ? T_OPCODE_ADD_PC : T_OPCODE_ADD_SP); newval |= rd << 8; newval |= value >> 2; @@ -5576,7 +5871,8 @@ md_apply_fix3 (fixP, val, seg) case 0x05: /* 8bit immediate CMP */ if (value < 0 || value > 255) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Invalid immediate: %d is too large"), value); + _("Invalid immediate: %ld is too large"), + (long) value); newval |= value; break; @@ -5590,7 +5886,7 @@ md_apply_fix3 (fixP, val, seg) /* 5bit shift value (0..31) */ if (value < 0 || value > 31) as_bad_where (fixP->fx_file, fixP->fx_line, - _("Illegal Thumb shift value: %d"), value); + _("Illegal Thumb shift value: %ld"), (long) value); newval = md_chars_to_number (buf, THUMB_SIZE) & 0xf03f; newval |= value << 6; md_number_to_chars (buf, newval , THUMB_SIZE); @@ -5604,7 +5900,7 @@ md_apply_fix3 (fixP, val, seg) case BFD_RELOC_NONE: default: as_bad_where (fixP->fx_file, fixP->fx_line, - _("Bad relocation fixup type (%d)\n"), fixP->fx_r_type); + _("Bad relocation fixup type (%d)"), fixP->fx_r_type); } return 1; @@ -5614,7 +5910,7 @@ md_apply_fix3 (fixP, val, seg) format. */ arelent * tc_gen_reloc (section, fixp) - asection * section; + asection * section ATTRIBUTE_UNUSED; fixS * fixp; { arelent * reloc; @@ -5622,7 +5918,8 @@ tc_gen_reloc (section, fixp) reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; /* @@ Why fx_addnumber sometimes and fx_offset other times? */ @@ -5671,17 +5968,11 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_ARM_LITERAL: case BFD_RELOC_ARM_HWLITERAL: /* If this is called then the a literal has been referenced across - a section boundry - possibly due to an implicit dump */ + a section boundary - possibly due to an implicit dump */ as_bad_where (fixp->fx_file, fixp->fx_line, - _("Literal referenced across section boundry (Implicit dump?)")); + _("Literal referenced across section boundary (Implicit dump?)")); return NULL; - case BFD_RELOC_ARM_GOTPC: - assert (fixp->fx_pcrel != 0); - code = fixp->fx_r_type; - code = BFD_RELOC_32_PCREL; - break; - #ifdef OBJ_ELF case BFD_RELOC_ARM_GOT32: case BFD_RELOC_ARM_GOTOFF: @@ -5696,6 +5987,12 @@ tc_gen_reloc (section, fixp) fixp->fx_r_type); return NULL; + case BFD_RELOC_ARM_ADRL_IMMEDIATE: + as_bad_where (fixp->fx_file, fixp->fx_line, + _("ADRL used for a symbol not defined in the same file"), + fixp->fx_r_type); + return NULL; + case BFD_RELOC_ARM_OFFSET_IMM: as_bad_where (fixp->fx_file, fixp->fx_line, _("Internal_relocation (type %d) not fixed up (OFFSET_IMM)"), @@ -5718,7 +6015,7 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_ARM_THUMB_SHIFT: type = "THUMB_SHIFT"; break; case BFD_RELOC_ARM_THUMB_IMM: type = "THUMB_IMM"; break; case BFD_RELOC_ARM_THUMB_OFFSET: type = "THUMB_OFFSET"; break; - default: type = ""; break; + default: type = _(""); break; } as_bad_where (fixp->fx_file, fixp->fx_line, _("Can not represent %s relocation in this object file format (%d)"), @@ -5731,7 +6028,10 @@ tc_gen_reloc (section, fixp) if (code == BFD_RELOC_32_PCREL && GOT_symbol && fixp->fx_addsy == GOT_symbol) - code = BFD_RELOC_ARM_GOTPC; + { + code = BFD_RELOC_ARM_GOTPC; + reloc->addend = fixp->fx_offset = reloc->address; + } #endif reloc->howto = bfd_reloc_type_lookup (stdoutput, code); @@ -5744,21 +6044,25 @@ tc_gen_reloc (section, fixp) return NULL; } + /* HACK: Since arm ELF uses Rel instead of Rela, encode the + vtable entry to be used in the relocation's section offset. */ + if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + reloc->address = fixp->fx_offset; + return reloc; } int md_estimate_size_before_relax (fragP, segtype) - fragS * fragP; - segT segtype; + fragS * fragP ATTRIBUTE_UNUSED; + segT segtype ATTRIBUTE_UNUSED; { as_fatal (_("md_estimate_size_before_relax\n")); return 1; } static void -output_inst (str) - char * str; +output_inst PARAMS ((void)) { char * to = NULL; @@ -5769,11 +6073,18 @@ output_inst (str) } to = frag_more (inst.size); + if (thumb_mode && (inst.size > THUMB_SIZE)) { assert (inst.size == (2 * THUMB_SIZE)); md_number_to_chars (to, inst.instruction >> 16, THUMB_SIZE); - md_number_to_chars (to + 2, inst.instruction, THUMB_SIZE); + md_number_to_chars (to + THUMB_SIZE, inst.instruction, THUMB_SIZE); + } + else if (inst.size > INSN_SIZE) + { + assert (inst.size == (2 * INSN_SIZE)); + md_number_to_chars (to, inst.instruction, INSN_SIZE); + md_number_to_chars (to + INSN_SIZE, inst.instruction, INSN_SIZE); } else md_number_to_chars (to, inst.instruction, inst.size); @@ -5803,7 +6114,7 @@ md_assemble (str) /* Align the previous label if needed. */ if (last_label_seen != NULL) { - last_label_seen->sy_frag = frag_now; + symbol_set_frag (last_label_seen, frag_now); S_SET_VALUE (last_label_seen, (valueT) frag_now_fix ()); S_SET_SEGMENT (last_label_seen, now_seg); } @@ -5811,9 +6122,8 @@ md_assemble (str) memset (&inst, '\0', sizeof (inst)); inst.reloc.type = BFD_RELOC_NONE; - if (*str == ' ') - str++; /* Skip leading white space */ - + skip_whitespace (str); + /* Scan up to the end of the op-code, which must end in white space or end of string. */ for (start = p = str; *p != '\0'; p++) @@ -5828,30 +6138,39 @@ md_assemble (str) if (thumb_mode) { - CONST struct thumb_opcode *opcode; + CONST struct thumb_opcode * opcode; c = *p; *p = '\0'; opcode = (CONST struct thumb_opcode *) hash_find (arm_tops_hsh, str); *p = c; + if (opcode) { + /* Check that this instruction is supported for this CPU. */ + if (thumb_mode == 1 && (opcode->variants & cpu_variant) == 0) + { + as_bad (_("selected processor does not support this opcode")); + return; + } + inst.instruction = opcode->value; inst.size = opcode->size; (*opcode->parms)(p); - output_inst (start); + output_inst (); return; } } else { - CONST struct asm_opcode *opcode; + CONST struct asm_opcode * opcode; + unsigned long cond_code; inst.size = INSN_SIZE; /* p now points to the end of the opcode, probably white space, but we have to break the opcode up in case it contains condionals and flags; keep trying with progressively smaller basic instructions until one - matches, or we run out of opcode. */ + matches, or we run out of opcode. */ q = (p - str > LONGEST_INST) ? str + LONGEST_INST : p; for (; q != str; q--) { @@ -5859,31 +6178,39 @@ md_assemble (str) *q = '\0'; opcode = (CONST struct asm_opcode *) hash_find (arm_ops_hsh, str); *q = c; + if (opcode && opcode->template) { unsigned long flag_bits = 0; - char *r; + char * r; - /* Check that this instruction is supported for this CPU */ + /* Check that this instruction is supported for this CPU. */ if ((opcode->variants & cpu_variant) == 0) goto try_shorter; inst.instruction = opcode->value; - if (q == p) /* Just a simple opcode */ + if (q == p) /* Just a simple opcode. */ { - if (opcode->comp_suffix != 0) - as_bad (_("Opcode `%s' must have suffix from <%s>\n"), str, - opcode->comp_suffix); + if (opcode->comp_suffix) + { + if (*opcode->comp_suffix != '\0') + as_bad (_("Opcode `%s' must have suffix from list: <%s>"), + str, opcode->comp_suffix); + else + /* Not a conditional instruction. */ + (*opcode->parms)(q, 0); + } else { + /* A conditional instruction with default condition. */ inst.instruction |= COND_ALWAYS; (*opcode->parms)(q, 0); } - output_inst (start); + output_inst (); return; } - /* Now check for a conditional */ + /* Not just a simple opcode. Check if extra is a conditional. */ r = q; if (p - r >= 2) { @@ -5899,18 +6226,33 @@ md_assemble (str) as_tsktsk ( _("Warning: Use of the 'nv' conditional is deprecated\n")); - inst.instruction |= cond->value; + cond_code = cond->value; r += 2; } else - inst.instruction |= COND_ALWAYS; + cond_code = COND_ALWAYS; } else - inst.instruction |= COND_ALWAYS; + cond_code = COND_ALWAYS; - /* if there is a compulsory suffix, it should come here, before - any optional flags. */ - if (opcode->comp_suffix) + /* Apply the conditional, or complain it's not allowed. */ + if (opcode->comp_suffix && *opcode->comp_suffix == '\0') + { + /* Instruction isn't conditional */ + if (cond_code != COND_ALWAYS) + { + as_bad (_("Opcode `%s' is unconditional\n"), str); + return; + } + } + else + /* Instruction is conditional: set the condition into it. */ + inst.instruction |= cond_code; + + + /* If there is a compulsory suffix, it should come here, before + any optional flags. */ + if (opcode->comp_suffix && *opcode->comp_suffix != '\0') { CONST char *s = opcode->comp_suffix; @@ -5964,7 +6306,7 @@ _("Warning: Use of the 'nv' conditional is deprecated\n")); } (*opcode->parms) (p, flag_bits); - output_inst (start); + output_inst (); return; } @@ -5974,11 +6316,9 @@ _("Warning: Use of the 'nv' conditional is deprecated\n")); } /* It wasn't an instruction, but it might be a register alias of the form - alias .req reg - */ + alias .req reg */ q = p; - while (*q == ' ') - q++; + skip_whitespace (q); c = *p; *p = '\0'; @@ -5990,8 +6330,7 @@ _("Warning: Use of the 'nv' conditional is deprecated\n")); char * r; q += 4; - while (*q == ' ') - q++; + skip_whitespace (q); for (r = q; *r != '\0'; r++) if (*r == ' ') @@ -6011,20 +6350,17 @@ _("Warning: Use of the 'nv' conditional is deprecated\n")); if (reg == FAIL) { if (regnum != FAIL) - { - insert_reg_alias (str, regnum); - } + insert_reg_alias (str, regnum); else - { - as_warn (_("register '%s' does not exist\n"), q); - } + as_warn (_("register '%s' does not exist\n"), q); } else if (regnum != FAIL) { if (reg != regnum) - as_warn (_("ignoring redefinition of register alias '%s'"), copy_of_str ); + as_warn (_("ignoring redefinition of register alias '%s'"), + copy_of_str ); - /* Do not warn abpout redefinitions to the same alias. */ + /* Do not warn about redefinitions to the same alias. */ } else as_warn (_("ignoring redefinition of register alias '%s' to non-existant register '%s'"), @@ -6051,7 +6387,10 @@ _("Warning: Use of the 'nv' conditional is deprecated\n")); * -m[arm]3 Arm 3 processor * -m[arm]6[xx], Arm 6 processors * -m[arm]7[xx][t][[d]m] Arm 7 processors - * -mstrongarm[110] Arm 8 processors + * -m[arm]8[10] Arm 8 processors + * -m[arm]9[20][tdmi] Arm 9 processors + * -mstrongarm[110[0]] StrongARM processors + * -m[arm]v[2345] Arm architectures * -mall All (except the ARM1) * FP variants: * -mfpa10, -mfpa11 FPA10 and 11 co-processor instructions @@ -6140,7 +6479,8 @@ md_parse_option (c, arg) } else if (streq (str, "thumb-interwork")) { - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_THUMB | ARM_ARCHv4; + if ((cpu_variant & ARM_THUMB) == 0) + cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_ARCH_V4T; #if defined OBJ_COFF || defined OBJ_ELF support_interwork = true; #endif @@ -6262,6 +6602,7 @@ md_parse_option (c, arg) case 70: case 700: case 710: + case 720: case 7100: case 7500: break; @@ -6274,7 +6615,7 @@ md_parse_option (c, arg) switch (* str) { case 't': - cpu_variant |= (ARM_THUMB | ARM_ARCHv4); + cpu_variant |= (ARM_THUMB | ARM_ARCH_V4); break; case 'm': @@ -6301,39 +6642,56 @@ md_parse_option (c, arg) case '8': if (streq (str, "8") || streq (str, "810")) - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_8 | ARM_ARCHv4 | ARM_LONGMUL; + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_8 | ARM_ARCH_V4 | ARM_LONGMUL; else goto bad; break; case '9': if (streq (str, "9")) - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_9 | ARM_ARCHv4 | ARM_LONGMUL; + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_9 | ARM_ARCH_V4 | ARM_LONGMUL | ARM_THUMB; + else if (streq (str, "920")) + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_9 | ARM_ARCH_V4 | ARM_LONGMUL; + else if (streq (str, "920t")) + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_9 | ARM_ARCH_V4 | ARM_LONGMUL | ARM_THUMB; else if (streq (str, "9tdmi")) - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_9 | ARM_ARCHv4 | ARM_LONGMUL | ARM_THUMB; + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_9 | ARM_ARCH_V4 | ARM_LONGMUL | ARM_THUMB; else goto bad; break; + case 's': if (streq (str, "strongarm") || streq (str, "strongarm110") || streq (str, "strongarm1100")) - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_8 | ARM_ARCHv4 | ARM_LONGMUL; + cpu_variant = (cpu_variant & ~ARM_ANY) + | ARM_8 | ARM_ARCH_V4 | ARM_LONGMUL; else goto bad; break; case 'v': - /* Select variant based on architecture rather than processor */ + /* Select variant based on architecture rather than processor. */ switch (*++str) { case '2': switch (*++str) { - case 'a': cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_3; break; - case 0: cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_2; break; - default: as_bad (_("Invalid architecture variant -m%s"), arg); break; + case 'a': + cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_3; + break; + case 0: + cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_2; + break; + default: + as_bad (_("Invalid architecture variant -m%s"), arg); + break; } break; @@ -6344,18 +6702,35 @@ md_parse_option (c, arg) { case 'm': cpu_variant |= ARM_LONGMUL; break; case 0: break; - default: as_bad (_("Invalid architecture variant -m%s"), arg); break; + default: + as_bad (_("Invalid architecture variant -m%s"), arg); + break; } break; case '4': - cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_ARCHv4; + cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_ARCH_V4; switch (*++str) { case 't': cpu_variant |= ARM_THUMB; break; case 0: break; - default: as_bad (_("Invalid architecture variant -m%s"), arg); break; + default: + as_bad (_("Invalid architecture variant -m%s"), arg); + break; + } + break; + + case '5': + cpu_variant = (cpu_variant & ~ARM_ANY) | ARM_ARCH_V5; + switch (*++str) + { + case 't': cpu_variant |= ARM_THUMB; break; + case 'e': cpu_variant |= ARM_EXT_V5E; break; + case 0: break; + default: + as_bad (_("Invalid architecture variant -m%s"), arg); + break; } break; @@ -6373,9 +6748,11 @@ md_parse_option (c, arg) } break; +#if defined OBJ_ELF || defined OBJ_COFF case 'k': pic_code = 1; break; +#endif default: return 0; @@ -6388,39 +6765,29 @@ void md_show_usage (fp) FILE * fp; { - fprintf (fp, -_("\ + fprintf (fp, _("\ ARM Specific Assembler Options:\n\ -m[arm][] select processor variant\n\ - -m[arm]v[2|2a|3|3m|4|4t] select architecture variant\n\ + -m[arm]v[2|2a|3|3m|4|4t|5[t][e]] select architecture variant\n\ -mthumb only allow Thumb instructions\n\ -mthumb-interwork mark the assembled code as supporting interworking\n\ -mall allow any instruction\n\ -mfpa10, -mfpa11 select floating point architecture\n\ -mfpe-old don't allow floating-point multiple instructions\n\ - -mno-fpu don't allow any floating-point instructions.\n")); - fprintf (fp, -_("\ + -mno-fpu don't allow any floating-point instructions.\n\ -k generate PIC code.\n")); #if defined OBJ_COFF || defined OBJ_ELF - fprintf (fp, -_("\ - -mapcs-32, -mapcs-26 specify which ARM Procedure Calling Standard to use\n")); - fprintf (fp, -_("\ - -mapcs-float floating point args are passed in FP regs\n")); - fprintf (fp, -_("\ + fprintf (fp, _("\ + -mapcs-32, -mapcs-26 specify which ARM Procedure Calling Standard to use\n\ + -mapcs-float floating point args are passed in FP regs\n\ -mapcs-reentrant the code is position independent/reentrant\n")); #endif #ifdef OBJ_ELF - fprintf (fp, -_("\ + fprintf (fp, _("\ -moabi support the old ELF ABI\n")); #endif #ifdef ARM_BI_ENDIAN - fprintf (fp, -_("\ + fprintf (fp, _("\ -EB assemble code for a big endian cpu\n\ -EL assemble code for a little endian cpu\n")); #endif @@ -6469,24 +6836,7 @@ fix_new_arm (frag, where, size, exp, pc_rel, reloc) } -/* - * This fix_new is called by cons via TC_CONS_FIX_NEW - * - * We check the expression to see if it is of the form - * __GLOBAL_OFFSET_TABLE + ??? - * If it is then this is a PC relative reference to the GOT. - * i.e. - * ldr sl, L1 - * add sl, pc, sl - * L2: - * ... - * L1: - * .word __GLOBAL_OFFSET_TABLE + (. - (L2 + 4)) - * - * In this case use a reloc type BFD_RELOC_ARM_GOTPC instead of the - * normal BFD_RELOC_{16,32,64} - */ - +/* This fix_new is called by cons via TC_CONS_FIX_NEW. */ void cons_fix_new_arm (frag, where, size, exp) fragS * frag; @@ -6515,28 +6865,21 @@ cons_fix_new_arm (frag, where, size, exp) break; } - /* Look for possible GOTPC reloc */ - - /* - * Look for pic assembler and 'undef symbol + expr symbol' expression - * and a 32 bit size. - */ - fix_new_exp (frag, where, (int) size, exp, pcrel, type); } /* A good place to do this, although this was probably not intended - * for this kind of use. We need to dump the literal pool before - * references are made to a null symbol pointer. */ + for this kind of use. We need to dump the literal pool before + references are made to a null symbol pointer. */ void arm_cleanup () { - if (current_poolP != NULL) - { - subseg_set (text_section, 0); /* Put it at the end of text section */ - s_ltorg (0); - listing_prev_line (); - } + if (current_poolP == NULL) + return; + + subseg_set (text_section, 0); /* Put it at the end of text section. */ + s_ltorg (0); + listing_prev_line (); } void @@ -6613,24 +6956,30 @@ arm_adjust_symtab () } if (ARM_IS_INTERWORK (sym)) - coffsymbol(sym->bsym)->native->u.syment.n_flags = 0xFF; + coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_flags = 0xFF; } #endif #ifdef OBJ_ELF symbolS * sym; - elf_symbol_type * elf_sym; char bind; for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym)) { if (ARM_IS_THUMB (sym)) { + elf_symbol_type * elf_sym; + + elf_sym = elf_symbol (symbol_get_bfdsym (sym)); + bind = ELF_ST_BIND (elf_sym); + + /* If it's a .thumb_func, declare it as so, + otherwise tag label as .code 16. */ if (THUMB_IS_FUNC (sym)) - { - elf_sym = elf_symbol (sym->bsym); - bind = ELF_ST_BIND (elf_sym); - elf_sym->internal_elf_sym.st_info = ELF_ST_INFO (bind, STT_ARM_TFUNC); - } + elf_sym->internal_elf_sym.st_info = + ELF_ST_INFO (bind, STT_ARM_TFUNC); + else + elf_sym->internal_elf_sym.st_info = + ELF_ST_INFO (bind, STT_ARM_16BIT); } } #endif @@ -6658,9 +7007,7 @@ arm_canonicalize_symbol_name (name) if (thumb_mode && (len = strlen (name)) > 5 && streq (name + len - 5, "/data")) - { - *(name + len - 5) = 0; - } + *(name + len - 5) = 0; return name; } @@ -6703,7 +7050,6 @@ boolean arm_fix_adjustable (fixP) fixS * fixP; { - if (fixP->fx_addsy == NULL) return 1; @@ -6755,7 +7101,8 @@ arm_force_relocation (fixp) { if ( fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY - || fixp->fx_r_type == BFD_RELOC_ARM_PCREL_BRANCH) + || fixp->fx_r_type == BFD_RELOC_ARM_PCREL_BRANCH + || fixp->fx_r_type == BFD_RELOC_THUMB_PCREL_BRANCH23) return 1; return 0; @@ -6766,7 +7113,7 @@ arm_parse_reloc () { char id[16]; char * ip; - int i; + unsigned int i; static struct { char * str; @@ -6782,7 +7129,7 @@ arm_parse_reloc () /* Added support for parsing "var(PLT)" branch instructions */ /* generated by GCC for PLT relocs */ MAP ("(plt)", BFD_RELOC_ARM_PLT32), - NULL, 0, BFD_RELOC_UNUSED + { NULL, 0, BFD_RELOC_UNUSED } #undef MAP }; @@ -6834,7 +7181,8 @@ s_arm_elf_cons (nbytes) int size = bfd_get_reloc_size (howto); if (size > nbytes) - as_bad ("%s relocations do not fit in %d bytes", howto->name, nbytes); + as_bad ("%s relocations do not fit in %d bytes", + howto->name, nbytes); else { register char * p = frag_more ((int) nbytes); @@ -6849,9 +7197,8 @@ s_arm_elf_cons (nbytes) } while (*input_line_pointer++ == ','); - input_line_pointer--; /* Put terminator back into stream. */ + input_line_pointer--; /* Put terminator back into stream. */ demand_empty_rest_of_line (); } #endif /* OBJ_ELF */ - diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index bf99e24..c5ab887 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -1,5 +1,6 @@ /* This file is tc-arm.h - Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 + Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) Modified by David Taylor (dtaylor@armltd.co.uk) @@ -103,7 +104,7 @@ extern void arm_start_line_hook PARAMS ((void)); #define tc_frob_label(S) arm_frob_label (S) - extern void arm_frob_label PARAMS ((struct symbol *)); + extern void arm_frob_label PARAMS ((symbolS *)); /* We also need to mark assembler created symbols: */ #define tc_frob_fake_label(S) arm_frob_label (S) @@ -112,8 +113,13 @@ deliberately not been updated to mark assembler created stabs symbols as Thumb. */ +#define TC_FIX_TYPE PTR +#define TC_INIT_FIX_DATA(FIXP) ((FIXP)->tc_fix_data = NULL) + #ifdef OBJ_ELF +#include "write.h" /* For definition of fixS */ #define obj_fix_adjustable(fixP) arm_fix_adjustable (fixP) +boolean arm_fix_adjustable PARAMS ((fixS *)); #else #define obj_fix_adjustable(fixP) 0 #endif @@ -121,9 +127,9 @@ /* We need to keep some local information on symbols. */ #define TC_SYMFIELD_TYPE unsigned int -#define ARM_GET_FLAG(s) ((s)->sy_tc) -#define ARM_SET_FLAG(s,v) ((s)->sy_tc |= (v)) -#define ARM_RESET_FLAG(s,v) ((s)->sy_tc &= ~(v)) +#define ARM_GET_FLAG(s) (*symbol_get_tc (s)) +#define ARM_SET_FLAG(s,v) (*symbol_get_tc (s) |= (v)) +#define ARM_RESET_FLAG(s,v) (*symbol_get_tc (s) &= ~(v)) #define ARM_FLAG_THUMB (1 << 0) /* The symbol is a Thumb symbol rather than an Arm symbol. */ #define ARM_FLAG_INTERWORK (1 << 1) /* The symbol is attached to code that suppports interworking. */ @@ -138,9 +144,6 @@ #define THUMB_SET_FUNC(s,t) ((t) ? ARM_SET_FLAG (s, THUMB_FLAG_FUNC) : ARM_RESET_FLAG (s, THUMB_FLAG_FUNC)) -#define TC_FIX_TYPE PTR -#define TC_INIT_FIX_DATA(FIXP) ((FIXP)->tc_fix_data = NULL) - #define TC_START_LABEL(C,STR) \ (c == ':' || (c == '/' && arm_data_in_code ())) int arm_data_in_code PARAMS ((void)); @@ -153,7 +156,8 @@ char * arm_canonicalize_symbol_name PARAMS ((char *)); extern void arm_adjust_symtab PARAMS ((void)); #ifdef OBJ_ELF -#define obj_frob_symbol(sym, punt) armelf_frob_symbol (sym, punt) +#define obj_frob_symbol(sym, punt) armelf_frob_symbol ((sym), & (punt)) +void armelf_frob_symbol PARAMS ((symbolS *, int *)); #endif #define tc_aout_pre_write_hook(x) {;} /* not used */ @@ -170,6 +174,9 @@ char * arm_canonicalize_symbol_name PARAMS ((char *)); #define LOCAL_LABEL(name) (name[0] == '.' && (name[1] == 'L')) #define LOCAL_LABELS_FB 1 +#ifdef OBJ_ELF +#define LOCAL_LABEL_PREFIX '.' +#endif /* This expression evaluates to false if the relocation is for a local object for which we still want to do the relocation at runtime. True if we diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c new file mode 100644 index 0000000..ea8008c --- /dev/null +++ b/gas/config/tc-avr.c @@ -0,0 +1,1252 @@ +/* tc-avr.c -- Assembler code for the ATMEL AVR + + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Contributed by Denis Chertykov + + 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 2, 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. */ + +#include +#include +#include "as.h" +#include "subsegs.h" + +const char comment_chars[] = ";"; +const char line_comment_chars[] = "#"; +const char line_separator_chars[] = "$"; + +#define AVR_ISA_1200 1 +#define AVR_ISA_2xxx 3 +#define AVR_ISA_MEGA_x03 0x17 +#define AVR_ISA_MEGA 0x10 +#define AVR_ISA_MEGA_161 0x1b + +const char *md_shortopts = "m:"; +struct mcu_type_s +{ + char *name; + int isa; + int mach; +}; + +static struct mcu_type_s mcu_types[] = +{ + {"avr1", AVR_ISA_1200, bfd_mach_avr1}, + {"avr2", AVR_ISA_2xxx, bfd_mach_avr2}, + {"avr3", AVR_ISA_MEGA_x03, bfd_mach_avr3}, + {"avr4", AVR_ISA_MEGA_161, bfd_mach_avr4}, + {"at90s1200", AVR_ISA_1200, bfd_mach_avr1}, + {"at90s2313", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s2323", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s2333", AVR_ISA_2xxx, bfd_mach_avr2}, + {"attiny22" , AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s2343", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s4433", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s4414", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s4434", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s8515", AVR_ISA_2xxx, bfd_mach_avr2}, + {"at90s8535", AVR_ISA_2xxx, bfd_mach_avr2}, + {"atmega603", AVR_ISA_MEGA_x03, bfd_mach_avr3}, + {"atmega103", AVR_ISA_MEGA_x03, bfd_mach_avr3}, + {"atmega161", AVR_ISA_MEGA_161, bfd_mach_avr4}, + {NULL, 0, 0} +}; + + +/* Current MCU type. */ +static struct mcu_type_s default_mcu = {"avr2", AVR_ISA_2xxx,bfd_mach_avr2}; +static struct mcu_type_s *avr_mcu = &default_mcu; + +const char EXP_CHARS[] = "eE"; +const char FLT_CHARS[] = "dD"; +static void avr_set_arch (int dummy); + +/* The target specific pseudo-ops which we support. */ +const pseudo_typeS md_pseudo_table[] = +{ + {"arch", avr_set_arch, 0}, + { NULL, NULL, 0} +}; + +#define LDI_IMMEDIATE(x) (((x) & 0xf) | (((x) << 4) & 0xf00)) +#define REGISTER_P(x) ((x) == 'r' || (x) == 'd' || (x) == 'w') + +struct avr_opcodes_s +{ + char *name; + char *constraints; + char *opcode; + int insn_size; /* in words */ + int isa; + unsigned int bin_opcode; +}; + +static char * skip_space (char * s); +static char * extract_word (char *from, char *to, int limit); +static unsigned int avr_operand (struct avr_opcodes_s *opcode, + int where, char *op, char **line); +static unsigned int avr_operands (struct avr_opcodes_s *opcode, char **line); +static unsigned int avr_get_constant (char * str, unsigned int max); +static char *parse_exp (char *s, expressionS * op); +static bfd_reloc_code_real_type avr_ldi_expression (expressionS *exp); +long md_pcrel_from_section PARAMS ((fixS *, segT)); + +/* constraint letters + r - any register + d - `ldi' register (r16-r31) + M - immediate value from 0 to 255 + n - immediate value from 0 to 255 ( n = ~M ). Relocation impossible + w - `adiw' register (r24,r26,r28,r30) + s - immediate value from 0 to 7 + P - Port address value from 0 to 64. (in, out) + p - Port address value from 0 to 32. (cbi, sbi, sbic, sbis) + K - immediate value from 0 to 64 (used in `adiw', `sbiw') + e - pointer regegisters (X,Y,Z) + b - base pointer register and displacement ([YZ]+disp) + i - immediate value + l - signed pc relative offset from -64 to 63 + L - signed pc relative offset from -2048 to 2047 + h - absolut code address (call, jmp) + S - immediate value from 0 to 7 (S = s << 4) +*/ +struct avr_opcodes_s avr_opcodes[] = +{ + {"adc", "r,r", "000111rdddddrrrr", 1, AVR_ISA_1200, 0x1c00}, + {"add", "r,r", "000011rdddddrrrr", 1, AVR_ISA_1200, 0x0c00}, + {"and", "r,r", "001000rdddddrrrr", 1, AVR_ISA_1200, 0x2000}, + {"cp", "r,r", "000101rdddddrrrr", 1, AVR_ISA_1200, 0x1400}, + {"cpc", "r,r", "000001rdddddrrrr", 1, AVR_ISA_1200, 0x0400}, + {"cpse", "r,r", "000100rdddddrrrr", 1, AVR_ISA_1200, 0x1000}, + {"eor", "r,r", "001001rdddddrrrr", 1, AVR_ISA_1200, 0x2400}, + {"mov", "r,r", "001011rdddddrrrr", 1, AVR_ISA_1200, 0x2c00}, + {"mul", "r,r", "100111rdddddrrrr", 1, AVR_ISA_MEGA_161, 0x9c00}, + {"or", "r,r", "001010rdddddrrrr", 1, AVR_ISA_1200, 0x2800}, + {"sbc", "r,r", "000010rdddddrrrr", 1, AVR_ISA_1200, 0x0800}, + {"sub", "r,r", "000110rdddddrrrr", 1, AVR_ISA_1200, 0x1800}, + + {"clr", "r=r", "001001rdddddrrrr", 1, AVR_ISA_1200, 0x2400}, + {"lsl", "r=r", "000011rdddddrrrr", 1, AVR_ISA_1200, 0x0c00}, + {"rol", "r=r", "000111rdddddrrrr", 1, AVR_ISA_1200, 0x1c00}, + {"tst", "r=r", "001000rdddddrrrr", 1, AVR_ISA_1200, 0x2000}, + + {"andi", "d,M", "0111KKKKddddKKKK", 1, AVR_ISA_1200, 0x7000}, + /*XXX special case*/ + {"cbr", "d,n", "0111KKKKddddKKKK", 1, AVR_ISA_1200, 0x7000}, + {"cpi", "d,M", "0011KKKKddddKKKK", 1, AVR_ISA_1200, 0x3000}, + {"ldi", "d,M", "1110KKKKddddKKKK", 1, AVR_ISA_1200, 0xe000}, + {"ori", "d,M", "0110KKKKddddKKKK", 1, AVR_ISA_1200, 0x6000}, + {"sbci", "d,M", "0100KKKKddddKKKK", 1, AVR_ISA_1200, 0x4000}, + {"sbr", "d,M", "0110KKKKddddKKKK", 1, AVR_ISA_1200, 0x6000}, + {"subi", "d,M", "0101KKKKddddKKKK", 1, AVR_ISA_1200, 0x5000}, + + {"sbrc", "r,s", "1111110rrrrr0sss", 1, AVR_ISA_1200, 0xfc00}, + {"sbrs", "r,s", "1111111rrrrr0sss", 1, AVR_ISA_1200, 0xfe00}, + {"bld", "r,s", "1111100ddddd0sss", 1, AVR_ISA_1200, 0xf800}, + {"bst", "r,s", "1111101ddddd0sss", 1, AVR_ISA_1200, 0xfa00}, + + {"in", "r,P", "10110PPdddddPPPP", 1, AVR_ISA_1200, 0xb000}, + {"out", "P,r", "10111PPrrrrrPPPP", 1, AVR_ISA_1200, 0xb800}, + + {"adiw", "w,K", "10010110KKddKKKK", 1, AVR_ISA_2xxx, 0x9600}, + {"sbiw", "w,K", "10010111KKddKKKK", 1, AVR_ISA_2xxx, 0x9700}, + + {"cbi", "p,s", "10011000pppppsss", 1, AVR_ISA_1200, 0x9800}, + {"sbi", "p,s", "10011010pppppsss", 1, AVR_ISA_1200, 0x9a00}, + {"sbic", "p,s", "10011001pppppsss", 1, AVR_ISA_1200, 0x9900}, + {"sbis", "p,s", "10011011pppppsss", 1, AVR_ISA_1200, 0x9b00}, + + /* ee = {X=11,Y=10,Z=00, 0} */ + {"ld", "r,e", "100!000dddddee-+", 1, AVR_ISA_2xxx, 0x8000}, + {"st", "e,r", "100!001rrrrree-+", 1, AVR_ISA_2xxx, 0x8200}, + {"ldd", "r,b", "10o0oo0dddddbooo", 1, AVR_ISA_2xxx, 0x8000}, + {"std", "b,r", "10o0oo1rrrrrbooo", 1, AVR_ISA_2xxx, 0x8200}, + {"sts", "i,r", "1001001ddddd0000", 2, AVR_ISA_2xxx, 0x9200}, + {"lds", "r,i", "1001000ddddd0000", 2, AVR_ISA_2xxx, 0x9000}, + + {"brbc", "s,l", "111101lllllllsss", 1, AVR_ISA_1200, 0xf400}, + {"brbs", "s,l", "111100lllllllsss", 1, AVR_ISA_1200, 0xf000}, + + {"brcc", "l", "111101lllllll000", 1, AVR_ISA_1200, 0xf400}, + {"brcs", "l", "111100lllllll000", 1, AVR_ISA_1200, 0xf000}, + {"breq", "l", "111100lllllll001", 1, AVR_ISA_1200, 0xf001}, + {"brge", "l", "111101lllllll100", 1, AVR_ISA_1200, 0xf404}, + {"brhc", "l", "111101lllllll101", 1, AVR_ISA_1200, 0xf405}, + {"brhs", "l", "111100lllllll101", 1, AVR_ISA_1200, 0xf005}, + {"brid", "l", "111101lllllll111", 1, AVR_ISA_1200, 0xf407}, + {"brie", "l", "111100lllllll111", 1, AVR_ISA_1200, 0xf007}, + {"brlo", "l", "111100lllllll000", 1, AVR_ISA_1200, 0xf000}, + {"brlt", "l", "111100lllllll100", 1, AVR_ISA_1200, 0xf004}, + {"brmi", "l", "111100lllllll010", 1, AVR_ISA_1200, 0xf002}, + {"brne", "l", "111101lllllll001", 1, AVR_ISA_1200, 0xf401}, + {"brpl", "l", "111101lllllll010", 1, AVR_ISA_1200, 0xf402}, + {"brsh", "l", "111101lllllll000", 1, AVR_ISA_1200, 0xf400}, + {"brtc", "l", "111101lllllll110", 1, AVR_ISA_1200, 0xf406}, + {"brts", "l", "111100lllllll110", 1, AVR_ISA_1200, 0xf006}, + {"brvc", "l", "111101lllllll011", 1, AVR_ISA_1200, 0xf403}, + {"brvs", "l", "111100lllllll011", 1, AVR_ISA_1200, 0xf003}, + + {"rcall", "L", "1101LLLLLLLLLLLL", 1, AVR_ISA_1200, 0xd000}, + {"rjmp", "L", "1100LLLLLLLLLLLL", 1, AVR_ISA_1200, 0xc000}, + + {"call", "h", "1001010hhhhh111h", 2, AVR_ISA_MEGA, 0x940e}, + {"jmp", "h", "1001010hhhhh110h", 2, AVR_ISA_MEGA, 0x940c}, + + {"asr", "r", "1001010rrrrr0101", 1, AVR_ISA_1200, 0x9405}, + {"com", "r", "1001010rrrrr0000", 1, AVR_ISA_1200, 0x9400}, + {"dec", "r", "1001010rrrrr1010", 1, AVR_ISA_1200, 0x940a}, + {"inc", "r", "1001010rrrrr0011", 1, AVR_ISA_1200, 0x9403}, + {"lsr", "r", "1001010rrrrr0110", 1, AVR_ISA_1200, 0x9406}, + {"neg", "r", "1001010rrrrr0001", 1, AVR_ISA_1200, 0x9401}, + {"pop", "r", "1001000rrrrr1111", 1, AVR_ISA_2xxx, 0x900f}, + {"push", "r", "1001001rrrrr1111", 1, AVR_ISA_2xxx, 0x920f}, + {"ror", "r", "1001010rrrrr0111", 1, AVR_ISA_1200, 0x9407}, + {"ser", "d", "11101111dddd1111", 1, AVR_ISA_1200, 0xef0f}, + {"swap", "r", "1001010rrrrr0010", 1, AVR_ISA_1200, 0x9402}, + + {"bclr", "S", "100101001SSS1000", 1, AVR_ISA_1200, 0x9488}, + {"bset", "S", "100101000SSS1000", 1, AVR_ISA_1200, 0x9408}, + + {"clc", "", "1001010010001000", 1, AVR_ISA_1200, 0x9488}, + {"clh", "", "1001010011011000", 1, AVR_ISA_1200, 0x94d8}, + {"cli", "", "1001010011111000", 1, AVR_ISA_1200, 0x94f8}, + {"cln", "", "1001010010101000", 1, AVR_ISA_1200, 0x94a8}, + {"cls", "", "1001010011001000", 1, AVR_ISA_1200, 0x94c8}, + {"clt", "", "1001010011101000", 1, AVR_ISA_1200, 0x94e8}, + {"clv", "", "1001010010111000", 1, AVR_ISA_1200, 0x94b8}, + {"clz", "", "1001010010011000", 1, AVR_ISA_1200, 0x9498}, + {"icall","", "1001010100001001", 1, AVR_ISA_2xxx, 0x9509}, + {"ijmp", "", "1001010000001001", 1, AVR_ISA_2xxx, 0x9409}, + {"lpm", "", "1001010111001000", 1, AVR_ISA_2xxx, 0x95c8}, + {"nop", "", "0000000000000000", 1, AVR_ISA_1200, 0x0000}, + {"ret", "", "1001010100001000", 1, AVR_ISA_1200, 0x9508}, + {"reti", "", "1001010100011000", 1, AVR_ISA_1200, 0x9518}, + {"sec", "", "1001010000001000", 1, AVR_ISA_1200, 0x9408}, + {"seh", "", "1001010001011000", 1, AVR_ISA_1200, 0x9458}, + {"sei", "", "1001010001111000", 1, AVR_ISA_1200, 0x9478}, + {"sen", "", "1001010000101000", 1, AVR_ISA_1200, 0x9428}, + {"ses", "", "1001010001001000", 1, AVR_ISA_1200, 0x9448}, + {"set", "", "1001010001101000", 1, AVR_ISA_1200, 0x9468}, + {"sev", "", "1001010000111000", 1, AVR_ISA_1200, 0x9438}, + {"sez", "", "1001010000011000", 1, AVR_ISA_1200, 0x9418}, + {"sleep","", "1001010110001000", 1, AVR_ISA_1200, 0x9588}, + {"wdr", "", "1001010110101000", 1, AVR_ISA_1200, 0x95a8}, + {"elpm", "", "1001010111011000", 1, AVR_ISA_MEGA_x03, 0x95d8}, + {NULL, NULL, NULL, 0, 0, 0} +}; + + + +#define EXP_MOD_NAME(i) exp_mod[i].name +#define EXP_MOD_RELOC(i) exp_mod[i].reloc +#define EXP_MOD_NEG_RELOC(i) exp_mod[i].neg_reloc +#define HAVE_PM_P(i) exp_mod[i].have_pm + +struct exp_mod_s +{ + char * name; + bfd_reloc_code_real_type reloc; + bfd_reloc_code_real_type neg_reloc; + int have_pm; +}; + +static struct exp_mod_s exp_mod[] = { + {"hh8", BFD_RELOC_AVR_HH8_LDI, BFD_RELOC_AVR_HH8_LDI_NEG, 1}, + {"pm_hh8", BFD_RELOC_AVR_HH8_LDI_PM, BFD_RELOC_AVR_HH8_LDI_PM_NEG, 0}, + {"hi8", BFD_RELOC_AVR_HI8_LDI, BFD_RELOC_AVR_HI8_LDI_NEG, 1}, + {"pm_hi8", BFD_RELOC_AVR_HI8_LDI_PM, BFD_RELOC_AVR_HI8_LDI_PM_NEG, 0}, + {"lo8", BFD_RELOC_AVR_LO8_LDI, BFD_RELOC_AVR_LO8_LDI_NEG, 1}, + {"pm_lo8", BFD_RELOC_AVR_LO8_LDI_PM, BFD_RELOC_AVR_LO8_LDI_PM_NEG, 0}, + {"hlo8", -BFD_RELOC_AVR_LO8_LDI, -BFD_RELOC_AVR_LO8_LDI_NEG, 0}, + {"hhi8", -BFD_RELOC_AVR_HI8_LDI, -BFD_RELOC_AVR_HI8_LDI_NEG, 0}, +}; + +/* Opcode hash table. */ +static struct hash_control *avr_hash; + +/* Reloc modifiers hash control (hh8,hi8,lo8,pm_xx). */ +static struct hash_control *avr_mod_hash; + +#define OPTION_MMCU (OPTION_MD_BASE + 1) + +struct option md_longopts[] = { + {"mmcu", required_argument, NULL, 'm'}, + {NULL, no_argument, NULL, 0} +}; +size_t md_longopts_size = sizeof(md_longopts); + +static inline char * +skip_space (s) + char * s; +{ + while (*s == ' ' || *s == '\t') + ++s; + return s; +} + +/* Extract one word from FROM and copy it to TO. */ +static char * +extract_word (char *from, char *to, int limit) +{ + char *op_start; + char *op_end; + int size = 0; + + /* Drop leading whitespace. */ + from = skip_space (from); + *to = 0; + /* Find the op code end. */ + for (op_start = op_end = from; *op_end != 0 && is_part_of_name(*op_end); ) + { + to[size++] = *op_end++; + if (size + 1 >= limit) + break; + } + to[size] = 0; + return op_end; +} + +int +md_estimate_size_before_relax (fragp, seg) + fragS *fragp; + asection *seg; +{ + abort (); + return 0; +} + +void +md_show_usage (stream) + FILE *stream; +{ + fprintf + (stream, + _ ("AVR options:\n" + " -mmcu=[avr-name] select microcontroller variant\n" + " [avr-name] can be:\n" + " avr1 - AT90S1200\n" + " avr2 - AT90S2xxx, AT90S4xxx, AT90S85xx, ATtiny22\n" + " avr3 - ATmega103 or ATmega603\n" + " avr4 - ATmega161\n" + " or immediate microcontroller name.\n")); +} + +static void +avr_set_arch (dummy) + int dummy; +{ + char * str; + str = (char *)alloca (20); + input_line_pointer = extract_word (input_line_pointer, str, 20); + md_parse_option ('m', str); + bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach); +} + +int +md_parse_option (c, arg) + int c; + char *arg; +{ + char *t = alloca (strlen (arg) + 1); + char *s = t; + char *arg1 = arg; + do + *t = tolower (*arg1++); + while (*t++); + + if (c == 'm') + { + int i; + + for (i = 0; mcu_types[i].name; ++i) + if (strcmp (mcu_types[i].name, s) == 0) + break; + + if (!mcu_types[i].name) + as_fatal (_ ("unknown MCU: %s\n"), arg); + if (avr_mcu == &default_mcu) + avr_mcu = &mcu_types[i]; + else + as_fatal (_ ("redefinition of mcu type `%s'"), mcu_types[i].name); + return 1; + } + return 0; +} + +symbolS * +md_undefined_symbol (name) + char *name; +{ + return 0; +} + +/* Convert a string pointed to by input_line_pointer into a floating point + constant of type `type', and store the appropriate bytes to `*litP'. + The number of LITTLENUMS emitted is stored in `*sizeP'. Returns NULL if + OK, or an error message otherwise. */ +char * +md_atof (type, litP, sizeP) + int type; + char *litP; + int *sizeP; +{ + int prec; + LITTLENUM_TYPE words[4]; + LITTLENUM_TYPE *wordP; + char *t; + + switch (type) + { + case 'f': + prec = 2; + break; + case 'd': + prec = 4; + break; + default: + *sizeP = 0; + return _("bad call to md_atof"); + } + + t = atof_ieee (input_line_pointer, type, words); + if (t) + input_line_pointer = t; + + *sizeP = prec * sizeof (LITTLENUM_TYPE); + /* This loop outputs the LITTLENUMs in REVERSE order. */ + for (wordP = words + prec - 1; prec--;) + { + md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE)); + litP += sizeof (LITTLENUM_TYPE); + } + return NULL; +} + +void +md_convert_frag (abfd, sec, fragP) + bfd *abfd; + asection *sec; + fragS *fragP; +{ + abort (); +} + + +void +md_begin () +{ + int i; + struct avr_opcodes_s *opcode; + avr_hash = hash_new(); + + /* Insert unique names into hash table. This hash table then provides a + quick index to the first opcode with a particular name in the opcode + table. */ + + for (opcode = avr_opcodes; opcode->name; opcode++) + hash_insert (avr_hash, opcode->name, (char *) opcode); + + avr_mod_hash = hash_new (); + + for (i = 0; i < sizeof (exp_mod) / sizeof (exp_mod[0]); ++i) + hash_insert (avr_mod_hash, EXP_MOD_NAME(i), (void*)(i+10)); + + for (i = 0; i < 32; i++) + { + char buf[5]; + + sprintf (buf, "r%d", i); + symbol_table_insert (symbol_new (buf, reg_section, i, + &zero_address_frag)); + sprintf (buf, "R%d", i); + symbol_table_insert (symbol_new (buf, reg_section, i, + &zero_address_frag)); + } + + bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach); +} + + +static unsigned int +avr_operands (opcode, line) + struct avr_opcodes_s *opcode; + char **line; +{ + char *op = opcode->constraints; + unsigned int bin = opcode->bin_opcode; + char *frag = frag_more (opcode->insn_size * 2); + char *str = *line; + int where = frag - frag_now->fr_literal; + + /* Opcode have operands. */ + if (*op) + { + unsigned int reg1 = 0; + unsigned int reg2 = 0; + int reg1_present = 0; + int reg2_present = 0; + + /* Parse first operand. */ + if (REGISTER_P (*op)) + reg1_present = 1; + reg1 = avr_operand (opcode, where, op, &str); + ++op; + + /* Parse second operand. */ + if (*op) + { + if (*op == ',') + ++op; + if (*op == '=') + { + reg2 = reg1; + reg2_present = 1; + } + else + { + if (REGISTER_P (*op)) + reg2_present = 1; + + str = skip_space (str); + if (*str++ != ',') + as_bad (_ ("`,' required")); + str = skip_space (str); + + reg2 = avr_operand (opcode, where, op, &str); + + } + if (reg1_present && reg2_present) + reg2 = (reg2 & 0xf) | ((reg2 << 5) & 0x200); + else if (reg2_present) + reg2 <<= 4; + } + if (reg1_present) + reg1 <<= 4; + bin |= reg1 | reg2; + } + if (opcode->insn_size == 2) + { + bfd_putl32 ((bfd_vma)bin, frag); + } + else + { + bfd_putl16 ((bfd_vma)bin, frag); + } + *line = str; + return bin; +} + +static unsigned int +avr_get_constant (str, max) + char * str; + unsigned int max; +{ + expressionS ex; + str = skip_space (str); + input_line_pointer = str; + expression (&ex); + + if (ex.X_op != O_constant) + as_bad (_("constant value required")); + + if (ex.X_add_number > max) + as_bad (_("number must be less than %d"), max+1); + return ex.X_add_number; +} + +static unsigned int +avr_operand (opcode, where, op, line) + struct avr_opcodes_s *opcode; + int where; + char *op; + char **line; +{ + unsigned int op_mask = 0; + char *str = *line; + expressionS op_expr; + + str = skip_space (str); + switch (*op) + { + /* Any register operand. */ + case 'w': + case 'd': + case 'r': + { + char r_name[256]; + str = extract_word (str, r_name, sizeof (r_name)); + parse_exp (r_name, &op_expr); + if (op_expr.X_op == O_register) + { + op_mask = op_expr.X_add_number; + if (op_mask <= 31) + { + if (*op == 'd') + { + if (op_mask < 16) + as_bad (_ ("register number above 15 required")); + op_mask -= 16; + } + if (*op == 'w') + { + op_mask -= 24; + if (op_mask & 1 || op_mask > 6) + as_bad (_ ("register r24,r26,r28 or r30 required")); + op_mask >>= 1; + } + break; + } + } + as_bad (_ ("register required")); + } + break; + + case 'e': + { + char c; + if (*str == '-') + { + str = skip_space (str+1); + op_mask = 0x1002; + } + c = tolower (*str); + if (c == 'x') + op_mask |= 0x100c; + else if (c == 'y') + op_mask |= 0x8; + else if (c != 'z') + as_bad (_ ("pointer register (X,Y or Z) required")); + + str = skip_space (str+1); + if (*str == '+') + { + ++str; + if (op_mask & 2) + as_bad (_ ("cannot both predecrement and postincrement")); + op_mask |= 0x1001; + } + } + break; + + case 'b': + { + char c = tolower (*str++); + if (c == 'y') + op_mask |= 0x8; + else if (c != 'z') + as_bad (_ ("pointer register (Y or Z) required")); + str = skip_space (str); + if (*str++ == '+') + { + unsigned int x; + x = avr_get_constant (str, 63); + str = input_line_pointer; + op_mask |= (x & 7) | ((x & (3 << 3)) << 7) | ((x & (1 << 5)) << 8); + } + } + break; + + case 'h': + { + str = parse_exp (str, &op_expr); + fix_new_exp (frag_now, where, opcode->insn_size * 2, + &op_expr, false, BFD_RELOC_AVR_CALL); + + } + break; + + case 'L': + { + str = parse_exp (str, &op_expr); + fix_new_exp (frag_now, where, opcode->insn_size * 2, + &op_expr, true, BFD_RELOC_AVR_13_PCREL); + + } + break; + + case 'l': + { + str = parse_exp (str, &op_expr); + fix_new_exp (frag_now, where, opcode->insn_size * 2, + &op_expr, true, BFD_RELOC_AVR_7_PCREL); + + } + break; + + case 'i': + { + str = parse_exp (str, &op_expr); + fix_new_exp (frag_now, where+2, opcode->insn_size * 2, + &op_expr, false, BFD_RELOC_16); + + } + break; + + case 'M': + { + bfd_reloc_code_real_type r_type; + input_line_pointer = str; + r_type = avr_ldi_expression (&op_expr); + str = input_line_pointer; + fix_new_exp (frag_now, where, 3, + &op_expr, false, r_type); + } + break; + + case 'n': + { + unsigned int x; + x = ~avr_get_constant (str, 255); + str = input_line_pointer; + op_mask |= (x & 0xf) | ((x << 4) & 0xf00); + } + break; + + case 'K': + { + unsigned int x; + x = avr_get_constant (str, 63); + str = input_line_pointer; + op_mask |= (x & 0xf) | ((x & 0x30) << 2); + } + break; + + case 'S': + case 's': + { + unsigned int x; + x = avr_get_constant (str, 7); + str = input_line_pointer; + if (*op == 'S') + x <<= 4; + op_mask |= x; + } + break; + + case 'P': + { + unsigned int x; + x = avr_get_constant (str, 63); + str = input_line_pointer; + op_mask |= (x & 0xf) | ((x & 0x30) << 5); + } + break; + + case 'p': + { + unsigned int x; + x = avr_get_constant (str, 31); + str = input_line_pointer; + op_mask |= x << 3; + } + break; + default: + as_bad (_ ("unknown constraint `%c'"), *op); + } + *line = str; + return op_mask; +} + +/* GAS will call this function for each section at the end of the assembly, + to permit the CPU backend to adjust the alignment of a section. */ +valueT +md_section_align (seg, addr) + asection *seg; + valueT addr; +{ + int align = bfd_get_section_alignment (stdoutput, seg); + return ((addr + (1 << align) - 1) & (-1 << align)); +} + +/* If you define this macro, it should return the offset between the + address of a PC relative fixup and the position from which the PC + relative adjustment should be made. On many processors, the base + of a PC relative instruction is the next instruction, so this + macro would return the length of an instruction. */ +long +md_pcrel_from_section (fixp, sec) + fixS *fixp; + segT sec; +{ + if (fixp->fx_addsy != (symbolS *)NULL + && (!S_IS_DEFINED (fixp->fx_addsy) + || (S_GET_SEGMENT (fixp->fx_addsy) != sec))) + return 0; + return fixp->fx_frag->fr_address + fixp->fx_where; +} + +/* GAS will call this for each fixup. It should store the correct + value in the object file. */ +int +md_apply_fix3 (fixp, valuep, seg) + fixS *fixp; + valueT *valuep; + segT seg; +{ + unsigned char *where; + unsigned long insn; + long value; + + if (fixp->fx_addsy == (symbolS *) NULL) + { + value = *valuep; + fixp->fx_done = 1; + } + else if (fixp->fx_pcrel) + { + segT s = S_GET_SEGMENT (fixp->fx_addsy); + if (fixp->fx_addsy && (s == seg || s == absolute_section)) + { + value = S_GET_VALUE (fixp->fx_addsy) + *valuep; + fixp->fx_done = 1; + } + else + value = *valuep; + } + else + { + value = fixp->fx_offset; + if (fixp->fx_subsy != (symbolS *) NULL) + { + if (S_GET_SEGMENT (fixp->fx_subsy) == absolute_section) + { + value -= S_GET_VALUE (fixp->fx_subsy); + fixp->fx_done = 1; + } + else + { + /* We don't actually support subtracting a symbol. */ + as_bad_where (fixp->fx_file, fixp->fx_line, + _ ("expression too complex")); + } + } + } + switch (fixp->fx_r_type) + { + default: + fixp->fx_no_overflow = 1; + break; + case BFD_RELOC_AVR_7_PCREL: + case BFD_RELOC_AVR_13_PCREL: + case BFD_RELOC_32: + case BFD_RELOC_16: + case BFD_RELOC_AVR_CALL: + break; + } + + if (fixp->fx_done) + { + /* Fetch the instruction, insert the fully resolved operand + value, and stuff the instruction back again. */ + where = fixp->fx_frag->fr_literal + fixp->fx_where; + insn = bfd_getl16 (where); + + switch (fixp->fx_r_type) + { + case BFD_RELOC_AVR_7_PCREL: + if (value & 1) + as_bad_where (fixp->fx_file, fixp->fx_line, + _("odd address operand: %ld"), value); + /* Instruction addresses are always right-shifted by 1. */ + value >>= 1; + --value; /* Correct PC. */ + if (value < -64 || value > 63) + as_bad_where (fixp->fx_file, fixp->fx_line, + _("operand out of range: %ld"), value); + value = (value << 3) & 0x3f8; + bfd_putl16 ((bfd_vma) (value | insn), where); + break; + + case BFD_RELOC_AVR_13_PCREL: + if (value & 1) + as_bad_where (fixp->fx_file, fixp->fx_line, + _("odd address operand: %ld"), value); + /* Instruction addresses are always right-shifted by 1. */ + value >>= 1; + --value; /* Correct PC. */ + /* XXX AT90S8515 must have WRAP here. */ + + if (value < -2048 || value > 2047) + { + if (avr_mcu->mach == bfd_mach_avr2) + { + if (value > 2047) + value -= 4096; + else + value += 4096; + } + else + as_bad_where (fixp->fx_file, fixp->fx_line, + _("operand out of range: %ld"), value); + } + + value &= 0xfff; + bfd_putl16 ((bfd_vma) (value | insn), where); + break; + + case BFD_RELOC_32: + bfd_putl16 ((bfd_vma) value, where); + break; + + case BFD_RELOC_16: + bfd_putl16 ((bfd_vma) value, where); + break; + + case BFD_RELOC_AVR_16_PM: + bfd_putl16 ((bfd_vma) (value>>1), where); + break; + + case BFD_RELOC_AVR_LO8_LDI: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value), where); + break; + + case -BFD_RELOC_AVR_LO8_LDI: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 16), where); + break; + + case BFD_RELOC_AVR_HI8_LDI: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 8), where); + break; + + case -BFD_RELOC_AVR_HI8_LDI: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 24), where); + break; + + case BFD_RELOC_AVR_HH8_LDI: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 16), where); + break; + + case BFD_RELOC_AVR_LO8_LDI_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value), where); + break; + + case -BFD_RELOC_AVR_LO8_LDI_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 16), where); + break; + + case BFD_RELOC_AVR_HI8_LDI_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 8), where); + break; + + case -BFD_RELOC_AVR_HI8_LDI_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 24), where); + break; + + case BFD_RELOC_AVR_HH8_LDI_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 16), where); + break; + + case BFD_RELOC_AVR_LO8_LDI_PM: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 1), where); + break; + + case BFD_RELOC_AVR_HI8_LDI_PM: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 9), where); + break; + + case BFD_RELOC_AVR_HH8_LDI_PM: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (value >> 17), where); + break; + + case BFD_RELOC_AVR_LO8_LDI_PM_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 1), where); + break; + + case BFD_RELOC_AVR_HI8_LDI_PM_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 9), where); + break; + + case BFD_RELOC_AVR_HH8_LDI_PM_NEG: + bfd_putl16 ((bfd_vma) insn | LDI_IMMEDIATE (-value >> 17), where); + break; + + case BFD_RELOC_AVR_CALL: + { + unsigned long x; + x = bfd_getl16 (where); + if (value & 1) + as_bad_where (fixp->fx_file, fixp->fx_line, + _("odd address operand: %ld"), value); + value >>= 1; + x |= ((value & 0x10000) | ((value << 3) & 0x1f00000)) >> 16; + bfd_putl16 ((bfd_vma) x, where); + bfd_putl16 ((bfd_vma) (value & 0xffff), where+2); + } + break; + + default: + as_fatal ( _("line %d: unknown relocation type: 0x%x"), + fixp->fx_line, fixp->fx_r_type); + break; + } + } + else + { + switch (fixp->fx_r_type) + { + case -BFD_RELOC_AVR_HI8_LDI_NEG: + case -BFD_RELOC_AVR_HI8_LDI: + case -BFD_RELOC_AVR_LO8_LDI_NEG: + case -BFD_RELOC_AVR_LO8_LDI: + as_bad_where (fixp->fx_file, fixp->fx_line, + _("only constant expression allowed")); + fixp->fx_done = 1; + break; + default: + break; + } + fixp->fx_addnumber = value; + } + return 0; +} + + +/* A `BFD_ASSEMBLER' GAS will call this to generate a reloc. GAS + will pass the resulting reloc to `bfd_install_relocation'. This + currently works poorly, as `bfd_install_relocation' often does the + wrong thing, and instances of `tc_gen_reloc' have been written to + work around the problems, which in turns makes it difficult to fix + `bfd_install_relocation'. */ + +/* If while processing a fixup, a reloc really needs to be created + then it is done here. */ + +arelent * +tc_gen_reloc (seg, fixp) + asection *seg; + fixS *fixp; +{ + arelent *reloc; + + reloc = (arelent *) xmalloc (sizeof (arelent)); + + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); + + reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; + reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); + if (reloc->howto == (reloc_howto_type *) NULL) + { + as_bad_where (fixp->fx_file, fixp->fx_line, + _("reloc %d not supported by object file format"), + (int)fixp->fx_r_type); + return NULL; + } + + if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT + || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + reloc->address = fixp->fx_offset; + + reloc->addend = fixp->fx_offset; + + return reloc; +} + + +void +md_assemble (str) + char *str; +{ + struct avr_opcodes_s * opcode; + char op[11]; + + str = extract_word (str, op, sizeof(op)); + + if (!op[0]) + as_bad (_ ("can't find opcode ")); + + opcode = (struct avr_opcodes_s *) hash_find (avr_hash, op); + + if (opcode == NULL) + { + as_bad (_ ("unknown opcode `%s'"), op); + return; + } + + if ((opcode->isa & avr_mcu->isa) != opcode->isa) + as_bad (_ ("illegal opcode %s for mcu %s"), opcode->name, avr_mcu->name); + + /* We used to set input_line_pointer to the result of get_operands, + but that is wrong. Our caller assumes we don't change it. */ + { + char *t = input_line_pointer; + avr_operands (opcode, &str); + if (*str) + as_bad (_ ("garbage at end of line")); + input_line_pointer = t; + } +} + +/* Parse ordinary expression. */ +static char * +parse_exp (s, op) + char *s; + expressionS * op; +{ + input_line_pointer = s; + expression (op); + if (op->X_op == O_absent) + as_bad (_("missing operand")); + return input_line_pointer; +} + + +/* Parse special expressions (needed for LDI command): + xx8 (address) + xx8 (-address) + pm_xx8 (address) + pm_xx8 (-address) + where xx is: hh, hi, lo +*/ +static bfd_reloc_code_real_type +avr_ldi_expression (exp) + expressionS *exp; +{ + char *str = input_line_pointer; + char *tmp; + char op[8]; + int mod; + tmp = str; + + str = extract_word (str, op, sizeof (op)); + if (op[0]) + { + mod = (int) hash_find (avr_mod_hash, op); + if (mod) + { + int closes = 0; + mod -= 10; + str = skip_space (str); + if (*str == '(') + { + int neg_p = 0; + ++str; + if (strncmp ("pm(", str, 3) == 0 + || strncmp ("-(pm(", str, 5) == 0) + { + if (HAVE_PM_P(mod)) + { + ++mod; + ++closes; + } + else + as_bad (_ ("illegal expression")); + if (*str == '-') + { + neg_p = 1; + ++closes; + str += 5; + } + else + str += 3; + } + if (*str == '-' && *(str + 1) == '(') + { + neg_p ^= 1; + ++closes; + str += 2; + } + input_line_pointer = str; + expression (exp); + do + { + if (*input_line_pointer != ')') + { + as_bad (_ ("`)' required")); + break; + } + input_line_pointer++; + } + while (closes--); + return neg_p ? EXP_MOD_NEG_RELOC (mod) : EXP_MOD_RELOC (mod); + } + } + } + input_line_pointer = tmp; + expression (exp); + return BFD_RELOC_AVR_LO8_LDI; +} + +/* Flag to pass `pm' mode between `avr_parse_cons_expression' and + `avr_cons_fix_new' */ +static int exp_mod_pm = 0; + +/* Parse special CONS expression: pm (expression) + which is used for addressing to a program memory. + Relocation: BFD_RELOC_AVR_16_PM */ +void +avr_parse_cons_expression (exp, nbytes) + expressionS *exp; + int nbytes; +{ + char * tmp; + + exp_mod_pm = 0; + + tmp = input_line_pointer = skip_space (input_line_pointer); + + if (nbytes == 2) + { + char * pm_name = "pm"; + int len = strlen (pm_name); + if (strncasecmp (input_line_pointer, pm_name, len) == 0) + { + input_line_pointer = skip_space (input_line_pointer + len); + if (*input_line_pointer == '(') + { + input_line_pointer = skip_space (input_line_pointer + 1); + exp_mod_pm = 1; + expression (exp); + if (*input_line_pointer == ')') + ++input_line_pointer; + else + { + as_bad (_ ("`)' required")); + exp_mod_pm = 0; + } + return; + } + input_line_pointer = tmp; + } + } + expression (exp); +} + +void +avr_cons_fix_new(frag, where, nbytes, exp) + fragS *frag; + int where; + int nbytes; + expressionS *exp; +{ + if (exp_mod_pm == 0) + { + if (nbytes == 2) + fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_16); + else if (nbytes == 4) + fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_32); + else + as_bad (_ ("illegal %srelocation size: %d"), "", nbytes); + } + else + { + if (nbytes == 2) + fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_AVR_16_PM); + else + as_bad (_ ("illegal %srelocation size: %d"), "`pm' ", nbytes); + exp_mod_pm = 0; + } +} diff --git a/gas/config/tc-avr.h b/gas/config/tc-avr.h new file mode 100644 index 0000000..2a8d3ee --- /dev/null +++ b/gas/config/tc-avr.h @@ -0,0 +1,118 @@ +/* This file is tc-avr.h + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + + Contributed by Denis Chertykov + + 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 2, 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. */ + +#ifndef BFD_ASSEMBLER + #error AVR support requires BFD_ASSEMBLER +#endif + + +#define TC_AVR +/* By convention, you should define this macro in the `.h' file. For + example, `tc-m68k.h' defines `TC_M68K'. You might have to use this + if it is necessary to add CPU specific code to the object format + file. */ + +#define TARGET_FORMAT "elf32-avr" +/* This macro is the BFD target name to use when creating the output + file. This will normally depend upon the `OBJ_FMT' macro. */ + +#define TARGET_ARCH bfd_arch_avr +/* This macro is the BFD architecture to pass to `bfd_set_arch_mach'. */ + +#define TARGET_MACH 0 +/* This macro is the BFD machine number to pass to + `bfd_set_arch_mach'. If it is not defined, GAS will use 0. */ + +#define TARGET_BYTES_BIG_ENDIAN 0 +/* You should define this macro to be non-zero if the target is big + endian, and zero if the target is little endian. */ + +#define ONLY_STANDARD_ESCAPES +/* If you define this macro, GAS will warn about the use of + nonstandard escape sequences in a string. */ + +#define md_operand(x) +/* GAS will call this function for any expression that can not be + recognized. When the function is called, `input_line_pointer' + will point to the start of the expression. */ + +void avr_parse_cons_expression (expressionS *exp, int nbytes); + +#define TC_PARSE_CONS_EXPRESSION(EXPR,N) avr_parse_cons_expression (EXPR,N) +/* + You may define this macro to parse an expression used in a data + allocation pseudo-op such as `.word'. You can use this to + recognize relocation directives that may appear in such directives.*/ + +void avr_cons_fix_new(fragS *frag,int where, int nbytes, expressionS *exp); + +#define TC_CONS_FIX_NEW(FRAG,WHERE,N,EXP) avr_cons_fix_new(FRAG,WHERE,N,EXP) +/* You may define this macro to generate a fixup for a data + allocation pseudo-op. */ + +#define md_number_to_chars number_to_chars_littleendian +/* This should just call either `number_to_chars_bigendian' or + `number_to_chars_littleendian', whichever is appropriate. On + targets like the MIPS which support options to change the + endianness, which function to call is a runtime decision. On + other targets, `md_number_to_chars' can be a simple macro. */ + +#define WORKING_DOT_WORD +/* +`md_short_jump_size' +`md_long_jump_size' +`md_create_short_jump' +`md_create_long_jump' + If `WORKING_DOT_WORD' is defined, GAS will not do broken word + processing (*note Broken words::.). Otherwise, you should set + `md_short_jump_size' to the size of a short jump (a jump that is + just long enough to jump around a long jmp) and + `md_long_jump_size' to the size of a long jump (a jump that can go + anywhere in the function), You should define + `md_create_short_jump' to create a short jump around a long jump, + and define `md_create_long_jump' to create a long jump. */ + +#define MD_APPLY_FIX3 + +#define TC_HANDLES_FX_DONE + +#undef RELOC_EXPANSION_POSSIBLE +/* If you define this macro, it means that `tc_gen_reloc' may return + multiple relocation entries for a single fixup. In this case, the + return value of `tc_gen_reloc' is a pointer to a null terminated + array. */ + +#define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from_section(FIXP, SEC) +/* If you define this macro, it should return the offset between the + address of a PC relative fixup and the position from which the PC + relative adjustment should be made. On many processors, the base + of a PC relative instruction is the next instruction, so this + macro would return the length of an instruction. */ + +#define LISTING_WORD_SIZE 2 +/* The number of bytes to put into a word in a listing. This affects + the way the bytes are clumped together in the listing. For + example, a value of 2 might print `1234 5678' where a value of 1 + would print `12 34 56 78'. The default value is 4. */ + +#define LEX_DOLLAR 0 +/* AVR port uses `$' as a logical line separator */ diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c index cf38f3e..d20ae10 100644 --- a/gas/config/tc-d10v.c +++ b/gas/config/tc-d10v.c @@ -1,6 +1,5 @@ /* tc-d10v.c -- Assembler code for the Mitsubishi D10V - - Copyright (C) 1996, 1997, 1998 Free Software Foundation. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -37,8 +36,8 @@ int Optimizing = 0; #define AT_WORD_P(X) ((X)->X_op == O_right_shift \ && (X)->X_op_symbol != NULL \ - && (X)->X_op_symbol->sy_value.X_op == O_constant \ - && (X)->X_op_symbol->sy_value.X_add_number == AT_WORD_RIGHT_SHIFT) + && symbol_constant_p ((X)->X_op_symbol) \ + && S_GET_VALUE ((X)->X_op_symbol) == AT_WORD_RIGHT_SHIFT) #define AT_WORD_RIGHT_SHIFT 2 @@ -63,6 +62,8 @@ typedef struct _fixups static Fixups FixUps[2]; static Fixups *fixups; +static int do_not_ignore_hash = 0; + /* True if instruction swapping warnings should be inhibited. */ static unsigned char flag_warn_suppress_instructionswap; /* --nowarnswap */ @@ -159,7 +160,7 @@ register_name (expressionP) { expressionP->X_op = O_register; /* temporarily store a pointer to the string here */ - expressionP->X_op_symbol = (struct symbol *)input_line_pointer; + expressionP->X_op_symbol = (symbolS *)input_line_pointer; expressionP->X_add_number = reg_number; input_line_pointer = p; return 1; @@ -195,10 +196,19 @@ check_range (num, bits, flags) if (flags & OPERAND_SIGNED) { - max = (1 << (bits - 1))-1; - min = - (1 << (bits - 1)); - if (((long)num > max) || ((long)num < min)) - retval = 1; + /* Signed 3-bit integers are restricted to the (-2, 3) range */ + if (flags & RESTRICTED_NUM3) + { + if ((long) num < -2 || (long) num > 3) + retval = 1; + } + else + { + max = (1 << (bits - 1)) - 1; + min = - (1 << (bits - 1)); + if (((long) num > max) || ((long) num < min)) + retval = 1; + } } else { @@ -393,7 +403,8 @@ get_operands (exp) char *p = input_line_pointer; int numops = 0; int post = 0; - + int uses_at = 0; + while (*p) { while (*p == ' ' || *p == '\t' || *p == ',') @@ -403,6 +414,8 @@ get_operands (exp) if (*p == '@') { + uses_at = 1; + p++; exp[numops].X_op = O_absent; if (*p == '(') @@ -437,7 +450,20 @@ get_operands (exp) if (!register_name (&exp[numops])) { /* parse as an expression */ - expression (&exp[numops]); + if (uses_at) + { + /* Any expression that involves the indirect addressing + cannot also involve immediate addressing. Therefore + the use of the hash character is illegal. */ + int save = do_not_ignore_hash; + do_not_ignore_hash = 1; + + expression (&exp[numops]); + + do_not_ignore_hash = save; + } + else + expression (&exp[numops]); } if (strncasecmp (input_line_pointer, "@word", 5) == 0) @@ -1227,7 +1253,7 @@ find_opcode (opcode, myops) value = S_GET_VALUE(myops[opnum].X_add_symbol) - value - (obstack_next_free(&frchain_now->frch_obstack) - frag_now->fr_literal); else - value = S_GET_VALUE(myops[opnum].X_add_symbol); + value += S_GET_VALUE(myops[opnum].X_add_symbol); if (AT_WORD_P (&myops[opnum])) { @@ -1288,7 +1314,7 @@ find_opcode (opcode, myops) ((flags & OPERAND_PLUS) && ((X_op != O_absent) || (num != OPERAND_PLUS))) || ((flags & OPERAND_ATMINUS) && ((X_op != O_absent) || (num != OPERAND_ATMINUS))) || ((flags & OPERAND_ATPAR) && ((X_op != O_absent) || (num != OPERAND_ATPAR))) || - ((flags & OPERAND_ATSIGN) && ((X_op != O_absent) || (num != OPERAND_ATSIGN)))) + ((flags & OPERAND_ATSIGN) && ((X_op != O_absent) || ((num != OPERAND_ATSIGN) && (num != OPERAND_ATPAR))))) { match = 0; break; @@ -1376,7 +1402,8 @@ tc_gen_reloc (seg, fixp) { arelent *reloc; reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); if (reloc->howto == (reloc_howto_type *) NULL) @@ -1595,7 +1622,7 @@ void md_operand (expressionP) expressionS *expressionP; { - if (*input_line_pointer == '#') + if (*input_line_pointer == '#' && ! do_not_ignore_hash) { input_line_pointer++; expression (expressionP); diff --git a/gas/config/tc-d10v.h b/gas/config/tc-d10v.h index c6ffd5c..18e6e30 100644 --- a/gas/config/tc-d10v.h +++ b/gas/config/tc-d10v.h @@ -60,3 +60,4 @@ int d10v_cleanup PARAMS ((void)); #define TC_FORCE_RELOCATION(fixp) d10v_force_relocation(fixp) extern int d10v_force_relocation PARAMS ((struct fix *)); +#define md_flush_pending_output d10v_cleanup diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c index c5033ba..f1dc0ea 100644 --- a/gas/config/tc-d30v.c +++ b/gas/config/tc-d30v.c @@ -1,6 +1,5 @@ /* tc-d30v.c -- Assembler code for the Mitsubishi D30V - - Copyright (C) 1997, 1998 Free Software Foundation. + Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -32,6 +31,14 @@ const char *md_shortopts = "OnNcC"; const char EXP_CHARS[] = "eE"; const char FLT_CHARS[] = "dD"; +#if HAVE_LIMITS_H +#include +#endif + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + #define NOP_MULTIPLY 1 #define NOP_ALL 2 static int warn_nops = 0; @@ -216,7 +223,7 @@ register_name (expressionP) { expressionP->X_op = O_register; /* temporarily store a pointer to the string here */ - expressionP->X_op_symbol = (struct symbol *)input_line_pointer; + expressionP->X_op_symbol = (symbolS *)input_line_pointer; expressionP->X_add_number = reg_number; input_line_pointer = p; return 1; @@ -234,38 +241,44 @@ check_range (num, bits, flags) int flags; { long min, max; - int retval=0; - /* don't bother checking 32-bit values */ + /* Don't bother checking 32-bit values. */ if (bits == 32) - return 0; + { + if (sizeof(unsigned long) * CHAR_BIT == 32) + return 0; + + /* We don't record signed or unsigned for 32-bit quantities. + Allow either. */ + min = -((unsigned long)1 << (bits - 1)); + max = ((unsigned long)1 << bits) - 1; + return (long)num < min || (long)num > max; + } if (flags & OPERAND_SHIFT) { /* We know that all shifts are right by three bits.... */ if (flags & OPERAND_SIGNED) - num = (unsigned long) (((/*signed*/ long) num) >> 3); + num = (unsigned long) ( (long) num >= 0) + ? ( ((long) num) >> 3 ) + : ( (num >> 3) | ~(~(unsigned long)0 >> 3) ); else num >>= 3; } if (flags & OPERAND_SIGNED) { - max = (1 << (bits - 1))-1; - min = - (1 << (bits - 1)); - if (((long)num > max) || ((long)num < min)) - retval = 1; + max = ((unsigned long)1 << (bits - 1)) - 1; + min = - ((unsigned long)1 << (bits - 1)); + return (long)num > max || (long)num < min; } else { - max = (1 << bits) - 1; + max = ((unsigned long)1 << bits) - 1; min = 0; - if ((num > max) || (num < min)) - retval = 1; + return num > max || num < min; } - - return retval; } @@ -569,7 +582,7 @@ build_insn (opcode, opers) expressionS *opers; { int i, length, bits, shift, flags; - unsigned int number, id=0; + unsigned long number, id=0; long long insn; struct d30v_opcode *op = opcode->op; struct d30v_format *form = opcode->form; @@ -644,10 +657,10 @@ build_insn (opcode, opers) if (bits == 32) { /* it's a LONG instruction */ - insn |= (number >> 26); /* top 6 bits */ + insn |= ((number & 0xffffffff) >> 26); /* top 6 bits */ insn <<= 32; /* shift the first word over */ - insn |= ((number & 0x03FC0000) << 2); /* next 8 bits */ - insn |= number & 0x0003FFFF; /* bottom 18 bits */ + insn |= ((number & 0x03FC0000) << 2); /* next 8 bits */ + insn |= number & 0x0003FFFF; /* bottom 18 bits */ } else insn |= number << shift; @@ -800,12 +813,16 @@ write_2_short (opcode1, insn1, opcode2, insn2, exec_type, fx) fx = fx->next; } } - else if (opcode1->op->flags_used & (FLAG_JMP | FLAG_JSR) - && ((opcode1->op->flags_used & FLAG_DELAY) == 0) - && ((opcode1->ecc == ECC_AL) || ! Optimizing)) + else if ((opcode1->op->flags_used & (FLAG_JMP | FLAG_JSR) + && ((opcode1->op->flags_used & FLAG_DELAY) == 0) + && ((opcode1->ecc == ECC_AL) || ! Optimizing)) + || opcode1->op->flags_used & FLAG_RP) { /* We must emit (non-delayed) branch type instructions on their own with nothing in the right container. */ + /* We must treat repeat instructions likewise, since the + following instruction has to be separate from the repeat + in order to be repeated. */ write_1_short (opcode1, insn1, fx->next, false); return 1; } @@ -1129,10 +1146,10 @@ parallel_ok (op1, insn1, op2, insn2, exec_type) flags_used1 = op1->op->flags_used; flags_used2 = op2->op->flags_used; - /* ST2W/ST4HB combined with ADDppp/SUBppp is illegal. */ - if (((flags_set1 & (FLAG_MEM | FLAG_2WORD)) == (FLAG_MEM | FLAG_2WORD) + /* Check for illegal combinations with ADDppp/SUBppp. */ + if (((flags_set1 & FLAG_NOT_WITH_ADDSUBppp) != 0 && (flags_used2 & FLAG_ADDSUBppp) != 0) - || ((flags_set2 & (FLAG_MEM | FLAG_2WORD)) == (FLAG_MEM | FLAG_2WORD) + || ((flags_set2 & FLAG_NOT_WITH_ADDSUBppp) != 0 && (flags_used1 & FLAG_ADDSUBppp) != 0)) return 0; @@ -1745,7 +1762,8 @@ tc_gen_reloc (seg, fixp) { arelent *reloc; reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); if (reloc->howto == (reloc_howto_type *) NULL) @@ -2028,7 +2046,7 @@ d30v_frob_label (lab) d30v_cleanup (false); /* Update the label's address with the current output pointer. */ - lab->sy_frag = frag_now; + symbol_set_frag (lab, frag_now); S_SET_VALUE (lab, (valueT) frag_now_fix ()); /* Record this label for future adjustment after we find out what @@ -2110,7 +2128,7 @@ d30v_align (n, pfill, label) assert (S_GET_SEGMENT (label) == now_seg); - old_frag = label->sy_frag; + old_frag = symbol_get_frag (label); old_value = S_GET_VALUE (label); new_value = (valueT) frag_now_fix (); @@ -2125,15 +2143,16 @@ d30v_align (n, pfill, label) in the target fragment. Note, this search is guaranteed to find at least one match when sym == label, so no special case code is necessary. */ - for (sym = symbol_lastP; sym != NULL; sym = sym->sy_previous) + for (sym = symbol_lastP; sym != NULL; sym = symbol_previous (sym)) { - if (sym->sy_frag == old_frag && S_GET_VALUE (sym) == old_value) + if (symbol_get_frag (sym) == old_frag + && S_GET_VALUE (sym) == old_value) { label_seen = true; - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, new_value); } - else if (label_seen && sym->sy_frag != old_frag) + else if (label_seen && symbol_get_frag (sym) != old_frag) break; } } diff --git a/gas/config/tc-d30v.h b/gas/config/tc-d30v.h index acce285..dfebbb9 100644 --- a/gas/config/tc-d30v.h +++ b/gas/config/tc-d30v.h @@ -1,5 +1,5 @@ /* tc-310v.h -- Header file for tc-d30v.c. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. Written by Martin Hunt, Cygnus Support. This file is part of GAS, the GNU Assembler. @@ -15,8 +15,9 @@ 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. */ + 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. */ #define TC_D30V @@ -52,7 +53,7 @@ int d30v_cleanup PARAMS ((int)); #define TC_START_LABEL(ch, ptr) (ch == ':' && d30v_cleanup (false)) #define md_start_line_hook() d30v_start_line (false) -void d30v_frob_label PARAMS ((struct symbol *)); +void d30v_frob_label PARAMS ((symbolS *)); #define tc_frob_label(sym) d30v_frob_label(sym) void d30v_cons_align PARAMS ((int)); diff --git a/gas/config/tc-fr30.c b/gas/config/tc-fr30.c index aa075b7..aca5880 100644 --- a/gas/config/tc-fr30.c +++ b/gas/config/tc-fr30.c @@ -384,7 +384,7 @@ md_convert_frag (abfd, sec, fragP) { /* Address we want to reach in file space. */ target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset; - target_address += fragP->fr_symbol->sy_frag->fr_address; + target_address += symbol_get_frag (fragP->fr_symbol)->fr_address; addend = (target_address - (opcode_address & -4)) >> 2; } diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c index 115ada1..736d6b9 100644 --- a/gas/config/tc-h8300.c +++ b/gas/config/tc-h8300.c @@ -311,7 +311,7 @@ parse_exp (s, op) static char * skip_colonthing (ptr, exp, mode) char *ptr; - expressionS *exp; + expressionS *exp ATTRIBUTE_UNUSED; int *mode; { if (*ptr == ':') @@ -399,7 +399,7 @@ static void get_operand (ptr, op, dst, direction) char **ptr; struct h8_op *op; - unsigned int dst; + unsigned int dst ATTRIBUTE_UNUSED; int direction; { char *src = *ptr; @@ -1343,21 +1343,21 @@ md_assemble (str) void tc_crawl_symbol_chain (headers) - object_headers * headers; + object_headers * headers ATTRIBUTE_UNUSED; { printf (_("call to tc_crawl_symbol_chain \n")); } symbolS * md_undefined_symbol (name) - char *name; + char *name ATTRIBUTE_UNUSED; { return 0; } void tc_headers_hook (headers) - object_headers * headers; + object_headers * headers ATTRIBUTE_UNUSED; { printf (_("call to tc_headers_hook \n")); } @@ -1433,15 +1433,15 @@ size_t md_longopts_size = sizeof(md_longopts); int md_parse_option (c, arg) - int c; - char *arg; + int c ATTRIBUTE_UNUSED; + char *arg ATTRIBUTE_UNUSED; { return 0; } void md_show_usage (stream) - FILE *stream; + FILE *stream ATTRIBUTE_UNUSED; { } @@ -1454,9 +1454,9 @@ tc_aout_fix_to_chars () void md_convert_frag (headers, seg, fragP) - object_headers *headers; - segT seg; - fragS *fragP; + object_headers *headers ATTRIBUTE_UNUSED; + segT seg ATTRIBUTE_UNUSED; + fragS *fragP ATTRIBUTE_UNUSED; { printf (_("call to md_convert_frag \n")); abort (); @@ -1500,8 +1500,8 @@ md_apply_fix (fixP, val) int md_estimate_size_before_relax (fragP, segment_type) - register fragS *fragP; - register segT segment_type; + register fragS *fragP ATTRIBUTE_UNUSED; + register segT segment_type ATTRIBUTE_UNUSED; { printf (_("call tomd_estimate_size_before_relax \n")); abort (); @@ -1519,7 +1519,7 @@ md_number_to_chars (ptr, use, nbytes) } long md_pcrel_from (fixP) - fixS *fixP; + fixS *fixP ATTRIBUTE_UNUSED; { abort (); } diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index 8785de8..7e95a4a 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -1,5 +1,6 @@ /* tc-hppa.c -- Assemble for the PA - Copyright (C) 1989, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -34,32 +35,40 @@ /* Be careful, this file includes data *declarations*. */ #include "opcode/hppa.h" +#if defined (OBJ_ELF) && defined (OBJ_SOM) +error only one of OBJ_ELF and OBJ_SOM can be defined +#endif + +/* If we are using ELF, then we probably can support dwarf2 debug + records. Furthermore, if we are supporting dwarf2 debug records, + then we want to use the assembler support for compact line numbers. */ +#ifdef OBJ_ELF +#include "dwarf2dbg.h" +struct dwarf2_line_info debug_line; +#endif + /* A "convient" place to put object file dependencies which do not need to be seen outside of tc-hppa.c. */ #ifdef OBJ_ELF -/* Names of various debugging spaces/subspaces. */ -#define GDB_DEBUG_SPACE_NAME ".stab" -#define GDB_STRINGS_SUBSPACE_NAME ".stabstr" -#define GDB_SYMBOLS_SUBSPACE_NAME ".stab" -#define UNWIND_SECTION_NAME ".PARISC.unwind" -/* Nonzero if CODE is a fixup code needing further processing. */ - /* Object file formats specify relocation types. */ -typedef elf32_hppa_reloc_type reloc_type; +typedef elf_hppa_reloc_type reloc_type; /* Object file formats specify BFD symbol types. */ typedef elf_symbol_type obj_symbol_type; +#ifdef BFD64 /* How to generate a relocation. */ -#define hppa_gen_reloc_type hppa_elf_gen_reloc_type +#define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type +#else +#define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type +#endif /* ELF objects can have versions, but apparently do not have anywhere to store a copyright string. */ #define obj_version obj_elf_version #define obj_copyright obj_elf_version -/* Use space aliases. */ -#define USE_ALIASES 1 +#define UNWIND_SECTION_NAME ".PARISC.unwind" #endif #ifdef OBJ_SOM @@ -76,9 +85,6 @@ typedef int reloc_type; #define obj_version obj_som_version #define obj_copyright obj_som_copyright -/* Do not use space aliases. */ -#define USE_ALIASES 0 - /* How to generate a relocation. */ #define hppa_gen_reloc_type hppa_som_gen_reloc_type @@ -204,6 +210,8 @@ struct pa_it fp_operand_format fpof1; fp_operand_format fpof2; + /* Whether or not we saw a truncation request on an fcnv insn. */ + int trunc; /* Holds the field selector for this instruction (for example L%, LR%, etc). */ @@ -267,6 +275,7 @@ struct call_desc unsigned int arg_count; }; +#ifdef OBJ_SOM /* This structure defines an entry in the subspace dictionary chain. */ @@ -321,17 +330,6 @@ struct space_dictionary_chain typedef struct space_dictionary_chain sd_chain_struct; -/* Structure for previous label tracking. Needed so that alignments, - callinfo declarations, etc can be easily attached to a particular - label. */ -typedef struct label_symbol_struct - { - struct symbol *lss_label; - sd_chain_struct *lss_space; - struct label_symbol_struct *lss_next; - } -label_symbol_struct; - /* This structure defines attributes of the default subspace dictionary entries. */ @@ -378,9 +376,6 @@ struct default_subspace_dict /* An index into the default spaces array. */ int def_space_index; - /* An alias for this section (or NULL if no alias exists). */ - char *alias; - /* Subsegment associated with this subspace. */ subsegT subsegment; }; @@ -411,10 +406,24 @@ struct default_space_dict /* Segment associated with this space. */ asection *segment; - - /* An alias for this section (or NULL if no alias exists). */ - char *alias; }; +#endif + +/* Structure for previous label tracking. Needed so that alignments, + callinfo declarations, etc can be easily attached to a particular + label. */ +typedef struct label_symbol_struct + { + struct symbol *lss_label; +#ifdef OBJ_SOM + sd_chain_struct *lss_space; +#endif +#ifdef OBJ_ELF + segT lss_segment; +#endif + struct label_symbol_struct *lss_next; + } +label_symbol_struct; /* Extra information needed to perform fixups (relocations) on the PA. */ struct hppa_fix_struct @@ -461,7 +470,10 @@ struct selector_entry /* Prototypes for functions local to tc-hppa.c. */ +#ifdef OBJ_SOM static void pa_check_current_space_and_subspace PARAMS ((void)); +#endif + static fp_operand_format pa_parse_fp_format PARAMS ((char **s)); static void pa_cons PARAMS ((int)); static void pa_data PARAMS ((int)); @@ -483,7 +495,9 @@ static int pa_parse_nonneg_cmpsub_cmpltr PARAMS ((char **, int)); static int pa_parse_neg_cmpsub_cmpltr PARAMS ((char **, int)); static int pa_parse_neg_add_cmpltr PARAMS ((char **, int)); static int pa_parse_nonneg_add_cmpltr PARAMS ((char **, int)); -static void pa_align PARAMS ((int)); +static int pa_parse_cmpb_64_cmpltr PARAMS ((char **)); +static int pa_parse_cmpib_64_cmpltr PARAMS ((char **)); +static int pa_parse_addb_64_cmpltr PARAMS ((char **)); static void pa_block PARAMS ((int)); static void pa_brtab PARAMS ((int)); static void pa_try PARAMS ((int)); @@ -492,9 +506,6 @@ static void pa_call_args PARAMS ((struct call_desc *)); static void pa_callinfo PARAMS ((int)); static void pa_code PARAMS ((int)); static void pa_comm PARAMS ((int)); -#ifdef OBJ_SOM -static void pa_compiler PARAMS ((int)); -#endif static void pa_copyright PARAMS ((int)); static void pa_end PARAMS ((int)); static void pa_enter PARAMS ((int)); @@ -510,15 +521,18 @@ static void pa_level PARAMS ((int)); static void pa_origin PARAMS ((int)); static void pa_proc PARAMS ((int)); static void pa_procend PARAMS ((int)); -static void pa_space PARAMS ((int)); -static void pa_spnum PARAMS ((int)); -static void pa_subspace PARAMS ((int)); static void pa_param PARAMS ((int)); static void pa_undefine_label PARAMS ((void)); static int need_pa11_opcode PARAMS ((struct pa_it *, struct pa_11_fp_reg_struct *)); static int pa_parse_number PARAMS ((char **, struct pa_11_fp_reg_struct *)); static label_symbol_struct *pa_get_label PARAMS ((void)); +#ifdef OBJ_SOM +static void pa_compiler PARAMS ((int)); +static void pa_align PARAMS ((int)); +static void pa_space PARAMS ((int)); +static void pa_spnum PARAMS ((int)); +static void pa_subspace PARAMS ((int)); static sd_chain_struct *create_new_space PARAMS ((char *, int, int, int, int, int, asection *, int)); @@ -539,6 +553,10 @@ static ssd_chain_struct *pa_subsegment_to_subspace PARAMS ((asection *, subsegT)); static sd_chain_struct *pa_find_space_by_number PARAMS ((int)); static unsigned int pa_subspace_start PARAMS ((sd_chain_struct *, int)); +static sd_chain_struct *pa_parse_space_stmt PARAMS ((char *, int)); +static int pa_next_subseg PARAMS ((sd_chain_struct *)); +static void pa_spaces_begin PARAMS ((void)); +#endif static void pa_ip PARAMS ((char *)); static void fix_new_hppa PARAMS ((fragS *, int, int, symbolS *, long, expressionS *, int, @@ -550,11 +568,10 @@ static int reg_name_search PARAMS ((char *)); static int pa_chk_field_selector PARAMS ((char **)); static int is_same_frag PARAMS ((fragS *, fragS *)); static void process_exit PARAMS ((void)); -static sd_chain_struct *pa_parse_space_stmt PARAMS ((char *, int)); static int log2 PARAMS ((int)); -static int pa_next_subseg PARAMS ((sd_chain_struct *)); static unsigned int pa_stringer_aux PARAMS ((char *)); -static void pa_spaces_begin PARAMS ((void)); +static fp_operand_format pa_parse_fp_cnv_format PARAMS ((char **s)); +static int pa_parse_ftest_gfx_completer PARAMS ((char **)); #ifdef OBJ_ELF static void hppa_elf_mark_end_of_function PARAMS ((void)); @@ -563,6 +580,7 @@ static void pa_build_unwind_subspace PARAMS ((struct call_info *)); /* File and gloally scoped variable declarations. */ +#ifdef OBJ_SOM /* Root and final entry in the space chain. */ static sd_chain_struct *space_dict_root; static sd_chain_struct *space_dict_last; @@ -570,6 +588,7 @@ static sd_chain_struct *space_dict_last; /* The current space and subspace. */ static sd_chain_struct *current_space; static ssd_chain_struct *current_subspace; +#endif /* Root of the call_info chain. */ static struct call_info *call_info_root; @@ -596,7 +615,12 @@ const pseudo_typeS md_pseudo_table[] = { /* align pseudo-ops on the PA specify the actual alignment requested, not the log2 of the requested alignment. */ +#ifdef OBJ_SOM {"align", pa_align, 8}, +#endif +#ifdef OBJ_ELF + {"align", s_align_bytes, 8}, +#endif {"begin_brtab", pa_brtab, 1}, {"begin_try", pa_try, 1}, {"block", pa_block, 1}, @@ -612,6 +636,7 @@ const pseudo_typeS md_pseudo_table[] = {"copyright", pa_copyright, 0}, {"data", pa_data, 0}, {"double", pa_float_cons, 'd'}, + {"dword", pa_cons, 8}, {"end", pa_end, 0}, {"end_brtab", pa_brtab, 0}, {"end_try", pa_try, 0}, @@ -620,6 +645,9 @@ const pseudo_typeS md_pseudo_table[] = {"equ", pa_equ, 0}, {"exit", pa_exit, 0}, {"export", pa_export, 0}, +#ifdef OBJ_ELF + { "file", dwarf2_directive_file }, +#endif {"fill", pa_fill, 0}, {"float", pa_float_cons, 'f'}, {"half", pa_cons, 2}, @@ -629,9 +657,14 @@ const pseudo_typeS md_pseudo_table[] = {"lcomm", pa_lcomm, 0}, {"leave", pa_leave, 0}, {"level", pa_level, 0}, +#ifdef OBJ_ELF + { "loc", dwarf2_directive_loc }, +#endif {"long", pa_cons, 4}, {"lsym", pa_lsym, 0}, +#ifdef OBJ_SOM {"nsubspa", pa_subspace, 1}, +#endif {"octa", pa_cons, 16}, {"org", pa_origin, 0}, {"origin", pa_origin, 0}, @@ -642,11 +675,15 @@ const pseudo_typeS md_pseudo_table[] = {"reg", pa_equ, 1}, {"short", pa_cons, 2}, {"single", pa_float_cons, 'f'}, +#ifdef OBJ_SOM {"space", pa_space, 0}, {"spnum", pa_spnum, 0}, +#endif {"string", pa_stringer, 0}, {"stringz", pa_stringer, 1}, +#ifdef OBJ_SOM {"subspa", pa_subspace, 0}, +#endif {"text", pa_text, 0}, {"version", pa_version, 0}, {"word", pa_cons, 4}, @@ -701,9 +738,16 @@ static label_symbol_struct *label_symbols_rootp = NULL; /* Holds the last field selector. */ static int hppa_field_selector; +/* Nonzero when strict syntax checking is enabled. Zero otherwise. + + Each opcode in the table has a flag which indicates whether or not + strict syntax checking should be enabled for that instruction. */ +static int strict = 0; +#ifdef OBJ_SOM /* A dummy bfd symbol so that all relocations have symbols of some kind. */ static symbolS *dummy_symbol; +#endif /* Nonzero if errors are to be printed. */ static int print_errors = 1; @@ -982,6 +1026,7 @@ static const struct selector_entry selector_table[] = {"lr", e_lrsel}, {"ls", e_lssel}, {"lt", e_ltsel}, + {"ltp", e_ltpsel}, {"n", e_nsel}, {"nl", e_nlsel}, {"nlr", e_nlrsel}, @@ -992,9 +1037,11 @@ static const struct selector_entry selector_table[] = {"rr", e_rrsel}, {"rs", e_rssel}, {"rt", e_rtsel}, + {"rtp", e_rtpsel}, {"t", e_tsel}, }; +#ifdef OBJ_SOM /* default space and subspace dictionaries */ #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME @@ -1012,31 +1059,23 @@ static const struct selector_entry selector_table[] = static struct default_subspace_dict pa_def_subspaces[] = { - {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_CODE}, - {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, ".data", SUBSEG_DATA}, - {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_LIT}, - {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_MILLI}, - {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, ".bss", SUBSEG_BSS}, -#ifdef OBJ_ELF - {"$UNWIND$", 1, 1, 0, 0, 0, 0, 64, 0x2c, 0, 4, 0, 0, ".PARISC.unwind", SUBSEG_UNWIND}, -#endif + {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE}, + {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA}, + {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT}, + {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI}, + {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS}, {NULL, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0} }; static struct default_space_dict pa_def_spaces[] = { - {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL, ".text"}, - {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL, ".data"}, - {NULL, 0, 0, 0, 0, 0, ASEC_NULL, NULL} + {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL}, + {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL}, + {NULL, 0, 0, 0, 0, 0, ASEC_NULL} }; /* Misc local definitions used by the assembler. */ -/* Return nonzero if the string pointed to by S potentially represents - a right or left half of a FP register */ -#define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r') -#define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l') - /* These macros are used to maintain spaces/subspaces. */ #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined @@ -1045,6 +1084,12 @@ static struct default_space_dict pa_def_spaces[] = #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name +#endif + +/* Return nonzero if the string pointed to by S potentially represents + a right or left half of a FP register */ +#define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r') +#define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l') /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip main loop after insertion. */ @@ -1071,11 +1116,11 @@ static struct default_space_dict pa_def_spaces[] = #define is_DP_relative(exp) \ ((exp).X_op == O_subtract \ - && strcmp((exp).X_op_symbol->bsym->name, "$global$") == 0) + && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0) #define is_PC_relative(exp) \ ((exp).X_op == O_subtract \ - && strcmp((exp).X_op_symbol->bsym->name, "$PIC_pcrel$0") == 0) + && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0) /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll always be able to reduce the expression to a constant, so we don't @@ -1098,18 +1143,6 @@ pa_check_eof () as_fatal (_("Missing .procend\n")); } -/* Check to make sure we have a valid space and subspace. */ - -static void -pa_check_current_space_and_subspace () -{ - if (current_space == NULL) - as_fatal (_("Not in a space.\n")); - - if (current_subspace == NULL) - as_fatal (_("Not in a subspace.\n")); -} - /* Returns a pointer to the label_symbol_struct for the current space. or NULL if no label_symbol_struct exists for the current space. */ @@ -1117,13 +1150,20 @@ static label_symbol_struct * pa_get_label () { label_symbol_struct *label_chain; - sd_chain_struct *space_chain = current_space; for (label_chain = label_symbols_rootp; label_chain; label_chain = label_chain->lss_next) - if (space_chain == label_chain->lss_space && label_chain->lss_label) + { +#ifdef OBJ_SOM + if (current_space == label_chain->lss_space && label_chain->lss_label) return label_chain; +#endif +#ifdef OBJ_ELF + if (now_seg == label_chain->lss_segment && label_chain->lss_label) + return label_chain; +#endif + } return NULL; } @@ -1136,7 +1176,6 @@ pa_define_label (symbol) symbolS *symbol; { label_symbol_struct *label_chain = pa_get_label (); - sd_chain_struct *space_chain = current_space; if (label_chain) label_chain->lss_label = symbol; @@ -1146,7 +1185,12 @@ pa_define_label (symbol) label_chain = (label_symbol_struct *) xmalloc (sizeof (label_symbol_struct)); label_chain->lss_label = symbol; - label_chain->lss_space = space_chain; +#ifdef OBJ_SOM + label_chain->lss_space = current_space; +#endif +#ifdef OBJ_ELF + label_chain->lss_segment = now_seg; +#endif label_chain->lss_next = NULL; if (label_symbols_rootp) @@ -1164,13 +1208,19 @@ pa_undefine_label () { label_symbol_struct *label_chain; label_symbol_struct *prev_label_chain = NULL; - sd_chain_struct *space_chain = current_space; for (label_chain = label_symbols_rootp; label_chain; label_chain = label_chain->lss_next) { - if (space_chain == label_chain->lss_space && label_chain->lss_label) + if (1 +#ifdef OBJ_SOM + && current_space == label_chain->lss_space && label_chain->lss_label +#endif +#ifdef OBJ_ELF + && now_seg == label_chain->lss_segment && label_chain->lss_label +#endif + ) { /* Remove the label from the chain and free its memory. */ if (prev_label_chain) @@ -1273,7 +1323,7 @@ cons_fix_new_hppa (frag, where, size, exp) fix_new_hppa (frag, where, size, (symbolS *) NULL, (offsetT) 0, exp, 0, rel_type, - hppa_field_selector, 32, 0, NULL); + hppa_field_selector, size * 8, 0, NULL); /* Reset field selector to its default state. */ hppa_field_selector = 0; @@ -1304,7 +1354,9 @@ md_begin () flag_readonly_data_in_text = 0; } +#ifdef OBJ_SOM pa_spaces_begin (); +#endif op_hash = hash_new (); @@ -1334,12 +1386,18 @@ md_begin () if (lose) as_fatal (_("Broken assembler. No assembly attempted.")); +#ifdef OBJ_SOM /* SOM will change text_section. To make sure we never put anything into the old one switch to the new one now. */ subseg_set (text_section, 0); +#endif +#ifdef OBJ_SOM dummy_symbol = symbol_find_or_make ("L$dummy"); S_SET_SEGMENT (dummy_symbol, text_section); + /* Force the symbol to be converted to a real symbol. */ + (void) symbol_get_bfdsym (dummy_symbol); +#endif } /* Assemble a single instruction storing it into a frag. */ @@ -1368,7 +1426,8 @@ md_assemble (str) if (label_symbol->lss_label) { last_call_info->start_symbol = label_symbol->lss_label; - label_symbol->lss_label->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (label_symbol->lss_label)->flags + |= BSF_FUNCTION; #ifdef OBJ_SOM /* Also handle allocation of a fixup to hold the unwind information when the label appears after the proc/procend. */ @@ -1405,6 +1464,23 @@ md_assemble (str) (offsetT) 0, &the_insn.exp, the_insn.pcrel, the_insn.reloc, the_insn.field_selector, the_insn.format, the_insn.arg_reloc, NULL); + +#ifdef OBJ_ELF + if (debug_type == DEBUG_DWARF2) + { + bfd_vma addr; + + /* First update the notion of the current source line. */ + dwarf2_where (&debug_line); + + /* We want the offset of the start of this instruction within the + the current frag. */ + addr = frag_now->fr_address + frag_now_fix () - 4; + + /* And record the information. */ + dwarf2_gen_line_info (addr, &debug_line); + } +#endif } /* Do the real work for assembling a single instruction. Store results @@ -1423,8 +1499,16 @@ pa_ip (str) unsigned long opcode; struct pa_opcode *insn; +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif + + /* Convert everything up to the first whitespace character into lower + case. */ + for (s = str; *s != ' ' && *s != '\t' && *s != '\n' && *s != '\0'; s++) + if (isupper (*s)) + *s = tolower (*s); /* Skip to something interesting. */ for (s = str; isupper (*s) || islower (*s) || (*s >= '0' && *s <= '3'); ++s) @@ -1451,14 +1535,6 @@ pa_ip (str) save_s = str; - /* Convert everything into lower case. */ - while (*save_s) - { - if (isupper (*save_s)) - *save_s = tolower (*save_s); - save_s++; - } - /* Look up the opcode in the has table. */ if ((insn = (struct pa_opcode *) hash_find (op_hash, str)) == NULL) { @@ -1478,6 +1554,7 @@ pa_ip (str) { /* Do some initialization. */ opcode = insn->match; + strict = (insn->flags & FLAG_STRICT); memset (&the_insn, 0, sizeof (the_insn)); the_insn.reloc = R_HPPA_NONE; @@ -1502,6 +1579,10 @@ pa_ip (str) sure that the operands match. */ for (args = insn->args;; ++args) { + /* Absorb white space in instruction. */ + while (*s == ' ' || *s == '\t') + s++; + switch (*args) { @@ -1533,26 +1614,65 @@ pa_ip (str) /* Handle a 5 bit register or control register field at 10. */ case 'b': case '^': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; num = pa_parse_number (&s, 0); CHECK_FIELD (num, 31, 0, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 21); + /* Handle %sar or %cr11. No bits get set, we just verify that it + is there. */ + case '!': + /* Skip whitespace before register. */ + while (*s == ' ' || *s == '\t') + s = s + 1; + + if (!strncasecmp(s, "%sar", 4)) + { + s += 4; + continue; + } + else if (!strncasecmp(s, "%cr11", 5)) + { + s += 5; + continue; + } + break; + /* Handle a 5 bit register field at 15. */ case 'x': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; num = pa_parse_number (&s, 0); CHECK_FIELD (num, 31, 0, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 16); /* Handle a 5 bit register field at 31. */ - case 'y': case 't': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; num = pa_parse_number (&s, 0); CHECK_FIELD (num, 31, 0, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + /* Handle a 5 bit register field at 10 and 15. */ + case 'a': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + num = pa_parse_number (&s, 0); + CHECK_FIELD (num, 31, 0, 0); + opcode |= num << 16; + INSERT_FIELD_AND_CONTINUE (opcode, num, 21); + /* Handle a 5 bit field length at 31. */ case 'T': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; CHECK_FIELD (num, 32, 1, 0); INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0); @@ -1560,546 +1680,1156 @@ pa_ip (str) /* Handle a 5 bit immediate at 15. */ case '5': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 15, -16, 0); + /* When in strict mode, we want to just reject this + match instead of giving an out of range error. */ + CHECK_FIELD (num, 15, -16, strict); low_sign_unext (num, 5, &num); INSERT_FIELD_AND_CONTINUE (opcode, num, 16); /* Handle a 5 bit immediate at 31. */ case 'V': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 15, -16, 0) + /* When in strict mode, we want to just reject this + match instead of giving an out of range error. */ + CHECK_FIELD (num, 15, -16, strict) low_sign_unext (num, 5, &num); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); /* Handle an unsigned 5 bit immediate at 31. */ case 'r': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; CHECK_FIELD (num, 31, 0, 0); - INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + INSERT_FIELD_AND_CONTINUE (opcode, num, strict); /* Handle an unsigned 5 bit immediate at 15. */ case 'R': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 31, 0, 0); + CHECK_FIELD (num, 31, 0, strict); + INSERT_FIELD_AND_CONTINUE (opcode, num, 16); + + /* Handle an unsigned 10 bit immediate at 15. */ + case 'U': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 1023, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 16); /* Handle a 2 bit space identifier at 17. */ case 's': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; num = pa_parse_number (&s, 0); CHECK_FIELD (num, 3, 0, 1); INSERT_FIELD_AND_CONTINUE (opcode, num, 14); /* Handle a 3 bit space identifier at 18. */ case 'S': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; num = pa_parse_number (&s, 0); CHECK_FIELD (num, 7, 0, 1); dis_assemble_3 (num, &num); INSERT_FIELD_AND_CONTINUE (opcode, num, 13); - /* Handle a completer for an indexing load or store. */ + /* Handle all completers. */ case 'c': - { - int uu = 0; - int m = 0; - int i = 0; - while (*s == ',' && i < 2) + switch (*++args) + { + + /* Handle a completer for an indexing load or store. */ + case 'x': { - s++; - if (strncasecmp (s, "sm", 2) == 0) + int uu = 0; + int m = 0; + int i = 0; + while (*s == ',' && i < 2) { - uu = 1; - m = 1; + s++; + if (strncasecmp (s, "sm", 2) == 0) + { + uu = 1; + m = 1; + s++; + i++; + } + else if (strncasecmp (s, "m", 1) == 0) + m = 1; + else if ((strncasecmp (s, "s ", 2) == 0) + || (strncasecmp (s, "s,", 2) == 0)) + uu = 1; + /* When in strict mode this is a match failure. */ + else if (strict) + { + s--; + break; + } + else + as_bad (_("Invalid Indexed Load Completer.")); s++; i++; } - else if (strncasecmp (s, "m", 1) == 0) - m = 1; - else if (strncasecmp (s, "s", 1) == 0) - uu = 1; - else - as_bad (_("Invalid Indexed Load Completer.")); - s++; - i++; + if (i > 2) + as_bad (_("Invalid Indexed Load Completer Syntax.")); + opcode |= m << 5; + INSERT_FIELD_AND_CONTINUE (opcode, uu, 13); } - if (i > 2) - as_bad (_("Invalid Indexed Load Completer Syntax.")); - opcode |= m << 5; - INSERT_FIELD_AND_CONTINUE (opcode, uu, 13); - } - /* Handle a short load/store completer. */ - case 'C': - { - int a = 0; - int m = 0; - if (*s == ',') + /* Handle a short load/store completer. */ + case 'm': + case 'q': + case 'J': + case 'e': { - s++; - if (strncasecmp (s, "ma", 2) == 0) + int a = 0; + int m = 0; + if (*s == ',') + { + int found = 0; + s++; + if (strncasecmp (s, "ma", 2) == 0) + { + a = 0; + m = 1; + found = 1; + } + else if (strncasecmp (s, "mb", 2) == 0) + { + a = 1; + m = 1; + found = 1; + } + + /* When in strict mode, pass through for cache op. */ + if (!found && strict) + s--; + else + { + if (!found) + as_bad (_("Invalid Short Load/Store Completer.")); + s += 2; + } + } + /* If we did not get a ma/mb completer, then we do not + consider this a positive match for 'ce'. */ + else if (*args == 'e') + break; + + /* 'J', 'm' and 'q' are the same, except for where they + encode the before/after field. */ + if (*args == 'm') { - a = 0; - m = 1; + opcode |= m << 5; + INSERT_FIELD_AND_CONTINUE (opcode, a, 13); } - else if (strncasecmp (s, "mb", 2) == 0) + else if (*args == 'q') { - a = 1; - m = 1; + opcode |= m << 3; + INSERT_FIELD_AND_CONTINUE (opcode, a, 2); + } + else if (*args == 'J') + { + /* M bit is explicit in the major opcode. */ + INSERT_FIELD_AND_CONTINUE (opcode, a, 2); + } + else if (*args == 'e') + { + /* Gross! Hide these values in the immediate field + of the instruction, then pull them out later. */ + opcode |= m << 8; + opcode |= a << 9; + continue; } - else - as_bad (_("Invalid Short Load/Store Completer.")); - s += 2; } - if (*args == 'C') + /* Handle a stbys completer. */ + case 's': { + int a = 0; + int m = 0; + int i = 0; + while (*s == ',' && i < 2) + { + s++; + if (strncasecmp (s, "m", 1) == 0) + m = 1; + else if ((strncasecmp (s, "b ", 2) == 0) + || (strncasecmp (s, "b,", 2) == 0)) + a = 0; + else if (strncasecmp (s, "e", 1) == 0) + a = 1; + /* When in strict mode this is a match failure. */ + else if (strict) + { + s--; + break; + } + else + as_bad (_("Invalid Store Bytes Short Completer")); + s++; + i++; + } + if (i > 2) + as_bad (_("Invalid Store Bytes Short Completer")); opcode |= m << 5; INSERT_FIELD_AND_CONTINUE (opcode, a, 13); } - } - - /* Handle a stbys completer. */ - case 'Y': - { - int a = 0; - int m = 0; - int i = 0; - while (*s == ',' && i < 2) - { - s++; - if (strncasecmp (s, "m", 1) == 0) - m = 1; - else if (strncasecmp (s, "b", 1) == 0) - a = 0; - else if (strncasecmp (s, "e", 1) == 0) - a = 1; - else - as_bad (_("Invalid Store Bytes Short Completer")); - s++; - i++; - } - if (i > 2) - as_bad (_("Invalid Store Bytes Short Completer")); - opcode |= m << 5; - INSERT_FIELD_AND_CONTINUE (opcode, a, 13); - } - /* Handle a non-negated compare/stubtract condition. */ - case '<': - cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1); - if (cmpltr < 0) - { - as_bad (_("Invalid Compare/Subtract Condition: %c"), *s); + /* Handle load cache hint completer. */ + case 'c': cmpltr = 0; - } - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); - - /* Handle a negated or non-negated compare/subtract condition. */ - case '?': - save_s = s; - cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1); - if (cmpltr < 0) - { - s = save_s; - cmpltr = pa_parse_neg_cmpsub_cmpltr (&s, 1); - if (cmpltr < 0) - { - as_bad (_("Invalid Compare/Subtract Condition.")); - cmpltr = 0; - } - else + if (!strncmp(s, ",sl", 3)) { - /* Negated condition requires an opcode change. */ - opcode |= 1 << 27; + s += 3; + cmpltr = 2; } - } - - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); - /* Handle non-negated add condition. */ - case '!': - cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1); - if (cmpltr < 0) - { - as_bad (_("Invalid Compare/Subtract Condition: %c"), *s); + /* Handle store cache hint completer. */ + case 'C': cmpltr = 0; - } - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); - - /* Handle a negated or non-negated add condition. */ - case '@': - save_s = s; - cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1); - if (cmpltr < 0) - { - s = save_s; - cmpltr = pa_parse_neg_add_cmpltr (&s, 1); - if (cmpltr < 0) + if (!strncmp(s, ",sl", 3)) { - as_bad (_("Invalid Compare/Subtract Condition")); - cmpltr = 0; + s += 3; + cmpltr = 2; } - else + else if (!strncmp(s, ",bc", 3)) { - /* Negated condition requires an opcode change. */ - opcode |= 1 << 27; + s += 3; + cmpltr = 1; } - } - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); - /* Handle a compare/subtract condition. */ - case 'a': - cmpltr = 0; - flag = 0; - if (*s == ',') - { - s++; - name = s; - while (*s != ',' && *s != ' ' && *s != '\t') - s += 1; - c = *s; - *s = 0x00; - if (strcmp (name, "=") == 0) - cmpltr = 1; - else if (strcmp (name, "<") == 0) - cmpltr = 2; - else if (strcmp (name, "<=") == 0) - cmpltr = 3; - else if (strcasecmp (name, "<<") == 0) - cmpltr = 4; - else if (strcasecmp (name, "<<=") == 0) - cmpltr = 5; - else if (strcasecmp (name, "sv") == 0) - cmpltr = 6; - else if (strcasecmp (name, "od") == 0) - cmpltr = 7; - else if (strcasecmp (name, "tr") == 0) - { - cmpltr = 0; - flag = 1; - } - else if (strcmp (name, "<>") == 0) + /* Handle load and clear cache hint completer. */ + case 'd': + cmpltr = 0; + if (!strncmp(s, ",co", 3)) { + s += 3; cmpltr = 1; - flag = 1; - } - else if (strcmp (name, ">=") == 0) - { - cmpltr = 2; - flag = 1; } - else if (strcmp (name, ">") == 0) - { - cmpltr = 3; - flag = 1; - } - else if (strcasecmp (name, ">>=") == 0) + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); + + /* Handle load ordering completer. */ + case 'o': + if (strncmp(s, ",o", 2) != 0) + break; + s += 2; + continue; + + /* Handle a branch gate completer. */ + case 'g': + if (strncasecmp (s, ",gate", 5) != 0) + break; + s += 5; + continue; + + /* Handle a branch link and push completer. */ + case 'p': + if (strncasecmp (s, ",l,push", 7) != 0) + break; + s += 7; + continue; + + /* Handle a branch link completer. */ + case 'l': + if (strncasecmp (s, ",l", 2) != 0) + break; + s += 2; + continue; + + /* Handle a branch pop completer. */ + case 'P': + if (strncasecmp (s, ",pop", 4) != 0) + break; + s += 4; + continue; + + /* Handle a local processor completer. */ + case 'L': + if (strncasecmp (s, ",l", 2) != 0) + break; + s += 2; + continue; + + /* Handle a PROBE read/write completer. */ + case 'w': + flag = 0; + if (!strncasecmp (s, ",w", 2)) { - cmpltr = 4; flag = 1; + s += 2; } - else if (strcasecmp (name, ">>") == 0) + else if (!strncasecmp (s, ",r", 2)) { - cmpltr = 5; - flag = 1; + flag = 0; + s += 2; } - else if (strcasecmp (name, "nsv") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); + + /* Handle MFCTL wide completer. */ + case 'W': + if (strncasecmp (s, ",w", 2) != 0) + break; + s += 2; + continue; + + /* Handle an RFI restore completer. */ + case 'r': + flag = 0; + if (!strncasecmp (s, ",r", 2)) { - cmpltr = 6; - flag = 1; + flag = 5; + s += 2; } - else if (strcasecmp (name, "ev") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 5); + + /* Handle a system control completer. */ + case 'Z': + if (*s == ',' && (*(s + 1) == 'm' || *(s + 1) == 'M')) { - cmpltr = 7; flag = 1; + s += 2; } else - as_bad (_("Invalid Add Condition: %s"), name); - *s = c; - } - opcode |= cmpltr << 13; - INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + flag = 0; - /* Handle a non-negated add condition. */ - case 'd': - cmpltr = 0; - flag = 0; - if (*s == ',') - { - s++; - name = s; - while (*s != ',' && *s != ' ' && *s != '\t') - s += 1; - c = *s; - *s = 0x00; - if (strcmp (name, "=") == 0) - cmpltr = 1; - else if (strcmp (name, "<") == 0) - cmpltr = 2; - else if (strcmp (name, "<=") == 0) - cmpltr = 3; - else if (strcasecmp (name, "nuv") == 0) - cmpltr = 4; - else if (strcasecmp (name, "znv") == 0) - cmpltr = 5; - else if (strcasecmp (name, "sv") == 0) - cmpltr = 6; - else if (strcasecmp (name, "od") == 0) - cmpltr = 7; - else if (strcasecmp (name, "tr") == 0) - { - cmpltr = 0; - flag = 1; - } - else if (strcmp (name, "<>") == 0) - { - cmpltr = 1; - flag = 1; - } - else if (strcmp (name, ">=") == 0) + INSERT_FIELD_AND_CONTINUE (opcode, flag, 5); + + /* Handle intermediate/final completer for DCOR. */ + case 'i': + flag = 0; + if (!strncasecmp (s, ",i", 2)) { - cmpltr = 2; flag = 1; + s += 2; } - else if (strcmp (name, ">") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); + + /* Handle zero/sign extension completer. */ + case 'z': + flag = 1; + if (!strncasecmp (s, ",z", 2)) { - cmpltr = 3; - flag = 1; + flag = 0; + s += 2; } - else if (strcasecmp (name, "uv") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 10); + + /* Handle add completer. */ + case 'a': + flag = 1; + if (!strncasecmp (s, ",l", 2)) { - cmpltr = 4; - flag = 1; + flag = 2; + s += 2; } - else if (strcasecmp (name, "vnz") == 0) + else if (!strncasecmp (s, ",tsv", 4)) { - cmpltr = 5; - flag = 1; + flag = 3; + s += 4; } - else if (strcasecmp (name, "nsv") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 10); + + /* Handle 64 bit carry for ADD. */ + case 'Y': + flag = 0; + if (!strncasecmp (s, ",dc,tsv", 7) || + !strncasecmp (s, ",tsv,dc", 7)) { - cmpltr = 6; flag = 1; + s += 7; } - else if (strcasecmp (name, "ev") == 0) + else if (!strncasecmp (s, ",dc", 3)) { - cmpltr = 7; - flag = 1; + flag = 0; + s += 3; } else - as_bad (_("Invalid Add Condition: %s"), name); - *s = c; - } - opcode |= cmpltr << 13; - INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + break; - /* HANDLE a logical instruction condition. */ - case '&': - cmpltr = 0; - flag = 0; - if (*s == ',') - { - s++; - name = s; - while (*s != ',' && *s != ' ' && *s != '\t') - s += 1; - c = *s; - *s = 0x00; - - - if (strcmp (name, "=") == 0) - cmpltr = 1; - else if (strcmp (name, "<") == 0) - cmpltr = 2; - else if (strcmp (name, "<=") == 0) - cmpltr = 3; - else if (strcasecmp (name, "od") == 0) - cmpltr = 7; - else if (strcasecmp (name, "tr") == 0) + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle 32 bit carry for ADD. */ + case 'y': + flag = 0; + if (!strncasecmp (s, ",c,tsv", 6) || + !strncasecmp (s, ",tsv,c", 6)) { - cmpltr = 0; flag = 1; + s += 6; } - else if (strcmp (name, "<>") == 0) + else if (!strncasecmp (s, ",c", 2)) { - cmpltr = 1; - flag = 1; + flag = 0; + s += 2; } - else if (strcmp (name, ">=") == 0) + else + break; + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle trap on signed overflow. */ + case 'v': + flag = 0; + if (!strncasecmp (s, ",tsv", 4)) { - cmpltr = 2; flag = 1; + s += 4; } - else if (strcmp (name, ">") == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle trap on condition and overflow. */ + case 't': + flag = 0; + if (!strncasecmp (s, ",tc,tsv", 7) || + !strncasecmp (s, ",tsv,tc", 7)) { - cmpltr = 3; flag = 1; + s += 7; } - else if (strcasecmp (name, "ev") == 0) + else if (!strncasecmp (s, ",tc", 3)) { - cmpltr = 7; - flag = 1; + flag = 0; + s += 3; } else - as_bad (_("Invalid Logical Instruction Condition.")); - *s = c; - } - opcode |= cmpltr << 13; - INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + break; - /* Handle a unit instruction condition. */ - case 'U': - cmpltr = 0; - flag = 0; - if (*s == ',') - { - s++; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); - - if (strncasecmp (s, "sbz", 3) == 0) + /* Handle 64 bit borrow for SUB. */ + case 'B': + flag = 0; + if (!strncasecmp (s, ",db,tsv", 7) || + !strncasecmp (s, ",tsv,db", 7)) { - cmpltr = 2; - s += 3; - } - else if (strncasecmp (s, "shz", 3) == 0) - { - cmpltr = 3; - s += 3; - } - else if (strncasecmp (s, "sdc", 3) == 0) - { - cmpltr = 4; - s += 3; - } - else if (strncasecmp (s, "sbc", 3) == 0) - { - cmpltr = 6; - s += 3; - } - else if (strncasecmp (s, "shc", 3) == 0) - { - cmpltr = 7; - s += 3; - } - else if (strncasecmp (s, "tr", 2) == 0) - { - cmpltr = 0; flag = 1; - s += 2; + s += 7; } - else if (strncasecmp (s, "nbz", 3) == 0) + else if (!strncasecmp (s, ",db", 3)) { - cmpltr = 2; - flag = 1; + flag = 0; s += 3; } - else if (strncasecmp (s, "nhz", 3) == 0) + else + break; + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle 32 bit borrow for SUB. */ + case 'b': + flag = 0; + if (!strncasecmp (s, ",b,tsv", 6) || + !strncasecmp (s, ",tsv,b", 6)) { - cmpltr = 3; flag = 1; - s += 3; + s += 6; } - else if (strncasecmp (s, "ndc", 3) == 0) + else if (!strncasecmp (s, ",b", 2)) { - cmpltr = 4; - flag = 1; - s += 3; + flag = 0; + s += 2; } - else if (strncasecmp (s, "nbc", 3) == 0) + else + break; + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle trap condition completer for UADDCM. */ + case 'T': + flag = 0; + if (!strncasecmp (s, ",tc", 3)) { - cmpltr = 6; flag = 1; s += 3; } - else if (strncasecmp (s, "nhc", 3) == 0) + + INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); + + /* Handle signed/unsigned at 21. */ + case 'S': + { + int sign = 1; + if (strncasecmp (s, ",s", 2) == 0) + { + sign = 1; + s += 2; + } + else if (strncasecmp (s, ",u", 2) == 0) + { + sign = 0; + s += 2; + } + + INSERT_FIELD_AND_CONTINUE (opcode, sign, 10); + } + + /* Handle left/right combination at 17:18. */ + case 'h': + if (*s++ == ',') { - cmpltr = 7; - flag = 1; - s += 3; + int lr = 0; + if (*s == 'r') + lr = 2; + else if (*s == 'l') + lr = 0; + else + as_bad(_("Invalid left/right combination completer")); + + s++; + INSERT_FIELD_AND_CONTINUE (opcode, lr, 13); } else - as_bad (_("Invalid Logical Instruction Condition.")); - } - opcode |= cmpltr << 13; - INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + as_bad(_("Invalid left/right combination completer")); + break; - /* Handle a shift/extract/deposit condition. */ - case '|': - case '>': - cmpltr = 0; - if (*s == ',') - { - save_s = s++; - - - name = s; - while (*s != ',' && *s != ' ' && *s != '\t') - s += 1; - c = *s; - *s = 0x00; - if (strcmp (name, "=") == 0) - cmpltr = 1; - else if (strcmp (name, "<") == 0) - cmpltr = 2; - else if (strcasecmp (name, "od") == 0) - cmpltr = 3; - else if (strcasecmp (name, "tr") == 0) - cmpltr = 4; - else if (strcmp (name, "<>") == 0) - cmpltr = 5; - else if (strcmp (name, ">=") == 0) - cmpltr = 6; - else if (strcasecmp (name, "ev") == 0) - cmpltr = 7; - /* Handle movb,n. Put things back the way they were. - This includes moving s back to where it started. */ - else if (strcasecmp (name, "n") == 0 && *args == '|') + /* Handle saturation at 24:25. */ + case 'H': + { + int sat = 3; + if (strncasecmp (s, ",ss", 3) == 0) + { + sat = 1; + s += 3; + } + else if (strncasecmp (s, ",us", 3) == 0) + { + sat = 0; + s += 3; + } + + INSERT_FIELD_AND_CONTINUE (opcode, sat, 6); + } + + /* Handle permutation completer. */ + case '*': + if (*s++ == ',') { - *s = c; - s = save_s; + int permloc[4]; + int perm = 0; + int i = 0; + permloc[0] = 13; + permloc[1] = 10; + permloc[2] = 8; + permloc[3] = 6; + for (; i < 4; i++) + { + switch (*s++) + { + case '0': + perm = 0; + break; + case '1': + perm = 1; + break; + case '2': + perm = 2; + break; + case '3': + perm = 3; + break; + default: + as_bad(_("Invalid permutation completer")); + } + opcode |= perm << permloc[i]; + } continue; } else - as_bad (_("Invalid Shift/Extract/Deposit Condition.")); - *s = c; - } - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + as_bad(_("Invalid permutation completer")); + break; - /* Handle bvb and bb conditions. */ - case '~': - cmpltr = 0; - if (*s == ',') - { - s++; - if (strncmp (s, "<", 1) == 0) - { - cmpltr = 0; - s++; - } - else if (strncmp (s, ">=", 2) == 0) - { - cmpltr = 1; - s += 2; - } - else - as_bad (_("Invalid Bit Branch Condition: %c"), *s); + default: + abort (); } - INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 15); + break; - /* Handle a system control completer. */ - case 'Z': - if (*s == ',' && (*(s + 1) == 'm' || *(s + 1) == 'M')) - { - flag = 1; - s += 2; - } - else - flag = 0; + /* Handle all conditions. */ + case '?': + { + args++; + switch (*args) + { + /* Handle FP compare conditions. */ + case 'f': + cond = pa_parse_fp_cmp_cond (&s); + INSERT_FIELD_AND_CONTINUE (opcode, cond, 0); + + /* Handle an add condition. */ + case 'A': + case 'a': + cmpltr = 0; + flag = 0; + if (*s == ',') + { + s++; + + /* 64 bit conditions. */ + if (*args == 'A') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + name = s; + + name = s; + while (*s != ',' && *s != ' ' && *s != '\t') + s += 1; + c = *s; + *s = 0x00; + if (strcmp (name, "=") == 0) + cmpltr = 1; + else if (strcmp (name, "<") == 0) + cmpltr = 2; + else if (strcmp (name, "<=") == 0) + cmpltr = 3; + else if (strcasecmp (name, "nuv") == 0) + cmpltr = 4; + else if (strcasecmp (name, "znv") == 0) + cmpltr = 5; + else if (strcasecmp (name, "sv") == 0) + cmpltr = 6; + else if (strcasecmp (name, "od") == 0) + cmpltr = 7; + else if (strcasecmp (name, "tr") == 0) + { + cmpltr = 0; + flag = 1; + } + else if (strcmp (name, "<>") == 0) + { + cmpltr = 1; + flag = 1; + } + else if (strcmp (name, ">=") == 0) + { + cmpltr = 2; + flag = 1; + } + else if (strcmp (name, ">") == 0) + { + cmpltr = 3; + flag = 1; + } + else if (strcasecmp (name, "uv") == 0) + { + cmpltr = 4; + flag = 1; + } + else if (strcasecmp (name, "vnz") == 0) + { + cmpltr = 5; + flag = 1; + } + else if (strcasecmp (name, "nsv") == 0) + { + cmpltr = 6; + flag = 1; + } + else if (strcasecmp (name, "ev") == 0) + { + cmpltr = 7; + flag = 1; + } + /* ",*" is a valid condition. */ + else if (*args == 'a') + as_bad (_("Invalid Add Condition: %s"), name); + *s = c; + } + opcode |= cmpltr << 13; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + + /* Handle non-negated add and branch condition. */ + case 'd': + cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1); + if (cmpltr < 0) + { + as_bad (_("Invalid Add and Branch Condition: %c"), *s); + cmpltr = 0; + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle 64 bit wide-mode add and branch condition. */ + case 'W': + cmpltr = pa_parse_addb_64_cmpltr (&s); + if (cmpltr < 0) + { + as_bad (_("Invalid Add and Branch Condition: %c"), *s); + cmpltr = 0; + } + else + { + /* Negated condition requires an opcode change. */ + opcode |= (cmpltr & 8) << 24; + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr & 7, 13); + + /* Handle a negated or non-negated add and branch + condition. */ + case '@': + save_s = s; + cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1); + if (cmpltr < 0) + { + s = save_s; + cmpltr = pa_parse_neg_add_cmpltr (&s, 1); + if (cmpltr < 0) + { + as_bad (_("Invalid Compare/Subtract Condition")); + cmpltr = 0; + } + else + { + /* Negated condition requires an opcode change. */ + opcode |= 1 << 27; + } + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle branch on bit conditions. */ + case 'B': + case 'b': + cmpltr = 0; + if (*s == ',') + { + s++; + + if (*args == 'B') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + + if (strncmp (s, "<", 1) == 0) + { + cmpltr = 0; + s++; + } + else if (strncmp (s, ">=", 2) == 0) + { + cmpltr = 1; + s += 2; + } + else + as_bad (_("Invalid Bit Branch Condition: %c"), *s); + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 15); + + /* Handle a compare/subtract condition. */ + case 'S': + case 's': + cmpltr = 0; + flag = 0; + if (*s == ',') + { + s++; + + /* 64 bit conditions. */ + if (*args == 'S') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + name = s; + + name = s; + while (*s != ',' && *s != ' ' && *s != '\t') + s += 1; + c = *s; + *s = 0x00; + if (strcmp (name, "=") == 0) + cmpltr = 1; + else if (strcmp (name, "<") == 0) + cmpltr = 2; + else if (strcmp (name, "<=") == 0) + cmpltr = 3; + else if (strcasecmp (name, "<<") == 0) + cmpltr = 4; + else if (strcasecmp (name, "<<=") == 0) + cmpltr = 5; + else if (strcasecmp (name, "sv") == 0) + cmpltr = 6; + else if (strcasecmp (name, "od") == 0) + cmpltr = 7; + else if (strcasecmp (name, "tr") == 0) + { + cmpltr = 0; + flag = 1; + } + else if (strcmp (name, "<>") == 0) + { + cmpltr = 1; + flag = 1; + } + else if (strcmp (name, ">=") == 0) + { + cmpltr = 2; + flag = 1; + } + else if (strcmp (name, ">") == 0) + { + cmpltr = 3; + flag = 1; + } + else if (strcasecmp (name, ">>=") == 0) + { + cmpltr = 4; + flag = 1; + } + else if (strcasecmp (name, ">>") == 0) + { + cmpltr = 5; + flag = 1; + } + else if (strcasecmp (name, "nsv") == 0) + { + cmpltr = 6; + flag = 1; + } + else if (strcasecmp (name, "ev") == 0) + { + cmpltr = 7; + flag = 1; + } + /* ",*" is a valid condition. */ + else if (*args != 'S') + as_bad (_("Invalid Compare/Subtract Condition: %s"), + name); + *s = c; + } + opcode |= cmpltr << 13; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + + /* Handle a non-negated compare condition. */ + case 't': + cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1); + if (cmpltr < 0) + { + as_bad (_("Invalid Compare/Subtract Condition: %c"), *s); + cmpltr = 0; + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle a 32 bit compare and branch condition. */ + case 'n': + save_s = s; + cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1); + if (cmpltr < 0) + { + s = save_s; + cmpltr = pa_parse_neg_cmpsub_cmpltr (&s, 1); + if (cmpltr < 0) + { + as_bad (_("Invalid Compare and Branch Condition.")); + cmpltr = 0; + } + else + { + /* Negated condition requires an opcode change. */ + opcode |= 1 << 27; + } + } + + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle a 64 bit compare and branch condition. */ + case 'N': + cmpltr = pa_parse_cmpb_64_cmpltr (&s); + if (cmpltr >= 0) + { + /* Negated condition requires an opcode change. */ + opcode |= (cmpltr & 8) << 26; + } + else + /* Not a 64 bit cond. Give 32 bit a chance. */ + break; + + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr & 7, 13); + + /* Handle a 64 bit cmpib condition. */ + case 'Q': + cmpltr = pa_parse_cmpib_64_cmpltr (&s); + if (cmpltr < 0) + /* Not a 64 bit cond. Give 32 bit a chance. */ + break; + + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle a logical instruction condition. */ + case 'L': + case 'l': + cmpltr = 0; + flag = 0; + if (*s == ',') + { + s++; - INSERT_FIELD_AND_CONTINUE (opcode, flag, 5); + /* 64 bit conditions. */ + if (*args == 'L') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + name = s; + + name = s; + while (*s != ',' && *s != ' ' && *s != '\t') + s += 1; + c = *s; + *s = 0x00; + + + if (strcmp (name, "=") == 0) + cmpltr = 1; + else if (strcmp (name, "<") == 0) + cmpltr = 2; + else if (strcmp (name, "<=") == 0) + cmpltr = 3; + else if (strcasecmp (name, "od") == 0) + cmpltr = 7; + else if (strcasecmp (name, "tr") == 0) + { + cmpltr = 0; + flag = 1; + } + else if (strcmp (name, "<>") == 0) + { + cmpltr = 1; + flag = 1; + } + else if (strcmp (name, ">=") == 0) + { + cmpltr = 2; + flag = 1; + } + else if (strcmp (name, ">") == 0) + { + cmpltr = 3; + flag = 1; + } + else if (strcasecmp (name, "ev") == 0) + { + cmpltr = 7; + flag = 1; + } + /* ",*" is a valid condition. */ + else if (*args != 'L') + as_bad (_("Invalid Logical Instruction Condition.")); + *s = c; + } + opcode |= cmpltr << 13; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + + /* Handle a shift/extract/deposit condition. */ + case 'X': + case 'x': + case 'y': + cmpltr = 0; + if (*s == ',') + { + save_s = s++; + + /* 64 bit conditions. */ + if (*args == 'X') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + name = s; + + name = s; + while (*s != ',' && *s != ' ' && *s != '\t') + s += 1; + c = *s; + *s = 0x00; + if (strcmp (name, "=") == 0) + cmpltr = 1; + else if (strcmp (name, "<") == 0) + cmpltr = 2; + else if (strcasecmp (name, "od") == 0) + cmpltr = 3; + else if (strcasecmp (name, "tr") == 0) + cmpltr = 4; + else if (strcmp (name, "<>") == 0) + cmpltr = 5; + else if (strcmp (name, ">=") == 0) + cmpltr = 6; + else if (strcasecmp (name, "ev") == 0) + cmpltr = 7; + /* Handle movb,n. Put things back the way they were. + This includes moving s back to where it started. */ + else if (strcasecmp (name, "n") == 0 && *args == 'y') + { + *s = c; + s = save_s; + continue; + } + /* ",*" is a valid condition. */ + else if (*args != 'X') + as_bad (_("Invalid Shift/Extract/Deposit Condition.")); + *s = c; + } + INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); + + /* Handle a unit instruction condition. */ + case 'U': + case 'u': + cmpltr = 0; + flag = 0; + if (*s == ',') + { + s++; + + /* 64 bit conditions. */ + if (*args == 'U') + { + if (*s == '*') + s++; + else + break; + } + else if (*s == '*') + break; + + if (strncasecmp (s, "sbz", 3) == 0) + { + cmpltr = 2; + s += 3; + } + else if (strncasecmp (s, "shz", 3) == 0) + { + cmpltr = 3; + s += 3; + } + else if (strncasecmp (s, "sdc", 3) == 0) + { + cmpltr = 4; + s += 3; + } + else if (strncasecmp (s, "sbc", 3) == 0) + { + cmpltr = 6; + s += 3; + } + else if (strncasecmp (s, "shc", 3) == 0) + { + cmpltr = 7; + s += 3; + } + else if (strncasecmp (s, "tr", 2) == 0) + { + cmpltr = 0; + flag = 1; + s += 2; + } + else if (strncasecmp (s, "nbz", 3) == 0) + { + cmpltr = 2; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "nhz", 3) == 0) + { + cmpltr = 3; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "ndc", 3) == 0) + { + cmpltr = 4; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "nbc", 3) == 0) + { + cmpltr = 6; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "nhc", 3) == 0) + { + cmpltr = 7; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "swz", 3) == 0) + { + cmpltr = 1; + flag = 0; + s += 3; + } + else if (strncasecmp (s, "swc", 3) == 0) + { + cmpltr = 5; + flag = 0; + s += 3; + } + else if (strncasecmp (s, "nwz", 3) == 0) + { + cmpltr = 1; + flag = 1; + s += 3; + } + else if (strncasecmp (s, "nwc", 3) == 0) + { + cmpltr = 5; + flag = 1; + s += 3; + } + /* ",*" is a valid condition. */ + else if (*args != 'U') + as_bad (_("Invalid Unit Instruction Condition.")); + } + opcode |= cmpltr << 13; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); + + default: + abort (); + } + break; + } /* Handle a nullification completer for branch instructions. */ case 'n': @@ -2111,6 +2841,52 @@ pa_ip (str) nullif = pa_parse_nullif (&s); INSERT_FIELD_AND_CONTINUE (opcode, nullif, 5); + /* Handle ,%r2 completer for new syntax branches. */ + case 'L': + if (*s == ',' && strncasecmp (s + 1, "%r2", 3) == 0) + s += 4; + else if (*s == ',' && strncasecmp (s + 1, "%rp", 3) == 0) + s += 4; + else + break; + continue; + + /* Handle 3 bit entry into the fp compare array. Valid values + are 0..6 inclusive. */ + case 'h': + get_expression (s); + s = expr_end; + if (the_insn.exp.X_op == O_constant) + { + num = evaluate_absolute (&the_insn); + CHECK_FIELD (num, 6, 0, 0); + num++; + INSERT_FIELD_AND_CONTINUE (opcode, num, 13); + } + else + break; + + /* Handle 3 bit entry into the fp compare array. Valid values + are 0..6 inclusive. */ + case 'm': + get_expression (s); + if (the_insn.exp.X_op == O_constant) + { + s = expr_end; + num = evaluate_absolute (&the_insn); + CHECK_FIELD (num, 6, 0, 0); + num = (num + 1) ^ 1; + INSERT_FIELD_AND_CONTINUE (opcode, num, 13); + } + else + break; + + /* Handle graphics test completers for ftest */ + case '=': + { + num = pa_parse_ftest_gfx_completer (&s); + INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + } /* Handle a 11 bit immediate at 31. */ case 'i': @@ -2136,6 +2912,125 @@ pa_ip (str) continue; } + /* Handle a 14 bit immediate at 31. */ + case 'J': + the_insn.field_selector = pa_chk_field_selector (&s); + get_expression (s); + s = expr_end; + if (the_insn.exp.X_op == O_constant) + { + int a, m; + + /* XXX the completer stored away tibits of information + for us to extract. We need a cleaner way to do this. + Now that we have lots of letters again, it would be + good to rethink this. */ + m = (opcode & (1 << 8)) != 0; + a = (opcode & (1 << 9)) != 0; + opcode &= ~ (3 << 8); + num = evaluate_absolute (&the_insn); + if ((a == 1 && num >= 0) || (a == 0 && num < 0)) + break; + CHECK_FIELD (num, 8191, -8192, 0); + low_sign_unext (num, 14, &num); + INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + } + else + { + break; + } + + /* Handle a 14 bit immediate at 31. */ + case 'K': + the_insn.field_selector = pa_chk_field_selector (&s); + get_expression (s); + s = expr_end; + if (the_insn.exp.X_op == O_constant) + { + int a, m; + + /* XXX the completer stored away tibits of information + for us to extract. We need a cleaner way to do this. + Now that we have lots of letters again, it would be + good to rethink this. */ + m = (opcode & (1 << 8)) != 0; + a = (opcode & (1 << 9)) != 0; + opcode &= ~ (3 << 8); + num = evaluate_absolute (&the_insn); + if ((a == 1 && num < 0) || (a == 0 && num > 0)) + break; + if (num % 4) + break; + CHECK_FIELD (num, 8191, -8192, 0); + if (num < 0) + opcode |= 1; + num &= 0x1fff; + num >>= 2; + INSERT_FIELD_AND_CONTINUE (opcode, num, 3); + } + else + { + break; + } + + /* Handle 14 bit immediated, shifted left three times. */ + case '#': + the_insn.field_selector = pa_chk_field_selector (&s); + get_expression (s); + s = expr_end; + if (the_insn.exp.X_op == O_constant) + { + num = evaluate_absolute (&the_insn); + if (num & 0x7) + break; + CHECK_FIELD (num, 8191, -8192, 0); + if (num < 0) + opcode |= 1; + num &= 0x1fff; + num >>= 3; + INSERT_FIELD_AND_CONTINUE (opcode, num, 4); + } + else + { + if (is_DP_relative (the_insn.exp)) + the_insn.reloc = R_HPPA_GOTOFF; + else if (is_PC_relative (the_insn.exp)) + the_insn.reloc = R_HPPA_PCREL_CALL; + else + the_insn.reloc = R_HPPA; + the_insn.format = 14; + continue; + } + break; + + /* Handle 14 bit immediate, shifted left twice. */ + case 'd': + the_insn.field_selector = pa_chk_field_selector (&s); + get_expression (s); + s = expr_end; + if (the_insn.exp.X_op == O_constant) + { + num = evaluate_absolute (&the_insn); + if (num & 0x3) + break; + CHECK_FIELD (num, 8191, -8192, 0); + if (num < 0) + opcode |= 1; + num &= 0x1fff; + num >>= 2; + INSERT_FIELD_AND_CONTINUE (opcode, num, 3); + } + else + { + if (is_DP_relative (the_insn.exp)) + the_insn.reloc = R_HPPA_GOTOFF; + else if (is_PC_relative (the_insn.exp)) + the_insn.reloc = R_HPPA_PCREL_CALL; + else + the_insn.reloc = R_HPPA; + the_insn.format = 14; + continue; + } /* Handle a 14 bit immediate at 31. */ case 'j': @@ -2253,6 +3148,45 @@ pa_ip (str) continue; } + /* Handle a 22 bit branch displacement. */ + case 'X': + the_insn.field_selector = pa_chk_field_selector (&s); + get_expression (s); + s = expr_end; + the_insn.pcrel = 1; + if (!the_insn.exp.X_add_symbol + || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), + "L$0\001")) + { + unsigned int w3, w2, w1, w, result; + + num = evaluate_absolute (&the_insn); + if (num % 4) + { + as_bad (_("Branch to unaligned address")); + break; + } + CHECK_FIELD (num, 8388607, -8388608, 0); + + if (the_insn.exp.X_add_symbol) + num -= 8; + + sign_unext (num >> 2, 22, &result); + dis_assemble_22 (result, &w3, &w1, &w2, &w); + INSERT_FIELD_AND_CONTINUE (opcode, + ((w3 << 21) | (w2 << 2) + | (w1 << 16) | w), + 0); + } + else + { + the_insn.reloc = R_HPPA_PCREL_CALL; + the_insn.format = 22; + the_insn.arg_reloc = last_call_desc.arg_reloc; + memset (&last_call_desc, 0, sizeof (struct call_desc)); + continue; + } + /* Handle an absolute 17 bit branch target. */ case 'z': the_insn.field_selector = pa_chk_field_selector (&s); @@ -2290,81 +3224,212 @@ pa_ip (str) continue; } + /* Handle '%r1' implicit operand of addil instruction. */ + case 'Z': + if (*s == ',' && *(s + 1) == '%' && *(s + 3) == '1' + && (*(s + 2) == 'r' || *(s + 2) == 'R')) + { + s += 4; + continue; + } + else + break; + + /* Handle '%sr0,%r31' implicit operand of be,l instruction. */ + case 'Y': + if (strncasecmp (s, "%sr0,%r31", 9) != 0) + break; + s += 9; + continue; + + /* Handle immediate value of 0 for ordered load/store instructions. */ + case '@': + if (*s != '0') + break; + s++; + continue; + + /* Handle a 2 bit shift count at 25. */ + case '.': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 3, 1, strict); + INSERT_FIELD_AND_CONTINUE (opcode, num, 6); + + /* Handle a 4 bit shift count at 25. */ + case '*': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 15, 0, strict); + INSERT_FIELD_AND_CONTINUE (opcode, num, 6); + /* Handle a 5 bit shift count at 26. */ case 'p': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 31, 0, 0); + CHECK_FIELD (num, 31, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5); + /* Handle a 6 bit shift count at 20,22:26. */ + case '~': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 63, 0, strict); + num = 63 - num; + opcode |= (num & 0x20) << 6; + INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 5); + + /* Handle a 6 bit field length at 23,27:31. */ + case '%': + flag = 0; + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 64, 1, strict); + num--; + opcode |= (num & 0x20) << 3; + num = 31 - (num & 0x1f); + INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + + /* Handle a 6 bit field length at 19,27:31. */ + case '|': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 64, 1, strict); + num--; + opcode |= (num & 0x20) << 7; + num = 31 - (num & 0x1f); + INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + /* Handle a 5 bit bit position at 26. */ case 'P': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 31, 0, 0); + CHECK_FIELD (num, 31, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 5); + /* Handle a 6 bit bit position at 20,22:26. */ + case 'q': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 63, 0, strict); + opcode |= (num & 0x20) << 6; + INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 5); + + /* Handle a 5 bit immediate at 10 with 'd' as the complement + of the high bit of the immediate. */ + case 'B': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 63, 0, strict); + if (num & 0x20) + ; + else + opcode |= (1 << 13); + INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 21); + /* Handle a 5 bit immediate at 10. */ case 'Q': - num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; if (the_insn.exp.X_op != O_constant) break; s = expr_end; - CHECK_FIELD (num, 31, 0, 0); - INSERT_FIELD_AND_CONTINUE (opcode, num, 21); + CHECK_FIELD (num, 31, 0, strict); + INSERT_FIELD_AND_CONTINUE (opcode, num, 21); + + /* Handle a 9 bit immediate at 28. */ + case '$': + num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; + s = expr_end; + CHECK_FIELD (num, 511, 1, strict); + INSERT_FIELD_AND_CONTINUE (opcode, num, 3); /* Handle a 13 bit immediate at 18. */ case 'A': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 8191, 0, 0); + CHECK_FIELD (num, 8191, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 13); /* Handle a 26 bit immediate at 31. */ case 'D': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 671108864, 0, 0); + CHECK_FIELD (num, 671108864, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); /* Handle a 3 bit SFU identifier at 25. */ - case 'f': + case 'v': if (*s++ != ',') as_bad (_("Invalid SFU identifier")); num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 7, 0, 0); + CHECK_FIELD (num, 7, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 6); /* Handle a 20 bit SOP field for spop0. */ case 'O': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 1048575, 0, 0); + CHECK_FIELD (num, 1048575, 0, strict); num = (num & 0x1f) | ((num & 0x000fffe0) << 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); /* Handle a 15bit SOP field for spop1. */ case 'o': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 32767, 0, 0); + CHECK_FIELD (num, 32767, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 11); /* Handle a 10bit SOP field for spop3. */ case '0': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 1023, 0, 0); + CHECK_FIELD (num, 1023, 0, strict); num = (num & 0x1f) | ((num & 0x000003e0) << 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); /* Handle a 15 bit SOP field for spop2. */ case '1': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 32767, 0, 0); + CHECK_FIELD (num, 32767, 0, strict); num = (num & 0x1f) | ((num & 0x00007fe0) << 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); @@ -2373,18 +3438,97 @@ pa_ip (str) if (*s++ != ',') as_bad (_("Invalid COPR identifier")); num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 7, 0, 0); + CHECK_FIELD (num, 7, 0, strict); INSERT_FIELD_AND_CONTINUE (opcode, num, 6); /* Handle a 22bit SOP field for copr. */ case '2': num = pa_get_absolute_expression (&the_insn, &s); + if (strict && the_insn.exp.X_op != O_constant) + break; s = expr_end; - CHECK_FIELD (num, 4194303, 0, 0); + CHECK_FIELD (num, 4194303, 0, strict); num = (num & 0x1f) | ((num & 0x003fffe0) << 4); INSERT_FIELD_AND_CONTINUE (opcode, num, 0); + /* Handle a source FP operand format completer. */ + case '{': + if (*s == ',' && *(s+1) == 't') + { + the_insn.trunc = 1; + s += 2; + } + else + the_insn.trunc = 0; + flag = pa_parse_fp_cnv_format (&s); + the_insn.fpof1 = flag; + if (flag == W || flag == UW) + flag = SGL; + if (flag == DW || flag == UDW) + flag = DBL; + if (flag == QW || flag == UQW) + flag = QUAD; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); + + /* Handle a destination FP operand format completer. */ + case '_': + /* pa_parse_format needs the ',' prefix. */ + s--; + flag = pa_parse_fp_cnv_format (&s); + the_insn.fpof2 = flag; + if (flag == W || flag == UW) + flag = SGL; + if (flag == DW || flag == UDW) + flag = DBL; + if (flag == QW || flag == UQW) + flag = QUAD; + opcode |= flag << 13; + if (the_insn.fpof1 == SGL + || the_insn.fpof1 == DBL + || the_insn.fpof1 == QUAD) + { + if (the_insn.fpof2 == SGL + || the_insn.fpof2 == DBL + || the_insn.fpof2 == QUAD) + flag = 0; + else if (the_insn.fpof2 == W + || the_insn.fpof2 == DW + || the_insn.fpof2 == QW) + flag = 2; + else if (the_insn.fpof2 == UW + || the_insn.fpof2 == UDW + || the_insn.fpof2 == UQW) + flag = 6; + else + abort (); + } + else if (the_insn.fpof1 == W + || the_insn.fpof1 == DW + || the_insn.fpof1 == QW) + { + if (the_insn.fpof2 == SGL + || the_insn.fpof2 == DBL + || the_insn.fpof2 == QUAD) + flag = 1; + else + abort (); + } + else if (the_insn.fpof1 == UW + || the_insn.fpof1 == UDW + || the_insn.fpof1 == UQW) + { + if (the_insn.fpof2 == SGL + || the_insn.fpof2 == DBL + || the_insn.fpof2 == QUAD) + flag = 5; + else + abort (); + } + flag |= the_insn.trunc; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 15); /* Handle a source FP operand format completer. */ case 'F': @@ -2400,208 +3544,285 @@ pa_ip (str) the_insn.fpof2 = flag; INSERT_FIELD_AND_CONTINUE (opcode, flag, 13); - /* Handle FP compare conditions. */ - case 'M': - cond = pa_parse_fp_cmp_cond (&s); - INSERT_FIELD_AND_CONTINUE (opcode, cond, 0); + /* Handle a source FP operand format completer at 20. */ + case 'I': + flag = pa_parse_fp_format (&s); + the_insn.fpof1 = flag; + INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); - /* Handle L/R register halves like 't'. */ - case 'v': - { - struct pa_11_fp_reg_struct result; + /* Handle a floating point operand format at 26. + Only allows single and double precision. */ + case 'H': + flag = pa_parse_fp_format (&s); + switch (flag) + { + case SGL: + opcode |= 0x20; + case DBL: + the_insn.fpof1 = flag; + continue; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - opcode |= result.number_part; + case QUAD: + case ILLEGAL_FMT: + default: + as_bad (_("Invalid Floating Point Operand Format.")); + } + break; - /* 0x30 opcodes are FP arithmetic operation opcodes - and need to be turned into 0x38 opcodes. This - is not necessary for loads/stores. */ - if (need_pa11_opcode (&the_insn, &result) - && ((opcode & 0xfc000000) == 0x30000000)) - opcode |= 1 << 27; + /* Handle all floating point registers. */ + case 'f': + switch (*++args) + { + /* Float target register. */ + case 't': + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + num = pa_parse_number (&s, 0); + CHECK_FIELD (num, 31, 0, 0); + INSERT_FIELD_AND_CONTINUE (opcode, num, 0); - INSERT_FIELD_AND_CONTINUE (opcode, result.l_r_select & 1, 6); - } + /* Float target register with L/R selection. */ + case 'T': + { + struct pa_11_fp_reg_struct result; - /* Handle L/R register halves like 'b'. */ - case 'E': - { - struct pa_11_fp_reg_struct result; + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= result.number_part; + + /* 0x30 opcodes are FP arithmetic operation opcodes + and need to be turned into 0x38 opcodes. This + is not necessary for loads/stores. */ + if (need_pa11_opcode (&the_insn, &result) + && ((opcode & 0xfc000000) == 0x30000000)) + opcode |= 1 << 27; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - opcode |= result.number_part << 21; - if (need_pa11_opcode (&the_insn, &result)) - { - opcode |= (result.l_r_select & 1) << 7; - opcode |= 1 << 27; + INSERT_FIELD_AND_CONTINUE (opcode, result.l_r_select & 1, 6); } - continue; - } - /* Handle L/R register halves like 'b'. */ - case '3': - { - struct pa_11_fp_reg_struct result; - int regnum; - - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - opcode |= (result.number_part & 0x1c) << 11; - opcode |= (result.number_part & 0x3) << 9; - opcode |= (result.l_r_select & 1) << 8; - continue; - } + /* Float operand 1. */ + case 'a': + { + struct pa_11_fp_reg_struct result; - /* Handle L/R register halves like 'x'. */ - case 'e': - { - struct pa_11_fp_reg_struct result; + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= result.number_part << 21; + if (need_pa11_opcode (&the_insn, &result)) + { + opcode |= (result.l_r_select & 1) << 7; + opcode |= 1 << 27; + } + continue; + } - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - opcode |= (result.number_part & 0x1f) << 16; - if (need_pa11_opcode (&the_insn, &result)) + /* Float operand 1 with L/R selection. */ + case 'X': + case 'A': { - opcode |= (result.l_r_select & 1) << 1; + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= result.number_part << 21; + opcode |= (result.l_r_select & 1) << 7; + continue; } - continue; - } - /* Handle L/R register halves like 'x'. */ - case 'X': - { - struct pa_11_fp_reg_struct result; + /* Float operand 2. */ + case 'b': + { + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= (result.number_part & 0x1f) << 16; + if (need_pa11_opcode (&the_insn, &result)) + { + opcode |= (result.l_r_select & 1) << 12; + opcode |= 1 << 27; + } + continue; + } - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - opcode |= (result.number_part & 0x1f) << 16; - if (need_pa11_opcode (&the_insn, &result)) + /* Float operand 2 with L/R selection. */ + case 'B': { + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= (result.number_part & 0x1f) << 16; opcode |= (result.l_r_select & 1) << 12; - opcode |= 1 << 27; + continue; } - continue; - } - /* Handle a 5 bit register field at 10. */ - case '4': - { - struct pa_11_fp_reg_struct result; + /* Float operand 3 for fmpyfadd, fmpynfadd. */ + case 'C': + { + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= (result.number_part & 0x1c) << 11; + opcode |= (result.number_part & 0x3) << 9; + opcode |= (result.l_r_select & 1) << 8; + continue; + } - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - if (the_insn.fpof1 == SGL) + /* Float mult operand 1 for fmpyadd, fmpysub */ + case 'i': { - if (result.number_part < 16) + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + if (the_insn.fpof1 == SGL) { - as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); - break; + if (result.number_part < 16) + { + as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); + break; + } + + result.number_part &= 0xF; + result.number_part |= (result.l_r_select & 1) << 4; } - - result.number_part &= 0xF; - result.number_part |= (result.l_r_select & 1) << 4; + INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 21); } - INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 21); - } - - /* Handle a 5 bit register field at 15. */ - case '6': - { - struct pa_11_fp_reg_struct result; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - if (the_insn.fpof1 == SGL) + /* Float mult operand 2 for fmpyadd, fmpysub */ + case 'j': { - if (result.number_part < 16) + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + if (the_insn.fpof1 == SGL) { - as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); - break; + if (result.number_part < 16) + { + as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); + break; + } + result.number_part &= 0xF; + result.number_part |= (result.l_r_select & 1) << 4; } - result.number_part &= 0xF; - result.number_part |= (result.l_r_select & 1) << 4; + INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 16); } - INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 16); - } - - /* Handle a 5 bit register field at 31. */ - case '7': - { - struct pa_11_fp_reg_struct result; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - if (the_insn.fpof1 == SGL) + /* Float mult target for fmpyadd, fmpysub */ + case 'k': { - if (result.number_part < 16) + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + if (the_insn.fpof1 == SGL) { - as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); - break; + if (result.number_part < 16) + { + as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); + break; + } + result.number_part &= 0xF; + result.number_part |= (result.l_r_select & 1) << 4; } - result.number_part &= 0xF; - result.number_part |= (result.l_r_select & 1) << 4; + INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 0); } - INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 0); - } - - /* Handle a 5 bit register field at 20. */ - case '8': - { - struct pa_11_fp_reg_struct result; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - if (the_insn.fpof1 == SGL) + /* Float add operand 1 for fmpyadd, fmpysub */ + case 'l': { - if (result.number_part < 16) + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + if (the_insn.fpof1 == SGL) { - as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); - break; + if (result.number_part < 16) + { + as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); + break; + } + result.number_part &= 0xF; + result.number_part |= (result.l_r_select & 1) << 4; } - result.number_part &= 0xF; - result.number_part |= (result.l_r_select & 1) << 4; + INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 6); } - INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 11); - } - - /* Handle a 5 bit register field at 25. */ - case '9': - { - struct pa_11_fp_reg_struct result; - pa_parse_number (&s, &result); - CHECK_FIELD (result.number_part, 31, 0, 0); - if (the_insn.fpof1 == SGL) + /* Float add target for fmpyadd, fmpysub */ + case 'm': { - if (result.number_part < 16) + struct pa_11_fp_reg_struct result; + + /* This should be more strict. Small steps. */ + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + if (the_insn.fpof1 == SGL) { - as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); - break; + if (result.number_part < 16) + { + as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); + break; + } + result.number_part &= 0xF; + result.number_part |= (result.l_r_select & 1) << 4; } - result.number_part &= 0xF; - result.number_part |= (result.l_r_select & 1) << 4; + INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 11); } - INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 6); - } - /* Handle a floating point operand format at 26. - Only allows single and double precision. */ - case 'H': - flag = pa_parse_fp_format (&s); - switch (flag) - { - case SGL: - opcode |= 0x20; - case DBL: - the_insn.fpof1 = flag; - continue; + /* Handle L/R register halves like 'x'. */ + case 'e': + { + struct pa_11_fp_reg_struct result; - case QUAD: - case ILLEGAL_FMT: + if (strict && *s != '%') + break; + pa_parse_number (&s, &result); + CHECK_FIELD (result.number_part, 31, 0, 0); + opcode |= (result.number_part & 0x1f) << 16; + if (need_pa11_opcode (&the_insn, &result)) + { + opcode |= (result.l_r_select & 1) << 1; + } + continue; + } default: - as_bad (_("Invalid Floating Point Operand Format.")); + abort (); } break; @@ -2730,13 +3951,14 @@ tc_gen_reloc (section, fixp) reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); codes = (bfd_reloc_code_real_type **) hppa_gen_reloc_type (stdoutput, fixp->fx_r_type, hppa_fixp->fx_r_format, hppa_fixp->fx_r_field, fixp->fx_subsy != NULL, - fixp->fx_addsy->bsym); + symbol_get_bfdsym (fixp->fx_addsy)); if (codes == NULL) abort (); @@ -2759,7 +3981,8 @@ tc_gen_reloc (section, fixp) code = *codes[0]; - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->howto = bfd_reloc_type_lookup (stdoutput, code); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->addend = 0; /* default */ @@ -2809,7 +4032,8 @@ tc_gen_reloc (section, fixp) { code = *codes[i]; - relocs[i]->sym_ptr_ptr = &fixp->fx_addsy->bsym; + relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); relocs[i]->howto = bfd_reloc_type_lookup (stdoutput, code); relocs[i]->address = fixp->fx_frag->fr_address + fixp->fx_where; @@ -2820,23 +4044,25 @@ tc_gen_reloc (section, fixp) of two symbols. With that in mind we fill in all four relocs now and break out of the loop. */ assert (i == 1); - relocs[0]->sym_ptr_ptr = (asymbol **) &bfd_abs_symbol; + relocs[0]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); relocs[0]->howto = bfd_reloc_type_lookup (stdoutput, *codes[0]); relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[0]->addend = 0; - relocs[1]->sym_ptr_ptr = &fixp->fx_addsy->bsym; + relocs[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); relocs[1]->howto = bfd_reloc_type_lookup (stdoutput, *codes[1]); relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[1]->addend = 0; - relocs[2]->sym_ptr_ptr = &fixp->fx_subsy->bsym; + relocs[2]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy); relocs[2]->howto = bfd_reloc_type_lookup (stdoutput, *codes[2]); relocs[2]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[2]->addend = 0; - relocs[3]->sym_ptr_ptr = (asymbol **) &bfd_abs_symbol; + relocs[3]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); relocs[3]->howto = bfd_reloc_type_lookup (stdoutput, *codes[3]); relocs[3]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[3]->addend = 0; - relocs[4]->sym_ptr_ptr = (asymbol **) &bfd_abs_symbol; + relocs[4]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); relocs[4]->howto = bfd_reloc_type_lookup (stdoutput, *codes[4]); relocs[4]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[4]->addend = 0; @@ -2874,7 +4100,8 @@ tc_gen_reloc (section, fixp) case R_N0SEL: case R_N1SEL: /* There is no symbol or addend associated with these fixups. */ - relocs[i]->sym_ptr_ptr = &dummy_symbol->bsym; + relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); relocs[i]->addend = 0; break; @@ -2882,7 +4109,8 @@ tc_gen_reloc (section, fixp) case R_ENTRY: case R_EXIT: /* There is no symbol associated with these fixups. */ - relocs[i]->sym_ptr_ptr = &dummy_symbol->bsym; + relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); relocs[i]->addend = fixp->fx_offset; break; @@ -3027,7 +4255,7 @@ md_apply_fix (fixP, valp) if (hppa_fixP) { unsigned long buf_wd = bfd_get_32 (stdoutput, buf); - unsigned char fmt = bfd_hppa_insn2fmt (buf_wd); + int fmt = bfd_hppa_insn2fmt (buf_wd); /* If there is a symbol associated with this fixup, then it's something which will need a SOM relocation (except for some PC-relative relocs). @@ -3039,7 +4267,7 @@ md_apply_fix (fixP, valp) && fmt != 32 #endif ) - new_val = ((fmt == 12 || fmt == 17) ? 8 : 0); + new_val = ((fmt == 12 || fmt == 17 || fmt == 22) ? 8 : 0); #ifdef OBJ_SOM /* These field selectors imply that we do not want an addend. */ else if (hppa_fixP->fx_r_field == e_psel @@ -3048,7 +4276,7 @@ md_apply_fix (fixP, valp) || hppa_fixP->fx_r_field == e_tsel || hppa_fixP->fx_r_field == e_rtsel || hppa_fixP->fx_r_field == e_ltsel) - new_val = ((fmt == 12 || fmt == 17) ? 8 : 0); + new_val = ((fmt == 12 || fmt == 17 || fmt == 22) ? 8 : 0); /* This is truely disgusting. The machine independent code blindly adds in the value of the symbol being relocated against. Damn! */ else if (fmt == 32 @@ -3063,20 +4291,22 @@ md_apply_fix (fixP, valp) /* Handle pc-relative exceptions from above. */ #define arg_reloc_stub_needed(CALLER, CALLEE) \ ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER))) - if ((fmt == 12 || fmt == 17) + if ((fmt == 12 || fmt == 17 || fmt == 22) && fixP->fx_addsy && fixP->fx_pcrel +#ifdef OBJ_SOM && !arg_reloc_stub_needed ((long) ((obj_symbol_type *) - fixP->fx_addsy->bsym)->tc_data.ap.hppa_arg_reloc, - hppa_fixP->fx_arg_reloc) - && ((int)(*valp) > -262144 && (int)(*valp) < 262143) + symbol_get_bfdsym (fixP->fx_addsy))->tc_data.ap.hppa_arg_reloc, + hppa_fixP->fx_arg_reloc) +#endif + && (((int)(*valp) > -262144 && (int)(*valp) < 262143) && fmt != 22) && S_GET_SEGMENT (fixP->fx_addsy) == hppa_fixP->segment && !(fixP->fx_subsy && S_GET_SEGMENT (fixP->fx_subsy) != hppa_fixP->segment)) - + new_val = hppa_field_adjust (*valp, 0, hppa_fixP->fx_r_field); #undef arg_reloc_stub_needed - + switch (fmt) { /* Handle all opcodes with the 'j' operand type. */ @@ -3153,6 +4383,29 @@ md_apply_fix (fixP, valp) break; } + case 22: + { + int distance = *valp, w3; + + CHECK_FIELD (new_val, 8388607, -8388608, 0); + + /* If this is an absolute branch (ie no link) with an out of + range target, then we want to complain. */ + if (fixP->fx_r_type == R_HPPA_PCREL_CALL + && (distance > 8388607 || distance < -8388608) + && (bfd_get_32 (stdoutput, buf) & 0xffe00000) == 0xe8000000) + CHECK_FIELD (distance, 8388607, -8388608, 0); + + /* Mask off 22 bits to be changed. */ + bfd_put_32 (stdoutput, + bfd_get_32 (stdoutput, buf) & 0xfc00e002, + buf); + sign_unext ((new_val - 8) >> 2, 22, &resulti); + dis_assemble_22 (resulti, &w3, &w1, &w2, &w); + result = ((w3 << 21) | (w2 << 2) | (w1 << 16) | w); + break; + } + case 32: result = 0; bfd_put_32 (stdoutput, new_val, buf); @@ -3483,31 +4736,151 @@ pa_parse_fp_cmp_cond (s) if (strncasecmp (*s, fp_cond_map[i].string, strlen (fp_cond_map[i].string)) == 0) { - cond = fp_cond_map[i].cond; - *s += strlen (fp_cond_map[i].string); - /* If not a complete match, back up the input string and - report an error. */ - if (**s != ' ' && **s != '\t') - { - *s -= strlen (fp_cond_map[i].string); - break; - } - while (**s == ' ' || **s == '\t') - *s = *s + 1; - return cond; + cond = fp_cond_map[i].cond; + *s += strlen (fp_cond_map[i].string); + /* If not a complete match, back up the input string and + report an error. */ + if (**s != ' ' && **s != '\t') + { + *s -= strlen (fp_cond_map[i].string); + break; + } + while (**s == ' ' || **s == '\t') + *s = *s + 1; + return cond; + } + } + + as_bad (_("Invalid FP Compare Condition: %s"), *s); + + /* Advance over the bogus completer. */ + while (**s != ',' && **s != ' ' && **s != '\t') + *s += 1; + + return 0; +} + +/* Parse a graphics test complete for ftest. */ + +static int +pa_parse_ftest_gfx_completer (s) + char **s; +{ + int value; + + value = 0; + if (strncasecmp (*s, "acc8", 4) == 0) + { + value = 5; + *s += 4; + } + else if (strncasecmp (*s, "acc6", 4) == 0) + { + value = 9; + *s += 4; + } + else if (strncasecmp (*s, "acc4", 4) == 0) + { + value = 13; + *s += 4; + } + else if (strncasecmp (*s, "acc2", 4) == 0) + { + value = 17; + *s += 4; + } + else if (strncasecmp (*s, "acc", 3) == 0) + { + value = 1; + *s += 3; + } + else if (strncasecmp (*s, "rej8", 4) == 0) + { + value = 6; + *s += 4; + } + else if (strncasecmp (*s, "rej", 3) == 0) + { + value = 2; + *s += 3; + } + else + { + value = 0; + as_bad (_("Invalid FTEST completer: %s"), *s); + } + + return value; +} + +/* Parse an FP operand format completer returning the completer + type. */ + +static fp_operand_format +pa_parse_fp_cnv_format (s) + char **s; +{ + int format; + + format = SGL; + if (**s == ',') + { + *s += 1; + if (strncasecmp (*s, "sgl", 3) == 0) + { + format = SGL; + *s += 4; + } + else if (strncasecmp (*s, "dbl", 3) == 0) + { + format = DBL; + *s += 4; + } + else if (strncasecmp (*s, "quad", 4) == 0) + { + format = QUAD; + *s += 5; + } + else if (strncasecmp (*s, "w", 1) == 0) + { + format = W; + *s += 2; + } + else if (strncasecmp (*s, "uw", 2) == 0) + { + format = UW; + *s += 3; + } + else if (strncasecmp (*s, "dw", 2) == 0) + { + format = DW; + *s += 3; + } + else if (strncasecmp (*s, "udw", 3) == 0) + { + format = UDW; + *s += 4; + } + else if (strncasecmp (*s, "qw", 2) == 0) + { + format = QW; + *s += 3; + } + else if (strncasecmp (*s, "uqw", 3) == 0) + { + format = UQW; + *s += 4; + } + else + { + format = ILLEGAL_FMT; + as_bad (_("Invalid FP Operand Format: %3s"), *s); } } - as_bad (_("Invalid FP Compare Condition: %s"), *s); - - /* Advance over the bogus completer. */ - while (**s != ',' && **s != ' ' && **s != '\t') - *s += 1; - - return 0; + return format; } - /* Parse an FP operand format completer returning the completer type. */ @@ -3568,13 +4941,11 @@ pa_chk_field_selector (str) name[0] = tolower ((*str)[0]), name[1] = tolower ((*str)[1]), name[2] = 0; -#ifdef OBJ_SOM else if ((*str)[3] == '\'' || (*str)[3] == '%') name[0] = tolower ((*str)[0]), name[1] = tolower ((*str)[1]), name[2] = tolower ((*str)[2]), name[3] = 0; -#endif else return e_fsel; @@ -3669,6 +5040,14 @@ pa_get_absolute_expression (insn, strp) *s = c; return evaluate_absolute (insn); } + /* When in strict mode we have a non-match, fix up the pointers + and return to our caller. */ + if (insn->exp.X_op != O_constant && strict) + { + expr_end = input_line_pointer; + input_line_pointer = save_in; + return 0; + } if (insn->exp.X_op != O_constant) { as_bad (_("Bad segment (should be absolute).")); @@ -3841,17 +5220,271 @@ pa_parse_nullif (s) computational instruction. */ static int -pa_parse_nonneg_cmpsub_cmpltr (s, isbranch) +pa_parse_nonneg_cmpsub_cmpltr (s, isbranch) + char **s; + int isbranch; +{ + int cmpltr; + char *name = *s + 1; + char c; + char *save_s = *s; + int nullify = 0; + + cmpltr = 0; + if (**s == ',') + { + *s += 1; + while (**s != ',' && **s != ' ' && **s != '\t') + *s += 1; + c = **s; + **s = 0x00; + + + if (strcmp (name, "=") == 0) + { + cmpltr = 1; + } + else if (strcmp (name, "<") == 0) + { + cmpltr = 2; + } + else if (strcmp (name, "<=") == 0) + { + cmpltr = 3; + } + else if (strcmp (name, "<<") == 0) + { + cmpltr = 4; + } + else if (strcmp (name, "<<=") == 0) + { + cmpltr = 5; + } + else if (strcasecmp (name, "sv") == 0) + { + cmpltr = 6; + } + else if (strcasecmp (name, "od") == 0) + { + cmpltr = 7; + } + /* If we have something like addb,n then there is no condition + completer. */ + else if (strcasecmp (name, "n") == 0 && isbranch) + { + cmpltr = 0; + nullify = 1; + } + else + { + cmpltr = -1; + } + **s = c; + } + + /* Reset pointers if this was really a ,n for a branch instruction. */ + if (nullify) + *s = save_s; + + + return cmpltr; +} + +/* Parse a negated compare/subtract completer returning the + number (for encoding in instrutions) of the given completer. + + ISBRANCH specifies whether or not this is parsing a condition + completer for a branch (vs a nullification completer for a + computational instruction. */ + +static int +pa_parse_neg_cmpsub_cmpltr (s, isbranch) + char **s; + int isbranch; +{ + int cmpltr; + char *name = *s + 1; + char c; + char *save_s = *s; + int nullify = 0; + + cmpltr = 0; + if (**s == ',') + { + *s += 1; + while (**s != ',' && **s != ' ' && **s != '\t') + *s += 1; + c = **s; + **s = 0x00; + + + if (strcasecmp (name, "tr") == 0) + { + cmpltr = 0; + } + else if (strcmp (name, "<>") == 0) + { + cmpltr = 1; + } + else if (strcmp (name, ">=") == 0) + { + cmpltr = 2; + } + else if (strcmp (name, ">") == 0) + { + cmpltr = 3; + } + else if (strcmp (name, ">>=") == 0) + { + cmpltr = 4; + } + else if (strcmp (name, ">>") == 0) + { + cmpltr = 5; + } + else if (strcasecmp (name, "nsv") == 0) + { + cmpltr = 6; + } + else if (strcasecmp (name, "ev") == 0) + { + cmpltr = 7; + } + /* If we have something like addb,n then there is no condition + completer. */ + else if (strcasecmp (name, "n") == 0 && isbranch) + { + cmpltr = 0; + nullify = 1; + } + else + { + cmpltr = -1; + } + **s = c; + } + + /* Reset pointers if this was really a ,n for a branch instruction. */ + if (nullify) + *s = save_s; + + + return cmpltr; +} + + +/* Parse a 64 bit compare and branch completer returning the number (for + encoding in instrutions) of the given completer. + + Nonnegated comparisons are returned as 0-7, negated comparisons are + returned as 8-15. */ + +static int +pa_parse_cmpb_64_cmpltr (s) + char **s; +{ + int cmpltr; + char *name = *s + 1; + char c; + char *save_s = *s; + + cmpltr = -1; + if (**s == ',') + { + *s += 1; + while (**s != ',' && **s != ' ' && **s != '\t') + *s += 1; + c = **s; + **s = 0x00; + + if (strcmp (name, "*") == 0) + { + cmpltr = 0; + } + else if (strcmp (name, "*=") == 0) + { + cmpltr = 1; + } + else if (strcmp (name, "*<") == 0) + { + cmpltr = 2; + } + else if (strcmp (name, "*<=") == 0) + { + cmpltr = 3; + } + else if (strcmp (name, "*<<") == 0) + { + cmpltr = 4; + } + else if (strcmp (name, "*<<=") == 0) + { + cmpltr = 5; + } + else if (strcasecmp (name, "*sv") == 0) + { + cmpltr = 6; + } + else if (strcasecmp (name, "*od") == 0) + { + cmpltr = 7; + } + else if (strcasecmp (name, "*tr") == 0) + { + cmpltr = 8; + } + else if (strcmp (name, "*<>") == 0) + { + cmpltr = 9; + } + else if (strcmp (name, "*>=") == 0) + { + cmpltr = 10; + } + else if (strcmp (name, "*>") == 0) + { + cmpltr = 11; + } + else if (strcmp (name, "*>>=") == 0) + { + cmpltr = 12; + } + else if (strcmp (name, "*>>") == 0) + { + cmpltr = 13; + } + else if (strcasecmp (name, "*nsv") == 0) + { + cmpltr = 14; + } + else if (strcasecmp (name, "*ev") == 0) + { + cmpltr = 15; + } + else + { + cmpltr = -1; + } + **s = c; + } + + + return cmpltr; +} + +/* Parse a 64 bit compare immediate and branch completer returning the number + (for encoding in instrutions) of the given completer. */ + +static int +pa_parse_cmpib_64_cmpltr (s) char **s; - int isbranch; { int cmpltr; char *name = *s + 1; char c; char *save_s = *s; - int nullify = 0; - cmpltr = 0; + cmpltr = -1; if (**s == ',') { *s += 1; @@ -3860,42 +5493,38 @@ pa_parse_nonneg_cmpsub_cmpltr (s, isbranch) c = **s; **s = 0x00; - - if (strcmp (name, "=") == 0) + if (strcmp (name, "*<<") == 0) + { + cmpltr = 0; + } + else if (strcmp (name, "*=") == 0) { cmpltr = 1; } - else if (strcmp (name, "<") == 0) + else if (strcmp (name, "*<") == 0) { cmpltr = 2; } - else if (strcmp (name, "<=") == 0) + else if (strcmp (name, "*<=") == 0) { cmpltr = 3; } - else if (strcmp (name, "<<") == 0) + else if (strcmp (name, "*>>=") == 0) { cmpltr = 4; } - else if (strcmp (name, "<<=") == 0) + else if (strcmp (name, "*<>") == 0) { cmpltr = 5; } - else if (strcasecmp (name, "sv") == 0) + else if (strcasecmp (name, "*>=") == 0) { cmpltr = 6; } - else if (strcasecmp (name, "od") == 0) + else if (strcasecmp (name, "*>") == 0) { cmpltr = 7; } - /* If we have something like addb,n then there is no condition - completer. */ - else if (strcasecmp (name, "n") == 0 && isbranch) - { - cmpltr = 0; - nullify = 1; - } else { cmpltr = -1; @@ -3903,23 +5532,19 @@ pa_parse_nonneg_cmpsub_cmpltr (s, isbranch) **s = c; } - /* Reset pointers if this was really a ,n for a branch instruction. */ - if (nullify) - *s = save_s; - return cmpltr; } -/* Parse a negated compare/subtract completer returning the - number (for encoding in instrutions) of the given completer. +/* Parse a non-negated addition completer returning the number + (for encoding in instrutions) of the given completer. ISBRANCH specifies whether or not this is parsing a condition completer for a branch (vs a nullification completer for a computational instruction. */ static int -pa_parse_neg_cmpsub_cmpltr (s, isbranch) +pa_parse_nonneg_add_cmpltr (s, isbranch) char **s; int isbranch; { @@ -3927,7 +5552,6 @@ pa_parse_neg_cmpsub_cmpltr (s, isbranch) char *name = *s + 1; char c; char *save_s = *s; - int nullify = 0; cmpltr = 0; if (**s == ',') @@ -3937,37 +5561,31 @@ pa_parse_neg_cmpsub_cmpltr (s, isbranch) *s += 1; c = **s; **s = 0x00; - - - if (strcasecmp (name, "tr") == 0) - { - cmpltr = 0; - } - else if (strcmp (name, "<>") == 0) + if (strcmp (name, "=") == 0) { cmpltr = 1; } - else if (strcmp (name, ">=") == 0) + else if (strcmp (name, "<") == 0) { cmpltr = 2; } - else if (strcmp (name, ">") == 0) + else if (strcmp (name, "<=") == 0) { cmpltr = 3; } - else if (strcmp (name, ">>=") == 0) + else if (strcasecmp (name, "nuv") == 0) { cmpltr = 4; } - else if (strcmp (name, ">>") == 0) + else if (strcasecmp (name, "znv") == 0) { cmpltr = 5; } - else if (strcasecmp (name, "nsv") == 0) + else if (strcasecmp (name, "sv") == 0) { cmpltr = 6; } - else if (strcasecmp (name, "ev") == 0) + else if (strcasecmp (name, "od") == 0) { cmpltr = 7; } @@ -3976,7 +5594,6 @@ pa_parse_neg_cmpsub_cmpltr (s, isbranch) else if (strcasecmp (name, "n") == 0 && isbranch) { cmpltr = 0; - nullify = 1; } else { @@ -3986,23 +5603,21 @@ pa_parse_neg_cmpsub_cmpltr (s, isbranch) } /* Reset pointers if this was really a ,n for a branch instruction. */ - if (nullify) + if (cmpltr == 0 && *name == 'n' && isbranch) *s = save_s; - return cmpltr; } - -/* Parse a non-negated addition completer returning the number +/* Parse a negated addition completer returning the number (for encoding in instrutions) of the given completer. ISBRANCH specifies whether or not this is parsing a condition completer for a branch (vs a nullification completer for a - computational instruction. */ + computational instruction). */ static int -pa_parse_nonneg_add_cmpltr (s, isbranch) +pa_parse_neg_add_cmpltr (s, isbranch) char **s; int isbranch; { @@ -4019,31 +5634,35 @@ pa_parse_nonneg_add_cmpltr (s, isbranch) *s += 1; c = **s; **s = 0x00; - if (strcmp (name, "=") == 0) + if (strcasecmp (name, "tr") == 0) + { + cmpltr = 0; + } + else if (strcmp (name, "<>") == 0) { cmpltr = 1; } - else if (strcmp (name, "<") == 0) + else if (strcmp (name, ">=") == 0) { cmpltr = 2; } - else if (strcmp (name, "<=") == 0) + else if (strcmp (name, ">") == 0) { cmpltr = 3; } - else if (strcasecmp (name, "nuv") == 0) + else if (strcasecmp (name, "uv") == 0) { cmpltr = 4; } - else if (strcasecmp (name, "znv") == 0) + else if (strcasecmp (name, "vnz") == 0) { cmpltr = 5; } - else if (strcasecmp (name, "sv") == 0) + else if (strcasecmp (name, "nsv") == 0) { cmpltr = 6; } - else if (strcasecmp (name, "od") == 0) + else if (strcasecmp (name, "ev") == 0) { cmpltr = 7; } @@ -4067,22 +5686,18 @@ pa_parse_nonneg_add_cmpltr (s, isbranch) return cmpltr; } -/* Parse a negated addition completer returning the number - (for encoding in instrutions) of the given completer. - - ISBRANCH specifies whether or not this is parsing a condition - completer for a branch (vs a nullification completer for a - computational instruction). */ +/* Parse a 64 bit wide mode add and branch completer returning the number (for + encoding in instrutions) of the given completer. */ static int -pa_parse_neg_add_cmpltr (s, isbranch) +pa_parse_addb_64_cmpltr (s) char **s; - int isbranch; { int cmpltr; char *name = *s + 1; char c; char *save_s = *s; + int nullify = 0; cmpltr = 0; if (**s == ',') @@ -4092,43 +5707,72 @@ pa_parse_neg_add_cmpltr (s, isbranch) *s += 1; c = **s; **s = 0x00; - if (strcasecmp (name, "tr") == 0) - { - cmpltr = 0; - } - else if (strcmp (name, "<>") == 0) + if (strcmp (name, "=") == 0) { cmpltr = 1; } - else if (strcmp (name, ">=") == 0) + else if (strcmp (name, "<") == 0) { cmpltr = 2; } - else if (strcmp (name, ">") == 0) + else if (strcmp (name, "<=") == 0) { cmpltr = 3; } - else if (strcasecmp (name, "uv") == 0) + else if (strcasecmp (name, "nuv") == 0) { cmpltr = 4; } - else if (strcasecmp (name, "vnz") == 0) + else if (strcasecmp (name, "*=") == 0) { cmpltr = 5; } - else if (strcasecmp (name, "nsv") == 0) + else if (strcasecmp (name, "*<") == 0) { cmpltr = 6; } - else if (strcasecmp (name, "ev") == 0) + else if (strcasecmp (name, "*<=") == 0) { cmpltr = 7; } + else if (strcmp (name, "tr") == 0) + { + cmpltr = 8; + } + else if (strcmp (name, "<>") == 0) + { + cmpltr = 9; + } + else if (strcmp (name, ">=") == 0) + { + cmpltr = 10; + } + else if (strcmp (name, ">") == 0) + { + cmpltr = 11; + } + else if (strcasecmp (name, "uv") == 0) + { + cmpltr = 12; + } + else if (strcasecmp (name, "*<>") == 0) + { + cmpltr = 13; + } + else if (strcasecmp (name, "*>=") == 0) + { + cmpltr = 14; + } + else if (strcasecmp (name, "*>") == 0) + { + cmpltr = 15; + } /* If we have something like addb,n then there is no condition completer. */ - else if (strcasecmp (name, "n") == 0 && isbranch) + else if (strcasecmp (name, "n") == 0) { cmpltr = 0; + nullify = 1; } else { @@ -4138,12 +5782,13 @@ pa_parse_neg_add_cmpltr (s, isbranch) } /* Reset pointers if this was really a ,n for a branch instruction. */ - if (cmpltr == 0 && *name == 'n' && isbranch) + if (nullify) *s = save_s; return cmpltr; } +#ifdef OBJ_SOM /* Handle an alignment directive. Special so that we can update the alignment of the subspace if necessary. */ static void @@ -4160,6 +5805,7 @@ pa_align (bytes) if (log2 (bytes) != -1) record_alignment (current_subspace->ssd_seg, log2 (bytes)); } +#endif /* Handle a .BLOCK type pseudo-op. */ @@ -4172,8 +5818,10 @@ pa_block (z) unsigned int temp_size; unsigned int i; +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif temp_size = get_absolute_expression (); @@ -4251,8 +5899,10 @@ static void pa_call (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif pa_call_args (&last_call_desc); demand_empty_rest_of_line (); @@ -4338,26 +5988,35 @@ pa_build_unwind_subspace (call_info) { char *unwind; asection *seg, *save_seg; + asymbol *sym; subsegT subseg, save_subseg; - int i; + int i, reloc; char c, *p; + if (now_seg != text_section) + return; + + if (bfd_get_arch_info (stdoutput)->bits_per_address == 32) + reloc = R_PARISC_DIR32; + else + reloc = R_PARISC_SEGREL32; + + save_seg = now_seg; + save_subseg = now_subseg; /* Get into the right seg/subseg. This may involve creating the seg the first time through. Make sure to have the old seg/subseg so that we can reset things when we are done. */ - subseg = SUBSEG_UNWIND; seg = bfd_get_section_by_name (stdoutput, UNWIND_SECTION_NAME); if (seg == ASEC_NULL) { - seg = bfd_make_section_old_way (stdoutput, UNWIND_SECTION_NAME); + seg = subseg_new (UNWIND_SECTION_NAME, 0); bfd_set_section_flags (stdoutput, seg, SEC_READONLY | SEC_HAS_CONTENTS - | SEC_LOAD | SEC_RELOC); + | SEC_LOAD | SEC_RELOC | SEC_ALLOC | SEC_DATA); + bfd_set_section_alignment (stdoutput, seg, 2); } - save_seg = now_seg; - save_subseg = now_subseg; - subseg_set (seg, subseg); + subseg_set (seg, 0); /* Get some space to hold relocation information for the unwind @@ -4368,7 +6027,8 @@ pa_build_unwind_subspace (call_info) /* Relocation info. for start offset of the function. */ fix_new_hppa (frag_now, p - frag_now->fr_literal, 4, call_info->start_symbol, (offsetT) 0, - (expressionS *) NULL, 0, R_PARISC_DIR32, e_fsel, 32, 0, NULL); + (expressionS *) NULL, 0, reloc, + e_fsel, 32, 0, NULL); p = frag_more (4); md_number_to_chars (p, 0, 4); @@ -4383,7 +6043,8 @@ pa_build_unwind_subspace (call_info) fix_new_hppa (frag_now, p - frag_now->fr_literal, 4, call_info->end_symbol, (offsetT) 0, - (expressionS *) NULL, 0, R_PARISC_DIR32, e_fsel, 32, 0, NULL); + (expressionS *) NULL, 0, reloc, + e_fsel, 32, 0, NULL); /* Dump it. */ unwind = (char *) &call_info->ci_unwind; @@ -4411,8 +6072,10 @@ pa_callinfo (unused) char *name, c, *p; int temp; +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif /* .CALLINFO must appear within a procedure definition. */ if (!within_procedure) @@ -4549,9 +6212,11 @@ static void pa_code (unused) int unused; { +#ifdef OBJ_SOM current_space = is_defined_space ("$TEXT$"); current_subspace = pa_subsegment_to_subspace (current_space->sd_seg, 0); +#endif s_text (0); pa_undefine_label (); } @@ -4601,7 +6266,7 @@ pa_comm (unused) /* colon() has already set the frag to the current location in the current subspace; we need to reset the fragment to the zero address fragment. We also need to reset the segment pointer. */ - symbol->sy_frag = &zero_address_frag; + symbol_set_frag (symbol, &zero_address_frag); } demand_empty_rest_of_line (); } @@ -4620,8 +6285,10 @@ static void pa_enter (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif as_bad (_("The .ENTER pseudo-op is not supported")); demand_empty_rest_of_line (); @@ -4633,8 +6300,10 @@ static void pa_entry (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif if (!within_procedure) as_bad (_("Misplaced .entry. Ignored.")); @@ -4738,8 +6407,10 @@ static void pa_exit (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif if (!within_procedure) as_bad (_(".EXIT must appear within a procedure")); @@ -4808,13 +6479,13 @@ pa_type_args (symbolP, is_export) char *name, c, *p; unsigned int temp, arg_reloc; pa_symbol_type type = SYMBOL_TYPE_UNKNOWN; - obj_symbol_type *symbol = (obj_symbol_type *) symbolP->bsym; + obj_symbol_type *symbol = (obj_symbol_type *) symbol_get_bfdsym (symbolP); if (strncasecmp (input_line_pointer, "absolute", 8) == 0) { input_line_pointer += 8; - symbolP->bsym->flags &= ~BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags &= ~BSF_FUNCTION; S_SET_SEGMENT (symbolP, bfd_abs_section_ptr); type = SYMBOL_TYPE_ABSOLUTE; } @@ -4827,54 +6498,56 @@ pa_type_args (symbolP, is_export) Complain if one tries to EXPORT a CODE type since that's never done. Both GCC and HP C still try to IMPORT CODE types, so silently fix them to be ENTRY types. */ - if (symbolP->bsym->flags & BSF_FUNCTION) + if (S_IS_FUNCTION (symbolP)) { if (is_export) - as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"), symbolP->bsym->name); + as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"), + S_GET_NAME (symbolP)); - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; type = SYMBOL_TYPE_ENTRY; } else { - symbolP->bsym->flags &= ~BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags &= ~BSF_FUNCTION; type = SYMBOL_TYPE_CODE; } } else if (strncasecmp (input_line_pointer, "data", 4) == 0) { input_line_pointer += 4; - symbolP->bsym->flags &= ~BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags &= ~BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; type = SYMBOL_TYPE_DATA; } else if ((strncasecmp (input_line_pointer, "entry", 5) == 0)) { input_line_pointer += 5; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; type = SYMBOL_TYPE_ENTRY; } else if (strncasecmp (input_line_pointer, "millicode", 9) == 0) { input_line_pointer += 9; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; type = SYMBOL_TYPE_MILLICODE; } else if (strncasecmp (input_line_pointer, "plabel", 6) == 0) { input_line_pointer += 6; - symbolP->bsym->flags &= ~BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags &= ~BSF_FUNCTION; type = SYMBOL_TYPE_PLABEL; } else if (strncasecmp (input_line_pointer, "pri_prog", 8) == 0) { input_line_pointer += 8; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; type = SYMBOL_TYPE_PRI_PROG; } else if (strncasecmp (input_line_pointer, "sec_prog", 8) == 0) { input_line_pointer += 8; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; type = SYMBOL_TYPE_SEC_PROG; } @@ -4882,7 +6555,7 @@ pa_type_args (symbolP, is_export) than BFD understands. This is how we get this information to the SOM BFD backend. */ #ifdef obj_set_symbol_type - obj_set_symbol_type (symbolP->bsym, (int) type); + obj_set_symbol_type (symbol_get_bfdsym (symbolP), (int) type); #endif /* Now that the type of the exported symbol has been handled, @@ -4903,7 +6576,9 @@ pa_type_args (symbolP, is_export) name = input_line_pointer; c = get_symbol_end (); arg_reloc = pa_align_arg_reloc (temp, pa_build_arg_reloc (name)); +#ifdef OBJ_SOM symbol->tc_data.ap.hppa_arg_reloc |= arg_reloc; +#endif *input_line_pointer = c; } /* The return value. */ @@ -4915,7 +6590,9 @@ pa_type_args (symbolP, is_export) name = input_line_pointer; c = get_symbol_end (); arg_reloc = pa_build_arg_reloc (name); +#ifdef OBJ_SOM symbol->tc_data.ap.hppa_arg_reloc |= arg_reloc; +#endif *input_line_pointer = c; } /* Privelege level. */ @@ -4925,7 +6602,9 @@ pa_type_args (symbolP, is_export) *p = c; input_line_pointer++; temp = atoi (input_line_pointer); +#ifdef OBJ_SOM symbol->tc_data.ap.hppa_priv_level = temp; +#endif c = get_symbol_end (); *input_line_pointer = c; } @@ -4976,7 +6655,7 @@ pa_import (unused) the the current segment. Note only BSF_FUNCTION really matters, we do not need to set the full SYMBOL_TYPE_* info. */ if (now_seg == text_section) - symbol->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbol)->flags |= BSF_FUNCTION; /* If the section is undefined, then the symbol is undefined Since this is an import, leave the section undefined. */ @@ -5030,8 +6709,10 @@ static void pa_leave (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif as_bad (_("The .LEAVE pseudo-op is not supported")); demand_empty_rest_of_line (); @@ -5058,6 +6739,12 @@ pa_level (unused) if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 11)) as_warn (_("could not set architecture and machine")); } + else if (strncmp (level, "2.0w", 4) == 0) + { + input_line_pointer += 4; + if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 25)) + as_warn (_("could not set architecture and machine")); + } else if (strncmp (level, "2.0", 3) == 0) { input_line_pointer += 3; @@ -5078,8 +6765,10 @@ static void pa_origin (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif s_org (0); pa_undefine_label (); @@ -5129,8 +6818,10 @@ pa_proc (unused) { struct call_info *call_info; +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif if (within_procedure) as_fatal (_("Nested procedures")); @@ -5176,7 +6867,7 @@ pa_proc (unused) if (label_symbol->lss_label) { last_call_info->start_symbol = label_symbol->lss_label; - label_symbol->lss_label->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (label_symbol->lss_label)->flags |= BSF_FUNCTION; } else as_bad (_("Missing function name for .PROC (corrupted label chain)")); @@ -5196,8 +6887,10 @@ pa_procend (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif /* If we are within a procedure definition, make sure we've defined a label for the procedure; handle case where the @@ -5215,7 +6908,8 @@ pa_procend (unused) if (label_symbol->lss_label) { last_call_info->start_symbol = label_symbol->lss_label; - label_symbol->lss_label->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (label_symbol->lss_label)->flags + |= BSF_FUNCTION; #ifdef OBJ_SOM /* Also handle allocation of a fixup to hold the unwind information when the label appears after the proc/procend. */ @@ -5257,6 +6951,38 @@ pa_procend (unused) pa_undefine_label (); } +/* If VALUE is an exact power of two between zero and 2^31, then + return log2 (VALUE). Else return -1. */ + +static int +log2 (value) + int value; +{ + int shift = 0; + + while ((1 << shift) != value && shift < 32) + shift++; + + if (shift >= 32) + return -1; + else + return shift; +} + + +#ifdef OBJ_SOM +/* Check to make sure we have a valid space and subspace. */ + +static void +pa_check_current_space_and_subspace () +{ + if (current_space == NULL) + as_fatal (_("Not in a space.\n")); + + if (current_subspace == NULL) + as_fatal (_("Not in a subspace.\n")); +} + /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero, then create a new space entry to hold the information specified by the parameters to the .SPACE directive. */ @@ -5525,24 +7251,6 @@ pa_spnum (unused) demand_empty_rest_of_line (); } -/* If VALUE is an exact power of two between zero and 2^31, then - return log2 (VALUE). Else return -1. */ - -static int -log2 (value) - int value; -{ - int shift = 0; - - while ((1 << shift) != value && shift < 32) - shift++; - - if (shift >= 32) - return -1; - else - return shift; -} - /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the given subspace, creating the new subspace if necessary. @@ -5553,7 +7261,7 @@ static void pa_subspace (create_new) int create_new; { - char *name, *ss_name, *alias, c; + char *name, *ss_name, c; char loadable, code_only, common, dup_common, zero, sort; int i, access, space_index, alignment, quadrant, applicable, flags; sd_chain_struct *space; @@ -5587,7 +7295,6 @@ pa_subspace (create_new) space_index = ~0; alignment = 1; quadrant = 0; - alias = NULL; space = current_space; if (create_new) @@ -5624,8 +7331,6 @@ pa_subspace (create_new) quadrant = pa_def_subspaces[i].quadrant; access = pa_def_subspaces[i].access; sort = pa_def_subspaces[i].sort; - if (USE_ALIASES && pa_def_subspaces[i].alias) - alias = pa_def_subspaces[i].alias; break; } i++; @@ -5734,14 +7439,6 @@ pa_subspace (create_new) section = subseg_force_new (ss_name, 0); else if (ssd) section = ssd->ssd_seg; - else if (alias) - section = subseg_new (alias, 0); - else if (!alias && USE_ALIASES) - { - as_warn (_("Ignoring subspace decl due to ELF BFD bugs.")); - demand_empty_rest_of_line (); - return; - } else section = subseg_new (ss_name, 0); @@ -5798,10 +7495,7 @@ pa_spaces_begin () char *name; /* Pick the right name to use for the new section. */ - if (pa_def_spaces[i].alias && USE_ALIASES) - name = pa_def_spaces[i].alias; - else - name = pa_def_spaces[i].name; + name = pa_def_spaces[i].name; pa_def_spaces[i].segment = subseg_new (name, 0); create_new_space (pa_def_spaces[i].name, pa_def_spaces[i].spnum, @@ -5821,16 +7515,8 @@ pa_spaces_begin () /* Pick the right name for the new section and pick the right subsegment number. */ - if (pa_def_subspaces[i].alias && USE_ALIASES) - { - name = pa_def_subspaces[i].alias; - subsegment = pa_def_subspaces[i].subsegment; - } - else - { - name = pa_def_subspaces[i].name; - subsegment = 0; - } + name = pa_def_subspaces[i].name; + subsegment = 0; /* Create the new section. */ segment = subseg_new (name, subsegment); @@ -5839,7 +7525,7 @@ pa_spaces_begin () /* For SOM we want to replace the standard .text, .data, and .bss sections with our own. We also want to set BFD flags for all the built-in subspaces. */ - if (!strcmp (pa_def_subspaces[i].name, "$CODE$") && !USE_ALIASES) + if (!strcmp (pa_def_subspaces[i].name, "$CODE$")) { text_section = segment; applicable = bfd_applicable_section_flags (stdoutput); @@ -5849,7 +7535,7 @@ pa_spaces_begin () | SEC_READONLY | SEC_HAS_CONTENTS)); } - else if (!strcmp (pa_def_subspaces[i].name, "$DATA$") && !USE_ALIASES) + else if (!strcmp (pa_def_subspaces[i].name, "$DATA$")) { data_section = segment; applicable = bfd_applicable_section_flags (stdoutput); @@ -5860,14 +7546,14 @@ pa_spaces_begin () } - else if (!strcmp (pa_def_subspaces[i].name, "$BSS$") && !USE_ALIASES) + else if (!strcmp (pa_def_subspaces[i].name, "$BSS$")) { bss_section = segment; applicable = bfd_applicable_section_flags (stdoutput); bfd_set_section_flags (stdoutput, segment, applicable & SEC_ALLOC); } - else if (!strcmp (pa_def_subspaces[i].name, "$LIT$") && !USE_ALIASES) + else if (!strcmp (pa_def_subspaces[i].name, "$LIT$")) { applicable = bfd_applicable_section_flags (stdoutput); bfd_set_section_flags (stdoutput, segment, @@ -5876,8 +7562,7 @@ pa_spaces_begin () | SEC_READONLY | SEC_HAS_CONTENTS)); } - else if (!strcmp (pa_def_subspaces[i].name, "$MILLICODE$") - && !USE_ALIASES) + else if (!strcmp (pa_def_subspaces[i].name, "$MILLICODE$")) { applicable = bfd_applicable_section_flags (stdoutput); bfd_set_section_flags (stdoutput, segment, @@ -5886,7 +7571,7 @@ pa_spaces_begin () | SEC_READONLY | SEC_HAS_CONTENTS)); } - else if (!strcmp (pa_def_subspaces[i].name, "$UNWIND$") && !USE_ALIASES) + else if (!strcmp (pa_def_subspaces[i].name, "$UNWIND$")) { applicable = bfd_applicable_section_flags (stdoutput); bfd_set_section_flags (stdoutput, segment, @@ -6037,7 +7722,7 @@ create_new_subspace (space, name, loadable, code_only, common, we'll set it to 1 which "locks-in" the subspace attributes. */ SUBSPACE_DEFINED (chain_entry) = 0; - chain_entry->ssd_subseg = USE_ALIASES ? pa_next_subseg (space) : 0; + chain_entry->ssd_subseg = 0; chain_entry->ssd_seg = seg; chain_entry->ssd_next = NULL; @@ -6256,7 +7941,6 @@ pa_subspace_start (space, quadrant) sd_chain_struct *space; int quadrant; { -#ifdef OBJ_SOM /* FIXME. Assumes everyone puts read/write data at 0x4000000, this is not correct for the PA OSF1 port. */ if ((strcmp (SPACE_NAME (space), "$PRIVATE$") == 0) && quadrant == 1) @@ -6265,7 +7949,6 @@ pa_subspace_start (space, quadrant) return 0x40000000; else return 0; -#endif return 0; } @@ -6278,6 +7961,7 @@ pa_next_subseg (space) space->sd_last_subseg++; return space->sd_last_subseg; } +#endif /* Helper function for pa_stringer. Used to find the end of a string. */ @@ -6288,8 +7972,10 @@ pa_stringer_aux (s) { unsigned int c = *s & CHAR_MASK; +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif switch (c) { @@ -6430,9 +8116,11 @@ static void pa_data (unused) int unused; { +#ifdef OBJ_SOM current_space = is_defined_space ("$PRIVATE$"); current_subspace = pa_subsegment_to_subspace (current_space->sd_seg, 0); +#endif s_data (0); pa_undefine_label (); } @@ -6453,8 +8141,10 @@ static void pa_fill (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif s_fill (0); pa_undefine_label (); @@ -6466,8 +8156,10 @@ static void pa_lcomm (needs_align) int needs_align; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif s_lcomm (needs_align); pa_undefine_label (); @@ -6479,8 +8171,10 @@ static void pa_lsym (unused) int unused; { +#ifdef OBJ_SOM /* We must have a valid space and subspace. */ pa_check_current_space_and_subspace (); +#endif s_lsym (0); pa_undefine_label (); @@ -6492,9 +8186,11 @@ static void pa_text (unused) int unused; { +#ifdef OBJ_SOM current_space = is_defined_space ("$TEXT$"); current_subspace = pa_subsegment_to_subspace (current_space->sd_seg, 0); +#endif s_text (0); pa_undefine_label (); @@ -6519,7 +8215,7 @@ pa_text (unused) selectors). Reject reductions involving symbols with external scope; such - reductions make life a living hell for object file editors. + reductions make life a living hell for object file editors. FIXME. Also reject R_HPPA relocations which are 32bits wide in the code space. The SOM BFD backend doesn't know how to pull the @@ -6539,7 +8235,7 @@ hppa_fix_adjustable (fixp) return 0; /* Reject reductions of symbols in sym1-sym2 expressions when - the fixup will occur in a CODE subspace. + the fixup will occur in a CODE subspace. XXX FIXME: Long term we probably want to reject all of these; for example reducing in the debug section would lose if we ever @@ -6549,7 +8245,7 @@ hppa_fix_adjustable (fixp) && (hppa_fix->segment->flags & SEC_CODE)) { /* Apparently sy_used_in_reloc never gets set for sub symbols. */ - fixp->fx_subsy->sy_used_in_reloc = 1; + symbol_mark_used_in_reloc (fixp->fx_subsy); return 0; } @@ -6571,7 +8267,7 @@ hppa_fix_adjustable (fixp) || hppa_fix->fx_r_field == e_lpsel) return 0; - if (fixp->fx_addsy && fixp->fx_addsy->bsym->flags & BSF_GLOBAL) + if (fixp->fx_addsy && S_IS_EXTERNAL (fixp->fx_addsy)) return 0; /* Reject absolute calls (jumps). */ @@ -6579,8 +8275,7 @@ hppa_fix_adjustable (fixp) return 0; /* Reject reductions of function symbols. */ - if (fixp->fx_addsy == 0 - || (fixp->fx_addsy->bsym->flags & BSF_FUNCTION) == 0) + if (fixp->fx_addsy == 0 || ! S_IS_FUNCTION (fixp->fx_addsy)) return 1; return 0; @@ -6612,15 +8307,16 @@ hppa_force_relocation (fixp) #define arg_reloc_stub_needed(CALLER, CALLEE) \ ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER))) +#ifdef OBJ_SOM /* It is necessary to force PC-relative calls/jumps to have a relocation entry if they're going to need either a argument relocation or long call stub. FIXME. Can't we need the same for absolute calls? */ if (fixp->fx_pcrel && fixp->fx_addsy && (arg_reloc_stub_needed ((long) ((obj_symbol_type *) - fixp->fx_addsy->bsym)->tc_data.ap.hppa_arg_reloc, - - hppa_fixp->fx_arg_reloc))) + symbol_get_bfdsym (fixp->fx_addsy))->tc_data.ap.hppa_arg_reloc, + hppa_fixp->fx_arg_reloc))) return 1; +#endif distance = (fixp->fx_offset + S_GET_VALUE (fixp->fx_addsy) - md_pcrel_from (fixp)); /* Now check and see if we're going to need a long-branch stub. */ @@ -6677,7 +8373,7 @@ hppa_elf_mark_end_of_function () frag_now); assert (symbolP); - symbolP->bsym->flags = BSF_LOCAL; + S_CLEAR_EXTERNAL (symbolP); symbol_table_insert (symbolP); } @@ -6707,10 +8403,19 @@ elf_hppa_final_processing () call_info_pointer = call_info_pointer->ci_next) { elf_symbol_type *esym - = (elf_symbol_type *) call_info_pointer->start_symbol->bsym; + = ((elf_symbol_type *) + symbol_get_bfdsym (call_info_pointer->start_symbol)); esym->internal_elf_sym.st_size = S_GET_VALUE (call_info_pointer->end_symbol) - S_GET_VALUE (call_info_pointer->start_symbol) + 4; } } #endif + +#ifdef OBJ_ELF +pa_end_of_source () +{ + if (debug_type == DEBUG_DWARF2) + dwarf2_finish (); +} +#endif diff --git a/gas/config/tc-hppa.h b/gas/config/tc-hppa.h index c1541d9..266c8ca 100644 --- a/gas/config/tc-hppa.h +++ b/gas/config/tc-hppa.h @@ -1,5 +1,6 @@ /* tc-hppa.h -- Header file for the PA - Copyright (C) 1989, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -48,9 +49,14 @@ /* FIXME. The lack of a place to put things which are both target cpu and target format dependent makes hacks like this necessary. */ #ifdef OBJ_ELF +#ifdef BFD64 +#include "bfd/elf64-hppa.h" +#define TARGET_FORMAT "elf64-hppa" +#else #include "bfd/elf32-hppa.h" #define TARGET_FORMAT "elf32-hppa" #endif +#endif #ifdef OBJ_SOM #include "bfd/som.h" @@ -66,7 +72,7 @@ #define ASEC_NULL (asection *)0 /* Labels are not required to have a colon for a suffix. */ -#define LABELS_WITHOUT_COLONS +#define LABELS_WITHOUT_COLONS 1 /* FIXME. This should be static and declared in tc-hppa.c, but pa_define_label gets used outside of tc-hppa.c via tc_frob_label. @@ -128,9 +134,9 @@ void elf_hppa_final_processing PARAMS ((void)); *not* end up in the symbol table. Likewise for absolute symbols with local scope. */ #define tc_frob_symbol(sym,punt) \ - if ((S_GET_SEGMENT (sym) == &bfd_und_section && sym->sy_used == 0) \ + if ((S_GET_SEGMENT (sym) == &bfd_und_section && ! symbol_used_p (sym)) \ || (S_GET_SEGMENT (sym) == &bfd_abs_section \ - && (sym->bsym->flags & BSF_EXPORT) == 0)) \ + && ! S_IS_EXTERNAL (sym))) \ punt = 1 /* We need to be able to make relocations involving the difference of @@ -147,14 +153,18 @@ void elf_hppa_final_processing PARAMS ((void)); #ifdef OBJ_ELF #define tc_frob_symbol(sym,punt) \ { \ - if ((S_GET_SEGMENT (sym) == &bfd_und_section && sym->sy_used == 0) \ + if ((S_GET_SEGMENT (sym) == &bfd_und_section && ! symbol_used_p (sym)) \ || (S_GET_SEGMENT (sym) == &bfd_abs_section \ - && (sym->bsym->flags & BSF_EXPORT) == 0)) \ + && ! S_IS_EXTERNAL (sym)) \ + || strcmp (S_GET_NAME (sym), "$global$") == 0) \ punt = 1; \ } #endif #define md_operand(x) +#ifdef OBJ_ELF +#define md_end() pa_end_of_source () +#endif #define TC_FIX_TYPE PTR #define TC_INIT_FIX_DATA(FIXP) ((FIXP)->tc_fix_data = NULL) diff --git a/gas/config/tc-i370.c b/gas/config/tc-i370.c new file mode 100644 index 0000000..2183273 --- /dev/null +++ b/gas/config/tc-i370.c @@ -0,0 +1,2967 @@ +/* tc-i370.c -- Assembler for the IBM 360/370/390 instruction set. + Loosely based on the ppc files by Linas Vepstas 1998, 99 + Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + + 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 2, 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. */ + +/* This assembler implements a very hacked version of an elf-like thing + * that gcc emits (when gcc is suitably hacked). To make it behave more + * HLASM-like, try turning on the -M or --mri flag (as there are various + * similarities between HLASM and the MRI assemblers, such as section + * names, lack of leading . in pseudo-ops, DC and DS, etc ... + */ + +#include +#include +#include "as.h" +#include "subsegs.h" +#include "struc-symbol.h" + +#include "opcode/i370.h" + +#ifdef OBJ_ELF +#include "elf/i370.h" +#endif + +/* This is the assembler for the System/390 Architecture */ + +/* Tell the main code what the endianness is. */ +extern int target_big_endian; + + +/* Generic assembler global variables which must be defined by all + targets. */ + +#ifdef OBJ_ELF +/* This string holds the chars that always start a comment. If the + pre-processor is disabled, these aren't very useful. The macro + tc_comment_chars points to this. We use this, rather than the + usual comment_chars, so that we can switch for Solaris conventions. */ +static const char i370_eabi_comment_chars[] = "#"; + +const char *i370_comment_chars = i370_eabi_comment_chars; +#else +const char comment_chars[] = "#"; +#endif + +/* Characters which start a comment at the beginning of a line. */ +const char line_comment_chars[] = "#*"; + +/* Characters which may be used to separate multiple commands on a + single line. */ +const char line_separator_chars[] = ";"; + +/* Characters which are used to indicate an exponent in a floating + point number. */ +const char EXP_CHARS[] = "eE"; + +/* Characters which mean that a number is a floating point constant, + as in 0d1.0. */ +const char FLT_CHARS[] = "dD"; + + +void +md_show_usage (stream) + FILE *stream; +{ + fprintf(stream, "\ +S/370 options: (these have not yet been tested and may not work) \n\ +-u ignored\n\ +-mregnames Allow symbolic names for registers\n\ +-mno-regnames Do not allow symbolic names for registers\n"); +#ifdef OBJ_ELF + fprintf(stream, "\ +-mrelocatable support for GCC's -mrelocatble option\n\ +-mrelocatable-lib support for GCC's -mrelocatble-lib option\n\ +-V print assembler version number\n"); +#endif +} + + +static void i370_byte PARAMS ((int)); +static void i370_tc PARAMS ((int)); +static void i370_ebcdic PARAMS ((int)); + +static void i370_dc PARAMS ((int)); +static void i370_ds PARAMS ((int)); +static void i370_rmode PARAMS ((int)); +static void i370_csect PARAMS ((int)); +static void i370_dsect PARAMS ((int)); +static void i370_ltorg PARAMS ((int)); +static void i370_using PARAMS ((int)); +static void i370_drop PARAMS ((int)); +static void i370_make_relative PARAMS ((expressionS *exp, expressionS *baseaddr)); + +#ifdef OBJ_ELF +static bfd_reloc_code_real_type i370_elf_suffix PARAMS ((char **, expressionS *)); +static void i370_elf_cons PARAMS ((int)); +static void i370_elf_rdata PARAMS ((int)); +static void i370_elf_lcomm PARAMS ((int)); +static void i370_elf_validate_fix PARAMS ((fixS *, segT)); +#endif + + + +/* The target specific pseudo-ops which we support. */ + +const pseudo_typeS md_pseudo_table[] = +{ + /* Pseudo-ops which must be overridden. */ + { "byte", i370_byte, 0 }, + + { "dc", i370_dc, 0 }, + { "ds", i370_ds, 0 }, + { "rmode", i370_rmode, 0 }, + { "csect", i370_csect, 0 }, + { "dsect", i370_dsect, 0 }, + + /* enable ebcdic strings e.g. for 3270 support */ + { "ebcdic", i370_ebcdic, 0 }, + +#ifdef OBJ_ELF + { "long", i370_elf_cons, 4 }, + { "word", i370_elf_cons, 4 }, + { "short", i370_elf_cons, 2 }, + { "rdata", i370_elf_rdata, 0 }, + { "rodata", i370_elf_rdata, 0 }, + { "lcomm", i370_elf_lcomm, 0 }, +#endif + + /* This pseudo-op is used even when not generating XCOFF output. */ + { "tc", i370_tc, 0 }, + + /* dump the literal pool */ + { "ltorg", i370_ltorg, 0 }, + + /* support the hlasm-style USING directive */ + { "using", i370_using, 0 }, + { "drop", i370_drop, 0 }, + + { NULL, NULL, 0 } +}; + +/* ***************************************************************** */ + +/* Whether to use user friendly register names. */ +#define TARGET_REG_NAMES_P true + +static boolean reg_names_p = TARGET_REG_NAMES_P; + +static boolean register_name PARAMS ((expressionS *)); +static void i370_set_cpu PARAMS ((void)); +static i370_insn_t i370_insert_operand + PARAMS ((i370_insn_t insn, const struct i370_operand *operand, offsetT val)); +static void i370_macro PARAMS ((char *str, const struct i370_macro *macro)); + +/* Predefined register names if -mregnames */ +/* In general, there are lots of them, in an attempt to be compatible */ +/* with a number of assemblers. */ + +/* Structure to hold information about predefined registers. */ +struct pd_reg + { + char *name; + int value; + }; + +/* List of registers that are pre-defined: + + Each general register has predefined names of the form: + 1. r which has the value . + 2. r. which has the value . + + + Each floating point register has predefined names of the form: + 1. f which has the value . + 2. f. which has the value . + + There are only four floating point registers, and these are + commonly labelled 0,2,4 and 6. Thus, there is no f1, f3, etc. + + + There are individual registers as well: + rbase or r.base has the value 3 (base register) + rpgt or r.pgt has the value 4 (page origin table pointer) + rarg or r.arg has the value 11 (argument pointer) + rtca or r.tca has the value 12 (table of contents pointer) + rtoc or r.toc has the value 12 (table of contents pointer) + sp or r.sp has the value 13 (stack pointer) + dsa or r.dsa has the value 13 (stack pointer) + lr has the value 14 (link reg) + + The table is sorted. Suitable for searching by a binary search. */ + +static const struct pd_reg pre_defined_registers[] = +{ + { "arg", 11 }, /* Argument Pointer */ + { "base", 3 }, /* Base Reg */ + + { "f.0", 0 }, /* Floating point registers */ + { "f.2", 2 }, + { "f.4", 4 }, + { "f.6", 6 }, + + { "f0", 0 }, + { "f2", 2 }, + { "f4", 4 }, + { "f6", 6 }, + + + { "dsa",13 }, /* stack pointer */ + { "lr", 14 }, /* Link Register */ + { "pgt", 4 }, /* Page Origin Table Pointer */ + + { "r.0", 0 }, /* General Purpose Registers */ + { "r.1", 1 }, + { "r.10", 10 }, + { "r.11", 11 }, + { "r.12", 12 }, + { "r.13", 13 }, + { "r.14", 14 }, + { "r.15", 15 }, + { "r.2", 2 }, + { "r.3", 3 }, + { "r.4", 4 }, + { "r.5", 5 }, + { "r.6", 6 }, + { "r.7", 7 }, + { "r.8", 8 }, + { "r.9", 9 }, + + { "r.arg", 11 }, /* Argument Pointer */ + { "r.base", 3 }, /* Base Reg */ + { "r.dsa", 13 }, /* Stack Pointer */ + { "r.pgt", 4 }, /* Page Origin Table Pointer */ + { "r.sp", 13 }, /* Stack Pointer */ + + { "r.tca", 12 }, /* Pointer to the table of contents */ + { "r.toc", 12 }, /* Pointer to the table of contents */ + + { "r0", 0 }, /* More general purpose registers */ + { "r1", 1 }, + { "r10", 10 }, + { "r11", 11 }, + { "r12", 12 }, + { "r13", 13 }, + { "r14", 14 }, + { "r15", 15 }, + { "r2", 2 }, + { "r3", 3 }, + { "r4", 4 }, + { "r5", 5 }, + { "r6", 6 }, + { "r7", 7 }, + { "r8", 8 }, + { "r9", 9 }, + + { "rbase", 3 }, /* Base Reg */ + + { "rtca", 12 }, /* Pointer to the table of contents */ + { "rtoc", 12 }, /* Pointer to the table of contents */ + + { "sp", 13 }, /* Stack Pointer */ + +}; + +#define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg)) + +/* Given NAME, find the register number associated with that name, return + the integer value associated with the given name or -1 on failure. */ + +static int reg_name_search + PARAMS ((const struct pd_reg *, int, const char * name)); + +static int +reg_name_search (regs, regcount, name) + const struct pd_reg *regs; + int regcount; + const char *name; +{ + int middle, low, high; + int cmp; + + low = 0; + high = regcount - 1; + + do + { + middle = (low + high) / 2; + cmp = strcasecmp (name, regs[middle].name); + if (cmp < 0) + high = middle - 1; + else if (cmp > 0) + low = middle + 1; + else + return regs[middle].value; + } + while (low <= high); + + return -1; +} + +/* + * Summary of register_name(). + * + * in: Input_line_pointer points to 1st char of operand. + * + * out: A expressionS. + * The operand may have been a register: in this case, X_op == O_register, + * X_add_number is set to the register number, and truth is returned. + * Input_line_pointer->(next non-blank) char after operand, or is in its + * original state. + */ + +static boolean +register_name (expressionP) + expressionS *expressionP; +{ + int reg_number; + char *name; + char *start; + char c; + + /* Find the spelling of the operand */ + start = name = input_line_pointer; + if (name[0] == '%' && isalpha (name[1])) + name = ++input_line_pointer; + + else if (!reg_names_p) + return false; + + while (' ' == *name) + name = ++input_line_pointer; + + /* if its a number, treat it as a number */ + /* if its alpha, look to see if it's in the register table */ + if (!isalpha (name[0])) + { + reg_number = get_single_number(); + c = get_symbol_end (); + } + else + { + c = get_symbol_end (); + reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name); + } + + /* if numeric, make sure its not out of bounds */ + if ((0 <= reg_number) && (16 >= reg_number)) + { + expressionP->X_op = O_register; + expressionP->X_add_number = reg_number; + + /* make the rest nice */ + expressionP->X_add_symbol = NULL; + expressionP->X_op_symbol = NULL; + *input_line_pointer = c; /* put back the delimiting char */ + return true; + } + + /* reset the line as if we had not done anything */ + *input_line_pointer = c; /* put back the delimiting char */ + input_line_pointer = start; /* reset input_line pointer */ + return false; +} + +/* Local variables. */ + +/* The type of processor we are assembling for. This is one or more + of the I370_OPCODE flags defined in opcode/i370.h. */ +static int i370_cpu = 0; + +/* The base register to use for opcode with optional operands. + * We define two of these: "text" and "other". Normally, "text" + * would get used in the .text section for branches, while "other" + * gets used in the .data section for address constants. + * + * The idea of a second base register in a different section + * is foreign to the usual HLASM-style semantics; however, it + * allows us to provide support for dynamically loaded libraries, + * by allowing us to place address constants in a section other + * than the text section. The "other" section need not be the + * .data section, it can be any section that isn't the .text section. + * + * Note that HLASM defines a multiple, concurrent .using semantic + * that we do not: in calculating offsets, it uses either the most + * recent .using directive, or the one with the smallest displacement. + * This allows HLASM to support a quasi-block-scope-like behaviour. + * Handy for people writing assembly by hand ... but not supported + * by us. + */ +static int i370_using_text_regno = -1; +static int i370_using_other_regno = -1; + +/* The base address for address literals */ +static expressionS i370_using_text_baseaddr; +static expressionS i370_using_other_baseaddr; + +/* the "other" section, used only for syntax error detection */ +static segT i370_other_section = undefined_section; + +/* Opcode hash table. */ +static struct hash_control *i370_hash; + +/* Macro hash table. */ +static struct hash_control *i370_macro_hash; + +#ifdef OBJ_ELF +/* What type of shared library support to use */ +static enum { SHLIB_NONE, SHLIB_PIC, SHILB_MRELOCATABLE } shlib = SHLIB_NONE; +#endif + +/* Flags to set in the elf header */ +static flagword i370_flags = 0; + +#ifndef WORKING_DOT_WORD +const int md_short_jump_size = 4; +const int md_long_jump_size = 4; +#endif + +#ifdef OBJ_ELF +CONST char *md_shortopts = "l:um:K:VQ:"; +#else +CONST char *md_shortopts = "um:"; +#endif +struct option md_longopts[] = +{ + {NULL, no_argument, NULL, 0} +}; +size_t md_longopts_size = sizeof(md_longopts); + +int +md_parse_option (c, arg) + int c; + char *arg; +{ + switch (c) + { + case 'u': + /* -u means that any undefined symbols should be treated as + external, which is the default for gas anyhow. */ + break; + +#ifdef OBJ_ELF + case 'K': + /* Recognize -K PIC */ + if (strcmp (arg, "PIC") == 0 || strcmp (arg, "pic") == 0) + { + shlib = SHLIB_PIC; + i370_flags |= EF_I370_RELOCATABLE_LIB; + } + else + return 0; + + break; +#endif + + case 'm': + + /* -m360 mean to assemble for the ancient 360 architecture */ + if (strcmp (arg, "360") == 0 || strcmp (arg, "i360") == 0) + i370_cpu = I370_OPCODE_360; + /* -mxa means to assemble for the IBM 370 XA */ + else if (strcmp (arg, "xa") == 0) + i370_cpu = I370_OPCODE_370_XA; + /* -many means to assemble for any architecture (370/XA). */ + else if (strcmp (arg, "any") == 0) + i370_cpu = I370_OPCODE_370; + + else if (strcmp (arg, "regnames") == 0) + reg_names_p = true; + + else if (strcmp (arg, "no-regnames") == 0) + reg_names_p = false; + +#ifdef OBJ_ELF + /* -mrelocatable/-mrelocatable-lib -- warn about initializations that require relocation */ + else if (strcmp (arg, "relocatable") == 0) + { + shlib = SHILB_MRELOCATABLE; + i370_flags |= EF_I370_RELOCATABLE; + } + + else if (strcmp (arg, "relocatable-lib") == 0) + { + shlib = SHILB_MRELOCATABLE; + i370_flags |= EF_I370_RELOCATABLE_LIB; + } + +#endif + else + { + as_bad ("invalid switch -m%s", arg); + return 0; + } + break; + +#ifdef OBJ_ELF + /* -V: SVR4 argument to print version ID. */ + case 'V': + print_version_id (); + break; + + /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section + should be emitted or not. FIXME: Not implemented. */ + case 'Q': + break; + +#endif + + default: + return 0; + } + + return 1; +} + + +/* Set i370_cpu if it is not already set. + Currently defaults to the reasonable superset; + but can be made more fine grained if desred. */ + +static void +i370_set_cpu () +{ + const char *default_os = TARGET_OS; + const char *default_cpu = TARGET_CPU; + + /* override with the superset for the moment. */ + i370_cpu = I370_OPCODE_ESA390_SUPERSET; + if (i370_cpu == 0) + { + if (strcmp (default_cpu, "i360") == 0) + i370_cpu = I370_OPCODE_360; + else if (strcmp (default_cpu, "i370") == 0) + i370_cpu = I370_OPCODE_370; + else if (strcmp (default_cpu, "XA") == 0) + i370_cpu = I370_OPCODE_370_XA; + else + as_fatal ("Unknown default cpu = %s, os = %s", default_cpu, default_os); + } +} + +/* Figure out the BFD architecture to use. */ +// hack alert -- specify the different 370 architectures + +enum bfd_architecture +i370_arch () +{ + return bfd_arch_i370; +} + +/* This function is called when the assembler starts up. It is called + after the options have been parsed and the output file has been + opened. */ + +void +md_begin () +{ + register const struct i370_opcode *op; + const struct i370_opcode *op_end; + const struct i370_macro *macro; + const struct i370_macro *macro_end; + boolean dup_insn = false; + + i370_set_cpu (); + +#ifdef OBJ_ELF + /* Set the ELF flags if desired. */ + if (i370_flags) + bfd_set_private_flags (stdoutput, i370_flags); +#endif + + /* Insert the opcodes into a hash table. */ + i370_hash = hash_new (); + + op_end = i370_opcodes + i370_num_opcodes; + for (op = i370_opcodes; op < op_end; op++) + { + know ((op->opcode & op->mask) == op->opcode); + + if ((op->flags & i370_cpu) != 0) + { + const char *retval; + + retval = hash_insert (i370_hash, op->name, (PTR) op); + if (retval != (const char *) NULL) + { + as_bad ("Internal assembler error for instruction %s", op->name); + dup_insn = true; + } + } + } + + /* Insert the macros into a hash table. */ + i370_macro_hash = hash_new (); + + macro_end = i370_macros + i370_num_macros; + for (macro = i370_macros; macro < macro_end; macro++) + { + if ((macro->flags & i370_cpu) != 0) + { + const char *retval; + + retval = hash_insert (i370_macro_hash, macro->name, (PTR) macro); + if (retval != (const char *) NULL) + { + as_bad ("Internal assembler error for macro %s", macro->name); + dup_insn = true; + } + } + } + + if (dup_insn) + abort (); +} + +/* Insert an operand value into an instruction. */ + +static i370_insn_t +i370_insert_operand (insn, operand, val) + i370_insn_t insn; + const struct i370_operand *operand; + offsetT val; +{ + if (operand->insert) + { + const char *errmsg; + + /* used for 48-bit insn's */ + errmsg = NULL; + insn = (*operand->insert) (insn, (long) val, &errmsg); + if (errmsg) + as_bad ("%s", errmsg); + } + else + { + /* this is used only for 16, 32 bit insn's */ + insn.i[0] |= (((long) val & ((1 << operand->bits) - 1)) + << operand->shift); + } + + return insn; +} + + +#ifdef OBJ_ELF +/* Parse @got, etc. and return the desired relocation. + * Currently, i370 does not support (don't really need to support) any + * of these fancier markups ... for example, no one is going to + * write 'L 6,=V(bogus)@got' it just doesn't make sense (at least to me). + * So basically, we could get away with this routine returning + * BFD_RELOC_UNUSED in all circumstances. However, I'll leave + * in for now in case someone ambitious finds a good use for this stuff ... + * this routine was pretty much just copied from the powerpc code ... + */ +static bfd_reloc_code_real_type +i370_elf_suffix (str_p, exp_p) + char **str_p; + expressionS *exp_p; +{ + struct map_bfd + { + char *string; + int length; + bfd_reloc_code_real_type reloc; + }; + + char ident[20]; + char *str = *str_p; + char *str2; + int ch; + int len; + struct map_bfd *ptr; + +#define MAP(str,reloc) { str, sizeof(str)-1, reloc } + + static struct map_bfd mapping[] = + { + // MAP ("l", BFD_RELOC_LO16), + // MAP ("h", BFD_RELOC_HI16), + // MAP ("ha", BFD_RELOC_HI16_S), + MAP ("fixup", BFD_RELOC_CTOR), /* warnings with -mrelocatable */ + { (char *)0, 0, BFD_RELOC_UNUSED } + }; + + if (*str++ != '@') + return BFD_RELOC_UNUSED; + + for (ch = *str, str2 = ident; + (str2 < ident + sizeof (ident) - 1 + && (isalnum (ch) || ch == '@')); + ch = *++str) + { + *str2++ = (islower (ch)) ? ch : tolower (ch); + } + + *str2 = '\0'; + len = str2 - ident; + + ch = ident[0]; + for (ptr = &mapping[0]; ptr->length > 0; ptr++) + if (ch == ptr->string[0] + && len == ptr->length + && memcmp (ident, ptr->string, ptr->length) == 0) + { + if (exp_p->X_add_number != 0 + && (ptr->reloc == BFD_RELOC_16_GOTOFF + || ptr->reloc == BFD_RELOC_LO16_GOTOFF + || ptr->reloc == BFD_RELOC_HI16_GOTOFF + || ptr->reloc == BFD_RELOC_HI16_S_GOTOFF)) + as_warn ("identifier+constant@got means identifier@got+constant"); + + /* Now check for identifier@suffix+constant */ + if (*str == '-' || *str == '+') + { + char *orig_line = input_line_pointer; + expressionS new_exp; + + input_line_pointer = str; + expression (&new_exp); + if (new_exp.X_op == O_constant) + { + exp_p->X_add_number += new_exp.X_add_number; + str = input_line_pointer; + } + + if (&input_line_pointer != str_p) + input_line_pointer = orig_line; + } + + *str_p = str; + return ptr->reloc; + } + + return BFD_RELOC_UNUSED; +} + +/* Like normal .long/.short/.word, except support @got, etc. */ +/* clobbers input_line_pointer, checks end-of-line. */ +static void +i370_elf_cons (nbytes) + register int nbytes; /* 1=.byte, 2=.word, 4=.long */ +{ + expressionS exp; + bfd_reloc_code_real_type reloc; + + if (is_it_end_of_statement ()) + { + demand_empty_rest_of_line (); + return; + } + + do + { + expression (&exp); + if (exp.X_op == O_symbol + && *input_line_pointer == '@' + && (reloc = i370_elf_suffix (&input_line_pointer, &exp)) != BFD_RELOC_UNUSED) + { + reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc); + int size = bfd_get_reloc_size (reloc_howto); + + if (size > nbytes) + as_bad ("%s relocations do not fit in %d bytes\n", reloc_howto->name, nbytes); + + else + { + register char *p = frag_more ((int) nbytes); + int offset = nbytes - size; + + fix_new_exp (frag_now, p - frag_now->fr_literal + offset, size, &exp, 0, reloc); + } + } + else + emit_expr (&exp, (unsigned int) nbytes); + } + while (*input_line_pointer++ == ','); + + input_line_pointer--; /* Put terminator back into stream. */ + demand_empty_rest_of_line (); +} + + +/* ASCII to EBCDIC conversion table. */ +static unsigned char ascebc[256] = +{ + /*00 NL SH SX EX ET NQ AK BL */ + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, + /*08 BS HT LF VT FF CR SO SI */ + 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + /*10 DL D1 D2 D3 D4 NK SN EB */ + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, + /*18 CN EM SB EC FS GS RS US */ + 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, + /*20 SP ! " # $ % & ' */ + 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, + /*28 ( ) * + , - . / */ + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, + /*30 0 1 2 3 4 5 6 7 */ + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + /*38 8 9 : ; < = > ? */ + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, + /*40 @ A B C D E F G */ + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + /*48 H I J K L M N O */ + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, + /*50 P Q R S T U V W */ + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, + /*58 X Y Z [ \ ] ^ _ */ + 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, + /*60 ` a b c d e f g */ + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*68 h i j k l m n o */ + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + /*70 p q r s t u v w */ + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + /*78 x y z { | } ~ DL */ + 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF +}; + +/* EBCDIC to ASCII conversion table. */ +unsigned char ebcasc[256] = +{ + /*00 NU SH SX EX PF HT LC DL */ + 0x00, 0x01, 0x02, 0x03, 0x00, 0x09, 0x00, 0x7F, + /*08 SM VT FF CR SO SI */ + 0x00, 0x00, 0x00, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + /*10 DE D1 D2 TM RS NL BS IL */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x0A, 0x08, 0x00, + /*18 CN EM CC C1 FS GS RS US */ + 0x18, 0x19, 0x00, 0x00, 0x1C, 0x1D, 0x1E, 0x1F, + /*20 DS SS FS BP LF EB EC */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x17, 0x1B, + /*28 SM C2 EQ AK BL */ + 0x00, 0x00, 0x00, 0x00, 0x05, 0x06, 0x07, 0x00, + /*30 SY PN RS UC ET */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + /*38 C3 D4 NK SU */ + 0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x00, 0x1A, + /*40 SP */ + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*48 . < ( + | */ + 0x00, 0x00, 0x00, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, + /*50 & */ + 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*58 ! $ * ) ; ^ */ + 0x00, 0x00, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, + /*60 - / */ + 0x2D, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*68 , % _ > ? */ + 0x00, 0x00, 0x00, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + /*70 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*78 ` : # @ ' = " */ + 0x00, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + /*80 a b c d e f g */ + 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + /*88 h i { */ + 0x68, 0x69, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x00, + /*90 j k l m n o p */ + 0x00, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + /*98 q r } */ + 0x71, 0x72, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x00, + /*A0 ~ s t u v w x */ + 0x00, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + /*A8 y z [ */ + 0x79, 0x7A, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x00, + /*B0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*B8 ] */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, + /*C0 { A B C D E F G */ + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /*C8 H I */ + 0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*D0 } J K L M N O P */ + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, + /*D8 Q R */ + 0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*E0 \ S T U V W X */ + 0x5C, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + /*E8 Y Z */ + 0x59, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*F0 0 1 2 3 4 5 6 7 */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + /*F8 8 9 */ + 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF +}; + +/* ebcdic translation tables needed for 3270 support */ +static void +i370_ebcdic (unused) + int unused; +{ + char *p, *end; + char delim = 0; + size_t nbytes; + + nbytes = strlen (input_line_pointer); + end = input_line_pointer + nbytes; + while ('\r' == *end) end --; + while ('\n' == *end) end --; + + delim = *input_line_pointer; + if (('\'' == delim) || ('\"' == delim)) { + input_line_pointer ++; + end = rindex (input_line_pointer, delim); + } + + if (end > input_line_pointer) + { + nbytes = end - input_line_pointer +1; + p = frag_more (nbytes); + while (end > input_line_pointer) + { + *p = ascebc [(unsigned char)(*input_line_pointer)]; + ++p; ++input_line_pointer; + } + *p = '\0'; + } + if (delim == *input_line_pointer) ++input_line_pointer; +} + + +/* stub out a couple of routines */ +static void +i370_rmode (unused) + int unused; +{ + as_tsktsk ("rmode ignored"); +} + +static void +i370_dsect (sect) + int sect; +{ + char *save_line = input_line_pointer; + static char section[] = ".data\n"; + + /* Just pretend this is .section .data */ + input_line_pointer = section; + obj_elf_section (sect); + + input_line_pointer = save_line; +} + +static void +i370_csect (unused) + int unused; +{ + as_tsktsk ("csect not supported"); +} + + +/* DC Define Const is only partially supported. + * For samplecode on what to do, look at i370_elf_cons() above. + * This code handles pseudoops of the style + * DC D'3.141592653' # in sysv4, .double 3.14159265 + * DC F'1' # in sysv4, .long 1 + */ +static void +i370_dc(unused) + int unused; +{ + char * p, tmp[50]; + int nbytes=0; + expressionS exp; + char type=0; + + if (is_it_end_of_statement ()) + { + demand_empty_rest_of_line (); + return; + } + + /* figure out the size */ + type = *input_line_pointer++; + switch (type) + { + case 'H': /* 16-bit */ + nbytes = 2; + break; + case 'E': /* 32-bit */ + case 'F': /* 32-bit */ + nbytes = 4; + break; + case 'D': /* 64-bit */ + nbytes = 8; + break; + default: + as_bad ("unsupported DC type"); + return; + } + + /* get rid of pesky quotes */ + if ('\'' == *input_line_pointer) + { + char * close; + ++input_line_pointer; + close = strchr (input_line_pointer, '\''); + if (close) + *close= ' '; + else + as_bad ("missing end-quote"); + } + if ('\"' == *input_line_pointer) + { + char * close; + ++input_line_pointer; + close = strchr (input_line_pointer, '\"'); + if (close) + *close= ' '; + else + as_bad ("missing end-quote"); + } + + switch (type) + { + case 'H': /* 16-bit */ + case 'F': /* 32-bit */ + expression (&exp); + emit_expr (&exp, nbytes); + break; + case 'E': /* 32-bit */ + case 'D': /* 64-bit */ + md_atof (type, tmp, &nbytes); + p = frag_more (nbytes); + memcpy (p, tmp, nbytes); + break; + default: + as_bad ("unsupported DC type"); + return; + } + + demand_empty_rest_of_line (); +} + + +/* provide minimal support for DS Define Storage */ +static void +i370_ds (unused) + int unused; +{ + /* DS 0H or DS 0F or DS 0D */ + if ('0' == *input_line_pointer) + { + int alignment = 0; /* left shift 1<>= 1, ++align2) + ; + if (align != 1) + { + as_bad ("Common alignment not a power of 2"); + ignore_rest_of_line (); + return; + } + } + else + align2 = 0; + + record_alignment (bss_section, align2); + subseg_set (bss_section, 0); + if (align2) + frag_align (align2, 0, 0); + if (S_GET_SEGMENT (symbolP) == bss_section) + symbol_get_frag (symbolP)->fr_symbol = 0; + symbol_set_frag (symbolP, frag_now); + pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size, + (char *) 0); + *pfrag = 0; + S_SET_SIZE (symbolP, size); + S_SET_SEGMENT (symbolP, bss_section); + subseg_set (old_sec, old_subsec); + demand_empty_rest_of_line (); +} + +/* Validate any relocations emitted for -mrelocatable, possibly adding + fixups for word relocations in writable segments, so we can adjust + them at runtime. */ +static void +i370_elf_validate_fix (fixp, seg) + fixS *fixp; + segT seg; +{ + if (fixp->fx_done || fixp->fx_pcrel) + return; + + switch (shlib) + { + case SHLIB_NONE: + case SHLIB_PIC: + return; + + case SHILB_MRELOCATABLE: + if (fixp->fx_r_type <= BFD_RELOC_UNUSED + && fixp->fx_r_type != BFD_RELOC_16_GOTOFF + && fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF + && fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF + && fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF + && fixp->fx_r_type != BFD_RELOC_32_BASEREL + && fixp->fx_r_type != BFD_RELOC_LO16_BASEREL + && fixp->fx_r_type != BFD_RELOC_HI16_BASEREL + && fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL + && strcmp (segment_name (seg), ".got2") != 0 + && strcmp (segment_name (seg), ".dtors") != 0 + && strcmp (segment_name (seg), ".ctors") != 0 + && strcmp (segment_name (seg), ".fixup") != 0 + && strcmp (segment_name (seg), ".stab") != 0 + && strcmp (segment_name (seg), ".gcc_except_table") != 0 + && strcmp (segment_name (seg), ".ex_shared") != 0) + { + if ((seg->flags & (SEC_READONLY | SEC_CODE)) != 0 + || fixp->fx_r_type != BFD_RELOC_CTOR) + { + as_bad_where (fixp->fx_file, fixp->fx_line, + "Relocation cannot be done when using -mrelocatable"); + } + } + return; + } +} +#endif /* OBJ_ELF */ + + + +#define LITERAL_POOL_SUPPORT +#ifdef LITERAL_POOL_SUPPORT +/* Provide support for literal pools within the text section. */ +/* Loosely based on similar code from tc-arm.c */ +/* + * We will use four symbols to locate four parts of the literal pool. + * These four sections contain 64,32,16 and 8-bit constants; we use + * four sections so that all memory access can be appropriately aligned. + * That is, we want to avoid mixing these together so that we don't + * waste space padding out to alignments. The four pointers + * longlong_poolP, word_poolP, etc. point to a symbol labeling the + * start of each pool part. + * + * lit_pool_num increments from zero to infinity and uniquely id's + * -- its used to generate the *_poolP symbol name. + */ + +#define MAX_LITERAL_POOL_SIZE 1024 + +typedef struct literalS +{ + struct expressionS exp; + char * sym_name; + char size; /* 1,2,4 or 8 */ + short offset; +} literalT; + +literalT literals[MAX_LITERAL_POOL_SIZE]; +int next_literal_pool_place = 0; /* Next free entry in the pool */ + +static symbolS *longlong_poolP = NULL; /* 64-bit pool entries */ +static symbolS *word_poolP = NULL; /* 32-bit pool entries */ +static symbolS *short_poolP = NULL; /* 16-bit pool entries */ +static symbolS *byte_poolP = NULL; /* 8-bit pool entries */ + +static int lit_pool_num = 1; + +/* create a new, empty symbol */ +static symbolS * +symbol_make_empty (void) +{ + return symbol_create (FAKE_LABEL_NAME, undefined_section, + (valueT) 0, &zero_address_frag); +} + +/* add an expression to the literal pool */ +static void +add_to_lit_pool (expressionS *exx, char *name, int sz) +{ + int lit_count = 0; + int offset_in_pool = 0; + + /* start a new pool, if necessary */ + if (8 == sz && NULL == longlong_poolP) + longlong_poolP = symbol_make_empty(); + else if (4 == sz && NULL == word_poolP) + word_poolP = symbol_make_empty(); + else if (2 == sz && NULL == short_poolP) + short_poolP = symbol_make_empty(); + else if (1 == sz && NULL == byte_poolP) + byte_poolP = symbol_make_empty(); + + /* Check if this literal value is already in the pool: */ + /* hack alert -- we should probably be checking expressions + * of type O_symbol as well ... */ + /* hack alert XXX this is probably(certainly?) broken for O_big, + * which includes 64-bit long-longs ... + */ + while (lit_count < next_literal_pool_place) + { + if (exx->X_op == O_constant + && literals[lit_count].exp.X_op == exx->X_op + && literals[lit_count].exp.X_add_number == exx->X_add_number + && literals[lit_count].exp.X_unsigned == exx->X_unsigned + && literals[lit_count].size == sz) + break; + else if (literals[lit_count].sym_name + && name + && !strcmp (name, literals[lit_count].sym_name)) + break; + if (sz == literals[lit_count].size) + offset_in_pool += sz; + lit_count ++; + } + + if (lit_count == next_literal_pool_place) /* new entry */ + { + if (next_literal_pool_place > MAX_LITERAL_POOL_SIZE) + { + as_bad("Literal Pool Overflow"); + } + + literals[next_literal_pool_place].exp = *exx; + literals[next_literal_pool_place].size = sz; + literals[next_literal_pool_place].offset = offset_in_pool; + if (name) + { + literals[next_literal_pool_place].sym_name = strdup (name); + } + else + { + literals[next_literal_pool_place].sym_name = NULL; + } + next_literal_pool_place++; + } + + /* ???_poolP points to the begining of the literal pool. + * X_add_number is the offset from the begining of the + * literal pool to this expr minus the location of the most + * recent .using directive. Thus, the grand total value of the + * expression is the distance from .using to the literal. + */ + if (8 == sz) + exx->X_add_symbol = longlong_poolP; + else if (4 == sz) + exx->X_add_symbol = word_poolP; + else if (2 == sz) + exx->X_add_symbol = short_poolP; + else if (1 == sz) + exx->X_add_symbol = byte_poolP; + exx->X_add_number = offset_in_pool; + exx->X_op_symbol = NULL; + + /* If the user has set up a base reg in another section, + * use that; otherwise use the text section. */ + if (0 < i370_using_other_regno) + { + i370_make_relative (exx, &i370_using_other_baseaddr); + } + else + { + i370_make_relative (exx, &i370_using_text_baseaddr); + } +} + +/* The symbol setup for the literal pool is done in two steps. First, + * a symbol that represents the start of the literal pool is created, + * above, in the add_to_pool() routine. This sym ???_poolP. + * However, we don't know what fragment its in until a bit later. + * So we defer the frag_now thing, and the symbol name, until .ltorg time + */ + +/* Can't use symbol_new here, so have to create a symbol and then at + a later date assign it a value. Thats what these functions do */ +static void +symbol_locate (symbolP, name, segment, valu, frag) + symbolS *symbolP; + CONST char *name; /* It is copied, the caller can modify */ + segT segment; /* Segment identifier (SEG_) */ + valueT valu; /* Symbol value */ + fragS *frag; /* Associated fragment */ +{ + size_t name_length; + char *preserved_copy_of_name; + + name_length = strlen (name) + 1; /* +1 for \0 */ + obstack_grow (¬es, name, name_length); + preserved_copy_of_name = obstack_finish (¬es); + + S_SET_NAME (symbolP, preserved_copy_of_name); + + S_SET_SEGMENT (symbolP, segment); + S_SET_VALUE (symbolP, valu); + symbol_clear_list_pointers(symbolP); + + symbol_set_frag (symbolP, frag); + + /* + * Link to end of symbol chain. + */ + { + extern int symbol_table_frozen; + if (symbol_table_frozen) + abort (); + } + + symbol_append (symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); + + obj_symbol_new_hook (symbolP); + +#ifdef tc_symbol_new_hook + tc_symbol_new_hook (symbolP); +#endif + +#define DEBUG_SYMS +#ifdef DEBUG_SYMS + verify_symbol_chain(symbol_rootP, symbol_lastP); +#endif /* DEBUG_SYMS */ +} + +/* i370_addr_offset() will convert operand expressions + * that appear to be absolute into thier base-register + * relative form. These expressions come in two types: + * + * (1) of the form "* + const" * where "*" means + * relative offset since the last using + * i.e. "*" means ".-using_baseaddr" + * + * (2) labels, which are never absolute, but are always + * relative to the last "using". Anything with an alpha + * character is considered to be a label (since symbols + * can never be operands), and since we've already handled + * register operands. For example, "BL .L33" branch low + * to .L33 RX form insn frequently terminates for-loops, + */ +static boolean +i370_addr_offset (expressionS *exx) +{ + char *dot, *lab; + int islabel = 0; + int all_digits = 0; + + /* search for a label; anything with an alpha char will do */ + /* local labels consist of N digits followed by either b or f */ + lab = input_line_pointer; + while (*lab && (',' != *lab) && ('(' != *lab)) + { + if (isdigit(*lab)) + { + all_digits = 1; + } + else if (isalpha(*lab)) + { + if (!all_digits) + { + islabel = 1; + break; + } + else if (('f' == *lab) || ('b' == *lab)) + { + islabel = 1; + break; + } + if (all_digits) + break; + } + else if ('.' != *lab) + break; + ++lab; + } + + /* See if operand has a * in it */ + dot = strchr (input_line_pointer, '*'); + + if (!dot && !islabel) + return false; + + /* replace * with . and let expr munch on it. */ + if (dot) + *dot = '.'; + expression (exx); + + /* OK, now we have to subtract the "using" location */ + /* normally branches appear in the text section only... */ + if (0 == strncmp (now_seg->name, ".text", 5) || 0 > i370_using_other_regno) + { + i370_make_relative (exx, &i370_using_text_baseaddr); + } + else + { + i370_make_relative (exx, &i370_using_other_baseaddr); + } + + /* put the * back */ + if (dot) + *dot = '*'; + + return true; +} + +/* handle address constants of various sorts */ +/* The currently supported types are + * =A(some_symb) + * =V(some_extern) + * =X'deadbeef' hexadecimal + * =F'1234' 32-bit const int + * =H'1234' 16-bit const int + */ +static boolean +i370_addr_cons (expressionS *exp) +{ + char *name; + char *sym_name, delim; + int name_len; + int hex_len=0; + int cons_len=0; + + name = input_line_pointer; + sym_name = input_line_pointer; + /* Find the spelling of the operand */ + if (name[0] == '=' && isalpha (name[1])) + { + name = ++input_line_pointer; + } + else + { + return false; + } + switch (name[0]) + { + case 'A': + case 'V': + /* A == address-of */ + /* V == extern */ + ++input_line_pointer; + expression (exp); + + /* we use a simple string name to collapse together + * multiple refrences to the same address literal + */ + name_len = strcspn (sym_name, ", "); + delim = *(sym_name + name_len); + *(sym_name + name_len) = 0x0; + add_to_lit_pool (exp, sym_name, 4); + *(sym_name + name_len) = delim; + + break; + case 'H': + case 'F': + case 'X': + case 'E': /* single-precision float point */ + case 'D': /* double-precision float point */ + + /* H == 16-bit fixed-point const; expression must be const */ + /* F == fixed-point const; expression must be const */ + /* X == fixed-point const; expression must be const */ + if ('H' == name[0]) cons_len = 2; + else if ('F' == name[0]) cons_len = 4; + else if ('X' == name[0]) cons_len = -1; + else if ('E' == name[0]) cons_len = 4; + else if ('D' == name[0]) cons_len = 8; + + /* extract length, if it is present; hack alert -- assume single-digit + * length */ + if ('L' == name[1]) + { + cons_len = name[2] - '0'; /* should work for ascii and ebcdic */ + input_line_pointer += 2; + } + + ++input_line_pointer; + + /* get rid of pesky quotes */ + if ('\'' == *input_line_pointer) + { + char * close; + ++input_line_pointer; + close = strchr (input_line_pointer, '\''); + if (close) + *close= ' '; + else + as_bad ("missing end-quote"); + } + if ('\"' == *input_line_pointer) + { + char * close; + ++input_line_pointer; + close = strchr (input_line_pointer, '\"'); + if (close) + *close= ' '; + else + as_bad ("missing end-quote"); + } + if (('X' == name[0]) || ('E' == name[0]) || ('D' == name[0])) + { + char tmp[50]; + char *save; + + /* The length of hex constants is specified directly with L, + * or implied through the number of hex digits. For example: + * =X'AB' one byte + * =X'abcd' two bytes + * =X'000000AB' four bytes + * =XL4'AB' four bytes, left-padded withn zero + */ + if (('X' == name[0]) && (0 > cons_len)) + { + save = input_line_pointer; + while (*save) + { + if (isxdigit(*save)) + hex_len++; + save++; + } + cons_len = (hex_len+1) /2; + } + /* I beleive this works even for =XL8'dada0000beeebaaa' + * which should parse out to X_op == O_big + * Note that floats and doubles get represented as + * 0d3.14159265358979 or 0f 2.7 + */ + tmp[0] = '0'; + tmp[1] = name[0]; + tmp[2] = 0; + strcat (tmp, input_line_pointer); + save = input_line_pointer; + input_line_pointer = tmp; + expression (exp); + input_line_pointer = save + (input_line_pointer-tmp-2); + + /* fix up lengths for floats and doubles */ + if (O_big == exp->X_op) + { + exp->X_add_number = cons_len / CHARS_PER_LITTLENUM; + } + } + else + { + expression (exp); + } + /* O_big occurs when more than 4 bytes worth gets parsed */ + if ((exp->X_op != O_constant) && (exp->X_op != O_big)) + { + as_bad ("expression not a constant"); + return false; + } + add_to_lit_pool (exp, 0x0, cons_len); + break; + + default: + as_bad ("Unknown/unsupported address literal type"); + return false; + } + + return true; +} + + +/* Dump the contents of the literal pool that we've accumulated so far. + * This aligns the pool to the size of the largest literal in the pool. + */ + +static void +i370_ltorg (ignore) + int ignore; +{ + int litsize; + int lit_count = 0; + int biggest_literal_size = 0; + int biggest_align = 0; + char pool_name[20]; + + if (strncmp (now_seg->name, ".text", 5)) + { + if (i370_other_section == undefined_section) + { + as_bad (".ltorg without prior .using in section %s", + now_seg->name); + } + if (i370_other_section != now_seg) + { + as_bad (".ltorg in section %s paired to .using in section %s", + now_seg->name, i370_other_section->name); + } + } + if (! longlong_poolP + && ! word_poolP + && ! short_poolP + && ! byte_poolP) + { + /* Nothing to do */ + /* as_tsktsk ("Nothing to put in the pool\n"); */ + return; + } + + /* find largest literal .. 2 4 or 8 */ + lit_count = 0; + while (lit_count < next_literal_pool_place) + { + if (biggest_literal_size < literals[lit_count].size) + biggest_literal_size = literals[lit_count].size; + lit_count ++; + } + if (1 == biggest_literal_size) biggest_align = 0; + else if (2 == biggest_literal_size) biggest_align = 1; + else if (4 == biggest_literal_size) biggest_align = 2; + else if (8 == biggest_literal_size) biggest_align = 3; + else as_bad ("bad alignment of %d bytes in literal pool", biggest_literal_size); + if (0 == biggest_align) biggest_align = 1; + + + /* Align pool for short, word, double word accesses */ + frag_align (biggest_align, 0, 0); + record_alignment (now_seg, biggest_align); + + /* Note that the gas listing will print only the first five + * entries in the pool .... wonder how to make it print more ... + */ + /* output largest literals first, then the smaller ones. */ + for (litsize=8; litsize; litsize /=2) + { + symbolS *current_poolP = NULL; + switch (litsize) + { + case 8: + current_poolP = longlong_poolP; break; + case 4: + current_poolP = word_poolP; break; + case 2: + current_poolP = short_poolP; break; + case 1: + current_poolP = byte_poolP; break; + default: + as_bad ("bad literal size\n"); + } + if (NULL == current_poolP) + continue; + sprintf (pool_name, ".LITP%01d%06d", litsize, lit_pool_num); + symbol_locate (current_poolP, pool_name, now_seg, + (valueT) frag_now_fix (), frag_now); + symbol_table_insert (current_poolP); + + lit_count = 0; + while (lit_count < next_literal_pool_place) + { + if (litsize == literals[lit_count].size) + { +#define EMIT_ADDR_CONS_SYMBOLS +#ifdef EMIT_ADDR_CONS_SYMBOLS + /* create a bogus symbol, add it to the pool ... + * For the most part, I think this is a useless excercise, + * except that having these symbol names in the objects + * is vaguely useful for debugging ... + */ + if (literals[lit_count].sym_name) + { + symbolS * symP = symbol_make_empty(); + symbol_locate (symP, literals[lit_count].sym_name, now_seg, + (valueT) frag_now_fix (), frag_now); + symbol_table_insert (symP); + } +#endif /* EMIT_ADDR_CONS_SYMBOLS */ + + emit_expr (&(literals[lit_count].exp), literals[lit_count].size); + } + lit_count ++; + } + } + + next_literal_pool_place = 0; + longlong_poolP = NULL; + word_poolP = NULL; + short_poolP = NULL; + byte_poolP = NULL; + lit_pool_num++; +} + +#endif /* LITERAL_POOL_SUPPORT */ + + +/* add support for the HLASM-like USING directive to indicate + * the base register to use ... we don't support the full + * hlasm semantics for this ... we merely pluck a base address + * and a register number out. We print a warning if using is + * called multiple times. I suppose we should check to see + * if the regno is valid ... + */ +static void +i370_using (ignore) + int ignore; +{ + expressionS ex, baseaddr; + int iregno; + char *star; + + /* if "*" appears in a using, it means "." */ + /* replace it with "." so that expr doesn't get confused. */ + star = strchr (input_line_pointer, '*'); + if (star) + *star = '.'; + + /* the first arg to using will usually be ".", but it can + * be a more complex exprsssion too ... */ + expression (&baseaddr); + if (star) + *star = '*'; + if (O_constant != baseaddr.X_op + && O_symbol != baseaddr.X_op + && O_uminus != baseaddr.X_op) + { + as_bad (".using: base address expression illegal or too complex"); + } + + if (*input_line_pointer != '\0') ++input_line_pointer; + + /* the second arg to using had better be a register */ + register_name (&ex); + demand_empty_rest_of_line (); + iregno = ex.X_add_number; + + if (0 == strncmp (now_seg->name, ".text", 5)) + { + i370_using_text_baseaddr = baseaddr; + i370_using_text_regno = iregno; + } + else + { + i370_using_other_baseaddr = baseaddr; + i370_using_other_regno = iregno; + i370_other_section = now_seg; + } +} + +static void +i370_drop (ignore) + int ignore; +{ + expressionS ex; + int iregno; + + register_name (&ex); + demand_empty_rest_of_line (); + iregno = ex.X_add_number; + + if (0 == strncmp (now_seg->name, ".text", 5)) + { + if (iregno != i370_using_text_regno) + { + as_bad ("droping register %d in section %s does not match using register %d", + iregno, now_seg->name, i370_using_text_regno); + } + i370_using_text_regno = -1; + i370_using_text_baseaddr.X_op = O_absent; + } + else + { + if (iregno != i370_using_other_regno) + { + as_bad ("droping register %d in section %s does not match using register %d", + iregno, now_seg->name, i370_using_other_regno); + } + if (i370_other_section != now_seg) + { + as_bad ("droping register %d in section %s previously used in section %s", + iregno, now_seg->name, i370_other_section->name); + } + i370_using_other_regno = -1; + i370_using_other_baseaddr.X_op = O_absent; + i370_other_section = undefined_section; + } +} + +/* Make the first argument an address-relative expression + * by subtracting the second argument. + */ +static void +i370_make_relative (expressionS *exx, expressionS *baseaddr) +{ + + if (O_constant == baseaddr->X_op) + { + exx->X_op = O_symbol; + exx->X_add_number -= baseaddr->X_add_number; + } + else if (O_symbol == baseaddr->X_op) + { + exx->X_op = O_subtract; + exx->X_op_symbol = baseaddr->X_add_symbol; + exx->X_add_number -= baseaddr->X_add_number; + } + else if (O_uminus == baseaddr->X_op) + { + exx->X_op = O_add; + exx->X_op_symbol = baseaddr->X_add_symbol; + exx->X_add_number += baseaddr->X_add_number; + } + else + { + as_bad ("Missing or bad .using directive"); + } +} + +/* We need to keep a list of fixups. We can't simply generate them as + we go, because that would require us to first create the frag, and + that would screw up references to ``.''. */ + +struct i370_fixup +{ + expressionS exp; + int opindex; + bfd_reloc_code_real_type reloc; +}; + +#define MAX_INSN_FIXUPS (5) + +/* This routine is called for each instruction to be assembled. */ + +void +md_assemble (str) + char *str; +{ + char *s, *opcode_str; + const struct i370_opcode *opcode; + i370_insn_t insn; + const unsigned char *opindex_ptr; + int have_optional_index, have_optional_basereg, have_optional_reg; + int skip_optional_index, skip_optional_basereg, skip_optional_reg; + int use_text=0, use_other=0; + int off_by_one; + struct i370_fixup fixups[MAX_INSN_FIXUPS]; + int fc; + char *f; + int i; +#ifdef OBJ_ELF + bfd_reloc_code_real_type reloc; +#endif + + /* Get the opcode. */ + for (s = str; *s != '\0' && ! isspace (*s); s++) + ; + if (*s != '\0') + *s++ = '\0'; + opcode_str = str; + + /* Look up the opcode in the hash table. */ + opcode = (const struct i370_opcode *) hash_find (i370_hash, str); + if (opcode == (const struct i370_opcode *) NULL) + { + const struct i370_macro *macro; + + assert (i370_macro_hash); + macro = (const struct i370_macro *) hash_find (i370_macro_hash, str); + if (macro == (const struct i370_macro *) NULL) + as_bad ("Unrecognized opcode: `%s'", str); + else + i370_macro (s, macro); + + return; + } + + insn = opcode->opcode; + + str = s; + while (isspace (*str)) + ++str; + + /* I370 operands are either expressions or address constants. + Many operand types are optional. The optional operands + are always surrounded by parens, and are used to denote the base + register ... e.g. "A R1, D2" or "A R1, D2(,B2) as opposed to + the fully-formed "A R1, D2(X2,B2)". Note also the = sign, + such as A R1,=A(i) where the address-of operator =A implies + use of both a base register, and a missing index register. + + So, before we start seriously parsing the operands, we check + to see if we have an optional operand, and, if we do, we count + the number of commas to see which operand should be omitted. */ + + have_optional_index = have_optional_basereg = have_optional_reg = 0; + for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) + { + const struct i370_operand *operand; + operand = &i370_operands[*opindex_ptr]; + if ((operand->flags & I370_OPERAND_INDEX) != 0) + have_optional_index = 1; + if ((operand->flags & I370_OPERAND_BASE) != 0) + have_optional_basereg = 1; + if ((operand->flags & I370_OPERAND_OPTIONAL) != 0) + have_optional_reg = 1; + } + + skip_optional_index = skip_optional_basereg = skip_optional_reg = 0; + if (have_optional_index || have_optional_basereg) + { + unsigned int opcount, nwanted; + + /* There is an optional operand. Count the number of + commas and open-parens in the input line. */ + if (*str == '\0') + opcount = 0; + else + { + opcount = 1; + s = str; + while ((s = strpbrk (s, ",(=")) != (char *) NULL) + { + ++opcount; + ++s; + if (',' == *s) ++s; /* avoid counting things like (, */ + if ('=' == *s) { ++s; --opcount; } + } + } + + /* If there are fewer operands in the line then are called + for by the instruction, we want to skip the optional + operand. */ + nwanted = strlen (opcode->operands); + if (have_optional_index) + { + if (opcount < nwanted) + skip_optional_index = 1; + if (have_optional_basereg && ((opcount+1) < nwanted)) + skip_optional_basereg = 1; + if (have_optional_reg && ((opcount+1) < nwanted)) + skip_optional_reg = 1; + } + else + { + if (have_optional_basereg && (opcount < nwanted)) + skip_optional_basereg = 1; + if (have_optional_reg && (opcount < nwanted)) + skip_optional_reg = 1; + } + } + + /* Perform some off-by-one hacks on the length field of certain instructions. + * Its such a shame to have to do this, but the problem is that HLASM got + * defined so that the lengths differ by one from the actual machine instructions. + * this code should probably be moved to a special inster-operand routine. + * Sigh. Affected instructions are Compare Logical, Move and Exclusive OR + * hack alert -- aren't *all* SS instructions affected ?? + */ + off_by_one = 0; + if (0 == strcasecmp ("CLC", opcode->name) + || 0 == strcasecmp ("ED", opcode->name) + || 0 == strcasecmp ("EDMK", opcode->name) + || 0 == strcasecmp ("MVC", opcode->name) + || 0 == strcasecmp ("MVCIN", opcode->name) + || 0 == strcasecmp ("MVN", opcode->name) + || 0 == strcasecmp ("MVZ", opcode->name) + || 0 == strcasecmp ("NC", opcode->name) + || 0 == strcasecmp ("OC", opcode->name) + || 0 == strcasecmp ("XC", opcode->name)) + off_by_one = 1; + + /* Gather the operands. */ + fc = 0; + for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) + { + const struct i370_operand *operand; + const char *errmsg; + char *hold; + expressionS ex; + + operand = &i370_operands[*opindex_ptr]; + errmsg = NULL; + + /* If this is an index operand, and we are skipping it, + just insert a zero. */ + if (skip_optional_index && + ((operand->flags & I370_OPERAND_INDEX) != 0)) + { + insn = i370_insert_operand (insn, operand, 0); + continue; + } + + /* If this is the base operand, and we are skipping it, + just insert the current using basreg. */ + if (skip_optional_basereg && + ((operand->flags & I370_OPERAND_BASE) != 0)) + { + int basereg = -1; + if (use_text) + { + if (0 == strncmp (now_seg->name, ".text", 5) + || 0 > i370_using_other_regno) + { + basereg = i370_using_text_regno; + } + else + { + basereg = i370_using_other_regno; + } + } + else if (use_other) + { + if (0 > i370_using_other_regno) + { + basereg = i370_using_text_regno; + } + else + { + basereg = i370_using_other_regno; + } + } + if (0 > basereg) + { + as_bad ("not using any base register"); + } + insn = i370_insert_operand (insn, operand, basereg); + continue; + } + + /* If this is an optional operand, and we are skipping it, + Use zero (since a non-zero value would denote a register) */ + if (skip_optional_reg + && ((operand->flags & I370_OPERAND_OPTIONAL) != 0)) + { + insn = i370_insert_operand (insn, operand, 0); + continue; + } + + /* Gather the operand. */ + hold = input_line_pointer; + input_line_pointer = str; + + /* register names are only allowed where there are registers ... */ + if ((operand->flags & I370_OPERAND_GPR) != 0) + { + /* quickie hack to get past things like (,r13) */ + if (skip_optional_index && (',' == *input_line_pointer)) + { + *input_line_pointer = ' '; + input_line_pointer ++; + } + if (! register_name (&ex)) + { + as_bad ("expecting a register for operand %d", + opindex_ptr - opcode->operands + 1); + } + } + + /* check for a address constant expression */ + /* We will put PSW-relative addresses in the text section, + * and adress literals in the .data (or other) section. */ + else if (i370_addr_cons (&ex)) + use_other=1; + else if (i370_addr_offset (&ex)) + use_text=1; + else expression (&ex); + + str = input_line_pointer; + input_line_pointer = hold; + + /* perform some off-by-one hacks on the length field of certain instructions. + * Its such a shame to have to do this, but the problem is that HLASM got + * defined so that the programmer specifies a length that is one greater + * than what the machine instruction wants. + * Sigh. + */ + if (off_by_one && (0 == strcasecmp ("SS L", operand->name))) + { + ex.X_add_number --; + } + + if (ex.X_op == O_illegal) + as_bad ("illegal operand"); + else if (ex.X_op == O_absent) + as_bad ("missing operand"); + else if (ex.X_op == O_register) + { + insn = i370_insert_operand (insn, operand, ex.X_add_number); + } + else if (ex.X_op == O_constant) + { +#ifdef OBJ_ELF + /* Allow @HA, @L, @H on constants. + * Well actually, no we don't; there really don't make sense + * (at least not to me) for the i370. However, this code is + * left here for any dubious future expansion reasons ... */ + char *orig_str = str; + + if ((reloc = i370_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED) + switch (reloc) + { + default: + str = orig_str; + break; + + case BFD_RELOC_LO16: + /* X_unsigned is the default, so if the user has done + something which cleared it, we always produce a + signed value. */ + ex.X_add_number = (((ex.X_add_number & 0xffff) + ^ 0x8000) + - 0x8000); + break; + + case BFD_RELOC_HI16: + ex.X_add_number = (ex.X_add_number >> 16) & 0xffff; + break; + + case BFD_RELOC_HI16_S: + ex.X_add_number = (((ex.X_add_number >> 16) & 0xffff) + + ((ex.X_add_number >> 15) & 1)); + break; + } +#endif + insn = i370_insert_operand (insn, operand, ex.X_add_number); + } +#ifdef OBJ_ELF + else if ((reloc = i370_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED) + { + as_tsktsk ("md_assemble(): suffixed relocations not supported\n"); + + /* We need to generate a fixup for this expression. */ + if (fc >= MAX_INSN_FIXUPS) + as_fatal ("too many fixups"); + fixups[fc].exp = ex; + fixups[fc].opindex = 0; + fixups[fc].reloc = reloc; + ++fc; + } +#endif /* OBJ_ELF */ + + else + { + /* We need to generate a fixup for this expression. */ + /* Typically, the expression will just be a symbol ... + * printf ("insn %s needs fixup for %s \n", + * opcode->name, ex.X_add_symbol->bsym->name); + */ + + if (fc >= MAX_INSN_FIXUPS) + as_fatal ("too many fixups"); + fixups[fc].exp = ex; + fixups[fc].opindex = *opindex_ptr; + fixups[fc].reloc = BFD_RELOC_UNUSED; + ++fc; + } + + /* skip over delimiter (close paren, or comma) */ + if ((')' == *str) && (',' == *(str+1))) + ++str; + if (*str != '\0') + ++str; + } + + while (isspace (*str)) + ++str; + + if (*str != '\0') + as_bad ("junk at end of line: `%s'", str); + + /* Write out the instruction. */ + f = frag_more (opcode->len); + if (4 >= opcode->len) + { + md_number_to_chars (f, insn.i[0], opcode->len); + } + else + { + md_number_to_chars (f, insn.i[0], 4); + if (6 == opcode->len) + { + md_number_to_chars ((f+4), ((insn.i[1])>>16), 2); + } + else + { + /* not used --- don't have any 8 byte instructions */ + as_bad ("Internal Error: bad instruction length"); + md_number_to_chars ((f+4), insn.i[1], opcode->len -4); + } + } + + /* Create any fixups. At this point we do not use a + bfd_reloc_code_real_type, but instead just use the + BFD_RELOC_UNUSED plus the operand index. This lets us easily + handle fixups for any operand type, although that is admittedly + not a very exciting feature. We pick a BFD reloc type in + md_apply_fix. */ + for (i = 0; i < fc; i++) + { + const struct i370_operand *operand; + + operand = &i370_operands[fixups[i].opindex]; + if (fixups[i].reloc != BFD_RELOC_UNUSED) + { + reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc); + int size; + fixS *fixP; + + if (!reloc_howto) + abort (); + + size = bfd_get_reloc_size (reloc_howto); + + if (size < 1 || size > 4) + abort(); + + printf (" gwana doo fixup %d \n", i); + fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, size, + &fixups[i].exp, reloc_howto->pc_relative, + fixups[i].reloc); + + /* Turn off complaints that the addend is too large for things like + foo+100000@ha. */ + switch (fixups[i].reloc) + { + case BFD_RELOC_16_GOTOFF: + case BFD_RELOC_LO16: + case BFD_RELOC_HI16: + case BFD_RELOC_HI16_S: + fixP->fx_no_overflow = 1; + break; + default: + break; + } + } + else + { + fix_new_exp (frag_now, f - frag_now->fr_literal, opcode->len, + &fixups[i].exp, + (operand->flags & I370_OPERAND_RELATIVE) != 0, + ((bfd_reloc_code_real_type) + (fixups[i].opindex + (int) BFD_RELOC_UNUSED))); + } + } +} + +/* Handle a macro. Gather all the operands, transform them as + described by the macro, and call md_assemble recursively. All the + operands are separated by commas; we don't accept parentheses + around operands here. */ + +static void +i370_macro (str, macro) + char *str; + const struct i370_macro *macro; +{ + char *operands[10]; + unsigned int count; + char *s; + unsigned int len; + const char *format; + int arg; + char *send; + char *complete; + + /* Gather the users operands into the operands array. */ + count = 0; + s = str; + while (1) + { + if (count >= sizeof operands / sizeof operands[0]) + break; + operands[count++] = s; + s = strchr (s, ','); + if (s == (char *) NULL) + break; + *s++ = '\0'; + } + + if (count != macro->operands) + { + as_bad ("wrong number of operands"); + return; + } + + /* Work out how large the string must be (the size is unbounded + because it includes user input). */ + len = 0; + format = macro->format; + while (*format != '\0') + { + if (*format != '%') + { + ++len; + ++format; + } + else + { + arg = strtol (format + 1, &send, 10); + know (send != format && arg >= 0 && arg < count); + len += strlen (operands[arg]); + format = send; + } + } + + /* Put the string together. */ + complete = s = (char *) alloca (len + 1); + format = macro->format; + while (*format != '\0') + { + if (*format != '%') + *s++ = *format++; + else + { + arg = strtol (format + 1, &send, 10); + strcpy (s, operands[arg]); + s += strlen (s); + format = send; + } + } + *s = '\0'; + + /* Assemble the constructed instruction. */ + md_assemble (complete); +} + +#ifdef OBJ_ELF +/* For ELF, add support for SHF_EXCLUDE and SHT_ORDERED */ + +int +i370_section_letter (letter, ptr_msg) + int letter; + char **ptr_msg; +{ + if (letter == 'e') + return SHF_EXCLUDE; + + *ptr_msg = "Bad .section directive: want a,w,x,e in string"; + return 0; +} + +int +i370_section_word (str, len) + char *str; + size_t len; +{ + if (len == 7 && strncmp (str, "exclude", 7) == 0) + return SHF_EXCLUDE; + + return -1; +} + +int +i370_section_type (str, len) + char *str; + size_t len; +{ + if (len == 7 && strncmp (str, "ordered", 7) == 0) + return SHT_ORDERED; + + return -1; +} + +int +i370_section_flags (flags, attr, type) + int flags; + int attr; + int type; +{ + if (type == SHT_ORDERED) + flags |= SEC_ALLOC | SEC_LOAD | SEC_SORT_ENTRIES; + + if (attr & SHF_EXCLUDE) + flags |= SEC_EXCLUDE; + + return flags; +} +#endif /* OBJ_ELF */ + + +/* Pseudo-op handling. */ + +/* The .byte pseudo-op. This is similar to the normal .byte + pseudo-op, but it can also take a single ASCII string. */ + +static void +i370_byte (ignore) + int ignore; +{ + if (*input_line_pointer != '\"') + { + cons (1); + return; + } + + /* Gather characters. A real double quote is doubled. Unusual + characters are not permitted. */ + ++input_line_pointer; + while (1) + { + char c; + + c = *input_line_pointer++; + + if (c == '\"') + { + if (*input_line_pointer != '\"') + break; + ++input_line_pointer; + } + + FRAG_APPEND_1_CHAR (c); + } + + demand_empty_rest_of_line (); +} + +/* The .tc pseudo-op. This is used when generating XCOFF and ELF. + This takes two or more arguments. + + When generating XCOFF output, the first argument is the name to + give to this location in the toc; this will be a symbol with class + TC. The rest of the arguments are 4 byte values to actually put at + this location in the TOC; often there is just one more argument, a + relocateable symbol reference. + + When not generating XCOFF output, the arguments are the same, but + the first argument is simply ignored. */ + +static void +i370_tc (ignore) + int ignore; +{ + + /* Skip the TOC symbol name. */ + while (is_part_of_name (*input_line_pointer) + || *input_line_pointer == '[' + || *input_line_pointer == ']' + || *input_line_pointer == '{' + || *input_line_pointer == '}') + ++input_line_pointer; + + /* Align to a four byte boundary. */ + frag_align (2, 0, 0); + record_alignment (now_seg, 2); + + if (*input_line_pointer != ',') + demand_empty_rest_of_line (); + else + { + ++input_line_pointer; + cons (4); + } +} + +/* Turn a string in input_line_pointer into a floating point constant + of type type, and store the appropriate bytes in *litp. The number + of LITTLENUMS emitted is stored in *sizep . An error message is + returned, or NULL on OK. */ + +char * +md_atof (type, litp, sizep) + int type; + char *litp; + int *sizep; +{ + int prec; + LITTLENUM_TYPE words[4]; + char *t; + int i; + + switch (type) + { + case 'f': + case 'E': + type = 'f'; + prec = 2; + break; + + case 'd': + case 'D': + type = 'd'; + prec = 4; + break; + + default: + *sizep = 0; + return "bad call to md_atof"; + } + + /* 360/370/390 have two float formats: an old, funky 360 single-precision + * format, and the ieee format. Support only the ieee format. */ + t = atof_ieee (input_line_pointer, type, words); + if (t) + input_line_pointer = t; + + *sizep = prec * 2; + + for (i = 0; i < prec; i++) + { + md_number_to_chars (litp, (valueT) words[i], 2); + litp += 2; + } + + return NULL; +} + +/* Write a value out to the object file, using the appropriate + endianness. */ + +void +md_number_to_chars (buf, val, n) + char *buf; + valueT val; + int n; +{ + number_to_chars_bigendian (buf, val, n); +} + +/* Align a section (I don't know why this is machine dependent). */ + +valueT +md_section_align (seg, addr) + asection *seg; + valueT addr; +{ + int align = bfd_get_section_alignment (stdoutput, seg); + + return (addr + (1 << align) - 1) & (-1 << align); +} + +/* We don't have any form of relaxing. */ + +int +md_estimate_size_before_relax (fragp, seg) + fragS *fragp; + asection *seg; +{ + abort (); + return 0; +} + +/* Convert a machine dependent frag. We never generate these. */ + +void +md_convert_frag (abfd, sec, fragp) + bfd *abfd; + asection *sec; + fragS *fragp; +{ + abort (); +} + +/* We have no need to default values of symbols. */ + +/*ARGSUSED*/ +symbolS * +md_undefined_symbol (name) + char *name; +{ + return 0; +} + +/* Functions concerning relocs. */ + +/* The location from which a PC relative jump should be calculated, + given a PC relative reloc. */ + +long +md_pcrel_from_section (fixp, sec) + fixS *fixp; + segT sec; +{ + return fixp->fx_frag->fr_address + fixp->fx_where; +} + + +/* Apply a fixup to the object code. This is called for all the + fixups we generated by the call to fix_new_exp, above. In the call + above we used a reloc code which was the largest legal reloc code + plus the operand index. Here we undo that to recover the operand + index. At this point all symbol values should be fully resolved, + and we attempt to completely resolve the reloc. If we can not do + that, we determine the correct reloc code and put it back in the + fixup. + + See gas/cgen.c for more sample code and explanations of what's + going on here ... +*/ + +int +md_apply_fix3 (fixp, valuep, seg) + fixS *fixp; + valueT *valuep; + segT seg; +{ + valueT value; + + value = *valuep; + if (fixp->fx_addsy != NULL) + { + /* Notes: + Branches to labels will come in here with fixp->fx_pcrel set to 1 + and fixp->fx_subsy not null, and holding the value of the base + (i.e. the value of the .using). These we want to ignore. + + 'Strong' and 'weak' symbols will come in here with + fixp->fx_pcrel==0, fixp->fx_addsy defined, and + *valuep holding the value of the symbol. + + 'Strong' symbols will have S_GET_VALUE(fx_addsy) equal to zero, + whereas 'weak' symbols will have S_GET_VALUE(fx_addsy) set to the + symbol value (usually). + + We want to subtract S_GET_VALUE(fx_addsy) if it set, and + for all practical purposes, do a fixup with value zero. This + is because the linker/loader, at a later time, will do this + fixup with the correct value. If we fixup now with a value, + it will get double-fixed, leading to garbage. + + Note that subsy will also be set for strong/weak symbols + when the user program was compiled with -g. In that case, + subsy will hold the base address (i.e. the .using address). + */ + + if (fixp->fx_addsy->sy_used_in_reloc + && S_GET_SEGMENT (fixp->fx_addsy) != absolute_section + && S_GET_SEGMENT (fixp->fx_addsy) != undefined_section + && ! bfd_is_com_section (S_GET_SEGMENT (fixp->fx_addsy))) + value -= S_GET_VALUE (fixp->fx_addsy); + +#ifdef DEBUG + printf ("\nmd_apply_fix3: symbol %s at 0x%x (%s:%d) val=0x%x addend=0x%x\n", + S_GET_NAME (fixp->fx_addsy), + fixp->fx_frag->fr_address + fixp->fx_where, + fixp->fx_file, fixp->fx_line, + S_GET_VALUE (fixp->fx_addsy), value); +#endif + } + else + { + fixp->fx_done = 1; + return 1; + } + + /* Apply fixups to operands. Note that there should be no relocations + for any operands, since no instruction ever takes an operand + that requires reloc. */ + if ((int) fixp->fx_r_type >= (int) BFD_RELOC_UNUSED) + { + int opindex; + const struct i370_operand *operand; + char *where; + i370_insn_t insn; + + opindex = (int) fixp->fx_r_type - (int) BFD_RELOC_UNUSED; + + operand = &i370_operands[opindex]; + +#ifdef DEBUG + printf ("\nmd_apply_fix3: fixup operand %s at 0x%x in %s:%d addend=0x%x\n", + operand->name, + fixp->fx_frag->fr_address + fixp->fx_where, + fixp->fx_file, fixp->fx_line, + value); +#endif + /* Fetch the instruction, insert the fully resolved operand + value, and stuff the instruction back again. + fisxp->fx_size is the length of the instruction. */ + where = fixp->fx_frag->fr_literal + fixp->fx_where; + insn.i[0] = bfd_getb32 ((unsigned char *) where); + if (6 <= fixp->fx_size) + { /* deal with 48-bit insn's */ + insn.i[1] = bfd_getb32 (((unsigned char *) where)+4); + } + insn = i370_insert_operand (insn, operand, (offsetT) value); + bfd_putb32 ((bfd_vma) insn.i[0], (unsigned char *) where); + if (6 <= fixp->fx_size) + { /* deal with 48-bit insn's */ + bfd_putb32 ((bfd_vma) insn.i[1], (((unsigned char *) where)+4)); + } + + /* we are done, right? right !! */ + fixp->fx_done = 1; + if (fixp->fx_done) + { + /* Nothing else to do here. */ + return 1; + } + + /* Determine a BFD reloc value based on the operand information. + We are only prepared to turn a few of the operands into + relocs. In fact, we support *zero* operand relocations ... + Why? Because we are not expecting the compiler to generate + any operands that need relocation. Due to the 12-bit naturew of + i370 addressing, this would be unusual. */ +#if 0 + if ((operand->flags & I370_OPERAND_RELATIVE) != 0 + && operand->bits == 12 + && operand->shift == 0) + fixp->fx_r_type = BFD_RELOC_I370_D12; + else +#endif + { + char *sfile; + unsigned int sline; + + /* Use expr_symbol_where to see if this is an expression + symbol. */ + if (expr_symbol_where (fixp->fx_addsy, &sfile, &sline)) + as_bad_where (fixp->fx_file, fixp->fx_line, + "unresolved expression that must be resolved"); + else + as_bad_where (fixp->fx_file, fixp->fx_line, + "unsupported relocation type"); + fixp->fx_done = 1; + return 1; + } + } + else + { + /* We branch to here if the fixup is not to a symbol that + * appears in an instruction operand, but is rather some + * declared storage. + */ +#ifdef OBJ_ELF + i370_elf_validate_fix (fixp, seg); +#endif +#ifdef DEBUG + printf ("md_apply_fix3: reloc case %d in segment %s %s:%d\n", + fixp->fx_r_type, segment_name (seg), fixp->fx_file, fixp->fx_line); + printf ("\tcurrent fixup value is 0x%x \n", value); +#endif + switch (fixp->fx_r_type) + { + case BFD_RELOC_32: + case BFD_RELOC_CTOR: + if (fixp->fx_pcrel) + fixp->fx_r_type = BFD_RELOC_32_PCREL; + /* fall through */ + + case BFD_RELOC_RVA: + case BFD_RELOC_32_PCREL: + case BFD_RELOC_32_BASEREL: +#ifdef DEBUG + printf ("\t32 bit relocation at 0x%x\n", + fixp->fx_frag->fr_address + fixp->fx_where); +#endif + md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, + value, 4); + break; + + case BFD_RELOC_LO16: + case BFD_RELOC_16: + if (fixp->fx_pcrel) + as_bad_where (fixp->fx_file, fixp->fx_line, + "cannot emit PC relative %s relocation%s%s", + bfd_get_reloc_code_name (fixp->fx_r_type), + fixp->fx_addsy != NULL ? " against " : "", + (fixp->fx_addsy != NULL + ? S_GET_NAME (fixp->fx_addsy) + : "")); + + md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, + value, 2); + break; + + /* This case happens when you write, for example, + lis %r3,(L1-L2)@ha + where L1 and L2 are defined later. */ + case BFD_RELOC_HI16: + if (fixp->fx_pcrel) + abort (); + md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, + value >> 16, 2); + break; + case BFD_RELOC_HI16_S: + if (fixp->fx_pcrel) + abort (); + md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, + (value + 0x8000) >> 16, 2); + break; + + case BFD_RELOC_8: + if (fixp->fx_pcrel) + abort (); + + md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, + value, 1); + break; + + default: + fprintf(stderr, + "Gas failure, reloc value %d\n", fixp->fx_r_type); + fflush(stderr); + abort (); + } + } + + fixp->fx_addnumber = value; + + return 1; +} + +/* Generate a reloc for a fixup. */ + +arelent * +tc_gen_reloc (seg, fixp) + asection *seg; + fixS *fixp; +{ + arelent *reloc; + + reloc = (arelent *) xmalloc (sizeof (arelent)); + + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); + reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; + reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); + if (reloc->howto == (reloc_howto_type *) NULL) + { + as_bad_where (fixp->fx_file, fixp->fx_line, + "reloc %d not supported by object file format", (int)fixp->fx_r_type); + return NULL; + } + reloc->addend = fixp->fx_addnumber; + +#ifdef DEBUG + printf ("\ngen_reloc(): sym %s (%s:%d) at addr 0x%x addend=0x%x\n", + fixp->fx_addsy->bsym->name, + fixp->fx_file, fixp->fx_line, + reloc->address, reloc->addend); +#endif + + return reloc; +} diff --git a/gas/config/tc-i370.h b/gas/config/tc-i370.h new file mode 100644 index 0000000..8f32fa8 --- /dev/null +++ b/gas/config/tc-i370.h @@ -0,0 +1,104 @@ +/* tc-i370.h -- Header file for tc-i370.c. + Copyright (C) 1994, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Support. + + 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 2, 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. */ + +#define TC_I370 + +#ifdef ANSI_PROTOTYPES +struct fix; +#endif + +/* Set the endianness we are using. Default to big endian. */ +#ifndef TARGET_BYTES_BIG_ENDIAN +#define TARGET_BYTES_BIG_ENDIAN 1 +#endif + +#ifndef BFD_ASSEMBLER + #error I370 support requires BFD_ASSEMBLER +#endif + +/* The target BFD architecture. */ +#define TARGET_ARCH (i370_arch ()) +extern enum bfd_architecture i370_arch PARAMS ((void)); + +/* Whether or not the target is big endian */ +extern int target_big_endian; + +/* The target BFD format. */ +#ifdef OBJ_ELF +#define TARGET_FORMAT ("elf32-i370") +#endif + +/* Permit temporary numeric labels. */ +#define LOCAL_LABELS_FB 1 + +/* $ is used to refer to the current location. */ +/* #define DOLLAR_DOT */ + +#ifdef OBJ_ELF +#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */ +#endif + +/* We don't need to handle .word strangely. */ +#define WORKING_DOT_WORD + +/* We set the fx_done field appropriately in md_apply_fix. */ +#define TC_HANDLES_FX_DONE + + +#ifdef OBJ_ELF + +/* Branch prediction relocations must force relocation. */ +#define TC_FORCE_RELOCATION_SECTION(FIXP,SEC) 1 + +/* Support for SHF_EXCLUDE and SHT_ORDERED */ +extern int i370_section_letter PARAMS ((int, char **)); +extern int i370_section_type PARAMS ((char *, size_t)); +extern int i370_section_word PARAMS ((char *, size_t)); +extern int i370_section_flags PARAMS ((int, int, int)); + +#define md_elf_section_letter(LETTER, PTR_MSG) i370_section_letter (LETTER, PTR_MSG) +#define md_elf_section_type(STR, LEN) i370_section_type (STR, LEN) +#define md_elf_section_word(STR, LEN) i370_section_word (STR, LEN) +#define md_elf_section_flags(FLAGS, ATTR, TYPE) i370_section_flags (FLAGS, ATTR, TYPE) + +#define tc_comment_chars i370_comment_chars +extern const char *i370_comment_chars; + +/* We must never ever try to resolve references to externally visible + symbols in the assembler, because the .o file might go into a shared + library, and some other shared library might override that symbol. */ +#define TC_RELOC_RTSYM_LOC_FIXUP(FIX) \ + ((FIX)->fx_addsy == NULL \ + || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \ + && ! S_IS_WEAK ((FIX)->fx_addsy) \ + && S_IS_DEFINED ((FIX)->fx_addsy) \ + && ! S_IS_COMMON ((FIX)->fx_addsy))) + +#endif /* OBJ_ELF */ + +/* call md_apply_fix3 with segment instead of md_apply_fix */ +#define MD_APPLY_FIX3 + +/* call md_pcrel_from_section, not md_pcrel_from */ +#define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from_section(FIXP, SEC) +extern long md_pcrel_from_section PARAMS ((struct fix *, segT)); + +#define md_operand(x) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 7149d71..3a01bab 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -1,5 +1,5 @@ /* i386.c -- Assemble code for the Intel 80386 - Copyright (C) 1989, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright (C) 1989, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -32,14 +32,14 @@ #include "subsegs.h" #include "opcode/i386.h" -#ifndef TC_RELOC -#define TC_RELOC(X,Y) (Y) -#endif - #ifndef REGISTER_WARNINGS #define REGISTER_WARNINGS 1 #endif +#ifndef INFER_ADDR_PREFIX +#define INFER_ADDR_PREFIX 1 +#endif + #ifndef SCALE1_WHEN_NO_INDEX /* Specifying a scale factor besides 1 when there is no index is futile. eg. `mov (%ebx,2),%al' does exactly the same as @@ -59,6 +59,7 @@ static int fits_in_signed_word PARAMS ((long)); static int smallest_imm_type PARAMS ((long)); static int add_prefix PARAMS ((unsigned int)); static void set_16bit_code_flag PARAMS ((int)); +static void set_16bit_gcc_code_flag PARAMS((int)); static void set_intel_syntax PARAMS ((int)); #ifdef BFD_ASSEMBLER @@ -69,6 +70,13 @@ static bfd_reloc_code_real_type reloc /* 'md_assemble ()' gathers together information and puts it into a i386_insn. */ +union i386_op + { + expressionS *disps; + expressionS *imms; + const reg_entry *regs; + }; + struct _i386_insn { /* TM holds the template for the insn were currently assembling. */ @@ -78,8 +86,6 @@ struct _i386_insn (e.g. 'l' for 'movl') */ char suffix; - /* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */ - /* OPERANDS gives the number of given operands. */ unsigned int operands; @@ -89,12 +95,12 @@ struct _i386_insn unsigned int reg_operands, disp_operands, mem_operands, imm_operands; /* TYPES [i] is the type (see above #defines) which tells us how to - search through DISPS [i] & IMMS [i] & REGS [i] for the required - operand. */ + use OP[i] for the corresponding operand. */ unsigned int types[MAX_OPERANDS]; - /* Displacements (if given) for each operand. */ - expressionS *disps[MAX_OPERANDS]; + /* Displacement expression, immediate expression, or register for each + operand. */ + union i386_op op[MAX_OPERANDS]; /* Relocation type for operand */ #ifdef BFD_ASSEMBLER @@ -103,12 +109,6 @@ struct _i386_insn int disp_reloc[MAX_OPERANDS]; #endif - /* Immediate operands (if given) for each operand. */ - expressionS *imms[MAX_OPERANDS]; - - /* Register operands (if given) for each operand. */ - const reg_entry *regs[MAX_OPERANDS]; - /* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode the base index byte below. */ const reg_entry *base_reg; @@ -225,10 +225,15 @@ static int intel_syntax = 0; /* 1 for intel syntax, 0 if att syntax */ static int allow_naked_reg = 0; /* 1 if register prefix % not required */ +static char stackop_size = '\0'; /* Used in 16 bit gcc mode to add an l + suffix to call, ret, enter, leave, push, + and pop instructions so that gcc has the + same stack frame as in 32 bit mode. */ + /* Interface to relax_segment. There are 2 relax states for 386 jump insns: one for conditional & - one for unconditional jumps. This is because the these two types - of jumps add different sizes to frags when we're figuring out what + one for unconditional jumps. This is because these two types of + jumps add different sizes to frags when we're figuring out what sort of jump to choose to reach a given label. */ /* types */ @@ -264,12 +269,12 @@ static int allow_naked_reg = 0; /* 1 if register prefix % not required */ const relax_typeS md_relax_table[] = { -/* The fields are: - 1) most positive reach of this state, - 2) most negative reach of this state, - 3) how many bytes this mode will add to the size of the current frag - 4) which index into the table to try if we can't fit into this one. - */ + /* The fields are: + 1) most positive reach of this state, + 2) most negative reach of this state, + 3) how many bytes this mode will add to the size of the current frag + 4) which index into the table to try if we can't fit into this one. + */ {1, 1, 0, 0}, {1, 1, 0, 0}, {1, 1, 0, 0}, @@ -343,6 +348,8 @@ i386_align_code (fragP, count) static const char f32_15[] = {0xeb,0x0d,0x90,0x90,0x90,0x90,0x90, /* jmp .+15; lotsa nops */ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90}; + static const char f16_3[] = + {0x8d,0x74,0x00}; /* lea 0(%esi),%esi */ static const char f16_4[] = {0x8d,0xb4,0x00,0x00}; /* lea 0w(%si),%si */ static const char f16_5[] = @@ -362,7 +369,7 @@ i386_align_code (fragP, count) f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15 }; static const char *const f16_patt[] = { - f32_1, f32_2, f32_3, f16_4, f16_5, f16_6, f16_7, f16_8, + f32_1, f32_2, f16_3, f16_4, f16_5, f16_6, f16_7, f16_8, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15 }; @@ -510,14 +517,23 @@ add_prefix (prefix) static void set_16bit_code_flag (new_16bit_code_flag) - int new_16bit_code_flag; + int new_16bit_code_flag; +{ + flag_16bit_code = new_16bit_code_flag; + stackop_size = '\0'; +} + +static void +set_16bit_gcc_code_flag (new_16bit_code_flag) + int new_16bit_code_flag; { flag_16bit_code = new_16bit_code_flag; + stackop_size = new_16bit_code_flag ? 'l' : '\0'; } static void set_intel_syntax (syntax_flag) - int syntax_flag; + int syntax_flag; { /* Find out if register prefixing is specified. */ int ask_naked_reg = 0; @@ -533,18 +549,18 @@ set_intel_syntax (syntax_flag) else if (strcmp(string, "noprefix") == 0) ask_naked_reg = -1; else - as_bad (_("Bad argument to syntax directive.")); + as_bad (_("bad argument to syntax directive.")); *input_line_pointer = e; } demand_empty_rest_of_line (); - + intel_syntax = syntax_flag; if (ask_naked_reg == 0) { #ifdef BFD_ASSEMBLER allow_naked_reg = (intel_syntax - && (bfd_get_symbol_leading_char (stdoutput) != '\0')); + && (bfd_get_symbol_leading_char (stdoutput) != '\0')); #else allow_naked_reg = 0; /* conservative default */ #endif @@ -569,6 +585,7 @@ const pseudo_typeS md_pseudo_table[] = {"value", cons, 2}, {"noopt", s_ignore, 0}, {"optim", s_ignore, 0}, + {"code16gcc", set_16bit_gcc_code_flag, 1}, {"code16", set_16bit_code_flag, 1}, {"code32", set_16bit_code_flag, 0}, {"intel_syntax", set_intel_syntax, 1}, @@ -682,8 +699,6 @@ md_begin () #ifdef LEX_AT identifier_chars['@'] = '@'; #endif - register_chars[')'] = ')'; - register_chars['('] = '('; digit_chars['-'] = '-'; identifier_chars['_'] = '_'; identifier_chars['.'] = '.'; @@ -740,12 +755,12 @@ pi (line, x) pt (x->types[i]); fprintf (stdout, "\n"); if (x->types[i] - & (Reg | SReg2 | SReg3 | Control | Debug | Test | RegMMX)) - fprintf (stdout, "%s\n", x->regs[i]->reg_name); + & (Reg | SReg2 | SReg3 | Control | Debug | Test | RegMMX | RegXMM)) + fprintf (stdout, "%s\n", x->op[i].regs->reg_name); if (x->types[i] & Imm) - pe (x->imms[i]); + pe (x->op[i].imms); if (x->types[i] & Disp) - pe (x->disps[i]); + pe (x->op[i].disps); } } @@ -776,9 +791,9 @@ static void pe (e) expressionS *e; { - fprintf (stdout, " operation %d\n", e->X_op); - fprintf (stdout, " add_number %d (%x)\n", - e->X_add_number, e->X_add_number); + fprintf (stdout, " operation %d\n", e->X_op); + fprintf (stdout, " add_number %ld (%lx)\n", + (long) e->X_add_number, (long) e->X_add_number); if (e->X_add_symbol) { fprintf (stdout, " add_symbol "); @@ -835,6 +850,7 @@ type_names[] = { Acc, "Acc" }, { JumpAbsolute, "Jump Absolute" }, { RegMMX, "rMMX" }, + { RegXMM, "rXMM" }, { EsSeg, "es" }, { 0, "" } }; @@ -871,7 +887,7 @@ tc_i386_force_relocation (fixp) return 0; #else /* For COFF */ - return fixp->fx_r_type==7; + return fixp->fx_r_type == 7; #endif } @@ -895,7 +911,7 @@ reloc (size, pcrel, other) case 2: return BFD_RELOC_16_PCREL; case 4: return BFD_RELOC_32_PCREL; } - as_bad (_("Can not do %d byte pc-relative relocation"), size); + as_bad (_("can not do %d byte pc-relative relocation"), size); } else { @@ -905,7 +921,7 @@ reloc (size, pcrel, other) case 2: return BFD_RELOC_16; case 4: return BFD_RELOC_32; } - as_bad (_("Can not do %d byte relocation"), size); + as_bad (_("can not do %d byte relocation"), size); } return BFD_RELOC_NONE; @@ -918,11 +934,12 @@ reloc (size, pcrel, other) * some cases we force the original symbol to be used. */ int -tc_i386_fix_adjustable(fixP) - fixS * fixP; +tc_i386_fix_adjustable (fixP) + fixS *fixP; { -#ifdef OBJ_ELF - /* Prevent all adjustments to global symbols. */ +#if defined (OBJ_ELF) || defined (TE_PE) + /* Prevent all adjustments to global symbols, or else dynamic + linking will not work correctly. */ if (S_IS_EXTERN (fixP->fx_addsy)) return 0; if (S_IS_WEAK (fixP->fx_addsy)) @@ -932,6 +949,7 @@ tc_i386_fix_adjustable(fixP) if (fixP->fx_r_type == BFD_RELOC_386_GOTOFF || fixP->fx_r_type == BFD_RELOC_386_PLT32 || fixP->fx_r_type == BFD_RELOC_386_GOT32 + || fixP->fx_r_type == BFD_RELOC_RVA || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) return 0; @@ -948,12 +966,15 @@ tc_i386_fix_adjustable(fixP) #define BFD_RELOC_386_GOTOFF 0 #endif -int +static int +intel_float_operand PARAMS ((char *mnemonic)); + +static int intel_float_operand (mnemonic) char *mnemonic; { if (mnemonic[0] == 'f' && mnemonic[1] =='i') - return 0; + return 2; if (mnemonic[0] == 'f') return 1; @@ -1065,30 +1086,27 @@ md_assemble (line) if (!current_templates) { - /* See if we can get a match by trimming off a suffix. */ + /* See if we can get a match by trimming off a suffix. */ switch (mnem_p[-1]) { - case DWORD_MNEM_SUFFIX: case WORD_MNEM_SUFFIX: case BYTE_MNEM_SUFFIX: case SHORT_MNEM_SUFFIX: -#if LONG_MNEM_SUFFIX != DWORD_MNEM_SUFFIX case LONG_MNEM_SUFFIX: -#endif i.suffix = mnem_p[-1]; mnem_p[-1] = '\0'; current_templates = hash_find (op_hash, mnemonic); - break; - - /* Intel Syntax */ - case INTEL_DWORD_MNEM_SUFFIX: - if (intel_syntax) - { - i.suffix = mnem_p[-1]; - mnem_p[-1] = '\0'; - current_templates = hash_find (op_hash, mnemonic); - break; - } + break; + + /* Intel Syntax */ + case DWORD_MNEM_SUFFIX: + if (intel_syntax) + { + i.suffix = mnem_p[-1]; + mnem_p[-1] = '\0'; + current_templates = hash_find (op_hash, mnemonic); + break; + } } if (!current_templates) { @@ -1137,10 +1155,10 @@ md_assemble (line) { if (paren_not_balanced) { - if (!intel_syntax) + if (!intel_syntax) as_bad (_("unbalanced parenthesis in operand %d."), i.operands + 1); - else + else as_bad (_("unbalanced brackets in operand %d."), i.operands + 1); return; @@ -1155,20 +1173,20 @@ md_assemble (line) i.operands + 1); return; } - if (!intel_syntax) - { + if (!intel_syntax) + { if (*l == '(') ++paren_not_balanced; if (*l == ')') --paren_not_balanced; - } - else - { + } + else + { if (*l == '[') ++paren_not_balanced; if (*l == ']') --paren_not_balanced; - } + } l++; } if (l != token_start) @@ -1184,10 +1202,10 @@ md_assemble (line) /* now parse operand adding info to 'i' as we go along */ END_STRING_AND_SAVE (l); - if (intel_syntax) - operand_ok = i386_intel_operand (token_start, intel_float_operand (mnemonic)); - else - operand_ok = i386_operand (token_start); + if (intel_syntax) + operand_ok = i386_intel_operand (token_start, intel_float_operand (mnemonic)); + else + operand_ok = i386_operand (token_start); RESTORE_END_STRING (l); /* restore old contents */ if (!operand_ok) @@ -1230,9 +1248,8 @@ md_assemble (line) with the template operand types. */ #define MATCH(overlap, given, template) \ - ((overlap) \ - && ((given) & BaseIndex) == ((overlap) & BaseIndex) \ - && ((given) & JumpAbsolute) == ((template) & JumpAbsolute)) + ((overlap & ~JumpAbsolute) \ + && ((given) & (BaseIndex|JumpAbsolute)) == ((overlap) & (BaseIndex|JumpAbsolute))) /* If given types r0 and r1 are registers they must be of the same type unless the expected operand type register overlap is null. @@ -1244,90 +1261,105 @@ md_assemble (line) { register unsigned int overlap0, overlap1; - expressionS *exp; unsigned int overlap2; unsigned int found_reverse_match; int suffix_check; - /* All intel opcodes have reversed operands except for BOUND and ENTER */ - if (intel_syntax - && (strcmp (mnemonic, "enter") != 0) - && (strcmp (mnemonic, "bound") != 0) - && (strncmp (mnemonic, "fsub", 4) !=0) - && (strncmp (mnemonic, "fdiv", 4) !=0)) + /* All intel opcodes have reversed operands except for "bound" and + "enter". We also don't reverse intersegment "jmp" and "call" + instructions with 2 immediate operands so that the immediate segment + precedes the offset, as it does when in AT&T mode. "enter" and the + intersegment "jmp" and "call" instructions are the only ones that + have two immediate operands. */ + if (intel_syntax && i.operands > 1 + && (strcmp (mnemonic, "bound") != 0) + && !((i.types[0] & Imm) && (i.types[1] & Imm))) + { + union i386_op temp_op; + unsigned int temp_type; + int xchg1 = 0; + int xchg2 = 0; + + if (i.operands == 2) + { + xchg1 = 0; + xchg2 = 1; + } + else if (i.operands == 3) + { + xchg1 = 0; + xchg2 = 2; + } + temp_type = i.types[xchg2]; + i.types[xchg2] = i.types[xchg1]; + i.types[xchg1] = temp_type; + temp_op = i.op[xchg2]; + i.op[xchg2] = i.op[xchg1]; + i.op[xchg1] = temp_op; + + if (i.mem_operands == 2) + { + const seg_entry *temp_seg; + temp_seg = i.seg[0]; + i.seg[0] = i.seg[1]; + i.seg[1] = temp_seg; + } + } + + if (i.imm_operands) { - const reg_entry *temp_reg; - expressionS *temp_disp; - expressionS *temp_imm; - unsigned int temp_type; - int xchg1, xchg2; - - if (i.operands == 2) - { - xchg1 = 0; - xchg2 = 1; - } - else if (i.operands == 3) - { - xchg1 = 0; - xchg2 = 2; - } - - if (i.operands > 1) - { - temp_type = i.types[xchg2]; - if (temp_type & (Reg | FloatReg)) - temp_reg = i.regs[xchg2]; - else if (temp_type & Imm) - temp_imm = i.imms[xchg2]; - else if (temp_type & Disp) - temp_disp = i.disps[xchg2]; - - i.types[xchg2] = i.types[xchg1]; - - if (i.types[xchg1] & (Reg | FloatReg)) - { - i.regs[xchg2] = i.regs[xchg1]; - i.regs[xchg1] = NULL; - } - else if (i.types[xchg2] & Imm) - { - i.imms[xchg2] = i.imms[xchg1]; - i.imms[xchg1] = NULL; - } - else if (i.types[xchg2] & Disp) - { - i.disps[xchg2] = i.disps[xchg1]; - i.disps[xchg1] = NULL; - } - - if (temp_type & (Reg | FloatReg)) - { - i.regs[xchg1] = temp_reg; - if (! (i.types[xchg1] & (Reg | FloatReg))) - i.regs[xchg2] = NULL; - } - else if (temp_type & Imm) - { - i.imms[xchg1] = temp_imm; - if (! (i.types[xchg1] & Imm)) - i.imms[xchg2] = NULL; - } - else if (temp_type & Disp) - { - i.disps[xchg1] = temp_disp; - if (! (i.types[xchg1] & Disp)) - i.disps[xchg2] = NULL; - } - - i.types[xchg1] = temp_type; - } - if (!strcmp(mnemonic,"jmp") - || !strcmp (mnemonic, "call")) - if ((i.types[0] & Reg) || i.types[0] & BaseIndex) - i.types[0] |= JumpAbsolute; - - } + /* Try to ensure constant immediates are represented in the smallest + opcode possible. */ + char guess_suffix = 0; + int op; + + if (i.suffix) + guess_suffix = i.suffix; + else if (i.reg_operands) + { + /* Figure out a suffix from the last register operand specified. + We can't do this properly yet, ie. excluding InOutPortReg, + but the following works for instructions with immediates. + In any case, we can't set i.suffix yet. */ + for (op = i.operands; --op >= 0; ) + if (i.types[op] & Reg) + { + if (i.types[op] & Reg8) + guess_suffix = BYTE_MNEM_SUFFIX; + else if (i.types[op] & Reg16) + guess_suffix = WORD_MNEM_SUFFIX; + break; + } + } + for (op = i.operands; --op >= 0; ) + if ((i.types[op] & Imm) + && i.op[op].imms->X_op == O_constant) + { + /* If a suffix is given, this operand may be shortened. */ + switch (guess_suffix) + { + case WORD_MNEM_SUFFIX: + i.types[op] |= Imm16; + break; + case BYTE_MNEM_SUFFIX: + i.types[op] |= Imm16 | Imm8 | Imm8S; + break; + } + + /* If this operand is at most 16 bits, convert it to a + signed 16 bit number before trying to see whether it will + fit in an even smaller size. This allows a 16-bit operand + such as $0xffe0 to be recognised as within Imm8S range. */ + if ((i.types[op] & Imm16) + && (i.op[op].imms->X_add_number & ~(offsetT)0xffff) == 0) + { + i.op[op].imms->X_add_number = + (((i.op[op].imms->X_add_number & 0xffff) ^ 0x8000) - 0x8000); + } + i.types[op] |= smallest_imm_type ((long) i.op[op].imms->X_add_number); + } + } + overlap0 = 0; overlap1 = 0; overlap2 = 0; @@ -1339,10 +1371,10 @@ md_assemble (line) : (i.suffix == SHORT_MNEM_SUFFIX ? No_sSuf : (i.suffix == LONG_MNEM_SUFFIX - ? No_lSuf - : (i.suffix == INTEL_DWORD_MNEM_SUFFIX - ? No_dSuf - : (i.suffix == LONG_DOUBLE_MNEM_SUFFIX ? No_xSuf : 0)))))); + ? No_lSuf + : (i.suffix == DWORD_MNEM_SUFFIX + ? No_dSuf + : (i.suffix == LONG_DOUBLE_MNEM_SUFFIX ? No_xSuf : 0)))))); for (t = current_templates->start; t < current_templates->end; @@ -1352,17 +1384,13 @@ md_assemble (line) if (i.operands != t->operands) continue; - /* For some opcodes, don't check the suffix */ - if (intel_syntax) - { - if (strcmp (t->name, "fnstcw") - && strcmp (t->name, "fldcw") - && (t->opcode_modifier & suffix_check)) - continue; - } - /* Must not have disallowed suffix. */ - else if ((t->opcode_modifier & suffix_check)) - continue; + /* Check the suffix, except for some instructions in intel mode. */ + if ((t->opcode_modifier & suffix_check) + && !(intel_syntax + && t->base_opcode == 0xd9 + && (t->extension_opcode == 5 /* 0xd9,5 "fldcw" */ + || t->extension_opcode == 7))) /* 0xd9,7 "f{n}stcw" */ + continue; else if (!t->operands) break; /* 0 operands always matches */ @@ -1419,9 +1447,9 @@ md_assemble (line) || !CONSISTENT_REGISTER_MATCH (overlap1, i.types[1], t->operand_types[1], overlap2, i.types[2], - t->operand_types[2])) + t->operand_types[2])) - continue; + continue; } /* found either forward/reverse 2 or 3 operand match here: slip through to break */ @@ -1435,6 +1463,12 @@ md_assemble (line) return; } + if (!intel_syntax + && (i.types[0] & JumpAbsolute) != (t->operand_types[0] & JumpAbsolute)) + { + as_warn (_("indirect %s without `*'"), t->name); + } + if ((t->opcode_modifier & (IsPrefix|IgnoreSize)) == (IsPrefix|IgnoreSize)) { /* Warn them that a data or address size prefix doesn't affect @@ -1446,10 +1480,21 @@ md_assemble (line) i.tm = *t; if (found_reverse_match) { + /* If we found a reverse match we must alter the opcode + direction bit. found_reverse_match holds bits to change + (different for int & float insns). */ + + i.tm.base_opcode ^= found_reverse_match; + i.tm.operand_types[0] = t->operand_types[1]; i.tm.operand_types[1] = t->operand_types[0]; } + /* Undo SYSV386_COMPAT brokenness when in Intel mode. See i386.h */ + if (SYSV386_COMPAT + && intel_syntax + && (i.tm.base_opcode & 0xfffffde0) == 0xdce0) + i.tm.base_opcode ^= FloatR; if (i.tm.opcode_modifier & FWait) if (! add_prefix (FWAIT_OPCODE)) @@ -1493,7 +1538,7 @@ md_assemble (line) if (i.tm.opcode_modifier & Size16) i.suffix = WORD_MNEM_SUFFIX; else - i.suffix = DWORD_MNEM_SUFFIX; + i.suffix = LONG_MNEM_SUFFIX; } else if (i.reg_operands) { @@ -1506,11 +1551,12 @@ md_assemble (line) register type. */ int op; for (op = i.operands; --op >= 0; ) - if (i.types[op] & Reg) + if ((i.types[op] & Reg) + && !(i.tm.operand_types[op] & InOutPortReg)) { i.suffix = ((i.types[op] & Reg8) ? BYTE_MNEM_SUFFIX : (i.types[op] & Reg16) ? WORD_MNEM_SUFFIX : - DWORD_MNEM_SUFFIX); + LONG_MNEM_SUFFIX); break; } } @@ -1525,15 +1571,15 @@ md_assemble (line) if (i.types[op] & Reg8) continue; - /* movzx and movsx should not generate this warning. */ - if (intel_syntax - && (i.tm.base_opcode == 0xfb7 - || i.tm.base_opcode == 0xfb6 - || i.tm.base_opcode == 0xfbe - || i.tm.base_opcode == 0xfbf)) - continue; + /* movzx and movsx should not generate this warning. */ + if (intel_syntax + && (i.tm.base_opcode == 0xfb7 + || i.tm.base_opcode == 0xfb6 + || i.tm.base_opcode == 0xfbe + || i.tm.base_opcode == 0xfbf)) + continue; - if ((i.types[op] & WordReg) && i.regs[op]->reg_num < 4 + if ((i.types[op] & WordReg) && i.op[op].regs->reg_num < 4 #if 0 /* Check that the template allows eight bit regs This kills insns such as `orb $1,%edx', which @@ -1545,25 +1591,27 @@ md_assemble (line) #if REGISTER_WARNINGS if ((i.tm.operand_types[op] & InOutPortReg) == 0) as_warn (_("using `%%%s' instead of `%%%s' due to `%c' suffix"), - (i.regs[op] - (i.types[op] & Reg16 ? 8 : 16))->reg_name, - i.regs[op]->reg_name, + (i.op[op].regs - (i.types[op] & Reg16 ? 8 : 16))->reg_name, + i.op[op].regs->reg_name, i.suffix); #endif continue; } /* Any other register is bad */ - if (i.types[op] & (Reg | RegMMX | Control | Debug | Test - | FloatReg | FloatAcc | SReg2 | SReg3)) + if (i.types[op] & (Reg | RegMMX | RegXMM + | SReg2 | SReg3 + | Control | Debug | Test + | FloatReg | FloatAcc)) { as_bad (_("`%%%s' not allowed with `%s%c'"), - i.regs[op]->reg_name, + i.op[op].regs->reg_name, i.tm.name, i.suffix); return; } } } - else if (i.suffix == DWORD_MNEM_SUFFIX) + else if (i.suffix == LONG_MNEM_SUFFIX) { int op; for (op = i.operands; --op >= 0; ) @@ -1573,7 +1621,7 @@ md_assemble (line) && (i.tm.operand_types[op] & (Reg16|Reg32|Acc)) != 0) { as_bad (_("`%%%s' not allowed with `%s%c'"), - i.regs[op]->reg_name, + i.op[op].regs->reg_name, i.tm.name, i.suffix); return; @@ -1584,8 +1632,8 @@ md_assemble (line) && (i.tm.operand_types[op] & (Reg32|Acc)) != 0) { as_warn (_("using `%%%s' instead of `%%%s' due to `%c' suffix"), - (i.regs[op] + 8)->reg_name, - i.regs[op]->reg_name, + (i.op[op].regs + 8)->reg_name, + i.op[op].regs->reg_name, i.suffix); } #endif @@ -1600,7 +1648,7 @@ md_assemble (line) && (i.tm.operand_types[op] & (Reg16|Reg32|Acc)) != 0) { as_bad (_("`%%%s' not allowed with `%s%c'"), - i.regs[op]->reg_name, + i.op[op].regs->reg_name, i.tm.name, i.suffix); return; @@ -1611,8 +1659,8 @@ md_assemble (line) && (i.tm.operand_types[op] & (Reg16|Acc)) != 0) { as_warn (_("using `%%%s' instead of `%%%s' due to `%c' suffix"), - (i.regs[op] - 8)->reg_name, - i.regs[op]->reg_name, + (i.op[op].regs - 8)->reg_name, + i.op[op].regs->reg_name, i.suffix); } #endif @@ -1620,6 +1668,10 @@ md_assemble (line) else abort(); } + else if ((i.tm.opcode_modifier & DefaultSize) && !i.suffix) + { + i.suffix = stackop_size; + } /* Make still unresolved immediate matches conform to size of immediate given in i.suffix. Note: overlap2 cannot be an immediate! */ @@ -1629,12 +1681,12 @@ md_assemble (line) { if (i.suffix) { - overlap0 &= (i.suffix == BYTE_MNEM_SUFFIX ? (Imm8 | Imm8S) : - (i.suffix == WORD_MNEM_SUFFIX ? Imm16 : Imm32)); + overlap0 &= (i.suffix == BYTE_MNEM_SUFFIX ? (Imm8 | Imm8S) : + (i.suffix == WORD_MNEM_SUFFIX ? Imm16 : Imm32)); } else if (overlap0 == (Imm16 | Imm32)) { - overlap0 = + overlap0 = (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0)) ? Imm16 : Imm32; } else @@ -1649,12 +1701,12 @@ md_assemble (line) { if (i.suffix) { - overlap1 &= (i.suffix == BYTE_MNEM_SUFFIX ? (Imm8 | Imm8S) : - (i.suffix == WORD_MNEM_SUFFIX ? Imm16 : Imm32)); + overlap1 &= (i.suffix == BYTE_MNEM_SUFFIX ? (Imm8 | Imm8S) : + (i.suffix == WORD_MNEM_SUFFIX ? Imm16 : Imm32)); } else if (overlap1 == (Imm16 | Imm32)) { - overlap1 = + overlap1 = (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0)) ? Imm16 : Imm32; } else @@ -1690,15 +1742,15 @@ md_assemble (line) /* For movzx and movsx, need to check the register type */ if (intel_syntax - && (i.tm.base_opcode == 0xfb6 || i.tm.base_opcode == 0xfbe)) + && (i.tm.base_opcode == 0xfb6 || i.tm.base_opcode == 0xfbe)) if (i.suffix && i.suffix == BYTE_MNEM_SUFFIX) - { - unsigned int prefix = DATA_PREFIX_OPCODE; + { + unsigned int prefix = DATA_PREFIX_OPCODE; - if ((i.regs[1]->reg_type & Reg16) != 0) - if (!add_prefix (prefix)) - return; - } + if ((i.op[1].regs->reg_type & Reg16) != 0) + if (!add_prefix (prefix)) + return; + } if (i.suffix && i.suffix != BYTE_MNEM_SUFFIX) { @@ -1713,8 +1765,7 @@ md_assemble (line) /* Now select between word & dword operations via the operand size prefix, except for instructions that will ignore this prefix anyway. */ - if (((intel_syntax && (i.suffix == INTEL_DWORD_MNEM_SUFFIX)) - || i.suffix == DWORD_MNEM_SUFFIX + if (((intel_syntax && (i.suffix == DWORD_MNEM_SUFFIX)) || i.suffix == LONG_MNEM_SUFFIX) == flag_16bit_code && !(i.tm.opcode_modifier & IgnoreSize)) { @@ -1727,32 +1778,26 @@ md_assemble (line) } /* Size floating point instruction. */ if (i.suffix == LONG_MNEM_SUFFIX - || (intel_syntax && i.suffix == INTEL_DWORD_MNEM_SUFFIX)) + || (intel_syntax && i.suffix == DWORD_MNEM_SUFFIX)) { if (i.tm.opcode_modifier & FloatMF) i.tm.base_opcode ^= 4; } - - if (intel_syntax && i.suffix == LONG_DOUBLE_MNEM_SUFFIX) - { - if (i.tm.opcode_modifier & FloatMF) - i.tm.base_opcode ^= 2; - } } - if (i.tm.base_opcode == AMD_3DNOW_OPCODE) + if (i.tm.opcode_modifier & ImmExt) { - /* These AMD specific instructions have an opcode suffix which - is coded in the same place as an 8-bit immediate field - would be. Here we fake an 8-bit immediate operand from the - opcode suffix stored in tm.extension_opcode. */ + /* These AMD 3DNow! and Intel Katmai New Instructions have an + opcode suffix which is coded in the same place as an 8-bit + immediate field would be. Here we fake an 8-bit immediate + operand from the opcode suffix stored in tm.extension_opcode. */ expressionS *exp; - assert(i.imm_operands == 0 && i.operands <= 2); + assert(i.imm_operands == 0 && i.operands <= 2 && 2 < MAX_OPERANDS); exp = &im_expressions[i.imm_operands++]; - i.imms[i.operands] = exp; + i.op[i.operands].imms = exp; i.types[i.operands++] = Imm8; exp->X_op = O_constant; exp->X_add_number = i.tm.extension_opcode; @@ -1762,17 +1807,11 @@ md_assemble (line) /* For insns with operands there are more diddles to do to the opcode. */ if (i.operands) { - /* Default segment register this instruction will use + /* Default segment register this instruction will use for memory accesses. 0 means unknown. This is only for optimizing out unnecessary segment overrides. */ const seg_entry *default_seg = 0; - /* If we found a reverse match we must alter the opcode - direction bit. found_reverse_match holds bits to change - (different for int & float insns). */ - - i.tm.base_opcode ^= found_reverse_match; - /* The imul $imm, %reg instruction is converted into imul $imm, %reg, %reg, and the clr %reg instruction is converted into xor %reg, %reg. */ @@ -1780,7 +1819,9 @@ md_assemble (line) { unsigned int first_reg_op = (i.types[0] & Reg) ? 0 : 1; /* Pretend we saw the extra register operand. */ - i.regs[first_reg_op+1] = i.regs[first_reg_op]; + assert (i.op[first_reg_op+1].regs == 0); + i.op[first_reg_op+1].regs = i.op[first_reg_op].regs; + i.types[first_reg_op+1] = i.types[first_reg_op]; i.reg_operands = 2; } @@ -1789,7 +1830,7 @@ md_assemble (line) /* The register or float register operand is in operand 0 or 1. */ unsigned int op = (i.types[0] & (Reg | FloatReg)) ? 0 : 1; /* Register goes in low 3 bits of opcode. */ - i.tm.base_opcode |= i.regs[op]->reg_num; + i.tm.base_opcode |= i.op[op].regs->reg_num; if ((i.tm.opcode_modifier & Ugh) != 0) { /* Warn about some common errors, but press on regardless. @@ -1798,14 +1839,14 @@ md_assemble (line) { /* reversed arguments on faddp, fsubp, etc. */ as_warn (_("translating to `%s %%%s,%%%s'"), i.tm.name, - i.regs[1]->reg_name, - i.regs[0]->reg_name); + i.op[1].regs->reg_name, + i.op[0].regs->reg_name); } else { /* extraneous `l' suffix on fp insn */ as_warn (_("translating to `%s %%%s'"), i.tm.name, - i.regs[0]->reg_name); + i.op[0].regs->reg_name); } } } @@ -1822,45 +1863,29 @@ md_assemble (line) { unsigned int source, dest; source = ((i.types[0] - & (Reg - | SReg2 - | SReg3 - | Control - | Debug - | Test - | RegMMX)) + & (Reg | RegMMX | RegXMM + | SReg2 | SReg3 + | Control | Debug | Test)) ? 0 : 1); dest = source + 1; - /* Certain instructions expect the destination to be - in the i.rm.reg field. This is by far the - exceptional case. For these instructions, if the - source operand is a register, we must reverse the - i.rm.reg and i.rm.regmem fields. We accomplish - this by pretending that the two register operands - were given in the reverse order. */ - if (i.tm.opcode_modifier & ReverseRegRegmem) - { - const reg_entry *tmp = i.regs[source]; - i.regs[source] = i.regs[dest]; - i.regs[dest] = tmp; - } - i.rm.mode = 3; - /* We must be careful to make sure that all - segment/control/test/debug/MMX registers go into - the i.rm.reg field (despite whether they are - source or destination operands). */ - if (i.regs[dest]->reg_type - & (SReg2 | SReg3 | Control | Debug | Test | RegMMX)) + /* One of the register operands will be encoded in the + i.tm.reg field, the other in the combined i.tm.mode + and i.tm.regmem fields. If no form of this + instruction supports a memory destination operand, + then we assume the source operand may sometimes be + a memory operand and so we need to store the + destination in the i.rm.reg field. */ + if ((i.tm.operand_types[dest] & AnyMem) == 0) { - i.rm.reg = i.regs[dest]->reg_num; - i.rm.regmem = i.regs[source]->reg_num; + i.rm.reg = i.op[dest].regs->reg_num; + i.rm.regmem = i.op[source].regs->reg_num; } else { - i.rm.reg = i.regs[source]->reg_num; - i.rm.regmem = i.regs[dest]->reg_num; + i.rm.reg = i.op[source].regs->reg_num; + i.rm.regmem = i.op[dest].regs->reg_num; } } else @@ -1981,8 +2006,11 @@ md_assemble (line) { /* Fakes a zero displacement assuming that i.types[op] holds the correct displacement size. */ + expressionS *exp; + + assert (i.op[op].disps == 0); exp = &disp_expressions[i.disp_operands++]; - i.disps[op] = exp; + i.op[op].disps = exp; exp->X_op = O_constant; exp->X_add_number = 0; exp->X_add_symbol = (symbolS *) 0; @@ -1999,20 +2027,22 @@ md_assemble (line) { unsigned int op = ((i.types[0] - & (Reg | SReg2 | SReg3 | Control | Debug - | Test | RegMMX)) + & (Reg | RegMMX | RegXMM + | SReg2 | SReg3 + | Control | Debug | Test)) ? 0 : ((i.types[1] - & (Reg | SReg2 | SReg3 | Control | Debug - | Test | RegMMX)) + & (Reg | RegMMX | RegXMM + | SReg2 | SReg3 + | Control | Debug | Test)) ? 1 : 2)); /* If there is an extension opcode to put here, the register number must be put into the regmem field. */ if (i.tm.extension_opcode != None) - i.rm.regmem = i.regs[op]->reg_num; + i.rm.regmem = i.op[op].regs->reg_num; else - i.rm.reg = i.regs[op]->reg_num; + i.rm.reg = i.op[op].regs->reg_num; /* Now, if no memory operand has set i.rm.mode = 0, 1, 2 we must set it to 3 to indicate this is a register @@ -2028,12 +2058,12 @@ md_assemble (line) } else if (i.tm.opcode_modifier & (Seg2ShortForm | Seg3ShortForm)) { - if (i.tm.base_opcode == POP_SEG_SHORT && i.regs[0]->reg_num == 1) + if (i.tm.base_opcode == POP_SEG_SHORT && i.op[0].regs->reg_num == 1) { as_bad (_("you can't `pop %%cs'")); return; } - i.tm.base_opcode |= (i.regs[0]->reg_num << 3); + i.tm.base_opcode |= (i.op[0].regs->reg_num << 3); } else if ((i.tm.base_opcode & ~(D|W)) == MOV_AX_DISP32) { @@ -2060,18 +2090,28 @@ md_assemble (line) } else if ((i.tm.opcode_modifier & Ugh) != 0) { - /* UnixWare fsub no args is alias for fsubp, fadd -> faddp, etc */ - as_warn (_("translating to `%sp'"), i.tm.name); + /* UnixWare fsub no args is alias for fsubp, fadd -> faddp, etc. */ + as_warn (_("translating to `%sp'"), i.tm.name); } } /* Handle conversion of 'int $3' --> special int3 insn. */ - if (i.tm.base_opcode == INT_OPCODE && i.imms[0]->X_add_number == 3) + if (i.tm.base_opcode == INT_OPCODE && i.op[0].imms->X_add_number == 3) { i.tm.base_opcode = INT3_OPCODE; i.imm_operands = 0; } + if ((i.tm.opcode_modifier & (Jump | JumpByte | JumpDword)) + && i.op[0].disps->X_op == O_constant) + { + /* Convert "jmp constant" (and "call constant") to a jump (call) to + the absolute address given by the constant. Since ix86 jumps and + calls are pc relative, we need to generate a reloc. */ + i.op[0].disps->X_add_symbol = &abs_symbol; + i.op[0].disps->X_op = O_symbol; + } + /* We are ready to output the insn. */ { register char *p; @@ -2079,96 +2119,60 @@ md_assemble (line) /* Output jumps. */ if (i.tm.opcode_modifier & Jump) { - long n = (long) i.disps[0]->X_add_number; - int prefix = (i.prefix[DATA_PREFIX] != 0); - int code16 = 0; + int size; + int code16; + int prefix; - if (prefix) + code16 = 0; + if (flag_16bit_code) + code16 = CODE16; + + prefix = 0; + if (i.prefix[DATA_PREFIX]) { + prefix = 1; i.prefixes -= 1; - code16 = CODE16; + code16 ^= CODE16; } - if (flag_16bit_code) - code16 ^= CODE16; - if (!intel_syntax && (i.prefixes != 0)) - as_warn (_("skipping prefixes on this instruction")); + size = 4; + if (code16) + size = 2; - if (i.disps[0]->X_op == O_constant) - { - if (fits_in_signed_byte (n)) - { - insn_size += 2; - p = frag_more (2); - p[0] = i.tm.base_opcode; - p[1] = n; - } - else - { - /* Use 16-bit jumps only for 16-bit code, - because text segments are limited to 64K anyway; - Use 32-bit jumps for 32-bit code, because they're faster, - and a 16-bit jump will clear the top 16 bits of %eip. */ - int jmp_size = code16 ? 2 : 4; - if (code16 && !fits_in_signed_word (n)) - { - as_bad (_("16-bit jump out of range")); - return; - } + if (i.prefixes != 0 && !intel_syntax) + as_warn (_("skipping prefixes on this instruction")); - if (i.tm.base_opcode == JUMP_PC_RELATIVE) - { /* pace */ - /* unconditional jump */ - insn_size += prefix + 1 + jmp_size; - p = frag_more (prefix + 1 + jmp_size); - if (prefix) - *p++ = DATA_PREFIX_OPCODE; - *p++ = (char) 0xe9; - md_number_to_chars (p, (valueT) n, jmp_size); - } - else - { - /* conditional jump */ - insn_size += prefix + 2 + jmp_size; - p = frag_more (prefix + 2 + jmp_size); - if (prefix) - *p++ = DATA_PREFIX_OPCODE; - *p++ = TWO_BYTE_OPCODE_ESCAPE; - *p++ = i.tm.base_opcode + 0x10; - md_number_to_chars (p, (valueT) n, jmp_size); - } - } - } - else - { - int size = code16 ? 2 : 4; - - /* It's a symbol; end frag & setup for relax. - Make sure there are more than 6 chars left in the current frag; - if not we'll have to start a new one. */ - frag_grow (prefix + 1 + 2 + size); - insn_size += 1 + prefix; - p = frag_more (1 + prefix); - if (prefix) - *p++ = DATA_PREFIX_OPCODE; - *p = i.tm.base_opcode; - frag_var (rs_machine_dependent, - prefix + 2 + size, /* 2 opcode/prefix + displacement */ - 1, - ((unsigned char) *p == JUMP_PC_RELATIVE - ? ENCODE_RELAX_STATE (UNCOND_JUMP, SMALL) | code16 - : ENCODE_RELAX_STATE (COND_JUMP, SMALL) | code16), - i.disps[0]->X_add_symbol, - (offsetT) n, p); - } + /* It's always a symbol; End frag & setup for relax. + Make sure there is enough room in this frag for the largest + instruction we may generate in md_convert_frag. This is 2 + bytes for the opcode and room for the prefix and largest + displacement. */ + frag_grow (prefix + 2 + size); + insn_size += prefix + 1; + /* Prefix and 1 opcode byte go in fr_fix. */ + p = frag_more (prefix + 1); + if (prefix) + *p++ = DATA_PREFIX_OPCODE; + *p = i.tm.base_opcode; + /* 1 possible extra opcode + displacement go in fr_var. */ + frag_var (rs_machine_dependent, + 1 + size, + 1, + ((unsigned char) *p == JUMP_PC_RELATIVE + ? ENCODE_RELAX_STATE (UNCOND_JUMP, SMALL) | code16 + : ENCODE_RELAX_STATE (COND_JUMP, SMALL) | code16), + i.op[0].disps->X_add_symbol, + i.op[0].disps->X_add_number, + p); } else if (i.tm.opcode_modifier & (JumpByte | JumpDword)) { - int size = (i.tm.opcode_modifier & JumpByte) ? 1 : 4; - long n = (long) i.disps[0]->X_add_number; + int size; - if (size == 1) /* then this is a loop or jecxz type instruction */ + if (i.tm.opcode_modifier & JumpByte) { + /* This is a loop or jecxz type instruction. */ + size = 1; if (i.prefix[ADDR_PREFIX]) { insn_size += 1; @@ -2178,23 +2182,26 @@ md_assemble (line) } else { - int code16 = 0; + int code16; + + code16 = 0; + if (flag_16bit_code) + code16 = CODE16; if (i.prefix[DATA_PREFIX]) { insn_size += 1; FRAG_APPEND_1_CHAR (DATA_PREFIX_OPCODE); i.prefixes -= 1; - code16 = CODE16; + code16 ^= CODE16; } - if (flag_16bit_code) - code16 ^= CODE16; + size = 4; if (code16) size = 2; } - if (!intel_syntax && (i.prefixes != 0)) + if (i.prefixes != 0 && !intel_syntax) as_warn (_("skipping prefixes on this instruction")); if (fits_in_unsigned_byte (i.tm.base_opcode)) @@ -2204,57 +2211,39 @@ md_assemble (line) } else { - insn_size += 2 + size; /* opcode can be at most two bytes */ + /* opcode can be at most two bytes */ + insn_size += 2 + size; p = frag_more (2 + size); *p++ = (i.tm.base_opcode >> 8) & 0xff; } *p++ = i.tm.base_opcode & 0xff; - if (i.disps[0]->X_op == O_constant) - { - if (size == 1 && !fits_in_signed_byte (n)) - { - as_bad (_("`%s' only takes byte displacement; %ld shortened to %d"), - i.tm.name, n, *p); - } - else if (size == 2 && !fits_in_signed_word (n)) - { - as_bad (_("16-bit jump out of range")); - return; - } - md_number_to_chars (p, (valueT) n, size); - } - else - { - fix_new_exp (frag_now, p - frag_now->fr_literal, size, - i.disps[0], 1, reloc (size, 1, i.disp_reloc[0])); - - } + fix_new_exp (frag_now, p - frag_now->fr_literal, size, + i.op[0].disps, 1, reloc (size, 1, i.disp_reloc[0])); } else if (i.tm.opcode_modifier & JumpInterSegment) { int size; - int reloc_type; - int prefix = i.prefix[DATA_PREFIX] != 0; - int code16 = 0; + int prefix; + int code16; - if (prefix) + code16 = 0; + if (flag_16bit_code) + code16 = CODE16; + + prefix = 0; + if (i.prefix[DATA_PREFIX]) { - code16 = CODE16; + prefix = 1; i.prefixes -= 1; + code16 ^= CODE16; } - if (flag_16bit_code) - code16 ^= CODE16; size = 4; - reloc_type = BFD_RELOC_32; if (code16) - { - size = 2; - reloc_type = BFD_RELOC_16; - } + size = 2; - if (!intel_syntax && (i.prefixes != 0)) + if (i.prefixes != 0 && !intel_syntax) as_warn (_("skipping prefixes on this instruction")); insn_size += prefix + 1 + 2 + size; /* 1 opcode; 2 segment; offset */ @@ -2262,11 +2251,13 @@ md_assemble (line) if (prefix) *p++ = DATA_PREFIX_OPCODE; *p++ = i.tm.base_opcode; - if (i.imms[1]->X_op == O_constant) + if (i.op[1].imms->X_op == O_constant) { - long n = (long) i.imms[1]->X_add_number; + long n = (long) i.op[1].imms->X_add_number; - if (size == 2 && !fits_in_unsigned_word (n)) + if (size == 2 + && !fits_in_unsigned_word (n) + && !fits_in_signed_word (n)) { as_bad (_("16-bit jump out of range")); return; @@ -2275,11 +2266,11 @@ md_assemble (line) } else fix_new_exp (frag_now, p - frag_now->fr_literal, size, - i.imms[1], 0, reloc_type); - if (i.imms[0]->X_op != O_constant) + i.op[1].imms, 0, reloc (size, 0, i.disp_reloc[0])); + if (i.op[0].imms->X_op != O_constant) as_bad (_("can't handle non absolute segment in `%s'"), i.tm.name); - md_number_to_chars (p + size, (valueT) i.imms[0]->X_add_number, 2); + md_number_to_chars (p + size, (valueT) i.op[0].imms->X_add_number, 2); } else { @@ -2365,50 +2356,45 @@ md_assemble (line) for (n = 0; n < i.operands; n++) { - if (i.disps[n]) + if (i.types[n] & Disp) { - if (i.disps[n]->X_op == O_constant) + if (i.op[n].disps->X_op == O_constant) { - if (i.types[n] & Disp8) - { - insn_size += 1; - p = frag_more (1); - md_number_to_chars (p, - (valueT) i.disps[n]->X_add_number, - 1); - } - else if (i.types[n] & Disp16) + int size = 4; + long val = (long) i.op[n].disps->X_add_number; + + if (i.types[n] & (Disp8 | Disp16)) { - insn_size += 2; - p = frag_more (2); - md_number_to_chars (p, - (valueT) i.disps[n]->X_add_number, - 2); - } - else - { /* Disp32 */ - insn_size += 4; - p = frag_more (4); - md_number_to_chars (p, - (valueT) i.disps[n]->X_add_number, - 4); + long mask; + + size = 2; + mask = ~ (long) 0xffff; + if (i.types[n] & Disp8) + { + size = 1; + mask = ~ (long) 0xff; + } + + if ((val & mask) != 0 && (val & mask) != mask) + as_warn (_("%ld shortened to %ld"), + val, val & ~mask); } - } - else if (i.types[n] & Disp32) - { - insn_size += 4; - p = frag_more (4); - fix_new_exp (frag_now, p - frag_now->fr_literal, 4, - i.disps[n], 0, - TC_RELOC (i.disp_reloc[n], BFD_RELOC_32)); + insn_size += size; + p = frag_more (size); + md_number_to_chars (p, (valueT) val, size); } else - { /* must be Disp16 */ - insn_size += 2; - p = frag_more (2); - fix_new_exp (frag_now, p - frag_now->fr_literal, 2, - i.disps[n], 0, - TC_RELOC (i.disp_reloc[n], BFD_RELOC_16)); + { + int size = 4; + + if (i.types[n] & Disp16) + size = 2; + + insn_size += size; + p = frag_more (size); + fix_new_exp (frag_now, p - frag_now->fr_literal, size, + i.op[n].disps, 0, + reloc (size, 0, i.disp_reloc[n])); } } } @@ -2421,68 +2407,68 @@ md_assemble (line) for (n = 0; n < i.operands; n++) { - if (i.imms[n]) + if (i.types[n] & Imm) { - if (i.imms[n]->X_op == O_constant) + if (i.op[n].imms->X_op == O_constant) { - if (i.types[n] & (Imm8 | Imm8S)) - { - insn_size += 1; - p = frag_more (1); - md_number_to_chars (p, - (valueT) i.imms[n]->X_add_number, - 1); - } - else if (i.types[n] & Imm16) - { - insn_size += 2; - p = frag_more (2); - md_number_to_chars (p, - (valueT) i.imms[n]->X_add_number, - 2); - } - else + int size = 4; + long val = (long) i.op[n].imms->X_add_number; + + if (i.types[n] & (Imm8 | Imm8S | Imm16)) { - insn_size += 4; - p = frag_more (4); - md_number_to_chars (p, - (valueT) i.imms[n]->X_add_number, - 4); + long mask; + + size = 2; + mask = ~ (long) 0xffff; + if (i.types[n] & (Imm8 | Imm8S)) + { + size = 1; + mask = ~ (long) 0xff; + } + if ((val & mask) != 0 && (val & mask) != mask) + as_warn (_("%ld shortened to %ld"), + val, val & ~mask); } + insn_size += size; + p = frag_more (size); + md_number_to_chars (p, (valueT) val, size); } else { /* not absolute_section */ /* Need a 32-bit fixup (don't support 8bit - non-absolute ims). Try to support other + non-absolute imms). Try to support other sizes ... */ - int r_type; - int size; - int pcrel = 0; +#ifdef BFD_ASSEMBLER + enum bfd_reloc_code_real reloc_type; +#else + int reloc_type; +#endif + int size = 4; - if (i.types[n] & (Imm8 | Imm8S)) - size = 1; - else if (i.types[n] & Imm16) + if (i.types[n] & Imm16) size = 2; - else - size = 4; + else if (i.types[n] & (Imm8 | Imm8S)) + size = 1; + insn_size += size; p = frag_more (size); - r_type = reloc (size, 0, i.disp_reloc[0]); + reloc_type = reloc (size, 0, i.disp_reloc[0]); #ifdef BFD_ASSEMBLER - if (r_type == BFD_RELOC_32 + if (reloc_type == BFD_RELOC_32 && GOT_symbol - && GOT_symbol == i.imms[n]->X_add_symbol - && (i.imms[n]->X_op == O_symbol - || (i.imms[n]->X_op == O_add - && (i.imms[n]->X_op_symbol->sy_value.X_op + && GOT_symbol == i.op[n].imms->X_add_symbol + && (i.op[n].imms->X_op == O_symbol + || (i.op[n].imms->X_op == O_add + && ((symbol_get_value_expression + (i.op[n].imms->X_op_symbol)->X_op) == O_subtract)))) { - r_type = BFD_RELOC_386_GOTPC; - i.imms[n]->X_add_number += 3; + reloc_type = BFD_RELOC_386_GOTPC; + i.op[n].imms->X_add_number += 3; } #endif fix_new_exp (frag_now, p - frag_now->fr_literal, size, - i.imms[n], pcrel, r_type); + i.op[n].imms, 0, reloc_type); } } } @@ -2498,30 +2484,6 @@ md_assemble (line) } } -static int i386_is_reg PARAMS ((char *)); - -static int -i386_is_reg (reg_string) - char *reg_string; -{ - register char *s = reg_string; - register char *p; - char reg_name_given[MAX_REG_NAME_SIZE + 1]; - - if (is_space_char (*s)) - ++s; - - p = reg_name_given; - while ((*p++ = register_chars[(unsigned char) *s++]) != '\0') - if (p >= reg_name_given + MAX_REG_NAME_SIZE) - return 0; - - if (!hash_find (reg_hash, reg_name_given)) - return 0; - else - return 1; -} - static int i386_immediate PARAMS ((char *)); static int @@ -2534,12 +2496,12 @@ i386_immediate (imm_start) if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) { - as_bad (_("Only 1 or 2 immediate operands are allowed")); + as_bad (_("only 1 or 2 immediate operands are allowed")); return 0; } exp = &im_expressions[i.imm_operands++]; - i.imms[this_operand] = exp; + i.op[this_operand].imms = exp; if (is_space_char (*imm_start)) ++imm_start; @@ -2548,114 +2510,114 @@ i386_immediate (imm_start) input_line_pointer = imm_start; #ifndef LEX_AT - { - /* - * We can have operands of the form - * @GOTOFF+ - * Take the easy way out here and copy everything - * into a temporary buffer... - */ - register char *cp; - - cp = strchr (input_line_pointer, '@'); - if (cp != NULL) - { - char *tmpbuf; - int len, first; - - /* GOT relocations are not supported in 16 bit mode */ - if (flag_16bit_code) - as_bad (_("GOT relocations not supported in 16 bit mode")); - - if (GOT_symbol == NULL) - GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); - - if (strncmp (cp + 1, "PLT", 3) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_PLT32; - len = 3; - } - else if (strncmp (cp + 1, "GOTOFF", 6) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_GOTOFF; - len = 6; - } - else if (strncmp (cp + 1, "GOT", 3) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_GOT32; - len = 3; - } - else - as_bad (_("Bad reloc specifier in expression")); - - /* Replace the relocation token with ' ', so that errors like - foo@GOTOFF1 will be detected. */ - first = cp - input_line_pointer; - tmpbuf = (char *) alloca (strlen(input_line_pointer)); - memcpy (tmpbuf, input_line_pointer, first); - tmpbuf[first] = ' '; - strcpy (tmpbuf + first + 1, cp + 1 + len); - input_line_pointer = tmpbuf; - } - } + { + /* + * We can have operands of the form + * @GOTOFF+ + * Take the easy way out here and copy everything + * into a temporary buffer... + */ + register char *cp; + + cp = strchr (input_line_pointer, '@'); + if (cp != NULL) + { + char *tmpbuf; + int len = 0; + int first; + + /* GOT relocations are not supported in 16 bit mode */ + if (flag_16bit_code) + as_bad (_("GOT relocations not supported in 16 bit mode")); + + if (GOT_symbol == NULL) + GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); + + if (strncmp (cp + 1, "PLT", 3) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_PLT32; + len = 3; + } + else if (strncmp (cp + 1, "GOTOFF", 6) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_GOTOFF; + len = 6; + } + else if (strncmp (cp + 1, "GOT", 3) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_GOT32; + len = 3; + } + else + as_bad (_("bad reloc specifier in expression")); + + /* Replace the relocation token with ' ', so that errors like + foo@GOTOFF1 will be detected. */ + first = cp - input_line_pointer; + tmpbuf = (char *) alloca (strlen(input_line_pointer)); + memcpy (tmpbuf, input_line_pointer, first); + tmpbuf[first] = ' '; + strcpy (tmpbuf + first + 1, cp + 1 + len); + input_line_pointer = tmpbuf; + } + } #endif exp_seg = expression (exp); + SKIP_WHITESPACE (); if (*input_line_pointer) - as_bad (_("Ignoring junk `%s' after expression"), input_line_pointer); + as_bad (_("ignoring junk `%s' after expression"), input_line_pointer); input_line_pointer = save_input_line_pointer; - if (exp->X_op == O_absent) + if (exp->X_op == O_absent || exp->X_op == O_big) { /* missing or bad expr becomes absolute 0 */ - as_bad (_("Missing or invalid immediate expression `%s' taken as 0"), - imm_start); + as_bad (_("missing or invalid immediate expression `%s' taken as 0"), + imm_start); exp->X_op = O_constant; exp->X_add_number = 0; exp->X_add_symbol = (symbolS *) 0; exp->X_op_symbol = (symbolS *) 0; - i.types[this_operand] |= Imm; } - else if (exp->X_op == O_constant) + + if (exp->X_op == O_constant) { - i.types[this_operand] |= - smallest_imm_type ((long) exp->X_add_number); - - /* If a suffix is given, this operand may be shortended. */ - switch (i.suffix) - { - case WORD_MNEM_SUFFIX: - i.types[this_operand] |= Imm16; - break; - case BYTE_MNEM_SUFFIX: - i.types[this_operand] |= Imm16 | Imm8 | Imm8S; - break; - } + int bigimm = Imm32; + if (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0)) + bigimm = Imm16; + i.types[this_operand] |= bigimm; } -#ifdef OBJ_AOUT - else if (exp_seg != text_section - && exp_seg != data_section - && exp_seg != bss_section - && exp_seg != undefined_section +#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)) + else if ( +#ifdef BFD_ASSEMBLER + OUTPUT_FLAVOR == bfd_target_aout_flavour && +#endif + exp_seg != text_section + && exp_seg != data_section + && exp_seg != bss_section + && exp_seg != undefined_section #ifdef BFD_ASSEMBLER - && !bfd_is_com_section (exp_seg) + && !bfd_is_com_section (exp_seg) #endif - ) + ) { - seg_unimplemented: - as_bad (_("Unimplemented segment type %d in operand"), exp_seg); +#ifdef BFD_ASSEMBLER + as_bad (_("unimplemented segment %s in operand"), exp_seg->name); +#else + as_bad (_("unimplemented segment type %d in operand"), exp_seg); +#endif return 0; } #endif else { /* This is an address. The size of the address will be - determined later, depending on destination register, - suffix, or the default for the section. We exclude - Imm8S here so that `push $foo' and other instructions - with an Imm8S form will use Imm16 or Imm32. */ + determined later, depending on destination register, + suffix, or the default for the section. We exclude + Imm8S here so that `push $foo' and other instructions + with an Imm8S form will use Imm16 or Imm32. */ i.types[this_operand] |= (Imm8 | Imm16 | Imm32); } @@ -2689,13 +2651,13 @@ i386_scale (scale) default: bad_scale: as_bad (_("expecting scale factor of 1, 2, 4, or 8: got `%s'"), - scale); + scale); return 0; } if (i.log2_scale_factor != 0 && ! i.index_reg) { as_warn (_("scale factor of %d without an index register"), - 1 << i.log2_scale_factor); + 1 << i.log2_scale_factor); #if SCALE1_WHEN_NO_INDEX i.log2_scale_factor = 0; #endif @@ -2715,17 +2677,12 @@ i386_displacement (disp_start, disp_end) char *save_input_line_pointer; int bigdisp = Disp32; - /* All of the pieces of the displacement expression are handled together. */ - if (intel_syntax && i.disp_operands != 0) - return 1; - if (flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0)) bigdisp = Disp16; i.types[this_operand] |= bigdisp; exp = &disp_expressions[i.disp_operands]; - i.disps[this_operand] = exp; - i.disp_reloc[this_operand] = NO_RELOC; + i.op[this_operand].disps = exp; i.disp_operands++; save_input_line_pointer = input_line_pointer; input_line_pointer = disp_start; @@ -2737,139 +2694,168 @@ i386_displacement (disp_start, disp_end) #if GCC_ASM_O_HACK END_STRING_AND_SAVE (disp_end + 1); if ((i.types[this_operand] & BaseIndex) != 0 - && displacement_string_end[-1] == '+') + && displacement_string_end[-1] == '+') { /* This hack is to avoid a warning when using the "o" - constraint within gcc asm statements. - For instance: - - #define _set_tssldt_desc(n,addr,limit,type) \ - __asm__ __volatile__ ( \ - "movw %w2,%0\n\t" \ - "movw %w1,2+%0\n\t" \ - "rorl $16,%1\n\t" \ - "movb %b1,4+%0\n\t" \ - "movb %4,5+%0\n\t" \ - "movb $0,6+%0\n\t" \ - "movb %h1,7+%0\n\t" \ - "rorl $16,%1" \ - : "=o"(*(n)) : "q" (addr), "ri"(limit), "i"(type)) - - This works great except that the output assembler ends - up looking a bit weird if it turns out that there is - no offset. You end up producing code that looks like: - - #APP - movw $235,(%eax) - movw %dx,2+(%eax) - rorl $16,%edx - movb %dl,4+(%eax) - movb $137,5+(%eax) - movb $0,6+(%eax) - movb %dh,7+(%eax) - rorl $16,%edx - #NO_APP - - So here we provide the missing zero. - */ - - *displacement_string_end = '0'; + constraint within gcc asm statements. + For instance: + + #define _set_tssldt_desc(n,addr,limit,type) \ + __asm__ __volatile__ ( \ + "movw %w2,%0\n\t" \ + "movw %w1,2+%0\n\t" \ + "rorl $16,%1\n\t" \ + "movb %b1,4+%0\n\t" \ + "movb %4,5+%0\n\t" \ + "movb $0,6+%0\n\t" \ + "movb %h1,7+%0\n\t" \ + "rorl $16,%1" \ + : "=o"(*(n)) : "q" (addr), "ri"(limit), "i"(type)) + + This works great except that the output assembler ends + up looking a bit weird if it turns out that there is + no offset. You end up producing code that looks like: + + #APP + movw $235,(%eax) + movw %dx,2+(%eax) + rorl $16,%edx + movb %dl,4+(%eax) + movb $137,5+(%eax) + movb $0,6+(%eax) + movb %dh,7+(%eax) + rorl $16,%edx + #NO_APP + + So here we provide the missing zero. + */ + + *displacement_string_end = '0'; } #endif #ifndef LEX_AT - { - /* - * We can have operands of the form - * @GOTOFF+ - * Take the easy way out here and copy everything - * into a temporary buffer... - */ - register char *cp; - - cp = strchr (input_line_pointer, '@'); - if (cp != NULL) - { - char *tmpbuf; - int len, first; - - /* GOT relocations are not supported in 16 bit mode */ - if (flag_16bit_code) - as_bad (_("GOT relocations not supported in 16 bit mode")); - - if (GOT_symbol == NULL) - GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); - - if (strncmp (cp + 1, "PLT", 3) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_PLT32; - len = 3; - } - else if (strncmp (cp + 1, "GOTOFF", 6) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_GOTOFF; - len = 6; - } - else if (strncmp (cp + 1, "GOT", 3) == 0) - { - i.disp_reloc[this_operand] = BFD_RELOC_386_GOT32; - len = 3; - } - else - as_bad (_("Bad reloc specifier in expression")); - - /* Replace the relocation token with ' ', so that errors like - foo@GOTOFF1 will be detected. */ - first = cp - input_line_pointer; - tmpbuf = (char *) alloca (strlen(input_line_pointer)); - memcpy (tmpbuf, input_line_pointer, first); - tmpbuf[first] = ' '; - strcpy (tmpbuf + first + 1, cp + 1 + len); - input_line_pointer = tmpbuf; - } - } -#endif + { + /* + * We can have operands of the form + * @GOTOFF+ + * Take the easy way out here and copy everything + * into a temporary buffer... + */ + register char *cp; + + cp = strchr (input_line_pointer, '@'); + if (cp != NULL) + { + char *tmpbuf; + int len = 0; + int first; + + /* GOT relocations are not supported in 16 bit mode */ + if (flag_16bit_code) + as_bad (_("GOT relocations not supported in 16 bit mode")); - exp_seg = expression (exp); + if (GOT_symbol == NULL) + GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); -#ifdef BFD_ASSEMBLER - /* We do this to make sure that the section symbol is in - the symbol table. We will ultimately change the relocation - to be relative to the beginning of the section */ - if (i.disp_reloc[this_operand] == BFD_RELOC_386_GOTOFF) - { - if (S_IS_LOCAL(exp->X_add_symbol) - && S_GET_SEGMENT (exp->X_add_symbol) != undefined_section) - section_symbol(exp->X_add_symbol->bsym->section); - assert (exp->X_op == O_symbol); - exp->X_op = O_subtract; - exp->X_op_symbol = GOT_symbol; - i.disp_reloc[this_operand] = BFD_RELOC_32; + if (strncmp (cp + 1, "PLT", 3) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_PLT32; + len = 3; + } + else if (strncmp (cp + 1, "GOTOFF", 6) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_GOTOFF; + len = 6; + } + else if (strncmp (cp + 1, "GOT", 3) == 0) + { + i.disp_reloc[this_operand] = BFD_RELOC_386_GOT32; + len = 3; + } + else + as_bad (_("bad reloc specifier in expression")); + + /* Replace the relocation token with ' ', so that errors like + foo@GOTOFF1 will be detected. */ + first = cp - input_line_pointer; + tmpbuf = (char *) alloca (strlen(input_line_pointer)); + memcpy (tmpbuf, input_line_pointer, first); + tmpbuf[first] = ' '; + strcpy (tmpbuf + first + 1, cp + 1 + len); + input_line_pointer = tmpbuf; } + } #endif - if (*input_line_pointer) - as_bad (_("Ignoring junk `%s' after expression"), - input_line_pointer); + exp_seg = expression (exp); + +#ifdef BFD_ASSEMBLER + /* We do this to make sure that the section symbol is in + the symbol table. We will ultimately change the relocation + to be relative to the beginning of the section */ + if (i.disp_reloc[this_operand] == BFD_RELOC_386_GOTOFF) + { + if (S_IS_LOCAL(exp->X_add_symbol) + && S_GET_SEGMENT (exp->X_add_symbol) != undefined_section) + section_symbol (S_GET_SEGMENT (exp->X_add_symbol)); + assert (exp->X_op == O_symbol); + exp->X_op = O_subtract; + exp->X_op_symbol = GOT_symbol; + i.disp_reloc[this_operand] = BFD_RELOC_32; + } +#endif + + SKIP_WHITESPACE (); + if (*input_line_pointer) + as_bad (_("ignoring junk `%s' after expression"), + input_line_pointer); #if GCC_ASM_O_HACK - RESTORE_END_STRING (disp_end + 1); + RESTORE_END_STRING (disp_end + 1); #endif - RESTORE_END_STRING (disp_end); - input_line_pointer = save_input_line_pointer; - - if (exp->X_op == O_constant) - { - if (fits_in_signed_byte (exp->X_add_number)) - i.types[this_operand] |= Disp8; - } -#ifdef OBJ_AOUT - else if (exp_seg != text_section - && exp_seg != data_section - && exp_seg != bss_section - && exp_seg != undefined_section) - { - as_bad (_ ("Unimplemented segment type %d in operand"), exp_seg); - return 0; - } + RESTORE_END_STRING (disp_end); + input_line_pointer = save_input_line_pointer; + + if (exp->X_op == O_absent || exp->X_op == O_big) + { + /* missing or bad expr becomes absolute 0 */ + as_bad (_("missing or invalid displacement expression `%s' taken as 0"), + disp_start); + exp->X_op = O_constant; + exp->X_add_number = 0; + exp->X_add_symbol = (symbolS *) 0; + exp->X_op_symbol = (symbolS *) 0; + } + + if (exp->X_op == O_constant) + { + if (i.types[this_operand] & Disp16) + { + /* We know this operand is at most 16 bits, so convert to a + signed 16 bit number before trying to see whether it will + fit in an even smaller size. */ + exp->X_add_number = + (((exp->X_add_number & 0xffff) ^ 0x8000) - 0x8000); + } + if (fits_in_signed_byte (exp->X_add_number)) + i.types[this_operand] |= Disp8; + } +#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)) + else if ( +#ifdef BFD_ASSEMBLER + OUTPUT_FLAVOR == bfd_target_aout_flavour && +#endif + exp_seg != text_section + && exp_seg != data_section + && exp_seg != bss_section + && exp_seg != undefined_section) + { +#ifdef BFD_ASSEMBLER + as_bad (_("unimplemented segment %s in operand"), exp_seg->name); +#else + as_bad (_("unimplemented segment type %d in operand"), exp_seg); +#endif + return 0; + } #endif return 1; } @@ -2881,64 +2867,67 @@ i386_operand_modifier (op_string, got_a_float) char **op_string; int got_a_float; { - if (!strncasecmp (*op_string, "BYTE PTR", 8)) - { - i.suffix = BYTE_MNEM_SUFFIX; - *op_string += 8; - return BYTE_PTR; + if (!strncasecmp (*op_string, "BYTE PTR", 8)) + { + i.suffix = BYTE_MNEM_SUFFIX; + *op_string += 8; + return BYTE_PTR; - } - else if (!strncasecmp (*op_string, "WORD PTR", 8)) - { - i.suffix = WORD_MNEM_SUFFIX; - *op_string += 8; - return WORD_PTR; - } + } + else if (!strncasecmp (*op_string, "WORD PTR", 8)) + { + if (got_a_float == 2) /* "fi..." */ + i.suffix = SHORT_MNEM_SUFFIX; + else + i.suffix = WORD_MNEM_SUFFIX; + *op_string += 8; + return WORD_PTR; + } - else if (!strncasecmp (*op_string, "DWORD PTR", 9)) - { - if (got_a_float) - i.suffix = SHORT_MNEM_SUFFIX; - else - i.suffix = DWORD_MNEM_SUFFIX; - *op_string += 9; - return DWORD_PTR; - } + else if (!strncasecmp (*op_string, "DWORD PTR", 9)) + { + if (got_a_float == 1) /* "f..." */ + i.suffix = SHORT_MNEM_SUFFIX; + else + i.suffix = LONG_MNEM_SUFFIX; + *op_string += 9; + return DWORD_PTR; + } - else if (!strncasecmp (*op_string, "QWORD PTR", 9)) - { - i.suffix = INTEL_DWORD_MNEM_SUFFIX; - *op_string += 9; - return QWORD_PTR; - } + else if (!strncasecmp (*op_string, "QWORD PTR", 9)) + { + i.suffix = DWORD_MNEM_SUFFIX; + *op_string += 9; + return QWORD_PTR; + } - else if (!strncasecmp (*op_string, "XWORD PTR", 9)) - { - i.suffix = LONG_DOUBLE_MNEM_SUFFIX; - *op_string += 9; - return XWORD_PTR; - } + else if (!strncasecmp (*op_string, "XWORD PTR", 9)) + { + i.suffix = LONG_DOUBLE_MNEM_SUFFIX; + *op_string += 9; + return XWORD_PTR; + } - else if (!strncasecmp (*op_string, "SHORT", 5)) - { - *op_string += 5; - return SHORT; - } + else if (!strncasecmp (*op_string, "SHORT", 5)) + { + *op_string += 5; + return SHORT; + } - else if (!strncasecmp (*op_string, "OFFSET FLAT:", 12)) - { - *op_string += 12; - return OFFSET_FLAT; - } + else if (!strncasecmp (*op_string, "OFFSET FLAT:", 12)) + { + *op_string += 12; + return OFFSET_FLAT; + } - else if (!strncasecmp (*op_string, "FLAT", 4)) - { - *op_string += 4; - return FLAT; - } + else if (!strncasecmp (*op_string, "FLAT", 4)) + { + *op_string += 4; + return FLAT; + } - else return NONE_FOUND; -} + else return NONE_FOUND; +} static char * build_displacement_string PARAMS ((int, char *)); @@ -2954,10 +2943,10 @@ build_displacement_string (initial_disp, op_string) temp_string[0] = '\0'; tc = end_of_operand_string = strchr (op_string, '['); - if ( initial_disp && !end_of_operand_string) + if (initial_disp && !end_of_operand_string) { strcpy (temp_string, op_string); - return (temp_string); + return temp_string; } /* Build the whole displacement string */ @@ -2967,45 +2956,46 @@ build_displacement_string (initial_disp, op_string) temp_string[end_of_operand_string - op_string] = '\0'; temp_disp = tc; } - else + else temp_disp = op_string; while (*temp_disp != '\0') { + char *end_op; int add_minus = (*temp_disp == '-'); if (*temp_disp == '+' || *temp_disp == '-' || *temp_disp == '[') - temp_disp++; + temp_disp++; if (is_space_char (*temp_disp)) - temp_disp++; + temp_disp++; /* Don't consider registers */ - if (*temp_disp != REGISTER_PREFIX - && !(allow_naked_reg && i386_is_reg (temp_disp))) - { - char *string_start = temp_disp; - - while (*temp_disp != ']' - && *temp_disp != '+' - && *temp_disp != '-' - && *temp_disp != '*') - ++temp_disp; - - if (add_minus) - strcat (temp_string, "-"); - else - strcat (temp_string, "+"); - - strncat (temp_string, string_start, temp_disp - string_start); - if (*temp_disp == '+' || *temp_disp == '-') - --temp_disp; - } + if ( !((*temp_disp == REGISTER_PREFIX || allow_naked_reg) + && parse_register (temp_disp, &end_op)) ) + { + char *string_start = temp_disp; + + while (*temp_disp != ']' + && *temp_disp != '+' + && *temp_disp != '-' + && *temp_disp != '*') + ++temp_disp; + + if (add_minus) + strcat (temp_string, "-"); + else + strcat (temp_string, "+"); + + strncat (temp_string, string_start, temp_disp - string_start); + if (*temp_disp == '+' || *temp_disp == '-') + --temp_disp; + } while (*temp_disp != '\0' - && *temp_disp != '+' - && *temp_disp != '-') - ++temp_disp; + && *temp_disp != '+' + && *temp_disp != '-') + ++temp_disp; } return temp_string; @@ -3048,8 +3038,8 @@ i386_parse_seg (op_string) if (*op_string++ != 's') { - as_bad (_("bad segment name `%s'"), op_string); - return 0; + as_bad (_("bad segment name `%s'"), op_string); + return 0; } if (is_space_char (*op_string)) @@ -3057,59 +3047,134 @@ i386_parse_seg (op_string) if (*op_string != ':') { - as_bad (_("bad segment name `%s'"), op_string); - return 0; + as_bad (_("bad segment name `%s'"), op_string); + return 0; } - return 1; - + return 1; + } -static int i386_intel_memory_operand PARAMS ((char *)); +static int i386_index_check PARAMS((const char *)); +/* Make sure the memory operand we've been dealt is valid. + Returns 1 on success, 0 on a failure. +*/ static int -i386_intel_memory_operand (op_string) - char *op_string; +i386_index_check (operand_string) + const char *operand_string; { +#if INFER_ADDR_PREFIX + int fudged = 0; + tryprefix: +#endif + if (flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0) + /* 16 bit mode checks */ + ? ((i.base_reg + && ((i.base_reg->reg_type & (Reg16|BaseIndex)) + != (Reg16|BaseIndex))) + || (i.index_reg + && (((i.index_reg->reg_type & (Reg16|BaseIndex)) + != (Reg16|BaseIndex)) + || ! (i.base_reg + && i.base_reg->reg_num < 6 + && i.index_reg->reg_num >= 6 + && i.log2_scale_factor == 0)))) + /* 32 bit mode checks */ + : ((i.base_reg + && (i.base_reg->reg_type & Reg32) == 0) + || (i.index_reg + && ((i.index_reg->reg_type & (Reg32|BaseIndex)) + != (Reg32|BaseIndex))))) + { +#if INFER_ADDR_PREFIX + if (i.prefix[ADDR_PREFIX] == 0 && stackop_size != '\0') + { + i.prefix[ADDR_PREFIX] = ADDR_PREFIX_OPCODE; + i.prefixes += 1; + /* Change the size of any displacement too. At most one of + Disp16 or Disp32 is set. + FIXME. There doesn't seem to be any real need for separate + Disp16 and Disp32 flags. The same goes for Imm16 and Imm32. + Removing them would probably clean up the code quite a lot. + */ + if (i.types[this_operand] & (Disp16|Disp32)) + i.types[this_operand] ^= (Disp16|Disp32); + fudged = 1; + goto tryprefix; + } + if (fudged) + as_bad (_("`%s' is not a valid base/index expression"), + operand_string); + else +#endif + as_bad (_("`%s' is not a valid %s bit base/index expression"), + operand_string, + flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0) ? "16" : "32"); + return 0; + } + return 1; +} + +static int i386_intel_memory_operand PARAMS ((char *)); + +static int +i386_intel_memory_operand (operand_string) + char *operand_string; +{ + char *op_string = operand_string; char *end_of_operand_string; - if (is_digit_char (*op_string) - && strchr (op_string, '[') == 0) + if ((i.mem_operands == 1 + && (current_templates->start->opcode_modifier & IsString) == 0) + || i.mem_operands == 2) { - if (!i386_immediate (op_string)) - return 0; - else - return 1; + as_bad (_("too many memory references for `%s'"), + current_templates->start->name); + return 0; } - /* Look for displacement preceding open bracket */ + /* First check for a segment override. */ if (*op_string != '[') { char *end_seg; - char *temp_string; end_seg = strchr (op_string, ':'); if (end_seg) - { - if (!i386_parse_seg (op_string)) - return 0; - op_string = end_seg + 1; - } + { + if (!i386_parse_seg (op_string)) + return 0; + op_string = end_seg + 1; + } + } + + /* Look for displacement preceding open bracket */ + if (*op_string != '[') + { + char *temp_string; + + if (i.disp_operands) + return 0; temp_string = build_displacement_string (true, op_string); + if (!i386_displacement (temp_string, temp_string + strlen (temp_string))) - return 0; + { + free (temp_string); + return 0; + } + free (temp_string); end_of_operand_string = strchr (op_string, '['); if (!end_of_operand_string) - end_of_operand_string = op_string + strlen (op_string); + end_of_operand_string = op_string + strlen (op_string); if (is_space_char (*end_of_operand_string)) - --end_of_operand_string; + --end_of_operand_string; op_string = end_of_operand_string; - } + } if (*op_string == '[') { @@ -3120,92 +3185,101 @@ i386_intel_memory_operand (op_string) end_of_operand_string = op_string; while (*op_string != ']') - { - - while (*end_of_operand_string != '+' - && *end_of_operand_string != '-' - && *end_of_operand_string != '*' - && *end_of_operand_string != ']') - end_of_operand_string++; - - if (*op_string == '+') - { - char *temp_string = op_string + 1; - if (is_space_char (*temp_string)) - ++temp_string; - if (*temp_string == REGISTER_PREFIX - || (allow_naked_reg && i386_is_reg (temp_string))) - ++op_string; - } - - if (*op_string == REGISTER_PREFIX - || (allow_naked_reg && i386_is_reg (op_string))) - { - const reg_entry *temp_reg; - char *end_op; - - END_STRING_AND_SAVE (end_of_operand_string); - temp_reg = parse_register (op_string, &end_op); - RESTORE_END_STRING (end_of_operand_string); - - if (temp_reg == NULL) - return 0; - - if (i.base_reg == NULL) - i.base_reg = temp_reg; - else - i.index_reg = temp_reg; - - i.types[this_operand] |= BaseIndex; - - } - else if (is_digit_char (*op_string) || *op_string == '+' || *op_string == '-') - { - - char *temp_string = build_displacement_string (false, op_string); - - if (*temp_string == '+') - ++temp_string; - - if (!i386_displacement (temp_string, temp_string + strlen (temp_string))) - return 0; - - ++op_string; - end_of_operand_string = op_string; - while (*end_of_operand_string != ']' - && *end_of_operand_string != '+' - && *end_of_operand_string != '-' - && *end_of_operand_string != '*') - ++end_of_operand_string; - } - else if (*op_string == '*') - { - ++op_string; - - if (i.base_reg && !i.index_reg) - { - i.index_reg = i.base_reg; - i.base_reg = 0; - } - - if (!i386_scale (op_string)) - return 0; - } - op_string = end_of_operand_string; - ++end_of_operand_string; - } + { + const reg_entry *temp_reg; + char *end_op; + char *temp_string; + + while (*end_of_operand_string != '+' + && *end_of_operand_string != '-' + && *end_of_operand_string != '*' + && *end_of_operand_string != ']') + end_of_operand_string++; + + temp_string = op_string; + if (*temp_string == '+') + { + ++temp_string; + if (is_space_char (*temp_string)) + ++temp_string; + } + + if ((*temp_string == REGISTER_PREFIX || allow_naked_reg) + && (temp_reg = parse_register (temp_string, &end_op)) != NULL) + { + if (i.base_reg == NULL) + i.base_reg = temp_reg; + else + i.index_reg = temp_reg; + + i.types[this_operand] |= BaseIndex; + } + else if (*temp_string == REGISTER_PREFIX) + { + as_bad (_("bad register name `%s'"), temp_string); + return 0; + } + else if (is_digit_char (*op_string) + || *op_string == '+' || *op_string == '-') + { + char *temp_str; + + if (i.disp_operands != 0) + return 0; + + temp_string = build_displacement_string (false, op_string); + + temp_str = temp_string; + if (*temp_str == '+') + ++temp_str; + + if (!i386_displacement (temp_str, temp_str + strlen (temp_str))) + { + free (temp_string); + return 0; + } + free (temp_string); + + ++op_string; + end_of_operand_string = op_string; + while (*end_of_operand_string != ']' + && *end_of_operand_string != '+' + && *end_of_operand_string != '-' + && *end_of_operand_string != '*') + ++end_of_operand_string; + } + else if (*op_string == '*') + { + ++op_string; + + if (i.base_reg && !i.index_reg) + { + i.index_reg = i.base_reg; + i.base_reg = 0; + } + + if (!i386_scale (op_string)) + return 0; + } + op_string = end_of_operand_string; + ++end_of_operand_string; + } } + if (i386_index_check (operand_string) == 0) + return 0; + + i.mem_operands++; return 1; } -static int i386_intel_operand PARAMS ((char *, int)); - static int i386_intel_operand (operand_string, got_a_float) char *operand_string; int got_a_float; { + const reg_entry * r; + char *end_op; char *op_string = operand_string; int operand_modifier = i386_operand_modifier (&op_string, got_a_float); @@ -3219,151 +3293,85 @@ i386_intel_operand (operand_string, got_a_float) case DWORD_PTR: case QWORD_PTR: case XWORD_PTR: - if ((i.mem_operands == 1 - && (current_templates->start->opcode_modifier & IsString) == 0) - || i.mem_operands == 2) - { - as_bad (_("too many memory references for `%s'"), - current_templates->start->name); - return 0; - } - if (!i386_intel_memory_operand (op_string)) - return 0; - - i.mem_operands++; + return 0; break; case FLAT: - case OFFSET_FLAT: if (!i386_immediate (op_string)) - return 0; + return 0; break; case SHORT: - case NONE_FOUND: - /* Should be register or immediate */ - if (is_digit_char (*op_string) - && strchr (op_string, '[') == 0) - { - if (!i386_immediate (op_string)) - return 0; - } - else if (*op_string == REGISTER_PREFIX - || (allow_naked_reg - && i386_is_reg (op_string))) - { - - register const reg_entry * r; - char *end_op; - - r = parse_register (op_string, &end_op); - if (r == NULL) - return 0; - - /* Check for a segment override by searching for ':' after a - segment register. */ - op_string = end_op; - if (is_space_char (*op_string)) - ++op_string; - if (*op_string == ':' && (r->reg_type & (SReg2 | SReg3))) - { - switch (r->reg_num) - { - case 0: - i.seg[i.mem_operands] = &es; - break; - case 1: - i.seg[i.mem_operands] = &cs; - break; - case 2: - i.seg[i.mem_operands] = &ss; - break; - case 3: - i.seg[i.mem_operands] = &ds; - break; - case 4: - i.seg[i.mem_operands] = &fs; - break; - case 5: - i.seg[i.mem_operands] = &gs; - break; - } - - } - i.types[this_operand] |= r->reg_type & ~BaseIndex; - i.regs[this_operand] = r; - i.reg_operands++; - } - - else - { - - if (!i386_intel_memory_operand (op_string)) - return 0; - - i.mem_operands++; - } - break; - - } /* end switch */ - /* Special case for (%dx) while doing input/output op. */ - if (i.base_reg - && i.base_reg->reg_type == (Reg16 | InOutPortReg) - && i.index_reg == 0 - && i.log2_scale_factor == 0 - && i.seg[i.mem_operands] == 0 - && (i.types[this_operand] & Disp) == 0) - { - i.types[this_operand] = InOutPortReg; - return 1; - } - /* Make sure the memory operand we've been dealt is valid. */ - if (flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0)) - { - if ((i.base_reg - && ((i.base_reg->reg_type & (Reg16|BaseIndex)) - != (Reg16|BaseIndex))) - || (i.index_reg - && (((i.index_reg->reg_type & (Reg16|BaseIndex)) - != (Reg16|BaseIndex)) - || ! (i.base_reg - && i.base_reg->reg_num < 6 - && i.index_reg->reg_num >= 6 - && i.log2_scale_factor == 0)))) - { - as_bad (_("`%s' is not a valid %s bit base/index expression"), - operand_string, "16"); - return 0; - } - } - else + /* Should be register or immediate */ + if (is_digit_char (*op_string) + && strchr (op_string, '[') == 0) { - if ((i.base_reg - && (i.base_reg->reg_type & Reg32) == 0) - || (i.index_reg - && ((i.index_reg->reg_type & (Reg32|BaseIndex)) - != (Reg32|BaseIndex)))) + if (!i386_immediate (op_string)) + return 0; + } + else if ((*op_string == REGISTER_PREFIX || allow_naked_reg) + && (r = parse_register (op_string, &end_op)) != NULL) + { + /* Check for a segment override by searching for ':' after a + segment register. */ + op_string = end_op; + if (is_space_char (*op_string)) + ++op_string; + if (*op_string == ':' && (r->reg_type & (SReg2 | SReg3))) { - as_bad (_("`%s' is not a valid %s bit base/index expression"), - operand_string, "32"); - return 0; + switch (r->reg_num) + { + case 0: + i.seg[i.mem_operands] = &es; + break; + case 1: + i.seg[i.mem_operands] = &cs; + break; + case 2: + i.seg[i.mem_operands] = &ss; + break; + case 3: + i.seg[i.mem_operands] = &ds; + break; + case 4: + i.seg[i.mem_operands] = &fs; + break; + case 5: + i.seg[i.mem_operands] = &gs; + break; + } + } + i.types[this_operand] |= r->reg_type & ~BaseIndex; + i.op[this_operand].regs = r; + i.reg_operands++; } + else if (*op_string == REGISTER_PREFIX) + { + as_bad (_("bad register name `%s'"), op_string); + return 0; + } + else if (!i386_intel_memory_operand (op_string)) + return 0; + + break; + } /* end switch */ + return 1; } /* Parse OPERAND_STRING into the i386_insn structure I. Returns non-zero on error. */ -static int i386_operand PARAMS ((char *)); - static int i386_operand (operand_string) char *operand_string; { + const reg_entry *r; + char *end_op; char *op_string = operand_string; if (is_space_char (*op_string)) @@ -3375,31 +3383,24 @@ i386_operand (operand_string) { ++op_string; if (is_space_char (*op_string)) - ++op_string; + ++op_string; i.types[this_operand] |= JumpAbsolute; } /* Check if operand is a register. */ - if (*op_string == REGISTER_PREFIX - || (allow_naked_reg && i386_is_reg (op_string))) + if ((*op_string == REGISTER_PREFIX || allow_naked_reg) + && (r = parse_register (op_string, &end_op)) != NULL) { - register const reg_entry *r; - char *end_op; - - r = parse_register (op_string, &end_op); - if (r == NULL) - return 0; - /* Check for a segment override by searching for ':' after a segment register. */ op_string = end_op; if (is_space_char (*op_string)) - ++op_string; + ++op_string; if (*op_string == ':' && (r->reg_type & (SReg2 | SReg3))) - { - switch (r->reg_num) - { - case 0: + { + switch (r->reg_num) + { + case 0: i.seg[i.mem_operands] = &es; break; case 1: @@ -3424,8 +3425,6 @@ i386_operand (operand_string) if (is_space_char (*op_string)) ++op_string; - /* Pretend given string starts here. */ - operand_string = op_string; if (!is_digit_char (*op_string) && !is_identifier_char (*op_string) && *op_string != '(' @@ -3446,34 +3445,41 @@ i386_operand (operand_string) } if (*op_string) { - as_bad (_("Junk `%s' after register"), op_string); + as_bad (_("junk `%s' after register"), op_string); return 0; } i.types[this_operand] |= r->reg_type & ~BaseIndex; - i.regs[this_operand] = r; + i.op[this_operand].regs = r; i.reg_operands++; } + else if (*op_string == REGISTER_PREFIX) + { + as_bad (_("bad register name `%s'"), op_string); + return 0; + } else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */ ++op_string; + if (i.types[this_operand] & JumpAbsolute) + { + as_bad (_("immediate operand illegal with absolute jump")); + return 0; + } if (!i386_immediate (op_string)) - return 0; + return 0; } - else if (is_digit_char (*op_string) - || is_identifier_char (*op_string) + else if (is_digit_char (*op_string) + || is_identifier_char (*op_string) || *op_string == '(' ) { /* This is a memory reference of some sort. */ - char *end_of_operand_string; - register char *base_string; - int found_base_index_form; + char *base_string; /* Start and end of displacement string expression (if found). */ char *displacement_string_start; char *displacement_string_end; do_memory_reference: - if ((i.mem_operands == 1 && (current_templates->start->opcode_modifier & IsString) == 0) || i.mem_operands == 2) @@ -3487,17 +3493,19 @@ i386_operand (operand_string) looking for an ')' at the end of the operand, searching for the '(' matching it, and finding a REGISTER_PREFIX or ',' after the '('. */ - found_base_index_form = 0; - end_of_operand_string = op_string + strlen (op_string); + base_string = op_string + strlen (op_string); - --end_of_operand_string; - if (is_space_char (*end_of_operand_string)) - --end_of_operand_string; + --base_string; + if (is_space_char (*base_string)) + --base_string; - base_string = end_of_operand_string; + /* If we only have a displacement, set-up for it to be parsed later. */ + displacement_string_start = op_string; + displacement_string_end = base_string + 1; if (*base_string == ')') { + char *temp_string; unsigned int parens_balanced = 1; /* We've already checked that the number of left & right ()'s are equal, so this loop will not be infinite. */ @@ -3511,115 +3519,93 @@ i386_operand (operand_string) } while (parens_balanced); - /* If there is a displacement set-up for it to be parsed later. */ - displacement_string_start = op_string; - displacement_string_end = base_string; + temp_string = base_string; /* Skip past '(' and whitespace. */ ++base_string; if (is_space_char (*base_string)) ++base_string; - if (*base_string == REGISTER_PREFIX - || (allow_naked_reg && i386_is_reg (base_string)) - || *base_string == ',') - found_base_index_form = 1; - } - - /* If we can't parse a base index register expression, we've found - a pure displacement expression. We set up displacement_string_start - and displacement_string_end for the code below. */ - if (!found_base_index_form) - { - displacement_string_start = op_string; - displacement_string_end = end_of_operand_string + 1; - } - else - { - i.types[this_operand] |= BaseIndex; - - /* Find base register (if any). */ - if (*base_string != ',') + if (*base_string == ',' + || ((*base_string == REGISTER_PREFIX || allow_naked_reg) + && (i.base_reg = parse_register (base_string, &end_op)) != NULL)) { - char *end_op; - - /* Trim off the closing ')' so that parse_register won't - see it. */ - END_STRING_AND_SAVE (end_of_operand_string); - i.base_reg = parse_register (base_string, &end_op); - RESTORE_END_STRING (end_of_operand_string); - - if (i.base_reg == NULL) - return 0; + displacement_string_end = temp_string; - base_string = end_op; - if (is_space_char (*base_string)) - ++base_string; - } + i.types[this_operand] |= BaseIndex; - /* There may be an index reg or scale factor here. */ - if (*base_string == ',') - { - ++base_string; - if (is_space_char (*base_string)) - ++base_string; - - if (*base_string == REGISTER_PREFIX - || (allow_naked_reg && i386_is_reg (base_string))) + if (i.base_reg) { - char *end_op; - - END_STRING_AND_SAVE (end_of_operand_string); - i.index_reg = parse_register (base_string, &end_op); - RESTORE_END_STRING (end_of_operand_string); - - if (i.index_reg == NULL) - return 0; - base_string = end_op; if (is_space_char (*base_string)) ++base_string; - if (*base_string == ',') + } + + /* There may be an index reg or scale factor here. */ + if (*base_string == ',') + { + ++base_string; + if (is_space_char (*base_string)) + ++base_string; + + if ((*base_string == REGISTER_PREFIX || allow_naked_reg) + && (i.index_reg = parse_register (base_string, &end_op)) != NULL) { - ++base_string; + base_string = end_op; if (is_space_char (*base_string)) ++base_string; + if (*base_string == ',') + { + ++base_string; + if (is_space_char (*base_string)) + ++base_string; + } + else if (*base_string != ')' ) + { + as_bad (_("expecting `,' or `)' after index register in `%s'"), + operand_string); + return 0; + } } - else if (*base_string != ')' ) + else if (*base_string == REGISTER_PREFIX) { - as_bad (_("expecting `,' or `)' after index register in `%s'"), - operand_string); + as_bad (_("bad register name `%s'"), base_string); return 0; } - } - /* Check for scale factor. */ - if (isdigit ((unsigned char) *base_string)) - { - if (!i386_scale (base_string)) - return 0; + /* Check for scale factor. */ + if (isdigit ((unsigned char) *base_string)) + { + if (!i386_scale (base_string)) + return 0; - ++base_string; - if (is_space_char (*base_string)) - ++base_string; - if (*base_string != ')') + ++base_string; + if (is_space_char (*base_string)) + ++base_string; + if (*base_string != ')') + { + as_bad (_("expecting `)' after scale factor in `%s'"), + operand_string); + return 0; + } + } + else if (!i.index_reg) { - as_bad (_("expecting `)' after scale factor in `%s'"), - operand_string); + as_bad (_("expecting index register or scale factor after `,'; got '%c'"), + *base_string); return 0; } } - else if (!i.index_reg) + else if (*base_string != ')') { - as_bad (_("expecting index register or scale factor after `,'; got '%c'"), - *base_string); + as_bad (_("expecting `,' or `)' after base register in `%s'"), + operand_string); return 0; } } - else if (*base_string != ')') + else if (*base_string == REGISTER_PREFIX) { - as_bad (_("expecting `,' or `)' after base register in `%s'"), - operand_string); + as_bad (_("bad register name `%s'"), base_string); return 0; } } @@ -3629,9 +3615,9 @@ i386_operand (operand_string) displacement_string_end are meaningful. */ if (displacement_string_start != displacement_string_end) { - if (!i386_displacement (displacement_string_start, - displacement_string_end)) - return 0; + if (!i386_displacement (displacement_string_start, + displacement_string_end)) + return 0; } /* Special case for (%dx) while doing input/output op. */ @@ -3645,38 +3631,9 @@ i386_operand (operand_string) i.types[this_operand] = InOutPortReg; return 1; } - /* Make sure the memory operand we've been dealt is valid. */ - if (flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0)) - { - if ((i.base_reg - && ((i.base_reg->reg_type & (Reg16|BaseIndex)) - != (Reg16|BaseIndex))) - || (i.index_reg - && (((i.index_reg->reg_type & (Reg16|BaseIndex)) - != (Reg16|BaseIndex)) - || ! (i.base_reg - && i.base_reg->reg_num < 6 - && i.index_reg->reg_num >= 6 - && i.log2_scale_factor == 0)))) - { - as_bad (_("`%s' is not a valid %s bit base/index expression"), - operand_string, "16"); - return 0; - } - } - else - { - if ((i.base_reg - && (i.base_reg->reg_type & Reg32) == 0) - || (i.index_reg - && ((i.index_reg->reg_type & (Reg32|BaseIndex)) - != (Reg32|BaseIndex)))) - { - as_bad (_("`%s' is not a valid %s bit base/index expression"), - operand_string, "32"); - return 0; - } - } + + if (i386_index_check (operand_string) == 0) + return 0; i.mem_operands++; } else @@ -3691,7 +3648,7 @@ i386_operand (operand_string) } /* - * md_estimate_size_before_relax() + * md_estimate_size_before_relax() * * Called just before relax(). * Any symbol that is now undefined will not become defined. @@ -3719,7 +3676,24 @@ md_estimate_size_before_relax (fragP, segment) /* symbol is undefined in this segment */ int code16 = fragP->fr_subtype & CODE16; int size = code16 ? 2 : 4; - int pcrel_reloc = code16 ? BFD_RELOC_16_PCREL : BFD_RELOC_32_PCREL; +#ifdef BFD_ASSEMBLER + enum bfd_reloc_code_real reloc_type; +#else + int reloc_type; +#endif + + if (GOT_symbol /* Not quite right - we should switch on presence of + @PLT, but I cannot see how to get to that from + here. We should have done this in md_assemble to + really get it right all of the time, but I think it + does not matter that much, as this will be right + most of the time. ERY */ + && S_GET_SEGMENT(fragP->fr_symbol) == undefined_section) + reloc_type = BFD_RELOC_386_PLT32; + else if (code16) + reloc_type = BFD_RELOC_16_PCREL; + else + reloc_type = BFD_RELOC_32_PCREL; switch (opcode[0]) { @@ -3729,31 +3703,19 @@ md_estimate_size_before_relax (fragP, segment) fix_new (fragP, old_fr_fix, size, fragP->fr_symbol, fragP->fr_offset, 1, - (GOT_symbol && /* Not quite right - we should switch on - presence of @PLT, but I cannot see how - to get to that from here. We should have - done this in md_assemble to really - get it right all of the time, but I - think it does not matter that much, as - this will be right most of the time. ERY*/ - S_GET_SEGMENT(fragP->fr_symbol) == undefined_section) - ? BFD_RELOC_386_PLT32 : pcrel_reloc); + reloc_type); break; default: - /* This changes the byte-displacement jump 0x7N --> - the dword-displacement jump 0x0f8N */ + /* This changes the byte-displacement jump 0x7N + to the dword-displacement jump 0x0f,0x8N. */ opcode[1] = opcode[0] + 0x10; - opcode[0] = TWO_BYTE_OPCODE_ESCAPE; /* two-byte escape */ + opcode[0] = TWO_BYTE_OPCODE_ESCAPE; fragP->fr_fix += 1 + size; /* we've added an opcode byte */ fix_new (fragP, old_fr_fix + 1, size, fragP->fr_symbol, fragP->fr_offset, 1, - (GOT_symbol && /* Not quite right - we should switch on - presence of @PLT, but I cannot see how - to get to that from here. ERY */ - S_GET_SEGMENT(fragP->fr_symbol) == undefined_section) - ? BFD_RELOC_386_PLT32 : pcrel_reloc); + reloc_type); break; } frag_wane (fragP); @@ -3775,14 +3737,14 @@ md_estimate_size_before_relax (fragP, segment) #ifndef BFD_ASSEMBLER void md_convert_frag (headers, sec, fragP) - object_headers *headers; - segT sec; + object_headers *headers ATTRIBUTE_UNUSED; + segT sec ATTRIBUTE_UNUSED; register fragS *fragP; #else void md_convert_frag (abfd, sec, fragP) - bfd *abfd; - segT sec; + bfd *abfd ATTRIBUTE_UNUSED; + segT sec ATTRIBUTE_UNUSED; register fragS *fragP; #endif { @@ -3798,7 +3760,7 @@ md_convert_frag (abfd, sec, fragP) /* Address we want to reach in file space. */ target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset; #ifdef BFD_ASSEMBLER /* not needed otherwise? */ - target_address += fragP->fr_symbol->sy_frag->fr_address; + target_address += symbol_get_frag (fragP->fr_symbol)->fr_address; #endif /* Address opcode resides at in file space. */ @@ -3864,8 +3826,8 @@ void md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) char *ptr; addressT from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; + fragS *frag ATTRIBUTE_UNUSED; + symbolS *to_symbol ATTRIBUTE_UNUSED; { long offset; @@ -3910,20 +3872,39 @@ int md_apply_fix3 (fixP, valp, seg) fixS *fixP; /* The fix we're to put in. */ valueT *valp; /* Pointer to the value of the bits. */ - segT seg; /* Segment fix is from. */ + segT seg ATTRIBUTE_UNUSED; /* Segment fix is from. */ { register char *p = fixP->fx_where + fixP->fx_frag->fr_literal; valueT value = *valp; - if (fixP->fx_r_type == BFD_RELOC_32 && fixP->fx_pcrel) - fixP->fx_r_type = BFD_RELOC_32_PCREL; - #if defined (BFD_ASSEMBLER) && !defined (TE_Mach) - /* - * This is a hack. There should be a better way to - * handle this. - */ - if (fixP->fx_r_type == BFD_RELOC_32_PCREL && fixP->fx_addsy) + if (fixP->fx_pcrel) + { + switch (fixP->fx_r_type) + { + default: + break; + + case BFD_RELOC_32: + fixP->fx_r_type = BFD_RELOC_32_PCREL; + break; + case BFD_RELOC_16: + fixP->fx_r_type = BFD_RELOC_16_PCREL; + break; + case BFD_RELOC_8: + fixP->fx_r_type = BFD_RELOC_8_PCREL; + break; + } + } + + /* This is a hack. There should be a better way to handle this. + This covers for the fact that bfd_install_relocation will + subtract the current location (for partial_inplace, PC relative + relocations); see more below. */ + if ((fixP->fx_r_type == BFD_RELOC_32_PCREL + || fixP->fx_r_type == BFD_RELOC_16_PCREL + || fixP->fx_r_type == BFD_RELOC_8_PCREL) + && fixP->fx_addsy) { #ifndef OBJ_AOUT if (OUTPUT_FLAVOR == bfd_target_elf_flavour @@ -3934,28 +3915,59 @@ md_apply_fix3 (fixP, valp, seg) value += fixP->fx_where + fixP->fx_frag->fr_address; #endif #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) - if (OUTPUT_FLAVOR == bfd_target_elf_flavour - && (S_GET_SEGMENT (fixP->fx_addsy) == seg - || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) - && ! S_IS_EXTERNAL (fixP->fx_addsy) - && ! S_IS_WEAK (fixP->fx_addsy) - && S_IS_DEFINED (fixP->fx_addsy) - && ! S_IS_COMMON (fixP->fx_addsy)) + if (OUTPUT_FLAVOR == bfd_target_elf_flavour) { - /* Yes, we add the values in twice. This is because - bfd_perform_relocation subtracts them out again. I think - bfd_perform_relocation is broken, but I don't dare change - it. FIXME. */ - value += fixP->fx_where + fixP->fx_frag->fr_address; + segT fseg = S_GET_SEGMENT (fixP->fx_addsy); + + if ((fseg == seg + || (symbol_section_p (fixP->fx_addsy) + && fseg != absolute_section)) + && ! S_IS_EXTERNAL (fixP->fx_addsy) + && ! S_IS_WEAK (fixP->fx_addsy) + && S_IS_DEFINED (fixP->fx_addsy) + && ! S_IS_COMMON (fixP->fx_addsy)) + { + /* Yes, we add the values in twice. This is because + bfd_perform_relocation subtracts them out again. I think + bfd_perform_relocation is broken, but I don't dare change + it. FIXME. */ + value += fixP->fx_where + fixP->fx_frag->fr_address; + } } #endif #if defined (OBJ_COFF) && defined (TE_PE) /* For some reason, the PE format does not store a section - address offset for a PC relative symbol. */ + address offset for a PC relative symbol. */ if (S_GET_SEGMENT (fixP->fx_addsy) != seg) value += md_pcrel_from (fixP); + else if (S_IS_EXTERNAL (fixP->fx_addsy) + || S_IS_WEAK (fixP->fx_addsy)) + { + /* We are generating an external relocation for this defined + symbol. We add the address, because + bfd_install_relocation will subtract it. VALUE already + holds the symbol value, because fixup_segment added it + in. We subtract it out, and then we subtract it out + again because bfd_install_relocation will add it in + again. */ + value += md_pcrel_from (fixP); + value -= 2 * S_GET_VALUE (fixP->fx_addsy); + } #endif } +#ifdef TE_PE + else if (fixP->fx_addsy != NULL + && S_IS_DEFINED (fixP->fx_addsy) + && (S_IS_EXTERNAL (fixP->fx_addsy) + || S_IS_WEAK (fixP->fx_addsy))) + { + /* We are generating an external relocation for this defined + symbol. VALUE already holds the symbol value, and + bfd_install_relocation will add it in again. We don't want + either addition. */ + value -= 2 * S_GET_VALUE (fixP->fx_addsy); + } +#endif /* Fix a few things - the dynamic linker expects certain values here, and we must not dissappoint it. */ @@ -3970,19 +3982,19 @@ md_apply_fix3 (fixP, valp, seg) break; case BFD_RELOC_386_GOTPC: /* - * This is tough to explain. We end up with this one if we have + * This is tough to explain. We end up with this one if we have * operands that look like "_GLOBAL_OFFSET_TABLE_+[.-.L284]". The goal * here is to obtain the absolute address of the GOT, and it is strongly * preferable from a performance point of view to avoid using a runtime - * relocation for this. The actual sequence of instructions often look + * relocation for this. The actual sequence of instructions often look * something like: - * - * call .L66 + * + * call .L66 * .L66: - * popl %ebx - * addl $_GLOBAL_OFFSET_TABLE_+[.-.L66],%ebx - * - * The call and pop essentially return the absolute address of + * popl %ebx + * addl $_GLOBAL_OFFSET_TABLE_+[.-.L66],%ebx + * + * The call and pop essentially return the absolute address of * the label .L66 and store it in %ebx. The linker itself will * ultimately change the first operand of the addl so that %ebx points to * the GOT, but to keep things simple, the .o file must have this operand @@ -3991,17 +4003,17 @@ md_apply_fix3 (fixP, valp, seg) * treat a GOTPC relocation as asking for a pcrel offset to the GOT to be * added in, and the addend of the relocation is stored in the operand * field for the instruction itself. - * - * Our job here is to fix the operand so that it would add the correct + * + * Our job here is to fix the operand so that it would add the correct * offset so that %ebx would point to itself. The thing that is tricky is * that .-.L66 will point to the beginning of the instruction, so we need * to further modify the operand so that it will point to itself. * There are other cases where you have something like: - * - * .long $_GLOBAL_OFFSET_TABLE_+[.-.L66] - * + * + * .long $_GLOBAL_OFFSET_TABLE_+[.-.L66] + * * and here no correction would be required. Internally in the assembler - * we treat operands of this form as not being pcrel since the '.' is + * we treat operands of this form as not being pcrel since the '.' is * explicitly mentioned, and I wonder whether it would simplify matters * to do it this way. Who knows. In earlier versions of the PIC patches, * the pcrel_adjust field was used to store the correction, but since the @@ -4010,7 +4022,7 @@ md_apply_fix3 (fixP, valp, seg) value -= 1; break; case BFD_RELOC_386_GOT32: - value = 0; /* Fully resolved at runtime. No addend. */ + value = 0; /* Fully resolved at runtime. No addend. */ break; case BFD_RELOC_386_GOTOFF: break; @@ -4023,9 +4035,9 @@ md_apply_fix3 (fixP, valp, seg) default: break; } -#endif - -#endif +#endif /* defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) */ + *valp = value; +#endif /* defined (BFD_ASSEMBLER) && !defined (TE_Mach) */ md_number_to_chars (p, value, fixP->fx_size); return 1; @@ -4056,7 +4068,7 @@ md_chars_to_number (con, nbytes) is stored in *sizeP . An error message is returned, or NULL on OK. */ char * md_atof (type, litP, sizeP) - char type; + int type; char *litP; int *sizeP; { @@ -4116,17 +4128,16 @@ output_invalid (c) return output_invalid_buf; } -/* REG_STRING starts *before* REGISTER_PREFIX. */ -static const reg_entry * parse_register PARAMS ((char *, char **)); +/* REG_STRING starts *before* REGISTER_PREFIX. */ static const reg_entry * parse_register (reg_string, end_op) char *reg_string; char **end_op; { - register char *s = reg_string; - register char *p; + char *s = reg_string; + char *p; char reg_name_given[MAX_REG_NAME_SIZE + 1]; const reg_entry *r; @@ -4138,35 +4149,49 @@ parse_register (reg_string, end_op) ++s; p = reg_name_given; - while ((*p++ = register_chars[(unsigned char) *s++]) != '\0') + while ((*p++ = register_chars[(unsigned char) *s]) != '\0') { if (p >= reg_name_given + MAX_REG_NAME_SIZE) - { - if (!allow_naked_reg) - { - *p = '\0'; - as_bad (_("bad register name `%s'"), reg_name_given); - } - return (const reg_entry *) NULL; - } + return (const reg_entry *) NULL; + s++; } - *end_op = s - 1; + *end_op = s; r = (const reg_entry *) hash_find (reg_hash, reg_name_given); - if (r == NULL) + /* Handle floating point regs, allowing spaces in the (i) part. */ + if (r == i386_regtab /* %st is first entry of table */) { - if (!allow_naked_reg) - as_bad (_("bad register name `%s'"), reg_name_given); - return (const reg_entry *) NULL; + if (is_space_char (*s)) + ++s; + if (*s == '(') + { + ++s; + if (is_space_char (*s)) + ++s; + if (*s >= '0' && *s <= '7') + { + r = &i386_float_regtab[*s - '0']; + ++s; + if (is_space_char (*s)) + ++s; + if (*s == ')') + { + *end_op = s + 1; + return r; + } + } + /* We have "%st(" then garbage */ + return (const reg_entry *) NULL; + } } return r; } -#ifdef OBJ_ELF -CONST char *md_shortopts = "kmVQ:"; +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) +CONST char *md_shortopts = "kmVQ:sq"; #else CONST char *md_shortopts = "m"; #endif @@ -4178,7 +4203,7 @@ size_t md_longopts_size = sizeof (md_longopts); int md_parse_option (c, arg) int c; - char *arg; + char *arg ATTRIBUTE_UNUSED; { switch (c) { @@ -4200,6 +4225,16 @@ md_parse_option (c, arg) should be emitted or not. FIXME: Not implemented. */ case 'Q': break; + + case 's': + /* -s: On i386 Solaris, this tells the native assembler to use + .stab instead of .stab.excl. We always use .stab anyhow. */ + break; + + case 'q': + /* -q: On i386 Solaris, this tells the native assembler does + fewer checks. */ + break; #endif default: @@ -4213,12 +4248,21 @@ md_show_usage (stream) FILE *stream; { fprintf (stream, _("\ --m do long jump\n")); + -m do long jump\n")); +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + fprintf (stream, _("\ + -V print assembler version number\n\ + -k ignored\n\ + -Qy, -Qn ignored\n\ + -q ignored\n\ + -s ignored\n")); +#endif } #ifdef BFD_ASSEMBLER -#ifdef OBJ_MAYBE_ELF -#ifdef OBJ_MAYBE_COFF +#if ((defined (OBJ_MAYBE_ELF) && defined (OBJ_MAYBE_COFF)) \ + || (defined (OBJ_MAYBE_ELF) && defined (OBJ_MAYBE_AOUT)) \ + || (defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT))) /* Pick the target format to use. */ @@ -4227,57 +4271,68 @@ i386_target_format () { switch (OUTPUT_FLAVOR) { +#ifdef OBJ_MAYBE_AOUT + case bfd_target_aout_flavour: + return AOUT_TARGET_FORMAT; +#endif +#ifdef OBJ_MAYBE_COFF case bfd_target_coff_flavour: return "coff-i386"; +#endif +#ifdef OBJ_MAYBE_ELF case bfd_target_elf_flavour: return "elf32-i386"; +#endif default: abort (); return NULL; } } -#endif /* OBJ_MAYBE_COFF */ -#endif /* OBJ_MAYBE_ELF */ +#endif /* OBJ_MAYBE_ more than one */ #endif /* BFD_ASSEMBLER */ -/* ARGSUSED */ symbolS * md_undefined_symbol (name) char *name; { - if (*name == '_' && *(name+1) == 'G' - && strcmp(name, GLOBAL_OFFSET_TABLE_NAME) == 0) - { - if (!GOT_symbol) - { - if (symbol_find (name)) - as_bad (_("GOT already in symbol table")); - GOT_symbol = symbol_new (name, undefined_section, - (valueT) 0, &zero_address_frag); - }; - return GOT_symbol; - } + if (name[0] == GLOBAL_OFFSET_TABLE_NAME[0] + && name[1] == GLOBAL_OFFSET_TABLE_NAME[1] + && name[2] == GLOBAL_OFFSET_TABLE_NAME[2] + && strcmp (name, GLOBAL_OFFSET_TABLE_NAME) == 0) + { + if (!GOT_symbol) + { + if (symbol_find (name)) + as_bad (_("GOT already in symbol table")); + GOT_symbol = symbol_new (name, undefined_section, + (valueT) 0, &zero_address_frag); + }; + return GOT_symbol; + } return 0; } /* Round up a section size to the appropriate boundary. */ valueT md_section_align (segment, size) - segT segment; + segT segment ATTRIBUTE_UNUSED; valueT size; { -#ifdef OBJ_AOUT #ifdef BFD_ASSEMBLER - /* For a.out, force the section size to be aligned. If we don't do - this, BFD will align it for us, but it will not write out the - final bytes of the section. This may be a bug in BFD, but it is - easier to fix it here since that is how the other a.out targets - work. */ - int align; - - align = bfd_get_section_alignment (stdoutput, segment); - size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); +#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)) + if (OUTPUT_FLAVOR == bfd_target_aout_flavour) + { + /* For a.out, force the section size to be aligned. If we don't do + this, BFD will align it for us, but it will not write out the + final bytes of the section. This may be a bug in BFD, but it is + easier to fix it here since that is how the other a.out targets + work. */ + int align; + + align = bfd_get_section_alignment (stdoutput, segment); + size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); + } #endif #endif @@ -4299,7 +4354,7 @@ md_pcrel_from (fixP) static void s_bss (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { register int temp; @@ -4324,12 +4379,9 @@ i386_validate_fix (fixp) } } -#define F(SZ,PCREL) (((SZ) << 1) + (PCREL)) -#define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break - arelent * tc_gen_reloc (section, fixp) - asection *section; + asection *section ATTRIBUTE_UNUSED; fixS *fixp; { arelent *rel; @@ -4347,27 +4399,35 @@ tc_gen_reloc (section, fixp) code = fixp->fx_r_type; break; default: - switch (F (fixp->fx_size, fixp->fx_pcrel)) + if (fixp->fx_pcrel) { - MAP (1, 0, BFD_RELOC_8); - MAP (2, 0, BFD_RELOC_16); - MAP (4, 0, BFD_RELOC_32); - MAP (1, 1, BFD_RELOC_8_PCREL); - MAP (2, 1, BFD_RELOC_16_PCREL); - MAP (4, 1, BFD_RELOC_32_PCREL); - default: - if (fixp->fx_pcrel) - as_bad (_("Can not do %d byte pc-relative relocation"), - fixp->fx_size); - else - as_bad (_("Can not do %d byte relocation"), fixp->fx_size); - code = BFD_RELOC_32; - break; + switch (fixp->fx_size) + { + default: + as_bad (_("can not do %d byte pc-relative relocation"), + fixp->fx_size); + code = BFD_RELOC_32_PCREL; + break; + case 1: code = BFD_RELOC_8_PCREL; break; + case 2: code = BFD_RELOC_16_PCREL; break; + case 4: code = BFD_RELOC_32_PCREL; break; + } + } + else + { + switch (fixp->fx_size) + { + default: + as_bad (_("can not do %d byte relocation"), fixp->fx_size); + code = BFD_RELOC_32; + break; + case 1: code = BFD_RELOC_8; break; + case 2: code = BFD_RELOC_16; break; + case 4: code = BFD_RELOC_32; break; + } } break; } -#undef MAP -#undef F if (code == BFD_RELOC_32 && GOT_symbol @@ -4375,7 +4435,8 @@ tc_gen_reloc (section, fixp) code = BFD_RELOC_386_GOTPC; rel = (arelent *) xmalloc (sizeof (arelent)); - rel->sym_ptr_ptr = &fixp->fx_addsy->bsym; + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); rel->address = fixp->fx_frag->fr_address + fixp->fx_where; /* HACK: Since i386 ELF uses Rel instead of Rela, encode the @@ -4392,7 +4453,7 @@ tc_gen_reloc (section, fixp) if (rel->howto == NULL) { as_bad_where (fixp->fx_file, fixp->fx_line, - _("Cannot represent relocation type %s"), + _("cannot represent relocation type %s"), bfd_get_reloc_code_name (code)); /* Set howto to a garbage value so that we can keep going. */ rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32); @@ -4470,6 +4531,6 @@ tc_coff_sizemachdep (frag) #endif /* I386COFF */ -#endif /* BFD_ASSEMBLER? */ +#endif /* ! BFD_ASSEMBLER */ /* end of tc-i386.c */ diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index d876d61..1d830ee 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -1,5 +1,6 @@ /* tc-i386.h -- Header file for tc-i386.c - Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation. + Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -37,11 +38,6 @@ struct fix; type. The idea is that if the original type is already some kind of PIC relocation, we leave it alone, otherwise we give it the desired type */ -#define TC_RELOC(X,Y) (((X) != BFD_RELOC_386_PLT32 && \ - (X) != BFD_RELOC_386_GOTOFF && \ - (X) != BFD_RELOC_386_GOT32 && \ - (X) != BFD_RELOC_386_GOTPC) ? Y : X) - #define tc_fix_adjustable(X) tc_i386_fix_adjustable(X) extern int tc_i386_fix_adjustable PARAMS ((struct fix *)); @@ -73,35 +69,36 @@ extern int tc_i386_fix_adjustable PARAMS ((struct fix *)); #define TARGET_ARCH bfd_arch_i386 -#ifdef OBJ_AOUT #ifdef TE_NetBSD -#define TARGET_FORMAT "a.out-i386-netbsd" +#define AOUT_TARGET_FORMAT "a.out-i386-netbsd" #endif #ifdef TE_386BSD -#define TARGET_FORMAT "a.out-i386-bsd" +#define AOUT_TARGET_FORMAT "a.out-i386-bsd" #endif #ifdef TE_LINUX -#define TARGET_FORMAT "a.out-i386-linux" +#define AOUT_TARGET_FORMAT "a.out-i386-linux" #endif #ifdef TE_Mach -#define TARGET_FORMAT "a.out-mach3" +#define AOUT_TARGET_FORMAT "a.out-mach3" #endif #ifdef TE_DYNIX -#define TARGET_FORMAT "a.out-i386-dynix" +#define AOUT_TARGET_FORMAT "a.out-i386-dynix" #endif -#ifndef TARGET_FORMAT -#define TARGET_FORMAT "a.out-i386" +#ifndef AOUT_TARGET_FORMAT +#define AOUT_TARGET_FORMAT "a.out-i386" #endif -#endif /* OBJ_AOUT */ +#if ((defined (OBJ_MAYBE_ELF) && defined (OBJ_MAYBE_COFF)) \ + || (defined (OBJ_MAYBE_ELF) && defined (OBJ_MAYBE_AOUT)) \ + || (defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT))) +extern const char *i386_target_format PARAMS ((void)); +#define TARGET_FORMAT i386_target_format () +#else #ifdef OBJ_ELF #define TARGET_FORMAT "elf32-i386" #endif - -#ifdef OBJ_MAYBE_ELF -#ifdef OBJ_MAYBE_COFF -extern const char *i386_target_format PARAMS ((void)); -#define TARGET_FORMAT i386_target_format () +#ifdef OBJ_AOUT +#define TARGET_FORMAT AOUT_TARGET_FORMAT #endif #endif @@ -117,7 +114,21 @@ extern const char *i386_target_format PARAMS ((void)); extern short tc_coff_fix2rtype PARAMS ((struct fix *)); #define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) extern int tc_coff_sizemachdep PARAMS ((fragS *frag)); + +#ifdef TE_GO32 +/* DJGPP now expects some sections to be 2**4 aligned. */ +#define SUB_SEGMENT_ALIGN(SEG) \ + ((strcmp (obj_segment_name (SEG), ".text") == 0 \ + || strcmp (obj_segment_name (SEG), ".data") == 0 \ + || strncmp (obj_segment_name (SEG), ".gnu.linkonce.t", 15) == 0 \ + || strncmp (obj_segment_name (SEG), ".gnu.linkonce.d", 15) == 0 \ + || strncmp (obj_segment_name (SEG), ".gnu.linkonce.r", 15) == 0) \ + ? 4 \ + : 2) +#else #define SUB_SEGMENT_ALIGN(SEG) 2 +#endif + #define TC_RVA_RELOC 7 /* Need this for PIC relocations */ #define NEED_FX_R_TYPE @@ -201,7 +212,6 @@ extern const char extra_symbol_chars[]; #define NO_BASE_REGISTER_16 6 /* these are the instruction mnemonic suffixes. */ -#define DWORD_MNEM_SUFFIX 'l' #define WORD_MNEM_SUFFIX 'w' #define BYTE_MNEM_SUFFIX 'b' #define SHORT_MNEM_SUFFIX 's' @@ -209,7 +219,7 @@ extern const char extra_symbol_chars[]; /* Intel Syntax */ #define LONG_DOUBLE_MNEM_SUFFIX 'x' /* Intel Syntax */ -#define INTEL_DWORD_MNEM_SUFFIX 'd' +#define DWORD_MNEM_SUFFIX 'd' /* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */ #define REGMEM_FIELD_HAS_REG 0x3/* always = 0x3 */ @@ -270,14 +280,21 @@ extern const char extra_symbol_chars[]; #define Acc 0x200000 /* Accumulator %al or %ax or %eax */ #define JumpAbsolute 0x400000 #define RegMMX 0x800000 /* MMX register */ -#define EsSeg 0x1000000 /* String insn operand with fixed es segment */ +#define RegXMM 0x1000000 /* XMM registers in PIII */ +#define EsSeg 0x2000000 /* String insn operand with fixed es segment */ +/* InvMem is for instructions with a modrm byte that only allow a + general register encoding in the i.tm.mode and i.tm.regmem fields, + eg. control reg moves. They really ought to support a memory form, + but don't, so we add an InvMem flag to the register operand to + indicate that it should be encoded in the i.tm.regmem field. */ +#define InvMem 0x4000000 #define Reg (Reg8|Reg16|Reg32) /* gen'l register */ #define WordReg (Reg16|Reg32) #define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc) #define Imm (Imm8|Imm8S|Imm16|Imm32) /* gen'l immediate */ #define Disp (Disp8|Disp16|Disp32) /* General displacement */ -#define AnyMem (Disp|BaseIndex) /* General memory */ +#define AnyMem (Disp|BaseIndex|InvMem) /* General memory */ /* The following aliases are defined because the opcode table carefully specifies the allowed memory types for each instruction. At the moment we can only tell a memory reference size by the @@ -323,7 +340,6 @@ typedef struct #define D 0x2 /* D = 0 if Reg --> Regmem; D = 1 if Regmem --> Reg: MUST BE 0x2 */ #define Modrm 0x4 -#define ReverseRegRegmem 0x8 /* swap reg,regmem fields for 2 reg case */ #define FloatR 0x8 /* src/dest swap for floats: MUST BE 0x8 */ #define ShortForm 0x10 /* register is in low 3 bits of opcode */ #define FloatMF 0x20 /* FP insn memory format bit, sized by 0x4 */ @@ -337,16 +353,18 @@ typedef struct #define Size16 0x2000 /* needs size prefix if in 32-bit mode */ #define Size32 0x4000 /* needs size prefix if in 16-bit mode */ #define IgnoreSize 0x8000 /* instruction ignores operand size prefix */ -#define No_bSuf 0x10000 /* b suffix on instruction illegal */ -#define No_wSuf 0x20000 /* w suffix on instruction illegal */ -#define No_lSuf 0x40000 /* l suffix on instruction illegal */ -#define No_sSuf 0x80000 /* s suffix on instruction illegal */ -#define FWait 0x100000 /* instruction needs FWAIT */ -#define IsString 0x200000 /* quick test for string instructions */ -#define regKludge 0x400000 /* fake an extra reg operand for clr, imul */ -#define IsPrefix 0x800000 /* opcode is a prefix */ -#define No_dSuf 0x1000000 /* d suffix on instruction illegal */ -#define No_xSuf 0x2000000 /* x suffix on instruction illegal */ +#define DefaultSize 0x10000 /* default insn size depends on mode */ +#define No_bSuf 0x20000 /* b suffix on instruction illegal */ +#define No_wSuf 0x40000 /* w suffix on instruction illegal */ +#define No_lSuf 0x80000 /* l suffix on instruction illegal */ +#define No_sSuf 0x100000 /* s suffix on instruction illegal */ +#define No_dSuf 0x200000 /* d suffix on instruction illegal */ +#define No_xSuf 0x400000 /* x suffix on instruction illegal */ +#define FWait 0x800000 /* instruction needs FWAIT */ +#define IsString 0x1000000 /* quick test for string instructions */ +#define regKludge 0x2000000 /* fake an extra reg operand for clr, imul */ +#define IsPrefix 0x4000000 /* opcode is a prefix */ +#define ImmExt 0x8000000 /* instruction has extension in 8 bit imm */ #define Ugh 0x80000000 /* deprecated fp insn, gets a warning */ /* operand_types[i] describes the type of operand i. This is made @@ -422,21 +440,10 @@ void i386_validate_fix PARAMS ((struct fix *)); extern const struct relax_type md_relax_table[]; #define TC_GENERIC_RELAX_TABLE md_relax_table - -extern int flag_16bit_code; - -#ifdef BFD_ASSEMBLER -#define md_maybe_text() \ - ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0) -#else -#define md_maybe_text() \ - (now_seg != data_section && now_seg != bss_section) -#endif - #define md_do_align(n, fill, len, max, around) \ if ((n) && !need_pass_2 \ && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1)) \ - && md_maybe_text ()) \ + && subseg_text_p (now_seg)) \ { \ char *p; \ p = frag_var (rs_align_code, 15, 1, (relax_substateT) max, \ diff --git a/gas/config/tc-i860.c b/gas/config/tc-i860.c index f2e2b19..3317282 100644 --- a/gas/config/tc-i860.c +++ b/gas/config/tc-i860.c @@ -1,5 +1,5 @@ /* tc-i860.c -- Assemble for the I860 - Copyright (C) 1989, 92, 93, 94, 95, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 92, 93, 94, 95, 98, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -1118,9 +1118,9 @@ emit_machine_reloc (fixP, segment_address_in_file) ri.r_extern = 0; ri.r_symbolnum = S_GET_TYPE (symbolP); } - if (symbolP && symbolP->sy_frag) + if (symbolP && symbol_get_frag (symbolP)) { - ri.r_addend = symbolP->sy_frag->fr_address; + ri.r_addend = symbol_get_frag (symbolP)->fr_address; } ri.r_type = fixP->fx_r_type; if (fixP->fx_pcrel) @@ -1184,9 +1184,9 @@ tc_aout_fix_to_chars (where, fixP, segment_address_in_file) | ((r_extern << 6) & 0x40) | (fixP->fx_r_type & 0x3F)); - if (fixP->fx_addsy->sy_frag) + if (symbol_get_frag (fixP->fx_addsy)) { - r_addend = fixP->fx_addsy->sy_frag->fr_address; + r_addend = symbol_get_frag (fixP->fx_addsy)->fr_address; } if (fixP->fx_pcrel) diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index 936b662..d8c15c0 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -1,5 +1,5 @@ /* tc-i960.c - All the i80960-specific stuff - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GAS. @@ -101,7 +101,22 @@ #define TC_S_FORCE_TO_SYSPROC(s) (S_SET_STORAGE_CLASS((s), C_SCALL)) #else /* ! OBJ_COFF */ -you lose; +#ifdef OBJ_ELF +#define TC_S_IS_SYSPROC(s) 0 + +#define TC_S_IS_BALNAME(s) 0 +#define TC_S_IS_CALLNAME(s) 0 +#define TC_S_IS_BADPROC(s) 0 + +#define TC_S_SET_SYSPROC(s, p) +#define TC_S_GET_SYSPROC(s) 0 + +#define TC_S_FORCE_TO_BALNAME(s) +#define TC_S_FORCE_TO_CALLNAME(s) +#define TC_S_FORCE_TO_SYSPROC(s) +#else + #error COFF, a.out, b.out, and ELF are the only supported formats. +#endif /* ! OBJ_ELF */ #endif /* ! OBJ_COFF */ #endif /* ! OBJ_A/BOUT */ @@ -1009,7 +1024,6 @@ md_show_usage (stream) } -#ifndef BFD_ASSEMBLER /***************************************************************************** md_convert_frag: Called by base assembler after address relaxation is finished: modify @@ -1023,11 +1037,19 @@ md_show_usage (stream) Replace the cobr with a two instructions (a compare and a branch). *************************************************************************** */ +#ifndef BFD_ASSEMBLER void md_convert_frag (headers, seg, fragP) object_headers *headers; segT seg; fragS *fragP; +#else +void +md_convert_frag (abfd, sec, fragP) + bfd *abfd; + segT sec; + fragS *fragP; +#endif { fixS *fixP; /* Structure describing needed address fix */ @@ -1082,6 +1104,7 @@ md_estimate_size_before_relax (fragP, segment_type) return 0; } /* md_estimate_size_before_relax() */ +#if defined(OBJ_AOUT) | defined(OBJ_BOUT) /***************************************************************************** md_ri_to_chars: @@ -1096,7 +1119,8 @@ md_estimate_size_before_relax (fragP, segment_type) does do the reordering (Ian Taylor 28 Aug 92). *************************************************************************** */ -void + +static void md_ri_to_chars (where, ri) char *where; struct relocation_info *ri; @@ -1114,7 +1138,8 @@ md_ri_to_chars (where, ri) | (ri->r_callj << 6)); } -#endif /* BFD_ASSEMBLER */ +#endif /* defined(OBJ_AOUT) | defined(OBJ_BOUT) */ + /* FOLLOWING ARE THE LOCAL ROUTINES, IN ALPHABETICAL ORDER */ @@ -2613,7 +2638,9 @@ s_leafproc (n_ops, args) } TC_S_FORCE_TO_BALNAME (balP); +#ifndef OBJ_ELF tc_set_bal_of_call (callP, balP); +#endif } /* if only one arg, or the args are the same */ } @@ -2819,25 +2846,42 @@ md_pcrel_from (fixP) return fixP->fx_where + fixP->fx_frag->fr_address; } +#ifdef BFD_ASSEMBLER +int +md_apply_fix (fixP, valp) + fixS *fixP; + valueT *valp; +#else void md_apply_fix (fixP, val) fixS *fixP; long val; +#endif { +#ifdef BFD_ASSEMBLER + long val = *valp; +#endif char *place = fixP->fx_where + fixP->fx_frag->fr_literal; if (!fixP->fx_bit_fixP) { +#ifndef BFD_ASSEMBLER /* For callx, we always want to write out zero, and emit a symbolic relocation. */ if (fixP->fx_bsr) val = 0; fixP->fx_addnumber = val; +#endif + md_number_to_imm (place, val, fixP->fx_size, fixP); } else md_number_to_field (place, val, fixP->fx_bit_fixP); + +#ifdef BFD_ASSEMBLER + return 0; +#endif } #if defined(OBJ_AOUT) | defined(OBJ_BOUT) @@ -2937,8 +2981,14 @@ md_section_align (seg, addr) segT seg; valueT addr; /* Address to be rounded up */ { - return ((addr + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg])); -} /* md_section_align() */ + int align; +#ifdef BFD_ASSEMBLER + align = bfd_get_section_alignment (stdoutput, seg); +#else + align = section_alignment[(int) seg]; +#endif + return (addr + (1 << align) - 1) & (-1 << align); +} extern int coff_flags; @@ -3007,6 +3057,8 @@ tc_headers_hook (headers) #endif /* OBJ_COFF */ +#ifndef BFD_ASSEMBLER + /* Things going on here: For bout, We need to assure a couple of simplifying @@ -3066,6 +3118,8 @@ tc_crawl_symbol_chain (headers) } /* walk the symbol chain */ } +#endif /* ! BFD_ASSEMBLER */ + /* For aout or bout, the bal immediately follows the call. For coff, we cheat and store a pointer to the bal symbol in the @@ -3105,7 +3159,7 @@ tc_set_bal_of_call (callP, balP) } /* if not in order */ #else /* ! OBJ_ABOUT */ - (as yet unwritten.); + as_fatal ("Only supported for a.out, b.out, or COFF"); #endif /* ! OBJ_ABOUT */ #endif /* ! OBJ_COFF */ } @@ -3124,7 +3178,7 @@ tc_get_bal_of_call (callP) #ifdef OBJ_ABOUT retval = symbol_next (callP); #else - (as yet unwritten.); + as_fatal ("Only supported for a.out, b.out, or COFF"); #endif /* ! OBJ_ABOUT */ #endif /* ! OBJ_COFF */ @@ -3228,4 +3282,68 @@ i960_validate_fix (fixP, this_segment_type, add_symbolPP) return 0; } +#ifdef BFD_ASSEMBLER + +/* From cgen.c: */ + +static short +tc_bfd_fix2rtype (fixP) + fixS *fixP; +{ +#if 0 + if (fixP->fx_bsr) + abort (); +#endif + + if (fixP->fx_pcrel == 0 && fixP->fx_size == 4) + return BFD_RELOC_32; + + if (fixP->fx_pcrel != 0 && fixP->fx_size == 4) + return BFD_RELOC_24_PCREL; + + abort (); + return 0; +} + +/* Translate internal representation of relocation info to BFD target + format. + + FIXME: To what extent can we get all relevant targets to use this? */ + +arelent * +tc_gen_reloc (section, fixP) + asection *section; + fixS *fixP; +{ + arelent * reloc; + + reloc = (arelent *) xmalloc (sizeof (arelent)); + + /* HACK: Is this right? */ + fixP->fx_r_type = tc_bfd_fix2rtype (fixP); + + reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type); + if (reloc->howto == (reloc_howto_type *) NULL) + { + as_bad_where (fixP->fx_file, fixP->fx_line, + "internal error: can't export reloc type %d (`%s')", + fixP->fx_r_type, + bfd_get_reloc_code_name (fixP->fx_r_type)); + return NULL; + } + + assert (!fixP->fx_pcrel == !reloc->howto->pc_relative); + + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy); + reloc->address = fixP->fx_frag->fr_address + fixP->fx_where; + reloc->addend = fixP->fx_addnumber; + + return reloc; +} + +/* end from cgen.c */ + +#endif /* BFD_ASSEMBLER */ + /* end of tc-i960.c */ diff --git a/gas/config/tc-i960.h b/gas/config/tc-i960.h index f606967..2746ede 100644 --- a/gas/config/tc-i960.h +++ b/gas/config/tc-i960.h @@ -1,5 +1,5 @@ /* tc-i960.h - Basic 80960 instruction formats. - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -22,6 +22,11 @@ #ifndef TC_I960 #define TC_I960 1 +#ifdef OBJ_ELF +#define TARGET_FORMAT "elf32-i960" +#define TARGET_ARCH bfd_arch_i960 +#endif + #define TARGET_BYTES_BIG_ENDIAN 0 #define WORKING_DOT_WORD @@ -125,7 +130,7 @@ struct relocation_info #ifdef OBJ_COFF /* We store the bal information in the sy_tc field. */ -#define TC_SYMFIELD_TYPE struct symbol * +#define TC_SYMFIELD_TYPE symbolS * #define TC_ADJUST_RELOC_COUNT(FIXP,COUNT) \ { fixS *tcfixp = (FIXP); \ @@ -135,20 +140,36 @@ struct relocation_info } #endif -extern int i960_validate_fix PARAMS ((struct fix *, segT, struct symbol **)); +extern int i960_validate_fix PARAMS ((struct fix *, segT, symbolS **)); #define TC_VALIDATE_FIX(FIXP,SEGTYPE,LABEL) \ if (i960_validate_fix (FIXP, SEGTYPE, &add_symbolP) != 0) goto LABEL +#ifdef OBJ_ELF +#define TC_RELOC_RTSYM_LOC_FIXUP(FIX) \ + ((FIX)->fx_addsy == NULL \ + || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \ + && ! S_IS_WEAK ((FIX)->fx_addsy) \ + && S_IS_DEFINED ((FIX)->fx_addsy) \ + && ! S_IS_COMMON ((FIX)->fx_addsy))) +#endif + +#ifndef OBJ_ELF #define tc_fix_adjustable(FIXP) ((FIXP)->fx_bsr == 0) +#else +#define tc_fix_adjustable(FIXP) \ + ((FIXP)->fx_bsr == 0 \ + && ! S_IS_EXTERNAL ((FIXP)->fx_addsy) \ + && ! S_IS_WEAK ((FIXP)->fx_addsy)) +#endif extern void brtab_emit PARAMS ((void)); #define md_end() brtab_emit () extern void reloc_callj (); -extern void tc_set_bal_of_call PARAMS ((struct symbol *, struct symbol *)); +extern void tc_set_bal_of_call PARAMS ((symbolS *, symbolS *)); -extern struct symbol *tc_get_bal_of_call PARAMS ((struct symbol *)); +extern struct symbol *tc_get_bal_of_call PARAMS ((symbolS *)); extern void i960_handle_align (); #define HANDLE_ALIGN(FRAG) i960_handle_align (FRAG) diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c index 997e623..7745338 100644 --- a/gas/config/tc-m32r.c +++ b/gas/config/tc-m32r.c @@ -91,6 +91,20 @@ static const char * m32r_cpu_desc; shouldn't assume or require it to). */ static int warn_unmatched_high = 0; +/* Non-zero if -m32rx has been specified, in which case support for the + extended M32RX instruction set should be enabled. */ +static int enable_m32rx = 0; + +/* Non-zero if -m32rx -hidden has been specified, in which case support for + the special M32RX instruction set should be enabled. */ +static int enable_special = 0; + +/* Non-zero if the programmer should be warned when an explicit parallel + instruction might have constraint violations. */ +static int warn_explicit_parallel_conflicts = 1; + +/* Non-zero if insns can be made parallel. */ +static int optimize; /* stuff for .scomm symbols. */ static segT sbss_section; @@ -127,28 +141,48 @@ struct m32r_hi_fixup static struct m32r_hi_fixup * m32r_hi_fixup_list; +static void +allow_m32rx (on) + int on; +{ + enable_m32rx = on; + + if (stdoutput != NULL) + bfd_set_arch_mach (stdoutput, TARGET_ARCH, + enable_m32rx ? bfd_mach_m32rx : bfd_mach_m32r); +} -#define M32R_SHORTOPTS "" +#define M32R_SHORTOPTS "O" const char * md_shortopts = M32R_SHORTOPTS; struct option md_longopts[] = { - +#define OPTION_M32R (OPTION_MD_BASE) +#define OPTION_M32RX (OPTION_M32R + 1) +#define OPTION_WARN_PARALLEL (OPTION_M32RX + 1) +#define OPTION_NO_WARN_PARALLEL (OPTION_WARN_PARALLEL + 1) +#define OPTION_SPECIAL (OPTION_NO_WARN_PARALLEL + 1) +#define OPTION_WARN_UNMATCHED (OPTION_SPECIAL + 1) +#define OPTION_NO_WARN_UNMATCHED (OPTION_WARN_UNMATCHED + 1) + {"m32r", no_argument, NULL, OPTION_M32R}, + {"m32rx", no_argument, NULL, OPTION_M32RX}, + {"warn-explicit-parallel-conflicts", no_argument, NULL, OPTION_WARN_PARALLEL}, + {"Wp", no_argument, NULL, OPTION_WARN_PARALLEL}, + {"no-warn-explicit-parallel-conflicts", no_argument, NULL, OPTION_NO_WARN_PARALLEL}, + {"Wnp", no_argument, NULL, OPTION_NO_WARN_PARALLEL}, + {"hidden", no_argument, NULL, OPTION_SPECIAL}, /* Sigh. I guess all warnings must now have both variants. */ -#define OPTION_WARN_UNMATCHED (OPTION_MD_BASE + 4) - {"warn-unmatched-high", OPTION_WARN_UNMATCHED}, - {"Wuh", OPTION_WARN_UNMATCHED}, -#define OPTION_NO_WARN_UNMATCHED (OPTION_MD_BASE + 5) - {"no-warn-unmatched-high", OPTION_WARN_UNMATCHED}, - {"Wnuh", OPTION_WARN_UNMATCHED}, + {"warn-unmatched-high", no_argument, NULL, OPTION_WARN_UNMATCHED}, + {"Wuh", no_argument, NULL, OPTION_WARN_UNMATCHED}, + {"no-warn-unmatched-high", no_argument, NULL, OPTION_NO_WARN_UNMATCHED}, + {"Wnuh", no_argument, NULL, OPTION_NO_WARN_UNMATCHED}, #if 0 /* not supported yet */ -#define OPTION_RELAX (OPTION_MD_BASE + 6) +#define OPTION_RELAX (OPTION_NO_WARN_UNMATCHED + 1) +#define OPTION_CPU_DESC (OPTION_RELAX + 1) {"relax", no_argument, NULL, OPTION_RELAX}, -#define OPTION_CPU_DESC (OPTION_MD_BASE + 7) {"cpu-desc", required_argument, NULL, OPTION_CPU_DESC}, #endif - {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof (md_longopts); @@ -160,6 +194,36 @@ md_parse_option (c, arg) { switch (c) { + case 'O': + optimize = 1; + break; + + case OPTION_M32R: + allow_m32rx (0); + break; + + case OPTION_M32RX: + allow_m32rx (1); + break; + + case OPTION_WARN_PARALLEL: + warn_explicit_parallel_conflicts = 1; + break; + + case OPTION_NO_WARN_PARALLEL: + warn_explicit_parallel_conflicts = 0; + break; + + case OPTION_SPECIAL: + if (enable_m32rx) + enable_special = 1; + else + { + /* Pretend that we do not recognise this option. */ + as_bad (_("Unrecognised option: -hidden")); + return 0; + } + break; case OPTION_WARN_UNMATCHED: warn_unmatched_high = 1; @@ -181,6 +245,7 @@ md_parse_option (c, arg) default: return 0; } + return 1; } @@ -190,6 +255,25 @@ md_show_usage (stream) { fprintf (stream, _(" M32R specific command line options:\n")); + fprintf (stream, _("\ + -m32r disable support for the m32rx instruction set\n")); + fprintf (stream, _("\ + -m32rx support the extended m32rx instruction set\n")); + fprintf (stream, _("\ + -O try to combine instructions in parallel\n")); + + fprintf (stream, _("\ + -warn-explicit-parallel-conflicts warn when parallel instructions\n")); + fprintf (stream, _("\ + violate contraints\n")); + fprintf (stream, _("\ + -no-warn-explicit-parallel-conflicts do not warn when parallel\n")); + fprintf (stream, _("\ + instructions violate contraints\n")); + fprintf (stream, _("\ + -Wp synonym for -warn-explicit-parallel-conflicts\n")); + fprintf (stream, _("\ + -Wnp synonym for -no-warn-explicit-parallel-conflicts\n")); fprintf (stream, _("\ -warn-unmatched-high warn when an (s)high reloc has no matching low reloc\n")); @@ -224,6 +308,9 @@ const pseudo_typeS md_pseudo_table[] = { "fillinsn", fill_insn, 0 }, { "scomm", m32r_scomm, 0 }, { "debugsym", debug_sym, 0 }, + /* Not documented as so far there is no need for them.... */ + { "m32r", allow_m32rx, 0 }, + { "m32rx", allow_m32rx, 1 }, { NULL, NULL, 0 } }; @@ -245,7 +332,7 @@ m32r_do_align (n, fill, len, max) { /* Only do this if the fill pattern wasn't specified. */ if (fill == NULL - && (now_seg->flags & SEC_CODE) != 0 + && subseg_text_p (now_seg) /* Only do this special handling if aligning to at least a 4 byte boundary. */ && n > 1 @@ -336,7 +423,7 @@ debug_sym (ignore) link->symbol = symbolP; link->next = debug_sym_link; debug_sym_link = link; - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; } *end_name = delim; @@ -464,9 +551,427 @@ md_begin () scom_symbol.name = ".scommon"; scom_symbol.section = & scom_section; + allow_m32rx (enable_m32rx); } +#define OPERAND_IS_COND_BIT(operand, indices, index) \ + ((operand)->hw_type == HW_H_COND \ + || ((operand)->hw_type == HW_H_PSW) \ + || ((operand)->hw_type == HW_H_CR \ + && (indices [index] == 0 || indices [index] == 1))) + +/* Returns true if an output of instruction 'a' is referenced by an operand + of instruction 'b'. If 'check_outputs' is true then b's outputs are + checked, otherwise its inputs are examined. */ + +static int +first_writes_to_seconds_operands (a, b, check_outputs) + m32r_insn * a; + m32r_insn * b; + const int check_outputs; +{ + const CGEN_OPINST * a_operands = CGEN_INSN_OPERANDS (a->insn); + const CGEN_OPINST * b_ops = CGEN_INSN_OPERANDS (b->insn); + int a_index; + + /* If at least one of the instructions takes no operands, then there is + nothing to check. There really are instructions without operands, + eg 'nop'. */ + if (a_operands == NULL || b_ops == NULL) + return 0; + + /* Scan the operand list of 'a' looking for an output operand. */ + for (a_index = 0; + a_operands->type != CGEN_OPINST_END; + a_index ++, a_operands ++) + { + if (a_operands->type == CGEN_OPINST_OUTPUT) + { + int b_index; + const CGEN_OPINST * b_operands = b_ops; + + /* Special Case: + The Condition bit 'C' is a shadow of the CBR register (control + register 1) and also a shadow of bit 31 of the program status + word (control register 0). For now this is handled here, rather + than by cgen.... */ + + if (OPERAND_IS_COND_BIT (a_operands, a->indices, a_index)) + { + /* Scan operand list of 'b' looking for another reference to the + condition bit, which goes in the right direction. */ + for (b_index = 0; + b_operands->type != CGEN_OPINST_END; + b_index ++, b_operands ++) + { + if ((b_operands->type + == (check_outputs + ? CGEN_OPINST_OUTPUT + : CGEN_OPINST_INPUT)) + && OPERAND_IS_COND_BIT (b_operands, b->indices, b_index)) + return 1; + } + } + else + { + /* Scan operand list of 'b' looking for an operand that + references the same hardware element, and which goes in the + right direction. */ + for (b_index = 0; + b_operands->type != CGEN_OPINST_END; + b_index ++, b_operands ++) + { + if ((b_operands->type + == (check_outputs + ? CGEN_OPINST_OUTPUT + : CGEN_OPINST_INPUT)) + && (b_operands->hw_type == a_operands->hw_type) + && (a->indices [a_index] == b->indices [b_index])) + return 1; + } + } + } + } + + return 0; +} + +/* Returns true if the insn can (potentially) alter the program counter. */ + +static int +writes_to_pc (a) + m32r_insn * a; +{ +#if 0 /* Once PC operands are working.... */ + const CGEN_OPINST * a_operands == CGEN_INSN_OPERANDS (gas_cgen_cpu_desc, + a->insn); + + if (a_operands == NULL) + return 0; + + while (a_operands->type != CGEN_OPINST_END) + { + if (a_operands->operand != NULL + && CGEN_OPERAND_INDEX (gas_cgen_cpu_desc, a_operands->operand) == M32R_OPERAND_PC) + return 1; + + a_operands ++; + } +#else + if (CGEN_INSN_ATTR_VALUE (a->insn, CGEN_INSN_UNCOND_CTI) + || CGEN_INSN_ATTR_VALUE (a->insn, CGEN_INSN_COND_CTI)) + return 1; +#endif + return 0; +} + +/* Returns NULL if the two 16 bit insns can be executed in parallel, + otherwise it returns a pointer to an error message explaining why not. */ + +static const char * +can_make_parallel (a, b) + m32r_insn * a; + m32r_insn * b; +{ + PIPE_ATTR a_pipe; + PIPE_ATTR b_pipe; + + /* Make sure the instructions are the right length. */ + if ( CGEN_FIELDS_BITSIZE (& a->fields) != 16 + || CGEN_FIELDS_BITSIZE (& b->fields) != 16) + abort(); + + if (first_writes_to_seconds_operands (a, b, true)) + return _("Instructions write to the same destination register."); + + a_pipe = CGEN_INSN_ATTR_VALUE (a->insn, CGEN_INSN_PIPE); + b_pipe = CGEN_INSN_ATTR_VALUE (b->insn, CGEN_INSN_PIPE); + + /* Make sure that the instructions use the correct execution pipelines. */ + if ( a_pipe == PIPE_NONE + || b_pipe == PIPE_NONE) + return _("Instructions do not use parallel execution pipelines."); + + /* Leave this test for last, since it is the only test that can + go away if the instructions are swapped, and we want to make + sure that any other errors are detected before this happens. */ + if ( a_pipe == PIPE_S + || b_pipe == PIPE_O) + return _("Instructions share the same execution pipeline"); + + return NULL; +} + +/* Force the top bit of the second 16-bit insn to be set. */ + +static void +make_parallel (buffer) + CGEN_INSN_BYTES_PTR buffer; +{ +#if CGEN_INT_INSN_P + *buffer |= 0x8000; +#else + buffer [CGEN_CPU_ENDIAN (gas_cgen_cpu_desc) == CGEN_ENDIAN_BIG ? 0 : 1] + |= 0x80; +#endif +} + +/* Same as make_parallel except buffer contains the bytes in target order. */ + +static void +target_make_parallel (buffer) + char *buffer; +{ + buffer [CGEN_CPU_ENDIAN (gas_cgen_cpu_desc) == CGEN_ENDIAN_BIG ? 0 : 1] + |= 0x80; +} + +/* Assemble two instructions with an explicit parallel operation (||) or + sequential operation (->). */ + +static void +assemble_two_insns (str, str2, parallel_p) + char * str; + char * str2; + int parallel_p; +{ + char * str3; + m32r_insn first; + m32r_insn second; + char * errmsg; + char save_str2 = *str2; + + * str2 = 0; /* Seperate the two instructions. */ + + /* Make sure the two insns begin on a 32 bit boundary. + This is also done for the serial case (foo -> bar), relaxing doesn't + affect insns written like this. + Note that we must always do this as we can't assume anything about + whether we're currently on a 32 bit boundary or not. Relaxing may + change this. */ + fill_insn (0); + + first.debug_sym_link = debug_sym_link; + debug_sym_link = (sym_linkS *)0; + + /* Parse the first instruction. */ + if (! (first.insn = m32r_cgen_assemble_insn + (gas_cgen_cpu_desc, str, & first.fields, first.buffer, & errmsg))) + { + as_bad (errmsg); + return; + } + + /* Check it. */ + if (CGEN_FIELDS_BITSIZE (&first.fields) != 16) + { + /* xgettext:c-format */ + as_bad (_("not a 16 bit instruction '%s'"), str); + return; + } + else if (! enable_special + && CGEN_INSN_ATTR_VALUE (first.insn, CGEN_INSN_SPECIAL)) + { + /* xgettext:c-format */ + as_bad (_("unknown instruction '%s'"), str); + return; + } + else if (! enable_m32rx + /* FIXME: Need standard macro to perform this test. */ + && CGEN_INSN_ATTR_VALUE (first.insn, CGEN_INSN_MACH) == (1 << MACH_M32RX)) + { + /* xgettext:c-format */ + as_bad (_("instruction '%s' is for the M32RX only"), str); + return; + } + + /* Check to see if this is an allowable parallel insn. */ + if (parallel_p && CGEN_INSN_ATTR_VALUE (first.insn, CGEN_INSN_PIPE) == PIPE_NONE) + { + /* xgettext:c-format */ + as_bad (_("instruction '%s' cannot be executed in parallel."), str); + return; + } + + *str2 = save_str2; /* Restore the original assembly text, just in case it is needed. */ + str3 = str; /* Save the original string pointer. */ + str = str2 + 2; /* Advanced past the parsed string. */ + str2 = str3; /* Remember the entire string in case it is needed for error messages. */ + + /* Convert the opcode to lower case. */ + { + char *s2 = str; + + while (isspace (*s2 ++)) + continue; + + --s2; + + while (isalnum (*s2)) + { + if (isupper ((unsigned char) *s2)) + *s2 = tolower (*s2); + s2 ++; + } + } + + /* Preserve any fixups that have been generated and reset the list to empty. */ + gas_cgen_save_fixups (); + + /* Get the indices of the operands of the instruction. */ + /* FIXME: CGEN_FIELDS is already recorded, but relying on that fact + doesn't seem right. Perhaps allow passing fields like we do insn. */ + /* FIXME: ALIAS insns do not have operands, so we use this function + to find the equivalent insn and overwrite the value stored in our + structure. We still need the original insn, however, since this + may have certain attributes that are not present in the unaliased + version (eg relaxability). When aliases behave differently this + may have to change. */ + first.orig_insn = first.insn; + { + CGEN_FIELDS tmp_fields; + first.insn = cgen_lookup_get_insn_operands + (gas_cgen_cpu_desc, NULL, INSN_VALUE (first.buffer), NULL, 16, + first.indices, &tmp_fields); + } + + if (first.insn == NULL) + as_fatal (_("internal error: lookup/get operands failed")); + + second.debug_sym_link = NULL; + + /* Parse the second instruction. */ + if (! (second.insn = m32r_cgen_assemble_insn + (gas_cgen_cpu_desc, str, & second.fields, second.buffer, & errmsg))) + { + as_bad (errmsg); + return; + } + + /* Check it. */ + if (CGEN_FIELDS_BITSIZE (&second.fields) != 16) + { + /* xgettext:c-format */ + as_bad (_("not a 16 bit instruction '%s'"), str); + return; + } + else if (! enable_special + && CGEN_INSN_ATTR_VALUE (second.insn, CGEN_INSN_SPECIAL)) + { + /* xgettext:c-format */ + as_bad (_("unknown instruction '%s'"), str); + return; + } + else if (! enable_m32rx + && CGEN_INSN_ATTR_VALUE (second.insn, CGEN_INSN_MACH) == (1 << MACH_M32RX)) + { + /* xgettext:c-format */ + as_bad (_("instruction '%s' is for the M32RX only"), str); + return; + } + /* Check to see if this is an allowable parallel insn. */ + if (parallel_p && CGEN_INSN_ATTR_VALUE (second.insn, CGEN_INSN_PIPE) == PIPE_NONE) + { + /* xgettext:c-format */ + as_bad (_("instruction '%s' cannot be executed in parallel."), str); + return; + } + + if (parallel_p && ! enable_m32rx) + { + if (CGEN_INSN_NUM (first.insn) != M32R_INSN_NOP + && CGEN_INSN_NUM (second.insn) != M32R_INSN_NOP) + { + /* xgettext:c-format */ + as_bad (_("'%s': only the NOP instruction can be issued in parallel on the m32r"), str2); + return; + } + } + + /* Get the indices of the operands of the instruction. */ + second.orig_insn = second.insn; + { + CGEN_FIELDS tmp_fields; + second.insn = cgen_lookup_get_insn_operands + (gas_cgen_cpu_desc, NULL, INSN_VALUE (second.buffer), NULL, 16, + second.indices, &tmp_fields); + } + + if (second.insn == NULL) + as_fatal (_("internal error: lookup/get operands failed")); + + /* We assume that if the first instruction writes to a register that is + read by the second instruction it is because the programmer intended + this to happen, (after all they have explicitly requested that these + two instructions be executed in parallel). Although if the global + variable warn_explicit_parallel_conflicts is true then we do generate + a warning message. Similarly we assume that parallel branch and jump + instructions are deliberate and should not produce errors. */ + + if (parallel_p && warn_explicit_parallel_conflicts) + { + if (first_writes_to_seconds_operands (& first, & second, false)) + /* xgettext:c-format */ + as_warn (_("%s: output of 1st instruction is the same as an input to 2nd instruction - is this intentional ?"), str2); + + if (first_writes_to_seconds_operands (& second, & first, false)) + /* xgettext:c-format */ + as_warn (_("%s: output of 2nd instruction is the same as an input to 1st instruction - is this intentional ?"), str2); + } + + if (!parallel_p + || (errmsg = (char *) can_make_parallel (& first, & second)) == NULL) + { + /* Get the fixups for the first instruction. */ + gas_cgen_swap_fixups (); + + /* Write it out. */ + expand_debug_syms (first.debug_sym_link, 1); + gas_cgen_finish_insn (first.orig_insn, first.buffer, + CGEN_FIELDS_BITSIZE (& first.fields), 0, NULL); + + /* Force the top bit of the second insn to be set. */ + if (parallel_p) + make_parallel (second.buffer); + + /* Get its fixups. */ + gas_cgen_restore_fixups (); + + /* Write it out. */ + expand_debug_syms (second.debug_sym_link, 1); + gas_cgen_finish_insn (second.orig_insn, second.buffer, + CGEN_FIELDS_BITSIZE (& second.fields), 0, NULL); + } + /* Try swapping the instructions to see if they work that way. */ + else if (can_make_parallel (& second, & first) == NULL) + { + /* Write out the second instruction first. */ + expand_debug_syms (second.debug_sym_link, 1); + gas_cgen_finish_insn (second.orig_insn, second.buffer, + CGEN_FIELDS_BITSIZE (& second.fields), 0, NULL); + + /* Force the top bit of the first instruction to be set. */ + make_parallel (first.buffer); + + /* Get the fixups for the first instruction. */ + gas_cgen_restore_fixups (); + + /* Write out the first instruction. */ + expand_debug_syms (first.debug_sym_link, 1); + gas_cgen_finish_insn (first.orig_insn, first.buffer, + CGEN_FIELDS_BITSIZE (& first.fields), 0, NULL); + } + else + { + as_bad ("'%s': %s", str2, errmsg); + return; + } + + /* Set these so m32r_fill_insn can use them. */ + prev_seg = now_seg; + prev_subseg = now_subseg; +} void md_assemble (str) @@ -479,6 +984,19 @@ md_assemble (str) /* Initialize GAS's cgen interface for a new instruction. */ gas_cgen_init_parse (); + /* Look for a parallel instruction seperator. */ + if ((str2 = strstr (str, "||")) != NULL) + { + assemble_two_insns (str, str2, 1); + return; + } + + /* Also look for a sequential instruction seperator. */ + if ((str2 = strstr (str, "->")) != NULL) + { + assemble_two_insns (str, str2, 0); + return; + } insn.debug_sym_link = debug_sym_link; debug_sym_link = (sym_linkS *)0; @@ -492,6 +1010,20 @@ md_assemble (str) return; } + if (! enable_special + && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_SPECIAL)) + { + /* xgettext:c-format */ + as_bad (_("unknown instruction '%s'"), str); + return; + } + else if (! enable_m32rx + && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_MACH) == (1 << MACH_M32RX)) + { + /* xgettext:c-format */ + as_bad (_("instruction '%s' is for the M32RX only"), str); + return; + } if (CGEN_INSN_BITSIZE (insn.insn) == 32) { @@ -513,16 +1045,62 @@ md_assemble (str) else { int on_32bit_boundary_p; + int swap = false; if (CGEN_INSN_BITSIZE (insn.insn) != 16) abort(); insn.orig_insn = insn.insn; + /* If the previous insn was relaxable, then it may be expanded + to fill the current 16 bit slot. Emit a NOP here to occupy + this slot, so that we can start at optimizing at a 32 bit + boundary. */ + if (prev_insn.insn && seen_relaxable_p && optimize) + fill_insn (0); + + if (enable_m32rx) + { + /* Get the indices of the operands of the instruction. + FIXME: See assemble_parallel for notes on orig_insn. */ + { + CGEN_FIELDS tmp_fields; + insn.insn = cgen_lookup_get_insn_operands + (gas_cgen_cpu_desc, NULL, INSN_VALUE (insn.buffer), NULL, + 16, insn.indices, &tmp_fields); + } + + if (insn.insn == NULL) + as_fatal (_("internal error: lookup/get operands failed")); + } + /* Compute whether we're on a 32 bit boundary or not. prev_insn.insn is NULL when we're on a 32 bit boundary. */ on_32bit_boundary_p = prev_insn.insn == NULL; + /* Look to see if this instruction can be combined with the + previous instruction to make one, parallel, 32 bit instruction. + If the previous instruction (potentially) changed the flow of + program control, then it cannot be combined with the current + instruction. If the current instruction is relaxable, then it + might be replaced with a longer version, so we cannot combine it. + Also if the output of the previous instruction is used as an + input to the current instruction then it cannot be combined. + Otherwise call can_make_parallel() with both orderings of the + instructions to see if they can be combined. */ + if ( ! on_32bit_boundary_p + && enable_m32rx + && optimize + && CGEN_INSN_ATTR_VALUE (insn.orig_insn, CGEN_INSN_RELAXABLE) == 0 + && ! writes_to_pc (& prev_insn) + && ! first_writes_to_seconds_operands (& prev_insn, &insn, false) + ) + { + if (can_make_parallel (& prev_insn, & insn) == NULL) + make_parallel (insn.buffer); + else if (can_make_parallel (& insn, & prev_insn) == NULL) + swap = true; + } expand_debug_syms (insn.debug_sym_link, 1); @@ -543,6 +1121,33 @@ md_assemble (str) insn.fixups[i] = fi.fixups[i]; } + if (swap) + { + int i,tmp; + +#define SWAP_BYTES(a,b) tmp = a; a = b; b = tmp + + /* Swap the two insns */ + SWAP_BYTES (prev_insn.addr [0], insn.addr [0]); + SWAP_BYTES (prev_insn.addr [1], insn.addr [1]); + + target_make_parallel (insn.addr); + + /* Swap any relaxable frags recorded for the two insns. */ + /* FIXME: Clarify. relaxation precludes parallel insns */ + if (prev_insn.frag->fr_opcode == prev_insn.addr) + prev_insn.frag->fr_opcode = insn.addr; + else if (insn.frag->fr_opcode == insn.addr) + insn.frag->fr_opcode = prev_insn.addr; + + /* Update the addresses in any fixups. + Note that we don't have to handle the case where each insn is in + a different frag as we ensure they're in the same frag above. */ + for (i = 0; i < prev_insn.num_fixups; ++i) + prev_insn.fixups[i]->fx_where += 2; + for (i = 0; i < insn.num_fixups; ++i) + insn.fixups[i]->fx_where -= 2; + } /* Keep track of whether we've seen a pair of 16 bit insns. prev_insn.insn is NULL when we're on a 32 bit boundary. */ @@ -694,7 +1299,7 @@ m32r_scomm (ignore) return; } - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec = now_seg; int old_subsec = now_subseg; @@ -707,9 +1312,9 @@ m32r_scomm (ignore) frag_align (align2, 0, 0); if (S_GET_SEGMENT (symbolP) == sbss_section) - symbolP->sy_frag->fr_symbol = 0; + symbol_get_frag (symbolP)->fr_symbol = 0; - symbolP->sy_frag = frag_now; + symbol_set_frag (symbolP, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size, (char *) 0); @@ -936,7 +1541,7 @@ md_convert_frag (abfd, sec, fragP) { /* Address we want to reach in file space. */ target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset; - target_address += fragP->fr_symbol->sy_frag->fr_address; + target_address += symbol_get_frag (fragP->fr_symbol)->fr_address; addend = (target_address - (opcode_address & -4)) >> 2; } @@ -1282,6 +1887,18 @@ m32r_fix_adjustable (fixP) fixS *fixP; { + bfd_reloc_code_real_type reloc_type; + + if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED) + { + const CGEN_INSN *insn = NULL; + int opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED; + const CGEN_OPERAND *operand = cgen_operand_lookup_by_num(gas_cgen_cpu_desc, opindex); + reloc_type = md_cgen_lookup_reloc (insn, operand, fixP); + } + else + reloc_type = fixP->fx_r_type; + if (fixP->fx_addsy == NULL) return 1; @@ -1292,8 +1909,8 @@ m32r_fix_adjustable (fixP) return 0; /* We need the symbol name for the VTABLE entries */ - if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT - || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + if (reloc_type == BFD_RELOC_VTABLE_INHERIT + || reloc_type == BFD_RELOC_VTABLE_ENTRY) return 0; return 1; diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index 856dd4e..0749665 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -1,5 +1,5 @@ /* tc-m68k.c -- Assemble for the m68k family - Copyright (C) 1987, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1987, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -27,6 +27,10 @@ #include "opcode/m68k.h" #include "m68k-parse.h" +#if defined (OBJ_ELF) +#include "elf/m68k.h" +#endif + /* This string holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful. The macro tc_comment_chars points to this. We use this, rather than the @@ -189,7 +193,7 @@ static const enum m68k_register m68060_control_regs[] = { USP, VBR, URP, SRP, PCR, 0 }; -static const enum m68k_register mcf5200_control_regs[] = { +static const enum m68k_register mcf_control_regs[] = { CACR, TC, ITT0, ITT1, DTT0, DTT1, VBR, ROMBAR, RAMBAR0, RAMBAR1, MBAR, 0 @@ -247,9 +251,10 @@ struct m68k_it reloc[5]; /* Five is enough??? */ }; -#define cpu_of_arch(x) ((x) & (m68000up|mcf5200)) +#define cpu_of_arch(x) ((x) & (m68000up|mcf)) #define float_of_arch(x) ((x) & mfloat) #define mmu_of_arch(x) ((x) & mmmu) +#define arch_coldfire_p(x) (((x) & mcf) != 0) /* Macros for determining if cpu supports a specific addressing mode */ #define HAVE_LONG_BRANCH(x) ((x) & (m68020|m68030|m68040|m68060|cpu32)) @@ -391,6 +396,8 @@ static const struct m68k_cpu archs[] = { { m68881, "68881", 0 }, { m68851, "68851", 0 }, { mcf5200, "5200", 0 }, + { mcf5206e, "5206e", 0 }, + { mcf5307, "5307", 0}, /* Aliases (effectively, so far as gas is concerned) for the above cpus. */ { m68020, "68k", 1 }, @@ -418,6 +425,9 @@ static const struct m68k_cpu archs[] = { { cpu32, "68349", 1 }, { cpu32, "68360", 1 }, { m68881, "68882", 1 }, + { mcf5200, "5202", 1 }, + { mcf5200, "5204", 1 }, + { mcf5200, "5206", 1 }, }; static const int n_archs = sizeof (archs) / sizeof (archs[0]); @@ -897,7 +907,8 @@ tc_gen_reloc (section, fixp) #undef MAP reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; #ifndef OBJ_ELF if (fixp->fx_pcrel) @@ -1471,11 +1482,26 @@ m68k_ip (instring) losing++; break; + case 'E': + if (opP->reg != ACC) + losing++; + break; + case 'F': if (opP->mode != FPREG) losing++; break; + case 'G': + if (opP->reg != MACSR) + losing++; + break; + + case 'H': + if (opP->reg != MASK) + losing++; + break; + case 'I': if (opP->mode != CONTROL || opP->reg < COP0 @@ -1737,6 +1763,19 @@ m68k_ip (instring) ++losing; break; + case 'u': + if (opP->reg < DATA0L || opP->reg > ADDR7U) + losing++; + /* FIXME: kludge instead of fixing parser: + upper/lower registers are *not* CONTROL + registers, but ordinary ones. */ + if ((opP->reg >= DATA0L && opP->reg <= DATA7L) + || (opP->reg >= DATA0U && opP->reg <= DATA7U)) + opP->mode = DREG; + else + opP->mode = AREG; + break; + default: abort (); } /* switch on type of operand */ @@ -1994,11 +2033,11 @@ m68k_ip (instring) && ((opP->disp.size == SIZE_UNSPEC && flag_short_refs == 0 && cpu_of_arch (current_architecture) >= m68020 - && cpu_of_arch (current_architecture) != mcf5200) + && ! arch_coldfire_p (current_architecture)) || opP->disp.size == SIZE_LONG))) { if (cpu_of_arch (current_architecture) < m68020 - || cpu_of_arch (current_architecture) == mcf5200) + || arch_coldfire_p (current_architecture)) opP->error = _("displacement too large for this architecture; needs 68020 or higher"); if (opP->reg == PC) @@ -2107,12 +2146,16 @@ m68k_ip (instring) if ((opP->index.scale != 1 && cpu_of_arch (current_architecture) < m68020) || (opP->index.scale == 8 - && current_architecture == mcf5200)) + && arch_coldfire_p (current_architecture))) { opP->error = _("scale factor invalid on this architecture; needs cpu32 or 68020 or higher"); } + if (arch_coldfire_p (current_architecture) + && opP->index.size == SIZE_WORD) + opP->error = _("invalid index size for coldfire"); + switch (opP->index.scale) { case 1: @@ -2144,7 +2187,7 @@ m68k_ip (instring) { if (siz1 == SIZE_BYTE || cpu_of_arch (current_architecture) < m68020 - || cpu_of_arch (current_architecture) == mcf5200 + || arch_coldfire_p (current_architecture) || (siz1 == SIZE_UNSPEC && ! isvar (&opP->disp) && issbyte (baseo))) @@ -2211,7 +2254,7 @@ m68k_ip (instring) /* It isn't simple. */ if (cpu_of_arch (current_architecture) < m68020 - || cpu_of_arch (current_architecture) == mcf5200) + || arch_coldfire_p (current_architecture)) opP->error = _("invalid operand mode for this architecture; needs 68020 or higher"); @@ -2570,10 +2613,17 @@ m68k_ip (instring) install_operand (s[1], opP->reg - DATA); break; + case 'E': /* Ignore it */ + break; + case 'F': install_operand (s[1], opP->reg - FP0); break; + case 'G': /* Ignore it */ + case 'H': + break; + case 'I': tmpreg = opP->reg - COP0; install_operand (s[1], tmpreg); @@ -2901,6 +2951,11 @@ m68k_ip (instring) addword (tmpreg >> 16); addword (tmpreg & 0xFFFF); break; + case 'u': + install_operand (s[1], opP->reg - DATA0L); + opP->reg -= (DATA0L); + opP->reg &= 0x0F; /* remove upper/lower bit */ + break; default: abort (); } @@ -3040,6 +3095,30 @@ install_operand (mode, val) the_ins.opcode[1] = (val >> 16); the_ins.opcode[2] = val & 0xffff; break; + case 'm': + the_ins.opcode[0] |= ((val & 0x8) << (6 - 3)); + the_ins.opcode[0] |= ((val & 0x7) << 9); + the_ins.opcode[1] |= ((val & 0x10) << (7 - 4)); + break; + case 'n': + the_ins.opcode[0] |= ((val & 0x8) << (6 - 3)); + the_ins.opcode[0] |= ((val & 0x7) << 9); + break; + case 'o': + the_ins.opcode[1] |= val << 12; + the_ins.opcode[1] |= ((val & 0x10) << (7 - 4)); + break; + case 'M': + the_ins.opcode[0] |= (val & 0xF); + the_ins.opcode[1] |= ((val & 0x10) << (6 - 4)); + break; + case 'N': + the_ins.opcode[1] |= (val & 0xF); + the_ins.opcode[1] |= ((val & 0x10) << (6 - 4)); + break; + case 'h': + the_ins.opcode[1] |= ((val != 1) << 10); + break; case 'c': default: as_fatal (_("failed sanity check.")); @@ -3241,6 +3320,10 @@ static const struct init_entry init_table[] = { "ccr", CCR }, { "cc", CCR }, + { "acc", ACC }, + { "macsr", MACSR }, + { "mask", MASK }, + /* control registers */ { "sfc", SFC }, /* Source Function Code */ { "sfcr", SFC }, @@ -3345,6 +3428,43 @@ static const struct init_entry init_table[] = { "za6", ZADDR6 }, { "za7", ZADDR7 }, + /* Upper and lower data and address registers, used by macw and msacw. */ + { "d0l", DATA0L }, + { "d1l", DATA1L }, + { "d2l", DATA2L }, + { "d3l", DATA3L }, + { "d4l", DATA4L }, + { "d5l", DATA5L }, + { "d6l", DATA6L }, + { "d7l", DATA7L }, + + { "a0l", ADDR0L }, + { "a1l", ADDR1L }, + { "a2l", ADDR2L }, + { "a3l", ADDR3L }, + { "a4l", ADDR4L }, + { "a5l", ADDR5L }, + { "a6l", ADDR6L }, + { "a7l", ADDR7L }, + + { "d0u", DATA0U }, + { "d1u", DATA1U }, + { "d2u", DATA2U }, + { "d3u", DATA3U }, + { "d4u", DATA4U }, + { "d5u", DATA5U }, + { "d6u", DATA6U }, + { "d7u", DATA7U }, + + { "a0u", ADDR0U }, + { "a1u", ADDR1U }, + { "a2u", ADDR2U }, + { "a3u", ADDR3U }, + { "a4u", ADDR4U }, + { "a5u", ADDR5U }, + { "a6u", ADDR6U }, + { "a7u", ADDR7U }, + { 0, 0 } }; @@ -3779,7 +3899,9 @@ select_control_regs () control_regs = cpu32_control_regs; break; case mcf5200: - control_regs = mcf5200_control_regs; + case mcf5206e: + case mcf5307: + control_regs = mcf_control_regs; break; default: abort (); @@ -3853,7 +3975,7 @@ m68k_init_after_args () select_control_regs (); if (cpu_of_arch (current_architecture) < m68020 - || cpu_of_arch (current_architecture) == mcf5200) + || arch_coldfire_p (current_architecture)) md_relax_table[TAB (PCINDEX, BYTE)].rlx_more = 0; } @@ -4171,7 +4293,7 @@ md_convert_frag_1 (fragP) disp = (disp + fragP->fr_offset) - object_address; #ifdef BFD_ASSEMBLER - disp += fragP->fr_symbol->sy_frag->fr_address; + disp += symbol_get_frag (fragP->fr_symbol)->fr_address; #endif switch (fragP->fr_subtype) @@ -4373,8 +4495,8 @@ md_convert_frag (headers, sec, fragP) void md_convert_frag (abfd, sec, fragP) - bfd *abfd; - segT sec; + bfd *abfd ATTRIBUTE_UNUSED; + segT sec ATTRIBUTE_UNUSED; fragS *fragP; { md_convert_frag_1 (fragP); @@ -4620,14 +4742,14 @@ md_estimate_size_before_relax (fragP, segment) word mode. */ if (fragP->fr_symbol && S_GET_VALUE (fragP->fr_symbol) == 0) { + fragS *stop; fragS *l; - for (l = fragP->fr_next; - l != fragP->fr_symbol->sy_frag; - l = l->fr_next) + stop = symbol_get_frag (fragP->fr_symbol); + for (l = fragP->fr_next; l != stop; l = l->fr_next) if (l->fr_fix + l->fr_var != 0) break; - if (l == fragP->fr_symbol->sy_frag) + if (l == stop) { fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT); fragP->fr_var += 2; @@ -4712,8 +4834,8 @@ void md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) char *ptr; addressT from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; + fragS *frag ATTRIBUTE_UNUSED; + symbolS *to_symbol ATTRIBUTE_UNUSED; { valueT offset; @@ -4898,7 +5020,7 @@ get_num (exp, ok) static void s_data1 (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { subseg_set (data_section, 1); demand_empty_rest_of_line (); @@ -4906,7 +5028,7 @@ s_data1 (ignore) static void s_data2 (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { subseg_set (data_section, 2); demand_empty_rest_of_line (); @@ -4914,7 +5036,7 @@ s_data2 (ignore) static void s_bss (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* We don't support putting frags in the BSS segment, we fake it by marking in_bss, then looking at s_skip for clues. */ @@ -4925,7 +5047,7 @@ s_bss (ignore) static void s_even (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { register int temp; register long temp_fill; @@ -4940,7 +5062,7 @@ s_even (ignore) static void s_proc (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { demand_empty_rest_of_line (); } @@ -5016,7 +5138,7 @@ mri_chip () static void s_chip (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *stop = NULL; char stopc; @@ -5033,7 +5155,7 @@ s_chip (ignore) static void s_fopt (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { SKIP_WHITESPACE (); @@ -5143,7 +5265,7 @@ static const struct opt_action opt_table[] = static void s_opt (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { do { @@ -5211,8 +5333,8 @@ s_opt (ignore) static void skip_to_comma (arg, on) - int arg; - int on; + int arg ATTRIBUTE_UNUSED; + int on ATTRIBUTE_UNUSED; { while (*input_line_pointer != ',' && ! is_end_of_line[(unsigned char) *input_line_pointer]) @@ -5223,8 +5345,8 @@ skip_to_comma (arg, on) static void opt_nest (arg, on) - int arg; - int on; + int arg ATTRIBUTE_UNUSED; + int on ATTRIBUTE_UNUSED; { if (*input_line_pointer != '=') { @@ -5240,8 +5362,8 @@ opt_nest (arg, on) static void opt_chip (arg, on) - int arg; - int on; + int arg ATTRIBUTE_UNUSED; + int on ATTRIBUTE_UNUSED; { if (*input_line_pointer != '=') { @@ -5257,7 +5379,7 @@ opt_chip (arg, on) static void opt_list (arg, on) - int arg; + int arg ATTRIBUTE_UNUSED; int on; { listing_list (on); @@ -5267,7 +5389,7 @@ opt_list (arg, on) static void opt_list_symbols (arg, on) - int arg; + int arg ATTRIBUTE_UNUSED; int on; { if (on) @@ -5280,7 +5402,7 @@ opt_list_symbols (arg, on) static void s_reg (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *s; int c; @@ -5351,7 +5473,7 @@ s_reg (ignore) S_SET_SEGMENT (line_label, reg_section); S_SET_VALUE (line_label, ~mask); - line_label->sy_frag = &zero_address_frag; + symbol_set_frag (line_label, &zero_address_frag); if (flag_mri) mri_comment_end (stop, stopc); @@ -5384,7 +5506,7 @@ static struct save_opts *save_stack; static void s_save (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { struct save_opts *s; @@ -5409,7 +5531,7 @@ s_save (ignore) static void s_restore (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { struct save_opts *s; @@ -6086,7 +6208,7 @@ s_mri_else (qual) static void s_mri_endi (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (mri_control_stack == NULL || mri_control_stack->type != mri_if) @@ -6429,7 +6551,7 @@ s_mri_for (qual) static void s_mri_endf (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (mri_control_stack == NULL || mri_control_stack->type != mri_for) @@ -6465,7 +6587,7 @@ s_mri_endf (ignore) static void s_mri_repeat (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { struct mri_control_info *n; @@ -6570,7 +6692,7 @@ s_mri_while (qual) static void s_mri_endw (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *buf; @@ -6929,7 +7051,7 @@ is_label (str) /* ARGSUSED */ symbolS * md_undefined_symbol (name) - char *name; + char *name ATTRIBUTE_UNUSED; { return 0; } @@ -6937,7 +7059,7 @@ md_undefined_symbol (name) /* Round up a section size to the appropriate boundary. */ valueT md_section_align (segment, size) - segT segment; + segT segment ATTRIBUTE_UNUSED; valueT size; { #ifdef OBJ_AOUT @@ -7005,5 +7127,12 @@ tc_coff_sizemachdep (frag) #endif #endif - +#ifdef OBJ_ELF +void m68k_elf_final_processing() +{ + /* Set file-specific flags if this is a cpu32 processor */ + if (cpu_of_arch (current_architecture) & cpu32) + elf_elfheader (stdoutput)->e_flags |= EF_CPU32; +} +#endif /* end of tc-m68k.c */ diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h index bc8308a..b3daf5e 100644 --- a/gas/config/tc-m68k.h +++ b/gas/config/tc-m68k.h @@ -1,5 +1,5 @@ /* This file is tc-m68k.h - Copyright (C) 1987, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998 + Copyright (C) 1987, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -22,7 +22,6 @@ #define TC_M68K 1 #ifdef ANSI_PROTOTYPES -struct symbol; struct fix; #endif @@ -124,7 +123,7 @@ extern const char *m68k_comment_chars; #define LEX_TILDE LEX_BEGIN_NAME #define tc_canonicalize_symbol_name(s) ((*(s) == '~' ? *(s) = '.' : '.'), s) /* On the Delta, dots are not required before pseudo-ops. */ -#define NO_PSEUDO_DOT +#define NO_PSEUDO_DOT 1 #ifndef BFD_ASSEMBLER #undef LOCAL_LABEL #define LOCAL_LABEL(name) \ @@ -138,13 +137,13 @@ extern void m68k_mri_mode_change PARAMS ((int)); extern int m68k_conditional_pseudoop PARAMS ((pseudo_typeS *)); #define tc_conditional_pseudoop(pop) m68k_conditional_pseudoop (pop) -extern void m68k_frob_label PARAMS ((struct symbol *)); +extern void m68k_frob_label PARAMS ((symbolS *)); #define tc_frob_label(sym) m68k_frob_label (sym) extern void m68k_flush_pending_output PARAMS ((void)); #define md_flush_pending_output() m68k_flush_pending_output () -extern void m68k_frob_symbol PARAMS ((struct symbol *)); +extern void m68k_frob_symbol PARAMS ((symbolS *)); #ifdef BFD_ASSEMBLER @@ -176,6 +175,8 @@ while (0) #define tc_fix_adjustable(X) tc_m68k_fix_adjustable(X) extern int tc_m68k_fix_adjustable PARAMS ((struct fix *)); +#define elf_tc_final_processing m68k_elf_final_processing +extern void m68k_elf_final_processing PARAMS ((void)); #endif #define TC_FORCE_RELOCATION(FIX) \ diff --git a/gas/config/tc-m88k.c b/gas/config/tc-m88k.c index 931a496..f77460a 100644 --- a/gas/config/tc-m88k.c +++ b/gas/config/tc-m88k.c @@ -1,7 +1,7 @@ /* m88k.c -- Assembler for the Motorola 88000 Contributed by Devon Bowen of Buffalo University and Torbjorn Granlund of the Swedish Institute of Computer Science. - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -1214,9 +1214,9 @@ emit_relocations (fixP, segment_address_in_file) ri.r_extern = 0; ri.r_symbolnum = symbolP->sy_type & N_TYPE; } - if (symbolP && symbolP->sy_frag) + if (symbolP && symbol_get_frag (symbolP)) { - ri.r_addend = symbolP->sy_frag->fr_address; + ri.r_addend = symbol_get_frag (symbolP)->fr_address; } ri.r_type = fixP->fx_r_type; if (fixP->fx_pcrel) @@ -1294,10 +1294,10 @@ s_bss () frag_align (bss_align, 0, 0); /* detach from old frag */ - if (symbolP->sy_type == N_BSS && symbolP->sy_frag != NULL) - symbolP->sy_frag->fr_symbol = NULL; + if (symbolP->sy_type == N_BSS && symbol_get_frag (symbolP) != NULL) + symbol_get_frag (symbolP)->fr_symbol = NULL; - symbolP->sy_frag = frag_now; + symbol_set_frag (symbolP, frag_now); p = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP, (offsetT) temp, (char *)0); *p = 0; diff --git a/gas/config/tc-m88k.h b/gas/config/tc-m88k.h index 426b697..cbd69c8 100644 --- a/gas/config/tc-m88k.h +++ b/gas/config/tc-m88k.h @@ -1,7 +1,7 @@ /* m88k.h -- Assembler for the Motorola 88000 Contributed by Devon Bowen of Buffalo University and Torbjorn Granlund of the Swedish Institute of Computer Science. - Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997 + Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -70,7 +70,7 @@ struct reloc_info_m88k #endif /* The m88k uses pseudo-ops with no leading period. */ -#define NO_PSEUDO_DOT +#define NO_PSEUDO_DOT 1 /* Don't warn on word overflow; it happens on %hi relocs. */ #undef WARN_SIGNED_OVERFLOW_WORD diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c index 7e78435..d072f03 100644 --- a/gas/config/tc-mcore.c +++ b/gas/config/tc-mcore.c @@ -1,6 +1,5 @@ /* tc-mcore.c -- Assemble code for M*Core - - Copyright (C) 1993,1994, 1999 Free Software Foundation. + Copyright (C) 1999, 2000 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -15,8 +14,9 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + 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. */ #include #include "as.h" @@ -40,29 +40,33 @@ static void mcore_s_literals PARAMS ((int)); static void mcore_cons PARAMS ((int)); static void mcore_float_cons PARAMS ((int)); static void mcore_stringer PARAMS ((int)); +static void mcore_fill PARAMS ((int)); static int log2 PARAMS ((unsigned int)); -static char * parse_reg PARAMS ((char *, unsigned *)); -static char * parse_creg PARAMS ((char *, unsigned *)); -static char * parse_exp PARAMS ((char *, expressionS *)); +static char * parse_reg PARAMS ((char *, unsigned *)); +static char * parse_creg PARAMS ((char *, unsigned *)); +static char * parse_exp PARAMS ((char *, expressionS *)); +static char * parse_rt PARAMS ((char *, char **, int, expressionS *)); +static char * parse_imm PARAMS ((char *, unsigned *, unsigned, unsigned)); +static char * parse_mem PARAMS ((char *, unsigned *, unsigned *, unsigned)); +static char * parse_psrmod PARAMS ((char *, unsigned *)); static void make_name PARAMS ((char *, char *, int)); static int enter_literal PARAMS ((expressionS *, int)); -static char * parse_rt PARAMS ((char *, char **, int, expressionS *)); -static char * parse_imm PARAMS ((char *, unsigned *, unsigned, unsigned)); -static char * parse_mem PARAMS ((char *, unsigned *, unsigned *, unsigned)); static void dump_literals PARAMS ((int)); static void check_literals PARAMS ((int, int)); static void mcore_s_text PARAMS ((int)); static void mcore_s_data PARAMS ((int)); -#ifdef OBJ_ELF static void mcore_s_section PARAMS ((int)); +static void mcore_s_bss PARAMS ((int)); +#ifdef OBJ_ELF +static void mcore_s_comm PARAMS ((int)); #endif /* Several places in this file insert raw instructions into the object. They should use MCORE_INST_XXX macros to get the opcodes and then use these two macros to crack the MCORE_INST value into the appropriate byte values. */ -#define INST_BYTE0(x) (((x) >> 8) & 0xFF) -#define INST_BYTE1(x) ((x) & 0xFF) +#define INST_BYTE0(x) (target_big_endian ? (((x) >> 8) & 0xFF) : ((x) & 0xFF)) +#define INST_BYTE1(x) (target_big_endian ? ((x) & 0xFF) : (((x) >> 8) & 0xFF)) const char comment_chars[] = "#/"; const char line_separator_chars[] = ";"; @@ -70,7 +74,6 @@ const char line_comment_chars[] = "#/"; const int md_reloc_size = 8; -static int relax; /* set if -relax seen */ static int do_jsri2bsr = 0; /* change here from 1 by Cruess 19 August 97 */ static int sifilter_mode = 0; @@ -101,6 +104,14 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP"; #define U12_LEN 2 #define U32_LEN 8 /* allow for align */ +typedef enum +{ + M210, + M340 +} +cpu_type; + +cpu_type cpu = M340; /* Initialize the relax table */ const relax_typeS md_relax_table[] = @@ -165,7 +176,6 @@ const pseudo_typeS md_pseudo_table[] = { "import", s_ignore, 0 }, { "literals", mcore_s_literals, 0 }, { "page", listing_eject, 0 }, - { "bss", s_lcomm_bytes, 1 }, /* The following are to intercept the placement of data into the text section (eg addresses for a switch table), so that the space they @@ -177,11 +187,11 @@ const pseudo_typeS md_pseudo_table[] = { "byte", mcore_cons, 1 }, { "dc", mcore_cons, 2 }, { "dc.b", mcore_cons, 1 }, - { "dc.d", mcore_float_cons, 'd' }, + { "dc.d", mcore_float_cons, 'd'}, { "dc.l", mcore_cons, 4 }, - { "dc.s", mcore_float_cons, 'f' }, + { "dc.s", mcore_float_cons, 'f'}, { "dc.w", mcore_cons, 2 }, - { "dc.x", mcore_float_cons, 'x' }, + { "dc.x", mcore_float_cons, 'x'}, { "double", mcore_float_cons, 'd'}, { "float", mcore_float_cons, 'f'}, { "hword", mcore_cons, 2 }, @@ -193,17 +203,20 @@ const pseudo_typeS md_pseudo_table[] = { "single", mcore_float_cons, 'f'}, { "string", mcore_stringer, 1 }, { "word", mcore_cons, 2 }, + { "fill", mcore_fill, 0 }, /* Allow for the effect of section changes. */ { "text", mcore_s_text, 0 }, { "data", mcore_s_data, 0 }, - -#ifdef OBJ_ELF + { "bss", mcore_s_bss, 1 }, +#ifdef OBJ_EF + { "comm", mcore_s_comm, 0 }, +#endif { "section", mcore_s_section, 0 }, { "section.s", mcore_s_section, 0 }, { "sect", mcore_s_section, 0 }, { "sect.s", mcore_s_section, 0 }, -#endif + { 0, 0, 0 } }; @@ -305,12 +318,52 @@ mcore_stringer (append_zero) } static void +mcore_fill (unused) + int unused; +{ + if (now_seg == text_section) + { + char * str = input_line_pointer; + int size = 1; + int repeat; + + repeat = atoi (str); + + /* Look to see if a size has been specified. */ + while (*str != '\n' && *str != 0 && *str != ',') + ++ str; + + if (* str == ',') + { + size = atoi (str + 1); + + if (size > 8) + size = 8; + else if (size < 0) + size = 0; + } + + poolspan += size * repeat; + } + + s_fill (unused); + + check_literals (2, 0); +} + +/* Handle the section changing pseudo-ops. These call through to the + normal implementations, but they dump the literal pool first. */ +static void mcore_s_text (ignore) int ignore; { dump_literals (0); +#ifdef OBJ_ELF + obj_elf_text (ignore); +#else s_text (ignore); +#endif } static void @@ -319,11 +372,64 @@ mcore_s_data (ignore) { dump_literals (0); +#ifdef OBJ_ELF + obj_elf_data (ignore); +#else s_data (ignore); +#endif +} + +static void +mcore_s_section (ignore) + int ignore; +{ + /* Scan forwards to find the name of the section. If the section + being switched to is ".line" then this is a DWARF1 debug section + which is arbitarily placed inside generated code. In this case + do not dump the literal pool because it is a) inefficient and + b) would require the generation of extra code to jump around the + pool. */ + char * ilp = input_line_pointer; + + while (*ilp != 0 && isspace(*ilp)) + ++ ilp; + + if (strncmp (ilp, ".line", 5) == 0 + && (isspace (ilp[5]) || *ilp == '\n' || *ilp == '\r')) + ; + else + dump_literals (0); + +#ifdef OBJ_ELF + obj_elf_section (ignore); +#endif +#ifdef OBJ_COFF + obj_coff_section (ignore); +#endif +} + +static void +mcore_s_bss (needs_align) + int needs_align; +{ + dump_literals (0); + + s_lcomm_bytes (needs_align); +} + +#ifdef OBJ_ELF +static void +mcore_s_comm (needs_align) + int needs_align; +{ + dump_literals (0); + + obj_elf_common (needs_align); } +#endif /* This function is called once, at assembler startup time. This should - set up all the tables, etc that the MD part of the assembler needs. */ + set up all the tables, etc that the MD part of the assembler needs. */ void md_begin () { @@ -394,7 +500,7 @@ parse_reg (s, reg) } else if ( tolower (s[0]) == 's' && tolower (s[1]) == 'p' - && (isspace (s[2]) || s[2] == ',')) + && ! isalnum (s[2])) { * reg = 0; return s + 2; @@ -490,6 +596,46 @@ parse_creg (s, reg) } static char * +parse_psrmod (s, reg) + char * s; + unsigned * reg; +{ + int i; + char buf[10]; + static struct psrmods + { + char * name; + unsigned int value; + } + psrmods[] = + { + { "ie", 1 }, + { "fe", 2 }, + { "ee", 4 }, + { "af", 8 } /* Really 0 and non-combinable. */ + }; + + for (i = 0; i < 2; i++) + buf[i] = isascii (s[i]) ? tolower (s[i]) : 0; + + for (i = sizeof (psrmods) / sizeof (psrmods[0]); i--;) + { + if (! strncmp (psrmods[i].name, buf, 2)) + { + * reg = psrmods[i].value; + + return s + 2; + } + } + + as_bad (_("bad/missing psr specifier")); + + * reg = 0; + + return s; +} + +static char * parse_exp (s, e) char * s; expressionS * e; @@ -533,13 +679,16 @@ make_name (s, p, n) s[7] = 0; } +#define POOL_END_LABEL ".LE" +#define POOL_START_LABEL ".LS" + static void dump_literals (isforce) int isforce; { int i; struct literal * p; - struct symbol * brarsym; + symbolS * brarsym; if (poolsize == 0) return; @@ -550,7 +699,7 @@ dump_literals (isforce) char * output; char brarname[8]; - make_name (brarname, ".YP.", poolnumber); + make_name (brarname, POOL_END_LABEL, poolnumber); brarsym = symbol_make (brarname); @@ -642,7 +791,7 @@ enter_literal (e, ispcrel) if (++ poolnumber > 0xFFFF) as_fatal (_("more than 65K literal pools")); - make_name (poolname, ".XP.", poolnumber); + make_name (poolname, POOL_START_LABEL, poolnumber); poolsym = symbol_make (poolname); symbol_table_insert (poolsym); poolspan = 0; @@ -877,8 +1026,8 @@ md_assemble (str) fixes problem of an interrupt during a jmp.. */ if (sifilter_mode) { - output[0] = (inst >> 8); - output[1] = (inst); + output[0] = INST_BYTE0 (inst); + output[1] = INST_BYTE1 (inst); output = frag_more (2); } break; @@ -896,20 +1045,20 @@ md_assemble (str) { /* Replace with: bsr .+2 ; addi r15,6; jmp rx ; jmp rx */ inst = MCORE_INST_BSR; /* with 0 displacement */ - output[0] = (inst >> 8); - output[1] = (inst); + output[0] = INST_BYTE0 (inst); + output[1] = INST_BYTE1 (inst); output = frag_more (2); inst = MCORE_INST_ADDI; inst |= 15; /* addi r15,6 */ inst |= (6 - 1) << 4; /* over the jmp's */ - output[0] = (inst >> 8); - output[1] = (inst); + output[0] = INST_BYTE0 (inst); + output[1] = INST_BYTE1 (inst); output = frag_more (2); inst = MCORE_INST_JMP | reg; - output[0] = (inst >> 8); - output[1] = (inst); + output[0] = INST_BYTE0 (inst); + output[1] = INST_BYTE1 (inst); output = frag_more (2); /* 2nd emitted in fallthru */ } @@ -932,6 +1081,13 @@ md_assemble (str) output = frag_more (2); break; + case MULSH: + if (cpu == M210) + { + as_bad (_("M340 specific opcode used when assembling for M210")); + break; + } + /* drop through... */ case O2: op_end = parse_reg (op_end + 1, & reg); inst |= reg; @@ -1239,8 +1395,11 @@ md_assemble (str) ++ op_end; if (* op_end == ',') - /* parse_rt calls frag_more() for us. */ - input_line_pointer = parse_rt (op_end + 1, & output, 0, 0); + { + /* parse_rt calls frag_more() for us. */ + input_line_pointer = parse_rt (op_end + 1, & output, 0, 0); + op_end = input_line_pointer; + } else { as_bad (_("second operand missing")); @@ -1251,6 +1410,7 @@ md_assemble (str) case LJ: input_line_pointer = parse_rt (op_end + 1, & output, 1, 0); /* parse_rt() calls frag_more() for us. */ + op_end = input_line_pointer; break; case RM: @@ -1363,6 +1523,7 @@ md_assemble (str) case BR: input_line_pointer = parse_exp (op_end + 1, & e); + op_end = input_line_pointer; output = frag_more (2); @@ -1395,6 +1556,7 @@ md_assemble (str) case JC: input_line_pointer = parse_exp (op_end + 1, & e); + op_end = input_line_pointer; output = frag_var (rs_machine_dependent, md_relax_table[C (COND_JUMP, COND32)].rlx_length, @@ -1405,6 +1567,8 @@ md_assemble (str) case JU: input_line_pointer = parse_exp (op_end + 1, & e); + op_end = input_line_pointer; + output = frag_var (rs_machine_dependent, md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length, md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length, @@ -1415,7 +1579,8 @@ md_assemble (str) case JL: inst = MCORE_INST_JSRI; /* jsri */ input_line_pointer = parse_rt (op_end + 1, & output, 1, & e); - /* parse_rt() calls frag_more for us */ + /* parse_rt() calls frag_more for us. */ + op_end = input_line_pointer; /* Only do this if we know how to do it ... */ if (e.X_op != O_absent && do_jsri2bsr) @@ -1492,12 +1657,49 @@ md_assemble (str) output = frag_more (2); break; + case OPSR: + if (cpu == M210) + { + as_bad (_("M340 specific opcode used when assembling for M210")); + break; + } + + op_end = parse_psrmod (op_end + 1, & reg); + + /* Look for further selectors. */ + while (* op_end == ',') + { + unsigned value; + + op_end = parse_psrmod (op_end + 1, & value); + + if (value & reg) + as_bad (_("duplicated psr bit specifier")); + + reg |= value; + } + + if (reg > 8) + as_bad (_("`af' must appear alone")); + + inst |= (reg & 0x7); + output = frag_more (2); + break; + default: as_bad (_("unimplemented opcode \"%s\""), name); } + + /* Drop whitespace after all the operands have been parsed. */ + while (isspace (* op_end)) + op_end ++; + + /* Give warning message if the insn has more operands than required. */ + if (strcmp (op_end, opcode->name) && strcmp (op_end, "")) + as_warn (_("ignoring operands: %s "), op_end); - output[0] = inst >> 8; - output[1] = inst; + output[0] = INST_BYTE0 (inst); + output[1] = INST_BYTE1 (inst); check_literals (opcode->transfer, isize); } @@ -1531,7 +1733,7 @@ md_atof (type, litP, sizeP) { int prec; LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE * wordP; + int i; char * t; char * atof_ieee (); @@ -1573,30 +1775,45 @@ md_atof (type, litP, sizeP) *sizeP = prec * sizeof (LITTLENUM_TYPE); - for (wordP = words; prec--;) + if (! target_big_endian) { - md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); + for (i = prec - 1; i >= 0; i--) + { + md_number_to_chars (litP, (valueT) words[i], + sizeof (LITTLENUM_TYPE)); + litP += sizeof (LITTLENUM_TYPE); + } } + else + for (i = 0; i < prec; i++) + { + md_number_to_chars (litP, (valueT) words[i], + sizeof (LITTLENUM_TYPE)); + litP += sizeof (LITTLENUM_TYPE); + } return 0; } CONST char * md_shortopts = ""; -#define OPTION_RELAX (OPTION_MD_BASE) -#define OPTION_JSRI2BSR_ON (OPTION_MD_BASE + 1) -#define OPTION_JSRI2BSR_OFF (OPTION_MD_BASE + 2) -#define OPTION_SIFILTER_ON (OPTION_MD_BASE + 3) -#define OPTION_SIFILTER_OFF (OPTION_MD_BASE + 4) +#define OPTION_JSRI2BSR_ON (OPTION_MD_BASE + 0) +#define OPTION_JSRI2BSR_OFF (OPTION_MD_BASE + 1) +#define OPTION_SIFILTER_ON (OPTION_MD_BASE + 2) +#define OPTION_SIFILTER_OFF (OPTION_MD_BASE + 3) +#define OPTION_CPU (OPTION_MD_BASE + 4) +#define OPTION_EB (OPTION_MD_BASE + 5) +#define OPTION_EL (OPTION_MD_BASE + 6) struct option md_longopts[] = { - { "relax", no_argument, NULL, OPTION_RELAX}, { "no-jsri2bsr", no_argument, NULL, OPTION_JSRI2BSR_OFF}, { "jsri2bsr", no_argument, NULL, OPTION_JSRI2BSR_ON}, { "sifilter", no_argument, NULL, OPTION_SIFILTER_ON}, { "no-sifilter", no_argument, NULL, OPTION_SIFILTER_OFF}, + { "cpu", required_argument, NULL, OPTION_CPU}, + { "EB", no_argument, NULL, OPTION_EB}, + { "EL", no_argument, NULL, OPTION_EL}, { NULL, no_argument, NULL, 0} }; @@ -1612,8 +1829,20 @@ md_parse_option (c, arg) switch (c) { + case OPTION_CPU: + if (streq (arg, "210")) + { + cpu = M210; + target_big_endian = 1; + } + else if (streq (arg, "340")) + cpu = M340; + else + as_warn (_("unrecognised cpu type '%s'"), arg); + break; - case OPTION_RELAX: relax = 1; break; + case OPTION_EB: target_big_endian = 1; break; + case OPTION_EL: target_big_endian = 0; cpu = M340; break; case OPTION_JSRI2BSR_ON: do_jsri2bsr = 1; break; case OPTION_JSRI2BSR_OFF: do_jsri2bsr = 0; break; case OPTION_SIFILTER_ON: sifilter_mode = 1; break; @@ -1630,9 +1859,11 @@ md_show_usage (stream) { fprintf (stream, _("\ MCORE specific options:\n\ - -{no-}jsri2bsr {dis}able jsri to bsr transformation (def: off)\n\ - -{no-}sifilter {dis}able silicon filter behavior (def: off)\n\ - -relax alter jump instructions for long displacements\n")); + -{no-}jsri2bsr {dis}able jsri to bsr transformation (def: dis)\n\ + -{no-}sifilter {dis}able silicon filter behavior (def: dis)\n\ + -cpu=[210|340] select CPU type\n\ + -EB assemble for a big endian system (default)\n\ + -EL assemble for a little endian system\n")); } int md_short_jump_size; @@ -1670,27 +1901,40 @@ md_convert_frag (abfd, sec, fragP) int targ_addr = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset; buffer = (unsigned char *) (fragP->fr_fix + fragP->fr_literal); - targ_addr += fragP->fr_symbol->sy_frag->fr_address; + targ_addr += symbol_get_frag (fragP->fr_symbol)->fr_address; switch (fragP->fr_subtype) { case C (COND_JUMP, COND12): case C (UNCD_JUMP, UNCD12): { - /* Get the address of the end of the instruction */ + /* Get the address of the end of the instruction. */ int next_inst = fragP->fr_fix + fragP->fr_address + 2; unsigned char t0; int disp = targ_addr - next_inst; if (disp & 1) - as_bad (_("odd displacement at %x"), next_inst - 2); + as_bad (_("odd displacement at %x"), next_inst - 2); disp >>= 1; - t0 = buffer[0] & 0xF8; - md_number_to_chars (buffer, disp, 2); + if (! target_big_endian) + { + t0 = buffer[1] & 0xF8; + + md_number_to_chars (buffer, disp, 2); + + buffer[1] = (buffer[1] & 0x07) | t0; + } + else + { + t0 = buffer[0] & 0xF8; + + md_number_to_chars (buffer, disp, 2); + + buffer[0] = (buffer[0] & 0x07) | t0; + } - buffer[0] = (buffer[0] & 0x07) | t0; fragP->fr_fix += 2; fragP->fr_var = 0; } @@ -1712,15 +1956,27 @@ md_convert_frag (abfd, sec, fragP) int first_inst = fragP->fr_fix + fragP->fr_address; int needpad = (first_inst & 3); - buffer[0] ^= 0x08; /* Toggle T/F bit */ + if (! target_big_endian) + buffer[1] ^= 0x08; + else + buffer[0] ^= 0x08; /* Toggle T/F bit */ buffer[2] = INST_BYTE0 (MCORE_INST_JMPI); /* Build jmpi */ buffer[3] = INST_BYTE1 (MCORE_INST_JMPI); if (needpad) { - buffer[1] = 4; /* branch over jmpi, pad, and ptr */ - buffer[3] = 1; /* jmpi offset of 1 gets the pointer */ + if (! target_big_endian) + { + buffer[0] = 4; /* branch over jmpi, pad, and ptr */ + buffer[2] = 1; /* jmpi offset of 1 gets the pointer */ + } + else + { + buffer[1] = 4; /* branch over jmpi, pad, and ptr */ + buffer[3] = 1; /* jmpi offset of 1 gets the pointer */ + } + buffer[4] = 0; /* alignment/pad */ buffer[5] = 0; buffer[6] = 0; /* space for 32 bit address */ @@ -1740,8 +1996,17 @@ md_convert_frag (abfd, sec, fragP) shrinking the fragment. '3' is the amount of code that we inserted here, but '4' is right for the space we reserved for this fragment. */ - buffer[1] = 3; /* branch over jmpi, and ptr */ - buffer[3] = 0; /* jmpi offset of 0 gets the pointer */ + if (! target_big_endian) + { + buffer[0] = 3; /* branch over jmpi, and ptr */ + buffer[2] = 0; /* jmpi offset of 0 gets the pointer */ + } + else + { + buffer[1] = 3; /* branch over jmpi, and ptr */ + buffer[3] = 0; /* jmpi offset of 0 gets the pointer */ + } + buffer[4] = 0; /* space for 32 bit address */ buffer[5] = 0; buffer[6] = 0; @@ -1752,12 +2017,15 @@ md_convert_frag (abfd, sec, fragP) fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32); fragP->fr_fix += C32_LEN; - /* frag is actually shorter (see the other side of this ifdef) - but gas isn't prepared for that. We have to re-adjust + /* Frag is actually shorter (see the other side of this ifdef) + but gas isn't prepared for that. We have to re-adjust the branch displacement so that it goes beyond the full length of the fragment, not just what we actually filled in. */ - buffer[1] = 4; /* jmpi, ptr, and the 'tail pad' */ + if (! target_big_endian) + buffer[0] = 4; /* jmpi, ptr, and the 'tail pad' */ + else + buffer[1] = 4; /* jmpi, ptr, and the 'tail pad' */ } fragP->fr_var = 0; @@ -1782,7 +2050,10 @@ md_convert_frag (abfd, sec, fragP) if (needpad) { - buffer[1] = 1; /* jmpi offset of 1 since padded */ + if (! target_big_endian) + buffer[0] = 1; /* jmpi offset of 1 since padded */ + else + buffer[1] = 1; /* jmpi offset of 1 since padded */ buffer[2] = 0; /* alignment */ buffer[3] = 0; buffer[4] = 0; /* space for 32 bit address */ @@ -1790,7 +2061,7 @@ md_convert_frag (abfd, sec, fragP) buffer[6] = 0; buffer[7] = 0; - /* Make reloc for the long disp */ + /* Make reloc for the long disp. */ fix_new (fragP, fragP->fr_fix + 4, 4, fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32); @@ -1798,13 +2069,16 @@ md_convert_frag (abfd, sec, fragP) } else { - buffer[1] = 0; /* jmpi offset of 0 if no pad */ + if (! target_big_endian) + buffer[0] = 0; /* jmpi offset of 0 if no pad */ + else + buffer[1] = 0; /* jmpi offset of 0 if no pad */ buffer[2] = 0; /* space for 32 bit address */ buffer[3] = 0; buffer[4] = 0; buffer[5] = 0; - /* Make reloc for the long disp */ + /* Make reloc for the long disp. */ fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32); fragP->fr_fix += U32_LEN; @@ -1865,9 +2139,17 @@ md_apply_fix3 (fixP, valp, segment) as_bad_where (file, fixP->fx_line, _("pcrel for branch to %s too far (0x%x)"), symname, val); - buf[0] |= ((val >> 8) & 0x7); - buf[1] |= (val & 0xff); - break; + if (target_big_endian) + { + buf[0] |= ((val >> 8) & 0x7); + buf[1] |= (val & 0xff); + } + else + { + buf[0] |= ((val >> 8) & 0x7); + buf[1] |= (val & 0xff); + } + break; case BFD_RELOC_MCORE_PCREL_IMM8BY4: /* lower 8 bits of 2 byte opcode */ val += 3; @@ -1876,16 +2158,21 @@ md_apply_fix3 (fixP, valp, segment) as_bad_where (file, fixP->fx_line, _("pcrel for lrw/jmpi/jsri to %s too far (0x%x)"), symname, val); + else if (! target_big_endian) + buf[0] |= (val & 0xff); else buf[1] |= (val & 0xff); - break; + break; case BFD_RELOC_MCORE_PCREL_IMM4BY2: /* loopt instruction */ if ((val < -32) || (val > -2)) as_bad_where (file, fixP->fx_line, _("pcrel for loopt too far (0x%x)"), val); val /= 2; - buf[1] |= (val & 0xf); + if (! target_big_endian) + buf[0] |= (val & 0xf); + else + buf[1] |= (val & 0xf); break; case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2: @@ -1898,8 +2185,8 @@ md_apply_fix3 (fixP, valp, segment) nval |= MCORE_INST_BSR; /* REPLACE the instruction, don't just modify it. */ - buf[0] = ((nval >> 8) & 0xff); - buf[1] = (nval & 0xff); + buf[0] = INST_BYTE0 (nval); + buf[1] = INST_BYTE1 (nval); } else fixP->fx_done = 0; @@ -1923,21 +2210,14 @@ md_apply_fix3 (fixP, valp, segment) #endif { if (fixP->fx_size == 4) - { - *buf++ = val >> 24; - *buf++ = val >> 16; - *buf++ = val >> 8; - *buf = val; - } + ; else if (fixP->fx_size == 2 && val >= -32768 && val <= 32767) - { - *buf++ = val >> 8; - *buf = val; - } + ; else if (fixP->fx_size == 1 && val >= -256 && val <= 255) - *buf = val; + ; else abort (); + md_number_to_chars (buf, val, fixP->fx_size); } break; } @@ -2021,22 +2301,31 @@ md_estimate_size_before_relax (fragP, segment_type) return fragP->fr_var; } -/* Put number into target byte order */ - +/* Put number into target byte order. */ void md_number_to_chars (ptr, use, nbytes) char * ptr; valueT use; int nbytes; { - switch (nbytes) - { - case 4: *ptr++ = (use >> 24) & 0xff; /* fall through */ - case 3: *ptr++ = (use >> 16) & 0xff; /* fall through */ - case 2: *ptr++ = (use >> 8) & 0xff; /* fall through */ - case 1: *ptr++ = (use >> 0) & 0xff; break; - default: abort (); - } + if (! target_big_endian) + switch (nbytes) + { + case 4: ptr[3] = (use >> 24) & 0xff; /* fall through */ + case 3: ptr[2] = (use >> 16) & 0xff; /* fall through */ + case 2: ptr[1] = (use >> 8) & 0xff; /* fall through */ + case 1: ptr[0] = (use >> 0) & 0xff; break; + default: abort (); + } + else + switch (nbytes) + { + case 4: *ptr++ = (use >> 24) & 0xff; /* fall through */ + case 3: *ptr++ = (use >> 16) & 0xff; /* fall through */ + case 2: *ptr++ = (use >> 8) & 0xff; /* fall through */ + case 1: *ptr++ = (use >> 0) & 0xff; break; + default: abort (); + } } /* Round up a section size to the appropriate boundary. */ @@ -2095,6 +2384,7 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_MCORE_PCREL_IMM8BY4: case BFD_RELOC_MCORE_PCREL_IMM11BY2: case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2: + case BFD_RELOC_RVA: code = fixp->fx_r_type; break; @@ -2117,7 +2407,8 @@ tc_gen_reloc (section, fixp) } rel = (arelent *) xmalloc (sizeof (arelent)); - rel->sym_ptr_ptr = & fixp->fx_addsy->bsym; + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); rel->address = fixp->fx_frag->fr_address + fixp->fx_where; /* Always pass the addend along! */ rel->addend = fixp->fx_addnumber; @@ -2147,7 +2438,8 @@ mcore_force_relocation (fix) fixS * fix; { if ( fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT - || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY + || fix->fx_r_type == BFD_RELOC_RVA) return 1; return 0; @@ -2169,15 +2461,4 @@ mcore_fix_adjustable (fixP) return 1; } - -/* Handle the .section pseudo-op. This is like the usual one, but it - dumps the literal pool before changing the section. */ -static void -mcore_s_section (ignore) - int ignore; -{ - dump_literals (0); - - obj_elf_section (ignore); -} #endif /* OBJ_ELF */ diff --git a/gas/config/tc-mcore.h b/gas/config/tc-mcore.h index 9e487c9..b0a29ab 100644 --- a/gas/config/tc-mcore.h +++ b/gas/config/tc-mcore.h @@ -1,6 +1,6 @@ /* This file is tc-mcore.h - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -15,8 +15,9 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + 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. */ #ifndef TC_MCORE #define TC_MCORE 1 @@ -26,7 +27,8 @@ #endif #define TARGET_ARCH bfd_arch_mcore -#define TARGET_BYTES_BIG_ENDIAN 1 +/* Used to initialise target_big_endian. */ +#define TARGET_BYTES_BIG_ENDIAN 0 /* Don't write out relocs for pcrel stuff. */ #define TC_COUNT_RELOC(x) (((x)->fx_addsy || (x)->fx_subsy) && \ @@ -65,7 +67,16 @@ extern const struct relax_type md_relax_table[]; #define TARGET_FORMAT (target_big_endian ? "pe-mcore-big" : "pe-mcore-little") -#define TARGET_SYMBOL_FIELDS int sy_flags ; +struct mcore_tc_sy +{ + int sy_flags; +}; + +#define TC_SYMFIELD_TYPE struct mcore_tc_sy + +# if defined TE_PE +# define TC_FORCE_RELOCATION(x) ((x)->fx_r_type == BFD_RELOC_RVA) +# endif #endif /* OBJ_COFF */ @@ -93,7 +104,6 @@ extern boolean mcore_fix_adjustable PARAMS ((struct fix *)); # error No target format specified. #endif -#include "struc-symbol.h" /* For definition of symbolS */ #include "write.h" /* For definition of fixS */ extern void md_begin PARAMS ((void)); diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 3d865fd..5daf89d 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1,5 +1,5 @@ /* tc-mips.c -- assemble code for a MIPS chip. - Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc. Contributed by the OSF and Ralph Campbell. Written by Keith Knowles and Ralph Campbell, working independently. Modified for ECOFF and R4000 support by Ian Lance Taylor of Cygnus @@ -54,7 +54,6 @@ static int mips_output_flavor () { return OUTPUT_FLAVOR; } #undef S_GET_SIZE #undef S_SET_ALIGN #undef S_SET_SIZE -#undef TARGET_SYMBOL_FIELDS #undef obj_frob_file #undef obj_frob_file_after_relocs #undef obj_frob_symbol @@ -119,6 +118,8 @@ mips_target_format () return target_big_endian ? "a.out-mips-big" : "a.out-mips-little"; case bfd_target_ecoff_flavour: return target_big_endian ? "ecoff-bigmips" : ECOFF_LITTLE_FORMAT; + case bfd_target_coff_flavour: + return "pe-mips"; case bfd_target_elf_flavour: return (target_big_endian ? (mips_64 ? "elf64-bigmips" : "elf32-bigmips") @@ -134,6 +135,8 @@ mips_target_format () ? ".data" \ : OUTPUT_FLAVOR == bfd_target_ecoff_flavour \ ? ".rdata" \ + : OUTPUT_FLAVOR == bfd_target_coff_flavour \ + ? ".rdata" \ : OUTPUT_FLAVOR == bfd_target_elf_flavour \ ? ".rodata" \ : (abort (), "")) @@ -204,6 +207,29 @@ static int mips_eabi64 = 0; mips3 or greater, then mark the object file 32BITMODE. */ static int mips_32bitmode = 0; +/* True if -mgp32 was passed. */ +static int mips_gp32 = 0; + +/* Some ISA's have delay slots for instructions which read or write + from a coprocessor (eg. mips1-mips3); some don't (eg mips4). + Return true if instructions marked INSN_LOAD_COPROC_DELAY, + INSN_COPROC_MOVE_DELAY, or INSN_WRITE_COND_CODE actually have a + delay slot in this ISA. The uses of this macro assume that any + ISA that has delay slots for one of these, has them for all. They + also assume that ISAs which don't have delays for these insns, don't + have delays for the INSN_LOAD_MEMORY_DELAY instructions either. */ +#define ISA_HAS_COPROC_DELAYS(ISA) ( \ + (ISA) == 1 \ + || (ISA) == 2 \ + || (ISA) == 3 \ + ) + +/* Return true if ISA supports 64 bit gp register instructions. */ +#define ISA_HAS_64BIT_REGS(ISA) ( \ + (ISA) == 3 \ + || (ISA) == 4 \ + ) + /* Whether the processor uses hardware interlocks to protect reads from the HI and LO registers, and thus does not require nops to be inserted. @@ -237,7 +263,7 @@ static int mips_32bitmode = 0; /* Whether the processor uses hardware interlocks to protect reads from the GPRs, and thus does not require nops to be inserted. */ #define gpr_interlocks \ - (mips_opts.isa >= 2 \ + (mips_opts.isa != 1 \ || mips_cpu == 3900) /* As with other "interlocks" this is used by hardware that has FP @@ -246,6 +272,10 @@ static int mips_32bitmode = 0; #define cop_interlocks (mips_cpu == 4300 \ ) +/* Is this a mfhi or mflo instruction? */ +#define MF_HILO_INSN(PINFO) \ + ((PINFO & INSN_READ_HI) || (PINFO & INSN_READ_LO)) + /* MIPS PIC level. */ enum mips_pic_level @@ -281,6 +311,10 @@ static int mips_trap; static int mips_any_noreorder; +/* Non-zero if nops should be inserted when the register referenced in + an mfhi/mflo instruction is read in the next two instructions. */ +static int mips_7000_hilo_fix; + /* The size of the small data section. */ static int g_switch_value = 8; /* Whether the -G option was used. */ @@ -295,8 +329,9 @@ static int g_switch_seen = 0; better. This function can only provide a guess, but it seems to work for - gcc output. If it guesses wrong, the only loss should be in - efficiency; it shouldn't introduce any bugs. + gcc output. It needs to guess right for gcc, otherwise gcc + will put what it thinks is a GP-relative instruction in a branch + delay slot. I don't know if a fix is needed for the SVR4_PIC mode. I've only fixed it for the non-PIC mode. KR 95/04/07 */ @@ -817,6 +852,15 @@ md_begin () int broken = 0; int mips_isa_from_cpu; + /* GP relative stuff not working for PE */ + if (strncmp (TARGET_OS, "pe", 2) == 0 + && g_switch_value != 0) + { + if (g_switch_seen) + as_bad (_("-G not supported in this configuration.")); + g_switch_value = 0; + } + cpu = TARGET_CPU; if (strcmp (cpu + (sizeof TARGET_CPU) - 3, "el") == 0) { @@ -834,10 +878,10 @@ md_begin () if (strcmp (cpu, "mips") == 0) { - if (mips_opts.isa < 0) - mips_cpu = 3000; + if (mips_opts.isa < 0) + mips_cpu = 3000; - else if (mips_opts.isa == 2) + else if (mips_opts.isa == 2) mips_cpu = 6000; else if (mips_opts.isa == 3) @@ -957,13 +1001,13 @@ md_begin () a = NULL; } - if (mips_opts.isa < 2 && mips_trap) + if (mips_opts.isa == 1 && mips_trap) as_bad (_("trap exception not supported at ISA 1")); /* Set the EABI kind based on the ISA before the user gets to change the ISA with directives. This isn't really the best, but then neither is basing the abi on the isa. */ - if (mips_opts.isa > 2 + if (ISA_HAS_64BIT_REGS (mips_opts.isa) && mips_abi_string && 0 == strcmp (mips_abi_string,"eabi")) mips_eabi64 = 1; @@ -971,11 +1015,12 @@ md_begin () if (mips_cpu != 0 && mips_cpu != -1) { ok = bfd_set_arch_mach (stdoutput, bfd_arch_mips, mips_cpu); - + /* If they asked for mips1 or mips2 and a cpu that is mips3 or greater, then mark the object file 32BITMODE. */ if (mips_isa_from_cpu != -1 - && mips_opts.isa <= 2 && mips_isa_from_cpu > 2) + && ! ISA_HAS_64BIT_REGS (mips_opts.isa) + && ISA_HAS_64BIT_REGS (mips_isa_from_cpu)) mips_32bitmode = 1; } else @@ -1334,7 +1379,7 @@ reg_needs_delay (reg) prev_pinfo = prev_insn.insn_mo->pinfo; if (! mips_opts.noreorder - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && ((prev_pinfo & INSN_LOAD_COPROC_DELAY) || (! gpr_interlocks && (prev_pinfo & INSN_LOAD_MEMORY_DELAY)))) @@ -1373,8 +1418,8 @@ mips16_mark_labels () if (OUTPUT_FLAVOR == bfd_target_elf_flavour) S_SET_OTHER (l->label, STO_MIPS16); #endif - if ((l->label->sy_value.X_add_number & 1) == 0) - ++l->label->sy_value.X_add_number; + if ((S_GET_VALUE (l->label) & 1) == 0) + S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1); } } } @@ -1437,7 +1482,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) /* The previous insn might require a delay slot, depending upon the contents of the current insn. */ if (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (((prev_pinfo & INSN_LOAD_COPROC_DELAY) && ! cop_interlocks) || (! gpr_interlocks @@ -1457,10 +1502,10 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) ++nops; } else if (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (((prev_pinfo & INSN_COPROC_MOVE_DELAY) && ! cop_interlocks) - || (mips_opts.isa < 2 + || (mips_opts.isa == 1 && (prev_pinfo & INSN_COPROC_MEMORY_DELAY)))) { /* A generic coprocessor delay. The previous instruction @@ -1516,7 +1561,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) } } else if (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (prev_pinfo & INSN_WRITE_COND_CODE) && ! cop_interlocks) { @@ -1530,6 +1575,37 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) || (pinfo & INSN_READ_COND_CODE)) ++nops; } + + /* If we're fixing up mfhi/mflo for the r7000 and the + previous insn was an mfhi/mflo and the current insn + reads the register that the mfhi/mflo wrote to, then + insert two nops. */ + + else if (mips_7000_hilo_fix + && MF_HILO_INSN (prev_pinfo) + && insn_uses_reg (ip, ((prev_insn.insn_opcode >> OP_SH_RD) + & OP_MASK_RD), + MIPS_GR_REG)) + + { + nops += 2; + } + + /* If we're fixing up mfhi/mflo for the r7000 and the + 2nd previous insn was an mfhi/mflo and the current insn + reads the register that the mfhi/mflo wrote to, then + insert one nop. */ + + else if (mips_7000_hilo_fix + && MF_HILO_INSN (prev_prev_insn.insn_opcode) + && insn_uses_reg (ip, ((prev_prev_insn.insn_opcode >> OP_SH_RD) + & OP_MASK_RD), + MIPS_GR_REG)) + + { + nops += 1; + } + else if (prev_pinfo & INSN_READ_LO) { /* The previous instruction reads the LO register; if the @@ -1593,7 +1669,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) instruction, we must check for these cases compared to the instruction previous to the previous instruction. */ if ((! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (prev_prev_insn.insn_mo->pinfo & INSN_COPROC_MOVE_DELAY) && (prev_prev_insn.insn_mo->pinfo & INSN_WRITE_COND_CODE) && (pinfo & INSN_READ_COND_CODE) @@ -1656,11 +1732,11 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) for (l = insn_labels; l != NULL; l = l->next) { assert (S_GET_SEGMENT (l->label) == now_seg); - l->label->sy_frag = frag_now; + symbol_set_frag (l->label, frag_now); S_SET_VALUE (l->label, (valueT) frag_now_fix ()); /* mips16 text labels are stored as odd. */ if (mips_opts.mips16) - ++l->label->sy_value.X_add_number; + S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1); } #ifndef NO_ECOFF_DEBUGGING @@ -1943,13 +2019,13 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) we can not swap, and I don't feel like handling that case. */ || (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (pinfo & INSN_READ_COND_CODE)) /* We can not swap with an instruction that requires a delay slot, becase the target of the branch might interfere with that instruction. */ || (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (prev_pinfo /* Itbl support may require additional care here. */ & (INSN_LOAD_COPROC_DELAY @@ -1964,7 +2040,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) && ! gpr_interlocks && (prev_pinfo & INSN_LOAD_MEMORY_DELAY)) || (! mips_opts.mips16 - && mips_opts.isa < 2 + && mips_opts.isa == 1 /* Itbl support may require additional care here. */ && (prev_pinfo & INSN_COPROC_MEMORY_DELAY)) /* We can not swap with a branch instruction. */ @@ -2069,7 +2145,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) delay, and sets a register that the branch reads, we can not swap. */ || (! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) /* Itbl support may require additional care here. */ && ((prev_prev_insn.insn_mo->pinfo & INSN_LOAD_COPROC_DELAY) || (! gpr_interlocks @@ -2098,7 +2174,7 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) || (mips_opts.mips16 && prev_insn_fixp) /* If the previous instruction is a sync, sync.l, or sync.p, we can not swap. */ - || (prev_pinfo && INSN_SYNC)) + || (prev_pinfo & INSN_SYNC)) { /* We could do even better for unconditional branches to portions of this object file; we could pick up the @@ -2285,7 +2361,7 @@ mips_emit_delays (insns) nops = 0; if ((! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (! cop_interlocks && (prev_insn.insn_mo->pinfo & (INSN_LOAD_COPROC_DELAY @@ -2300,14 +2376,14 @@ mips_emit_delays (insns) && (prev_insn.insn_mo->pinfo & INSN_LOAD_MEMORY_DELAY)) || (! mips_opts.mips16 - && mips_opts.isa < 2 + && mips_opts.isa == 1 && (prev_insn.insn_mo->pinfo & INSN_COPROC_MEMORY_DELAY))) { /* Itbl support may require additional care here. */ ++nops; if ((! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (! cop_interlocks && prev_insn.insn_mo->pinfo & INSN_WRITE_COND_CODE)) || (! hilo_interlocks @@ -2319,7 +2395,7 @@ mips_emit_delays (insns) nops = 0; } else if ((! mips_opts.mips16 - && mips_opts.isa < 4 + && ISA_HAS_COPROC_DELAYS (mips_opts.isa) && (! cop_interlocks && prev_prev_insn.insn_mo->pinfo & INSN_WRITE_COND_CODE)) || (! hilo_interlocks @@ -2360,11 +2436,11 @@ mips_emit_delays (insns) for (l = insn_labels; l != NULL; l = l->next) { assert (S_GET_SEGMENT (l->label) == now_seg); - l->label->sy_frag = frag_now; + symbol_set_frag (l->label, frag_now); S_SET_VALUE (l->label, (valueT) frag_now_fix ()); /* mips16 text labels are stored as odd. */ if (mips_opts.mips16) - ++l->label->sy_value.X_add_number; + S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1); } } } @@ -2403,7 +2479,6 @@ macro_build (place, counter, ep, name, fmt, va_alist) struct mips_cl_insn insn; bfd_reloc_code_real_type r; va_list args; - int insn_isa; #ifdef USE_STDARG va_start (args, fmt); @@ -2437,30 +2512,10 @@ macro_build (place, counter, ep, name, fmt, va_alist) /* Search until we get a match for NAME. */ while (1) { - if ((insn.insn_mo->membership & INSN_ISA) == INSN_ISA1) - insn_isa = 1; - else if ((insn.insn_mo->membership & INSN_ISA) == INSN_ISA2) - insn_isa = 2; - else if ((insn.insn_mo->membership & INSN_ISA) == INSN_ISA3) - insn_isa = 3; - else if ((insn.insn_mo->membership & INSN_ISA) == INSN_ISA4) - insn_isa = 4; - else - insn_isa = 15; - if (strcmp (fmt, insn.insn_mo->args) == 0 && insn.insn_mo->pinfo != INSN_MACRO - && (insn_isa <= mips_opts.isa - || (mips_cpu == 4650 - && (insn.insn_mo->membership & INSN_4650) != 0) - || (mips_cpu == 4010 - && (insn.insn_mo->membership & INSN_4010) != 0) - || ((mips_cpu == 4100 - || mips_cpu == 4111 - ) - && (insn.insn_mo->membership & INSN_4100) != 0) - || (mips_cpu == 3900 - && (insn.insn_mo->membership & INSN_3900) != 0)) + && OPCODE_IS_MEMBER (insn.insn_mo, mips_opts.isa, mips_cpu, + mips_gp32) && (mips_cpu != 4650 || (insn.insn_mo->pinfo & FP_D) == 0)) break; @@ -2542,7 +2597,6 @@ macro_build (place, counter, ep, name, fmt, va_alist) || r == BFD_RELOC_MIPS_GOT_LO16 || r == BFD_RELOC_MIPS_CALL_LO16 || (ep->X_op == O_subtract - && now_seg == text_section && r == BFD_RELOC_PCREL_LO16)); continue; @@ -2556,7 +2610,6 @@ macro_build (place, counter, ep, name, fmt, va_alist) || r == BFD_RELOC_MIPS_GOT_HI16 || r == BFD_RELOC_MIPS_CALL_HI16)) || (ep->X_op == O_subtract - && now_seg == text_section && r == BFD_RELOC_PCREL_HI16_S))); if (ep->X_op == O_constant) { @@ -2960,9 +3013,9 @@ load_register (counter, reg, ep, dbl) || ! ep->X_unsigned || sizeof (ep->X_add_number) > 4 || (ep->X_add_number & 0x80000000) == 0)) - || ((mips_opts.isa < 3 || ! dbl) + || ((! ISA_HAS_64BIT_REGS (mips_opts.isa) || ! dbl) && (ep->X_add_number &~ (offsetT) 0xffffffff) == 0) - || (mips_opts.isa < 3 + || (! ISA_HAS_64BIT_REGS (mips_opts.isa) && ! dbl && ((ep->X_add_number &~ (offsetT) 0xffffffff) == ~ (offsetT) 0xffffffff))) @@ -2979,7 +3032,7 @@ load_register (counter, reg, ep, dbl) /* The value is larger than 32 bits. */ - if (mips_opts.isa < 3) + if (! ISA_HAS_64BIT_REGS (mips_opts.isa)) { as_bad (_("Number larger than 32 bits")); macro_build ((char *) NULL, counter, ep, "addiu", "t,r,j", reg, 0, @@ -3220,7 +3273,7 @@ load_address (counter, reg, ep) frag_grow (20); macro_build ((char *) NULL, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, GP, (int) BFD_RELOC_MIPS_GPREL); p = frag_var (rs_machine_dependent, 8, 0, @@ -3233,7 +3286,7 @@ load_address (counter, reg, ep) p += 4; macro_build (p, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, reg, (int) BFD_RELOC_LO16); } @@ -3253,7 +3306,7 @@ load_address (counter, reg, ep) frag_grow (20); macro_build ((char *) NULL, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", reg, (int) BFD_RELOC_MIPS_GOT16, GP); macro_build ((char *) NULL, counter, (expressionS *) NULL, "nop", ""); @@ -3262,7 +3315,7 @@ load_address (counter, reg, ep) ep->X_add_symbol, (offsetT) 0, (char *) NULL); macro_build (p, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, reg, (int) BFD_RELOC_LO16); if (ex.X_add_number != 0) @@ -3272,7 +3325,7 @@ load_address (counter, reg, ep) ex.X_op = O_constant; macro_build ((char *) NULL, counter, &ex, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, reg, (int) BFD_RELOC_LO16); } @@ -3303,12 +3356,12 @@ load_address (counter, reg, ep) (int) BFD_RELOC_MIPS_GOT_HI16); macro_build ((char *) NULL, counter, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", reg, reg, GP); macro_build ((char *) NULL, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", reg, (int) BFD_RELOC_MIPS_GOT_LO16, reg); p = frag_var (rs_machine_dependent, 12 + off, 0, @@ -3326,7 +3379,7 @@ load_address (counter, reg, ep) } macro_build (p, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", reg, (int) BFD_RELOC_MIPS_GOT16, GP); p += 4; @@ -3334,7 +3387,7 @@ load_address (counter, reg, ep) p += 4; macro_build (p, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, reg, (int) BFD_RELOC_LO16); if (ex.X_add_number != 0) @@ -3344,7 +3397,7 @@ load_address (counter, reg, ep) ex.X_op = O_constant; macro_build ((char *) NULL, counter, &ex, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, reg, (int) BFD_RELOC_LO16); } @@ -3356,7 +3409,7 @@ load_address (counter, reg, ep) */ macro_build ((char *) NULL, counter, ep, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", reg, GP, (int) BFD_RELOC_MIPS_GPREL); } @@ -3564,7 +3617,7 @@ macro (ip) case M_BGT_I: /* check for > max integer */ maxnum = 0x7fffffff; - if (mips_opts.isa >= 3 && sizeof (maxnum) > 4) + if (ISA_HAS_64BIT_REGS (mips_opts.isa) && sizeof (maxnum) > 4) { maxnum <<= 16; maxnum |= 0xffff; @@ -3573,7 +3626,7 @@ macro (ip) } if (imm_expr.X_op == O_constant && imm_expr.X_add_number >= maxnum - && (mips_opts.isa < 3 || sizeof (maxnum) > 4)) + && (! ISA_HAS_64BIT_REGS (mips_opts.isa) || sizeof (maxnum) > 4)) { do_false: /* result is always false */ @@ -3613,7 +3666,7 @@ macro (ip) return; } maxnum = 0x7fffffff; - if (mips_opts.isa >= 3 && sizeof (maxnum) > 4) + if (ISA_HAS_64BIT_REGS (mips_opts.isa) && sizeof (maxnum) > 4) { maxnum <<= 16; maxnum |= 0xffff; @@ -3623,7 +3676,7 @@ macro (ip) maxnum = - maxnum - 1; if (imm_expr.X_op == O_constant && imm_expr.X_add_number <= maxnum - && (mips_opts.isa < 3 || sizeof (maxnum) > 4)) + && (! ISA_HAS_64BIT_REGS (mips_opts.isa) || sizeof (maxnum) > 4)) { do_true: /* result is always true */ @@ -3660,7 +3713,7 @@ macro (ip) likely = 1; case M_BGTU_I: if (sreg == 0 - || (mips_opts.isa < 3 + || (! ISA_HAS_64BIT_REGS (mips_opts.isa) && imm_expr.X_op == O_constant && imm_expr.X_add_number == 0xffffffff)) goto do_false; @@ -3756,7 +3809,7 @@ macro (ip) likely = 1; case M_BLE_I: maxnum = 0x7fffffff; - if (mips_opts.isa >= 3 && sizeof (maxnum) > 4) + if (ISA_HAS_64BIT_REGS (mips_opts.isa) && sizeof (maxnum) > 4) { maxnum <<= 16; maxnum |= 0xffff; @@ -3765,7 +3818,7 @@ macro (ip) } if (imm_expr.X_op == O_constant && imm_expr.X_add_number >= maxnum - && (mips_opts.isa < 3 || sizeof (maxnum) > 4)) + && (! ISA_HAS_64BIT_REGS (mips_opts.isa) || sizeof (maxnum) > 4)) goto do_true; if (imm_expr.X_op != O_constant) as_bad (_("Unsupported large constant")); @@ -3818,7 +3871,7 @@ macro (ip) likely = 1; case M_BLEU_I: if (sreg == 0 - || (mips_opts.isa < 3 + || (! ISA_HAS_64BIT_REGS (mips_opts.isa) && imm_expr.X_op == O_constant && imm_expr.X_add_number == 0xffffffff)) goto do_true; @@ -4095,28 +4148,29 @@ macro (ip) /* When generating embedded PIC code, we permit expressions of the form la $4,foo-bar - where bar is an address in the .text section. These are used + where bar is an address in the current section. These are used when getting the addresses of functions. We don't permit X_add_number to be non-zero, because if the symbol is external the relaxing code needs to know that any addend is purely the offset to X_op_symbol. */ if (mips_pic == EMBEDDED_PIC && offset_expr.X_op == O_subtract - && now_seg == text_section - && (offset_expr.X_op_symbol->sy_value.X_op == O_constant - ? S_GET_SEGMENT (offset_expr.X_op_symbol) == text_section - : (offset_expr.X_op_symbol->sy_value.X_op == O_symbol - && (S_GET_SEGMENT (offset_expr.X_op_symbol - ->sy_value.X_add_symbol) - == text_section))) + && (symbol_constant_p (offset_expr.X_op_symbol) + ? S_GET_SEGMENT (offset_expr.X_op_symbol) == now_seg + : (symbol_equated_p (offset_expr.X_op_symbol) + && (S_GET_SEGMENT + (symbol_get_value_expression (offset_expr.X_op_symbol) + ->X_add_symbol) + == now_seg))) && breg == 0 - && offset_expr.X_add_number == 0) + && (offset_expr.X_add_number == 0 + || OUTPUT_FLAVOR == bfd_target_elf_flavour)) { macro_build ((char *) NULL, &icnt, &offset_expr, "lui", "t,u", treg, (int) BFD_RELOC_PCREL_HI16_S); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", treg, treg, (int) BFD_RELOC_PCREL_LO16); return; @@ -4159,7 +4213,7 @@ macro (ip) frag_grow (20); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, GP, (int) BFD_RELOC_MIPS_GPREL); p = frag_var (rs_machine_dependent, 8, 0, @@ -4173,7 +4227,7 @@ macro (ip) p += 4; macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); } @@ -4240,7 +4294,7 @@ macro (ip) } macro_build (p, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); /* FIXME: If breg == 0, and the next instruction uses @@ -4254,7 +4308,7 @@ macro (ip) "nop", ""); macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); (void) frag_var (rs_machine_dependent, 0, 0, @@ -4281,7 +4335,7 @@ macro (ip) "nop", ""); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", treg, AT, breg); breg = 0; @@ -4298,12 +4352,12 @@ macro (ip) macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", AT, AT, (int) BFD_RELOC_LO16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, AT); (void) frag_var (rs_machine_dependent, 0, 0, @@ -4364,7 +4418,7 @@ macro (ip) tempreg, (int) BFD_RELOC_MIPS_GOT_HI16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, GP); macro_build ((char *) NULL, &icnt, &offset_expr, @@ -4403,7 +4457,7 @@ macro (ip) "nop", ""); macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); @@ -4438,7 +4492,7 @@ macro (ip) "nop", ""); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", treg, AT, breg); dreg = treg; @@ -4454,12 +4508,12 @@ macro (ip) macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", AT, AT, (int) BFD_RELOC_LO16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", dreg, dreg, AT); @@ -4493,7 +4547,7 @@ macro (ip) p += 4; macro_build (p, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); /* FIXME: If add_number is 0, and there was no base @@ -4513,7 +4567,7 @@ macro (ip) p += 4; macro_build (p, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", treg, AT, breg); p += 4; @@ -4527,13 +4581,13 @@ macro (ip) p += 4; macro_build (p, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", AT, AT, (int) BFD_RELOC_LO16); p += 4; macro_build (p, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, AT); p += 4; @@ -4546,7 +4600,7 @@ macro (ip) */ macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, GP, (int) BFD_RELOC_MIPS_GPREL); } @@ -4556,7 +4610,7 @@ macro (ip) if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", treg, tempreg, breg); @@ -4600,7 +4654,7 @@ macro (ip) expr1.X_add_number = mips_cprestore_offset; macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", GP, (int) BFD_RELOC_LO16, mips_frame_reg); } @@ -4643,7 +4697,7 @@ macro (ip) { macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", PIC_CALL_REG, (int) BFD_RELOC_MIPS_CALL16, GP); @@ -4666,12 +4720,12 @@ macro (ip) PIC_CALL_REG, (int) BFD_RELOC_MIPS_CALL_HI16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", PIC_CALL_REG, PIC_CALL_REG, GP); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", PIC_CALL_REG, (int) BFD_RELOC_MIPS_CALL_LO16, PIC_CALL_REG); @@ -4689,7 +4743,7 @@ macro (ip) } macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", PIC_CALL_REG, (int) BFD_RELOC_MIPS_GOT16, GP); @@ -4699,7 +4753,7 @@ macro (ip) } macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", PIC_CALL_REG, PIC_CALL_REG, (int) BFD_RELOC_LO16); @@ -4715,7 +4769,7 @@ macro (ip) expr1.X_add_number = mips_cprestore_offset; macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", GP, (int) BFD_RELOC_LO16, mips_frame_reg); @@ -4972,7 +5026,7 @@ macro (ip) frag_grow (28); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, breg, GP); macro_build ((char *) NULL, &icnt, &offset_expr, s, fmt, @@ -4987,7 +5041,7 @@ macro (ip) p += 4; macro_build (p, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, breg); if (p != NULL) @@ -5022,7 +5076,7 @@ macro (ip) frag_grow (20); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", tempreg, (int) BFD_RELOC_MIPS_GOT16, GP); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", ""); @@ -5032,13 +5086,13 @@ macro (ip) (char *) NULL); macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, breg); macro_build ((char *) NULL, &icnt, &expr1, s, fmt, treg, @@ -5079,12 +5133,12 @@ macro (ip) tempreg, (int) BFD_RELOC_MIPS_GOT_HI16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, GP); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", tempreg, (int) BFD_RELOC_MIPS_GOT_LO16, tempreg); @@ -5098,7 +5152,7 @@ macro (ip) } macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", tempreg, (int) BFD_RELOC_MIPS_GOT16, GP); p += 4; @@ -5106,13 +5160,13 @@ macro (ip) p += 4; macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16); if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, tempreg, breg); macro_build ((char *) NULL, &icnt, &expr1, s, fmt, treg, @@ -5137,7 +5191,7 @@ macro (ip) { macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", tempreg, breg, GP); macro_build ((char *) NULL, &icnt, &offset_expr, s, fmt, @@ -5188,7 +5242,7 @@ macro (ip) or in offset_expr. */ if (imm_expr.X_op == O_constant || imm_expr.X_op == O_big) { - if (mips_opts.isa >= 3) + if (ISA_HAS_64BIT_REGS (mips_opts.isa)) load_register (&icnt, treg, &imm_expr, 1); else { @@ -5233,7 +5287,7 @@ macro (ip) { macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT16, GP); } @@ -5243,7 +5297,7 @@ macro (ip) a single instruction. */ macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", AT, GP, (int) BFD_RELOC_MIPS_GPREL); offset_expr.X_op = O_constant; @@ -5253,7 +5307,7 @@ macro (ip) abort (); /* Now we load the register(s). */ - if (mips_opts.isa >= 3) + if (ISA_HAS_64BIT_REGS (mips_opts.isa)) macro_build ((char *) NULL, &icnt, &offset_expr, "ld", "t,o(b)", treg, (int) BFD_RELOC_LO16, AT); else @@ -5284,8 +5338,8 @@ macro (ip) or in offset_expr. */ if (imm_expr.X_op == O_constant || imm_expr.X_op == O_big) { - load_register (&icnt, AT, &imm_expr, mips_opts.isa >= 3); - if (mips_opts.isa >= 3) + load_register (&icnt, AT, &imm_expr, ISA_HAS_64BIT_REGS (mips_opts.isa)); + if (ISA_HAS_64BIT_REGS (mips_opts.isa)) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "dmtc1", "t,S", AT, treg); else @@ -5311,7 +5365,7 @@ macro (ip) s = segment_name (S_GET_SEGMENT (offset_expr.X_add_symbol)); if (strcmp (s, ".lit8") == 0) { - if (mips_opts.isa >= 2) + if (mips_opts.isa != 1) { macro_build ((char *) NULL, &icnt, &offset_expr, "ldc1", "T,o(b)", treg, (int) BFD_RELOC_MIPS_LITERAL, GP); @@ -5327,7 +5381,7 @@ macro (ip) if (mips_pic == SVR4_PIC) macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT16, GP); else @@ -5336,7 +5390,7 @@ macro (ip) macro_build_lui ((char *) NULL, &icnt, &offset_expr, AT); } - if (mips_opts.isa >= 2) + if (mips_opts.isa != 1) { macro_build ((char *) NULL, &icnt, &offset_expr, "ldc1", "T,o(b)", treg, (int) BFD_RELOC_LO16, AT); @@ -5363,7 +5417,7 @@ macro (ip) to adjust when loading from memory. */ r = BFD_RELOC_LO16; dob: - assert (mips_opts.isa < 2); + assert (mips_opts.isa == 1); macro_build ((char *) NULL, &icnt, &offset_expr, "lwc1", "T,o(b)", target_big_endian ? treg + 1 : treg, (int) r, breg); @@ -5402,7 +5456,7 @@ macro (ip) } /* Itbl support may require additional care here. */ coproc = 1; - if (mips_opts.isa >= 2) + if (mips_opts.isa != 1) { s = "ldc1"; goto ld; @@ -5419,7 +5473,7 @@ macro (ip) return; } - if (mips_opts.isa >= 2) + if (mips_opts.isa != 1) { s = "sdc1"; goto st; @@ -5432,7 +5486,7 @@ macro (ip) goto ldd_std; case M_LD_AB: - if (mips_opts.isa >= 3) + if (ISA_HAS_64BIT_REGS (mips_opts.isa)) { s = "ld"; goto ld; @@ -5443,7 +5497,7 @@ macro (ip) goto ldd_std; case M_SD_AB: - if (mips_opts.isa >= 3) + if (ISA_HAS_64BIT_REGS (mips_opts.isa)) { s = "sd"; goto st; @@ -5506,7 +5560,7 @@ macro (ip) frag_grow (36); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, GP); tempreg = AT; @@ -5564,7 +5618,7 @@ macro (ip) { macro_build (p, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, AT); if (p != NULL) @@ -5613,14 +5667,14 @@ macro (ip) frag_grow (24 + off); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT16, GP); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", ""); if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, AT); /* Itbl support may require additional care here. */ @@ -5682,19 +5736,19 @@ macro (ip) AT, (int) BFD_RELOC_MIPS_GOT_HI16); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, AT, GP); macro_build ((char *) NULL, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT_LO16, AT); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", ""); if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, AT); /* Itbl support may require additional care here. */ @@ -5726,7 +5780,7 @@ macro (ip) } macro_build (p, &icnt, &offset_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "lw" : "ld"), "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT16, GP); p += 4; @@ -5736,7 +5790,7 @@ macro (ip) { macro_build (p, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, AT); p += 4; @@ -5777,7 +5831,7 @@ macro (ip) { macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, breg, GP); tempreg = AT; @@ -5808,7 +5862,8 @@ macro (ip) case M_SD_OB: s = "sw"; sd_ob: - assert (bfd_arch_bits_per_address (stdoutput) == 32 || mips_opts.isa < 3); + assert (bfd_arch_bits_per_address (stdoutput) == 32 + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)); macro_build ((char *) NULL, &icnt, &offset_expr, s, "t,o(b)", treg, (int) BFD_RELOC_LO16, breg); offset_expr.X_add_number += 4; @@ -6046,7 +6101,7 @@ macro2 (ip) as_bad (_("opcode not supported on this processor")); return; } - assert (mips_opts.isa < 2); + assert (mips_opts.isa == 1); /* Even on a big endian machine $fn comes before $fn+1. We have to adjust when storing to memory. */ macro_build ((char *) NULL, &icnt, &offset_expr, "swc1", "T,o(b)", @@ -6103,7 +6158,7 @@ macro2 (ip) imm_expr.X_add_number = -imm_expr.X_add_number; macro_build ((char *) NULL, &icnt, &imm_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", dreg, sreg, (int) BFD_RELOC_LO16); @@ -6256,7 +6311,7 @@ macro2 (ip) ip->insn_mo->name); macro_build ((char *) NULL, &icnt, &expr1, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", dreg, 0, (int) BFD_RELOC_LO16); return; @@ -6276,7 +6331,7 @@ macro2 (ip) imm_expr.X_add_number = -imm_expr.X_add_number; macro_build ((char *) NULL, &icnt, &imm_expr, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addiu" : "daddiu"), "t,r,j", dreg, sreg, (int) BFD_RELOC_LO16); used_at = 0; @@ -6355,7 +6410,7 @@ macro2 (ip) case M_TRUNCWD: case M_TRUNCWS: - assert (mips_opts.isa < 2); + assert (mips_opts.isa == 1); sreg = (ip->insn_opcode >> 11) & 0x1f; /* floating reg */ dreg = (ip->insn_opcode >> 06) & 0x1f; /* floating reg */ @@ -6445,7 +6500,7 @@ macro2 (ip) if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, AT, breg); if (! target_big_endian) @@ -6468,7 +6523,7 @@ macro2 (ip) if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, AT, breg); if (target_big_endian) @@ -6542,7 +6597,7 @@ macro2 (ip) if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, AT, breg); if (! target_big_endian) @@ -6564,7 +6619,7 @@ macro2 (ip) if (breg != 0) macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", AT, AT, breg); if (! target_big_endian) @@ -6956,13 +7011,13 @@ mips_ip (str, ip) /* If the instruction contains a '.', we first try to match an instruction including the '.'. Then we try again without the '.'. */ insn = NULL; - for (s = str; *s != '\0' && !isspace(*s); ++s) + for (s = str; *s != '\0' && !isspace ((unsigned char) *s); ++s) continue; /* If we stopped on whitespace, then replace the whitespace with null for the call to hash_find. Save the character we replaced just in case we have to re-parse the instruction. */ - if (isspace (*s)) + if (isspace ((unsigned char) *s)) { save_c = *s; *s++ = '\0'; @@ -6980,7 +7035,7 @@ mips_ip (str, ip) *(--s) = save_c; /* Scan up to the first '.' or whitespace. */ - for (s = str; *s != '\0' && *s != '.' && !isspace (*s); ++s) + for (s = str; *s != '\0' && *s != '.' && !isspace ((unsigned char) *s); ++s) continue; /* If we did not find a '.', then we can quit now. */ @@ -7004,37 +7059,15 @@ mips_ip (str, ip) argsStart = s; for (;;) { - int insn_isa; boolean ok; assert (strcmp (insn->name, str) == 0); - if ((insn->membership & INSN_ISA) == INSN_ISA1) - insn_isa = 1; - else if ((insn->membership & INSN_ISA) == INSN_ISA2) - insn_isa = 2; - else if ((insn->membership & INSN_ISA) == INSN_ISA3) - insn_isa = 3; - else if ((insn->membership & INSN_ISA) == INSN_ISA4) - insn_isa = 4; - else - insn_isa = 15; - - if (insn_isa <= mips_opts.isa) - ok = true; - else if (insn->pinfo == INSN_MACRO) - ok = false; - else if ((mips_cpu == 4650 && (insn->membership & INSN_4650) != 0) - || (mips_cpu == 4010 && (insn->membership & INSN_4010) != 0) - || ((mips_cpu == 4100 - || mips_cpu == 4111 - ) - && (insn->membership & INSN_4100) != 0) - || (mips_cpu == 3900 && (insn->membership & INSN_3900) != 0)) + if (OPCODE_IS_MEMBER (insn, mips_opts.isa, mips_cpu, mips_gp32)) ok = true; - else + else ok = false; - + if (insn->pinfo != INSN_MACRO) { if (mips_cpu == 4650 && (insn->pinfo & FP_D) != 0) @@ -7049,17 +7082,16 @@ mips_ip (str, ip) ++insn; continue; } - if (insn_isa == 15 - || insn_isa <= mips_opts.isa) - insn_error = _("opcode not supported on this processor"); else { static char buf[100]; - - sprintf (buf, _("opcode requires -mips%d or greater"), insn_isa); + sprintf (buf, + _("opcode not supported on this processor: %d (MIPS%d)"), + mips_cpu, mips_opts.isa); + insn_error = buf; + return; } - return; } ip->insn_mo = insn; @@ -7246,7 +7278,7 @@ mips_ip (str, ip) if (s[0] == '$') { - if (isdigit (s[1])) + if (isdigit ((unsigned char) s[1])) { ++s; regno = 0; @@ -7256,7 +7288,7 @@ mips_ip (str, ip) regno += *s - '0'; ++s; } - while (isdigit (*s)); + while (isdigit ((unsigned char) *s)); if (regno > 31) as_bad (_("Invalid register number (%d)"), regno); } @@ -7297,23 +7329,22 @@ mips_ip (str, ip) else if (itbl_have_entries) { char *p, *n; - int r; + unsigned long r; - p = s+1; /* advance past '$' */ + p = s + 1; /* advance past '$' */ n = itbl_get_field (&p); /* n is name */ - /* See if this is a register defined in an - itbl entry */ - r = itbl_get_reg_val (n); - if (r) + /* See if this is a register defined in an + itbl entry. */ + if (itbl_get_reg_val (n, &r)) { /* Get_field advances to the start of the next field, so we need to back - rack to the end of the last field. */ + rack to the end of the last field. */ if (p) s = p - 1; else - s = strchr (s,'\0'); + s = strchr (s, '\0'); regno = r; } else @@ -7406,7 +7437,7 @@ mips_ip (str, ip) case 'V': case 'W': s_reset = s; - if (s[0] == '$' && s[1] == 'f' && isdigit (s[2])) + if (s[0] == '$' && s[1] == 'f' && isdigit ((unsigned char) s[2])) { s += 2; regno = 0; @@ -7416,13 +7447,13 @@ mips_ip (str, ip) regno += *s - '0'; ++s; } - while (isdigit (*s)); + while (isdigit ((unsigned char) *s)); if (regno > 31) as_bad (_("Invalid float register number (%d)"), regno); if ((regno & 1) != 0 - && mips_opts.isa < 3 + && ! ISA_HAS_64BIT_REGS (mips_opts.isa) && ! (strcmp (str, "mtc1") == 0 || strcmp (str, "mfc1") == 0 || strcmp (str, "lwc1") == 0 @@ -7575,7 +7606,7 @@ mips_ip (str, ip) offset_expr to the low order 32 bits. Otherwise, set imm_expr to the entire 64 bit constant. */ - if (mips_opts.isa < 3) + if (! ISA_HAS_64BIT_REGS (mips_opts.isa)) { imm_expr.X_op = O_constant; offset_expr.X_op = O_constant; @@ -7633,11 +7664,15 @@ mips_ip (str, ip) default: /* unused default case avoids warnings. */ case 'L': newname = RDATA_SECTION_NAME; - if (USE_GLOBAL_POINTER_OPT && g_switch_value >= 8) + if ((USE_GLOBAL_POINTER_OPT && g_switch_value >= 8) + || mips_pic == EMBEDDED_PIC) newname = ".lit8"; break; case 'F': - newname = RDATA_SECTION_NAME; + if (mips_pic == EMBEDDED_PIC) + newname = ".lit8"; + else + newname = RDATA_SECTION_NAME; break; case 'l': assert (!USE_GLOBAL_POINTER_OPT @@ -7744,7 +7779,7 @@ mips_ip (str, ip) && imm_expr.X_op == O_constant) || (more && imm_expr.X_add_number < 0 - && mips_opts.isa >= 3 + && ISA_HAS_64BIT_REGS (mips_opts.isa) && imm_expr.X_unsigned && sizeof (imm_expr.X_add_number) <= 4)) { @@ -7780,9 +7815,8 @@ mips_ip (str, ip) || offset_expr.X_add_number < -0x8000) && (mips_pic != EMBEDDED_PIC || offset_expr.X_op != O_subtract - || now_seg != text_section || (S_GET_SEGMENT (offset_expr.X_op_symbol) - != text_section))) + != now_seg))) break; if (c == 'h' || c == 'H') @@ -7848,7 +7882,7 @@ mips_ip (str, ip) regno += *s - '0'; ++s; } - while (isdigit (*s)); + while (isdigit ((unsigned char) *s)); if (regno > 7) as_bad (_("invalid condition code register $fcc%d"), regno); if (*args == 'N') @@ -7901,7 +7935,7 @@ mips16_ip (str, ip) mips16_small = false; mips16_ext = false; - for (s = str; islower (*s); ++s) + for (s = str; islower ((unsigned char) *s); ++s) ; switch (*s) { @@ -8034,7 +8068,7 @@ mips16_ip (str, ip) if (s[0] != '$') break; s_reset = s; - if (isdigit (s[1])) + if (isdigit ((unsigned char) s[1])) { ++s; regno = 0; @@ -8044,7 +8078,7 @@ mips16_ip (str, ip) regno += *s - '0'; ++s; } - while (isdigit (*s)); + while (isdigit ((unsigned char) *s)); if (regno > 31) { as_bad (_("invalid register number (%d)"), regno); @@ -8315,7 +8349,7 @@ mips16_ip (str, ip) ++s; } reg1 = 0; - while (isdigit (*s)) + while (isdigit ((unsigned char) *s)) { reg1 *= 10; reg1 += *s - '0'; @@ -8342,7 +8376,7 @@ mips16_ip (str, ip) } } reg2 = 0; - while (isdigit (*s)) + while (isdigit ((unsigned char) *s)) { reg2 *= 10; reg2 += *s - '0'; @@ -8626,9 +8660,9 @@ my_getSmallExpression (ep, str) ; if (sp - 4 >= str && sp[-1] == RP) { - if (isdigit (sp[-2])) + if (isdigit ((unsigned char) sp[-2])) { - for (sp -= 3; sp >= str && isdigit (*sp); sp--) + for (sp -= 3; sp >= str && isdigit ((unsigned char) *sp); sp--) ; if (*sp == '$' && sp > str && sp[-1] == LP) { @@ -8699,10 +8733,10 @@ my_getExpression (ep, str) && ep->X_op == O_symbol && strcmp (S_GET_NAME (ep->X_add_symbol), FAKE_LABEL_NAME) == 0 && S_GET_SEGMENT (ep->X_add_symbol) == now_seg - && ep->X_add_symbol->sy_frag == frag_now - && ep->X_add_symbol->sy_value.X_op == O_constant - && ep->X_add_symbol->sy_value.X_add_number == frag_now_fix ()) - ++ep->X_add_symbol->sy_value.X_add_number; + && symbol_get_frag (ep->X_add_symbol) == frag_now + && symbol_constant_p (ep->X_add_symbol) + && S_GET_VALUE (ep->X_add_symbol) == frag_now_fix ()) + S_SET_VALUE (ep->X_add_symbol, S_GET_VALUE (ep->X_add_symbol) + 1); } /* Turn a string in input_line_pointer into a floating point constant @@ -8825,6 +8859,11 @@ struct option md_longopts[] = { #define OPTION_MABI (OPTION_MD_BASE + 38) {"mabi", required_argument, NULL, OPTION_MABI}, +#define OPTION_M7000_HILO_FIX (OPTION_MD_BASE + 39) + {"mfix7000", no_argument, NULL, OPTION_M7000_HILO_FIX}, +#define OPTION_NO_M7000_HILO_FIX (OPTION_MD_BASE + 40) + {"no-fix-7000", no_argument, NULL, OPTION_NO_M7000_HILO_FIX}, + #define OPTION_CALL_SHARED (OPTION_MD_BASE + 7) #define OPTION_NON_SHARED (OPTION_MD_BASE + 8) #define OPTION_XGOT (OPTION_MD_BASE + 19) @@ -8839,6 +8878,11 @@ struct option md_longopts[] = { {"64", no_argument, NULL, OPTION_64}, #endif +#define OPTION_GP32 (OPTION_MD_BASE + 41) +#define OPTION_GP64 (OPTION_MD_BASE + 42) + {"mgp32", no_argument, NULL, OPTION_GP32}, + {"mgp64", no_argument, NULL, OPTION_GP64}, + {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof(md_longopts); @@ -9139,6 +9183,27 @@ md_parse_option (c, arg) } break; + case OPTION_GP32: + mips_gp32 = 1; + mips_64 = 0; + + /* We deliberately don't allow "-gp32" to set the MIPS_32BITMODE + flag in object files because to do so would make it + impossible to link with libraries compiled without "-gp32". + This is unnecessarily restrictive. + + We could solve this problem by adding "-gp32" multilibs to + gcc, but to set this flag before gcc is built with such + multilibs will break too many systems. */ + +/* mips_32bitmode = 1; */ + break; + + case OPTION_GP64: + mips_gp32 = 0; + mips_64 = 1; +/* mips_32bitmode = 0; */ + break; case OPTION_MABI: if (strcmp (arg,"32") == 0 @@ -9149,6 +9214,14 @@ md_parse_option (c, arg) mips_abi_string = arg; break; + case OPTION_M7000_HILO_FIX: + mips_7000_hilo_fix = true; + break; + + case OPTION_NO_M7000_HILO_FIX: + mips_7000_hilo_fix = false; + break; + default: return 0; } @@ -9423,6 +9496,7 @@ mips_frob_file () fixup requires the special reloc. */ #define SWITCH_TABLE(fixp) \ ((fixp)->fx_r_type == BFD_RELOC_32 \ + && OUTPUT_FLAVOR != bfd_target_elf_flavour \ && (fixp)->fx_addsy != NULL \ && (fixp)->fx_subsy != NULL \ && S_GET_SEGMENT ((fixp)->fx_addsy) == text_section \ @@ -9470,15 +9544,16 @@ md_apply_fix (fixP, valueP) symbol, we need to adjust the value. */ #ifdef OBJ_ELF if (fixP->fx_addsy != NULL && OUTPUT_FLAVOR == bfd_target_elf_flavour) + { if (S_GET_OTHER (fixP->fx_addsy) == STO_MIPS16 || S_IS_WEAK (fixP->fx_addsy) - || (fixP->fx_addsy->sy_used_in_reloc - && (bfd_get_section_flags (stdoutput, - S_GET_SEGMENT (fixP->fx_addsy)) - & SEC_LINK_ONCE != 0) - || !strncmp (segment_name (S_GET_SEGMENT (fixP->fx_addsy)), - ".gnu.linkonce", - sizeof (".gnu.linkonce") - 1))) + || (symbol_used_in_reloc_p (fixP->fx_addsy) + && (((bfd_get_section_flags (stdoutput, + S_GET_SEGMENT (fixP->fx_addsy)) + & SEC_LINK_ONCE) != 0) + || !strncmp (segment_name (S_GET_SEGMENT (fixP->fx_addsy)), + ".gnu.linkonce", + sizeof (".gnu.linkonce") - 1)))) { value -= S_GET_VALUE (fixP->fx_addsy); @@ -9486,12 +9561,29 @@ md_apply_fix (fixP, valueP) { /* In this case, the bfd_install_relocation routine will incorrectly add the symbol value back in. We just want - the addend to appear in the object file. */ + the addend to appear in the object file. + FIXME: If this makes VALUE zero, we're toast. */ value -= S_GET_VALUE (fixP->fx_addsy); } } -#endif + /* This code was generated using trial and error and so is + fragile and not trustworthy. If you change it, you should + rerun the elf-rel, elf-rel2, and empic testcases and ensure + they still pass. */ + if (fixP->fx_pcrel || fixP->fx_subsy != NULL) + { + value += fixP->fx_frag->fr_address + fixP->fx_where; + + /* BFD's REL handling, for MIPS, is _very_ weird. + This gives the right results, but it can't possibly + be the way things are supposed to work. */ + if (fixP->fx_r_type != BFD_RELOC_16_PCREL_S2 + || S_GET_SEGMENT (fixP->fx_addsy) != undefined_section) + value += fixP->fx_frag->fr_address + fixP->fx_where; + } + } +#endif fixP->fx_addnumber = value; /* Remember value for tc_gen_reloc */ @@ -9529,7 +9621,12 @@ md_apply_fix (fixP, valueP) case BFD_RELOC_PCREL_HI16_S: /* The addend for this is tricky if it is internal, so we just do everything here rather than in bfd_install_relocation. */ - if ((fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0) + if (OUTPUT_FLAVOR == bfd_target_elf_flavour + && !fixP->fx_done + && value != 0) + break; + if (fixP->fx_addsy + && (symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_SECTION_SYM) == 0) { /* For an external symbol adjust by the address to make it pcrel_offset. We use the address of the RELLO reloc @@ -9549,7 +9646,12 @@ md_apply_fix (fixP, valueP) case BFD_RELOC_PCREL_LO16: /* The addend for this is tricky if it is internal, so we just do everything here rather than in bfd_install_relocation. */ - if ((fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0) + if (OUTPUT_FLAVOR == bfd_target_elf_flavour + && !fixP->fx_done + && value != 0) + break; + if (fixP->fx_addsy + && (symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_SECTION_SYM) == 0) value += fixP->fx_frag->fr_address + fixP->fx_where; buf = (unsigned char *) fixP->fx_frag->fr_literal + fixP->fx_where; if (target_big_endian) @@ -9586,6 +9688,7 @@ md_apply_fix (fixP, valueP) } break; + case BFD_RELOC_RVA: case BFD_RELOC_32: /* If we are deleting this reloc entry, we must fill in the value now. This can happen if we have a .word which is not @@ -9631,6 +9734,15 @@ md_apply_fix (fixP, valueP) if ((value & 0x3) != 0) as_bad_where (fixP->fx_file, fixP->fx_line, _("Branch to odd address (%lx)"), value); + + if (!fixP->fx_done && value != 0) + break; + /* If 'value' is zero, the remaining reloc code won't actually + do the store, so it must be done here. This is probably + a bug somewhere. */ + if (!fixP->fx_done) + value -= fixP->fx_frag->fr_address + fixP->fx_where; + value >>= 2; /* update old instruction data */ @@ -9818,7 +9930,7 @@ mips_align (to, fill, label) if (label != NULL) { assert (S_GET_SEGMENT (label) == now_seg); - label->sy_frag = frag_now; + symbol_set_frag (label, frag_now); S_SET_VALUE (label, (valueT) frag_now_fix ()); } } @@ -10002,10 +10114,12 @@ s_float_cons (type) mips_emit_delays (false); if (auto_align) - if (type == 'd') - mips_align (3, 0, label); - else - mips_align (2, 0, label); + { + if (type == 'd') + mips_align (3, 0, label); + else + mips_align (2, 0, label); + } mips_clear_insn_labels (); @@ -10053,7 +10167,7 @@ s_mips_globl (x) flag = BSF_FUNCTION; } - symbolP->bsym->flags |= flag; + symbol_get_bfdsym (symbolP)->flags |= flag; S_SET_EXTERNAL (symbolP); demand_empty_rest_of_line (); @@ -10297,7 +10411,7 @@ s_cpload (ignore) ex.X_add_number = 0; /* In ELF, this symbol is implicitly an STT_OBJECT symbol. */ - ex.X_add_symbol->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (ex.X_add_symbol)->flags |= BSF_OBJECT; macro_build_lui ((char *) NULL, &icnt, &ex, GP); macro_build ((char *) NULL, &icnt, &ex, "addiu", "t,r,j", GP, GP, @@ -10336,7 +10450,7 @@ s_cprestore (ignore) macro_build ((char *) NULL, &icnt, &ex, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "sw" : "sd"), "t,o(b)", GP, (int) BFD_RELOC_LO16, SP); @@ -10404,7 +10518,7 @@ s_cpadd (ignore) reg = tc_get_register (0); macro_build ((char *) NULL, &icnt, (expressionS *) NULL, ((bfd_arch_bits_per_address (stdoutput) == 32 - || mips_opts.isa < 3) + || ! ISA_HAS_64BIT_REGS (mips_opts.isa)) ? "addu" : "daddu"), "d,v,t", reg, reg, GP); @@ -10489,7 +10603,7 @@ s_mips_weakext (ignore) ignore_rest_of_line(); return; } - symbolP->sy_value = exp; + symbol_set_value_expression (symbolP, &exp); } demand_empty_rest_of_line (); @@ -10601,15 +10715,16 @@ nopic_need_relax (sym, before_relaxing) else if ((! S_IS_DEFINED (sym) || S_IS_COMMON (sym)) && (0 #ifndef NO_ECOFF_DEBUGGING - || (sym->ecoff_extern_size != 0 - && sym->ecoff_extern_size <= g_switch_value) + || (symbol_get_obj (sym)->ecoff_extern_size != 0 + && (symbol_get_obj (sym)->ecoff_extern_size + <= g_switch_value)) #endif /* We must defer this decision until after the whole file has been read, since there might be a .extern after the first use of this symbol. */ || (before_relaxing #ifndef NO_ECOFF_DEBUGGING - && sym->ecoff_extern_size == 0 + && symbol_get_obj (sym)->ecoff_extern_size == 0 #endif && S_GET_VALUE (sym) == 0) || (S_GET_VALUE (sym) != 0 @@ -10623,7 +10738,9 @@ nopic_need_relax (sym, before_relaxing) assert (strcmp (segname, ".lit8") != 0 && strcmp (segname, ".lit4") != 0); change = (strcmp (segname, ".sdata") != 0 - && strcmp (segname, ".sbss") != 0); + && strcmp (segname, ".sbss") != 0 + && strncmp (segname, ".sdata.", 7) != 0 + && strncmp (segname, ".gnu.linkonce.s.", 16) != 0); } return change; } @@ -10679,23 +10796,26 @@ mips16_extended_frag (fragp, sec, stretch) maxtiny = (1 << (op->nbits - 1)) - 1; } - /* We can't call S_GET_VALUE here, because we don't want to lock in - a particular frag address. */ - if (fragp->fr_symbol->sy_value.X_op == O_constant) + /* We can't always call S_GET_VALUE here, because we don't want to + lock in a particular frag address. */ + if (symbol_constant_p (fragp->fr_symbol)) { - val = (fragp->fr_symbol->sy_value.X_add_number - + fragp->fr_symbol->sy_frag->fr_address); + val = (S_GET_VALUE (fragp->fr_symbol) + + symbol_get_frag (fragp->fr_symbol)->fr_address); symsec = S_GET_SEGMENT (fragp->fr_symbol); } - else if (fragp->fr_symbol->sy_value.X_op == O_symbol - && (fragp->fr_symbol->sy_value.X_add_symbol->sy_value.X_op - == O_constant)) + else if (symbol_equated_p (fragp->fr_symbol) + && (symbol_constant_p + (symbol_get_value_expression (fragp->fr_symbol)->X_add_symbol))) { - val = (fragp->fr_symbol->sy_value.X_add_symbol->sy_value.X_add_number - + fragp->fr_symbol->sy_value.X_add_symbol->sy_frag->fr_address - + fragp->fr_symbol->sy_value.X_add_number - + fragp->fr_symbol->sy_frag->fr_address); - symsec = S_GET_SEGMENT (fragp->fr_symbol->sy_value.X_add_symbol); + symbolS *eqsym; + + eqsym = symbol_get_value_expression (fragp->fr_symbol)->X_add_symbol; + val = (S_GET_VALUE (eqsym) + + symbol_get_frag (eqsym)->fr_address + + symbol_get_value_expression (fragp->fr_symbol)->X_add_number + + symbol_get_frag (fragp->fr_symbol)->fr_address); + symsec = S_GET_SEGMENT (eqsym); } else return 1; @@ -10737,7 +10857,8 @@ mips16_extended_frag (fragp, sec, stretch) in STRETCH in order to get a better estimate of the address. This particularly matters because of the shift bits. */ if (stretch != 0 - && fragp->fr_symbol->sy_frag->fr_address >= fragp->fr_address) + && (symbol_get_frag (fragp->fr_symbol)->fr_address + >= fragp->fr_address)) { fragS *f; @@ -10748,7 +10869,7 @@ mips16_extended_frag (fragp, sec, stretch) a maximum number of bytes to skip when doing an alignment. */ for (f = fragp; - f != NULL && f != fragp->fr_symbol->sy_frag; + f != NULL && f != symbol_get_frag (fragp->fr_symbol); f = f->fr_next) { if (f->fr_type == rs_align || f->fr_type == rs_align_code) @@ -10882,14 +11003,14 @@ md_estimate_size_before_relax (fragp, segtype) sym = fragp->fr_symbol; /* Handle the case of a symbol equated to another symbol. */ - while (sym->sy_value.X_op == O_symbol + while (symbol_equated_p (sym) && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym))) { symbolS *n; /* It's possible to get a loop here in a badly written program. */ - n = sym->sy_value.X_add_symbol; + n = symbol_get_value_expression (sym)->X_add_symbol; if (n == sym) break; sym = n; @@ -10967,7 +11088,8 @@ tc_gen_reloc (section, fixp) reloc = retval[0] = (arelent *) xmalloc (sizeof (arelent)); retval[1] = NULL; - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; if (mips_pic == EMBEDDED_PIC @@ -10981,10 +11103,12 @@ tc_gen_reloc (section, fixp) as_fatal (_("Double check fx_r_type in tc-mips.c:tc_gen_reloc")); fixp->fx_r_type = BFD_RELOC_GPREL32; } + else if (fixp->fx_pcrel == 0 || OUTPUT_FLAVOR == bfd_target_elf_flavour) + reloc->addend = fixp->fx_addnumber; else if (fixp->fx_r_type == BFD_RELOC_PCREL_LO16) { /* We use a special addend for an internal RELLO reloc. */ - if (fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM) + if (symbol_section_p (fixp->fx_addsy)) reloc->addend = reloc->address - S_GET_VALUE (fixp->fx_subsy); else reloc->addend = fixp->fx_addnumber + reloc->address; @@ -10996,7 +11120,7 @@ tc_gen_reloc (section, fixp) /* We use a special addend for an internal RELHI reloc. The reloc is relative to the RELLO; adjust the addend accordingly. */ - if (fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM) + if (symbol_section_p (fixp->fx_addsy)) reloc->addend = (fixp->fx_next->fx_frag->fr_address + fixp->fx_next->fx_where - S_GET_VALUE (fixp->fx_subsy)); @@ -11005,8 +11129,6 @@ tc_gen_reloc (section, fixp) + fixp->fx_next->fx_frag->fr_address + fixp->fx_next->fx_where); } - else if (fixp->fx_pcrel == 0) - reloc->addend = fixp->fx_addnumber; else { if (OUTPUT_FLAVOR != bfd_target_aout_flavour) @@ -11055,7 +11177,8 @@ tc_gen_reloc (section, fixp) reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc2 = retval[1] = (arelent *) xmalloc (sizeof (arelent)); retval[2] = NULL; - reloc2->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc2->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc2->address = (reloc->address + (RELAX_RELOC2 (fixp->fx_frag->fr_subtype) - RELAX_RELOC1 (fixp->fx_frag->fr_subtype))); @@ -11144,7 +11267,8 @@ tc_gen_reloc (section, fixp) /* To support a PC relative reloc when generating embedded PIC code for ECOFF, we use a Cygnus extension. We check for that here to make sure that we don't let such a reloc escape normally. */ - if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour + if ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour + || OUTPUT_FLAVOR == bfd_target_elf_flavour) && code == BFD_RELOC_16_PCREL_S2 && mips_pic != EMBEDDED_PIC) reloc->howto = NULL; @@ -11433,7 +11557,7 @@ mips_elf_final_processing () typedef struct proc { - struct symbol *isym; + symbolS *isym; unsigned long reg_mask; unsigned long reg_offset; unsigned long fpreg_mask; @@ -11448,6 +11572,36 @@ static procS cur_proc; static procS *cur_proc_ptr; static int numprocs; +/* When we align code in the .text section of mips16, use the correct two + byte nop pattern of 0x6500 (move $0,$0) */ + +int +mips_do_align (n, fill, len, max) + int n; + const char *fill; + int len; + int max; +{ + if (fill == NULL + && subseg_text_p (now_seg) + && n > 1 + && mips_opts.mips16) + { + static const unsigned char be_nop[] = { 0x65, 0x00 }; + static const unsigned char le_nop[] = { 0x00, 0x65 }; + + frag_align (1, 0, 0); + + if (target_big_endian) + frag_align_pattern (n, be_nop, 2, max); + else + frag_align_pattern (n, le_nop, 2, max); + return 1; + } + + return 0; +} + static void md_obj_begin () { @@ -11472,14 +11626,14 @@ get_number () ++input_line_pointer; negative = 1; } - if (!isdigit (*input_line_pointer)) + if (!isdigit ((unsigned char) *input_line_pointer)) as_bad (_("Expected simple number.")); if (input_line_pointer[0] == '0') { if (input_line_pointer[1] == 'x') { input_line_pointer += 2; - while (isxdigit (*input_line_pointer)) + while (isxdigit ((unsigned char) *input_line_pointer)) { val <<= 4; val |= hex_value (*input_line_pointer++); @@ -11489,7 +11643,7 @@ get_number () else { ++input_line_pointer; - while (isdigit (*input_line_pointer)) + while (isdigit ((unsigned char) *input_line_pointer)) { val <<= 3; val |= *input_line_pointer++ - '0'; @@ -11497,14 +11651,14 @@ get_number () return negative ? -val : val; } } - if (!isdigit (*input_line_pointer)) + if (!isdigit ((unsigned char) *input_line_pointer)) { printf (_(" *input_line_pointer == '%c' 0x%02x\n"), *input_line_pointer, *input_line_pointer); as_warn (_("Invalid number")); return -1; } - while (isdigit (*input_line_pointer)) + while (isdigit ((unsigned char) *input_line_pointer)) { val *= 10; val += *input_line_pointer++ - '0'; @@ -11630,7 +11784,8 @@ s_mips_ent (aent) if (*input_line_pointer == ',') input_line_pointer++; SKIP_WHITESPACE (); - if (isdigit (*input_line_pointer) || *input_line_pointer == '-') + if (isdigit ((unsigned char) *input_line_pointer) + || *input_line_pointer == '-') number = get_number (); #ifdef BFD_ASSEMBLER @@ -11658,7 +11813,7 @@ s_mips_ent (aent) cur_proc_ptr->isym = symbolP; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; numprocs++; } @@ -11778,6 +11933,3 @@ s_loc (x) symbolP->sy_segment = now_seg; } #endif - - - diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h index 868aede..1008b75 100644 --- a/gas/config/tc-mips.h +++ b/gas/config/tc-mips.h @@ -1,5 +1,5 @@ /* tc-mips.h -- header file for tc-mips.c. - Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 1999, 2000 Free Software Foundation, Inc. Contributed by the OSF and Ralph Campbell. Written by Keith Knowles and Ralph Campbell, working independently. Modified for ECOFF support by Ian Lance Taylor of Cygnus Support. @@ -55,6 +55,9 @@ extern int mips_relax_frag PARAMS ((struct frag *, long)); #define md_undefined_symbol(name) (0) #define md_operand(x) +extern int mips_do_align PARAMS ((int, const char *, int, int)); +#define md_do_align(n,fill,len,max,l) if (mips_do_align (n,fill,len,max)) goto l + /* We permit PC relative difference expressions when generating embedded PIC code. */ #define DIFF_EXPR_OK @@ -85,7 +88,7 @@ extern void mips_init_after_args PARAMS ((void)); extern int mips_parse_long_option PARAMS ((const char *)); #define tc_frob_label(sym) mips_define_label (sym) -extern void mips_define_label PARAMS ((struct symbol *)); +extern void mips_define_label PARAMS ((symbolS *)); #define tc_frob_file_before_adjust() mips_frob_file_before_adjust () extern void mips_frob_file_before_adjust PARAMS ((void)); @@ -139,6 +142,7 @@ extern void md_mips_end PARAMS ((void)); #define md_end() md_mips_end() #define USE_GLOBAL_POINTER_OPT (OUTPUT_FLAVOR == bfd_target_ecoff_flavour \ + || OUTPUT_FLAVOR == bfd_target_coff_flavour \ || OUTPUT_FLAVOR == bfd_target_elf_flavour) extern void mips_pop_insert PARAMS ((void)); diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c index 2380915..264f7bf 100644 --- a/gas/config/tc-mn10200.c +++ b/gas/config/tc-mn10200.c @@ -1,6 +1,5 @@ /* tc-mn10200.c -- Assembler code for the Matsushita 10200 - - Copyright (C) 1996, 1997, 1998 Free Software Foundation. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -1252,7 +1251,8 @@ tc_gen_reloc (seg, fixp) } else { - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->addend = fixp->fx_offset; } return reloc; diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index 3f9e9ce..e0076f4 100644 --- a/gas/config/tc-mn10300.c +++ b/gas/config/tc-mn10300.c @@ -1,6 +1,5 @@ /* tc-mn10300.c -- Assembler code for the Matsushita 10300 - - Copyright (C) 1996, 1997, 1998 Free Software Foundation. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -120,6 +119,7 @@ size_t md_longopts_size = sizeof(md_longopts); const pseudo_typeS md_pseudo_table[] = { { "am30", set_arch_mach, 300 }, + { "am33", set_arch_mach, 330 }, { "mn10300", set_arch_mach, 300 }, {NULL, 0, 0} }; @@ -146,6 +146,77 @@ static const struct reg_name address_registers[] = }; #define ADDRESS_REG_NAME_CNT (sizeof(address_registers) / sizeof(struct reg_name)) +static const struct reg_name r_registers[] = +{ + { "a0", 8 }, + { "a1", 9 }, + { "a2", 10 }, + { "a3", 11 }, + { "d0", 12 }, + { "d1", 13 }, + { "d2", 14 }, + { "d3", 15 }, + { "e0", 0 }, + { "e1", 1 }, + { "e10", 10 }, + { "e11", 11 }, + { "e12", 12 }, + { "e13", 13 }, + { "e14", 14 }, + { "e15", 15 }, + { "e2", 2 }, + { "e3", 3 }, + { "e4", 4 }, + { "e5", 5 }, + { "e6", 6 }, + { "e7", 7 }, + { "e8", 8 }, + { "e9", 9 }, + { "r0", 0 }, + { "r1", 1 }, + { "r10", 10 }, + { "r11", 11 }, + { "r12", 12 }, + { "r13", 13 }, + { "r14", 14 }, + { "r15", 15 }, + { "r2", 2 }, + { "r3", 3 }, + { "r4", 4 }, + { "r5", 5 }, + { "r6", 6 }, + { "r7", 7 }, + { "r8", 8 }, + { "r9", 9 }, +}; +#define R_REG_NAME_CNT (sizeof(r_registers) / sizeof(struct reg_name)) + +static const struct reg_name xr_registers[] = +{ + { "mcrh", 2 }, + { "mcrl", 3 }, + { "mcvf", 4 }, + { "mdrq", 1 }, + { "sp", 0 }, + { "xr0", 0 }, + { "xr1", 1 }, + { "xr10", 10 }, + { "xr11", 11 }, + { "xr12", 12 }, + { "xr13", 13 }, + { "xr14", 14 }, + { "xr15", 15 }, + { "xr2", 2 }, + { "xr3", 3 }, + { "xr4", 4 }, + { "xr5", 5 }, + { "xr6", 6 }, + { "xr7", 7 }, + { "xr8", 8 }, + { "xr9", 9 }, +}; +#define XR_REG_NAME_CNT (sizeof(xr_registers) / sizeof(struct reg_name)) + static const struct reg_name other_registers[] = { @@ -187,6 +258,97 @@ reg_name_search (regs, regcount, name) } +/* Summary of register_name(). + * + * in: Input_line_pointer points to 1st char of operand. + * + * out: A expressionS. + * The operand may have been a register: in this case, X_op == O_register, + * X_add_number is set to the register number, and truth is returned. + * Input_line_pointer->(next non-blank) char after operand, or is in + * its original state. + */ +static boolean +r_register_name (expressionP) + expressionS *expressionP; +{ + int reg_number; + char *name; + char *start; + char c; + + /* Find the spelling of the operand */ + start = name = input_line_pointer; + + c = get_symbol_end (); + reg_number = reg_name_search (r_registers, R_REG_NAME_CNT, name); + + /* look to see if it's in the register table */ + if (reg_number >= 0) + { + expressionP->X_op = O_register; + expressionP->X_add_number = reg_number; + + /* make the rest nice */ + expressionP->X_add_symbol = NULL; + expressionP->X_op_symbol = NULL; + *input_line_pointer = c; /* put back the delimiting char */ + return true; + } + else + { + /* reset the line as if we had not done anything */ + *input_line_pointer = c; /* put back the delimiting char */ + input_line_pointer = start; /* reset input_line pointer */ + return false; + } +} + +/* Summary of register_name(). + * + * in: Input_line_pointer points to 1st char of operand. + * + * out: A expressionS. + * The operand may have been a register: in this case, X_op == O_register, + * X_add_number is set to the register number, and truth is returned. + * Input_line_pointer->(next non-blank) char after operand, or is in + * its original state. + */ +static boolean +xr_register_name (expressionP) + expressionS *expressionP; +{ + int reg_number; + char *name; + char *start; + char c; + + /* Find the spelling of the operand */ + start = name = input_line_pointer; + + c = get_symbol_end (); + reg_number = reg_name_search (xr_registers, XR_REG_NAME_CNT, name); + + /* look to see if it's in the register table */ + if (reg_number >= 0) + { + expressionP->X_op = O_register; + expressionP->X_add_number = reg_number; + + /* make the rest nice */ + expressionP->X_add_symbol = NULL; + expressionP->X_op_symbol = NULL; + *input_line_pointer = c; /* put back the delimiting char */ + return true; + } + else + { + /* reset the line as if we had not done anything */ + *input_line_pointer = c; /* put back the delimiting char */ + input_line_pointer = start; /* reset input_line pointer */ + return false; + } +} /* Summary of register_name(). * @@ -855,6 +1017,110 @@ md_assemble (str) *input_line_pointer = c; goto keep_going; } + else if (operand->flags & MN10300_OPERAND_RREG) + { + if (!r_register_name (&ex)) + { + input_line_pointer = hold; + str = hold; + goto error; + } + } + else if (operand->flags & MN10300_OPERAND_XRREG) + { + if (!xr_register_name (&ex)) + { + input_line_pointer = hold; + str = hold; + goto error; + } + } + else if (operand->flags & MN10300_OPERAND_USP) + { + char *start = input_line_pointer; + char c = get_symbol_end (); + + if (strcasecmp (start, "usp") != 0) + { + *input_line_pointer = c; + input_line_pointer = hold; + str = hold; + goto error; + } + *input_line_pointer = c; + goto keep_going; + } + else if (operand->flags & MN10300_OPERAND_SSP) + { + char *start = input_line_pointer; + char c = get_symbol_end (); + + if (strcasecmp (start, "ssp") != 0) + { + *input_line_pointer = c; + input_line_pointer = hold; + str = hold; + goto error; + } + *input_line_pointer = c; + goto keep_going; + } + else if (operand->flags & MN10300_OPERAND_MSP) + { + char *start = input_line_pointer; + char c = get_symbol_end (); + + if (strcasecmp (start, "msp") != 0) + { + *input_line_pointer = c; + input_line_pointer = hold; + str = hold; + goto error; + } + *input_line_pointer = c; + goto keep_going; + } + else if (operand->flags & MN10300_OPERAND_PC) + { + char *start = input_line_pointer; + char c = get_symbol_end (); + + if (strcasecmp (start, "pc") != 0) + { + *input_line_pointer = c; + input_line_pointer = hold; + str = hold; + goto error; + } + *input_line_pointer = c; + goto keep_going; + } + else if (operand->flags & MN10300_OPERAND_EPSW) + { + char *start = input_line_pointer; + char c = get_symbol_end (); + + if (strcasecmp (start, "epsw") != 0) + { + *input_line_pointer = c; + input_line_pointer = hold; + str = hold; + goto error; + } + *input_line_pointer = c; + goto keep_going; + } + else if (operand->flags & MN10300_OPERAND_PLUS) + { + if (*input_line_pointer != '+') + { + input_line_pointer = hold; + str = hold; + goto error; + } + input_line_pointer++; + goto keep_going; + } else if (operand->flags & MN10300_OPERAND_PSW) { char *start = input_line_pointer; @@ -941,6 +1207,30 @@ md_assemble (str) value |= 0x08; *input_line_pointer = c; } + else if (current_machine == 330 + && strcasecmp (start, "exreg0") == 0) + { + value |= 0x04; + *input_line_pointer = c; + } + else if (current_machine == 330 + && strcasecmp (start, "exreg1") == 0) + { + value |= 0x02; + *input_line_pointer = c; + } + else if (current_machine == 330 + && strcasecmp (start, "exother") == 0) + { + value |= 0x01; + *input_line_pointer = c; + } + else if (current_machine == 330 + && strcasecmp (start, "all") == 0) + { + value |= 0xff; + *input_line_pointer = c; + } else { input_line_pointer = hold; @@ -972,6 +1262,18 @@ md_assemble (str) str = hold; goto error; } + else if (r_register_name (&ex)) + { + input_line_pointer = hold; + str = hold; + goto error; + } + else if (xr_register_name (&ex)) + { + input_line_pointer = hold; + str = hold; + goto error; + } else if (*str == ')' || *str == '(') { input_line_pointer = hold; @@ -996,6 +1298,7 @@ md_assemble (str) int mask; mask = MN10300_OPERAND_DREG | MN10300_OPERAND_AREG; + mask |= MN10300_OPERAND_RREG | MN10300_OPERAND_XRREG; if ((operand->flags & mask) == 0) { input_line_pointer = hold; @@ -1012,6 +1315,10 @@ md_assemble (str) || opcode->format == FMT_S6 || opcode->format == FMT_D5) extra_shift = 16; + else if (opcode->format == FMT_D7) + extra_shift = 8; + else if (opcode->format == FMT_D8 || opcode->format == FMT_D9) + extra_shift = 8; else extra_shift = 0; @@ -1139,6 +1446,17 @@ keep_going: if (opcode->format == FMT_S2 || opcode->format == FMT_D1) size = 3; + if (opcode->format == FMT_D6) + size = 3; + + if (opcode->format == FMT_D7 || opcode->format == FMT_D10) + size = 4; + + if (opcode->format == FMT_D8) + size = 6; + + if (opcode->format == FMT_D9) + size = 7; if (opcode->format == FMT_S4) size = 5; @@ -1223,6 +1541,9 @@ keep_going: if (opcode->format == FMT_S0 || opcode->format == FMT_S1 || opcode->format == FMT_D0 + || opcode->format == FMT_D6 + || opcode->format == FMT_D7 + || opcode->format == FMT_D10 || opcode->format == FMT_D1) { number_to_chars_bigendian (f, insn, size); @@ -1297,6 +1618,19 @@ keep_going: number_to_chars_littleendian (f + 2, temp, 4); number_to_chars_bigendian (f + 6, extension & 0xff, 1); } + else if (opcode->format == FMT_D8) + { + unsigned long temp = ((insn & 0xff) << 16) | (extension & 0xffff); + number_to_chars_bigendian (f, (insn >> 8) & 0xffffff, 3); + number_to_chars_bigendian (f + 3, (temp & 0xff), 1); + number_to_chars_littleendian (f + 4, temp >> 8, 2); + } + else if (opcode->format == FMT_D9) + { + unsigned long temp = ((insn & 0xff) << 24) | (extension & 0xffffff); + number_to_chars_bigendian (f, (insn >> 8) & 0xffffff, 3); + number_to_chars_littleendian (f + 3, temp, 4); + } /* Create any fixups. */ for (i = 0; i < fc; i++) @@ -1337,6 +1671,8 @@ keep_going: implicitly 32bits. */ if ((operand->flags & MN10300_OPERAND_SPLIT) != 0) reloc_size = 32; + else if ((operand->flags & MN10300_OPERAND_24BIT) != 0) + reloc_size = 24; else reloc_size = operand->bits; @@ -1445,7 +1781,8 @@ tc_gen_reloc (seg, fixp) } else { - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof( asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->addend = fixp->fx_offset; } return reloc; @@ -1544,6 +1881,8 @@ mn10300_insert_operand (insnp, extensionp, operand, val, file, line, shift) int bits; bits = operand->bits; + if (operand->flags & MN10300_OPERAND_24BIT) + bits = 24; if ((operand->flags & MN10300_OPERAND_SIGNED) != 0) { @@ -1579,6 +1918,12 @@ mn10300_insert_operand (insnp, extensionp, operand, val, file, line, shift) *extensionp |= ((val & ((1 << (32 - operand->bits)) - 1)) << operand->shift); } + else if ((operand->flags & MN10300_OPERAND_24BIT) != 0) + { + *insnp |= (val >> (24 - operand->bits)) & ((1 << operand->bits) - 1); + *extensionp |= ((val & ((1 << (24 - operand->bits)) - 1)) + << operand->shift); + } else if ((operand->flags & MN10300_OPERAND_EXTENDED) == 0) { *insnp |= (((long) val & ((1 << operand->bits) - 1)) @@ -1615,6 +1960,8 @@ check_operand (insn, operand, val) int bits; bits = operand->bits; + if (operand->flags & MN10300_OPERAND_24BIT) + bits = 24; if ((operand->flags & MN10300_OPERAND_SIGNED) != 0) { diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c index 42dc528..59f1467 100644 --- a/gas/config/tc-ns32k.c +++ b/gas/config/tc-ns32k.c @@ -1,5 +1,6 @@ /* ns32k.c -- Assemble on the National Semiconductor 32k series - Copyright (C) 1987, 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 1999 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -1970,7 +1971,7 @@ md_convert_frag (abfd, sec, fragP) /* The displacement of the address, from current location. */ disp = (S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset) - object_address; #ifdef BFD_ASSEMBLER - disp += fragP->fr_symbol->sy_frag->fr_address; + disp += symbol_get_frag (fragP->fr_symbol)->fr_address; #endif disp += md_pcrel_adjust(fragP); @@ -2264,7 +2265,8 @@ tc_gen_reloc (section, fixp) code = reloc(fixp->fx_size, fixp->fx_pcrel, fix_im_disp(fixp)); rel = (arelent *) xmalloc (sizeof (arelent)); - rel->sym_ptr_ptr = &fixp->fx_addsy->bsym; + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); rel->address = fixp->fx_frag->fr_address + fixp->fx_where; if (fixp->fx_pcrel) rel->addend = fixp->fx_addnumber; diff --git a/gas/config/tc-ns32k.h b/gas/config/tc-ns32k.h index 4b038eb..69c86ec 100644 --- a/gas/config/tc-ns32k.h +++ b/gas/config/tc-ns32k.h @@ -1,5 +1,5 @@ /* tc-ns32k.h -- Opcode table for National Semi 32k processor - Copyright (C) 1987, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. + Copyright (C) 1987, 92, 93, 94, 95, 97, 1999 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -76,7 +76,7 @@ extern void fix_new_ns32k_exp PARAMS((fragS *frag, extern void fix_new_ns32k PARAMS ((fragS *frag, int where, int size, - struct symbol *add_symbol, + symbolS *add_symbol, long offset, int pcrel, int im_disp, diff --git a/gas/config/tc-pj.c b/gas/config/tc-pj.c new file mode 100644 index 0000000..4f80309 --- /dev/null +++ b/gas/config/tc-pj.c @@ -0,0 +1,594 @@ +/*- + tc-pj.c -- Assemble code for Pico Java + Copyright (C) 1999 Free Software Foundation. + + 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 2, 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. */ + +/* Contributed by Steve Chamberlain of Transmeta, sac@pobox.com */ + +#include "as.h" +#include "opcode/pj.h" + + +extern const pj_opc_info_t pj_opc_info[512]; + +const char comment_chars[] = "!/"; +const char line_separator_chars[] = ";"; +const char line_comment_chars[] = "/!#"; + +static int pending_reloc; +static struct hash_control *opcode_hash_control; + + +static void +little (ignore) + int ignore ATTRIBUTE_UNUSED; +{ + target_big_endian = 0; +} + +static void +big (ignore) + int ignore ATTRIBUTE_UNUSED; +{ + target_big_endian = 1; +} + + +const pseudo_typeS md_pseudo_table[] = { + {"ml", little, 0}, + {"mb", big, 0}, + {0, 0, 0} +}; + + +const char FLT_CHARS[] = "rRsSfFdDxXpP"; +const char EXP_CHARS[] = "eE"; + +void +md_operand (op) + expressionS *op; +{ + if (strncmp (input_line_pointer, "%hi16", 5) == 0) + { + if (pending_reloc) + as_bad (_ ("confusing relocation expressions")); + pending_reloc = BFD_RELOC_PJ_CODE_HI16; + input_line_pointer += 5; + expression (op); + } + if (strncmp (input_line_pointer, "%lo16", 5) == 0) + { + if (pending_reloc) + as_bad (_ ("confusing relocation expressions")); + pending_reloc = BFD_RELOC_PJ_CODE_LO16; + input_line_pointer += 5; + expression (op); + } +} + +/* Parse an expression and then restore the input line pointer. */ + +static char * +parse_exp_save_ilp (s, op) + char *s; + expressionS *op; +{ + char *save = input_line_pointer; + input_line_pointer = s; + expression (op); + s = input_line_pointer; + input_line_pointer = save; + return s; +} + +/* This is called by emit_expr via TC_CONS_FIX_NEW when creating a + reloc for a cons. We could use the definition there, except that + we want to handle magic pending reloc expressions specially. */ + +void +pj_cons_fix_new_pj (frag, where, nbytes, exp) + fragS *frag; + int where; + int nbytes; + expressionS *exp; +{ + static int rv[5][2] = + { { 0, 0 }, + { BFD_RELOC_8, BFD_RELOC_8 }, + { BFD_RELOC_PJ_CODE_DIR16, BFD_RELOC_16 }, + { 0, 0 }, + { BFD_RELOC_PJ_CODE_DIR32, BFD_RELOC_32 }}; + + fix_new_exp (frag, where, nbytes, exp, 0, + pending_reloc ? pending_reloc + : rv [nbytes][(now_seg->flags & SEC_CODE) ? 0 : 1]); + + pending_reloc = 0; +} + + +/* Turn a reloc description character from the pj-opc.h table into + code which BFD can handle. */ + +static int +c_to_r (x) + char x; +{ + switch (x) + { + case O_R8: + return BFD_RELOC_8_PCREL; + case O_U8: + case O_8: + return BFD_RELOC_8; + case O_R16: + return BFD_RELOC_PJ_CODE_REL16; + case O_U16: + case O_16: + return BFD_RELOC_PJ_CODE_DIR16; + case O_R32: + return BFD_RELOC_PJ_CODE_REL32; + case O_32: + return BFD_RELOC_PJ_CODE_DIR32; + } + abort (); + return 0; +} + + + + +/* Handler for the ipush fake opcode, + turns ipush into sipush lo16, sethi hi16. */ + +static void +ipush_code (opcode, str) + pj_opc_info_t *opcode ATTRIBUTE_UNUSED; + char *str; +{ + int mod = 0; + char *b = frag_more (6); + expressionS arg; + b[0] = 0x11; + b[3] = 0xed; + parse_exp_save_ilp (str + 1, &arg, &mod); + if (mod) + as_bad (_ ("can't have relocation for ipush")); + + + fix_new_exp (frag_now, b - frag_now->fr_literal + 1, 2, + &arg, 0, BFD_RELOC_PJ_CODE_DIR16); + fix_new_exp (frag_now, b - frag_now->fr_literal + 4, 2, + &arg, 0, BFD_RELOC_PJ_CODE_HI16); +} + +/* Insert names into the opcode table which are really mini macros, + not opcodes. The fakeness is inidicated with an opcode of -1. */ + +static void + fake_opcode (name, func) const char * + name; + void (*func) (); +{ + pj_opc_info_t *fake = (pj_opc_info_t *) xmalloc (sizeof (pj_opc_info_t)); + + fake->opcode = -1; + fake->opcode_next = -1; + fake->name = (const char *) func; + hash_insert (opcode_hash_control, name, (char *) fake); +} + + +/* Enter another entry into the opcode hash table so the same opcode + can have another name. */ +static void + alias (new, old) const char * + new; + const char *old; +{ + hash_insert (opcode_hash_control, new, + (char *) hash_find (opcode_hash_control, old)); +} + + +/* This function is called once, at assembler startup time. It sets + up the hash table with all the opcodes in it, and also initializes + some aliases for compatibility with other assemblers. */ + +void +md_begin () +{ + const pj_opc_info_t *opcode; + opcode_hash_control = hash_new (); + + /* Insert names into hash table */ + for (opcode = pj_opc_info; opcode->name; opcode++) + hash_insert (opcode_hash_control, opcode->name, (char *) opcode); + + /* Insert the only fake opcode. */ + fake_opcode ("ipush", ipush_code); + + /* Add some aliases for opcode names. */ + alias ("ifeq_s", "ifeq"); + alias ("ifne_s", "ifne"); + alias ("if_icmpge_s", "if_icmpge"); + alias ("if_icmpne_s", "if_icmpne"); + alias ("if_icmpeq_s", "if_icmpeq"); + alias ("if_icmpgt_s", "if_icmpgt"); + alias ("goto_s", "goto"); + + bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0); +} + +/* This is the guts of the machine-dependent assembler. STR points to a + machine dependent instruction. This function is supposed to emit + the frags/bytes it assembles to. + */ + +void +md_assemble (str) + char *str; +{ + unsigned char *op_start; + unsigned char *op_end; + + // pj_operan_info operand[3]; + pj_opc_info_t *opcode; + char *output; + int idx = 0; + char pend; + + int nlen = 0; + + /* Drop leading whitespace */ + while (*str == ' ') + str++; + + /* find the op code end */ + for (op_start = op_end = (unsigned char *) (str); + *op_end && !is_end_of_line[*op_end] && *op_end != ' '; + op_end++) + nlen++; + + pend = *op_end; + *op_end = 0; + + if (nlen == 0) + { + as_bad (_ ("can't find opcode ")); + } + + opcode = (pj_opc_info_t *) hash_find (opcode_hash_control, op_start); + *op_end = pend; + + if (opcode == NULL) + { + as_bad (_ ("unknown opcode %s"), op_start); + return; + } + + if (opcode->opcode == -1) + { + /* It's a fake opcode.. dig out the args and pretend that was + what we were passed */ + ((void (*)()) opcode->name) (opcode, op_end); + } + else + { + int an; + + output = frag_more (opcode->len); + output[idx++] = opcode->opcode; + + if (opcode->opcode_next != -1) + output[idx++] = opcode->opcode_next; + + for (an = 0; opcode->arg[an]; an++) + { + expressionS arg; + + if (*op_end == ',' && an != 0) + op_end++; + + if (*op_end == 0) + as_bad ("expected expresssion"); + + op_end = parse_exp_save_ilp (op_end, &arg); + + fix_new_exp (frag_now, + output - frag_now->fr_literal + idx, + ASIZE (opcode->arg[an]), + &arg, + PCREL (opcode->arg[an]), + pending_reloc ? pending_reloc : c_to_r (opcode->arg[an])); + + idx += ASIZE (opcode->arg[an]); + pending_reloc = 0; + } + + while (isspace (*op_end)) + op_end++; + + if (*op_end != 0) + as_warn ("extra stuff on line ignored"); + + } + + if (pending_reloc) + as_bad ("Something forgot to clean up\n"); + +} + +/* Turn a string in input_line_pointer into a floating point constant of type + type, and store the appropriate bytes in *litP. The number of LITTLENUMS + emitted is stored in *sizeP . An error message is returned, or NULL on OK. + */ +char * +md_atof (type, litP, sizeP) + int type; + char *litP; + int *sizeP; +{ + int prec; + LITTLENUM_TYPE words[4]; + char *t; + int i; + + switch (type) + { + case 'f': + prec = 2; + break; + + case 'd': + prec = 4; + break; + + default: + *sizeP = 0; + return _ ("bad call to md_atof"); + } + + t = atof_ieee (input_line_pointer, type, words); + if (t) + input_line_pointer = t; + + *sizeP = prec * 2; + + if (!target_big_endian) + { + for (i = prec - 1; i >= 0; i--) + { + md_number_to_chars (litP, (valueT) words[i], 2); + litP += 2; + } + } + else + { + for (i = 0; i < prec; i++) + { + md_number_to_chars (litP, (valueT) words[i], 2); + litP += 2; + } + } + + return NULL; +} + + +CONST char *md_shortopts = ""; + +struct option md_longopts[] = { + +#define OPTION_LITTLE (OPTION_MD_BASE) +#define OPTION_BIG (OPTION_LITTLE + 1) + + {"little", no_argument, NULL, OPTION_LITTLE}, + {"big", no_argument, NULL, OPTION_BIG}, + {NULL, no_argument, NULL, 0} +}; +size_t md_longopts_size = sizeof (md_longopts); + +int +md_parse_option (c, arg) + int c; + char *arg ATTRIBUTE_UNUSED; +{ + switch (c) + { + case OPTION_LITTLE: + little (); + break; + case OPTION_BIG: + big (); + break; + default: + return 0; + } + return 1; +} + +void +md_show_usage (stream) + FILE *stream; +{ + fprintf (stream, _ ("\ +PJ options:\n\ +-little generate little endian code\n\ +-big generate big endian code\n")); +} + + + +/* Apply a fixup to the object file. */ + + +int +md_apply_fix (fixP, valp) + fixS *fixP; + valueT *valp; +{ + char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; + long val = *valp; + long max, min; + int shift; + + + /* adjust_reloc_syms won't convert a reloc against a weak symbol + into a reloc against a section, but bfd_install_relocation will + screw up if the symbol is defined, so we have to adjust val here + to avoid the screw up later. */ + + if (fixP->fx_addsy != NULL && S_IS_WEAK (fixP->fx_addsy)) + val -= S_GET_VALUE (fixP->fx_addsy); + + max = min = 0; + shift = 0; + switch (fixP->fx_r_type) + { + case BFD_RELOC_VTABLE_INHERIT: + case BFD_RELOC_VTABLE_ENTRY: + fixP->fx_done = 0; + return 0; + + case BFD_RELOC_PJ_CODE_REL16: + if (val < -0x8000 || val >= 0x7fff) + as_bad_where (fixP->fx_file, fixP->fx_line, _ ("pcrel too far")); + buf[0] |= (val >> 8) & 0xff; + buf[1] = val & 0xff; + break; + + case BFD_RELOC_PJ_CODE_HI16: + *buf++ = val >> 24; + *buf++ = val >> 16; + fixP->fx_addnumber = val & 0xffff; + break; + + case BFD_RELOC_PJ_CODE_DIR16: + case BFD_RELOC_PJ_CODE_LO16: + *buf++ = val >> 8; + *buf++ = val >> 0; + + max = 0xffff; + min = -0xffff; + break; + + case BFD_RELOC_8: + max = 0xff; + min = -0xff; + *buf++ = val; + break; + + case BFD_RELOC_PJ_CODE_DIR32: + *buf++ = val >> 24; + *buf++ = val >> 16; + *buf++ = val >> 8; + *buf++ = val >> 0; + break; + + case BFD_RELOC_32: + if (target_big_endian) + { + *buf++ = val >> 24; + *buf++ = val >> 16; + *buf++ = val >> 8; + *buf++ = val >> 0; + } + else + { + *buf++ = val >> 0; + *buf++ = val >> 8; + *buf++ = val >> 16; + *buf++ = val >> 24; + } + break; + + case BFD_RELOC_16: + if (target_big_endian) + { + *buf++ = val >> 8; + *buf++ = val >> 0; + } + else + { + *buf++ = val >> 0; + *buf++ = val >> 8; + } + break; + + + default: + abort (); + } + + if (max != 0 && (val < min || val > max)) + as_bad_where (fixP->fx_file, fixP->fx_line, _ ("offset out of range")); + + return 0; +} + +/* Put number into target byte order. Always put values in an + executable section into big endian order. */ + +void +md_number_to_chars (ptr, use, nbytes) + char *ptr; + valueT use; + int nbytes; +{ + if (target_big_endian || now_seg->flags & SEC_CODE) + number_to_chars_bigendian (ptr, use, nbytes); + else + number_to_chars_littleendian (ptr, use, nbytes); +} + + + +/* Translate internal representation of relocation info to BFD target + format. */ + +arelent * +tc_gen_reloc (section, fixp) + asection *section ATTRIBUTE_UNUSED; + fixS *fixp; +{ + arelent *rel; + bfd_reloc_code_real_type r_type; + + rel = (arelent *) xmalloc (sizeof (arelent)); + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); + rel->address = fixp->fx_frag->fr_address + fixp->fx_where; + + r_type = fixp->fx_r_type; + rel->addend = fixp->fx_addnumber; + rel->howto = bfd_reloc_type_lookup (stdoutput, r_type); + + if (rel->howto == NULL) + { + as_bad_where (fixp->fx_file, fixp->fx_line, + _ ("Cannot represent relocation type %s"), + bfd_get_reloc_code_name (r_type)); + /* Set howto to a garbage value so that we can keep going. */ + rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32); + assert (rel->howto != NULL); + } + + return rel; +} diff --git a/gas/config/tc-pj.h b/gas/config/tc-pj.h new file mode 100644 index 0000000..efbf7b7 --- /dev/null +++ b/gas/config/tc-pj.h @@ -0,0 +1,62 @@ +/*-This file is tc-pj.h + + Copyright (C) 1999 Free Software Foundation, Inc. + + Contributed by Steve Chamberlain of Transmeta, sac@pobox.com + + 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 2, 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. */ + + +/* Contributed by Steve Chamberlain, of Transmeta. sac@pobox.com. */ + +#define WORKING_DOT_WORD +#define IGNORE_NONSTANDARD_ESCAPES +#define TARGET_ARCH bfd_arch_pj +#define TARGET_FORMAT (target_big_endian ? "elf32-pj" : "elf32-pjl") +#define LISTING_HEADER \ + (target_big_endian \ + ? "Pico Java GAS Big Endian" \ + : "Pico Java GAS Little Endian") + + +void pj_cons_fix_new_pj PARAMS ((struct frag *, int, int, expressionS *)); +arelent *tc_gen_reloc PARAMS((asection *section, struct fix *fixp)); + +#define md_section_align(SEGMENT, SIZE) (SIZE) +#define md_convert_frag(B, S, F) (as_fatal (_("convert_frag\n")), 0) +#define md_estimate_size_before_relax(A, B) (as_fatal (_("estimate size\n")),0) +#define md_undefined_symbol(NAME) 0 + +/* PC relative operands are relative to the start of the opcode, and the operand + is always one byte into the opcode. */ + +#define md_pcrel_from(FIXP) \ + ((FIXP)->fx_where + (FIXP)->fx_frag->fr_address - 1) + + +#define TC_CONS_FIX_NEW(FRAG, WHERE, NBYTES, EXP) \ + pj_cons_fix_new_pj(FRAG, WHERE, NBYTES, EXP) + +/* Always leave vtable relocs untouched in the output. */ +#define TC_FORCE_RELOCATION(FIX) \ + ((FIX)->fx_r_type == BFD_RELOC_VTABLE_INHERIT \ + || (FIX)->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + +#define obj_fix_adjustable(FIX) \ + (! ((FIX)->fx_r_type == BFD_RELOC_VTABLE_INHERIT \ + || (FIX)->fx_r_type == BFD_RELOC_VTABLE_ENTRY)) diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 8c31ba6..365a535 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -1,5 +1,6 @@ /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000) - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GAS, the GNU Assembler. @@ -588,7 +589,7 @@ static int ppc_cpu = 0; /* The size of the processor we are assembling for. This is either PPC_OPCODE_32 or PPC_OPCODE_64. */ -static int ppc_size = PPC_OPCODE_32; +static unsigned long ppc_size = PPC_OPCODE_32; /* Opcode hash table. */ static struct hash_control *ppc_hash; @@ -766,6 +767,11 @@ md_parse_option (c, arg) ppc_cpu = PPC_OPCODE_PPC; ppc_size = PPC_OPCODE_64; } + else if (strcmp (arg, "ppc64bridge") == 0) + { + ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64_BRIDGE; + ppc_size = PPC_OPCODE_64; + } /* -mcom means assemble for the common intersection between Power and PowerPC. At present, we just allow the union, rather than the intersection. */ @@ -872,6 +878,7 @@ PowerPC options:\n\ -mppc, -mppc32, -m403, -m603, -m604\n\ generate code for Motorola PowerPC 603/604\n\ -mppc64, -m620 generate code for Motorola PowerPC 620\n\ +-mppc64bridge generate code for PowerPC 64, including bridge insns\n\ -mcom generate code Power/PowerPC common instructions\n\ -many generate code for any architecture (PWR/PWRX/PPC)\n\ -mregnames Allow symbolic names for registers\n\ @@ -972,7 +979,8 @@ md_begin () if ((op->flags & ppc_cpu) != 0 && ((op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == 0 - || (op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == ppc_size)) + || (op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == ppc_size + || (ppc_cpu & PPC_OPCODE_64_BRIDGE) != 0)) { const char *retval; @@ -1026,9 +1034,9 @@ md_begin () text csects to precede the data csects. These symbols will not be output. */ ppc_text_csects = symbol_make ("dummy\001"); - ppc_text_csects->sy_tc.within = ppc_text_csects; + symbol_get_tc (ppc_text_csects)->within = ppc_text_csects; ppc_data_csects = symbol_make ("dummy\001"); - ppc_data_csects->sy_tc.within = ppc_data_csects; + symbol_get_tc (ppc_data_csects)->within = ppc_data_csects; #endif #ifdef TE_PE @@ -1056,8 +1064,7 @@ ppc_insert_operand (insn, operand, val, file, line) if ((operand->flags & PPC_OPERAND_SIGNED) != 0) { - if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0 - && ppc_size == PPC_OPCODE_32) + if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0) max = (1 << operand->bits) - 1; else max = (1 << (operand->bits - 1)) - 1; @@ -1070,8 +1077,8 @@ ppc_insert_operand (insn, operand, val, file, line) valid, but, to permit this code to assemble on a 64 bit host, we sign extend the 32 bit value. */ if (val > 0 - && (val & 0x80000000) != 0 - && (val & 0xffffffff) == val) + && (val & (offsetT) 0x80000000) != 0 + && (val & (offsetT) 0xffffffff) == val) { val -= 0x80000000; val -= 0x80000000; @@ -1305,7 +1312,7 @@ ppc_elf_rdata (xxx) /* Pseudo op to make file scope bss items */ static void ppc_elf_lcomm(xxx) - int xxx; + int xxx ATTRIBUTE_UNUSED; { register char *name; register char c; @@ -1399,8 +1406,8 @@ ppc_elf_lcomm(xxx) if (align2) frag_align (align2, 0, 0); if (S_GET_SEGMENT (symbolP) == bss_section) - symbolP->sy_frag->fr_symbol = 0; - symbolP->sy_frag = frag_now; + symbol_get_frag (symbolP)->fr_symbol = 0; + symbol_set_frag (symbolP, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size, (char *) 0); *pfrag = 0; @@ -1777,7 +1784,8 @@ md_assemble (str) if (ex.X_op == O_symbol) { assert (ex.X_add_symbol != NULL); - if (ex.X_add_symbol->bsym->section != tocdata_section) + if (symbol_get_bfdsym (ex.X_add_symbol)->section + != tocdata_section) { as_bad(_("[tocv] symbol is not a toc symbol")); } @@ -1878,8 +1886,9 @@ md_assemble (str) break; case BFD_RELOC_HI16_S: - ex.X_add_number = (((ex.X_add_number >> 16) & 0xffff) - + ((ex.X_add_number >> 15) & 1)); + ex.X_add_number = ((((ex.X_add_number >> 16) & 0xffff) + + ((ex.X_add_number >> 15) & 1)) + & 0xffff); break; } #endif @@ -2120,29 +2129,25 @@ ppc_section_letter (letter, ptr_msg) } int -ppc_section_word (ptr_str) - char **ptr_str; +ppc_section_word (str, len) + char *str; + size_t len; { - if (strncmp (*ptr_str, "exclude", sizeof ("exclude")-1) == 0) - { - *ptr_str += sizeof ("exclude")-1; - return SHF_EXCLUDE; - } + if (len == 7 && strncmp (str, "exclude", 7) == 0) + return SHF_EXCLUDE; - return 0; + return -1; } int -ppc_section_type (ptr_str) - char **ptr_str; +ppc_section_type (str, len) + char *str; + size_t len; { - if (strncmp (*ptr_str, "ordered", sizeof ("ordered")-1) == 0) - { - *ptr_str += sizeof ("ordered")-1; - return SHT_ORDERED; - } + if (len == 7 && strncmp (str, "ordered", 7) == 0) + return SHT_ORDERED; - return 0; + return -1; } int @@ -2169,7 +2174,7 @@ ppc_section_flags (flags, attr, type) static void ppc_byte (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (*input_line_pointer != '\"') { @@ -2325,7 +2330,7 @@ ppc_comm (lcomm) } else { - lcomm_sym->sy_tc.output = 1; + symbol_get_tc (lcomm_sym)->output = 1; def_sym = lcomm_sym; def_size = 0; } @@ -2333,30 +2338,30 @@ ppc_comm (lcomm) subseg_set (bss_section, 1); frag_align (align, 0, 0); - def_sym->sy_frag = frag_now; + symbol_set_frag (def_sym, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, def_sym, def_size, (char *) NULL); *pfrag = 0; S_SET_SEGMENT (def_sym, bss_section); - def_sym->sy_tc.align = align; + symbol_get_tc (def_sym)->align = align; } else if (lcomm) { /* Align the size of lcomm_sym. */ - lcomm_sym->sy_frag->fr_offset = - ((lcomm_sym->sy_frag->fr_offset + (1 << align) - 1) + symbol_get_frag (lcomm_sym)->fr_offset = + ((symbol_get_frag (lcomm_sym)->fr_offset + (1 << align) - 1) &~ ((1 << align) - 1)); - if (align > lcomm_sym->sy_tc.align) - lcomm_sym->sy_tc.align = align; + if (align > symbol_get_tc (lcomm_sym)->align) + symbol_get_tc (lcomm_sym)->align = align; } if (lcomm) { /* Make sym an offset from lcomm_sym. */ S_SET_SEGMENT (sym, bss_section); - sym->sy_frag = lcomm_sym->sy_frag; - S_SET_VALUE (sym, lcomm_sym->sy_frag->fr_offset); - lcomm_sym->sy_frag->fr_offset += size; + symbol_set_frag (sym, symbol_get_frag (lcomm_sym)); + S_SET_VALUE (sym, symbol_get_frag (lcomm_sym)->fr_offset); + symbol_get_frag (lcomm_sym)->fr_offset += size; } subseg_set (current_seg, current_subseg); @@ -2388,7 +2393,7 @@ ppc_csect (ignore) if (S_GET_NAME (sym)[0] == '\0') { /* An unnamed csect is assumed to be [PR]. */ - sym->sy_tc.class = XMC_PR; + symbol_get_tc (sym)->class = XMC_PR; } ppc_change_csect (sym); @@ -2396,7 +2401,7 @@ ppc_csect (ignore) if (*input_line_pointer == ',') { ++input_line_pointer; - sym->sy_tc.align = get_absolute_expression (); + symbol_get_tc (sym)->align = get_absolute_expression (); } demand_empty_rest_of_line (); @@ -2409,7 +2414,7 @@ ppc_change_csect (sym) symbolS *sym; { if (S_IS_DEFINED (sym)) - subseg_set (S_GET_SEGMENT (sym), sym->sy_tc.subseg); + subseg_set (S_GET_SEGMENT (sym), symbol_get_tc (sym)->subseg); else { symbolS **list_ptr; @@ -2421,7 +2426,7 @@ ppc_change_csect (sym) figure out whether it should go in the text section or the data section. */ after_toc = 0; - switch (sym->sy_tc.class) + switch (symbol_get_tc (sym)->class) { case XMC_PR: case XMC_RO: @@ -2432,7 +2437,7 @@ ppc_change_csect (sym) case XMC_TI: case XMC_TB: S_SET_SEGMENT (sym, text_section); - sym->sy_tc.subseg = ppc_text_subsegment; + symbol_get_tc (sym)->subseg = ppc_text_subsegment; ++ppc_text_subsegment; list_ptr = &ppc_text_csects; break; @@ -2444,10 +2449,11 @@ ppc_change_csect (sym) case XMC_BS: case XMC_UC: if (ppc_toc_csect != NULL - && ppc_toc_csect->sy_tc.subseg + 1 == ppc_data_subsegment) + && (symbol_get_tc (ppc_toc_csect)->subseg + 1 + == ppc_data_subsegment)) after_toc = 1; S_SET_SEGMENT (sym, data_section); - sym->sy_tc.subseg = ppc_data_subsegment; + symbol_get_tc (sym)->subseg = ppc_data_subsegment; ++ppc_data_subsegment; list_ptr = &ppc_data_csects; break; @@ -2461,28 +2467,30 @@ ppc_change_csect (sym) hold_chunksize = chunksize; chunksize = 64; - subseg_new (segment_name (S_GET_SEGMENT (sym)), sym->sy_tc.subseg); + subseg_new (segment_name (S_GET_SEGMENT (sym)), + symbol_get_tc (sym)->subseg); chunksize = hold_chunksize; if (after_toc) ppc_after_toc_frag = frag_now; - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, (valueT) frag_now_fix ()); - sym->sy_tc.align = 2; - sym->sy_tc.output = 1; - sym->sy_tc.within = sym; + symbol_get_tc (sym)->align = 2; + symbol_get_tc (sym)->output = 1; + symbol_get_tc (sym)->within = sym; for (list = *list_ptr; - list->sy_tc.next != (symbolS *) NULL; - list = list->sy_tc.next) + symbol_get_tc (list)->next != (symbolS *) NULL; + list = symbol_get_tc (list)->next) ; - list->sy_tc.next = sym; + symbol_get_tc (list)->next = sym; symbol_remove (sym, &symbol_rootP, &symbol_lastP); - symbol_append (sym, list->sy_tc.within, &symbol_rootP, &symbol_lastP); + symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP, + &symbol_lastP); } ppc_current_csect = sym; @@ -2586,7 +2594,7 @@ ppc_lglobl (ignore) *input_line_pointer = endc; - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; demand_empty_rest_of_line (); } @@ -2618,7 +2626,7 @@ ppc_rename (ignore) } ++input_line_pointer; - sym->sy_tc.real_name = demand_copy_C_string (&len); + symbol_get_tc (sym)->real_name = demand_copy_C_string (&len); demand_empty_rest_of_line (); } @@ -2652,7 +2660,7 @@ ppc_stabx (ignore) sym = symbol_make (name); ppc_stab_symbol = false; - sym->sy_tc.real_name = name; + symbol_get_tc (sym)->real_name = name; (void) expression (&exp); @@ -2666,17 +2674,17 @@ ppc_stabx (ignore) /* Fall through. */ case O_constant: S_SET_VALUE (sym, (valueT) exp.X_add_number); - sym->sy_frag = &zero_address_frag; + symbol_set_frag (sym, &zero_address_frag); break; case O_symbol: if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section) - sym->sy_value = exp; + symbol_set_value_expression (sym, &exp); else { S_SET_VALUE (sym, exp.X_add_number + S_GET_VALUE (exp.X_add_symbol)); - sym->sy_frag = exp.X_add_symbol->sy_frag; + symbol_set_frag (sym, symbol_get_frag (exp.X_add_symbol)); } break; @@ -2684,12 +2692,12 @@ ppc_stabx (ignore) /* The value is some complex expression. This will probably fail at some later point, but this is probably the right thing to do here. */ - sym->sy_value = exp; + symbol_set_value_expression (sym, &exp); break; } S_SET_SEGMENT (sym, ppc_coff_debug_section); - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; if (*input_line_pointer != ',') { @@ -2709,10 +2717,10 @@ ppc_stabx (ignore) S_SET_DATA_TYPE (sym, get_absolute_expression ()); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; if (S_GET_STORAGE_CLASS (sym) == C_STSYM) - sym->sy_tc.within = ppc_current_block; + symbol_get_tc (sym)->within = ppc_current_block; if (exp.X_op != O_symbol || ! S_IS_EXTERNAL (exp.X_add_symbol) @@ -2722,8 +2730,8 @@ ppc_stabx (ignore) { symbol_remove (sym, &symbol_rootP, &symbol_lastP); symbol_append (sym, exp.X_add_symbol, &symbol_rootP, &symbol_lastP); - if (ppc_current_csect->sy_tc.within == exp.X_add_symbol) - ppc_current_csect->sy_tc.within = sym; + if (symbol_get_tc (ppc_current_csect)->within == exp.X_add_symbol) + symbol_get_tc (ppc_current_csect)->within = sym; } demand_empty_rest_of_line (); @@ -2778,15 +2786,19 @@ ppc_function (ignore) if (ext_sym != lab_sym) { - ext_sym->sy_value.X_op = O_symbol; - ext_sym->sy_value.X_add_symbol = lab_sym; - ext_sym->sy_value.X_op_symbol = NULL; - ext_sym->sy_value.X_add_number = 0; + expressionS exp; + + exp.X_op = O_symbol; + exp.X_add_symbol = lab_sym; + exp.X_op_symbol = NULL; + exp.X_add_number = 0; + exp.X_unsigned = 0; + symbol_set_value_expression (ext_sym, &exp); } - if (ext_sym->sy_tc.class == -1) - ext_sym->sy_tc.class = XMC_PR; - ext_sym->sy_tc.output = 1; + if (symbol_get_tc (ext_sym)->class == -1) + symbol_get_tc (ext_sym)->class = XMC_PR; + symbol_get_tc (ext_sym)->output = 1; if (*input_line_pointer == ',') { @@ -2804,11 +2816,11 @@ ppc_function (ignore) { /* The fifth argument is the function size. */ ++input_line_pointer; - ext_sym->sy_tc.size = symbol_new ("L0\001", - absolute_section, - (valueT) 0, - &zero_address_frag); - pseudo_set (ext_sym->sy_tc.size); + symbol_get_tc (ext_sym)->size = symbol_new ("L0\001", + absolute_section, + (valueT) 0, + &zero_address_frag); + pseudo_set (symbol_get_tc (ext_sym)->size); } } } @@ -2832,7 +2844,7 @@ ppc_bf (ignore) sym = symbol_make (".bf"); S_SET_SEGMENT (sym, text_section); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, frag_now_fix ()); S_SET_STORAGE_CLASS (sym, C_FCN); @@ -2841,7 +2853,7 @@ ppc_bf (ignore) S_SET_NUMBER_AUXILIARY (sym, 1); SA_SET_SYM_LNNO (sym, coff_line_base); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); @@ -2860,12 +2872,12 @@ ppc_ef (ignore) sym = symbol_make (".ef"); S_SET_SEGMENT (sym, text_section); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, frag_now_fix ()); S_SET_STORAGE_CLASS (sym, C_FCN); S_SET_NUMBER_AUXILIARY (sym, 1); SA_SET_SYM_LNNO (sym, get_absolute_expression ()); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); @@ -2899,10 +2911,10 @@ ppc_biei (ei) .text section. */ S_SET_SEGMENT (sym, text_section); S_SET_VALUE (sym, coff_n_line_nos); - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; S_SET_STORAGE_CLASS (sym, ei ? C_EINCL : C_BINCL); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; for (look = last_biei ? last_biei : symbol_rootP; (look != (symbolS *) NULL @@ -2947,10 +2959,10 @@ ppc_bs (ignore) sym = symbol_make (".bs"); S_SET_SEGMENT (sym, now_seg); S_SET_STORAGE_CLASS (sym, C_BSTAT); - sym->bsym->flags |= BSF_DEBUGGING; - sym->sy_tc.output = 1; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; + symbol_get_tc (sym)->output = 1; - sym->sy_tc.within = csect; + symbol_get_tc (sym)->within = csect; ppc_frob_label (sym); @@ -2973,8 +2985,8 @@ ppc_es (ignore) sym = symbol_make (".es"); S_SET_SEGMENT (sym, now_seg); S_SET_STORAGE_CLASS (sym, C_ESTAT); - sym->bsym->flags |= BSF_DEBUGGING; - sym->sy_tc.output = 1; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); @@ -2994,14 +3006,14 @@ ppc_bb (ignore) sym = symbol_make (".bb"); S_SET_SEGMENT (sym, text_section); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, frag_now_fix ()); S_SET_STORAGE_CLASS (sym, C_BLOCK); S_SET_NUMBER_AUXILIARY (sym, 1); SA_SET_SYM_LNNO (sym, get_absolute_expression ()); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; SF_SET_PROCESS (sym); @@ -3021,12 +3033,12 @@ ppc_eb (ignore) sym = symbol_make (".eb"); S_SET_SEGMENT (sym, text_section); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, frag_now_fix ()); S_SET_STORAGE_CLASS (sym, C_BLOCK); S_SET_NUMBER_AUXILIARY (sym, 1); SA_SET_SYM_LNNO (sym, get_absolute_expression ()); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; SF_SET_PROCESS (sym); @@ -3049,10 +3061,10 @@ ppc_bc (ignore) name = demand_copy_C_string (&len); sym = symbol_make (name); S_SET_SEGMENT (sym, ppc_coff_debug_section); - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; S_SET_STORAGE_CLASS (sym, C_BCOMM); S_SET_VALUE (sym, 0); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); @@ -3069,10 +3081,10 @@ ppc_ec (ignore) sym = symbol_make (".ec"); S_SET_SEGMENT (sym, ppc_coff_debug_section); - sym->bsym->flags |= BSF_DEBUGGING; + symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; S_SET_STORAGE_CLASS (sym, C_ECOMM); S_SET_VALUE (sym, 0); - sym->sy_tc.output = 1; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); @@ -3086,7 +3098,7 @@ ppc_toc (ignore) int ignore; { if (ppc_toc_csect != (symbolS *) NULL) - subseg_set (data_section, ppc_toc_csect->sy_tc.subseg); + subseg_set (data_section, symbol_get_tc (ppc_toc_csect)->subseg); else { subsegT subseg; @@ -3100,23 +3112,24 @@ ppc_toc (ignore) ppc_toc_frag = frag_now; sym = symbol_find_or_make ("TOC[TC0]"); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_SEGMENT (sym, data_section); S_SET_VALUE (sym, (valueT) frag_now_fix ()); - sym->sy_tc.subseg = subseg; - sym->sy_tc.output = 1; - sym->sy_tc.within = sym; + symbol_get_tc (sym)->subseg = subseg; + symbol_get_tc (sym)->output = 1; + symbol_get_tc (sym)->within = sym; ppc_toc_csect = sym; for (list = ppc_data_csects; - list->sy_tc.next != (symbolS *) NULL; - list = list->sy_tc.next) + symbol_get_tc (list)->next != (symbolS *) NULL; + list = symbol_get_tc (list)->next) ; - list->sy_tc.next = sym; + symbol_get_tc (list)->next = sym; symbol_remove (sym, &symbol_rootP, &symbol_lastP); - symbol_append (sym, list->sy_tc.within, &symbol_rootP, &symbol_lastP); + symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP, + &symbol_lastP); } ppc_current_csect = ppc_toc_csect; @@ -3179,7 +3192,7 @@ ppc_vbyte (dummy) static void ppc_tc (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { #ifdef OBJ_XCOFF @@ -3208,8 +3221,8 @@ ppc_tc (ignore) { symbolS *label; - label = ppc_current_csect->sy_tc.within; - if (label->sy_tc.class != XMC_TC0) + label = symbol_get_tc (ppc_current_csect)->within; + if (symbol_get_tc (label)->class != XMC_TC0) { as_bad (_(".tc with no label")); ignore_rest_of_line (); @@ -3217,7 +3230,7 @@ ppc_tc (ignore) } S_SET_SEGMENT (label, S_GET_SEGMENT (sym)); - label->sy_frag = sym->sy_frag; + symbol_set_frag (label, symbol_get_frag (sym)); S_SET_VALUE (label, S_GET_VALUE (sym)); while (! is_end_of_line[(unsigned char) *input_line_pointer]) @@ -3227,10 +3240,10 @@ ppc_tc (ignore) } S_SET_SEGMENT (sym, now_seg); - sym->sy_frag = frag_now; + symbol_set_frag (sym, frag_now); S_SET_VALUE (sym, (valueT) frag_now_fix ()); - sym->sy_tc.class = XMC_TC; - sym->sy_tc.output = 1; + symbol_get_tc (sym)->class = XMC_TC; + symbol_get_tc (sym)->output = 1; ppc_frob_label (sym); } @@ -3910,16 +3923,18 @@ void ppc_symbol_new_hook (sym) symbolS *sym; { + struct ppc_tc_sy *tc; const char *s; - sym->sy_tc.next = NULL; - sym->sy_tc.output = 0; - sym->sy_tc.class = -1; - sym->sy_tc.real_name = NULL; - sym->sy_tc.subseg = 0; - sym->sy_tc.align = 0; - sym->sy_tc.size = NULL; - sym->sy_tc.within = NULL; + tc = symbol_get_tc (sym); + tc->next = NULL; + tc->output = 0; + tc->class = -1; + tc->real_name = NULL; + tc->subseg = 0; + tc->align = 0; + tc->size = NULL; + tc->within = NULL; if (ppc_stab_symbol) return; @@ -3937,55 +3952,55 @@ ppc_symbol_new_hook (sym) { case 'B': if (strcmp (s, "BS]") == 0) - sym->sy_tc.class = XMC_BS; + tc->class = XMC_BS; break; case 'D': if (strcmp (s, "DB]") == 0) - sym->sy_tc.class = XMC_DB; + tc->class = XMC_DB; else if (strcmp (s, "DS]") == 0) - sym->sy_tc.class = XMC_DS; + tc->class = XMC_DS; break; case 'G': if (strcmp (s, "GL]") == 0) - sym->sy_tc.class = XMC_GL; + tc->class = XMC_GL; break; case 'P': if (strcmp (s, "PR]") == 0) - sym->sy_tc.class = XMC_PR; + tc->class = XMC_PR; break; case 'R': if (strcmp (s, "RO]") == 0) - sym->sy_tc.class = XMC_RO; + tc->class = XMC_RO; else if (strcmp (s, "RW]") == 0) - sym->sy_tc.class = XMC_RW; + tc->class = XMC_RW; break; case 'S': if (strcmp (s, "SV]") == 0) - sym->sy_tc.class = XMC_SV; + tc->class = XMC_SV; break; case 'T': if (strcmp (s, "TC]") == 0) - sym->sy_tc.class = XMC_TC; + tc->class = XMC_TC; else if (strcmp (s, "TI]") == 0) - sym->sy_tc.class = XMC_TI; + tc->class = XMC_TI; else if (strcmp (s, "TB]") == 0) - sym->sy_tc.class = XMC_TB; + tc->class = XMC_TB; else if (strcmp (s, "TC0]") == 0 || strcmp (s, "T0]") == 0) - sym->sy_tc.class = XMC_TC0; + tc->class = XMC_TC0; break; case 'U': if (strcmp (s, "UA]") == 0) - sym->sy_tc.class = XMC_UA; + tc->class = XMC_UA; else if (strcmp (s, "UC]") == 0) - sym->sy_tc.class = XMC_UC; + tc->class = XMC_UC; break; case 'X': if (strcmp (s, "XO]") == 0) - sym->sy_tc.class = XMC_XO; + tc->class = XMC_XO; break; } - if (sym->sy_tc.class == -1) + if (tc->class == -1) as_bad (_("Unrecognized symbol suffix")); } @@ -3999,13 +4014,13 @@ ppc_frob_label (sym) { if (ppc_current_csect != (symbolS *) NULL) { - if (sym->sy_tc.class == -1) - sym->sy_tc.class = ppc_current_csect->sy_tc.class; + if (symbol_get_tc (sym)->class == -1) + symbol_get_tc (sym)->class = symbol_get_tc (ppc_current_csect)->class; symbol_remove (sym, &symbol_rootP, &symbol_lastP); - symbol_append (sym, ppc_current_csect->sy_tc.within, &symbol_rootP, - &symbol_lastP); - ppc_current_csect->sy_tc.within = sym; + symbol_append (sym, symbol_get_tc (ppc_current_csect)->within, + &symbol_rootP, &symbol_lastP); + symbol_get_tc (ppc_current_csect)->within = sym; } } @@ -4029,15 +4044,15 @@ ppc_frob_symbol (sym) /* Discard symbols that should not be included in the output symbol table. */ - if (! sym->sy_used_in_reloc - && ((sym->bsym->flags & BSF_SECTION_SYM) != 0 + if (! symbol_used_in_reloc_p (sym) + && ((symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0 || (! S_IS_EXTERNAL (sym) - && ! sym->sy_tc.output + && ! symbol_get_tc (sym)->output && S_GET_STORAGE_CLASS (sym) != C_FILE))) return 1; - if (sym->sy_tc.real_name != (char *) NULL) - S_SET_NAME (sym, sym->sy_tc.real_name); + if (symbol_get_tc (sym)->real_name != (char *) NULL) + S_SET_NAME (sym, symbol_get_tc (sym)->real_name); else { const char *name; @@ -4070,10 +4085,11 @@ ppc_frob_symbol (sym) if (ppc_last_function != (symbolS *) NULL) as_bad (_("two .function pseudo-ops with no intervening .ef")); ppc_last_function = sym; - if (sym->sy_tc.size != (symbolS *) NULL) + if (symbol_get_tc (sym)->size != (symbolS *) NULL) { - resolve_symbol_value (sym->sy_tc.size, 1); - SA_SET_SYM_FSIZE (sym, (long) S_GET_VALUE (sym->sy_tc.size)); + resolve_symbol_value (symbol_get_tc (sym)->size, 1); + SA_SET_SYM_FSIZE (sym, + (long) S_GET_VALUE (symbol_get_tc (sym)->size)); } } else if (S_GET_STORAGE_CLASS (sym) == C_FCN @@ -4093,7 +4109,7 @@ ppc_frob_symbol (sym) } if (! S_IS_EXTERNAL (sym) - && (sym->bsym->flags & BSF_SECTION_SYM) == 0 + && (symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) == 0 && S_GET_STORAGE_CLASS (sym) != C_FILE && S_GET_STORAGE_CLASS (sym) != C_FCN && S_GET_STORAGE_CLASS (sym) != C_BLOCK @@ -4113,39 +4129,39 @@ ppc_frob_symbol (sym) /* Create a csect aux. */ i = S_GET_NUMBER_AUXILIARY (sym); S_SET_NUMBER_AUXILIARY (sym, i + 1); - a = &coffsymbol (sym->bsym)->native[i + 1].u.auxent; - if (sym->sy_tc.class == XMC_TC0) + a = &coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].u.auxent; + if (symbol_get_tc (sym)->class == XMC_TC0) { /* This is the TOC table. */ know (strcmp (S_GET_NAME (sym), "TOC") == 0); a->x_csect.x_scnlen.l = 0; a->x_csect.x_smtyp = (2 << 3) | XTY_SD; } - else if (sym->sy_tc.subseg != 0) + else if (symbol_get_tc (sym)->subseg != 0) { /* This is a csect symbol. x_scnlen is the size of the csect. */ - if (sym->sy_tc.next == (symbolS *) NULL) + if (symbol_get_tc (sym)->next == (symbolS *) NULL) a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput, S_GET_SEGMENT (sym)) - S_GET_VALUE (sym)); else { - resolve_symbol_value (sym->sy_tc.next, 1); - a->x_csect.x_scnlen.l = (S_GET_VALUE (sym->sy_tc.next) + resolve_symbol_value (symbol_get_tc (sym)->next, 1); + a->x_csect.x_scnlen.l = (S_GET_VALUE (symbol_get_tc (sym)->next) - S_GET_VALUE (sym)); } - a->x_csect.x_smtyp = (sym->sy_tc.align << 3) | XTY_SD; + a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_SD; } else if (S_GET_SEGMENT (sym) == bss_section) { /* This is a common symbol. */ - a->x_csect.x_scnlen.l = sym->sy_frag->fr_offset; - a->x_csect.x_smtyp = (sym->sy_tc.align << 3) | XTY_CM; + a->x_csect.x_scnlen.l = symbol_get_frag (sym)->fr_offset; + a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM; if (S_IS_EXTERNAL (sym)) - sym->sy_tc.class = XMC_RW; + symbol_get_tc (sym)->class = XMC_RW; else - sym->sy_tc.class = XMC_BS; + symbol_get_tc (sym)->class = XMC_BS; } else if (S_GET_SEGMENT (sym) == absolute_section) { @@ -4153,8 +4169,8 @@ ppc_frob_symbol (sym) ppc_adjust_symtab. */ ppc_saw_abs = true; a->x_csect.x_smtyp = XTY_LD; - if (sym->sy_tc.class == -1) - sym->sy_tc.class = XMC_XO; + if (symbol_get_tc (sym)->class == -1) + symbol_get_tc (sym)->class = XMC_XO; } else if (! S_IS_DEFINED (sym)) { @@ -4162,17 +4178,17 @@ ppc_frob_symbol (sym) a->x_csect.x_scnlen.l = 0; a->x_csect.x_smtyp = XTY_ER; } - else if (sym->sy_tc.class == XMC_TC) + else if (symbol_get_tc (sym)->class == XMC_TC) { symbolS *next; /* This is a TOC definition. x_scnlen is the size of the TOC entry. */ next = symbol_next (sym); - while (next->sy_tc.class == XMC_TC0) + while (symbol_get_tc (next)->class == XMC_TC0) next = symbol_next (next); if (next == (symbolS *) NULL - || next->sy_tc.class != XMC_TC) + || symbol_get_tc (next)->class != XMC_TC) { if (ppc_after_toc_frag == (fragS *) NULL) a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput, @@ -4204,7 +4220,7 @@ ppc_frob_symbol (sym) abort (); /* Skip the initial dummy symbol. */ - csect = csect->sy_tc.next; + csect = symbol_get_tc (csect)->next; if (csect == (symbolS *) NULL) { @@ -4213,31 +4229,34 @@ ppc_frob_symbol (sym) } else { - while (csect->sy_tc.next != (symbolS *) NULL) + while (symbol_get_tc (csect)->next != (symbolS *) NULL) { - resolve_symbol_value (csect->sy_tc.next, 1); - if (S_GET_VALUE (csect->sy_tc.next) > S_GET_VALUE (sym)) + resolve_symbol_value (symbol_get_tc (csect)->next, 1); + if (S_GET_VALUE (symbol_get_tc (csect)->next) + > S_GET_VALUE (sym)) break; - csect = csect->sy_tc.next; + csect = symbol_get_tc (csect)->next; } - a->x_csect.x_scnlen.p = coffsymbol (csect->bsym)->native; - coffsymbol (sym->bsym)->native[i + 1].fix_scnlen = 1; + a->x_csect.x_scnlen.p = + coffsymbol (symbol_get_bfdsym (csect))->native; + coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].fix_scnlen = + 1; } a->x_csect.x_smtyp = XTY_LD; } a->x_csect.x_parmhash = 0; a->x_csect.x_snhash = 0; - if (sym->sy_tc.class == -1) + if (symbol_get_tc (sym)->class == -1) a->x_csect.x_smclas = XMC_PR; else - a->x_csect.x_smclas = sym->sy_tc.class; + a->x_csect.x_smclas = symbol_get_tc (sym)->class; a->x_csect.x_stab = 0; a->x_csect.x_snstab = 0; /* Don't let the COFF backend resort these symbols. */ - sym->bsym->flags |= BSF_NOT_AT_END; + symbol_get_bfdsym (sym)->flags |= BSF_NOT_AT_END; } else if (S_GET_STORAGE_CLASS (sym) == C_BSTAT) { @@ -4245,8 +4264,10 @@ ppc_frob_symbol (sym) csect symbol. BFD will do that for us if we set the right flags. */ S_SET_VALUE (sym, - (valueT) coffsymbol (sym->sy_tc.within->bsym)->native); - coffsymbol (sym->bsym)->native->fix_value = 1; + ((valueT) + coffsymbol (symbol_get_bfdsym + (symbol_get_tc (sym)->within))->native)); + coffsymbol (symbol_get_bfdsym (sym))->native->fix_value = 1; } else if (S_GET_STORAGE_CLASS (sym) == C_STSYM) { @@ -4254,8 +4275,8 @@ ppc_frob_symbol (sym) symbolS *csect; /* The value is the offset from the enclosing csect. */ - block = sym->sy_tc.within; - csect = block->sy_tc.within; + block = symbol_get_tc (sym)->within; + csect = symbol_get_tc (block)->within; resolve_symbol_value (csect, 1); S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect)); } @@ -4265,7 +4286,7 @@ ppc_frob_symbol (sym) /* We want the value to be a file offset into the line numbers. BFD will do that for us if we set the right flags. We have already set the value correctly. */ - coffsymbol (sym->bsym)->native->fix_line = 1; + coffsymbol (symbol_get_bfdsym (sym))->native->fix_line = 1; } return 0; @@ -4293,11 +4314,11 @@ ppc_adjust_symtab () csect = symbol_create (".abs[XO]", absolute_section, S_GET_VALUE (sym), &zero_address_frag); - csect->bsym->value = S_GET_VALUE (sym); + symbol_get_bfdsym (csect)->value = S_GET_VALUE (sym); S_SET_STORAGE_CLASS (csect, C_HIDEXT); i = S_GET_NUMBER_AUXILIARY (csect); S_SET_NUMBER_AUXILIARY (csect, i + 1); - a = &coffsymbol (csect->bsym)->native[i + 1].u.auxent; + a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1].u.auxent; a->x_csect.x_scnlen.l = 0; a->x_csect.x_smtyp = XTY_SD; a->x_csect.x_parmhash = 0; @@ -4309,9 +4330,9 @@ ppc_adjust_symtab () symbol_insert (csect, sym, &symbol_rootP, &symbol_lastP); i = S_GET_NUMBER_AUXILIARY (sym); - a = &coffsymbol (sym->bsym)->native[i].u.auxent; - a->x_csect.x_scnlen.p = coffsymbol (csect->bsym)->native; - coffsymbol (sym->bsym)->native[i].fix_scnlen = 1; + a = &coffsymbol (symbol_get_bfdsym (sym))->native[i].u.auxent; + a->x_csect.x_scnlen.p = coffsymbol (symbol_get_bfdsym (csect))->native; + coffsymbol (symbol_get_bfdsym (sym))->native[i].fix_scnlen = 1; } ppc_saw_abs = false; @@ -4420,8 +4441,8 @@ md_section_align (seg, addr) int md_estimate_size_before_relax (fragp, seg) - fragS *fragp; - asection *seg; + fragS *fragp ATTRIBUTE_UNUSED; + asection *seg ATTRIBUTE_UNUSED; { abort (); return 0; @@ -4431,9 +4452,9 @@ md_estimate_size_before_relax (fragp, seg) void md_convert_frag (abfd, sec, fragp) - bfd *abfd; - asection *sec; - fragS *fragp; + bfd *abfd ATTRIBUTE_UNUSED; + asection *sec ATTRIBUTE_UNUSED; + fragS *fragp ATTRIBUTE_UNUSED; { abort (); } @@ -4443,7 +4464,7 @@ md_convert_frag (abfd, sec, fragp) /*ARGSUSED*/ symbolS * md_undefined_symbol (name) - char *name; + char *name ATTRIBUTE_UNUSED; { return 0; } @@ -4456,7 +4477,7 @@ md_undefined_symbol (name) long md_pcrel_from_section (fixp, sec) fixS *fixp; - segT sec; + segT sec ATTRIBUTE_UNUSED; { return fixp->fx_frag->fr_address + fixp->fx_where; } @@ -4490,9 +4511,9 @@ ppc_fix_adjustable (fix) sy != (symbolS *) NULL; sy = symbol_next (sy)) { - if (sy->sy_tc.class == XMC_TC0) + if (symbol_get_tc (sy)->class == XMC_TC0) continue; - if (sy->sy_tc.class != XMC_TC) + if (symbol_get_tc (sy)->class != XMC_TC) break; resolve_symbol_value (sy, 1); if (val == S_GET_VALUE (sy)) @@ -4509,9 +4530,9 @@ ppc_fix_adjustable (fix) /* Possibly adjust the reloc to be against the csect. */ if (fix->fx_addsy != (symbolS *) NULL - && fix->fx_addsy->sy_tc.subseg == 0 - && fix->fx_addsy->sy_tc.class != XMC_TC0 - && fix->fx_addsy->sy_tc.class != XMC_TC + && symbol_get_tc (fix->fx_addsy)->subseg == 0 + && symbol_get_tc (fix->fx_addsy)->class != XMC_TC0 + && symbol_get_tc (fix->fx_addsy)->class != XMC_TC && S_GET_SEGMENT (fix->fx_addsy) != bss_section /* Don't adjust if this is a reloc in the toc section. */ && (S_GET_SEGMENT (fix->fx_addsy) != data_section @@ -4530,29 +4551,28 @@ ppc_fix_adjustable (fix) abort (); /* Skip the initial dummy symbol. */ - csect = csect->sy_tc.next; + csect = symbol_get_tc (csect)->next; if (csect != (symbolS *) NULL) { - while (csect->sy_tc.next != (symbolS *) NULL - && (csect->sy_tc.next->sy_frag->fr_address - <= fix->fx_addsy->sy_frag->fr_address)) + while (symbol_get_tc (csect)->next != (symbolS *) NULL + && (symbol_get_frag (symbol_get_tc (csect)->next)->fr_address + <= val)) { /* If the csect address equals the symbol value, then we have to look through the full symbol table to see whether this is the csect we want. Note that we will only get here if the csect has zero length. */ - if ((csect->sy_frag->fr_address - == fix->fx_addsy->sy_frag->fr_address) + if ((symbol_get_frag (csect)->fr_address == val) && S_GET_VALUE (csect) == S_GET_VALUE (fix->fx_addsy)) { symbolS *scan; - for (scan = csect->sy_next; + for (scan = symbol_next (csect); scan != NULL; - scan = scan->sy_next) + scan = symbol_next (scan)) { - if (scan->sy_tc.subseg != 0) + if (symbol_get_tc (scan)->subseg != 0) break; if (scan == fix->fx_addsy) break; @@ -4564,11 +4584,11 @@ ppc_fix_adjustable (fix) break; } - csect = csect->sy_tc.next; + csect = symbol_get_tc (csect)->next; } fix->fx_offset += (S_GET_VALUE (fix->fx_addsy) - - csect->sy_frag->fr_address); + - symbol_get_frag (csect)->fr_address); fix->fx_addsy = csect; } } @@ -4579,10 +4599,11 @@ ppc_fix_adjustable (fix) && S_GET_SEGMENT (fix->fx_addsy) == bss_section && ! S_IS_EXTERNAL (fix->fx_addsy)) { - resolve_symbol_value (fix->fx_addsy->sy_frag->fr_symbol, 1); - fix->fx_offset += (S_GET_VALUE (fix->fx_addsy) - - S_GET_VALUE (fix->fx_addsy->sy_frag->fr_symbol)); - fix->fx_addsy = fix->fx_addsy->sy_frag->fr_symbol; + resolve_symbol_value (symbol_get_frag (fix->fx_addsy)->fr_symbol, 1); + fix->fx_offset += + (S_GET_VALUE (fix->fx_addsy) + - S_GET_VALUE (symbol_get_frag (fix->fx_addsy)->fr_symbol)); + fix->fx_addsy = symbol_get_frag (fix->fx_addsy)->fr_symbol; } return 0; @@ -4602,10 +4623,11 @@ ppc_force_relocation (fix) we need to force the relocation. */ if (fix->fx_pcrel && fix->fx_addsy != NULL - && fix->fx_addsy->sy_tc.subseg != 0 - && (fix->fx_addsy->sy_frag->fr_address > fix->fx_frag->fr_address - || (fix->fx_addsy->sy_tc.next != NULL - && (fix->fx_addsy->sy_tc.next->sy_frag->fr_address + && symbol_get_tc (fix->fx_addsy)->subseg != 0 + && ((symbol_get_frag (fix->fx_addsy)->fr_address + > fix->fx_frag->fr_address) + || (symbol_get_tc (fix->fx_addsy)->next != NULL + && (symbol_get_frag (symbol_get_tc (fix->fx_addsy)->next)->fr_address <= fix->fx_frag->fr_address)))) return 1; @@ -4621,7 +4643,7 @@ ppc_is_toc_sym (sym) symbolS *sym; { #ifdef OBJ_XCOFF - return sym->sy_tc.class == XMC_TC; + return symbol_get_tc (sym)->class == XMC_TC; #else return strcmp (segment_name (S_GET_SEGMENT (sym)), ".got") == 0; #endif @@ -4650,7 +4672,7 @@ md_apply_fix3 (fixp, valuep, seg) { /* `*valuep' may contain the value of the symbol on which the reloc will be based; we have to remove it. */ - if (fixp->fx_addsy->sy_used_in_reloc + if (symbol_used_in_reloc_p (fixp->fx_addsy) && S_GET_SEGMENT (fixp->fx_addsy) != absolute_section && S_GET_SEGMENT (fixp->fx_addsy) != undefined_section && ! bfd_is_com_section (S_GET_SEGMENT (fixp->fx_addsy))) @@ -4725,9 +4747,9 @@ md_apply_fix3 (fixp, valuep, seg) && operand->shift == 0 && operand->insert == NULL && fixp->fx_addsy != NULL - && fixp->fx_addsy->sy_tc.subseg != 0 - && fixp->fx_addsy->sy_tc.class != XMC_TC - && fixp->fx_addsy->sy_tc.class != XMC_TC0 + && symbol_get_tc (fixp->fx_addsy)->subseg != 0 + && symbol_get_tc (fixp->fx_addsy)->class != XMC_TC + && symbol_get_tc (fixp->fx_addsy)->class != XMC_TC0 && S_GET_SEGMENT (fixp->fx_addsy) != bss_section) { value = fixp->fx_offset; @@ -4881,7 +4903,7 @@ md_apply_fix3 (fixp, valuep, seg) if (fixp->fx_pcrel) abort (); md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, - value + 0x8000 >> 16, 2); + (value + 0x8000) >> 16, 2); break; /* Because SDA21 modifies the register field, the size is set to 4 @@ -4981,14 +5003,15 @@ md_apply_fix3 (fixp, valuep, seg) arelent * tc_gen_reloc (seg, fixp) - asection *seg; + asection *seg ATTRIBUTE_UNUSED; fixS *fixp; { arelent *reloc; reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); if (reloc->howto == (reloc_howto_type *) NULL) diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index 0871d13..783a215 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -1,5 +1,6 @@ /* tc-ppc.h -- Header file for tc-ppc.c. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GAS, the GNU Assembler. @@ -121,7 +122,7 @@ extern int ppc_pe_fix_adjustable PARAMS ((struct fix *)); struct ppc_tc_sy { /* We keep a few linked lists of symbols. */ - struct symbol *next; + symbolS *next; /* Non-zero if the symbol should be output. The RS/6000 assembler only outputs symbols that are external or are mentioned in a .globl or .lglobl statement. */ @@ -137,11 +138,11 @@ struct ppc_tc_sy int align; /* For a function symbol, a symbol whose value is the size. The field is NULL if there is no size. */ - struct symbol *size; + symbolS *size; /* For a csect symbol, the last symbol which has been defined in this csect, or NULL if none have been defined so far. For a .bs symbol, the referenced csect symbol. */ - struct symbol *within; + symbolS *within; }; #define TC_SYMFIELD_TYPE struct ppc_tc_sy @@ -158,11 +159,11 @@ extern char *ppc_canonicalize_symbol_name PARAMS ((char *)); /* Get the symbol class from the name. */ #define tc_symbol_new_hook(sym) ppc_symbol_new_hook (sym) -extern void ppc_symbol_new_hook PARAMS ((struct symbol *)); +extern void ppc_symbol_new_hook PARAMS ((symbolS *)); /* Set the symbol class of a label based on the csect. */ #define tc_frob_label(sym) ppc_frob_label (sym) -extern void ppc_frob_label PARAMS ((struct symbol *)); +extern void ppc_frob_label PARAMS ((symbolS *)); /* TOC relocs requires special handling. */ #define tc_fix_adjustable(fixp) ppc_fix_adjustable (fixp) @@ -178,7 +179,7 @@ extern void ppc_frob_section PARAMS ((asection *)); /* Finish up the symbol. */ #define tc_frob_symbol(sym, punt) punt = ppc_frob_symbol (sym) -extern int ppc_frob_symbol PARAMS ((struct symbol *)); +extern int ppc_frob_symbol PARAMS ((symbolS *)); /* Finish up the entire symtab. */ #define tc_adjust_symtab() ppc_adjust_symtab () @@ -187,6 +188,19 @@ extern void ppc_adjust_symtab PARAMS ((void)); /* Niclas Andersson says this is needed. */ #define SUB_SEGMENT_ALIGN(SEG) 2 +/* We also need to copy, in particular, the class of the symbol, + over what obj-coff would otherwise have copied. */ +#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src) \ +do { \ + if (SF_GET_GET_SEGMENT (dest)) \ + S_SET_SEGMENT (dest, S_GET_SEGMENT (src)); \ + symbol_get_tc (dest)->size = symbol_get_tc (src)->size; \ + symbol_get_tc (dest)->align = symbol_get_tc (src)->align; \ + symbol_get_tc (dest)->class = symbol_get_tc (src)->class; \ + symbol_get_tc (dest)->within = symbol_get_tc (src)->within; \ +} while (0) + + #endif /* OBJ_XCOFF */ #ifdef OBJ_ELF @@ -203,18 +217,18 @@ extern void ppc_adjust_symtab PARAMS ((void)); #define TC_FORCE_RELOCATION_SECTION(FIXP,SEC) \ (TC_FORCE_RELOCATION (FIXP) \ - || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy && (FIXP)->fx_addsy->bsym \ - && (FIXP)->fx_addsy->bsym->section != SEC)) + || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy \ + && S_GET_SEGMENT ((FIXP)->fx_addsy) != SEC)) /* Support for SHF_EXCLUDE and SHT_ORDERED */ extern int ppc_section_letter PARAMS ((int, char **)); -extern int ppc_section_type PARAMS ((char **)); -extern int ppc_section_word PARAMS ((char **)); +extern int ppc_section_type PARAMS ((char *, size_t)); +extern int ppc_section_word PARAMS ((char *, size_t)); extern int ppc_section_flags PARAMS ((int, int, int)); #define md_elf_section_letter(LETTER, PTR_MSG) ppc_section_letter (LETTER, PTR_MSG) -#define md_elf_section_type(PTR_STR) ppc_section_type (PTR_STR) -#define md_elf_section_word(PTR_STR) ppc_section_word (PTR_STR) +#define md_elf_section_type(STR, LEN) ppc_section_type (STR, LEN) +#define md_elf_section_word(STR, LEN) ppc_section_word (STR, LEN) #define md_elf_section_flags(FLAGS, ATTR, TYPE) ppc_section_flags (FLAGS, ATTR, TYPE) /* Add extra PPC sections -- Note, for now, make .sbss2 and .PPC.EMB.sbss0 a @@ -247,8 +261,7 @@ extern const char *ppc_comment_chars; || ((FIX)->fx_subsy != NULL \ && (S_GET_SEGMENT ((FIX)->fx_subsy) \ == S_GET_SEGMENT ((FIX)->fx_addsy))) \ - || strchr (S_GET_NAME ((FIX)->fx_addsy), '\001') != NULL \ - || strchr (S_GET_NAME ((FIX)->fx_addsy), '\002') != NULL)) + || S_IS_LOCAL ((FIX)->fx_addsy))) /* We must never ever try to resolve references to externally visible symbols in the assembler, because the .o file might go into a shared diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 6d8ca81..4003f5b 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -1,5 +1,5 @@ /* tc-sh.c -- Assemble code for the Hitachi Super-H - Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -30,6 +30,11 @@ #define DEFINE_TABLE #include "opcodes/sh-opc.h" #include + +#ifdef OBJ_ELF +#include "elf/sh.h" +#endif + const char comment_chars[] = "!"; const char line_separator_chars[] = ";"; const char line_comment_chars[] = "!#"; @@ -39,16 +44,11 @@ static void s_uses PARAMS ((int)); static void sh_count_relocs PARAMS ((bfd *, segT, PTR)); static void sh_frob_section PARAMS ((bfd *, segT, PTR)); -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ - void cons (); void s_align_bytes (); static void s_uacons PARAMS ((int)); +static sh_opcode_info *find_cooked_opcode PARAMS ((char **)); +static void assemble_ppi PARAMS ((char *, sh_opcode_info *)); int shl = 0; @@ -60,6 +60,13 @@ little (ignore) target_big_endian = 0; } +/* This table describes all the machine specific pseudo-ops the assembler + has to support. The fields are: + pseudo-op name without dot + function to call to execute this pseudo-op + Integer arg to pass to the function + */ + const pseudo_typeS md_pseudo_table[] = { {"int", cons, 4}, @@ -84,6 +91,14 @@ int sh_relax; /* set if -relax seen */ int sh_small; +/* Whether -dsp was seen. */ + +static int sh_dsp; + +/* The bit mask of architectures that could + accomodate the insns seen so far. */ +static int valid_arch; + const char EXP_CHARS[] = "eE"; /* Chars that mean this number is a floating point constant */ @@ -189,9 +204,18 @@ md_begin () { sh_opcode_info *opcode; char *prev_name = ""; + int target_arch; +#ifdef TE_PE + /* The WinCE OS only supports little endian executables. */ + target_big_endian = 0; +#else if (! shl) target_big_endian = 1; +#endif + + target_arch = arch_sh1_up & ~(sh_dsp ? arch_sh3e_up : arch_sh_dsp_up); + valid_arch = target_arch; opcode_hash_control = hash_new (); @@ -200,6 +224,8 @@ md_begin () { if (strcmp (prev_name, opcode->name)) { + if (! (opcode->arch & target_arch)) + continue; prev_name = opcode->name; hash_insert (opcode_hash_control, opcode->name, (char *) opcode); } @@ -214,6 +240,8 @@ md_begin () static int reg_m; static int reg_n; +static int reg_x, reg_y; +static int reg_efg; static int reg_b; static expressionS immediate; /* absolute expression */ @@ -226,6 +254,8 @@ typedef struct sh_operand_info; +#define IDENT_CHAR(c) (isalnum (c) || (c) == '_') + /* try and parse a reg name, returns number of chars consumed */ static int parse_reg (src, mode, reg) @@ -233,109 +263,227 @@ parse_reg (src, mode, reg) int *mode; int *reg; { - /* We use !isalnum for the next character after the register name, to + /* We use ! IDENT_CHAR for the next character after the register name, to make sure that we won't accidentally recognize a symbol name such as - 'sram' as being a reference to the register 'sr'. */ + 'sram' or sr_ram as being a reference to the register 'sr'. */ if (src[0] == 'r') { - if (src[1] >= '0' && src[1] <= '7' && strncmp(&src[2], "_bank", 5) == 0 - && ! isalnum ((unsigned char) src[7])) + if (src[1] == '1') + { + if (src[2] >= '0' && src[2] <= '5' + && ! IDENT_CHAR ((unsigned char) src[3])) + { + *mode = A_REG_N; + *reg = 10 + src[2] - '0'; + return 3; + } + } + if (src[1] >= '0' && src[1] <= '9' + && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = A_REG_N; + *reg = (src[1] - '0'); + return 2; + } + if (src[1] >= '0' && src[1] <= '7' && strncmp (&src[2], "_bank", 5) == 0 + && ! IDENT_CHAR ((unsigned char) src[7])) { *mode = A_REG_B; *reg = (src[1] - '0'); return 7; } + + if (src[1] == 'e' && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = A_RE; + return 2; + } + if (src[1] == 's' && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = A_RS; + return 2; + } } - if (src[0] == 'r') + if (src[0] == 'a') { + if (src[1] == '0') + { + if (! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = DSP_REG_N; + *reg = A_A0_NUM; + return 2; + } + if (src[2] == 'g' && ! IDENT_CHAR ((unsigned char) src[3])) + { + *mode = DSP_REG_N; + *reg = A_A0G_NUM; + return 3; + } + } if (src[1] == '1') { - if (src[2] >= '0' && src[2] <= '5' - && ! isalnum ((unsigned char) src[3])) + if (! IDENT_CHAR ((unsigned char) src[2])) { - *mode = A_REG_N; - *reg = 10 + src[2] - '0'; + *mode = DSP_REG_N; + *reg = A_A1_NUM; + return 2; + } + if (src[2] == 'g' && ! IDENT_CHAR ((unsigned char) src[3])) + { + *mode = DSP_REG_N; + *reg = A_A1G_NUM; return 3; } } - if (src[1] >= '0' && src[1] <= '9' - && ! isalnum ((unsigned char) src[2])) + + if (src[1] == 'x' && src[2] >= '0' && src[2] <= '1' + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_REG_N; - *reg = (src[1] - '0'); + *reg = 4 + (src[1] - '0'); + return 3; + } + if (src[1] == 'y' && src[2] >= '0' && src[2] <= '1' + && ! IDENT_CHAR ((unsigned char) src[3])) + { + *mode = A_REG_N; + *reg = 6 + (src[1] - '0'); + return 3; + } + if (src[1] == 's' && src[2] >= '0' && src[2] <= '3' + && ! IDENT_CHAR ((unsigned char) src[3])) + { + int n = src[1] - '0'; + + *mode = A_REG_N; + *reg = n | ((~n & 2) << 1); + return 3; + } + } + + if (src[0] == 'i' && src[1] && ! IDENT_CHAR ((unsigned char) src[3])) + { + if (src[1] == 's') + { + *mode = A_REG_N; + *reg = 8; return 2; } + if (src[1] == 'x') + { + *mode = A_REG_N; + *reg = 8; + return 2; + } + if (src[1] == 'y') + { + *mode = A_REG_N; + *reg = 9; + return 2; + } + } + + if (src[0] == 'x' && src[1] >= '0' && src[1] <= '1' + && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = DSP_REG_N; + *reg = A_X0_NUM + src[1] - '0'; + return 2; + } + + if (src[0] == 'y' && src[1] >= '0' && src[1] <= '1' + && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = DSP_REG_N; + *reg = A_Y0_NUM + src[1] - '0'; + return 2; + } + + if (src[0] == 'm' && src[1] >= '0' && src[1] <= '1' + && ! IDENT_CHAR ((unsigned char) src[2])) + { + *mode = DSP_REG_N; + *reg = src[1] == '0' ? A_M0_NUM : A_M1_NUM; + return 2; } if (src[0] == 's' && src[1] == 's' - && src[2] == 'r' && ! isalnum ((unsigned char) src[3])) + && src[2] == 'r' && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_SSR; return 3; } if (src[0] == 's' && src[1] == 'p' && src[2] == 'c' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_SPC; return 3; } if (src[0] == 's' && src[1] == 'g' && src[2] == 'r' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_SGR; return 3; } + if (src[0] == 'd' && src[1] == 's' && src[2] == 'r' + && ! IDENT_CHAR ((unsigned char) src[3])) + { + *mode = A_DSR; + return 3; + } + if (src[0] == 'd' && src[1] == 'b' && src[2] == 'r' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_DBR; return 3; } - if (src[0] == 's' && src[1] == 'r' && ! isalnum ((unsigned char) src[2])) + if (src[0] == 's' && src[1] == 'r' && ! IDENT_CHAR ((unsigned char) src[2])) { *mode = A_SR; return 2; } - if (src[0] == 's' && src[1] == 'p' && ! isalnum ((unsigned char) src[2])) + if (src[0] == 's' && src[1] == 'p' && ! IDENT_CHAR ((unsigned char) src[2])) { *mode = A_REG_N; *reg = 15; return 2; } - if (src[0] == 'p' && src[1] == 'r' && ! isalnum ((unsigned char) src[2])) + if (src[0] == 'p' && src[1] == 'r' && ! IDENT_CHAR ((unsigned char) src[2])) { *mode = A_PR; return 2; } - if (src[0] == 'p' && src[1] == 'c' && ! isalnum ((unsigned char) src[2])) + if (src[0] == 'p' && src[1] == 'c' && ! IDENT_CHAR ((unsigned char) src[2])) { *mode = A_DISP_PC; return 2; } if (src[0] == 'g' && src[1] == 'b' && src[2] == 'r' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_GBR; return 3; } if (src[0] == 'v' && src[1] == 'b' && src[2] == 'r' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = A_VBR; return 3; } if (src[0] == 'm' && src[1] == 'a' && src[2] == 'c' - && ! isalnum ((unsigned char) src[4])) + && ! IDENT_CHAR ((unsigned char) src[4])) { if (src[3] == 'l') { @@ -348,12 +496,18 @@ parse_reg (src, mode, reg) return 4; } } + if (src[0] == 'm' && src[1] == 'o' && src[2] == 'd' + && ! IDENT_CHAR ((unsigned char) src[4])) + { + *mode = A_MOD; + return 3; + } if (src[0] == 'f' && src[1] == 'r') { if (src[2] == '1') { if (src[3] >= '0' && src[3] <= '5' - && ! isalnum ((unsigned char) src[4])) + && ! IDENT_CHAR ((unsigned char) src[4])) { *mode = F_REG_N; *reg = 10 + src[3] - '0'; @@ -361,7 +515,7 @@ parse_reg (src, mode, reg) } } if (src[2] >= '0' && src[2] <= '9' - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = F_REG_N; *reg = (src[2] - '0'); @@ -373,7 +527,7 @@ parse_reg (src, mode, reg) if (src[2] == '1') { if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1) - && ! isalnum ((unsigned char) src[4])) + && ! IDENT_CHAR ((unsigned char) src[4])) { *mode = D_REG_N; *reg = 10 + src[3] - '0'; @@ -381,7 +535,7 @@ parse_reg (src, mode, reg) } } if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1) - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = D_REG_N; *reg = (src[2] - '0'); @@ -393,7 +547,7 @@ parse_reg (src, mode, reg) if (src[2] == '1') { if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1) - && ! isalnum ((unsigned char) src[4])) + && ! IDENT_CHAR ((unsigned char) src[4])) { *mode = X_REG_N; *reg = 11 + src[3] - '0'; @@ -401,7 +555,7 @@ parse_reg (src, mode, reg) } } if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1) - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = X_REG_N; *reg = (src[2] - '0') + 1; @@ -410,14 +564,14 @@ parse_reg (src, mode, reg) } if (src[0] == 'f' && src[1] == 'v') { - if (src[2] == '1'&& src[3] == '2' && ! isalnum ((unsigned char) src[4])) + if (src[2] == '1'&& src[3] == '2' && ! IDENT_CHAR ((unsigned char) src[4])) { *mode = V_REG_N; *reg = 12; return 4; } if ((src[2] == '0' || src[2] == '4' || src[2] == '8') - && ! isalnum ((unsigned char) src[3])) + && ! IDENT_CHAR ((unsigned char) src[3])) { *mode = V_REG_N; *reg = (src[2] - '0'); @@ -425,21 +579,21 @@ parse_reg (src, mode, reg) } } if (src[0] == 'f' && src[1] == 'p' && src[2] == 'u' && src[3] == 'l' - && ! isalnum ((unsigned char) src[4])) + && ! IDENT_CHAR ((unsigned char) src[4])) { *mode = FPUL_N; return 4; } if (src[0] == 'f' && src[1] == 'p' && src[2] == 's' && src[3] == 'c' - && src[4] == 'r' && ! isalnum ((unsigned char) src[5])) + && src[4] == 'r' && ! IDENT_CHAR ((unsigned char) src[5])) { *mode = FPSCR_N; return 5; } if (src[0] == 'x' && src[1] == 'm' && src[2] == 't' && src[3] == 'r' - && src[4] == 'x' && ! isalnum ((unsigned char) src[5])) + && src[4] == 'x' && ! IDENT_CHAR ((unsigned char) src[5])) { *mode = XMTRX_M4; return 5; @@ -605,8 +759,21 @@ parse_at (src, op) } if (src[0] == '+') { - op->type = A_INC_N; src++; + if ((src[0] == 'r' && src[1] == '8') + || (src[0] == 'i' && (src[1] == 'x' || src[1] == 's'))) + { + src += 2; + op->type = A_PMOD_N; + } + if ((src[0] == 'r' && src[1] == '9') + || (src[0] == 'i' && src[1] == 'y')) + { + src += 2; + op->type = A_PMODY_N; + } + else + op->type = A_INC_N; } else { @@ -665,7 +832,11 @@ get_operands (info, args, operand) char *ptr = args; if (info->arg[0]) { - ptr++; + /* The pre-processor will eliminate whitespace in front of '@' + after the first argument; we may be called multiple times + from assemble_ppi, so don't insist on finding whitespace here. */ + if (*ptr == ' ') + ptr++; get_operand (&ptr, operand + 0); if (info->arg[1]) @@ -774,16 +945,14 @@ get_specific (opcode, operands) case V_REG_N: case FPUL_N: case FPSCR_N: + case A_PMOD_N: + case A_PMODY_N: + case DSP_REG_N: /* Opcode needs rn */ if (user->type != arg) goto fail; reg_n = user->reg; break; - case FD_REG_N: - if (user->type != F_REG_N && user->type != D_REG_N) - goto fail; - reg_n = user->reg; - break; case DX_REG_N: if (user->type != D_REG_N && user->type != X_REG_N) goto fail; @@ -792,6 +961,10 @@ get_specific (opcode, operands) case A_GBR: case A_SR: case A_VBR: + case A_DSR: + case A_MOD: + case A_RE: + case A_RS: case A_SSR: case A_SPC: case A_SGR: @@ -812,12 +985,144 @@ get_specific (opcode, operands) case A_IND_M: case A_IND_R0_REG_M: case A_DISP_REG_M: + case DSP_REG_M: /* Opcode needs rn */ if (user->type != arg - A_REG_M + A_REG_N) goto fail; reg_m = user->reg; break; + case DSP_REG_X: + if (user->type != DSP_REG_N) + goto fail; + switch (user->reg) + { + case A_X0_NUM: + reg_x = 0; + break; + case A_X1_NUM: + reg_x = 1; + break; + case A_A0_NUM: + reg_x = 2; + break; + case A_A1_NUM: + reg_x = 3; + break; + default: + goto fail; + } + break; + + case DSP_REG_Y: + if (user->type != DSP_REG_N) + goto fail; + switch (user->reg) + { + case A_Y0_NUM: + reg_y = 0; + break; + case A_Y1_NUM: + reg_y = 1; + break; + case A_M0_NUM: + reg_y = 2; + break; + case A_M1_NUM: + reg_y = 3; + break; + default: + goto fail; + } + break; + + case DSP_REG_E: + if (user->type != DSP_REG_N) + goto fail; + switch (user->reg) + { + case A_X0_NUM: + reg_efg = 0 << 10; + break; + case A_X1_NUM: + reg_efg = 1 << 10; + break; + case A_Y0_NUM: + reg_efg = 2 << 10; + break; + case A_A1_NUM: + reg_efg = 3 << 10; + break; + default: + goto fail; + } + break; + + case DSP_REG_F: + if (user->type != DSP_REG_N) + goto fail; + switch (user->reg) + { + case A_Y0_NUM: + reg_efg |= 0 << 8; + break; + case A_Y1_NUM: + reg_efg |= 1 << 8; + break; + case A_X0_NUM: + reg_efg |= 2 << 8; + break; + case A_A1_NUM: + reg_efg |= 3 << 8; + break; + default: + goto fail; + } + break; + + case DSP_REG_G: + if (user->type != DSP_REG_N) + goto fail; + switch (user->reg) + { + case A_M0_NUM: + reg_efg |= 0 << 2; + break; + case A_M1_NUM: + reg_efg |= 1 << 2; + break; + case A_A0_NUM: + reg_efg |= 2 << 2; + break; + case A_A1_NUM: + reg_efg |= 3 << 2; + break; + default: + goto fail; + } + break; + + case A_A0: + if (user->type != DSP_REG_N || user->reg != A_A0_NUM) + goto fail; + break; + case A_X0: + if (user->type != DSP_REG_N || user->reg != A_X0_NUM) + goto fail; + break; + case A_X1: + if (user->type != DSP_REG_N || user->reg != A_X1_NUM) + goto fail; + break; + case A_Y0: + if (user->type != DSP_REG_N || user->reg != A_Y0_NUM) + goto fail; + break; + case A_Y1: + if (user->type != DSP_REG_N || user->reg != A_Y1_NUM) + goto fail; + break; + case F_REG_M: case D_REG_M: case X_REG_M: @@ -845,6 +1150,9 @@ get_specific (opcode, operands) goto fail; } } + if ( !(valid_arch & this_try->arch)) + goto fail; + valid_arch &= this_try->arch; return this_try; fail:; } @@ -949,6 +1257,11 @@ build_Mytes (opcode, operand) case REG_M: nbuf[index] = reg_m; break; + case SDT_REG_N: + if (reg_n < 2 || reg_n > 5) + as_bad (_("Invalid register: 'r%d'"), reg_n); + nbuf[index] = (reg_n & 3) | 4; + break; case REG_NM: nbuf[index] = reg_n | (reg_m >> 2); break; @@ -997,50 +1310,274 @@ build_Mytes (opcode, operand) } } -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. - */ +/* Find an opcode at the start of *STR_P in the hash table, and set + *STR_P to the first character after the last one read. */ -void -md_assemble (str) - char *str; +static sh_opcode_info * +find_cooked_opcode (str_p) + char **str_p; { + char *str = *str_p; unsigned char *op_start; unsigned char *op_end; - sh_operand_info operand[3]; - sh_opcode_info *opcode; char name[20]; int nlen = 0; /* Drop leading whitespace */ while (*str == ' ') str++; - /* find the op code end */ + /* Find the op code end. + The pre-processor will eliminate whitespace in front of + any '@' after the first argument; we may be called from + assemble_ppi, so the opcode might be terminated by an '@'. */ for (op_start = op_end = (unsigned char *) (str); *op_end && nlen < 20 - && !is_end_of_line[*op_end] && *op_end != ' '; + && !is_end_of_line[*op_end] && *op_end != ' ' && *op_end != '@'; op_end++) { unsigned char c = op_start[nlen]; /* The machine independent code will convert CMP/EQ into cmp/EQ - because it thinks the '/' is the end of the symbol. Instead of - hacking up the machine independent code, we just deal with it - here. */ + because it thinks the '/' is the end of the symbol. Moreover, + all but the first sub-insn is a parallel processing insn won't + be capitailzed. Instead of hacking up the machine independent + code, we just deal with it here. */ c = isupper (c) ? tolower (c) : c; name[nlen] = c; nlen++; } name[nlen] = 0; + *str_p = op_end; if (nlen == 0) { as_bad (_("can't find opcode ")); } - opcode = (sh_opcode_info *) hash_find (opcode_hash_control, name); + return (sh_opcode_info *) hash_find (opcode_hash_control, name); +} + +/* Assemble a parallel processing insn. */ +#define DDT_BASE 0xf000 /* Base value for double data transfer insns */ +static void +assemble_ppi (op_end, opcode) + char *op_end; + sh_opcode_info *opcode; +{ + int movx = 0; + int movy = 0; + int cond = 0; + int field_b = 0; + char *output; + int move_code; + + /* Some insn ignore one or more register fields, e.g. psts machl,a0. + Make sure we encode a defined insn pattern. */ + reg_x = 0; + reg_y = 0; + + for (;;) + { + sh_operand_info operand[3]; + + if (opcode->arg[0] != A_END) + op_end = get_operands (opcode, op_end, operand); + opcode = get_specific (opcode, operand); + if (opcode == 0) + { + /* Couldn't find an opcode which matched the operands */ + char *where = frag_more (2); + + where[0] = 0x0; + where[1] = 0x0; + as_bad (_("invalid operands for opcode")); + return; + } + if (opcode->nibbles[0] != PPI) + as_bad (_("insn can't be combined with parallel processing insn")); + + switch (opcode->nibbles[1]) + { + + case NOPX: + if (movx) + as_bad (_("multiple movx specifications")); + movx = DDT_BASE; + break; + case NOPY: + if (movy) + as_bad (_("multiple movy specifications")); + movy = DDT_BASE; + break; + + case MOVX: + if (movx) + as_bad (_("multiple movx specifications")); + if (reg_n < 4 || reg_n > 5) + as_bad (_("invalid movx address register")); + if (opcode->nibbles[2] & 8) + { + if (reg_m == A_A1_NUM) + movx = 1 << 7; + else if (reg_m != A_A0_NUM) + as_bad (_("invalid movx dsp register")); + } + else + { + if (reg_x > 1) + as_bad (_("invalid movx dsp register")); + movx = reg_x << 7; + } + movx += ((reg_n - 4) << 9) + (opcode->nibbles[2] << 2) + DDT_BASE; + break; + + case MOVY: + if (movy) + as_bad (_("multiple movy specifications")); + if (opcode->nibbles[2] & 8) + { + /* Bit 3 in nibbles[2] is intended for bit 4 of the opcode, + so add 8 more. */ + movy = 8; + if (reg_m == A_A1_NUM) + movy += 1 << 6; + else if (reg_m != A_A0_NUM) + as_bad (_("invalid movy dsp register")); + } + else + { + if (reg_y > 1) + as_bad (_("invalid movy dsp register")); + movy = reg_y << 6; + } + if (reg_n < 6 || reg_n > 7) + as_bad (_("invalid movy address register")); + movy += ((reg_n - 6) << 8) + opcode->nibbles[2] + DDT_BASE; + break; + + case PSH: + if (immediate.X_op != O_constant) + as_bad (_("dsp immediate shift value not constant")); + field_b = ((opcode->nibbles[2] << 12) + | (immediate.X_add_number & 127) << 4 + | reg_n); + break; + case PPI3: + if (field_b) + as_bad (_("multiple parallel processing specifications")); + field_b = ((opcode->nibbles[2] << 12) + (opcode->nibbles[3] << 8) + + (reg_x << 6) + (reg_y << 4) + reg_n); + break; + case PDC: + if (cond) + as_bad (_("multiple condition specifications")); + cond = opcode->nibbles[2] << 8; + if (*op_end) + goto skip_cond_check; + break; + case PPIC: + if (field_b) + as_bad (_("multiple parallel processing specifications")); + field_b = ((opcode->nibbles[2] << 12) + (opcode->nibbles[3] << 8) + + cond + (reg_x << 6) + (reg_y << 4) + reg_n); + cond = 0; + break; + case PMUL: + if (field_b) + { + if ((field_b & 0xef00) != 0xa100) + as_bad (_("insn cannot be combined with pmuls")); + field_b -= 0x8100; + switch (field_b & 0xf) + { + case A_X0_NUM: + field_b += 0 - A_X0_NUM; + break; + case A_Y0_NUM: + field_b += 1 - A_Y0_NUM; + break; + case A_A0_NUM: + field_b += 2 - A_A0_NUM; + break; + case A_A1_NUM: + field_b += 3 - A_A1_NUM; + break; + default: + as_bad (_("bad padd / psub pmuls output operand")); + } + } + field_b += 0x4000 + reg_efg; + break; + default: + abort (); + } + if (cond) + { + as_bad (_("condition not followed by conditionalizable insn")); + cond = 0; + } + if (! *op_end) + break; + skip_cond_check: + opcode = find_cooked_opcode (&op_end); + if (opcode == NULL) + { + (as_bad + (_("unrecognized characters at end of parallel processing insn"))); + break; + } + } + + move_code = movx | movy; + if (field_b) + { + /* Parallel processing insn. */ + unsigned long ppi_code = (movx | movy | 0xf800) << 16 | field_b; + + output = frag_more (4); + if (! target_big_endian) + { + output[3] = ppi_code >> 8; + output[2] = ppi_code; + } + else + { + output[2] = ppi_code >> 8; + output[3] = ppi_code; + } + move_code |= 0xf800; + } + else + /* Just a double data transfer. */ + output = frag_more (2); + if (! target_big_endian) + { + output[1] = move_code >> 8; + output[0] = move_code; + } + else + { + output[0] = move_code >> 8; + output[1] = move_code; + } +} + +/* This is the guts of the machine-dependent assembler. STR points to a + machine dependent instruction. This function is supposed to emit + the frags/bytes it assembles to. + */ + +void +md_assemble (str) + char *str; +{ + unsigned char *op_end; + sh_operand_info operand[3]; + sh_opcode_info *opcode; + + opcode = find_cooked_opcode (&str); + op_end = str; if (opcode == NULL) { @@ -1058,6 +1595,12 @@ md_assemble (str) seg_info (now_seg)->tc_segment_info_data.in_code = 1; } + if (opcode->nibbles[0] == PPI) + { + assemble_ppi (op_end, opcode); + return; + } + if (opcode->arg[0] == A_BDISP12 || opcode->arg[0] == A_BDISP8) { @@ -1066,9 +1609,16 @@ md_assemble (str) } else { - if (opcode->arg[0] != A_END) + if (opcode->arg[0] == A_END) + { + /* Ignore trailing whitespace. If there is any, it has already + been compressed to a single space. */ + if (*op_end == ' ') + op_end++; + } + else { - get_operands (opcode, op_end, operand); + op_end = get_operands (opcode, op_end, operand); } opcode = get_specific (opcode, operand); @@ -1083,6 +1633,9 @@ md_assemble (str) return; } + if (*op_end) + as_bad (_("excess operands: '%s'"), op_end); + build_Mytes (opcode, operand); } @@ -1136,6 +1689,7 @@ DEFUN (md_undefined_symbol, (name), } #ifdef OBJ_COFF +#ifndef BFD_ASSEMBLER void DEFUN (tc_crawl_symbol_chain, (headers), @@ -1152,6 +1706,7 @@ DEFUN (tc_headers_hook, (headers), } #endif +#endif /* Various routines to kill one day */ /* Equal to MAX_PRECISION in atof-ieee.c */ @@ -1247,10 +1802,12 @@ struct option md_longopts[] = { #define OPTION_RELAX (OPTION_MD_BASE) #define OPTION_LITTLE (OPTION_MD_BASE + 1) #define OPTION_SMALL (OPTION_LITTLE + 1) +#define OPTION_DSP (OPTION_SMALL + 1) {"relax", no_argument, NULL, OPTION_RELAX}, {"little", no_argument, NULL, OPTION_LITTLE}, {"small", no_argument, NULL, OPTION_SMALL}, + {"dsp", no_argument, NULL, OPTION_DSP}, {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof(md_longopts); @@ -1275,6 +1832,10 @@ md_parse_option (c, arg) sh_small = 1; break; + case OPTION_DSP: + sh_dsp = 1; + break; + default: return 0; } @@ -1290,7 +1851,8 @@ md_show_usage (stream) SH options:\n\ -little generate little endian code\n\ -relax alter jump instructions for long displacements\n\ --small align sections to 4 byte boundaries, not 16\n")); +-small align sections to 4 byte boundaries, not 16\n\ +-dsp enable sh-dsp insns, and disable sh3e / sh4 insns.\n")); } void @@ -1450,7 +2012,8 @@ sh_frob_section (abfd, sec, ignore) We have already adjusted the value of sym to include the fragment address, so we undo that adjustment here. */ subseg_change (sec, 0); - fix_new (sym->sy_frag, S_GET_VALUE (sym) - sym->sy_frag->fr_address, + fix_new (symbol_get_frag (sym), + S_GET_VALUE (sym) - symbol_get_frag (sym)->fr_address, 4, &abs_symbol, info.count, 0, BFD_RELOC_SH_COUNT); } } @@ -1875,6 +2438,33 @@ sh_fix_adjustable (fixP) return 1; } + +void sh_elf_final_processing() +{ + int val; + + /* Set file-specific flags to indicate if this code needs + a processor with the sh-dsp / sh3e ISA to execute. */ + if (valid_arch & arch_sh1) + val = EF_SH1; + else if (valid_arch & arch_sh2) + val = EF_SH2; + else if (valid_arch & arch_sh_dsp) + val = EF_SH_DSP; + else if (valid_arch & arch_sh3) + val = EF_SH3; + else if (valid_arch & arch_sh3_dsp) + val = EF_SH_DSP; + else if (valid_arch & arch_sh3e) + val = EF_SH3E; + else if (valid_arch & arch_sh4) + val = EF_SH4; + else + abort (); + + elf_elfheader (stdoutput)->e_flags &= ~EF_SH_MACH_MASK; + elf_elfheader (stdoutput)->e_flags |= val; +} #endif /* Apply a fixup to the object file. */ @@ -2056,7 +2646,11 @@ md_apply_fix (fixP, val) case BFD_RELOC_VTABLE_INHERIT: case BFD_RELOC_VTABLE_ENTRY: fixP->fx_done = 0; +#ifdef BFD_ASSEMBLER + return 0; +#else return; +#endif default: abort (); @@ -2187,12 +2781,7 @@ sh_do_align (n, fill, len, max) int max; { if (fill == NULL -#ifdef BFD_ASSEMBLER - && (now_seg->flags & SEC_CODE) != 0 -#else - && now_seg != data_section - && now_seg != bss_section -#endif + && subseg_text_p (now_seg) && n > 1) { static const unsigned char big_nop_pattern[] = { 0x00, 0x09 }; @@ -2377,7 +2966,8 @@ tc_gen_reloc (section, fixp) bfd_reloc_code_real_type r_type; rel = (arelent *) xmalloc (sizeof (arelent)); - rel->sym_ptr_ptr = &fixp->fx_addsy->bsym; + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); rel->address = fixp->fx_frag->fr_address + fixp->fx_where; r_type = fixp->fx_r_type; diff --git a/gas/config/tc-sh.h b/gas/config/tc-sh.h index cc02eab..f5ab8a9 100644 --- a/gas/config/tc-sh.h +++ b/gas/config/tc-sh.h @@ -1,5 +1,5 @@ /* This file is tc-sh.h - Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -56,6 +56,8 @@ extern int sh_force_relocation (); #ifdef OBJ_ELF #define obj_fix_adjustable(fixP) sh_fix_adjustable(fixP) +struct fix; +extern boolean sh_fix_adjustable PARAMS ((struct fix *)); #endif #define IGNORE_NONSTANDARD_ESCAPES @@ -127,14 +129,20 @@ extern void sh_coff_reloc_mangle #define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag) extern int tc_coff_sizemachdep PARAMS ((fragS *)); +#ifdef BFD_ASSEMBLER +#define SEG_NAME(SEG) segment_name (SEG) +#else +#define SEG_NAME(SEG) obj_segment_name (SEG) +#endif + /* We align most sections to a 16 byte boundary. */ -#define SUB_SEGMENT_ALIGN(SEG) \ - (strncmp (obj_segment_name (SEG), ".stabstr", 8) == 0 \ - ? 0 \ - : ((strncmp (obj_segment_name (SEG), ".stab", 5) == 0 \ - || strcmp (obj_segment_name (SEG), ".ctors") == 0 \ - || strcmp (obj_segment_name (SEG), ".dtors") == 0) \ - ? 2 \ +#define SUB_SEGMENT_ALIGN(SEG) \ + (strncmp (SEG_NAME (SEG), ".stabstr", 8) == 0 \ + ? 0 \ + : ((strncmp (SEG_NAME (SEG), ".stab", 5) == 0 \ + || strcmp (SEG_NAME (SEG), ".ctors") == 0 \ + || strcmp (SEG_NAME (SEG), ".dtors") == 0) \ + ? 2 \ : (sh_small ? 2 : 4))) #endif /* OBJ_COFF */ @@ -147,6 +155,9 @@ extern int target_big_endian; #define TARGET_FORMAT (shl ? "elf32-shl" : "elf32-sh") +#define elf_tc_final_processing sh_elf_final_processing +extern void sh_elf_final_processing PARAMS ((void)); + #endif /* OBJ_ELF */ /* end of tc-sh.h */ diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 1518a8a..f7049d6 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -1,5 +1,5 @@ /* tc-sparc.c -- Assemble for the SPARC - Copyright (C) 1989, 90-96, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 90-96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. GAS is free software; you can redistribute it and/or modify @@ -31,11 +31,14 @@ static struct sparc_arch *lookup_arch PARAMS ((char *)); static void init_default_arch PARAMS ((void)); -static void sparc_ip PARAMS ((char *, const struct sparc_opcode **)); +static int sparc_ip PARAMS ((char *, const struct sparc_opcode **)); static int in_signed_range PARAMS ((bfd_signed_vma, bfd_signed_vma)); static int in_unsigned_range PARAMS ((bfd_vma, bfd_vma)); static int in_bitfield_range PARAMS ((bfd_signed_vma, bfd_signed_vma)); static int sparc_ffs PARAMS ((unsigned int)); +static void synthetize_setuw PARAMS ((const struct sparc_opcode *)); +static void synthetize_setsw PARAMS ((const struct sparc_opcode *)); +static void synthetize_setx PARAMS ((const struct sparc_opcode *)); static bfd_vma BSR PARAMS ((bfd_vma, int)); static int cmp_reg_entry PARAMS ((const PTR, const PTR)); static int parse_keyword_arg PARAMS ((int (*) (const char *), char **, int *)); @@ -84,6 +87,10 @@ static int warn_on_bump; architecture, issue a warning. */ static enum sparc_opcode_arch_val warn_after_architecture; +/* Non-zero if as should generate error if an undeclared g[23] register + has been used in -64. */ +static int no_undeclared_regs; + /* Non-zero if we are generating PIC code. */ int sparc_pic_code; @@ -94,6 +101,9 @@ extern int target_big_endian; static int target_little_endian_data; +/* Symbols for global registers on v9. */ +static symbolS *globals[8]; + /* V9 and 86x have big and little endian data, but instructions are always big endian. The sparclet has bi-endian support but both data and insns have the same endianness. Global `target_big_endian' is used for data. @@ -115,6 +125,8 @@ static void s_reserve PARAMS ((int)); static void s_common PARAMS ((int)); static void s_empty PARAMS ((int)); static void s_uacons PARAMS ((int)); +static void s_ncons PARAMS ((int)); +static void s_register PARAMS ((int)); const pseudo_typeS md_pseudo_table[] = { @@ -123,6 +135,7 @@ const pseudo_typeS md_pseudo_table[] = {"empty", s_empty, 0}, {"global", s_globl, 0}, {"half", cons, 2}, + {"nword", s_ncons, 0}, {"optim", s_ignore, 0}, {"proc", s_proc, 0}, {"reserve", s_reserve, 0}, @@ -135,11 +148,10 @@ const pseudo_typeS md_pseudo_table[] = {"uaxword", s_uacons, 8}, #ifdef OBJ_ELF /* these are specific to sparc/svr4 */ - {"pushsection", obj_elf_section, 0}, - {"popsection", obj_elf_previous, 0}, {"2byte", s_uacons, 2}, {"4byte", s_uacons, 4}, {"8byte", s_uacons, 8}, + {"register", s_register, 0}, #endif {NULL, 0, 0}, }; @@ -174,9 +186,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP"; changed in read.c. Ideally it shouldn't have to know about it at all, but nothing is ideal around here. */ -static unsigned char octal[256]; -#define isoctal(c) octal[(unsigned char) (c)] -static unsigned char toHex[256]; +#define isoctal(c) ((unsigned)((c) - '0') < '8') struct sparc_it { @@ -184,6 +194,7 @@ struct sparc_it unsigned long opcode; struct nlist *nlistp; expressionS exp; + expressionS exp2; int pcrel; bfd_reloc_code_real_type reloc; }; @@ -398,6 +409,12 @@ struct option md_longopts[] = { {"enforce-aligned-data", no_argument, NULL, OPTION_ENFORCE_ALIGNED_DATA}, #define OPTION_LITTLE_ENDIAN_DATA (OPTION_MD_BASE + 11) {"little-endian-data", no_argument, NULL, OPTION_LITTLE_ENDIAN_DATA}, +#ifdef OBJ_ELF +#define OPTION_NO_UNDECLARED_REGS (OPTION_MD_BASE + 12) + {"no-undeclared-regs", no_argument, NULL, OPTION_NO_UNDECLARED_REGS}, +#define OPTION_UNDECLARED_REGS (OPTION_MD_BASE + 13) + {"undeclared-regs", no_argument, NULL, OPTION_UNDECLARED_REGS}, +#endif {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof(md_longopts); @@ -547,6 +564,14 @@ md_parse_option (c, arg) else sparc_pic_code = 1; break; + + case OPTION_NO_UNDECLARED_REGS: + no_undeclared_regs = 1; + break; + + case OPTION_UNDECLARED_REGS: + no_undeclared_regs = 0; + break; #endif default: @@ -600,6 +625,10 @@ md_show_usage (stream) fprintf (stream, _("\ -KPIC generate PIC\n\ -V print assembler version number\n\ +-undeclared-regs ignore application global register usage without\n\ + appropriate .register directive (default)\n\ +-no-undeclared-regs force error on application global register usage\n\ + without appropriate .register directive\n\ -q ignored\n\ -Qy, -Qn ignored\n\ -s ignored\n")); @@ -613,6 +642,27 @@ md_show_usage (stream) #endif } +/* native operand size opcode translation */ +struct + { + char *name; + char *name32; + char *name64; + } native_op_table[] = +{ + {"ldn", "ld", "ldx"}, + {"ldna", "lda", "ldxa"}, + {"stn", "st", "stx"}, + {"stna", "sta", "stxa"}, + {"slln", "sll", "sllx"}, + {"srln", "srl", "srlx"}, + {"sran", "sra", "srax"}, + {"casn", "cas", "casx"}, + {"casna", "casa", "casxa"}, + {"clrn", "clr", "clrx"}, + {NULL, NULL, NULL}, +}; + /* sparc64 priviledged registers */ struct priv_reg_entry @@ -693,16 +743,16 @@ md_begin () retval = hash_insert (op_hash, name, (PTR) &sparc_opcodes[i]); if (retval != NULL) { - fprintf (stderr, _("internal error: can't hash `%s': %s\n"), - sparc_opcodes[i].name, retval); + as_bad (_("Internal error: can't hash `%s': %s\n"), + sparc_opcodes[i].name, retval); lose = 1; } do { if (sparc_opcodes[i].match & sparc_opcodes[i].lose) { - fprintf (stderr, _("internal error: losing opcode: `%s' \"%s\"\n"), - sparc_opcodes[i].name, sparc_opcodes[i].args); + as_bad (_("Internal error: losing opcode: `%s' \"%s\"\n"), + sparc_opcodes[i].name, sparc_opcodes[i].args); lose = 1; } ++i; @@ -711,18 +761,33 @@ md_begin () && !strcmp (sparc_opcodes[i].name, name)); } + for (i = 0; native_op_table[i].name; i++) + { + const struct sparc_opcode *insn; + char *name = sparc_arch_size == 32 ? native_op_table[i].name32 : + native_op_table[i].name64; + insn = (struct sparc_opcode *)hash_find (op_hash, name); + if (insn == NULL) + { + as_bad (_("Internal error: can't find opcode `%s' for `%s'\n"), + name, native_op_table[i].name); + lose = 1; + } + else + { + retval = hash_insert (op_hash, native_op_table[i].name, (PTR) insn); + if (retval != NULL) + { + as_bad (_("Internal error: can't hash `%s': %s\n"), + sparc_opcodes[i].name, retval); + lose = 1; + } + } + } + if (lose) as_fatal (_("Broken assembler. No assembly attempted.")); - for (i = '0'; i < '8'; ++i) - octal[i] = 1; - for (i = '0'; i <= '9'; ++i) - toHex[i] = i - '0'; - for (i = 'a'; i <= 'f'; ++i) - toHex[i] = i + 10 - 'a'; - for (i = 'A'; i <= 'F'; ++i) - toHex[i] = i + 10 - 'A'; - qsort (priv_reg_table, sizeof (priv_reg_table) / sizeof (priv_reg_table[0]), sizeof (priv_reg_table[0]), cmp_reg_entry); @@ -860,9 +925,6 @@ BSR (val, amount) /* For communication between sparc_ip and get_expression. */ static char *expr_end; -/* For communication between md_assemble and sparc_ip. */ -static int special_case; - /* Values for `special_case'. Instructions that require wierd handling because they're longer than 4 bytes. */ @@ -876,6 +938,7 @@ static int special_case; /* Bit masks of various insns. */ #define NOP_INSN 0x01000000 #define OR_INSN 0x80100000 +#define XOR_INSN 0x80180000 #define FMOVS_INSN 0x81A00020 #define SETHI_INSN 0x01000000 #define SLLX_INSN 0x81281000 @@ -886,6 +949,281 @@ static const struct sparc_opcode *last_insn; /* The assembled opcode of `last_insn'. */ static unsigned long last_opcode; +/* Handle the set and setuw synthetic instructions. */ +static void +synthetize_setuw (insn) + const struct sparc_opcode *insn; +{ + int need_hi22_p = 0; + int rd = (the_insn.opcode & RD (~0)) >> 25; + + if (the_insn.exp.X_op == O_constant) + { + if (SPARC_OPCODE_ARCH_V9_P (max_architecture)) + { + if (sizeof(offsetT) > 4 + && (the_insn.exp.X_add_number < 0 + || the_insn.exp.X_add_number > (offsetT) 0xffffffff)) + as_warn (_("set: number not in 0..4294967295 range")); + } + else + { + if (sizeof(offsetT) > 4 + && (the_insn.exp.X_add_number < -(offsetT) 0x80000000 + || the_insn.exp.X_add_number > (offsetT) 0xffffffff)) + as_warn (_("set: number not in -2147483648..4294967295 range")); + the_insn.exp.X_add_number = (int)the_insn.exp.X_add_number; + } + } + + /* See if operand is absolute and small; skip sethi if so. */ + if (the_insn.exp.X_op != O_constant + || the_insn.exp.X_add_number >= (1 << 12) + || the_insn.exp.X_add_number < -(1 << 12)) + { + the_insn.opcode = (SETHI_INSN | RD (rd) + | ((the_insn.exp.X_add_number >> 10) + & (the_insn.exp.X_op == O_constant ? 0x3fffff : 0))); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_HI22 + : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + need_hi22_p = 1; + } + + /* See if operand has no low-order bits; skip OR if so. */ + if (the_insn.exp.X_op != O_constant + || (need_hi22_p && (the_insn.exp.X_add_number & 0x3FF) != 0) + || ! need_hi22_p) + { + the_insn.opcode = (OR_INSN | (need_hi22_p ? RS1 (rd) : 0) + | RD (rd) | IMMED + | (the_insn.exp.X_add_number + & (the_insn.exp.X_op != O_constant ? 0 : + need_hi22_p ? 0x3ff : 0x1fff))); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_LO10 + : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + } +} + +/* Handle the setsw synthetic instruction. */ +static void +synthetize_setsw (insn) + const struct sparc_opcode *insn; +{ + int low32, rd, opc; + + rd = (the_insn.opcode & RD (~0)) >> 25; + + if (the_insn.exp.X_op != O_constant) + { + synthetize_setuw (insn); + + /* Need to sign extend it. */ + the_insn.opcode = (SRA_INSN | RS1 (rd) | RD (rd)); + the_insn.reloc = BFD_RELOC_NONE; + output_insn (insn, &the_insn); + return; + } + + if (sizeof(offsetT) > 4 + && (the_insn.exp.X_add_number < -(offsetT) 0x80000000 + || the_insn.exp.X_add_number > (offsetT) 0xffffffff)) + as_warn (_("setsw: number not in -2147483648..4294967295 range")); + + low32 = the_insn.exp.X_add_number; + + if (low32 >= 0) + { + synthetize_setuw (insn); + return; + } + + opc = OR_INSN; + + the_insn.reloc = BFD_RELOC_NONE; + /* See if operand is absolute and small; skip sethi if so. */ + if (low32 < -(1 << 12)) + { + the_insn.opcode = (SETHI_INSN | RD (rd) + | (((~the_insn.exp.X_add_number) >> 10) & 0x3fffff)); + output_insn (insn, &the_insn); + low32 = 0x1c00 | (low32 & 0x3ff); + opc = RS1 (rd) | XOR_INSN; + } + + the_insn.opcode = (opc | RD (rd) | IMMED + | (low32 & 0x1fff)); + output_insn (insn, &the_insn); +} + +/* Handle the setsw synthetic instruction. */ +static void +synthetize_setx (insn) + const struct sparc_opcode *insn; +{ + int upper32, lower32; + int tmpreg = (the_insn.opcode & RS1 (~0)) >> 14; + int dstreg = (the_insn.opcode & RD (~0)) >> 25; + int upper_dstreg; + int need_hh22_p = 0, need_hm10_p = 0, need_hi22_p = 0, need_lo10_p = 0; + int need_xor10_p = 0; + +#define SIGNEXT32(x) ((((x) & 0xffffffff) ^ 0x80000000) - 0x80000000) + lower32 = SIGNEXT32 (the_insn.exp.X_add_number); + upper32 = SIGNEXT32 (BSR (the_insn.exp.X_add_number, 32)); +#undef SIGNEXT32 + + upper_dstreg = tmpreg; + /* The tmp reg should not be the dst reg. */ + if (tmpreg == dstreg) + as_warn (_("setx: temporary register same as destination register")); + + /* ??? Obviously there are other optimizations we can do + (e.g. sethi+shift for 0x1f0000000) and perhaps we shouldn't be + doing some of these. Later. If you do change things, try to + change all of this to be table driven as well. */ + /* What to output depends on the number if it's constant. + Compute that first, then output what we've decided upon. */ + if (the_insn.exp.X_op != O_constant) + { + if (sparc_arch_size == 32) + { + /* When arch size is 32, we want setx to be equivalent + to setuw for anything but constants. */ + the_insn.exp.X_add_number &= 0xffffffff; + synthetize_setuw (insn); + return; + } + need_hh22_p = need_hm10_p = need_hi22_p = need_lo10_p = 1; + lower32 = 0; upper32 = 0; + } + else + { + /* Reset X_add_number, we've extracted it as upper32/lower32. + Otherwise fixup_segment will complain about not being able to + write an 8 byte number in a 4 byte field. */ + the_insn.exp.X_add_number = 0; + + /* Only need hh22 if `or' insn can't handle constant. */ + if (upper32 < -(1 << 12) || upper32 >= (1 << 12)) + need_hh22_p = 1; + + /* Does bottom part (after sethi) have bits? */ + if ((need_hh22_p && (upper32 & 0x3ff) != 0) + /* No hh22, but does upper32 still have bits we can't set + from lower32? */ + || (! need_hh22_p && upper32 != 0 && upper32 != -1)) + need_hm10_p = 1; + + /* If the lower half is all zero, we build the upper half directly + into the dst reg. */ + if (lower32 != 0 + /* Need lower half if number is zero or 0xffffffff00000000. */ + || (! need_hh22_p && ! need_hm10_p)) + { + /* No need for sethi if `or' insn can handle constant. */ + if (lower32 < -(1 << 12) || lower32 >= (1 << 12) + /* Note that we can't use a negative constant in the `or' + insn unless the upper 32 bits are all ones. */ + || (lower32 < 0 && upper32 != -1) + || (lower32 >= 0 && upper32 == -1)) + need_hi22_p = 1; + + if (need_hi22_p && upper32 == -1) + need_xor10_p = 1; + + /* Does bottom part (after sethi) have bits? */ + else if ((need_hi22_p && (lower32 & 0x3ff) != 0) + /* No sethi. */ + || (! need_hi22_p && (lower32 & 0x1fff) != 0) + /* Need `or' if we didn't set anything else. */ + || (! need_hi22_p && ! need_hh22_p && ! need_hm10_p)) + need_lo10_p = 1; + } + else + /* Output directly to dst reg if lower 32 bits are all zero. */ + upper_dstreg = dstreg; + } + + if (!upper_dstreg && dstreg) + as_warn (_("setx: illegal temporary register g0")); + + if (need_hh22_p) + { + the_insn.opcode = (SETHI_INSN | RD (upper_dstreg) + | ((upper32 >> 10) & 0x3fffff)); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_SPARC_HH22 : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + } + + if (need_hi22_p) + { + the_insn.opcode = (SETHI_INSN | RD (dstreg) + | (((need_xor10_p ? ~lower32 : lower32) + >> 10) & 0x3fffff)); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_SPARC_LM22 : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + } + + if (need_hm10_p) + { + the_insn.opcode = (OR_INSN + | (need_hh22_p ? RS1 (upper_dstreg) : 0) + | RD (upper_dstreg) + | IMMED + | (upper32 & (need_hh22_p ? 0x3ff : 0x1fff))); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_SPARC_HM10 : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + } + + if (need_lo10_p) + { + /* FIXME: One nice optimization to do here is to OR the low part + with the highpart if hi22 isn't needed and the low part is + positive. */ + the_insn.opcode = (OR_INSN | (need_hi22_p ? RS1 (dstreg) : 0) + | RD (dstreg) + | IMMED + | (lower32 & (need_hi22_p ? 0x3ff : 0x1fff))); + the_insn.reloc = (the_insn.exp.X_op != O_constant + ? BFD_RELOC_LO10 : BFD_RELOC_NONE); + output_insn (insn, &the_insn); + } + + /* If we needed to build the upper part, shift it into place. */ + if (need_hh22_p || need_hm10_p) + { + the_insn.opcode = (SLLX_INSN | RS1 (upper_dstreg) | RD (upper_dstreg) + | IMMED | 32); + the_insn.reloc = BFD_RELOC_NONE; + output_insn (insn, &the_insn); + } + + /* To get -1 in upper32, we do sethi %hi(~x), r; xor r, -0x400 | x, r. */ + if (need_xor10_p) + { + the_insn.opcode = (XOR_INSN | RS1 (dstreg) | RD (dstreg) | IMMED + | 0x1c00 | (lower32 & 0x3ff)); + the_insn.reloc = BFD_RELOC_NONE; + output_insn (insn, &the_insn); + } + + /* If we needed to build both upper and lower parts, OR them together. */ + else if ((need_hh22_p || need_hm10_p) && (need_hi22_p || need_lo10_p)) + { + the_insn.opcode = (OR_INSN | RS1 (dstreg) | RS2 (upper_dstreg) + | RD (dstreg)); + the_insn.reloc = BFD_RELOC_NONE; + output_insn (insn, &the_insn); + } +} + /* Main entry point to assemble one instruction. */ void @@ -893,10 +1231,10 @@ md_assemble (str) char *str; { const struct sparc_opcode *insn; + int special_case; know (str); - special_case = SPECIAL_CASE_NONE; - sparc_ip (str, &insn); + special_case = sparc_ip (str, &insn); /* We warn about attempts to put a floating point branch in a delay slot, unless the delay slot has been annulled. */ @@ -934,202 +1272,24 @@ md_assemble (str) output_insn (insn, &the_insn); break; - case SPECIAL_CASE_SET: - { - int need_hi22_p = 0; - - /* "set" is not defined for negative numbers in v9: it doesn't yield - what you expect it to. */ - if (SPARC_OPCODE_ARCH_V9_P (max_architecture) - && the_insn.exp.X_op == O_constant) - { - if (the_insn.exp.X_add_number < 0) - as_warn (_("set: used with negative number")); - else if (the_insn.exp.X_add_number > (offsetT) 0xffffffff) - as_warn (_("set: number larger than 4294967295")); - } - - /* See if operand is absolute and small; skip sethi if so. */ - if (the_insn.exp.X_op != O_constant - || the_insn.exp.X_add_number >= (1 << 12) - || the_insn.exp.X_add_number < -(1 << 12)) - { - output_insn (insn, &the_insn); - need_hi22_p = 1; - } - /* See if operand has no low-order bits; skip OR if so. */ - if (the_insn.exp.X_op != O_constant - || (need_hi22_p && (the_insn.exp.X_add_number & 0x3FF) != 0) - || ! need_hi22_p) - { - int rd = (the_insn.opcode & RD (~0)) >> 25; - the_insn.opcode = (OR_INSN | (need_hi22_p ? RS1 (rd) : 0) - | RD (rd) - | IMMED - | (the_insn.exp.X_add_number - & (need_hi22_p ? 0x3ff : 0x1fff))); - the_insn.reloc = (the_insn.exp.X_op != O_constant - ? BFD_RELOC_LO10 - : BFD_RELOC_NONE); - output_insn (insn, &the_insn); - } - break; - } - case SPECIAL_CASE_SETSW: - { - /* FIXME: Not finished. */ - break; - } + synthetize_setsw (insn); + break; + + case SPECIAL_CASE_SET: + synthetize_setuw (insn); + break; case SPECIAL_CASE_SETX: - { -#define SIGNEXT32(x) ((((x) & 0xffffffff) ^ 0x80000000) - 0x80000000) - int upper32 = SIGNEXT32 (BSR (the_insn.exp.X_add_number, 32)); - int lower32 = SIGNEXT32 (the_insn.exp.X_add_number); -#undef SIGNEXT32 - int tmpreg = (the_insn.opcode & RS1 (~0)) >> 14; - int dstreg = (the_insn.opcode & RD (~0)) >> 25; - /* Output directly to dst reg if lower 32 bits are all zero. */ - int upper_dstreg = (the_insn.exp.X_op == O_constant - && lower32 == 0) ? dstreg : tmpreg; - int need_hh22_p = 0, need_hm10_p = 0, need_hi22_p = 0, need_lo10_p = 0; - - /* The tmp reg should not be the dst reg. */ - if (tmpreg == dstreg) - as_warn (_("setx: temporary register same as destination register")); - - /* Reset X_add_number, we've extracted it as upper32/lower32. - Otherwise fixup_segment will complain about not being able to - write an 8 byte number in a 4 byte field. */ - the_insn.exp.X_add_number = 0; - - /* ??? Obviously there are other optimizations we can do - (e.g. sethi+shift for 0x1f0000000) and perhaps we shouldn't be - doing some of these. Later. If you do change things, try to - change all of this to be table driven as well. */ - - /* What to output depends on the number if it's constant. - Compute that first, then output what we've decided upon. */ - if (the_insn.exp.X_op != O_constant) - need_hh22_p = need_hm10_p = need_hi22_p = need_lo10_p = 1; - else - { - /* Only need hh22 if `or' insn can't handle constant. */ - if (upper32 < -(1 << 12) || upper32 >= (1 << 12)) - need_hh22_p = 1; - - /* Does bottom part (after sethi) have bits? */ - if ((need_hh22_p && (upper32 & 0x3ff) != 0) - /* No hh22, but does upper32 still have bits we can't set - from lower32? */ - || (! need_hh22_p - && upper32 != 0 - && (upper32 != -1 || lower32 >= 0))) - need_hm10_p = 1; - - /* If the lower half is all zero, we build the upper half directly - into the dst reg. */ - if (lower32 != 0 - /* Need lower half if number is zero. */ - || (! need_hh22_p && ! need_hm10_p)) - { - /* No need for sethi if `or' insn can handle constant. */ - if (lower32 < -(1 << 12) || lower32 >= (1 << 12) - /* Note that we can't use a negative constant in the `or' - insn unless the upper 32 bits are all ones. */ - || (lower32 < 0 && upper32 != -1)) - need_hi22_p = 1; - - /* Does bottom part (after sethi) have bits? */ - if ((need_hi22_p && (lower32 & 0x3ff) != 0) - /* No sethi. */ - || (! need_hi22_p && (lower32 & 0x1fff) != 0) - /* Need `or' if we didn't set anything else. */ - || (! need_hi22_p && ! need_hh22_p && ! need_hm10_p)) - need_lo10_p = 1; - } - } - - if (need_hh22_p) - { - the_insn.opcode = (SETHI_INSN | RD (upper_dstreg) - | ((upper32 >> 10) & 0x3fffff)); - the_insn.reloc = (the_insn.exp.X_op != O_constant - ? BFD_RELOC_SPARC_HH22 : BFD_RELOC_NONE); - output_insn (insn, &the_insn); - } - - if (need_hm10_p) - { - the_insn.opcode = (OR_INSN - | (need_hh22_p ? RS1 (upper_dstreg) : 0) - | RD (upper_dstreg) - | IMMED - | (upper32 - & (need_hh22_p ? 0x3ff : 0x1fff))); - the_insn.reloc = (the_insn.exp.X_op != O_constant - ? BFD_RELOC_SPARC_HM10 : BFD_RELOC_NONE); - output_insn (insn, &the_insn); - } - - if (need_hi22_p) - { - the_insn.opcode = (SETHI_INSN | RD (dstreg) - | ((lower32 >> 10) & 0x3fffff)); - the_insn.reloc = BFD_RELOC_HI22; - output_insn (insn, &the_insn); - } - - if (need_lo10_p) - { - /* FIXME: One nice optimization to do here is to OR the low part - with the highpart if hi22 isn't needed and the low part is - positive. */ - the_insn.opcode = (OR_INSN | (need_hi22_p ? RS1 (dstreg) : 0) - | RD (dstreg) - | IMMED - | (lower32 - & (need_hi22_p ? 0x3ff : 0x1fff))); - the_insn.reloc = BFD_RELOC_LO10; - output_insn (insn, &the_insn); - } - - /* If we needed to build the upper part, shift it into place. */ - if (need_hh22_p || need_hm10_p) - { - the_insn.opcode = (SLLX_INSN | RS1 (upper_dstreg) | RD (upper_dstreg) - | IMMED | 32); - the_insn.reloc = BFD_RELOC_NONE; - output_insn (insn, &the_insn); - } - - /* If we needed to build both upper and lower parts, OR them together. */ - if ((need_hh22_p || need_hm10_p) - && (need_hi22_p || need_lo10_p)) - { - the_insn.opcode = (OR_INSN | RS1 (dstreg) | RS2 (upper_dstreg) - | RD (dstreg)); - the_insn.reloc = BFD_RELOC_NONE; - output_insn (insn, &the_insn); - } - /* We didn't need both regs, but we may have to sign extend lower32. */ - else if (need_hi22_p && upper32 == -1) - { - the_insn.opcode = (SRA_INSN | RS1 (dstreg) | RD (dstreg) - | IMMED | 0); - the_insn.reloc = BFD_RELOC_NONE; - output_insn (insn, &the_insn); - } - break; - } - + synthetize_setx (insn); + break; + case SPECIAL_CASE_FDIV: { int rd = (the_insn.opcode >> 25) & 0x1f; - + output_insn (insn, &the_insn); - + /* According to information leaked from Sun, the "fdiv" instructions on early SPARC machines would produce incorrect results sometimes. The workaround is to add an fmovs of the destination register to @@ -1138,9 +1298,9 @@ md_assemble (str) assert (the_insn.reloc == BFD_RELOC_NONE); the_insn.opcode = FMOVS_INSN | rd | RD (rd); output_insn (insn, &the_insn); - break; + return; } - + default: as_fatal (_("failed special case insn sanity check")); } @@ -1148,7 +1308,7 @@ md_assemble (str) /* Subroutine of md_assemble to do the actual parsing. */ -static void +static int sparc_ip (str, pinsn) char *str; const struct sparc_opcode **pinsn; @@ -1164,6 +1324,7 @@ sparc_ip (str, pinsn) int match = 0; int comma = 0; int v9_arg_p; + int special_case = SPECIAL_CASE_NONE; s = str; if (islower ((unsigned char) *s)) @@ -1195,7 +1356,7 @@ sparc_ip (str, pinsn) if (insn == NULL) { as_bad (_("Unknown opcode: `%s'"), str); - return; + return special_case; } if (comma) { @@ -1654,7 +1815,8 @@ sparc_ip (str, pinsn) goto error; case 'g': /* global register */ - if (isoctal (c = *s++)) + c = *s++; + if (isoctal (c)) { mask = c - '0'; break; @@ -1662,7 +1824,8 @@ sparc_ip (str, pinsn) goto error; case 'i': /* in register */ - if (isoctal (c = *s++)) + c = *s++; + if (isoctal (c)) { mask = c - '0' + 24; break; @@ -1670,7 +1833,8 @@ sparc_ip (str, pinsn) goto error; case 'l': /* local register */ - if (isoctal (c = *s++)) + c = *s++; + if (isoctal (c)) { mask = (c - '0' + 16); break; @@ -1678,7 +1842,8 @@ sparc_ip (str, pinsn) goto error; case 'o': /* out register */ - if (isoctal (c = *s++)) + c = *s++; + if (isoctal (c)) { mask = (c - '0' + 8); break; @@ -1727,6 +1892,11 @@ sparc_ip (str, pinsn) goto error; } + if ((mask & ~1) == 2 && sparc_arch_size == 64 + && no_undeclared_regs && ! globals [mask]) + as_bad (_("detected global register use not " + "covered by .register pseudo-op")); + /* Got the register, now figure out where it goes in the opcode. */ switch (*args) @@ -1854,14 +2024,10 @@ sparc_ip (str, pinsn) } break; - case '0': /* 64 bit immediate (setx insn) */ + case '0': /* 64 bit immediate (set, setsw, setx insn) */ the_insn.reloc = BFD_RELOC_NONE; /* reloc handled elsewhere */ goto immediate; - case 'h': /* high 22 bits */ - the_insn.reloc = BFD_RELOC_HI22; - goto immediate; - case 'l': /* 22 bit PC relative immediate */ the_insn.reloc = BFD_RELOC_SPARC_WDISP22; the_insn.pcrel = 1; @@ -1872,6 +2038,7 @@ sparc_ip (str, pinsn) the_insn.pcrel = 1; goto immediate; + case 'h': case 'n': /* 22 bit immediate */ the_insn.reloc = BFD_RELOC_SPARC22; goto immediate; @@ -1885,89 +2052,227 @@ sparc_ip (str, pinsn) if (*s == ' ') s++; - /* Check for %hi, etc. */ - if (*s == '%') - { - static struct ops { - /* The name as it appears in assembler. */ - char *name; - /* strlen (name), precomputed for speed */ - int len; - /* The reloc this pseudo-op translates to. */ - int reloc; - /* Non-zero if for v9 only. */ - int v9_p; - /* Non-zero if can be used in pc-relative contexts. */ - int pcrel_p;/*FIXME:wip*/ - } ops[] = { - /* hix/lox must appear before hi/lo so %hix won't be - mistaken for %hi. */ - { "hix", 3, BFD_RELOC_SPARC_HIX22, 1, 0 }, - { "lox", 3, BFD_RELOC_SPARC_LOX10, 1, 0 }, - { "hi", 2, BFD_RELOC_HI22, 0, 1 }, - { "lo", 2, BFD_RELOC_LO10, 0, 1 }, - { "hh", 2, BFD_RELOC_SPARC_HH22, 1, 1 }, - { "hm", 2, BFD_RELOC_SPARC_HM10, 1, 1 }, - { "lm", 2, BFD_RELOC_SPARC_LM22, 1, 1 }, - { "h44", 3, BFD_RELOC_SPARC_H44, 1, 0 }, - { "m44", 3, BFD_RELOC_SPARC_M44, 1, 0 }, - { "l44", 3, BFD_RELOC_SPARC_L44, 1, 0 }, - { "uhi", 3, BFD_RELOC_SPARC_HH22, 1, 0 }, - { "ulo", 3, BFD_RELOC_SPARC_HM10, 1, 0 }, - { NULL } - }; - struct ops *o; - - for (o = ops; o->name; o++) - if (strncmp (s + 1, o->name, o->len) == 0) + { + char *s1; + char *op_arg = NULL; + expressionS op_exp; + bfd_reloc_code_real_type old_reloc = the_insn.reloc; + + /* Check for %hi, etc. */ + if (*s == '%') + { + static const struct ops { + /* The name as it appears in assembler. */ + char *name; + /* strlen (name), precomputed for speed */ + int len; + /* The reloc this pseudo-op translates to. */ + int reloc; + /* Non-zero if for v9 only. */ + int v9_p; + /* Non-zero if can be used in pc-relative contexts. */ + int pcrel_p;/*FIXME:wip*/ + } ops[] = { + /* hix/lox must appear before hi/lo so %hix won't be + mistaken for %hi. */ + { "hix", 3, BFD_RELOC_SPARC_HIX22, 1, 0 }, + { "lox", 3, BFD_RELOC_SPARC_LOX10, 1, 0 }, + { "hi", 2, BFD_RELOC_HI22, 0, 1 }, + { "lo", 2, BFD_RELOC_LO10, 0, 1 }, + { "hh", 2, BFD_RELOC_SPARC_HH22, 1, 1 }, + { "hm", 2, BFD_RELOC_SPARC_HM10, 1, 1 }, + { "lm", 2, BFD_RELOC_SPARC_LM22, 1, 1 }, + { "h44", 3, BFD_RELOC_SPARC_H44, 1, 0 }, + { "m44", 3, BFD_RELOC_SPARC_M44, 1, 0 }, + { "l44", 3, BFD_RELOC_SPARC_L44, 1, 0 }, + { "uhi", 3, BFD_RELOC_SPARC_HH22, 1, 0 }, + { "ulo", 3, BFD_RELOC_SPARC_HM10, 1, 0 }, + { NULL } + }; + const struct ops *o; + + for (o = ops; o->name; o++) + if (strncmp (s + 1, o->name, o->len) == 0) + break; + if (o->name == NULL) break; - if (o->name == NULL) - break; + + if (s[o->len + 1] != '(') + { + as_bad (_("Illegal operands: %%%s requires arguments in ()"), o->name); + return special_case; + } - the_insn.reloc = o->reloc; - s += o->len + 1; - v9_arg_p = o->v9_p; - } + op_arg = o->name; + the_insn.reloc = o->reloc; + s += o->len + 2; + v9_arg_p = o->v9_p; + } + + /* Note that if the get_expression() fails, we will still + have created U entries in the symbol table for the + 'symbols' in the input string. Try not to create U + symbols for registers, etc. */ - /* Note that if the get_expression() fails, we will still - have created U entries in the symbol table for the - 'symbols' in the input string. Try not to create U - symbols for registers, etc. */ - { /* This stuff checks to see if the expression ends in +%reg. If it does, it removes the register from the expression, and re-sets 's' to point to the right place. */ - char *s1; + if (op_arg) + { + int npar = 0; + + for (s1 = s; *s1 && *s1 != ',' && *s1 != ']'; s1++) + if (*s1 == '(') + npar++; + else if (*s1 == ')') + { + if (!npar) + break; + npar--; + } + + if (*s1 != ')') + { + as_bad (_("Illegal operands: %%%s requires arguments in ()"), op_arg); + return special_case; + } + + *s1 = '\0'; + (void) get_expression (s); + *s1 = ')'; + s = s1 + 1; + if (*s == ',' || *s == ']' || !*s) + continue; + if (*s != '+' && *s != '-') + { + as_bad (_("Illegal operands: Can't do arithmetics other than + and - involving %%%s()"), op_arg); + return special_case; + } + *s1 = '0'; + s = s1; + op_exp = the_insn.exp; + memset (&the_insn.exp, 0, sizeof(the_insn.exp)); + } for (s1 = s; *s1 && *s1 != ',' && *s1 != ']'; s1++) ; if (s1 != s && isdigit ((unsigned char) s1[-1])) { if (s1[-2] == '%' && s1[-3] == '+') + s1 -= 3; + else if (strchr ("goli0123456789", s1[-2]) && s1[-3] == '%' && s1[-4] == '+') + s1 -= 4; + else + s1 = NULL; + if (s1) { - s1 -= 3; *s1 = '\0'; - (void) get_expression (s); + if (op_arg && s1 == s + 1) + the_insn.exp.X_op = O_absent; + else + (void) get_expression (s); *s1 = '+'; + if (op_arg) + *s = ')'; s = s1; - continue; } - else if (strchr ("goli0123456789", s1[-2]) && s1[-3] == '%' && s1[-4] == '+') + } + else + s1 = NULL; + + if (!s1) + { + (void) get_expression (s); + if (op_arg) + *s = ')'; + s = expr_end; + } + + if (op_arg) + { + the_insn.exp2 = the_insn.exp; + the_insn.exp = op_exp; + if (the_insn.exp2.X_op == O_absent) + the_insn.exp2.X_op = O_illegal; + else if (the_insn.exp.X_op == O_absent) { - s1 -= 4; - *s1 = '\0'; - (void) get_expression (s); - *s1 = '+'; - s = s1; - continue; + the_insn.exp = the_insn.exp2; + the_insn.exp2.X_op = O_illegal; + } + else if (the_insn.exp.X_op == O_constant) + { + valueT val = the_insn.exp.X_add_number; + switch (the_insn.reloc) + { + default: + break; + + case BFD_RELOC_SPARC_HH22: + val = BSR (val, 32); + /* intentional fallthrough */ + + case BFD_RELOC_SPARC_LM22: + case BFD_RELOC_HI22: + val = (val >> 10) & 0x3fffff; + break; + + case BFD_RELOC_SPARC_HM10: + val = BSR (val, 32); + /* intentional fallthrough */ + + case BFD_RELOC_LO10: + val &= 0x3ff; + break; + + case BFD_RELOC_SPARC_H44: + val >>= 22; + val &= 0x3fffff; + break; + + case BFD_RELOC_SPARC_M44: + val >>= 12; + val &= 0x3ff; + break; + + case BFD_RELOC_SPARC_L44: + val &= 0xfff; + break; + + case BFD_RELOC_SPARC_HIX22: + val = ~ val; + val = (val >> 10) & 0x3fffff; + break; + + case BFD_RELOC_SPARC_LOX10: + val = (val & 0x3ff) | 0x1c00; + break; + } + the_insn.exp = the_insn.exp2; + the_insn.exp.X_add_number += val; + the_insn.exp2.X_op = O_illegal; + the_insn.reloc = old_reloc; + } + else if (the_insn.exp2.X_op != O_constant) + { + as_bad (_("Illegal operands: Can't add non-constant expression to %%%s()"), op_arg); + return special_case; + } + else + { + if (old_reloc != BFD_RELOC_SPARC13 + || the_insn.reloc != BFD_RELOC_LO10 + || sparc_arch_size != 64 + || sparc_pic_code) + { + as_bad (_("Illegal operands: Can't do arithmetics involving %%%s() of a relocatable symbol"), op_arg); + return special_case; + } + the_insn.reloc = BFD_RELOC_SPARC_OLO10; } } } - (void) get_expression (s); - s = expr_end; - /* Check for constants that don't require emitting a reloc. */ if (the_insn.exp.X_op == O_constant && the_insn.exp.X_add_symbol == 0 @@ -2176,7 +2481,7 @@ sparc_ip (str, pinsn) else { as_bad (_("Illegal operands%s"), error_message); - return; + return special_case; } } else @@ -2244,7 +2549,7 @@ sparc_ip (str, pinsn) as_tsktsk (_(" (Requires %s; requested architecture is %s.)"), required_archs, sparc_opcode_archs[max_architecture].name); - return; + return special_case; } } /* if no match */ @@ -2252,6 +2557,7 @@ sparc_ip (str, pinsn) } /* forever looking for a match */ the_insn.opcode = opcode; + return special_case; } /* Parse an argument that can be expressed as a keyword. @@ -2374,6 +2680,8 @@ output_insn (insn, the_insn) the insn size is 4 and fixup_segment will signal an overflow for large 8 byte quantities. */ fixP->fx_no_overflow = 1; + if (the_insn->reloc == BFD_RELOC_SPARC_OLO10) + fixP->tc_fix_data = the_insn->exp2.X_add_number; } last_insn = insn; @@ -2504,7 +2812,7 @@ md_apply_fix3 (fixP, value, segment) don't want to include the value of an externally visible symbol. */ if (fixP->fx_addsy != NULL) { - if (fixP->fx_addsy->sy_used_in_reloc + if (symbol_used_in_reloc_p (fixP->fx_addsy) && (S_IS_EXTERNAL (fixP->fx_addsy) || S_IS_WEAK (fixP->fx_addsy) || (sparc_pic_code && ! fixP->fx_pcrel) @@ -2549,7 +2857,7 @@ md_apply_fix3 (fixP, value, segment) && fixP->fx_r_type != BFD_RELOC_32_PCREL_S2 && fixP->fx_addsy != NULL && ! S_IS_COMMON (fixP->fx_addsy) - && (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0) + && symbol_section_p (fixP->fx_addsy)) fixP->fx_addnumber -= 2 * S_GET_VALUE (fixP->fx_addsy); /* When generating PIC code, we need to fiddle to get @@ -2606,7 +2914,7 @@ md_apply_fix3 (fixP, value, segment) being done! */ if (! sparc_pic_code || fixP->fx_addsy == NULL - || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) + || symbol_section_p (fixP->fx_addsy)) ++val; insn |= val & 0x3fffffff; break; @@ -2708,6 +3016,11 @@ md_apply_fix3 (fixP, value, segment) } break; + case BFD_RELOC_SPARC_OLO10: + val &= 0x3ff; + val += fixP->tc_fix_data; + /* intentional fallthrough */ + case BFD_RELOC_SPARC13: if (! in_signed_range (val, 0x1fff)) as_bad_where (fixP->fx_file, fixP->fx_line, @@ -2777,17 +3090,20 @@ md_apply_fix3 (fixP, value, segment) /* Translate internal representation of relocation info to BFD target format. */ -arelent * +arelent ** tc_gen_reloc (section, fixp) asection *section; fixS *fixp; { + static arelent *relocs[3]; arelent *reloc; bfd_reloc_code_real_type code; - reloc = (arelent *) xmalloc (sizeof (arelent)); + relocs[0] = reloc = (arelent *) xmalloc (sizeof (arelent)); + relocs[1] = NULL; - reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; switch (fixp->fx_r_type) @@ -2798,6 +3114,7 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_LO10: case BFD_RELOC_32_PCREL_S2: case BFD_RELOC_SPARC13: + case BFD_RELOC_SPARC22: case BFD_RELOC_SPARC_BASE13: case BFD_RELOC_SPARC_WDISP16: case BFD_RELOC_SPARC_WDISP19: @@ -2820,6 +3137,7 @@ tc_gen_reloc (section, fixp) case BFD_RELOC_SPARC_HIX22: case BFD_RELOC_SPARC_LOX10: case BFD_RELOC_SPARC_REV32: + case BFD_RELOC_SPARC_OLO10: case BFD_RELOC_VTABLE_ENTRY: case BFD_RELOC_VTABLE_INHERIT: code = fixp->fx_r_type; @@ -2839,6 +3157,8 @@ tc_gen_reloc (section, fixp) #define GOT_NAME "__GLOBAL_OFFSET_TABLE_" #endif + /* This code must be parallel to the OBJ_ELF tc_fix_adjustable. */ + if (sparc_pic_code) { switch (code) @@ -2873,13 +3193,18 @@ tc_gen_reloc (section, fixp) } #endif /* defined (OBJ_ELF) || defined (OBJ_AOUT) */ - reloc->howto = bfd_reloc_type_lookup (stdoutput, code); + if (code == BFD_RELOC_SPARC_OLO10) + reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_LO10); + else + reloc->howto = bfd_reloc_type_lookup (stdoutput, code); if (reloc->howto == 0) { as_bad_where (fixp->fx_file, fixp->fx_line, _("internal error: can't export reloc type %d (`%s')"), fixp->fx_r_type, bfd_get_reloc_code_name (code)); - return 0; + xfree (reloc); + relocs[0] = NULL; + return relocs; } /* @@ Why fx_addnumber sometimes and fx_offset other times? */ @@ -2906,7 +3231,7 @@ tc_gen_reloc (section, fixp) || code == BFD_RELOC_SPARC_PC10 || code == BFD_RELOC_SPARC_PC22) reloc->addend = fixp->fx_addnumber; - else if ((fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) + else if (symbol_section_p (fixp->fx_addsy)) reloc->addend = (section->vma + fixp->fx_addnumber + md_pcrel_from (fixp)); @@ -2914,7 +3239,21 @@ tc_gen_reloc (section, fixp) reloc->addend = fixp->fx_offset; #endif - return reloc; + /* We expand R_SPARC_OLO10 to R_SPARC_LO10 and R_SPARC_13 + on the same location. */ + if (code == BFD_RELOC_SPARC_OLO10) + { + relocs[1] = reloc = (arelent *) xmalloc (sizeof (arelent)); + relocs[2] = NULL; + + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (section_symbol (absolute_section)); + reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; + reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_SPARC13); + reloc->addend = fixp->tc_fix_data; + } + + return relocs; } /* We have no need to default values of symbols. */ @@ -2961,7 +3300,7 @@ md_pcrel_from (fixP) ret = fixP->fx_where + fixP->fx_frag->fr_address; if (! sparc_pic_code || fixP->fx_addsy == NULL - || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) + || symbol_section_p (fixP->fx_addsy)) ret += fixP->fx_size; return ret; } @@ -3110,9 +3449,9 @@ s_reserve (ignore) /* detach from old frag */ if (S_GET_SEGMENT(symbolP) == bss_section) - symbolP->sy_frag->fr_symbol = NULL; + symbol_get_frag (symbolP)->fr_symbol = NULL; - symbolP->sy_frag = frag_now; + symbol_set_frag (symbolP, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP, (offsetT) size, (char *)0); *pfrag = 0; @@ -3189,7 +3528,7 @@ s_common (ignore) S_SET_EXTERNAL (symbolP); #endif } - know (symbolP->sy_frag == &zero_address_frag); + know (symbol_get_frag (symbolP) == &zero_address_frag); if (*input_line_pointer != ',') { as_bad (_("Expected comma after common length")); @@ -3218,7 +3557,7 @@ s_common (ignore) } #ifdef OBJ_ELF - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec; int old_subsec; @@ -3245,8 +3584,8 @@ s_common (ignore) if (align) frag_align (align, 0, 0); if (S_GET_SEGMENT (symbolP) == bss_section) - symbolP->sy_frag->fr_symbol = 0; - symbolP->sy_frag = frag_now; + symbol_get_frag (symbolP)->fr_symbol = 0; + symbol_set_frag (symbolP, frag_now); p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, (offsetT) size, (char *) 0); *p = 0; @@ -3289,7 +3628,7 @@ s_common (ignore) } #ifdef BFD_ASSEMBLER - symbolP->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; #endif demand_empty_rest_of_line (); @@ -3394,6 +3733,134 @@ s_uacons (bytes) cons (bytes); } +/* This handles the native word allocation pseudo-op .nword. + For sparc_arch_size 32 it is equivalent to .word, for + sparc_arch_size 64 it is equivalent to .xword. */ + +static void +s_ncons (bytes) + int bytes; +{ + cons (sparc_arch_size == 32 ? 4 : 8); +} + +#ifdef OBJ_ELF +/* Handle the SPARC ELF .register pseudo-op. This sets the binding of a + global register. + The syntax is: + + .register %g[2367],{#scratch|symbolname|#ignore} + */ + +static void +s_register (ignore) + int ignore; +{ + char c; + int reg; + int flags; + const char *regname; + + if (input_line_pointer[0] != '%' + || input_line_pointer[1] != 'g' + || ((input_line_pointer[2] & ~1) != '2' + && (input_line_pointer[2] & ~1) != '6') + || input_line_pointer[3] != ',') + as_bad (_("register syntax is .register %%g[2367],{#scratch|symbolname|#ignore}")); + reg = input_line_pointer[2] - '0'; + input_line_pointer += 4; + + if (*input_line_pointer == '#') + { + ++input_line_pointer; + regname = input_line_pointer; + c = get_symbol_end (); + if (strcmp (regname, "scratch") && strcmp (regname, "ignore")) + as_bad (_("register syntax is .register %%g[2367],{#scratch|symbolname|#ignore}")); + if (regname [0] == 'i') + regname = NULL; + else + regname = ""; + } + else + { + regname = input_line_pointer; + c = get_symbol_end (); + } + if (sparc_arch_size == 64) + { + if (globals [reg]) + { + if ((regname && globals [reg] != (symbolS *)1 + && strcmp (S_GET_NAME (globals [reg]), regname)) + || ((regname != NULL) ^ (globals [reg] != (symbolS *)1))) + as_bad (_("redefinition of global register")); + } + else + { + if (regname == NULL) + globals [reg] = (symbolS *)1; + else + { + if (*regname) + { + if (symbol_find (regname)) + as_bad (_("Register symbol %s already defined."), + regname); + } + globals [reg] = symbol_make (regname); + flags = symbol_get_bfdsym (globals [reg])->flags; + if (! *regname) + flags = flags & ~(BSF_GLOBAL|BSF_LOCAL|BSF_WEAK); + if (! (flags & (BSF_GLOBAL|BSF_LOCAL|BSF_WEAK))) + flags |= BSF_GLOBAL; + symbol_get_bfdsym (globals [reg])->flags = flags; + S_SET_VALUE (globals [reg], (valueT)reg); + S_SET_ALIGN (globals [reg], reg); + S_SET_SIZE (globals [reg], 0); + /* Although we actually want undefined_section here, + we have to use absolute_section, because otherwise + generic as code will make it a COM section. + We fix this up in sparc_adjust_symtab. */ + S_SET_SEGMENT (globals [reg], absolute_section); + S_SET_OTHER (globals [reg], 0); + elf_symbol (symbol_get_bfdsym (globals [reg])) + ->internal_elf_sym.st_info = + ELF_ST_INFO(STB_GLOBAL, STT_REGISTER); + elf_symbol (symbol_get_bfdsym (globals [reg])) + ->internal_elf_sym.st_shndx = SHN_UNDEF; + } + } + } + + *input_line_pointer = c; + + demand_empty_rest_of_line (); +} + +/* Adjust the symbol table. We set undefined sections for STT_REGISTER + symbols which need it. */ + +void +sparc_adjust_symtab () +{ + symbolS *sym; + + for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym)) + { + if (ELF_ST_TYPE (elf_symbol (symbol_get_bfdsym (sym)) + ->internal_elf_sym.st_info) != STT_REGISTER) + continue; + + if (ELF_ST_TYPE (elf_symbol (symbol_get_bfdsym (sym)) + ->internal_elf_sym.st_shndx != SHN_UNDEF)) + continue; + + S_SET_SEGMENT (sym, undefined_section); + } +} +#endif + /* If the --enforce-aligned-data option is used, we require .word, et. al., to be aligned correctly. We do it by setting up an rs_align_code frag, and checking in HANDLE_ALIGN to make sure that diff --git a/gas/config/tc-sparc.h b/gas/config/tc-sparc.h index 2a05764..91fda22 100644 --- a/gas/config/tc-sparc.h +++ b/gas/config/tc-sparc.h @@ -35,6 +35,9 @@ struct frag; extern const char *sparc_target_format PARAMS ((void)); #define TARGET_FORMAT sparc_target_format () +#define RELOC_EXPANSION_POSSIBLE +#define MAX_RELOC_EXPANSION 2 + #if 0 #ifdef TE_SPARCAOUT /* Bi-endian support may eventually be unconditional, but until things are @@ -57,7 +60,7 @@ extern int sparc_pic_code; #define md_do_align(n, fill, len, max, around) \ if ((n) && (n) <= 10 && !need_pass_2 && !(fill) \ - && now_seg != data_section && now_seg != bss_section) \ + && subseg_text_p (now_seg)) \ { \ char *p; \ p = frag_var (rs_align_code, 1 << n, 1, (relax_substateT) 1024, \ @@ -120,17 +123,32 @@ extern int elf32_sparc_force_relocation PARAMS ((struct fix *)); /* Keep relocations against global symbols. Don't turn them into relocations against sections. This is required for the dynamic linker to operate properly. When generating PIC, we need to keep - any non PC relative reloc. */ + any non PC relative reloc. The PIC part of this test must be + parallel to the code in tc_gen_reloc which converts relocations to + GOT relocations. */ #define tc_fix_adjustable(FIX) \ (! S_IS_EXTERNAL ((FIX)->fx_addsy) \ && ! S_IS_WEAK ((FIX)->fx_addsy) \ + && (FIX)->fx_r_type != BFD_RELOC_VTABLE_INHERIT \ + && (FIX)->fx_r_type != BFD_RELOC_VTABLE_ENTRY \ && (! sparc_pic_code \ - || (FIX)->fx_pcrel \ - || ((FIX)->fx_subsy != NULL \ - && (S_GET_SEGMENT ((FIX)->fx_subsy) \ - == S_GET_SEGMENT ((FIX)->fx_addsy))) \ - || strchr (S_GET_NAME ((FIX)->fx_addsy), '\001') != NULL \ - || strchr (S_GET_NAME ((FIX)->fx_addsy), '\002') != NULL)) + || ((FIX)->fx_r_type != BFD_RELOC_HI22 \ + && (FIX)->fx_r_type != BFD_RELOC_LO10 \ + && (FIX)->fx_r_type != BFD_RELOC_SPARC13 \ + && ((FIX)->fx_r_type != BFD_RELOC_32_PCREL_S2 \ + || (S_IS_DEFINED ((FIX)->fx_addsy) \ + && ! S_IS_COMMON ((FIX)->fx_addsy) \ + && ! S_IS_EXTERNAL ((FIX)->fx_addsy) \ + && ! S_IS_WEAK ((FIX)->fx_addsy))) \ + && ((FIX)->fx_pcrel \ + || ((FIX)->fx_subsy != NULL \ + && (S_GET_SEGMENT ((FIX)->fx_subsy) \ + == S_GET_SEGMENT ((FIX)->fx_addsy))) \ + || S_IS_LOCAL ((FIX)->fx_addsy))))) + +/* Finish up the entire symtab. */ +#define tc_adjust_symtab() sparc_adjust_symtab () +extern void sparc_adjust_symtab PARAMS ((void)); #endif #ifdef OBJ_AOUT @@ -161,4 +179,21 @@ extern void sparc_md_end PARAMS ((void)); extern void cons_fix_new_sparc PARAMS ((struct frag *, int, unsigned int, struct expressionS *)); +#define TC_FIX_TYPE valueT + +#define TC_INIT_FIX_DATA(X) \ + do \ + { \ + (X)->tc_fix_data = 0; \ + } \ + while(0) + +#define TC_FIX_DATA_PRINT(FILE, FIXP) \ + do \ + { \ + fprintf((FILE), "addend2=%ld\n", \ + (unsigned long) (FIXP)->tc_fix_data); \ + } \ + while(0) + /* end of tc-sparc.h */ diff --git a/gas/config/tc-tahoe.c b/gas/config/tc-tahoe.c index 2bd63ca..26a7524 100644 --- a/gas/config/tc-tahoe.c +++ b/gas/config/tc-tahoe.c @@ -1611,7 +1611,7 @@ md_assemble (instruction_string) segT to_seg; /* Target segment of the address. */ register valueT this_add_number; - register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */ + register symbolS *this_add_symbol; /* +ve (minuend) symbol. */ /* tahoe_opcodeT opcode_as_number; fixme: remove this line *//* The opcode as a number. */ char *opcodeP; /* Where it is in a frag. */ diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c index 61ed905..255c06a 100644 --- a/gas/config/tc-tic30.c +++ b/gas/config/tc-tic30.c @@ -1,5 +1,5 @@ /* tc-c30.c -- Assembly code for the Texas Instruments TMS320C30 - Copyright (C) 1998 Free Software Foundation. + Copyright (C) 1998, 1999 Free Software Foundation. Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au) This file is part of GAS, the GNU Assembler. @@ -1842,7 +1842,8 @@ tc_gen_reloc (section, fixP) rel = (arelent *) xmalloc (sizeof (arelent)); assert (rel != 0); - rel->sym_ptr_ptr = &fixP->fx_addsy->bsym; + rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy); rel->address = fixP->fx_frag->fr_address + fixP->fx_where; if (fixP->fx_pcrel) rel->addend = fixP->fx_addnumber; diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c index c8ab145..e53054d 100644 --- a/gas/config/tc-v850.c +++ b/gas/config/tc-v850.c @@ -1,5 +1,5 @@ /* tc-v850.c -- Assembler code for the NEC V850 - Copyright (C) 1996, 1997, 1998 Free Software Foundation. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -297,7 +297,7 @@ v850_comm (area) } } - know (symbolP->sy_frag == & zero_address_frag); + know (symbol_get_frag (symbolP) == & zero_address_frag); if (*input_line_pointer != ',') have_align = 0; @@ -323,7 +323,7 @@ v850_comm (area) } } - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec; int old_subsec; @@ -421,24 +421,24 @@ v850_comm (area) { case AREA_SDA: if (S_GET_SEGMENT (symbolP) == sbss_section) - symbolP->sy_frag->fr_symbol = 0; + symbol_get_frag (symbolP)->fr_symbol = 0; break; case AREA_ZDA: if (S_GET_SEGMENT (symbolP) == zbss_section) - symbolP->sy_frag->fr_symbol = 0; + symbol_get_frag (symbolP)->fr_symbol = 0; break; case AREA_TDA: if (S_GET_SEGMENT (symbolP) == tbss_section) - symbolP->sy_frag->fr_symbol = 0; + symbol_get_frag (symbolP)->fr_symbol = 0; break; default: - abort(); + abort (); } - symbolP->sy_frag = frag_now; + symbol_set_frag (symbolP, frag_now); pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, (offsetT) size, (char *) 0); *pfrag = 0; @@ -548,7 +548,7 @@ v850_comm (area) goto allocate_common; } - symbolP->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; demand_empty_rest_of_line (); return; @@ -726,9 +726,9 @@ reg_name_search (regs, regcount, name, accept_numbers) { /* If the symbol is an alias for another name then use that. If the symbol is an alias for a number, then return the number. */ - if (symbolP->sy_value.X_op == O_symbol) + if (symbol_equated_p (symbolP)) { - name = S_GET_NAME (symbolP->sy_value.X_add_symbol); + name = S_GET_NAME (symbol_get_value_expression (symbolP)->X_add_symbol); } else if (accept_numbers) { @@ -2243,7 +2243,8 @@ tc_gen_reloc (seg, fixp) arelent * reloc; reloc = (arelent *) xmalloc (sizeof (arelent)); - reloc->sym_ptr_ptr = & fixp->fx_addsy->bsym; + reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr= symbol_get_bfdsym (fixp->fx_addsy); reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); @@ -2259,7 +2260,7 @@ tc_gen_reloc (seg, fixp) return NULL; } - if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY + if ( fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY || fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT) reloc->addend = fixp->fx_offset; else @@ -2289,16 +2290,14 @@ v850_pcrel_from_section (fixp, section) segT section; { /* If the symbol is undefined, or in a section other than our own, + or it is weak (in which case it may well be in another section, then let the linker figure it out. */ if (fixp->fx_addsy != (symbolS *) NULL && (! S_IS_DEFINED (fixp->fx_addsy) + || S_IS_WEAK (fixp->fx_addsy) || (S_GET_SEGMENT (fixp->fx_addsy) != section))) - { - /* The symbol is undefined/not in our section. - Let the linker figure it out. */ - return 0; - } - + return 0; + return fixp->fx_frag->fr_address + fixp->fx_where; } @@ -2311,7 +2310,7 @@ md_apply_fix3 (fixp, valuep, seg) valueT value; char * where; - if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT + if ( fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY) { fixp->fx_done = 0; @@ -2407,7 +2406,7 @@ md_apply_fix3 (fixp, valuep, seg) on the v850. */ void parse_cons_expression_v850 (exp) - expressionS *exp; + expressionS * exp; { /* See if there's a reloc prefix like hi() we have to handle. */ hold_cons_reloc = v850_reloc_prefix (NULL); @@ -2421,7 +2420,7 @@ parse_cons_expression_v850 (exp) appropriate one based on the size of the expression. */ void cons_fix_new_v850 (frag, where, size, exp) - fragS *frag; + fragS * frag; int where; int size; expressionS *exp; @@ -2441,37 +2440,42 @@ cons_fix_new_v850 (frag, where, size, exp) else fix_new (frag, where, size, NULL, 0, 0, hold_cons_reloc); } + boolean v850_fix_adjustable (fixP) - fixS *fixP; + fixS * fixP; { - if (fixP->fx_addsy == NULL) return 1; /* Prevent all adjustments to global symbols. */ if (S_IS_EXTERN (fixP->fx_addsy)) return 0; + if (S_IS_WEAK (fixP->fx_addsy)) return 0; + /* Don't adjust function names */ if (S_IS_FUNCTION (fixP->fx_addsy)) return 0; /* We need the symbol name for the VTABLE entries */ - if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT + if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) return 0; - + return 1; } int -v850_force_relocation (fixp) - struct fix *fixp; +v850_force_relocation (fixP) + struct fix * fixP; { - if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT - || fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY) + if (fixP->fx_addsy && S_IS_WEAK (fixP->fx_addsy)) + return 1; + + if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT + || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) return 1; return 0; diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c index 24e4a9b..f425ccc 100644 --- a/gas/config/tc-vax.c +++ b/gas/config/tc-vax.c @@ -1,5 +1,6 @@ /* tc-vax.c - vax-specific - - Copyright (C) 1987, 91, 92, 93, 94, 95, 1998 Free Software Foundation, Inc. + Copyright (C) 1987, 91, 92, 93, 94, 95, 98, 1999 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -335,7 +336,7 @@ md_assemble (instruction_string) segT to_seg; valueT this_add_number; /* Positive (minuend) symbol. */ - struct symbol *this_add_symbol; + symbolS *this_add_symbol; /* As a number. */ long opcode_as_number; /* Least significant byte 1st. */ diff --git a/gas/config/tc-w65.c b/gas/config/tc-w65.c index 72201e7..e57eb0f 100644 --- a/gas/config/tc-w65.c +++ b/gas/config/tc-w65.c @@ -1081,7 +1081,7 @@ md_pcrel_from (fixP) void tc_coff_symbol_emit_hook (x) - struct symbol *x; + symbolS *x; { } diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c index 1611341..f89b14b 100644 --- a/gas/config/tc-z8k.c +++ b/gas/config/tc-z8k.c @@ -1,5 +1,5 @@ /* tc-z8k.c -- Assemble code for the Zilog Z800n - Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -1520,7 +1520,7 @@ md_pcrel_from (fixP) void tc_coff_symbol_emit_hook (s) - struct symbol *s; + symbolS *s; { } diff --git a/gas/config/te-go32.h b/gas/config/te-go32.h index 49fbd2e..085c958 100644 --- a/gas/config/te-go32.h +++ b/gas/config/te-go32.h @@ -12,5 +12,7 @@ /* GAS should treat '.align value' as an alignment of 2**value */ #define USE_ALIGN_PTWO +#define COFF_LONG_SECTION_NAMES + /* these define interfaces */ #include "obj-format.h" diff --git a/gas/config/te-interix.h b/gas/config/te-interix.h new file mode 100644 index 0000000..073ad24 --- /dev/null +++ b/gas/config/te-interix.h @@ -0,0 +1,16 @@ +#define TE_PE_DYN /* PE with dynamic linking (UNIX shared lib) support */ +#define TE_PE +#define LEX_AT 1 /* can have @'s inside labels */ +#define LEX_QM 3 /* can have ?'s in or begin labels */ + +/* The PE format supports long section names. */ +#define COFF_LONG_SECTION_NAMES + +#define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_" + +/* Both architectures use these */ +#ifndef LOCAL_LABELS_FB +#define LOCAL_LABELS_FB 1 +#endif + +#include "obj-format.h" diff --git a/gas/config/te-multi.h b/gas/config/te-multi.h deleted file mode 100644 index b8eda45..0000000 --- a/gas/config/te-multi.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file is te-generic.h and is intended to be a template for - * target environment specific header files. - * - * It is my intent that this file will evolve into a file suitable for config, - * compile, and copying as an aid for testing and porting. xoxorich. - */ - -/* Added these, because if we don't know what we're targetting we may - need an assembler version of libgcc, and that will use local - labels. */ -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -/* these define interfaces */ -#ifdef OBJ_HEADER -#include OBJ_HEADER -#else -#include "obj-format.h" -#endif - -/* end of te-generic.h */ diff --git a/gas/config/te-wince-pe.h b/gas/config/te-wince-pe.h new file mode 100644 index 0000000..d1193b8 --- /dev/null +++ b/gas/config/te-wince-pe.h @@ -0,0 +1,2 @@ +#define TE_WINCE +#include "te-pe.h" diff --git a/gas/configure b/gas/configure index b8eefe4..665f8ac 100755 --- a/gas/configure +++ b/gas/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 +# Generated automatically using autoconf version 2.13.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -16,8 +16,12 @@ ac_help="$ac_help 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 avoid locking (might break parallel builds)" +ac_help="$ac_help --enable-bfd-assembler use BFD back end for writing object files" ac_help="$ac_help targets alternative target configurations besides the primary" @@ -352,7 +356,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" + echo "configure generated by autoconf version 2.13.1" exit 0 ;; -with-* | --with-*) @@ -512,7 +516,7 @@ done if test -r "$cache_file"; then echo "loading cache $cache_file" - . $cache_file + test -f "$cache_file" && . $cache_file else echo "creating cache $cache_file" > $cache_file @@ -556,9 +560,130 @@ 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. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:570: checking host system type" >&5 +if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_host_alias=$host + case "$ac_cv_host_alias" in + NONE) + case $nonopt in + NONE) + if ac_cv_host_alias=`$ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) ac_cv_host_alias=$nonopt ;; + esac ;; + esac + + ac_cv_host=`$ac_config_sub $ac_cv_host_alias` + ac_cv_host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_host" 1>&6 + +host=$ac_cv_host +host_alias=$ac_cv_host_alias +host_cpu=$ac_cv_host_cpu +host_vendor=$ac_cv_host_vendor +host_os=$ac_cv_host_os + + + + + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:611: checking target system type" >&5 +if test "x$ac_cv_target" = "x" || (test "x$target" != "xNONE" && test "x$target" != "x$ac_cv_target_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_target_alias=$target + case "$ac_cv_target_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_target_alias=$host_alias ;; + + *) ac_cv_target_alias=$nonopt ;; + esac ;; + esac + + ac_cv_target=`$ac_config_sub $ac_cv_target_alias` + ac_cv_target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_target" 1>&6 + +target=$ac_cv_target +target_alias=$ac_cv_target_alias +target_cpu=$ac_cv_target_cpu +target_vendor=$ac_cv_target_vendor +target_os=$ac_cv_target_os + + + + + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:651: checking build system type" >&5 +if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_build_alias=$build + case "$ac_cv_build_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_build_alias=$host_alias ;; + + *) ac_cv_build_alias=$nonopt ;; + esac ;; + esac + + ac_cv_build=`$ac_config_sub $ac_cv_build_alias` + ac_cv_build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_build" 1>&6 + +build=$ac_cv_build +build_alias=$ac_cv_build_alias +build_cpu=$ac_cv_build_cpu +build_vendor=$ac_cv_build_vendor +build_os=$ac_cv_build_os + + + # Do some error checking and defaulting for the host and target type. @@ -581,69 +706,6 @@ 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:592: 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:613: 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:631: 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, && @@ -662,9 +724,9 @@ test "$host_alias" != "$target_alias" && # 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:666: checking for a BSD compatible install" >&5 +echo "configure:728: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then +if eval "test \"\${ac_cv_path_install+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" @@ -682,6 +744,10 @@ else grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : + elif test $ac_prog = install && + grep pwplus $ac_dir/$ac_prog >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 @@ -710,12 +776,12 @@ echo "$ac_t""$INSTALL" 1>&6 # 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_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:719: checking whether build environment is sane" >&5 +echo "configure:785: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -763,18 +829,18 @@ EOF_SED rm -f conftestsed fi test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" + 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" + 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:776: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:842: 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 +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF @@ -801,7 +867,7 @@ fi PACKAGE=gas -VERSION=2.9.4 +VERSION=2.9.5 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; } @@ -818,7 +884,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:822: checking for working aclocal" >&5 +echo "configure:888: 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. @@ -831,7 +897,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:835: checking for working autoconf" >&5 +echo "configure:901: 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. @@ -844,7 +910,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:848: checking for working automake" >&5 +echo "configure:914: 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. @@ -857,7 +923,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:861: checking for working autoheader" >&5 +echo "configure:927: 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. @@ -870,7 +936,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:874: checking for working makeinfo" >&5 +echo "configure:940: 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. @@ -930,11 +996,34 @@ 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:937: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then +echo "configure:1026: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then @@ -963,8 +1052,8 @@ 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:967: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:1056: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -993,8 +1082,8 @@ 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:997: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:1086: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -1040,12 +1129,12 @@ fi if test -z "$CC"; then case "`uname -s`" in - *win32* | *WIN32*) + *win32* | *WIN32* | *CYGWIN*) # 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:1048: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:1137: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -1075,8 +1164,8 @@ 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:1080: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:1169: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1087,12 +1176,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1091 "configure" +#line 1180 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1185: \"$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 @@ -1117,14 +1206,14 @@ 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:1122: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1211: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $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:1127: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then +echo "configure:1216: checking whether we are using GNU C" >&5 +if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1225: \"$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 @@ -1151,8 +1240,8 @@ 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:1155: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then +echo "configure:1244: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c @@ -1190,18 +1279,23 @@ 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:1199: checking for ld used by GCC" >&5 +echo "configure:1287: 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" - ;; + # 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 @@ -1213,19 +1307,19 @@ echo "configure:1199: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1217: checking for GNU ld" >&5 +echo "configure:1311: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1220: checking for non-GNU ld" >&5 +echo "configure:1314: checking for non-GNU ld" >&5 fi -if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then +if eval "test \"\${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}:" + 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 + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; 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. @@ -1233,7 +1327,7 @@ else 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 + test "$with_gnu_ld" != yes && break fi fi done @@ -1250,10 +1344,9 @@ 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:1256: checking if the linker ($LD) is GNU ld" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then +echo "configure:1349: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"\${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. @@ -1268,29 +1361,31 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1272: checking for BSD-compatible nm" >&5 -if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then +echo "configure:1365: checking for BSD-compatible nm" >&5 +if eval "test \"\${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 + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + 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 + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; 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" + 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" + ac_cv_path_NM="$ac_dir/nm -p" + break else - ac_cv_path_NM="$ac_dir/nm" + 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 - break fi done IFS="$ac_save_ifs" @@ -1301,10 +1396,9 @@ 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:1307: checking whether ln -s works" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then +echo "configure:1401: checking whether ln -s works" >&5 +if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftestdata @@ -1323,30 +1417,37 @@ else echo "$ac_t""no" 1>&6 fi -if test $host != $build; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac # Check for any special flags to pass to ltconfig. -libtool_flags= +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 "$silent" = yes && libtool_flags="$libtool_flags --silent" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" 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" + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 1349 "configure"' > conftest.$ac_ext - if { (eval echo configure:1350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 1450 "configure"' > conftest.$ac_ext + if { (eval echo configure:1451: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -1364,157 +1465,118 @@ case "$host" in *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" 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:1375: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then + echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 +echo "configure:1472: checking whether the C compiler needs -belf" >&5 +if eval "test \"\${lt_cv_cc_needs_belf+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 + cat > conftest.$ac_ext <&6 -echo "configure:1407: 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. +; return 0; } +EOF +if { (eval echo configure:1484: \"$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 - 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 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_needs_belf=no fi -DLLTOOL="$ac_cv_prog_DLLTOOL" -if test -n "$DLLTOOL"; then - echo "$ac_t""$DLLTOOL" 1>&6 -else - echo "$ac_t""no" 1>&6 +rm -f conftest* fi -else - DLLTOOL="false" -fi -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 + ;; -# 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:1442: 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 +esac -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:1474: 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 +# 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 - AS="false" -fi + 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 - ;; - -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" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ || { 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" + test -f "$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 @@ -1557,15 +1619,30 @@ using_cgen=no +# If we are on a DOS filesystem, we must use gdb.ini rather than +# .gdbinit. +GDBINIT=".gdbinit" +case "${host}" in + *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) + GDBINIT="gdb.ini" + ;; +esac + + te_file=generic # Makefile target for installing gas in $(tooldir)/bin. install_tooldir=install-exec-tooldir canon_targets="" +all_targets=no if test -n "$enable_targets" ; then for t in `echo $enable_targets | sed 's/,/ /g'`; do - result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $t 2>/dev/null` + if test $t = "all"; then + all_targets=yes + continue + fi + result=`$ac_config_sub $t 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" # else @@ -1615,6 +1692,8 @@ for this_target in $target $canon_targets ; do m8*) cpu_type=m88k ;; mips*el) cpu_type=mips endian=little ;; mips*) cpu_type=mips endian=big ;; + pjl*) cpu_type=pj endian=little ;; + pj*) cpu_type=pj endian=big ;; powerpcle*) cpu_type=ppc endian=little ;; powerpc*) cpu_type=ppc endian=big ;; rs6000*) cpu_type=ppc ;; @@ -1659,14 +1738,18 @@ for this_target in $target $canon_targets ; do arm-*-aout) fmt=aout ;; arm-*-coff | thumb-*-coff) fmt=coff ;; arm-*-elf | thumb-*-elf) fmt=elf ;; + arm*-*-conix*) fmt=elf ;; arm-*-linux*aout*) fmt=aout em=linux ;; - arm-*-linux* | armv*-*-linux-gnu) fmt=elf em=linux ;; + arm*-*-linux-gnu*) fmt=elf em=linux ;; arm-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;; arm-*-oabi | thumb-*-oabi) fmt=elf ;; arm-epoc-pe | thumb-epoc-pe) fmt=coff em=epoc-pe ;; + arm-*-wince) fmt=coff em=wince-pe bfd_gas=yes;; arm-*-pe | thumb-*-pe) fmt=coff em=pe ;; arm-*-riscix*) fmt=aout em=riscix ;; + avr-*-*) fmt=elf bfd_gas=yes ;; + d10v-*-*) fmt=elf bfd_gas=yes ;; d30v-*-*) fmt=elf bfd_gas=yes ;; @@ -1674,6 +1757,7 @@ for this_target in $target $canon_targets ; do fr30-*-*) fmt=elf bfd_gas=yes ;; hppa-*-*elf*) fmt=elf em=hppa ;; + hppa-*-linux-gnu*) fmt=elf em=hppa ;; hppa-*-lites*) fmt=elf em=hppa ;; hppa-*-osf*) fmt=som em=hppa ;; hppa-*-rtems*) fmt=elf em=hppa ;; @@ -1684,6 +1768,7 @@ for this_target in $target $canon_targets ; do h8300-*-coff) fmt=coff ;; + i370-*-elf* | i370-*-linux*) fmt=elf ;; i386-ibm-aix*) fmt=coff em=i386aix ;; i386-sequent-bsd*) fmt=aout em=dynix bfd_gas=yes ;; i386-*-beospe*) fmt=coff em=pe bfd_gas=yes ;; @@ -1698,8 +1783,9 @@ for this_target in $target $canon_targets ; do i386-*-lynxos*) fmt=coff em=lynx ;; i386-*-sysv4* | i386-*-solaris* | i386-*-elf) fmt=elf bfd_gas=yes ;; - i386-*-freebsdelf*) fmt=elf bfd_gas=yes ;; - i386-*-freebsd*) fmt=aout em=386bsd ;; + i386-*-freebsdaout* | i386-*-freebsd12.* | i386-*-freebsd12) + fmt=aout em=386bsd ;; + i386-*-freebsd*) fmt=elf bfd_gas=yes ;; i386-*-coff | i386-*-sysv* | i386-*-sco3.2v5*coff | i386-*-isc*) fmt=coff ;; i386-*-sco3.2v5*) fmt=elf @@ -1714,6 +1800,7 @@ EOF i386-*-vsta) fmt=aout ;; i386-*-msdosdjgpp* | i386-*-go32* | i386-go32-rtems*) fmt=coff em=go32;; + i386-*-rtemself*) fmt=elf ;; i386-*-rtems*) fmt=coff ;; i386-*-gnu*) fmt=elf ;; i386-*-mach*) @@ -1722,8 +1809,10 @@ EOF i386-*-moss*) fmt=elf ;; i386-*-pe) fmt=coff em=pe ;; i386-*-cygwin*) fmt=coff em=pe bfd_gas=yes ;; + i386-*-interix*) fmt=coff em=interix bfd_gas=yes ;; i386-*-mingw32*) fmt=coff em=pe bfd_gas=yes ;; i386-*-*nt*) fmt=coff em=pe ;; + i386-*-vxworks*) fmt=aout ;; i960-*-bout) fmt=bout ;; i960-*-coff) fmt=coff em=ic960 ;; i960-*-rtems*) fmt=coff em=ic960 ;; @@ -1732,6 +1821,7 @@ EOF i960-*-vxworks5.0) fmt=bout ;; i960-*-vxworks5.*) fmt=coff em=ic960 ;; i960-*-vxworks*) fmt=bout ;; + i960-*-elf*) fmt=elf ;; m32r-*-*) fmt=elf bfd_gas=yes ;; @@ -1771,6 +1861,7 @@ EOF mips-*-osf*) fmt=ecoff endian=little ;; mips-*-ecoff*) fmt=ecoff ;; mips-*-ecoff*) fmt=ecoff ;; + mips-*-pe*) fmt=coff endian=little em=pe ;; mips-*-irix6*) fmt=elf ;; mips-*-irix5*) fmt=elf ;; mips-*-irix*) fmt=ecoff ;; @@ -1787,6 +1878,7 @@ EOF ;; mn10200-*-*) fmt=elf bfd_gas=yes ;; mn10300-*-*) fmt=elf bfd_gas=yes ;; + pj*) fmt=elf ;; ppc-*-pe | ppc-*-cygwin* | ppc-*-winnt*) fmt=coff em=pe ;; ppc-*-aix*) fmt=coff ;; @@ -1814,9 +1906,12 @@ EOF ppc-*-macos* | ppc-*-mpw*) fmt=coff em=macos ;; ppc-*-netware*) fmt=elf em=ppcnw ;; + ppc-*-vxworks*) fmt=elf ;; sh-*-elf*) fmt=elf ;; sh-*-coff*) fmt=coff ;; + sh-*-pe*) fmt=coff em=pe bfd_gas=yes;; + sh-*-rtemself*) fmt=elf ;; sh-*-rtems*) fmt=coff ;; ns32k-pc532-mach* | ns32k-pc532-ux*) fmt=aout em=pc532mach ;; @@ -1902,6 +1997,10 @@ EOF *-elf) bfd_gas=yes ;; *-ecoff) bfd_gas=yes ;; *-som) bfd_gas=yes ;; + #enable bfd for coff and aout to allow testing if a bfd target is + #the primary target, but not for coff or aout as the primary target + i386-coff) if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;; + i386-aout) if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;; *) ;; esac @@ -2008,17 +2107,39 @@ EOF mips-*-*-elf) case "$endian" in big) emulation="mipsbelf mipslelf mipself" ;; *) emulation="mipslelf mipsbelf mipself" ;; - # Uncommenting the next line will turn on support for i386 COFF - # in any i386 ELF configuration. This probably doesn't work - # correctly. - # i386-*-*-elf) emulation="i386coff i386elf" ;; esac ;; + # Uncommenting the next line will turn on support for i386 AOUT + # for the default linux configuration + # i386-*-linux*-elf) emulation="i386elf i386aout" ;; + # + i386-*-aout) emulation="i386aout" ;; + i386-*-coff) emulation="i386coff" ;; + i386-*-elf) emulation="i386elf" ;; esac emulations="$emulations $emulation" done +# Turn on all targets if possible +if test ${all_targets} = "yes"; then + case ${target_cpu_type} in + i386) + case ${obj_format} in + aout) + emulations="$emulations i386coff i386elf" + ;; + coff) + emulations="$emulations i386aout i386elf" + ;; + elf) + emulations="$emulations i386aout i386coff" + ;; + esac + ;; + esac +fi + # Assign floating point type. Most processors with FP support # IEEE FP. On those that don't support FP at all, usually IEEE # is emulated. @@ -2129,6 +2250,8 @@ for em in . $emulations ; do fmt=elf file=mipself ;; mipsbecoff | mipslecoff) fmt=ecoff file=mipsecoff ;; + i386aout) + fmt=aout file=i386aout ;; i386coff) fmt=coff file=i386coff ;; i386elf) @@ -2213,13 +2336,18 @@ EOF obj_format=multi fi if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then - te_file=multi - extra_objects="$extra_objects $emfiles" DEFAULT_EMULATION=`set . $emulations ; echo $2` - cat >> confdefs.h <<\EOF + # e-mips* has more than one emulation per file, e-i386* has just one at the + # moment. If only one emulation is specified, then don't define + # USE_EMULATIONS or include any of the e-files as they will only be bloat. + case "${obj_format}${emfiles}" in + multi* | *mips*) + extra_objects="$extra_objects $emfiles" + cat >> confdefs.h <<\EOF #define USE_EMULATIONS 1 EOF - + ;; + esac fi cat >> confdefs.h <&6 -echo "configure:2323: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:2437: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -2335,8 +2463,8 @@ 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:2353: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:2467: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -2382,12 +2510,12 @@ fi if test -z "$CC"; then case "`uname -s`" in - *win32* | *WIN32*) + *win32* | *WIN32* | *CYGWIN*) # 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:2404: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:2518: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -2417,8 +2545,8 @@ 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:2436: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:2550: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2429,12 +2557,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2447 "configure" +#line 2561 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2566: \"$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 @@ -2459,14 +2587,14 @@ 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:2478: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:2592: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $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:2483: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then +echo "configure:2597: checking whether we are using GNU C" >&5 +if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2606: \"$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 @@ -2493,8 +2621,8 @@ 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:2511: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then +echo "configure:2625: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c @@ -2530,8 +2658,8 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2548: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then +echo "configure:2662: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_YACC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$YACC"; then @@ -2561,13 +2689,13 @@ done test -n "$YACC" || YACC="yacc" echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2579: checking how to run the C preprocessor" >&5 +echo "configure:2693: 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 +if eval "test \"\${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 @@ -2576,13 +2704,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2714: \"$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 : @@ -2593,13 +2721,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2617: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2731: \"$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 : @@ -2610,13 +2738,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2634: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2748: \"$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 : @@ -2646,8 +2774,8 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2664: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then +echo "configure:2778: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_LEX+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$LEX"; then @@ -2679,8 +2807,8 @@ test -n "$LEX" || LEX=""$missing_dir/missing flex"" # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2697: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then +echo "configure:2811: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_LEX+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$LEX"; then @@ -2713,15 +2841,15 @@ then *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:2731: checking for yywrap in -l$ac_lib" >&5 -ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then +echo "configure:2845: checking for yywrap in -l$ac_lib" >&5 +ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-:%__p__%'` +if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2864: \"$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 @@ -2755,8 +2883,8 @@ fi fi echo $ac_n "checking lex output file root""... $ac_c" 1>&6 -echo "configure:2773: checking lex output file root" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then +echo "configure:2887: checking lex output file root" >&5 +if eval "test \"\${ac_cv_prog_lex_root+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # The minimal lex program is just a single line: %%. But some broken lexes @@ -2776,8 +2904,8 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 -echo "configure:2794: checking whether yytext is a pointer" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then +echo "configure:2908: checking whether yytext is a pointer" >&5 +if eval "test \"\${ac_cv_prog_lex_yytext_pointer+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # POSIX says lex can declare yytext either as a pointer or an array; the @@ -2788,14 +2916,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c ac_save_LIBS="$LIBS" LIBS="$LIBS $LEXLIB" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_prog_lex_yytext_pointer=yes else @@ -2819,7 +2947,7 @@ fi ALL_LINGUAS= echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:2837: checking for POSIXized ISC" >&5 +echo "configure:2951: 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 @@ -2840,12 +2968,12 @@ else fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2858: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then +echo "configure:2972: checking for ANSI C header files" >&5 +if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2853,7 +2981,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2871: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2985: \"$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* @@ -2870,7 +2998,7 @@ 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 @@ -2888,7 +3016,7 @@ 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 @@ -2909,7 +3037,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2920,7 +3048,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2944,12 +3072,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2962: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then +echo "configure:3076: checking for working const" >&5 +if eval "test \"\${ac_cv_c_const+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -3019,21 +3147,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:3037: checking for inline" >&5 -if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then +echo "configure:3151: checking for inline" >&5 +if eval "test \"\${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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -3059,12 +3187,12 @@ EOF esac echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:3077: checking for off_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then +echo "configure:3191: checking for off_t" >&5 +if eval "test \"\${ac_cv_type_off_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3075,29 +3203,31 @@ 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 + eval "ac_cv_type_off_t=yes" else rm -rf conftest* - ac_cv_type_off_t=no + eval "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 +if eval "test \"`echo '$ac_cv_type_'off_t`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <&6 -echo "configure:3110: checking for size_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then +echo "configure:3226: checking for size_t" >&5 +if eval "test \"\${ac_cv_type_size_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3108,17 +3238,19 @@ 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 + eval "ac_cv_type_size_t=yes" else rm -rf conftest* - ac_cv_type_size_t=no + eval "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 +if eval "test \"`echo '$ac_cv_type_'size_t`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <&6 -echo "configure:3145: checking for working alloca.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then +echo "configure:3263: checking for working alloca.h" >&5 +if eval "test \"\${ac_cv_header_alloca_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:3157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3275: \"$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 @@ -3160,12 +3292,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:3178: checking for alloca" >&5 -if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then +echo "configure:3296: checking for alloca" >&5 +if eval "test \"\${ac_cv_func_alloca_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3329: \"$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 @@ -3225,12 +3357,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:3243: checking whether alloca needs Cray hooks" >&5 -if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then +echo "configure:3361: checking whether alloca needs Cray hooks" >&5 +if eval "test \"\${ac_cv_os_cray+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&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:3273: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3391: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3420: \"$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 @@ -3310,15 +3443,15 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:3328: checking stack direction for C alloca" >&5 -if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then +echo "configure:3447: checking stack direction for C alloca" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3474: \"$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 @@ -3362,17 +3495,17 @@ 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:3380: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:3499: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3390: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3509: \"$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* @@ -3401,12 +3534,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3419: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3538: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3567: \"$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 @@ -3454,15 +3588,15 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3472: checking for working mmap" >&5 -if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then +echo "configure:3592: checking for working mmap" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3740: \"$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 @@ -3630,17 +3764,17 @@ 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:3648: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:3768: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3658: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3778: \"$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* @@ -3670,12 +3804,12 @@ done __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3688: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3808: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3837: \"$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 @@ -3727,12 +3862,12 @@ done for ac_func in stpcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3745: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3866: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3895: \"$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 @@ -3789,19 +3925,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:3807: checking for LC_MESSAGES" >&5 -if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then +echo "configure:3929: checking for LC_MESSAGES" >&5 +if eval "test \"\${am_cv_val_LC_MESSAGES+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:3819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3941: \"$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 @@ -3822,7 +3958,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:3840: checking whether NLS is requested" >&5 +echo "configure:3962: 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" @@ -3842,7 +3978,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:3860: checking whether included gettext is requested" >&5 +echo "configure:3982: 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" @@ -3861,17 +3997,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:3879: checking for libintl.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:4001: checking for libintl.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3889: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4011: \"$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* @@ -3888,19 +4024,19 @@ 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:3906: checking for gettext in libc" >&5 -if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then +echo "configure:4028: checking for gettext in libc" >&5 +if eval "test \"\${gt_cv_func_gettext_libc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:3918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4040: \"$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 @@ -3916,15 +4052,15 @@ 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:3934: 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 "configure:4056: checking for bindtextdomain in -lintl" >&5 +ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-:%__p__%'` +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4075: \"$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 @@ -3951,19 +4087,19 @@ 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:3969: checking for gettext in libintl" >&5 -if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then +echo "configure:4091: checking for gettext in libintl" >&5 +if eval "test \"\${gt_cv_func_gettext_libintl+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4103: \"$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 @@ -3991,8 +4127,8 @@ 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:4009: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then +echo "configure:4131: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_MSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$MSGFMT" in @@ -4025,12 +4161,12 @@ fi for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4043: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:4165: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4194: \"$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 @@ -4080,8 +4217,8 @@ 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:4098: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then +echo "configure:4221: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_GMSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$GMSGFMT" in @@ -4116,8 +4253,8 @@ 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:4134: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then +echo "configure:4257: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_XGETTEXT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$XGETTEXT" in @@ -4148,7 +4285,7 @@ else fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -4188,8 +4325,8 @@ fi # 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:4206: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then +echo "configure:4329: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_MSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$MSGFMT" in @@ -4222,8 +4359,8 @@ 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:4240: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then +echo "configure:4363: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_GMSGFMT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$GMSGFMT" in @@ -4258,8 +4395,8 @@ 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:4276: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then +echo "configure:4399: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_XGETTEXT+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$XGETTEXT" in @@ -4348,7 +4485,7 @@ fi LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:4366: checking for catalogs to be installed" >&5 +echo "configure:4489: checking for catalogs to be installed" >&5 NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in @@ -4376,17 +4513,17 @@ echo "configure:4366: checking for catalogs to be installed" >&5 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:4394: checking for linux/version.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:4517: checking for linux/version.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4527: \"$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* @@ -4449,7 +4586,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:4467: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:4590: 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" @@ -4472,12 +4609,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:4490: checking for Cygwin environment" >&5 -if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then +echo "configure:4613: checking for Cygwin environment" >&5 +if eval "test \"\${ac_cv_cygwin+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4629: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -4498,26 +4635,25 @@ else 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:4523: checking for mingw32 environment" >&5 -if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then +echo "configure:4645: checking for mingw32 environment" >&5 +if eval "test \"\${ac_cv_mingw32+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4657: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -4527,29 +4663,57 @@ else 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 EMX OS/2 environment""... $ac_c" 1>&6 +echo "configure:4673: checking for EMX OS/2 environment" >&5 +if eval "test \"\${ac_cv_emxos2+set}\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_emxos2=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_emxos2=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_emxos2" 1>&6 +EMXOS2= +test "$ac_cv_emxos2" = yes && EMXOS2=yes + echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:4554: checking for executable suffix" >&5 -if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then +echo "configure:4704: checking for executable suffix" >&5 +if eval "test \"\${ac_cv_exeext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - if test "$CYGWIN" = yes || test "$MINGW32" = yes; then + if test "$CYGWIN" = yes || test "$MINGW32" = yes || test "$EMXOS2" = 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:4564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:4714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj | *.ilk | *.pdb) ;; + *.c | *.C | *.o | *.obj | *.xcoff) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -4571,17 +4735,17 @@ for ac_hdr in string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h e do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4589: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:4739: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4599: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4749: \"$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* @@ -4611,7 +4775,7 @@ done # Put this here so that autoconf's "cross-compiling" message doesn't confuse # people who are not cross-compiling but are compiling cross-assemblers. echo $ac_n "checking whether compiling a cross-assembler""... $ac_c" 1>&6 -echo "configure:4629: checking whether compiling a cross-assembler" >&5 +echo "configure:4779: checking whether compiling a cross-assembler" >&5 if test "${host}" = "${target}"; then cross_gas=no else @@ -4626,19 +4790,19 @@ echo "$ac_t""$cross_gas" 1>&6 # 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:4644: checking for working alloca.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then +echo "configure:4794: checking for working alloca.h" >&5 +if eval "test \"\${ac_cv_header_alloca_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4656: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4806: \"$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 @@ -4659,12 +4823,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4677: checking for alloca" >&5 -if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then +echo "configure:4827: checking for alloca" >&5 +if eval "test \"\${ac_cv_func_alloca_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4860: \"$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 @@ -4724,12 +4888,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4742: checking whether alloca needs Cray hooks" >&5 -if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then +echo "configure:4892: checking whether alloca needs Cray hooks" >&5 +if eval "test \"\${ac_cv_os_cray+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&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:4772: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:4922: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4951: \"$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 @@ -4809,15 +4974,15 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4827: checking stack direction for C alloca" >&5 -if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then +echo "configure:4978: checking stack direction for C alloca" >&5 +if eval "test \"\${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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5005: \"$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 @@ -4858,21 +5023,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:4876: checking for inline" >&5 -if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then +echo "configure:5027: checking for inline" >&5 +if eval "test \"\${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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5041: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -4902,12 +5067,12 @@ esac for ac_func in unlink remove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4920: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:5071: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5100: \"$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 @@ -4959,12 +5125,12 @@ done for ac_func in sbrk do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4977: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:5129: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5158: \"$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 @@ -5016,12 +5183,12 @@ done # enough, but on some of those systems, the assert macro relies on requoting # working properly! echo $ac_n "checking for working assert macro""... $ac_c" 1>&6 -echo "configure:5034: checking for working assert macro" >&5 -if eval "test \"`echo '$''{'gas_cv_assert_ok'+set}'`\" = set"; then +echo "configure:5187: checking for working assert macro" >&5 +if eval "test \"\${gas_cv_assert_ok+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5037,7 +5204,7 @@ assert (a == b ; return 0; } EOF -if { (eval echo configure:5055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_assert_ok=yes else @@ -5078,12 +5245,12 @@ gas_test_headers=" " echo $ac_n "checking whether declaration is required for strstr""... $ac_c" 1>&6 -echo "configure:5096: checking whether declaration is required for strstr" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_strstr'+set}'`\" = set"; then +echo "configure:5249: checking whether declaration is required for strstr" >&5 +if eval "test \"\${gas_cv_decl_needed_strstr+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_strstr=no else @@ -5115,12 +5282,12 @@ fi echo $ac_n "checking whether declaration is required for malloc""... $ac_c" 1>&6 -echo "configure:5133: checking whether declaration is required for malloc" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_malloc'+set}'`\" = set"; then +echo "configure:5286: checking whether declaration is required for malloc" >&5 +if eval "test \"\${gas_cv_decl_needed_malloc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_malloc=no else @@ -5152,12 +5319,12 @@ fi echo $ac_n "checking whether declaration is required for free""... $ac_c" 1>&6 -echo "configure:5170: checking whether declaration is required for free" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_free'+set}'`\" = set"; then +echo "configure:5323: checking whether declaration is required for free" >&5 +if eval "test \"\${gas_cv_decl_needed_free+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_free=no else @@ -5189,12 +5356,12 @@ fi echo $ac_n "checking whether declaration is required for sbrk""... $ac_c" 1>&6 -echo "configure:5207: checking whether declaration is required for sbrk" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_sbrk'+set}'`\" = set"; then +echo "configure:5360: checking whether declaration is required for sbrk" >&5 +if eval "test \"\${gas_cv_decl_needed_sbrk+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_sbrk=no else @@ -5226,12 +5393,12 @@ fi echo $ac_n "checking whether declaration is required for environ""... $ac_c" 1>&6 -echo "configure:5244: checking whether declaration is required for environ" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_environ'+set}'`\" = set"; then +echo "configure:5397: checking whether declaration is required for environ" >&5 +if eval "test \"\${gas_cv_decl_needed_environ+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5413: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_environ=no else @@ -5266,12 +5433,12 @@ fi # for it? echo $ac_n "checking whether declaration is required for errno""... $ac_c" 1>&6 -echo "configure:5284: checking whether declaration is required for errno" >&5 -if eval "test \"`echo '$''{'gas_cv_decl_needed_errno'+set}'`\" = set"; then +echo "configure:5437: checking whether declaration is required for errno" >&5 +if eval "test \"\${gas_cv_decl_needed_errno+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gas_cv_decl_needed_errno=no else @@ -5398,7 +5565,7 @@ do 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" + echo "$CONFIG_STATUS generated by autoconf version 2.13.1" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -5409,7 +5576,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile doc/Makefile .gdbinit:gdbinit.in po/Makefile.in:po/Make-in config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile doc/Makefile ${GDBINIT}:gdbinit.in po/Makefile.in:po/Make-in config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then @@ -5746,5 +5910,5 @@ 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 +test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 diff --git a/gas/configure.bat b/gas/configure.bat deleted file mode 100644 index 1fd269f..0000000 --- a/gas/configure.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -if "%1" == "h8/300" goto h8300 - -echo Configuring gas for go32 -update config/tc-i386.c targ-cpu.c -update config/tc-i386.h targ-cpu.h -update config/te-go32.h targ-env.h -update config/obj-coff.h obj-format.h -update config/obj-coff.c obj-format.c -update config/atof-ieee.c atof-targ.c -goto common - -:h8300 -echo Configuring gas for H8/300 -copy config\ho-go32.h host.h -copy config\tc-h8300.c targ-cpu.c -copy config\tc-h8300.h targ-cpu.h -copy config\te-generic.h targ-env.h -copy config\objcoffbfd.h obj-format.h -copy config\objcoffbfd.c obj-format.c -copy config\atof-ieee.c atof-targ.c - -:common - -echo # Makefile generated by "configure.bat"> Makefile.2 -echo all.dos : as.new gasp.new>> Makefile.2 - -if exist config.sed del config.sed - -echo "s/@srcdir@/./g ">> config.sed -echo "s/@target_alias@/go32/ ">> config.sed -echo "s/@prefix@// ">> config.sed -echo "s/@CC@/gcc/g ">> config.sed -echo "s/@OPCODES_LIB@/..\/opcodes\/libopcodes.a/g ">> config.sed -echo "s/@BFDLIB@/..\/bfd\/libbfd.a/g ">> config.sed -echo "s/@ALL_OBJ_DEPS@/..\/bfd\/bfd.h/g ">> config.sed - -echo "/^all[ ]*:/ a\ ">> config.sed -echo "dummy: ">> config.sed - -echo "s/\/usr[^ ]*.h//g ">> config.sed - -echo "/^config.h[ ]*:/ d ">> config.sed -echo "s/^Makefile/not-Makefile/ ">> config.sed - -sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed -sed -f config2.sed Makefile.in >> Makefile.2 -update Makefile.2 Makefile -del Makefile.2 -del config.sed -del config2.sed - -echo #ifndef GAS_VERSION> config.new -sed -n "/^VERSION=/p" Makefile.in | sed -e "s/VERSION=/#define GAS_VERSION \"/" -e "s/$/\"/">> config.new -type config\go32.cfg >> config.new -echo #endif>> config.new -update config.new config.h diff --git a/gas/configure.in b/gas/configure.in index 4d847ba..8ee42a6 100644 --- a/gas/configure.in +++ b/gas/configure.in @@ -10,7 +10,7 @@ AC_INIT(as.h) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(gas, 2.9.4) +AM_INIT_AUTOMAKE(gas, 2.9.5) AM_PROG_LIBTOOL @@ -43,15 +43,30 @@ using_cgen=no # Generate a header file AM_CONFIG_HEADER(config.h:config.in) +# If we are on a DOS filesystem, we must use gdb.ini rather than +# .gdbinit. +GDBINIT=".gdbinit" +case "${host}" in + *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) + GDBINIT="gdb.ini" + ;; +esac +AC_SUBST(GDBINIT) + te_file=generic # Makefile target for installing gas in $(tooldir)/bin. install_tooldir=install-exec-tooldir canon_targets="" +all_targets=no if test -n "$enable_targets" ; then for t in `echo $enable_targets | sed 's/,/ /g'`; do - result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $t 2>/dev/null` + if test $t = "all"; then + all_targets=yes + continue + fi + result=`$ac_config_sub $t 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" # else @@ -93,6 +108,8 @@ changequote([,])dnl m8*) cpu_type=m88k ;; mips*el) cpu_type=mips endian=little ;; mips*) cpu_type=mips endian=big ;; + pjl*) cpu_type=pj endian=little ;; + pj*) cpu_type=pj endian=big ;; powerpcle*) cpu_type=ppc endian=little ;; powerpc*) cpu_type=ppc endian=big ;; rs6000*) cpu_type=ppc ;; @@ -137,14 +154,18 @@ changequote([,])dnl arm-*-aout) fmt=aout ;; arm-*-coff | thumb-*-coff) fmt=coff ;; arm-*-elf | thumb-*-elf) fmt=elf ;; + arm*-*-conix*) fmt=elf ;; arm-*-linux*aout*) fmt=aout em=linux ;; - arm-*-linux* | armv*-*-linux-gnu) fmt=elf em=linux ;; + arm*-*-linux-gnu*) fmt=elf em=linux ;; arm-*-netbsd*) fmt=aout em=nbsd bfd_gas=yes ;; arm-*-oabi | thumb-*-oabi) fmt=elf ;; arm-epoc-pe | thumb-epoc-pe) fmt=coff em=epoc-pe ;; + arm-*-wince) fmt=coff em=wince-pe bfd_gas=yes;; arm-*-pe | thumb-*-pe) fmt=coff em=pe ;; arm-*-riscix*) fmt=aout em=riscix ;; + avr-*-*) fmt=elf bfd_gas=yes ;; + d10v-*-*) fmt=elf bfd_gas=yes ;; d30v-*-*) fmt=elf bfd_gas=yes ;; @@ -152,6 +173,7 @@ changequote([,])dnl fr30-*-*) fmt=elf bfd_gas=yes ;; hppa-*-*elf*) fmt=elf em=hppa ;; + hppa-*-linux-gnu*) fmt=elf em=hppa ;; hppa-*-lites*) fmt=elf em=hppa ;; hppa-*-osf*) fmt=som em=hppa ;; hppa-*-rtems*) fmt=elf em=hppa ;; @@ -162,6 +184,7 @@ changequote([,])dnl h8300-*-coff) fmt=coff ;; + i370-*-elf* | i370-*-linux*) fmt=elf ;; i386-ibm-aix*) fmt=coff em=i386aix ;; i386-sequent-bsd*) fmt=aout em=dynix bfd_gas=yes ;; i386-*-beospe*) fmt=coff em=pe bfd_gas=yes ;; @@ -176,8 +199,9 @@ changequote([,])dnl i386-*-lynxos*) fmt=coff em=lynx ;; i386-*-sysv4* | i386-*-solaris* | i386-*-elf) fmt=elf bfd_gas=yes ;; - i386-*-freebsdelf*) fmt=elf bfd_gas=yes ;; - i386-*-freebsd*) fmt=aout em=386bsd ;; + i386-*-freebsdaout* | i386-*-freebsd[12].* | i386-*-freebsd[12]) + fmt=aout em=386bsd ;; + i386-*-freebsd*) fmt=elf bfd_gas=yes ;; i386-*-coff | i386-*-sysv* | i386-*-sco3.2v5*coff | i386-*-isc*) fmt=coff ;; i386-*-sco3.2v5*) fmt=elf @@ -190,6 +214,7 @@ changequote([,])dnl i386-*-vsta) fmt=aout ;; i386-*-msdosdjgpp* | i386-*-go32* | i386-go32-rtems*) fmt=coff em=go32;; + i386-*-rtemself*) fmt=elf ;; i386-*-rtems*) fmt=coff ;; i386-*-gnu*) fmt=elf ;; i386-*-mach*) @@ -198,8 +223,10 @@ changequote([,])dnl i386-*-moss*) fmt=elf ;; i386-*-pe) fmt=coff em=pe ;; i386-*-cygwin*) fmt=coff em=pe bfd_gas=yes ;; + i386-*-interix*) fmt=coff em=interix bfd_gas=yes ;; i386-*-mingw32*) fmt=coff em=pe bfd_gas=yes ;; i386-*-*nt*) fmt=coff em=pe ;; + i386-*-vxworks*) fmt=aout ;; i960-*-bout) fmt=bout ;; i960-*-coff) fmt=coff em=ic960 ;; i960-*-rtems*) fmt=coff em=ic960 ;; @@ -208,6 +235,7 @@ changequote([,])dnl i960-*-vxworks5.0) fmt=bout ;; i960-*-vxworks5.*) fmt=coff em=ic960 ;; i960-*-vxworks*) fmt=bout ;; + i960-*-elf*) fmt=elf ;; m32r-*-*) fmt=elf bfd_gas=yes ;; @@ -247,6 +275,7 @@ changequote([,])dnl mips-*-osf*) fmt=ecoff endian=little ;; mips-*-ecoff*) fmt=ecoff ;; mips-*-ecoff*) fmt=ecoff ;; + mips-*-pe*) fmt=coff endian=little em=pe ;; mips-*-irix6*) fmt=elf ;; mips-*-irix5*) fmt=elf ;; mips-*-irix*) fmt=ecoff ;; @@ -261,6 +290,7 @@ changequote([,])dnl ;; mn10200-*-*) fmt=elf bfd_gas=yes ;; mn10300-*-*) fmt=elf bfd_gas=yes ;; + pj*) fmt=elf ;; ppc-*-pe | ppc-*-cygwin* | ppc-*-winnt*) fmt=coff em=pe ;; ppc-*-aix*) fmt=coff ;; @@ -286,9 +316,12 @@ changequote([,])dnl ppc-*-macos* | ppc-*-mpw*) fmt=coff em=macos ;; ppc-*-netware*) fmt=elf em=ppcnw ;; + ppc-*-vxworks*) fmt=elf ;; sh-*-elf*) fmt=elf ;; sh-*-coff*) fmt=coff ;; + sh-*-pe*) fmt=coff em=pe bfd_gas=yes;; + sh-*-rtemself*) fmt=elf ;; sh-*-rtems*) fmt=coff ;; ns32k-pc532-mach* | ns32k-pc532-ux*) fmt=aout em=pc532mach ;; @@ -372,6 +405,10 @@ changequote([,])dnl *-elf) bfd_gas=yes ;; *-ecoff) bfd_gas=yes ;; *-som) bfd_gas=yes ;; + #enable bfd for coff and aout to allow testing if a bfd target is + #the primary target, but not for coff or aout as the primary target + i386-coff) if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;; + i386-aout) if test x${primary_bfd_gas} = xyes; then bfd_gas=yes; fi ;; *) ;; esac @@ -475,17 +512,39 @@ changequote([,])dnl mips-*-*-elf) case "$endian" in big) emulation="mipsbelf mipslelf mipself" ;; *) emulation="mipslelf mipsbelf mipself" ;; - # Uncommenting the next line will turn on support for i386 COFF - # in any i386 ELF configuration. This probably doesn't work - # correctly. - # i386-*-*-elf) emulation="i386coff i386elf" ;; esac ;; + # Uncommenting the next line will turn on support for i386 AOUT + # for the default linux configuration + # i386-*-linux*-elf) emulation="i386elf i386aout" ;; + # + i386-*-aout) emulation="i386aout" ;; + i386-*-coff) emulation="i386coff" ;; + i386-*-elf) emulation="i386elf" ;; esac emulations="$emulations $emulation" done +# Turn on all targets if possible +if test ${all_targets} = "yes"; then + case ${target_cpu_type} in + i386) + case ${obj_format} in + aout) + emulations="$emulations i386coff i386elf" + ;; + coff) + emulations="$emulations i386aout i386elf" + ;; + elf) + emulations="$emulations i386aout i386coff" + ;; + esac + ;; + esac +fi + # Assign floating point type. Most processors with FP support # IEEE FP. On those that don't support FP at all, usually IEEE # is emulated. @@ -575,6 +634,8 @@ for em in . $emulations ; do fmt=elf file=mipself ;; mipsbecoff | mipslecoff) fmt=ecoff file=mipsecoff ;; + i386aout) + fmt=aout file=i386aout ;; i386coff) fmt=coff file=i386coff ;; i386elf) @@ -605,10 +666,15 @@ if test `set . $formats ; shift ; echo $#` -gt 1 ; then obj_format=multi fi if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then - te_file=multi - extra_objects="$extra_objects $emfiles" DEFAULT_EMULATION=`set . $emulations ; echo $2` - AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) + # e-mips* has more than one emulation per file, e-i386* has just one at the + # moment. If only one emulation is specified, then don't define + # USE_EMULATIONS or include any of the e-files as they will only be bloat. + case "${obj_format}${emfiles}" in + multi* | *mips*) + extra_objects="$extra_objects $emfiles" + AC_DEFINE(USE_EMULATIONS, 1, [Use emulation support?]) ;; + esac fi AC_SUBST(extra_objects) AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS, [Supported emulations.]) @@ -749,7 +815,7 @@ dnl the build directory which include the right .h file. Make sure dnl the old symlinks don't exist, so that a reconfigure in an existing dnl directory behaves reasonably. -AC_OUTPUT(Makefile doc/Makefile .gdbinit:gdbinit.in po/Makefile.in:po/Make-in, +AC_OUTPUT(Makefile doc/Makefile ${GDBINIT}:gdbinit.in po/Makefile.in:po/Make-in, [rm -f targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c itbl-cpu.h echo '#include "tc-'"${target_cpu_type}"'.h"' > targ-cpu.h echo '#include "obj-'"${obj_format}"'.h"' > obj-format.h diff --git a/gas/dep-in.sed b/gas/dep-in.sed index c07f969..8771f0f 100644 --- a/gas/dep-in.sed +++ b/gas/dep-in.sed @@ -18,7 +18,6 @@ s! obj-format.h!!g s! targ-cpu.h!!g s! flonum.h!!g s! expr.h!!g -s! struc-symbol.h!!g s! write.h!!g s! frags.h!!g s! hash.h!!g diff --git a/gas/doc/Makefile.am b/gas/doc/Makefile.am index eaf5a4a..c6eaf77 100644 --- a/gas/doc/Makefile.am +++ b/gas/doc/Makefile.am @@ -22,11 +22,14 @@ CPU_DOCS = \ c-h8300.texi \ c-h8500.texi \ c-hppa.texi \ + c-i370.texi \ c-i386.texi \ c-i960.texi \ + c-m32r.texi \ c-m68k.texi \ c-mips.texi \ c-ns32k.texi \ + c-pj.texi \ c-sh.texi \ c-sparc.texi \ c-vax.texi \ diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in index 5f4d1a5..f9fed15 100644 --- a/gas/doc/Makefile.in +++ b/gas/doc/Makefile.in @@ -72,6 +72,7 @@ CC = @CC@ DATADIRNAME = @DATADIRNAME@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ +GDBINIT = @GDBINIT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GT_NO = @GT_NO@ @@ -81,7 +82,6 @@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ INTLOBJS = @INTLOBJS@ -LD = @LD@ LEX = @LEX@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ @@ -89,7 +89,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ -NM = @NM@ +OBJDUMP = @OBJDUMP@ OPCODES_LIB = @OPCODES_LIB@ PACKAGE = @PACKAGE@ POFILES = @POFILES@ @@ -97,7 +97,6 @@ POSUB = @POSUB@ RANLIB = @RANLIB@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ -USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@ VERSION = @VERSION@ YACC = @YACC@ atof = @atof@ @@ -125,11 +124,14 @@ CPU_DOCS = \ c-h8300.texi \ c-h8500.texi \ c-hppa.texi \ + c-i370.texi \ c-i386.texi \ c-i960.texi \ + c-m32r.texi \ c-m68k.texi \ c-mips.texi \ c-ns32k.texi \ + c-pj.texi \ c-sh.texi \ c-sparc.texi \ c-vax.texi \ @@ -161,7 +163,7 @@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: @@ -342,7 +344,7 @@ 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; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/gas/doc/all.texi b/gas/doc/all.texi index 9b90c5b..d1058fb 100644 --- a/gas/doc/all.texi +++ b/gas/doc/all.texi @@ -1,4 +1,4 @@ -@c Copyright 1992, 1993 Free Software Foundation, Inc. +@c Copyright 1992, 1993, 2000 Free Software Foundation, Inc. @c This file is part of the documentation for the GAS manual @c Configuration settings for all-inclusive version of manual @@ -32,19 +32,21 @@ @set D30V @set H8/300 @set H8/500 -@set SH +@set HPPA +@set I370 @set I80386 @set I960 -@set MCORE -@set MIPS @set M32R @set M680X0 -@set Z8000 +@set MCORE +@set MIPS +@set PJ +@set SH @set SPARC +@set V850 @set VAX @set VXWORKS -@set HPPA -@set V850 +@set Z8000 @c Does this version of the assembler use the difference-table kluge? @set DIFF-TBL-KLUGE diff --git a/gas/doc/as.1 b/gas/doc/as.1 index adf2886..08d5805 100644 --- a/gas/doc/as.1 +++ b/gas/doc/as.1 @@ -195,8 +195,14 @@ Announce \c .B as\c \& version .TP -.B \-W -Suppress warning messages +.B \-W, \-\-no-warn +Suppress warning messages. +.TP +.B \-\-fatal\-warnings +Consider warnings to be fatal. +.TP +.B \-\-warn +Just warn on warnings. .TP .IR "\-\^\-" "\ |\ " "files\|.\|.\|." Source files to assemble, or standard input (\c diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index afe362a..5917a00 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -1,5 +1,5 @@ \input texinfo @c -*-Texinfo-*- -@c Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998 +@c Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 2000 @c Free Software Foundation, Inc. @c UPDATE!! On future updates-- @c (1) check for new machine-dep cmdline options in @@ -202,9 +202,10 @@ Here is a brief summary of how to invoke @code{@value{AS}}. For details, @c to be limited to one line for the header. @smallexample @value{AS} [ -a[cdhlns][=file] ] [ -D ] [ --defsym @var{sym}=@var{val} ] - [ -f ] [ --gstabs ] [ --help ] [ -I @var{dir} ] [ -J ] [ -K ] [ -L ] + [ -f ] [ --gstabs ] [ --gdwarf2 ] [ --help ] [ -I @var{dir} ] [ -J ] [ -K ] [ -L ] [ --keep-locals ] [ -o @var{objfile} ] [ -R ] [ --statistics ] [ -v ] - [ -version ] [ --version ] [ -W ] [ -w ] [ -x ] [ -Z ] + [ -version ] [ --version ] [ -W ] [ --warn ] [ --fatal-warnings ] + [ -w ] [ -x ] [ -Z ] @ifset A29K @c am29k has no machine-dependent assembler options @end ifset @@ -212,12 +213,20 @@ Here is a brief summary of how to invoke @code{@value{AS}}. For details, [ -mbig-endian | -mlittle-endian ] @end ifset @ifset ARM - [ -m[arm]1 | -m[arm]2 | -m[arm]250 | -m[arm]3 | -m[arm]6 | -m[arm]7[t][[d]m[i]] ] - [ -m[arm]v2 | -m[arm]v2a | -m[arm]v3 | -m[arm]v3m | -m[arm]v4 | -m[arm]v4t ] + [ -m[arm]1 | -m[arm]2 | -m[arm]250 | -m[arm]3 | -m[arm]6 | -m[arm]60 | + -m[arm]600 | -m[arm]610 | -m[arm]620 | -m[arm]7[t][[d]m[i]][fe] | -m[arm]70 | + -m[arm]700 | -m[arm]710[c] | -m[arm]7100 | -m[arm]7500 | -m[arm]8 | + -m[arm]810 | -m[arm]9 | -m[arm]920 | -m[arm]920t | -m[arm]9tdmi | + -mstrongarm | -mstrongarm110 | -mstrongarm1100 ] + [ -m[arm]v2 | -m[arm]v2a | -m[arm]v3 | -m[arm]v3m | -m[arm]v4 | -m[arm]v4t | + -m[arm]v5 | -[arm]v5t ] [ -mthumb | -mall ] [ -mfpa10 | -mfpa11 | -mfpe-old | -mno-fpu ] [ -EB | -EL ] - [ -mapcs-32 | -mapcs-26 ] + [ -mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant ] + [ -mthumb-interwork ] + [ -moabi ] + [ -k ] @end ifset @ifset D10V [ -O ] @@ -231,6 +240,9 @@ Here is a brief summary of how to invoke @code{@value{AS}}. For details, @ifset HPPA @c HPPA has no machine-dependent assembler options (yet). @end ifset +@ifset PJ + [ -mb | -me ] +@end ifset @ifset SPARC @c The order here is important. See c-sparc.texi. [ -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite @@ -311,6 +323,10 @@ compiler output). Generate stabs debugging information for each assembler line. This may help debugging assembler code, if the debugger can handle it. +@item --gdwarf2 +Generate DWARF2 debugging information for each assembler line. This +may help debugging assembler code, if the debugger can handle it. + @item --help Print a summary of the command line options and exit. @@ -355,8 +371,15 @@ Print the @code{as} version. Print the @code{as} version and exit. @item -W +@itemx --no-warn Suppress warning messages. +@item --fatal-warnings +Treat warnings as errors. + +@item --warn +Don't suppress warning messages or treat them as errors. + @item -w Ignored. @@ -395,16 +418,23 @@ The following options are available when @value{AS} is configured for the ARM processor family. @table @code -@item -m[arm]1 | -m[arm]2 | -m[arm]250 | -m[arm]3 | -m[arm]6 | -m[arm]7[t][[d]m] | -m[arm]v2 | -m[arm]v2a | -m[arm]v3 | -m[arm]v3m | -m[arm]v4 | -m[arm]v4t -Specify which variant of the ARM architecture is the target. +@item -m[arm][1|2|3|6|7|8|9][...] +Specify which ARM processor variant is the target. +@item -m[arm]v[2|2a|3|3m|4|4t|5|5t] +Specify which ARM architecture variant is used by the target. @item -mthumb | -mall Enable or disable Thumb only instruction decoding. @item -mfpa10 | -mfpa11 | -mfpe-old | -mno-fpu Select which Floating Point architcture is the target. -@item -mapcs-32 | -mapcs-26 +@item -mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant | -moabi Select which procedure calling convention is in use. @item -EB | -EL Select either big-endian (-EB) or little-endian (-EL) output. +@item -mthumb-interwork +Specify that the code has been generated with interworking between Thumb and +ARM code in mind. +@item -k +Specify that PIC code has been generated. @end table @end ifset @@ -485,6 +515,26 @@ unit coprocessor. The default is to assume an MMU for 68020 and up. @end table @end ifset +@ifset PJ +The following options are available when @value{AS} is configured for +a picoJava processor. + +@table @code + +@cindex PJ endianness +@cindex endianness, PJ +@cindex big endian output, PJ +@item -mb +Generate ``big endian'' format output. + +@cindex little endian output, PJ +@item -ml +Generate ``little endian'' format output. + +@end table +@end ifset + + @ifset SPARC The following options are available when @code{@value{AS}} is configured for the SPARC architecture: @@ -982,7 +1032,7 @@ assembler.) * statistics:: --statistics to see statistics about assembly * traditional-format:: --traditional-format for compatible output * v:: -v to announce version -* W:: -W to suppress warnings +* W:: -W, --no-warn, --warn, --fatal-warnings to control warnings * Z:: -Z to make object file even after errors @end menu @@ -1358,19 +1408,32 @@ option @samp{-v} (which you can also spell as @samp{-version}) on the command line. @node W -@section Suppress Warnings: @code{-W} +@section Control Warnings: @code{-W}, @code{--warn}, @code{--no-warn}, @code{--fatal-warnings} -@kindex -W -@cindex suppressing warnings -@cindex warnings, suppressing @code{@value{AS}} should never give a warning or error message when assembling compiler output. But programs written by people often cause @code{@value{AS}} to give a warning that a particular assumption was made. All such warnings are directed to the standard error file. -If you use this option, no warnings are issued. This option only -affects the warning messages: it does not change any particular of how -@code{@value{AS}} assembles your file. Errors, which stop the assembly, are -still reported. + +@kindex @samp{-W} +@kindex @samp{--no-warn} +@cindex suppressing warnings +@cindex warnings, suppressing +If you use the @code{-W} and @code{--no-warn} options, no warnings are issued. +This only affects the warning messages: it does not change any particular of +how @code{@value{AS}} assembles your file. Errors, which stop the assembly, +are still reported. + +@kindex @samp{--fatal-warnings} +@cindex errors, caused by warnings +@cindex warnings, causing error +If you use the @code{--fatal-warnings} option, @code{@value{AS}} considers +files that generate warnings to be in error. + +@kindex @samp{--warn} +@cindex warnings, switching on +You can switch these options off again by specifying @code{--warn}, which +causes warnings to be output as usual. @node Z @section Generate Object File in Spite of Errors: @code{-Z} @@ -1492,6 +1555,9 @@ is considered a comment and is ignored. The line comment character is @ifset ARC @samp{;} on the ARC; @end ifset +@ifset ARM +@samp{@@} on the ARM; +@end ifset @ifset H8/300 @samp{;} for the H8/300 family; @end ifset @@ -1504,6 +1570,9 @@ is considered a comment and is ignored. The line comment character is @ifset I960 @samp{#} on the i960; @end ifset +@ifset PJ +@samp{;} for picoJava; +@end ifset @ifset SH @samp{!} for the Hitachi SH; @end ifset @@ -3040,6 +3109,7 @@ Some machine configurations provide additional directives. * Double:: @code{.double @var{flonums}} * Eject:: @code{.eject} * Else:: @code{.else} +* Elseif:: @code{.elseif} * End:: @code{.end} @ifset COFF * Endef:: @code{.endef} @@ -3129,6 +3199,9 @@ Some machine configurations provide additional directives. * Type:: @code{.type @var{int}} * Val:: @code{.val @var{addr}} @end ifset +@ifset ELF +* Visibility:: @code{.internal @var{name}, .hidden @var{name}, .protected @var{name}} +@end ifset * Uleb128:: @code{.uleb128 @var{expressions}} * Word:: @code{.word @var{expressions}} @@ -3394,6 +3467,14 @@ assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section of code to be assembled if the condition for the preceding @code{.if} was false. +@node Elseif +@section @code{.elseif} + +@cindex @code{elseif} directive +@code{.elseif} is part of the @code{@value{AS}} support for conditional +assembly; @pxref{If,,@code{.if}}. It is shorthand for beginning a new +@code{.if} block that would otherwise fill the entire @code{.else} section. + @node End @section @code{.end} @@ -3622,6 +3703,8 @@ considered part of the source program being assembled if the argument the conditional section of code must be marked by @code{.endif} (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}). +If you have several conditions to check, @code{.elseif} may be used to avoid +nesting blocks if/else within each subsequent @code{.else} block. The following variants of @code{.if} are also supported: @table @code @@ -4291,6 +4374,8 @@ data section read-only section @item x executable section +@item s +shared section (meaningful for PE targets) @end table If no flags are specified, the default flags depend upon the section name. If @@ -4688,6 +4773,40 @@ configured for @code{b.out}, it accepts this directive but ignores it. compact, variable length representation of numbers used by the DWARF symbolic debugging format. @xref{Sleb128,@code{.sleb128}}. +@ifset ELF +@node Visibility +@section @code{.internal}, @code{.hidden}, @code{.protected} +@cindex @code{internal} directive +@cindex @code{hidden} directive +@cindex @code{protected} directive +@cindex symbol visibility + +These directives can be used to set the visibility of a specified symbol. By +default a symbol's visibility is set by its binding (local, global or weak), +but these directives can be used to override that. + +A visibility of @code{protected} means that any references to the symbol from +within the component that defines the symbol must be resolved to the definition +in that component, even if a definition in another component would normally +preempt this. + +A visibility of @code{hidden} means that the symbol is not visible to other +components. Such a symbol is always considered to be protected as well. + +A visibility of @code{internal} is the same as a visibility of @code{hidden}, +except that some extra, processor specific processing must also be performed +upon the symbol. + +For ELF targets, the directives are used like this: + +@smallexample +.internal @var{name} +.hidden @var{name} +.protected @var{name} +@end smallexample + +@end ifset + @node Word @section @code{.word @var{expressions}} @@ -4808,6 +4927,9 @@ subject, see the hardware manufacturer's manual. @ifset HPPA * HPPA-Dependent:: HPPA Dependent Features @end ifset +@ifset I370 +* ESA/390-Dependent:: IBM ESA/390 Dependent Features +@end ifset @ifset I80386 * i386-Dependent:: Intel 80386 Dependent Features @end ifset @@ -4823,6 +4945,9 @@ subject, see the hardware manufacturer's manual. @ifset SH * SH-Dependent:: Hitachi SH Dependent Features @end ifset +@ifset PJ +* PJ-Dependent:: picoJava Dependent Features +@end ifset @ifset SPARC * Sparc-Dependent:: SPARC Dependent Features @end ifset @@ -4972,6 +5097,10 @@ family. @include c-hppa.texi @end ifset +@ifset I370 +@include c-i370.texi +@end ifset + @ifset I80386 @include c-i386.texi @end ifset @@ -4993,6 +5122,10 @@ family. @include c-ns32k.texi @end ifset +@ifset PJ +@include c-pj.texi +@end ifset + @ifset SH @include c-sh.texi @end ifset @@ -5299,6 +5432,8 @@ Jeff Law at the University of Utah (HPPA mainly), Michael Meissner of the Open Software Foundation (i386 mainly), and Ken Raeburn of Cygnus Support (sparc, and some initial 64-bit support). +Linas Vepstas added GAS support for the ESA/390 "IBM 370" architecture. + Richard Henderson rewrote the Alpha assembler. Klaus Kaempf wrote GAS and BFD support for openVMS/Alpha. diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi index b94fb2a..ff98d7f 100644 --- a/gas/doc/c-arm.texi +++ b/gas/doc/c-arm.texi @@ -29,12 +29,12 @@ @cindex options for ARM (none) @table @code @cindex @code{-marm} command line option, ARM -@item -marm @var{[2|250|3|6|60|600|610|620|7|7m|7d|7dm|7di|7dmi|70|700|700i|710|710c|7100|7500|7500fe|7tdmi|8|810|9|9tdmistrongarm|strongarm110|strongarm1100]} +@item -marm [@var{2}|@var{250}|@var{3}|@var{6}|@var{60}|@var{600}|@var{610}|@var{620}|@var{7}|@var{7m}|@var{7d}|@var{7dm}|@var{7di}|@var{7dmi}|@var{70}|@var{700}|@var{700i}|@var{710}|@var{710c}|@var{7100}|@var{7500}|@var{7500fe}|@var{7tdmi}|@var{8}|@var{810}|@var{9}|@var{9tdmi}|@var{920}|@var{strongarm}|@var{strongarm110}|@var{strongarm1100}] This option specifies the target processor. The assembler will issue an error message if an attempt is made to assemble an instruction which will not execute on the target processor. @cindex @code{-marmv} command line option, ARM -@item -marmv @var{[2|2a|3|3m|4|4t]} +@item -marmv [@var{2}|@var{2a}|@var{3}|@var{3m}|@var{4}|@var{4t}|@var{5}|@var{5t}] This option specifies the target architecture. The assembler will issue an error message if an attempt is made to assemble an instruction which will not execute on the target architecture. @@ -45,7 +45,7 @@ This option specifies that only Thumb instructions should be assembled. @item -mall This option specifies that any Arm or Thumb instruction should be assembled. @cindex @code{-mfpa} command line option, ARM -@item -mfpa @var{[10|11]} +@item -mfpa [@var{10}|@var{11}] This option specifies the floating point architecture in use on the target processor. @cindex @code{-mfpe-old} command line option, ARM @@ -59,14 +59,14 @@ Do not allow the assembly of any floating point instructions. This option specifies that the output generated by the assembler should be marked as supporting interworking. @cindex @code{-mapcs} command line option, ARM -@item -mapcs @var{[26|32]} +@item -mapcs [@var{26}|@var{32}] This option specifies that the output generated by the assembler should be marked as supporting the indicated version of the Arm Procedure. Calling Standard. @item -mapcs-float This indicates the the floating point variant of the APCS should be used. In this variant floating point arguments are passed in FP -registers ratehr than integer registers. +registers rather than integer registers. @item -mapcs-reentrant This indicates that the reentrant variant of the APCS should be used. This variant supports position independent code. @@ -102,8 +102,19 @@ the final release of the ARM-ELF specifications. @cindex line comment character, ARM @cindex ARM line comment character -The presence of a @samp{#} and @samp{@@} on a line indicates the start of -a comment that extends to the end of the current line. +The presence of a @samp{@@} on a line indicates the start of a comment +that extends to the end of the current line. If a @samp{#} appears as +the first character of a line, the whole line is treated as a comment. + +@cindex line separator, ARM +@cindex statement separator, ARM +@cindex ARM line separator +On ARM systems running the GNU/Linux operating system, @samp{;} can be +used instead of a newline to separate statements. + +@cindex immediate character, ARM +@cindex ARM immediate character +Either @samp{#} or @samp{$} can be used to indicate immediate operands. @cindex identifiers, ARM @cindex ARM identifiers @@ -142,7 +153,7 @@ example: @end smallexample @cindex @code{code} directive, ARM -@item .code @var{[16|32]} +@item .code [@var{16}|@var{32}] This directive selects the instruction set being generated. The value 16 selects Thumb, with the value 32 selecting ARM. @@ -167,6 +178,14 @@ the assembler and linker to generate correct code for interworking between Arm and Thumb instructions and should be used even if interworking is not going to be performed. +@cindex @code{thumb_set} directive, ARM +@item .thumb_set +This performs the equivalent of a @code{.set} directive in that it +creates a symbol which is an alias for another symbol (possibly not yet +defined). This directive also has the added property in that it marks +the aliased symbol as being a thumb function entry point, in the same +way that the @code{.thumb_func} directive does. + @cindex @code{.ltorg} directive, ARM @item .ltorg This directive causes the current contents of the literal pool to be @@ -184,13 +203,23 @@ This is a synonym for .ltorg. @cindex ARM opcodes @cindex opcodes for ARM -@code{@value{AS}} implements all the standard ARM opcodes. +@code{@value{AS}} implements all the standard ARM opcodes. It also +implements several pseudo opcodes, including several synthetic load +instructions. -*TODO* Document the pseudo-ops (adr, nop) +@table @code -GAS for the ARM supports a synthetic register load instruction whoes -syntax is: +@cindex @code{NOP} pseudo op, ARM +@item NOP +@smallexample + nop +@end smallexample + +This pseudo op will always evaluate to a legal ARM instruction that does +nothing. Currently it will evaluate to MOV r0, r0. +@cindex @code{LDR reg,=