summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2002-11-15 19:19:28 +0000
committerDavid Carlton <carlton@bactrian.org>2002-11-15 19:19:28 +0000
commit111a4444749ee1570694eb9b1542cdf4112fba4e (patch)
treeaa3a0e53c0692302ea8ed9b48cb8f81860bd3e02 /bfd
parentaf3142547dec4d6a640c3f8b012cf5e98cc9ba9d (diff)
downloadgdb-111a4444749ee1570694eb9b1542cdf4112fba4e.tar.gz
2002-11-15 David Carlton <carlton@math.stanford.edu>
* Merge from mainline; tag is carlton_dictionary-20021115-merge.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog331
-rw-r--r--bfd/Makefile.am39
-rw-r--r--bfd/Makefile.in41
-rw-r--r--bfd/archures.c25
-rw-r--r--bfd/bfd-in2.h33
-rw-r--r--bfd/bfd.c159
-rw-r--r--bfd/coff-h8300.c97
-rw-r--r--bfd/coff-stgo32.c99
-rw-r--r--bfd/coff-tic4x.c26
-rw-r--r--bfd/coffcode.h2
-rw-r--r--bfd/config.bfd40
-rwxr-xr-xbfd/configure76
-rw-r--r--bfd/configure.in48
-rw-r--r--bfd/doc/Makefile.in2
-rw-r--r--bfd/elf-bfd.h105
-rw-r--r--bfd/elf-eh-frame.c196
-rw-r--r--bfd/elf.c57
-rw-r--r--bfd/elf32-arm.h21
-rw-r--r--bfd/elf32-cris.c3
-rw-r--r--bfd/elf32-h8300.c217
-rw-r--r--bfd/elf32-i386.c17
-rw-r--r--bfd/elf32-ppc.c21
-rw-r--r--bfd/elf32-qnx.c92
-rw-r--r--bfd/elf32-qnx.h32
-rw-r--r--bfd/elf32-sh.c23
-rw-r--r--bfd/elf32-sh64-com.c2
-rw-r--r--bfd/elf32-v850.c8
-rw-r--r--bfd/elf64-mips.c25
-rw-r--r--bfd/elf64-mmix.c5
-rw-r--r--bfd/elf64-ppc.c82
-rw-r--r--bfd/elf64-ppc.h2
-rw-r--r--bfd/elf64-sparc.c29
-rw-r--r--bfd/elfarm-nabi.c23
-rw-r--r--bfd/elfcode.h60
-rw-r--r--bfd/elfcore.h46
-rw-r--r--bfd/elflink.h238
-rw-r--r--bfd/elfxx-ia64.c6
-rw-r--r--bfd/elfxx-target.h12
-rw-r--r--bfd/format.c54
-rw-r--r--bfd/libbfd-in.h3
-rw-r--r--bfd/libbfd.h3
-rw-r--r--bfd/mach-o-target.c117
-rw-r--r--bfd/mach-o.c2194
-rw-r--r--bfd/mach-o.h490
-rw-r--r--bfd/pef-traceback.h215
-rw-r--r--bfd/pef.c1312
-rw-r--r--bfd/pef.h186
-rw-r--r--bfd/po/SRC-POTFILES.in9
-rw-r--r--bfd/po/da.po340
-rw-r--r--bfd/reloc.c27
-rw-r--r--bfd/reloc16.c71
-rw-r--r--bfd/simple.c15
-rw-r--r--bfd/targets.c71
-rw-r--r--bfd/version.h2
-rw-r--r--bfd/vms-gsd.c8
-rw-r--r--bfd/vms.c2
-rw-r--r--bfd/xsym.c2484
-rw-r--r--bfd/xsym.h701
58 files changed, 9323 insertions, 1321 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7e6a4128c3b..479674b6c6b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,334 @@
+2002-11-15 Kazu Hirata <kazu@cs.umass.edu>
+
+ * coff-h8300.c (h8300_reloc16_estimate): Do not optimize away
+ jsr after a short jump.
+ * elf32-h8300.c (elf32_h8_relax_section): Likewise.
+
+2002-11-15 Klee Dienes <kdienes@apple.com>
+
+ * pef.c (bfd_pef_convert_architecture): Move declaration of
+ ARCH_POWERPC and ARCH_M68K to the start of the function.
+
+2002-11-14 Svein E. Seldal <Svein.Seldal@solidas.com>
+
+ * coff-tic4x.c (tic4x_howto_table): Formatting fixup
+
+2002-11-14 Hans-Peter Nilsson <hp@bitrange.com>
+
+ * elf64-mmix.c (_bfd_mmix_finalize_linker_allocated_gregs):
+ For bpo_gregs_section->contents, allocate _raw_size, not
+ _cooked_size.
+
+2002-11-13 Klee Dienes <kdienes@apple.com>
+
+ * config.bfd: Add entries for powerpc-*-darwin and cousins.
+
+2002-11-13 H.J. Lu <hjl@gnu.org>
+
+ * elfcode.h (elf_object_p): Don't restore abfd->arch_info.
+
+2002-11-13 Klee Dienes <kdienes@apple.com>
+ Alan Modra <amodra@bigpond.net.au>
+
+ * bfd.c (struct bfd_preserve): New.
+ (bfd_preserve_save): New function.
+ (bfd_preserve_restore): Ditto.
+ (bfd_preserve_finish): Ditto.
+ * bfd-in2.h: Regenerate.
+ * mach-o.c: Formatting.
+ (bfd_mach_o_scan_read_symtab_symbol): Make "value" unsigned.
+ (bfd_mach_o_object_p): Use bfd_preserve_save/restore/finish.
+ (bfd_mach_o_core_p): Ditto.
+ (bfd_mach_o_scan): Pass in mdata.
+ * mach-o.h (bfd_mach_o_scan): Update prototype.
+ * pef.c: Formatting.
+ (bfd_pef_object_p): Use bfd_preserve_save/restore/finish.
+ (bfd_pef_xlib_object_p): Ditto.
+ (bfd_pef_scan): Pass in mdata. Move version check to bfd_pef_object_p.
+ * pef.h (bfd_pef_scan): Update prototype.
+ * xsym.c: Formatting, K&R fixes.
+ (bfd_sym_object_p): Use bfd_preserve_save/restore/finish.
+ (bfd_sym_scan): New function split out from bfd_sym_object_p.
+ * xsym.h (bfd_sym_scan): Declare.
+ * elfcode.h (elf_object_p): Use bfd_preserve_save/restore/finish.
+ * elfcore.h (elf_core_file_p): Likewise.
+ * targets.c (_bfd_target_vector): Revert 2002-11-08 change.
+
+2002-11-12 Nick Clifton <nickc@redhat.com>
+
+ * po/da.po: Updated Danish translation.
+
+2002-11-12 Alan Modra <amodra@bigpond.net.au>
+
+ * elflink.h (elf_link_add_object_symbols): Optimize stabs for
+ relocatable link too.
+ (elf_link_input_bfd): When emitting relocs, adjust offsets for
+ eh_frame and stab sections. Zap deleted relocs.
+ (elf_reloc_symbol_deleted_p): Return true for zero r_symndx.
+ (elf_bfd_discard_info): Run for relocatable link too.
+ * elf64-ppc.c (ppc64_elf_edit_opd): Rename from edit_opd. Make global.
+ Handle ld -r case.
+ (ppc64_elf_size_dynamic_sections): Don't call edit_opd from here.
+ * elf64-ppc.h (ppc64_elf_edit_opd): Declare.
+
+ * elf-bfd.h (struct cie_header): Move from elf_eh-frame.c.
+ (struct cie, struct eh_cie_fde, struct eh_frame_sec_info): Likewise.
+ (struct eh_frame_array_ent, struct eh_frame_hdr_info): Likewise.
+ (enum elf_link_info_type): Remove ELF_INFO_TYPE_EH_FRAME_HDR.
+ (struct eh_frame_hdr_info): Add "hdr_sec", remove "split".
+ (struct elf_link_hash_table): Add eh_info.
+ (struct elf_obj_tdata): Change eh_frame_hdr to an asection *.
+ (_bfd_elf_discard_section_eh_frame): Update prototype.
+ (_bfd_elf_discard_section_eh_frame_hdr): Likewise.
+ (_bfd_elf_write_section_eh_frame): Likewise.
+ (_bfd_elf_write_section_eh_frame_hdr): Likewise.
+ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Remove "ehdrsec"
+ param. Get "hdr_info" from link hash table.
+ (_bfd_elf_discard_section_eh_frame_hdr): Remove "sec" param. Get
+ header section from link hash table. Save header section to elf_tdata.
+ (_bfd_elf_maybe_strip_eh_frame_hdr): Remove local "sec". Use
+ header section from link hash table. Don't alloc hdr_info. Clear
+ hdr_sec instead of setting "strip".
+ (_bfd_elf_eh_frame_section_offset): Formatting.
+ (_bfd_elf_write_section_eh_frame): Remove "ehdrsec", add "info" param.
+ Get header section from link hash table.
+ (_bfd_elf_write_section_eh_frame_hdr): Remove "sec", add "info" param.
+ Get header section from link hash table.
+ * elf.c (map_sections_to_segments): Use cached eh_frame_hdr.
+ (get_program_header_size): Likewise.
+ (_bfd_elf_section_offset): Formatting.
+ * elflink.h (elf_link_create_dynamic_sections): Stash eh frame header
+ section pointer in link hash table.
+ (elf_bfd_final_link): Adjust _bfd_elf_write_section_eh_frame_hdr
+ and _bfd_elf_write_section_eh_frame calls. Update comment about
+ eh_frame entries.
+ (elf_bfd_discard_info): Adjust _bfd_elf_discard_section_eh_frame and
+ _bfd_elf_discard_section_eh_frame_hdr calls. Remove "ehdr".
+
+ * po/SRC-POTFILES.in: Regenerate.
+
+ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't zero
+ relocs for discarded FDEs. Remove dead code.
+ (_bfd_elf_write_section_eh_frame_hdr): Remove dead code.
+ * elflink.h (elf_bfd_discard_info): Don't save edited relocs.
+ Tidy conditions under which stabs are edited. Formatting.
+ * elf64-sparc.c (sparc64_elf_relocate_section): Ignore overflows
+ from discarded relocs.
+ * elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Add reloc output
+ section adjustments after testing magic values.
+
+2002-11-12 Thomas Moestl <tmm@FreeBSD.org>
+
+ * elf64-sparc.c (sparc64_elf_adjust_dynamic_symbol): Correct
+ references to large plt symbols.
+
+2002-11-12 Klee Dienes <kdienes@apple.com>
+
+ * mach-o.c (bfd_mach_o_scan_read_thread): Don't re-use 'i' when
+ looking for an unused section name.
+
+2002-11-11 Kazu Hirata <kazu@cs.umass.edu>
+
+ * coff-h8300.c: Fix formatting.
+ * elf32-h8300.c: Likewise.
+ * reloc16.c: Likewise.
+
+2002-11-09 Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+
+ * elf32-arm.h (elf32_arm_size_dynamic_sections): Don't strip output
+ section when dynamic section unused; _bfd_strip_section_from_output
+ instead.
+
+2002-11-08 Alan Modra <amodra@bigpond.net.au>
+
+ * targets.c (_bfd_target_vector): Disable pef_vec, pef_xlib_vec
+ and sym_vec.
+
+ * dwarf2.c: Revert last change.
+
+2002-11-07 Michal Ludvig <mludvig@suse.cz>
+
+ * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
+ _bfd_dwarf2_find_nearest_line): Use
+ bfd_simple_get_relocated_section_contents() instead of
+ bfd_get_section_contents().
+ * reloc.c (bfd_perform_relocation): Add sanity check.
+ * simple.c (simple_get_relocated_section_contents): If the section
+ does not have any relocs associated with it, just return the
+ unadjusted contents.
+
+2002-11-07 Hans-Peter Nilsson <hp@axis.com>
+
+ * elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_16_GOT,
+ case R_CRIS_32_GOT>: Correct test for filling in constant .got
+ contents, enabling for a non-DSO, for symbols defined in the
+ program with --export-dynamic.
+
+2002-11-07 Alan Modra <amodra@bigpond.net.au>
+
+ * elf64-ppc.c: Comment typo fixes.
+ (ppc64_elf_merge_private_bfd_data): Allow BFD_ENDIAN_UNKNOWN input.
+
+2002-11-07 Nick Clifton <nickc@redhat.com>
+
+ * po/da.po: Updated Danish translation.
+
+2002-11-06 Alexandre Oliva <aoliva@redhat.com>
+
+ * elf64-mips.c (mips_elf64_slurp_one_reloc_table): Generate
+ exactly three internal relocs per external reloc. Set reloc_count
+ to the external reloc count.
+
+2002-11-06 Klee Dienes <kdienes@apple.com>
+
+ * coff-stgo32.c (stub_bytes): Mark as const.
+ Fix comment formatting.
+
+2002-11-06 Klee Dienes <kdienes@apple.com>
+
+ * Makefile.am (BFD32_BACKENDS): Add mach-o.lo, pef.lo, and
+ xsym.lo.
+ (BFD32_BACKENDS_CFILES): Add mach-o.c, pef.c, and xsym.c.
+ (SOURCE_HFILES): Add mach-o.h, pef.h, pef-traceback.h, xsym.h
+ * archures.c (enum bfd_architecture): Add bfd_arch_m98k.
+ * bfd.c (struct bfd): Add private data for mach-o, pef, and sym.
+ * targets.c (enum bfd_flavour): Add flavours for mach-o, pef, and
+ sym.
+ (_bfd_target_vector): Add target vectors for mach-o, pef, and sym.
+ * Makefile.in: Regenerate.
+ * doc/Makefile.in: Regenerate.
+ * bfd-in2.h: Regenerate.
+ * xsym.c: New file. Contains support for the Apple/Metrowerks
+ xSYM debugging format.
+ * xsym.h: New file.
+ * pef.c: New file. Contains support for the Apple Code Fragment
+ Manager Preferred Executable Format
+ * pef.h: New file.
+ * pef-traceback.h: New file. Contains support for parsing PowerPC
+ traceback tables as used by PEF executables (and perhaps other
+ systems as well).
+ * mach-o.c: New file. Contains support for the Mach-O object file
+ format.
+ * mach-o.h: New file.
+ * mach-o-target.c: New file. Declares the mach-o targets
+ themselves. Included three times by mach-o.c; each time with a
+ different set of macros set.
+
+2002-11-06 Graeme Peterson <gp@qnx.com>
+
+ * Makefile.am: Remove entries for elf32-qnx.[ch].
+ * Makefile.in: Regenerate.
+ * config.bfd: Change arm-nto to use bfd_elf32_{big|little}arm_vec,
+ ppc-nto to use bfd_elf32_powerpc{le}_vec, sh-nto to use
+ bfd_elf32_sh{l}_vec, and i386-nto to use bfd_elf32_i386_vec.
+ * configure.in: Remove support for bfd_elf32_sh{l}qnx_vec,
+ bfd_elf32_powerpc{le}qnx_vec, bfd_elf32_{big|little}armqnx_vec,
+ and bfd_elf32_i386qnx_vec, and removed elf32-qnx.lo from other targets.
+ bfd_elf32_sh{l}_vec, and i386-nto to use bfd_elf32_i386_vec.
+ * configure: Regenerate.
+ * elf32-qnx.c: Remove.
+ * elf32-qnx.h: Remove.
+ * elf.c: Remove calls to QNX specific set_nonloadable_filepos,
+ is_contained_by_filepos, and copy_private_bfd_data_p.
+ * elf-bfd.h (struct elf_backend_data): Remove set_nonloadable_filepos,
+ is_contained_by_filepos, and copy_private_bfd_data_p.
+ * elf32-i386.c: Remove QNX extended bfd support.
+ * elf32-ppc.c: Remove QNX extended bfd support.
+ * elf32-sh.c: Remove QNX extended bfd support.
+ * elfarm-nabi.c: Remove QNX extended bfd support.
+ * targets.c: Remove qnx vectors.
+ * elfxx-target.h (elf_backend_set_nonloadable_filepos): Remove
+ (elf_backend_is_contained_by_filepos): Remove.
+ (elf_backend_copy_private_bfd_data_p): Remove.
+ * po/SRC-POTFILES.in: Regenerate.
+
+2002-11-06 David O'Brien <obrien@FreeBSD.org>
+ Alan Modra <amodra@bigpond.net.au>
+
+ * elf64-sparc.c (sparc64_elf_relocate_section): Adjust addend of
+ dynamic relocs against section symbols for the output section vma.
+
+2002-11-05 Alan Modra <amodra@bigpond.net.au>
+
+ * elf32-arm.h (t2a1_push_insn, t2a2_ldr_insn, t2a3_mov_insn,
+ t2a4_bx_insn, t2a5_pop_insn, t2a6_bx_insn): Remove.
+
+2002-11-05 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+ Alan Modra <amodra@bigpond.net.au>
+
+ * config.bfd (sh-*-linux*): Use bfd_elf*_sh64*lin_vec as sh64
+ vectors in target_selvecs.
+ (shle-*-netbsdelf*): Use bfd_elf*_sh64*nbsd_vec as sh64 vectors
+ in target_selvecs.
+ (sh-*-netbsdelf*): Likewise.
+ * configure.in (assocvecs): New variable. Handle assocvecs like
+ selvecs.
+ * configure: Regenerate.
+ * format.c (bfd_check_format_matches): Store bfd_target pointers
+ in matching_vector instead of target names. Select first target
+ from bfd_associated_vector that matches a list of ambiguous targets.
+ * targets.c (_bfd_associated_vector): New array.
+ (bfd_associated_vector): New variable.
+ (_bfd_target_vector): Add bfd_elf*_sh64*lin_vec.
+ * libbfd-in.h (bfd_associated_vector): Declare.
+ * libbfd.h: Regenerate.
+
+2002-11-05 Elias Athanasopoulos <eathan@otenet.gr>
+
+ * vms-gsd.c (_bfd_vms_write_gsd): Check that symbol->udata.p is
+ non-NULL before dereferencing.
+
+2002-11-04 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * vms.c (vms_object_p): Restore the start address when returning
+ NULL.
+
+2002-11-04 Alan Modra <amodra@bigpond.net.au>
+ Hans-Peter Nilsson <hp@axis.com>
+
+ * elflink.h (struct elf_final_link_info): Add shndxbuf_size.
+ (elf_bfd_final_link): Don't bother zeroing symtab_hdr fields.
+ Set up a larger symshndxbuf, and write it out. Free it on
+ exit rather than freeing symbuf twice. Correct section index
+ on output section symbol loop.
+ (elf_link_output_sym): Accumulate symbol extension section
+ indices, reallocating symshndxbuf rather than writing it out.
+ (elf_link_flush_output_syms): Don't flush symshndxbuf.
+ * elf.c (assign_section_numbers): Init i_shdrp to all zero.
+ Use bfd_zalloc to clear i_shdrp[0] too.
+
+2002-11-03 Stephen Clarke <stephen.clarke@earthling.net>
+
+ * elf32-sh64-com.c (sh64_address_in_cranges): Use
+ _raw_size of cranges section if _cooked_size not yet set.
+
+2002-11-03 Hans-Peter Nilsson <hp@axis.com>
+
+ * elf32-v850.c (v850_elf_relax_delete_bytes): Correct parameters
+ for bfd_elf32_swap_symbol_out.
+
+2002-10-31 David O'Brien <obrien@FreeBSD.org>
+
+ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't mix
+ signed and unsigned in comparison.
+
+2002-10-30 Daniel Jacobowitz <drow@mvista.com>
+
+ * coffcode.h: Remove extraneous '\'.
+
+2002-10-28 H.J. Lu <hjl@gnu.org>
+
+ * Makefile.am (targets.lo): Depend on Makefile instead of
+ config.status.
+ (archures.lo): Likewise.
+ * Makefile.in: Regenerated.
+
+2002-10-25 Jason Thorpe <thorpej@wasabisystems.com>
+
+ * config.bfd (mips*el-*-netbsd*, mips*-*-netbsd*): Add
+ bfd_elf64_bigmips_vec and bfd_elf64_littlemips_vec to
+ targ_selvecs.
+
2002-10-25 Jim Wilson <wilson@redhat.com>
* elf64-sh64.c (sh_elf64_relocate_section): Call
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index ecd583a67f2..0c1a7980440 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -233,7 +233,6 @@ BFD32_BACKENDS = \
elf32-or32.lo \
elf32-pj.lo \
elf32-ppc.lo \
- elf32-qnx.lo \
elf32-s390.lo \
elf32-sh.lo \
elf32-sh64.lo \
@@ -267,6 +266,7 @@ BFD32_BACKENDS = \
m68klynx.lo \
m68knetbsd.lo \
m88kmach3.lo \
+ mach-o.lo \
mipsbsd.lo \
newsos3.lo \
nlm.lo \
@@ -278,6 +278,7 @@ BFD32_BACKENDS = \
oasys.lo \
pc532-mach.lo \
pdp11.lo \
+ pef.lo \
pe-arm.lo \
pei-arm.lo \
pe-i386.lo \
@@ -307,7 +308,8 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
- xcofflink.lo
+ xcofflink.lo \
+ xsym.lo
BFD32_BACKENDS_CFILES = \
aout-adobe.c \
@@ -388,7 +390,6 @@ BFD32_BACKENDS_CFILES = \
elf32-or32.c \
elf32-pj.c \
elf32-ppc.c \
- elf32-qnx.c \
elf32-sh64.c \
elf32-sh64-com.c \
elf32-s390.c \
@@ -422,6 +423,7 @@ BFD32_BACKENDS_CFILES = \
m68klynx.c \
m68knetbsd.c \
m88kmach3.c \
+ mach-o.c \
mipsbsd.c \
newsos3.c \
nlm.c \
@@ -433,6 +435,7 @@ BFD32_BACKENDS_CFILES = \
oasys.c \
pc532-mach.c \
pdp11.c \
+ pef.c \
pe-arm.c \
pei-arm.c \
pe-i386.c \
@@ -461,7 +464,8 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
- xcofflink.c
+ xcofflink.c \
+ xsym.c
# The .o files needed by all of the 64 bit vectors that are configured into
# target_vector in targets.c if configured with --enable-targets=all
@@ -561,13 +565,14 @@ CFILES = $(SOURCE_CFILES) $(BUILD_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 \
- elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h elf32-qnx.h \
+ elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h \
elf64-hppa.h elfcode.h elfcore.h elflink.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
- libnlm.h liboasys.h libpei.h libxcoff.h \
+ libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
- peicode.h som.h version.h vms.h xcoff-target.h
+ pef.h pef-traceback.h peicode.h som.h version.h \
+ vms.h xcoff-target.h xsym.h
## ... and all .h files which are in the build tree.
BUILD_HFILES = \
@@ -654,10 +659,10 @@ targmatch.h: config.bfd targmatch.sed
# When compiling archures.c and targets.c, supply the default target
# info from configure.
-targets.lo: targets.c config.status
+targets.lo: targets.c Makefile
$(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/targets.c
-archures.lo: archures.c config.status
+archures.lo: archures.c Makefile
$(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/archures.c
elf32-target.h : elfxx-target.h
@@ -1099,7 +1104,7 @@ elfarm-oabi.lo: elfarm-oabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
elfarm-nabi.lo: elfarm-nabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
$(INCDIR)/filenames.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-qnx.h
+ elf32-arm.h elf32-target.h
elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h 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 \
@@ -1146,7 +1151,7 @@ elf32-i370.lo: elf32-i370.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-i386.lo: elf32-i386.c $(INCDIR)/filenames.h $(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-qnx.h
+ elf32-target.h
elf32-i860.lo: elf32-i860.c $(INCDIR)/filenames.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(INCDIR)/elf/i860.h $(INCDIR)/elf/reloc-macros.h \
@@ -1217,10 +1222,7 @@ elf32-pj.lo: elf32-pj.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-ppc.lo: elf32-ppc.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h \
- elf32-target.h elf32-qnx.h
-elf32-qnx.lo: elf32-qnx.c $(INCDIR)/filenames.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/bfdlink.h elf32-qnx.h
+ elf32-target.h
elf32-sh64.lo: elf32-sh64.c $(INCDIR)/filenames.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(srcdir)/../opcodes/sh64-opc.h \
@@ -1237,7 +1239,7 @@ elf32-s390.lo: elf32-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \
- elf32-target.h elf32-qnx.h
+ elf32-target.h
elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \
$(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \
@@ -1332,6 +1334,8 @@ m68knetbsd.lo: m68knetbsd.c netbsd.h $(INCDIR)/filenames.h \
m88kmach3.lo: m88kmach3.c $(INCDIR)/filenames.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
+mach-o.lo: mach-o.c mach-o.h $(INCDIR)/filenames.h \
+ $(INCDIR)/libiberty.h mach-o-target.c
mipsbsd.lo: mipsbsd.c $(INCDIR)/filenames.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
@@ -1363,6 +1367,8 @@ pc532-mach.lo: pc532-mach.c $(INCDIR)/filenames.h libaout.h \
pdp11.lo: pdp11.c $(INCDIR)/filenames.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 $(INCDIR)/safe-ctype.h
+pef.lo: pef.c pef.h pef-traceback.h $(INCDIR)/filenames.h \
+ $(INCDIR)/libiberty.h
pe-arm.lo: pe-arm.c $(INCDIR)/filenames.h coff-arm.c \
$(INCDIR)/coff/arm.h $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
$(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
@@ -1455,6 +1461,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
libxcoff.h
+xsym.lo: xsym.c xsym.h $(INCDIR)/filenames.h
aix5ppc-core.lo: aix5ppc-core.c
aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
$(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index a3a0d40fb2a..0104743b6fa 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -360,7 +360,6 @@ BFD32_BACKENDS = \
elf32-or32.lo \
elf32-pj.lo \
elf32-ppc.lo \
- elf32-qnx.lo \
elf32-s390.lo \
elf32-sh.lo \
elf32-sh64.lo \
@@ -394,6 +393,7 @@ BFD32_BACKENDS = \
m68klynx.lo \
m68knetbsd.lo \
m88kmach3.lo \
+ mach-o.lo \
mipsbsd.lo \
newsos3.lo \
nlm.lo \
@@ -405,6 +405,7 @@ BFD32_BACKENDS = \
oasys.lo \
pc532-mach.lo \
pdp11.lo \
+ pef.lo \
pe-arm.lo \
pei-arm.lo \
pe-i386.lo \
@@ -434,7 +435,8 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
- xcofflink.lo
+ xcofflink.lo \
+ xsym.lo
BFD32_BACKENDS_CFILES = \
@@ -516,7 +518,6 @@ BFD32_BACKENDS_CFILES = \
elf32-or32.c \
elf32-pj.c \
elf32-ppc.c \
- elf32-qnx.c \
elf32-sh64.c \
elf32-sh64-com.c \
elf32-s390.c \
@@ -550,6 +551,7 @@ BFD32_BACKENDS_CFILES = \
m68klynx.c \
m68knetbsd.c \
m88kmach3.c \
+ mach-o.c \
mipsbsd.c \
newsos3.c \
nlm.c \
@@ -561,6 +563,7 @@ BFD32_BACKENDS_CFILES = \
oasys.c \
pc532-mach.c \
pdp11.c \
+ pef.c \
pe-arm.c \
pei-arm.c \
pe-i386.c \
@@ -589,7 +592,8 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
- xcofflink.c
+ xcofflink.c \
+ xsym.c
# The .o files needed by all of the 64 bit vectors that are configured into
@@ -695,13 +699,14 @@ CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
SOURCE_HFILES = \
aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \
- elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h elf32-qnx.h \
+ elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h \
elf64-hppa.h elfcode.h elfcore.h elflink.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
- libnlm.h liboasys.h libpei.h libxcoff.h \
+ libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
- peicode.h som.h version.h vms.h xcoff-target.h
+ pef.h pef-traceback.h peicode.h som.h version.h \
+ vms.h xcoff-target.h xsym.h
BUILD_HFILES = \
@@ -780,7 +785,7 @@ configure.in version.h
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)
@@ -1201,10 +1206,10 @@ targmatch.h: config.bfd targmatch.sed
# When compiling archures.c and targets.c, supply the default target
# info from configure.
-targets.lo: targets.c config.status
+targets.lo: targets.c Makefile
$(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/targets.c
-archures.lo: archures.c config.status
+archures.lo: archures.c Makefile
$(LIBTOOL) --mode=compile $(COMPILE) -c $(TDEFAULTS) $(srcdir)/archures.c
elf32-target.h : elfxx-target.h
@@ -1630,7 +1635,7 @@ elfarm-oabi.lo: elfarm-oabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
elfarm-nabi.lo: elfarm-nabi.c $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
$(INCDIR)/filenames.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-qnx.h
+ elf32-arm.h elf32-target.h
elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h 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 \
@@ -1677,7 +1682,7 @@ elf32-i370.lo: elf32-i370.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-i386.lo: elf32-i386.c $(INCDIR)/filenames.h $(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-qnx.h
+ elf32-target.h
elf32-i860.lo: elf32-i860.c $(INCDIR)/filenames.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(INCDIR)/elf/i860.h $(INCDIR)/elf/reloc-macros.h \
@@ -1748,10 +1753,7 @@ elf32-pj.lo: elf32-pj.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-ppc.lo: elf32-ppc.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h \
- elf32-target.h elf32-qnx.h
-elf32-qnx.lo: elf32-qnx.c $(INCDIR)/filenames.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/bfdlink.h elf32-qnx.h
+ elf32-target.h
elf32-sh64.lo: elf32-sh64.c $(INCDIR)/filenames.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(srcdir)/../opcodes/sh64-opc.h \
@@ -1768,7 +1770,7 @@ elf32-s390.lo: elf32-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \
- elf32-target.h elf32-qnx.h
+ elf32-target.h
elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \
$(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \
@@ -1863,6 +1865,8 @@ m68knetbsd.lo: m68knetbsd.c netbsd.h $(INCDIR)/filenames.h \
m88kmach3.lo: m88kmach3.c $(INCDIR)/filenames.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
+mach-o.lo: mach-o.c mach-o.h $(INCDIR)/filenames.h \
+ $(INCDIR)/libiberty.h mach-o-target.c
mipsbsd.lo: mipsbsd.c $(INCDIR)/filenames.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
@@ -1894,6 +1898,8 @@ pc532-mach.lo: pc532-mach.c $(INCDIR)/filenames.h libaout.h \
pdp11.lo: pdp11.c $(INCDIR)/filenames.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 $(INCDIR)/safe-ctype.h
+pef.lo: pef.c pef.h pef-traceback.h $(INCDIR)/filenames.h \
+ $(INCDIR)/libiberty.h
pe-arm.lo: pe-arm.c $(INCDIR)/filenames.h coff-arm.c \
$(INCDIR)/coff/arm.h $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
$(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
@@ -1986,6 +1992,7 @@ vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
libxcoff.h
+xsym.lo: xsym.c xsym.h $(INCDIR)/filenames.h
aix5ppc-core.lo: aix5ppc-core.c
aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
$(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
diff --git a/bfd/archures.c b/bfd/archures.c
index 1ab0cfa52c3..485fef27401 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public 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"
@@ -160,6 +160,7 @@ DESCRIPTION
. bfd_arch_alliant, {* Alliant *}
. bfd_arch_convex, {* Convex *}
. bfd_arch_m88k, {* Motorola 88xxx *}
+. bfd_arch_m98k, {* Motorola 98xxx *}
. bfd_arch_pyramid, {* Pyramid Technology *}
. bfd_arch_h8300, {* Hitachi H8/300 *}
.#define bfd_mach_h8300 1
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 018a0fd292c..8f4a48ba456 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1551,6 +1551,7 @@ enum bfd_architecture
bfd_arch_alliant, /* Alliant */
bfd_arch_convex, /* Convex */
bfd_arch_m88k, /* Motorola 88xxx */
+ bfd_arch_m98k, /* Motorola 98xxx */
bfd_arch_pyramid, /* Pyramid Technology */
bfd_arch_h8300, /* Hitachi H8/300 */
#define bfd_mach_h8300 1
@@ -3533,6 +3534,11 @@ struct _bfd
struct cisco_core_struct *cisco_core_data;
struct versados_data_struct *versados_data;
struct netbsd_core_struct *netbsd_core_data;
+ struct mach_o_data_struct *mach_o_data;
+ struct mach_o_fat_data_struct *mach_o_fat_data;
+ struct bfd_pef_data_struct *pef_data;
+ struct bfd_pef_xlib_data_struct *pef_xlib_data;
+ struct bfd_sym_data_struct *sym_data;
PTR any;
}
tdata;
@@ -3733,6 +3739,27 @@ extern bfd_byte *bfd_get_relocated_section_contents
boolean
bfd_alt_mach_code PARAMS ((bfd *abfd, int alternative));
+struct bfd_preserve
+{
+ PTR marker;
+ PTR tdata;
+ flagword flags;
+ const struct bfd_arch_info *arch_info;
+ struct sec *sections;
+ struct sec **section_tail;
+ unsigned int section_count;
+ struct bfd_hash_table section_htab;
+};
+
+boolean
+bfd_preserve_save PARAMS ((bfd *, struct bfd_preserve *));
+
+void
+bfd_preserve_restore PARAMS ((bfd *, struct bfd_preserve *));
+
+void
+bfd_preserve_finish PARAMS ((bfd *, struct bfd_preserve *));
+
/* Extracted from archive.c. */
symindex
bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
@@ -3795,7 +3822,11 @@ enum bfd_flavour
bfd_target_msdos_flavour,
bfd_target_ovax_flavour,
bfd_target_evax_flavour,
- bfd_target_mmo_flavour
+ bfd_target_mmo_flavour,
+ bfd_target_mach_o_flavour,
+ bfd_target_pef_flavour,
+ bfd_target_pef_xlib_flavour,
+ bfd_target_sym_flavour
};
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
diff --git a/bfd/bfd.c b/bfd/bfd.c
index bf451621657..5412ac8bfc9 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
SECTION
@@ -180,6 +180,11 @@ CODE_FRAGMENT
. struct cisco_core_struct *cisco_core_data;
. struct versados_data_struct *versados_data;
. struct netbsd_core_struct *netbsd_core_data;
+. struct mach_o_data_struct *mach_o_data;
+. struct mach_o_fat_data_struct *mach_o_fat_data;
+. struct bfd_pef_data_struct *pef_data;
+. struct bfd_pef_xlib_data_struct *pef_xlib_data;
+. struct bfd_sym_data_struct *sym_data;
. PTR any;
. }
. tdata;
@@ -1387,3 +1392,133 @@ bfd_alt_mach_code (abfd, alternative)
return false;
}
+
+/*
+CODE_FRAGMENT
+
+.struct bfd_preserve
+.{
+. PTR marker;
+. PTR tdata;
+. flagword flags;
+. const struct bfd_arch_info *arch_info;
+. struct sec *sections;
+. struct sec **section_tail;
+. unsigned int section_count;
+. struct bfd_hash_table section_htab;
+.};
+.
+*/
+
+/*
+FUNCTION
+ bfd_preserve_save
+
+SYNOPSIS
+ boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
+
+DESCRIPTION
+ When testing an object for compatibility with a particular
+ target back-end, the back-end object_p function needs to set
+ up certain fields in the bfd on successfully recognizing the
+ object. This typically happens in a piecemeal fashion, with
+ failures possible at many points. On failure, the bfd is
+ supposed to be restored to its initial state, which is
+ virtually impossible. However, restoring a subset of the bfd
+ state works in practice. This function stores the subset and
+ reinitializes the bfd.
+
+*/
+
+boolean
+bfd_preserve_save (abfd, preserve)
+ bfd *abfd;
+ struct bfd_preserve *preserve;
+{
+ preserve->tdata = abfd->tdata.any;
+ preserve->arch_info = abfd->arch_info;
+ preserve->flags = abfd->flags;
+
+ preserve->sections = abfd->sections;
+ preserve->section_tail = abfd->section_tail;
+ preserve->section_count = abfd->section_count;
+ preserve->section_htab = abfd->section_htab;
+
+ if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
+ return false;
+
+ abfd->tdata.any = NULL;
+ abfd->arch_info = &bfd_default_arch_struct;
+ abfd->flags = 0;
+
+ abfd->sections = NULL;
+ abfd->section_tail = &abfd->sections;
+ abfd->section_count = 0;
+
+ return true;
+}
+
+/*
+FUNCTION
+ bfd_preserve_restore
+
+SYNOPSIS
+ void bfd_preserve_restore (bfd *, struct bfd_preserve *);
+
+DESCRIPTION
+ This function restores bfd state saved by bfd_preserve_save.
+ If MARKER is non-NULL in struct bfd_preserve then that block
+ and all subsequently bfd_alloc'd memory is freed.
+
+*/
+
+void
+bfd_preserve_restore (abfd, preserve)
+ bfd *abfd;
+ struct bfd_preserve *preserve;
+{
+ bfd_hash_table_free (&abfd->section_htab);
+
+ abfd->tdata.any = preserve->tdata;
+ abfd->arch_info = preserve->arch_info;
+ abfd->flags = preserve->flags;
+
+ abfd->section_htab = preserve->section_htab;
+ abfd->sections = preserve->sections;
+ abfd->section_tail = preserve->section_tail;
+ abfd->section_count = preserve->section_count;
+
+ /* bfd_release frees all memory more recently bfd_alloc'd than
+ its arg, as well as its arg. */
+ if (preserve->marker != NULL)
+ {
+ bfd_release (abfd, preserve->marker);
+ preserve->marker = NULL;
+ }
+}
+
+/*
+FUNCTION
+ bfd_preserve_finish
+
+SYNOPSIS
+ void bfd_preserve_finish (bfd *, struct bfd_preserve *);
+
+DESCRIPTION
+ This function should be called when the bfd state saved by
+ bfd_preserve_save is no longer needed. ie. when the back-end
+ object_p function returns with success.
+
+*/
+
+void
+bfd_preserve_finish (abfd, preserve)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ struct bfd_preserve *preserve;
+{
+ /* It would be nice to be able to free more memory here, eg. old
+ tdata, but that's not possible since these blocks are sitting
+ inside bfd_alloc'd memory. The section hash is on a separate
+ objalloc. */
+ bfd_hash_table_free (&preserve->section_htab);
+}
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
index 82b7bca5b01..c83015e4efb 100644
--- a/bfd/coff-h8300.c
+++ b/bfd/coff-h8300.c
@@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Steve Chamberlain, <sac@cygnus.com>.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public 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"
@@ -87,8 +87,7 @@ static boolean h8300_bfd_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *
the generic linker hash table, not the COFF backend linker hash
table! We use this to attach additional data structures we
need while linking on the h8300. */
-struct h8300_coff_link_hash_table
-{
+struct h8300_coff_link_hash_table {
/* The main hash table. */
struct generic_link_hash_table root;
@@ -135,7 +134,7 @@ funcvec_hash_newfunc (entry, gen_table, string)
/* Call the allocation method of the superclass. */
ret = ((struct funcvec_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
if (ret == NULL)
return NULL;
@@ -165,8 +164,8 @@ funcvec_hash_table_init (table, abfd, newfunc)
struct funcvec_hash_table *table;
bfd *abfd;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
+ struct bfd_hash_table *,
+ const char *));
{
/* Initialize our local fields, then call the generic initialization
routine. */
@@ -232,8 +231,7 @@ special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
return bfd_reloc_ok;
}
-static reloc_howto_type howto_table[] =
-{
+static reloc_howto_type howto_table[] = {
HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
@@ -270,9 +268,9 @@ static reloc_howto_type howto_table[] =
/* Turn a howto into a reloc number. */
#define SELECT_RELOC(x,howto) \
- { x.r_type = select_reloc(howto); }
+ { x.r_type = select_reloc (howto); }
-#define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x))
+#define BADMAG(x) (H8300BADMAG (x) && H8300HBADMAG (x) && H8300SBADMAG (x))
#define H8300 1 /* Customize coffcode.h */
#define __A_MAGIC_SET__
@@ -365,15 +363,15 @@ rtype2howto (internal, dst)
}
}
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
/* Perform any necessary magic to the addend in a reloc entry. */
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
+ cache_ptr->addend = ext_reloc.r_offset;
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
+ reloc_processing (relent, reloc, symbols, abfd, section)
static void
reloc_processing (relent, reloc, symbols, abfd, section)
@@ -483,8 +481,15 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
/* If the distance is within -128..+128 inclusive, then we can relax
this jump. +128 is valid since the target will move two bytes
closer if we do relax this branch. */
- if ((int)gap >= -128 && (int)gap <= 128 )
+ if ((int) gap >= -128 && (int) gap <= 128)
{
+ bfd_byte code;
+
+ if (!bfd_get_section_contents (abfd, input_section, & code,
+ reloc->address, 1))
+ break;
+ code = bfd_get_8 (abfd, & code);
+
/* It's possible we may be able to eliminate this branch entirely;
if the previous instruction is a branch around this instruction,
and there's no label at this instruction, then we can reverse
@@ -496,9 +501,25 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
lab1: lab1:
This saves 4 bytes instead of two, and should be relatively
- common. */
-
- if (gap <= 126
+ common.
+
+ Only perform this optimisation for jumps (code 0x5a) not
+ subroutine calls, as otherwise it could transform:
+
+ mov.w r0,r0
+ beq .L1
+ jsr @_bar
+ .L1: rts
+ _bar: rts
+ into:
+ mov.w r0,r0
+ bne _bar
+ rts
+ _bar: rts
+
+ which changes the call (jsr) into a branch (bne). */
+ if (code == 0x5a
+ && gap <= 126
&& last_reloc
&& last_reloc->howto->type == R_PCRBYTE)
{
@@ -546,7 +567,7 @@ h8300_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
/* If the distance is within -128..+128 inclusive, then we can relax
this jump. +128 is valid since the target will move two bytes
closer if we do relax this branch. */
- if ((int)gap >= -128 && (int)gap <= 128 )
+ if ((int) gap >= -128 && (int) gap <= 128)
{
/* Change the reloc type. */
reloc->howto = howto_table + 15;
@@ -736,7 +757,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
/* Sanity check. */
if (value <= 0xff
|| (value >= 0x0000ff00 && value <= 0x0000ffff)
- || (value >= 0x00ffff00 && value <= 0x00ffffff)
+ || (value >= 0x00ffff00 && value <= 0x00ffffff)
|| (value >= 0xffffff00 && value <= 0xffffffff))
{
/* Everything looks OK. Apply the relocation and update the
@@ -804,7 +825,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
/* Fix the opcode. For all the move insns, we simply
need to turn off bit 0x20 in the previous byte. */
- data[dst_address - 1] &= ~0x20;
+ data[dst_address - 1] &= ~0x20;
dst_address += 2;
src_address += 4;
}
@@ -815,7 +836,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
reloc->howto->name, reloc->addend, input_section->owner,
input_section, reloc->address)))
abort ();
- }
+ }
break;
/* A 16bit absolute branch that is now an 8-bit pc-relative branch. */
@@ -912,14 +933,14 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
abort ();
}
- /* Output the target. */
- bfd_put_8 (abfd, gap, data + dst_address - 1);
+ /* Output the target. */
+ bfd_put_8 (abfd, gap, data + dst_address - 1);
- /* We don't advance dst_address -- the 8bit reloc is applied at
- dst_address - 1, so the next insn should begin at dst_address. */
- src_address += 2;
+ /* We don't advance dst_address -- the 8bit reloc is applied at
+ dst_address - 1, so the next insn should begin at dst_address. */
+ src_address += 2;
- break;
+ break;
/* Similarly for a 24bit absolute that is now 8 bits. */
case R_JMPL2:
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index 5d867ea40b9..5c80b11b5d3 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -32,8 +32,7 @@
image and NOT in the file.
To be compatible with any existing executables I have fixed this
- here and NOT in the DJGPP startup code.
- */
+ here and NOT in the DJGPP startup code. */
#define TARGET_SYM go32stubbedcoff_vec
#define TARGET_NAME "coff-go32-exe"
@@ -55,40 +54,32 @@
#include "bfd.h"
-/* At first the prototypes */
+/* At first the prototypes. */
static void
-adjust_filehdr_in_post PARAMS ((bfd * abfd, PTR src, PTR dst));
+adjust_filehdr_in_post PARAMS ((bfd *, PTR, PTR));
static void
-adjust_filehdr_out_pre PARAMS ((bfd * abfd, PTR in, PTR out));
+adjust_filehdr_out_pre PARAMS ((bfd *, PTR, PTR));
static void
-adjust_filehdr_out_post PARAMS ((bfd * abfd, PTR in, PTR out));
-
+adjust_filehdr_out_post PARAMS ((bfd *, PTR, PTR));
static void
-adjust_scnhdr_in_post PARAMS ((bfd * abfd, PTR ext, PTR in));
+adjust_scnhdr_in_post PARAMS ((bfd *, PTR, PTR));
static void
-adjust_scnhdr_out_pre PARAMS ((bfd * abfd, PTR in, PTR out));
+adjust_scnhdr_out_pre PARAMS ((bfd *, PTR, PTR));
static void
-adjust_scnhdr_out_post PARAMS ((bfd * abfd, PTR in, PTR out));
-
+adjust_scnhdr_out_post PARAMS ((bfd *, PTR, PTR));
static void
-adjust_aux_in_post PARAMS ((bfd * abfd, PTR ext1, int type, int class, int indx,
- int numaux, PTR in1));
+adjust_aux_in_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
static void
-adjust_aux_out_pre PARAMS ((bfd * abfd, PTR inp, int type, int class, int indx,
- int numaux, PTR extp));
+adjust_aux_out_pre PARAMS ((bfd *, PTR, int, int, int, int, PTR));
static void
-adjust_aux_out_post PARAMS ((bfd * abfd, PTR inp, int type, int class, int indx,
- int numaux, PTR extp));
-
+adjust_aux_out_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
static void
-create_go32_stub PARAMS ((bfd * abfd));
+create_go32_stub PARAMS ((bfd *));
-/*
- All that ..._PRE and ...POST functions are called from the corresponding
+/* All that ..._PRE and ...POST functions are called from the corresponding
coff_swap... functions. The ...PRE functions are called at the beginning
- of the function and the ...POST functions at the end of the swap routines.
- */
+ of the function and the ...POST functions at the end of the swap routines. */
#define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post
#define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre
@@ -103,23 +94,23 @@ create_go32_stub PARAMS ((bfd * abfd));
#define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post
static boolean
- go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd * ibfd, bfd * obfd));
+ go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
#include "coff-i386.c"
-/* I hold in the usrdata the stub */
+/* I hold in the usrdata the stub. */
#define bfd_coff_go32stub bfd_usrdata
/* This macro is used, because I cannot assume the endianess of the
- host system */
+ host system. */
#define _H(index) (H_GET_16 (abfd, (header+index*2)))
/* These bytes are a 2048-byte DOS executable, which loads the COFF
- image into memory and then runs it. It is called 'stub' */
+ image into memory and then runs it. It is called 'stub'. */
-static unsigned char stub_bytes[STUBSIZE] =
+static const unsigned char stub_bytes[STUBSIZE] =
{
#include "go32stub.h"
};
@@ -129,10 +120,10 @@ static unsigned char stub_bytes[STUBSIZE] =
technique is in any function the same. For the ...in function,
all the pointers are adjusted by adding STUBSIZE and for the
...out function, it is subtracted first and after calling the
- standard swap function it is reset to the old value */
+ standard swap function it is reset to the old value. */
/* This macro is used for adjusting the filepointers, which
- is done only, if the pointer is nonzero */
+ is done only, if the pointer is nonzero. */
#define ADJUST_VAL(val,diff) \
if (val != 0) val += diff
@@ -148,13 +139,13 @@ adjust_filehdr_in_post (abfd, src, dst)
ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
- /* Save now the stub to be used later */
+ /* Save now the stub to be used later. */
bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
/* Since this function returns no status, I do not set here
any bfd_error_...
That means, before the use of bfd_coff_go32stub (), this value
- should be checked if it is != NULL */
+ should be checked if it is != NULL. */
if (bfd_coff_go32stub (abfd) == NULL)
return;
memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
@@ -169,14 +160,14 @@ adjust_filehdr_out_pre (abfd, in, out)
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
FILHDR *filehdr_out = (FILHDR *) out;
- /* Generate the stub */
+ /* Generate the stub. */
create_go32_stub (abfd);
- /* Copy the stub to the file header */
+ /* Copy the stub to the file header. */
if (bfd_coff_go32stub (abfd) != NULL)
memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
else
- /* use the default */
+ /* Use the default. */
memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
@@ -189,7 +180,7 @@ adjust_filehdr_out_post (abfd, in, out)
PTR out ATTRIBUTE_UNUSED;
{
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
- /* undo the above change */
+ /* Undo the above change. */
ADJUST_VAL (filehdr_in->f_symptr, STUBSIZE);
}
@@ -286,8 +277,7 @@ adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
}
}
-/*
- That's the function, which creates the stub. There are
+/* That's the function, which creates the stub. There are
different cases from where the stub is taken.
At first the environment variable $(GO32STUB) is checked and then
$(STUB) if it was not set.
@@ -297,14 +287,13 @@ adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
file.
If there was any error, the standard stub (compiled in this file)
- is taken.
- */
+ is taken. */
static void
create_go32_stub (abfd)
bfd *abfd;
{
- /* Do it only once */
+ /* Do it only once. */
if (bfd_coff_go32stub (abfd) == NULL)
{
char *stub;
@@ -315,9 +304,9 @@ create_go32_stub (abfd)
unsigned long coff_start;
long exe_start;
- /* Check at first the environment variable $(GO32STUB) */
+ /* Check at first the environment variable $(GO32STUB). */
stub = getenv ("GO32STUB");
- /* Now check the environment variable $(STUB) */
+ /* Now check the environment variable $(STUB). */
if (stub == NULL)
stub = getenv ("STUB");
if (stub == NULL)
@@ -336,19 +325,19 @@ create_go32_stub (abfd)
close (f);
goto stub_end;
}
- if (_H (0) != 0x5a4d) /* it is not an exe file */
+ if (_H (0) != 0x5a4d) /* It is not an exe file. */
{
close (f);
goto stub_end;
}
/* Compute the size of the stub (it is every thing up
- to the beginning of the coff image) */
+ to the beginning of the coff image). */
coff_start = (long) _H (2) * 512L;
if (_H (1))
coff_start += (long) _H (1) - 512L;
/* Currently there is only a fixed stub size of 2048 bytes
- supported */
+ supported. */
if (coff_start != 2048)
{
close (f);
@@ -370,7 +359,7 @@ create_go32_stub (abfd)
close (f);
goto stub_end;
}
- /* Now we found a correct stub (hopefully) */
+ /* Now we found a correct stub (hopefully). */
bfd_coff_go32stub (abfd)
= (PTR) bfd_alloc (abfd, (bfd_size_type) coff_start);
if (bfd_coff_go32stub (abfd) == NULL)
@@ -389,39 +378,35 @@ create_go32_stub (abfd)
}
stub_end:
/* There was something wrong above, so use now the standard builtin
- stub */
+ stub. */
if (bfd_coff_go32stub (abfd) == NULL)
{
bfd_coff_go32stub (abfd)
= (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
if (bfd_coff_go32stub (abfd) == NULL)
- {
- return;
- }
-
+ return;
memcpy (bfd_coff_go32stub (abfd), stub_bytes, STUBSIZE);
}
}
/* If ibfd was a stubbed coff image, copy the stub from that bfd
- to the new obfd.
- */
+ to the new obfd. */
static boolean
go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
{
- /* check if both are the same targets */
+ /* Check if both are the same targets. */
if (ibfd->xvec != obfd->xvec)
return true;
- /* check if both have a valid stub */
+ /* Check if both have a valid stub. */
if (bfd_coff_go32stub (ibfd) == NULL
|| bfd_coff_go32stub (obfd) == NULL)
return true;
- /* Now copy the stub */
+ /* Now copy the stub. */
memcpy (bfd_coff_go32stub (obfd), bfd_coff_go32stub (ibfd), STUBSIZE);
return true;
diff --git a/bfd/coff-tic4x.c b/bfd/coff-tic4x.c
index 561d161f82f..8afd04a614d 100644
--- a/bfd/coff-tic4x.c
+++ b/bfd/coff-tic4x.c
@@ -123,20 +123,20 @@ tic4x_relocation (abfd, reloc_entry, symbol, data, input_section,
reloc_howto_type tic4x_howto_table[] =
{
- HOWTO(R_RELWORD, 0, 2, 16, false, 0, complain_overflow_signed, tic4x_relocation, "RELWORD", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_RELWORD, 0, 2, 16, false, 0, complain_overflow_signed, tic4x_relocation, "RELWORD", true, 0x0000ffff, 0x0000ffff, false),
HOWTO(R_REL24, 0, 2, 24, false, 0, complain_overflow_bitfield, tic4x_relocation, "REL24", true, 0x00ffffff, 0x00ffffff, false),
- HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_dont, tic4x_relocation, "RELLONG", true, 0xffffffff, 0xffffffff, false),
- HOWTO(R_PCRWORD, 0, 2, 16, true, 0, complain_overflow_signed, tic4x_relocation, "PCRWORD", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_PCR24, 0, 2, 24, true, 0, complain_overflow_signed, tic4x_relocation, "PCR24", true, 0x00ffffff, 0x00ffffff, false),
- HOWTO(R_PARTLS16, 0, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "PARTLS16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_PARTMS8, 16, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "PARTMS8", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_RELWORD, 0, 2, 16, false, 0, complain_overflow_signed, tic4x_relocation, "ARELWORD", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_REL24, 0, 2, 24, false, 0, complain_overflow_signed, tic4x_relocation, "AREL24", true, 0x00ffffff, 0x00ffffff, false),
- HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_signed, tic4x_relocation, "ARELLONG", true, 0xffffffff, 0xffffffff, false),
- HOWTO(R_PCRWORD, 0, 2, 16, true, 0, complain_overflow_signed, tic4x_relocation, "APCRWORD", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_PCR24, 0, 2, 24, true, 0, complain_overflow_signed, tic4x_relocation, "APCR24", true, 0x00ffffff, 0x00ffffff, false),
- HOWTO(R_PARTLS16, 0, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "APARTLS16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO(R_PARTMS8, 16, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "APARTMS8", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_dont, tic4x_relocation, "RELLONG", true, 0xffffffff, 0xffffffff, false),
+ HOWTO(R_PCRWORD, 0, 2, 16, true, 0, complain_overflow_signed, tic4x_relocation, "PCRWORD", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_PCR24, 0, 2, 24, true, 0, complain_overflow_signed, tic4x_relocation, "PCR24", true, 0x00ffffff, 0x00ffffff, false),
+ HOWTO(R_PARTLS16, 0, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "PARTLS16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_PARTMS8, 16, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "PARTMS8", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_RELWORD, 0, 2, 16, false, 0, complain_overflow_signed, tic4x_relocation, "ARELWORD", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_REL24, 0, 2, 24, false, 0, complain_overflow_signed, tic4x_relocation, "AREL24", true, 0x00ffffff, 0x00ffffff, false),
+ HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_signed, tic4x_relocation, "ARELLONG", true, 0xffffffff, 0xffffffff, false),
+ HOWTO(R_PCRWORD, 0, 2, 16, true, 0, complain_overflow_signed, tic4x_relocation, "APCRWORD", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_PCR24, 0, 2, 24, true, 0, complain_overflow_signed, tic4x_relocation, "APCR24", true, 0x00ffffff, 0x00ffffff, false),
+ HOWTO(R_PARTLS16, 0, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "APARTLS16", true, 0x0000ffff, 0x0000ffff, false),
+ HOWTO(R_PARTMS8, 16, 2, 16, false, 0, complain_overflow_dont, tic4x_relocation, "APARTMS8", true, 0x0000ffff, 0x0000ffff, false),
};
#define HOWTO_SIZE (sizeof(tic4x_howto_table) / sizeof(tic4x_howto_table[0]))
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index e47b4d0050f..694fb12f4d8 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1246,7 +1246,7 @@ Special entry points for gdb to swap in coff symbol table parts:
. struct coff_link_hash_entry *, struct internal_syment *,
. bfd_vma *));
.
-. boolean (*_bfd_coff_adjust_symndx)\
+. boolean (*_bfd_coff_adjust_symndx)
. PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
. struct internal_reloc *, boolean *));
.
diff --git a/bfd/config.bfd b/bfd/config.bfd
index fdc7bbe4854..9270d7e9e85 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -139,8 +139,8 @@ case "${targ}" in
targ_underscore=yes
;;
arm-*-nto* | nto*arm*)
- targ_defvec=bfd_elf32_littlearmqnx_vec
- targ_selvecs=bfd_elf32_bigarmqnx_vec
+ targ_defvec=bfd_elf32_littlearm_vec
+ targ_selvecs=bfd_elf32_bigarm_vec
;;
arm-*-riscix*)
targ_defvec=riscix_vec
@@ -370,8 +370,8 @@ case "${targ}" in
targ_defvec=bfd_elf32_i386_vec
targ_selvecs=i386coff_vec
;;
- i[3456]86-*-nto-qnx*)
- targ_defvec=bfd_elf32_i386qnx_vec
+ i[3456]86-*-nto*)
+ targ_defvec=bfd_elf32_i386_vec
targ_selvecs=i386coff_vec
;;
i[3456]86-*-chorus*)
@@ -393,6 +393,11 @@ case "${targ}" in
targ_defvec=bfd_elf32_i386_vec
targ_selvecs="i386coff_vec i386aout_vec"
;;
+ i[3456]86-*-darwin* | i[3456]86-*-macos10* | i[3456]86-*-rhapsody*)
+ targ_defvec=mach_o_le_vec
+ targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec"
+ targ_archs="bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch"
+ ;;
i[3456]86-sequent-bsd*)
targ_defvec=i386dynix_vec
targ_underscore=yes
@@ -691,11 +696,11 @@ case "${targ}" in
;;
mips*el-*-netbsd*)
targ_defvec=bfd_elf32_littlemips_vec
- targ_selvecs="bfd_elf32_bigmips_vec ecoff_little_vec ecoff_big_vec"
+ targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_little_vec ecoff_big_vec"
;;
mips*-*-netbsd*)
targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec"
;;
mips*-dec-bsd*)
targ_defvec=aout_mips_little_vec
@@ -885,6 +890,11 @@ case "${targ}" in
targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
;;
+ powerpc-*-darwin* | powerpc-*-macos10* | powerpc-*-rhapsody*)
+ targ_defvec=mach_o_be_vec
+ targ_selvecs="mach_o_be_vec mach_o_le_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec"
+ targ_archs="bfd_powerpc_arch bfd_rs6000_arch bfd_i386_arch"
+ ;;
powerpc-*-macos* | powerpc-*-mpw*)
targ_defvec=pmac_xcoff_vec
;;
@@ -893,12 +903,12 @@ case "${targ}" in
targ_selvecs="nlm32_powerpc_vec rs6000coff_vec"
;;
powerpc-*-nto*)
- targ_defvec=bfd_elf32_powerpcqnx_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpcleqnx_vec ppcboot_vec"
+ targ_defvec=bfd_elf32_powerpc_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
;;
powerpcle-*-nto*)
- targ_defvec=bfd_elf32_powerpcleqnx_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpcqnx_vec ppcboot_vec"
+ targ_defvec=bfd_elf32_powerpcle_vec
+ targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec ppcboot_vec"
;;
powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
powerpcle-*-solaris2* | powerpcle-*-linux-gnu* | powerpcle-*-vxworks* |\
@@ -949,7 +959,7 @@ case "${targ}" in
targ_defvec=bfd_elf32_shblin_vec
targ_selvecs=bfd_elf32_shlin_vec
#ifdef BFD64
- targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+ targ_selvecs="${targ_selvecs} bfd_elf32_sh64lin_vec bfd_elf32_sh64blin_vec bfd_elf64_sh64lin_vec bfd_elf64_sh64blin_vec"
#endif
;;
sh*eb-*-linux*)
@@ -985,7 +995,7 @@ case "${targ}" in
targ_defvec=bfd_elf32_shlnbsd_vec
targ_selvecs="bfd_elf32_shnbsd_vec shcoff_vec shlcoff_vec"
#ifdef BFD64
- targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+ targ_selvecs="${targ_selvecs} bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec"
#endif
;;
sh*le-*-netbsdelf*)
@@ -996,7 +1006,7 @@ case "${targ}" in
targ_defvec=bfd_elf32_shnbsd_vec
targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec"
#ifdef BFD64
- targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+ targ_selvecs="${targ_selvecs} bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec"
#endif
;;
sh*-*-netbsdelf*)
@@ -1021,8 +1031,8 @@ case "${targ}" in
targ_underscore=yes
;;
sh-*-nto*)
- targ_defvec=bfd_elf32_shqnx_vec
- targ_selvecs="bfd_elf32_shlqnx_vec shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec"
+ 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)
diff --git a/bfd/configure b/bfd/configure
index 794cb620551..6eb4abbd3f8 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -5975,12 +5975,14 @@ fi
all_targets=false
defvec=
selvecs=
+assocvecs=
selarchs=
TDEFINES=
for targ in $target $canon_targets
do
if test "x$targ" = "xall"; then
all_targets=true
+ assocvecs="$assocvecs $targ_defvec $targ_selvecs"
else
. $srcdir/config.bfd
if test "x$targ" = "x$target"; then
@@ -6011,6 +6013,17 @@ done
selvecs="$f"
+# uniq the associated vectors in all the configured targets.
+f=""
+for i in $assocvecs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+assocvecs="$f"
+
+
# uniq the architectures in all the configured targets.
f=""
for i in $selarchs ; do
@@ -6061,8 +6074,7 @@ do
bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_bigarmqnx_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
@@ -6074,9 +6086,8 @@ do
bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.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_freebsd_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_i386qnx_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.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" ;;
@@ -6086,8 +6097,7 @@ do
bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_littlearmqnx_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
@@ -6106,10 +6116,8 @@ do
bfd_elf32_or32_big_vec) tb="$tb elf32-or32.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-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcleqnx_vec) tb="$tb elf32-ppc.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcqnx_vec) tb="$tb elf32-ppc.lo elf32-qnx.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_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
# FIXME: We include cofflink.lo not because it's needed for
# bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
@@ -6120,14 +6128,12 @@ do
bfd_elf32_sh64blin_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
bfd_elf32_sh64lnbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
bfd_elf32_sh64nbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
- bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
- bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo elf32-qnx.lo $elf coff-sh.lo" ;;
- bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shlqnx_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
- bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shqnx_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
@@ -6320,9 +6326,12 @@ if test x${all_targets} = xtrue ; then
selvecs=
havevecs=
selarchs=
+ test -n "$assocvecs" &&
+ assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
+ assocvecs=
test -n "$selvecs" &&
havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
test -n "$selvecs" &&
@@ -6343,10 +6352,10 @@ case ${host64}-${target64}-${want64} in
if test -n "$GCC" ; then
bad_64bit_gcc=no;
echo $ac_n "checking for gcc version with buggy 64-bit support""... $ac_c" 1>&6
-echo "configure:6347: checking for gcc version with buggy 64-bit support" >&5
+echo "configure:6356: checking for gcc version with buggy 64-bit support" >&5
# Add more tests for gcc versions with non-working 64-bit support here.
cat > conftest.$ac_ext <<EOF
-#line 6350 "configure"
+#line 6359 "configure"
#include "confdefs.h"
:__GNUC__:__GNUC_MINOR__:__i386__:
EOF
@@ -6383,6 +6392,7 @@ esac
tdefaults=""
test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${assocvecs}" && tdefaults="${tdefaults} -DASSOCIATED_VECS='${assocvecs}'"
test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
@@ -6391,17 +6401,17 @@ for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6395: checking for $ac_hdr" >&5
+echo "configure:6405: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6400 "configure"
+#line 6410 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6415: \"$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*
@@ -6430,12 +6440,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6434: checking for $ac_func" >&5
+echo "configure:6444: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6439 "configure"
+#line 6449 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6458,7 +6468,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6472: \"$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
@@ -6483,7 +6493,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6487: checking for working mmap" >&5
+echo "configure:6497: 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
@@ -6491,7 +6501,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 6495 "configure"
+#line 6505 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6644,7 +6654,7 @@ main()
}
EOF
-if { (eval echo configure:6648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6658: \"$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
@@ -6669,12 +6679,12 @@ fi
for ac_func in madvise mprotect
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6673: checking for $ac_func" >&5
+echo "configure:6683: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6678 "configure"
+#line 6688 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6697,7 +6707,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6711: \"$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
diff --git a/bfd/configure.in b/bfd/configure.in
index b59089d5e8f..cb39e8fdbd0 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -471,12 +471,14 @@ fi
all_targets=false
defvec=
selvecs=
+assocvecs=
selarchs=
TDEFINES=
for targ in $target $canon_targets
do
if test "x$targ" = "xall"; then
all_targets=true
+ assocvecs="$assocvecs $targ_defvec $targ_selvecs"
else
. $srcdir/config.bfd
if test "x$targ" = "x$target"; then
@@ -507,6 +509,17 @@ done
selvecs="$f"
+# uniq the associated vectors in all the configured targets.
+f=""
+for i in $assocvecs ; do
+ case " $f " in
+ *" $i "*) ;;
+ *) f="$f $i" ;;
+ esac
+done
+assocvecs="$f"
+
+
# uniq the architectures in all the configured targets.
f=""
for i in $selarchs ; do
@@ -557,8 +570,7 @@ do
bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_bigarmqnx_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
@@ -570,9 +582,8 @@ do
bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.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_freebsd_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_i386qnx_vec) tb="$tb elf32-i386.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.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" ;;
@@ -582,8 +593,7 @@ do
bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_littlearmqnx_vec) tb="$tb elfarm-nabi.lo elf32-qnx.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
@@ -602,10 +612,8 @@ do
bfd_elf32_or32_big_vec) tb="$tb elf32-or32.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-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcleqnx_vec) tb="$tb elf32-ppc.lo elf32-qnx.lo elf32.lo $elf" ;;
- bfd_elf32_powerpcqnx_vec) tb="$tb elf32-ppc.lo elf32-qnx.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_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
# FIXME: We include cofflink.lo not because it's needed for
# bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
@@ -616,14 +624,12 @@ do
bfd_elf32_sh64blin_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
bfd_elf32_sh64lnbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
bfd_elf32_sh64nbsd_vec) tb="$tb elf32-sh64.lo elf32-sh64-com.lo elf32.lo $elf cofflink.lo" ;;
- bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
- bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo elf32-qnx.lo $elf coff-sh.lo" ;;
- bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shlqnx_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
- bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shqnx_vec) tb="$tb elf32-sh.lo elf32-qnx.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+ bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
@@ -816,9 +822,12 @@ if test x${all_targets} = xtrue ; then
selvecs=
havevecs=
selarchs=
+ test -n "$assocvecs" &&
+ assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
+ assocvecs=
test -n "$selvecs" &&
havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
test -n "$selvecs" &&
@@ -866,6 +875,7 @@ AC_SUBST(bfd_default_target_size)
tdefaults=""
test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${assocvecs}" && tdefaults="${tdefaults} -DASSOCIATED_VECS='${assocvecs}'"
test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
AC_SUBST(tdefaults)
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index d25bbf2c743..ec09ffb70fc 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -245,7 +245,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:
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index dcccc482f88..2fae2b4486d 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -235,11 +235,79 @@ enum elf_link_info_type
ELF_INFO_TYPE_STABS,
ELF_INFO_TYPE_MERGE,
ELF_INFO_TYPE_EH_FRAME,
- ELF_INFO_TYPE_EH_FRAME_HDR,
ELF_INFO_TYPE_JUST_SYMS,
ELF_INFO_TYPE_LAST
};
+/* Structures used by the eh_frame optimization code. */
+struct cie_header
+{
+ unsigned int length;
+ unsigned int id;
+};
+
+struct cie
+{
+ struct cie_header hdr;
+ unsigned char version;
+ unsigned char augmentation[20];
+ unsigned int code_align;
+ int data_align;
+ unsigned int ra_column;
+ unsigned int augmentation_size;
+ struct elf_link_hash_entry *personality;
+ unsigned char per_encoding;
+ unsigned char lsda_encoding;
+ unsigned char fde_encoding;
+ unsigned char initial_insn_length;
+ unsigned char make_relative;
+ unsigned char make_lsda_relative;
+ unsigned char initial_instructions[50];
+};
+
+struct eh_cie_fde
+{
+ unsigned int offset;
+ unsigned int size;
+ asection *sec;
+ unsigned int new_offset;
+ unsigned char fde_encoding;
+ unsigned char lsda_encoding;
+ unsigned char lsda_offset;
+ unsigned char cie : 1;
+ unsigned char removed : 1;
+ unsigned char make_relative : 1;
+ unsigned char make_lsda_relative : 1;
+ unsigned char per_encoding_relative : 1;
+};
+
+struct eh_frame_sec_info
+{
+ unsigned int count;
+ unsigned int alloced;
+ struct eh_cie_fde entry[1];
+};
+
+struct eh_frame_array_ent
+{
+ bfd_vma initial_loc;
+ bfd_vma fde;
+};
+
+struct eh_frame_hdr_info
+{
+ struct cie last_cie;
+ asection *last_cie_sec;
+ asection *hdr_sec;
+ unsigned int last_cie_offset;
+ unsigned int fde_count, array_count;
+ struct eh_frame_array_ent *array;
+ /* TRUE if .eh_frame_hdr should contain the sorted search table.
+ We build it if we successfully read all .eh_frame input sections
+ and recognize them. */
+ boolean table;
+};
+
/* Cached start, size and alignment of PT_TLS segment. */
struct elf_link_tls_segment
{
@@ -294,6 +362,9 @@ struct elf_link_hash_table
/* A pointer to information used to merge SEC_MERGE sections. */
PTR merge_info;
+ /* Used by eh_frame code when editing .eh_frame. */
+ struct eh_frame_hdr_info eh_info;
+
/* A linked list of local symbols to be added to .dynsym. */
struct elf_link_local_dynamic_entry *dynlocal;
@@ -770,22 +841,6 @@ struct elf_backend_data
boolean (*elf_backend_write_section)
PARAMS ((bfd *, asection *, bfd_byte *));
- /* This function, if defined, sets up the file positions for non PT_LOAD
- segments, especially for segments containing non-allocated sections. */
- void (*set_nonloadable_filepos)
- PARAMS ((bfd *, Elf_Internal_Phdr *));
-
- /* This function, if defined, returns true if the section is contained
- within the segment. File positions are compared. */
- boolean (*is_contained_by_filepos)
- PARAMS ((asection *, Elf_Internal_Phdr *));
-
- /* This function, if defined, returns true if copy_private_bfd_data
- should be called. It provides a way of overriding default
- test conditions in _bfd_elf_copy_private_section_data. */
- boolean (*copy_private_bfd_data_p)
- PARAMS ((bfd *, asection *, bfd *, asection *));
-
/* The level of IRIX compatibility we're striving for.
MIPS ELF specific function. */
irix_compat_t (*elf_backend_mips_irix_compat)
@@ -1134,12 +1189,12 @@ struct elf_obj_tdata
include this field for a MIPS ELF target. */
asection **local_stubs;
- /* Used to determine if the e_flags field has been initialized */
- boolean flags_init;
-
/* Used to determine if PT_GNU_EH_FRAME segment header should be
created. */
- boolean eh_frame_hdr;
+ asection *eh_frame_hdr;
+
+ /* Used to determine if the e_flags field has been initialized */
+ boolean flags_init;
/* Number of symbol version definitions we are about to emit. */
unsigned int cverdefs;
@@ -1382,16 +1437,16 @@ extern void _bfd_elf_strtab_finalize
PARAMS ((struct elf_strtab_hash *));
extern boolean _bfd_elf_discard_section_eh_frame
- PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *,
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
boolean (*) (bfd_vma, PTR), struct elf_reloc_cookie *));
extern boolean _bfd_elf_discard_section_eh_frame_hdr
- PARAMS ((bfd *, struct bfd_link_info *, asection *));
+ PARAMS ((bfd *, struct bfd_link_info *));
extern bfd_vma _bfd_elf_eh_frame_section_offset
PARAMS ((bfd *, asection *, bfd_vma));
extern boolean _bfd_elf_write_section_eh_frame
- PARAMS ((bfd *, asection *, asection *, bfd_byte *));
+ PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_byte *));
extern boolean _bfd_elf_write_section_eh_frame_hdr
- PARAMS ((bfd *, asection *));
+ PARAMS ((bfd *, struct bfd_link_info *));
extern boolean _bfd_elf_maybe_strip_eh_frame_hdr
PARAMS ((struct bfd_link_info *));
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index e80fc6c9d57..fa152abd9af 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -26,74 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define EH_FRAME_HDR_SIZE 8
-struct cie_header
-{
- unsigned int length;
- unsigned int id;
-};
-
-struct cie
-{
- struct cie_header hdr;
- unsigned char version;
- unsigned char augmentation[20];
- unsigned int code_align;
- int data_align;
- unsigned int ra_column;
- unsigned int augmentation_size;
- struct elf_link_hash_entry *personality;
- unsigned char per_encoding;
- unsigned char lsda_encoding;
- unsigned char fde_encoding;
- unsigned char initial_insn_length;
- unsigned char make_relative;
- unsigned char make_lsda_relative;
- unsigned char initial_instructions[50];
-};
-
-struct eh_cie_fde
-{
- unsigned int offset;
- unsigned int size;
- asection *sec;
- unsigned int new_offset;
- unsigned char fde_encoding;
- unsigned char lsda_encoding;
- unsigned char lsda_offset;
- unsigned char cie : 1;
- unsigned char removed : 1;
- unsigned char make_relative : 1;
- unsigned char make_lsda_relative : 1;
- unsigned char per_encoding_relative : 1;
-};
-
-struct eh_frame_sec_info
-{
- unsigned int count;
- unsigned int alloced;
- struct eh_cie_fde entry[1];
-};
-
-struct eh_frame_array_ent
-{
- bfd_vma initial_loc;
- bfd_vma fde;
-};
-
-struct eh_frame_hdr_info
-{
- struct cie last_cie;
- asection *last_cie_sec;
- unsigned int last_cie_offset;
- unsigned int fde_count, array_count;
- struct eh_frame_array_ent *array;
- /* TRUE if .eh_frame_hdr should contain the sorted search table.
- We build it if we successfully read all .eh_frame input sections
- and recognize them. */
- boolean table;
- boolean strip;
-};
-
static bfd_vma read_unsigned_leb128
PARAMS ((bfd *, char *, unsigned int *));
static bfd_signed_vma read_signed_leb128
@@ -282,11 +214,11 @@ int cie_compare (c1, c2)
deleted. */
boolean
-_bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
+_bfd_elf_discard_section_eh_frame (abfd, info, sec,
reloc_symbol_deleted_p, cookie)
bfd *abfd;
struct bfd_link_info *info;
- asection *sec, *ehdrsec;
+ asection *sec;
boolean (*reloc_symbol_deleted_p) PARAMS ((bfd_vma, PTR));
struct elf_reloc_cookie *cookie;
{
@@ -294,12 +226,12 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
bfd_byte *last_cie, *last_fde;
struct cie_header hdr;
struct cie cie;
+ struct elf_link_hash_table *htab;
struct eh_frame_hdr_info *hdr_info;
struct eh_frame_sec_info *sec_info = NULL;
unsigned int leb128_tmp;
unsigned int cie_usage_count, last_cie_ndx, i, offset;
unsigned int make_relative, make_lsda_relative;
- Elf_Internal_Rela *rel;
bfd_size_type new_size;
unsigned int ptr_size;
@@ -317,10 +249,8 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
return false;
}
- BFD_ASSERT (elf_section_data (ehdrsec)->sec_info_type
- == ELF_INFO_TYPE_EH_FRAME_HDR);
- hdr_info = (struct eh_frame_hdr_info *)
- elf_section_data (ehdrsec)->sec_info;
+ htab = elf_hash_table (info);
+ hdr_info = &htab->eh_info;
/* Read the frame unwind information from abfd. */
@@ -414,7 +344,7 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
/* 64-bit .eh_frame is not supported. */
goto free_no_table;
buf += 4;
- if ((buf - ehbuf) + hdr.length > sec->_raw_size)
+ if ((bfd_size_type) (buf - ehbuf) + hdr.length > sec->_raw_size)
/* CIE/FDE not contained fully in this .eh_frame input section. */
goto free_no_table;
@@ -555,10 +485,9 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
+ ((buf - ehbuf + per_width - 1)
& ~((bfd_size_type) per_width - 1)));
ENSURE_NO_RELOCS (buf);
- rel = GET_RELOC (buf);
/* Ensure we have a reloc here, against
a global symbol. */
- if (rel != NULL)
+ if (GET_RELOC (buf) != NULL)
{
unsigned long r_symndx;
@@ -626,8 +555,7 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
goto free_no_table;
ENSURE_NO_RELOCS (buf);
- rel = GET_RELOC (buf);
- if (rel == NULL)
+ if (GET_RELOC (buf) == NULL)
/* This should not happen. */
goto free_no_table;
if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie))
@@ -636,7 +564,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
be deleted. */
new_size -= hdr.length + 4;
sec_info->entry[sec_info->count].removed = 1;
- memset (rel, 0, sizeof (*rel));
}
else
{
@@ -654,7 +581,6 @@ _bfd_elf_discard_section_eh_frame (abfd, info, sec, ehdrsec,
cie_usage_count++;
hdr_info->fde_count++;
}
- cookie->rel = rel;
if (cie.lsda_encoding != DW_EH_PE_omit)
{
unsigned int dummy;
@@ -745,36 +671,27 @@ free_no_table:
input sections. It finalizes the size of .eh_frame_hdr section. */
boolean
-_bfd_elf_discard_section_eh_frame_hdr (abfd, info, sec)
+_bfd_elf_discard_section_eh_frame_hdr (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
- asection *sec;
{
+ struct elf_link_hash_table *htab;
struct eh_frame_hdr_info *hdr_info;
- unsigned int ptr_size;
-
- ptr_size = (elf_elfheader (abfd)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
-
- if ((elf_section_data (sec)->sec_info_type
- != ELF_INFO_TYPE_EH_FRAME_HDR)
- || ! info->eh_frame_hdr)
- {
- _bfd_strip_section_from_output (info, sec);
- return false;
- }
+ asection *sec;
- hdr_info = (struct eh_frame_hdr_info *)
- elf_section_data (sec)->sec_info;
- if (hdr_info->strip)
+ htab = elf_hash_table (info);
+ hdr_info = &htab->eh_info;
+ sec = hdr_info->hdr_sec;
+ if (sec == NULL)
return false;
+
sec->_cooked_size = EH_FRAME_HDR_SIZE;
if (hdr_info->table)
sec->_cooked_size += 4 + hdr_info->fde_count * 8;
/* Request program headers to be recalculated. */
elf_tdata (abfd)->program_header_size = 0;
- elf_tdata (abfd)->eh_frame_hdr = true;
+ elf_tdata (abfd)->eh_frame_hdr = sec;
return true;
}
@@ -787,21 +704,21 @@ boolean
_bfd_elf_maybe_strip_eh_frame_hdr (info)
struct bfd_link_info *info;
{
- asection *sec, *o;
+ asection *o;
bfd *abfd;
+ struct elf_link_hash_table *htab;
struct eh_frame_hdr_info *hdr_info;
- sec = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".eh_frame_hdr");
- if (sec == NULL || bfd_is_abs_section (sec->output_section))
+ htab = elf_hash_table (info);
+ hdr_info = &htab->eh_info;
+ if (hdr_info->hdr_sec == NULL)
return true;
- hdr_info
- = bfd_zmalloc (sizeof (struct eh_frame_hdr_info));
- if (hdr_info == NULL)
- return false;
-
- elf_section_data (sec)->sec_info = hdr_info;
- elf_section_data (sec)->sec_info_type = ELF_INFO_TYPE_EH_FRAME_HDR;
+ if (bfd_is_abs_section (hdr_info->hdr_sec->output_section))
+ {
+ hdr_info->hdr_sec = NULL;
+ return true;
+ }
abfd = NULL;
if (info->eh_frame_hdr)
@@ -816,11 +733,12 @@ _bfd_elf_maybe_strip_eh_frame_hdr (info)
if (abfd == NULL)
{
- _bfd_strip_section_from_output (info, sec);
- hdr_info->strip = true;
+ _bfd_strip_section_from_output (info, hdr_info->hdr_sec);
+ hdr_info->hdr_sec = NULL;
+ return true;
}
- else
- hdr_info->table = true;
+
+ hdr_info->table = true;
return true;
}
@@ -878,9 +796,8 @@ _bfd_elf_eh_frame_section_offset (output_bfd, sec, offset)
for run-time relocation against LSDA field. */
if (sec_info->entry[mid].make_lsda_relative
&& ! sec_info->entry[mid].cie
- && (offset
- == (sec_info->entry[mid].offset + 8
- + sec_info->entry[mid].lsda_offset)))
+ && (offset == (sec_info->entry[mid].offset + 8
+ + sec_info->entry[mid].lsda_offset)))
return (bfd_vma) -2;
return (offset + sec_info->entry[mid].new_offset
@@ -891,12 +808,14 @@ _bfd_elf_eh_frame_section_offset (output_bfd, sec, offset)
contents. */
boolean
-_bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
+_bfd_elf_write_section_eh_frame (abfd, info, sec, contents)
bfd *abfd;
- asection *sec, *ehdrsec;
+ struct bfd_link_info *info;
+ asection *sec;
bfd_byte *contents;
{
struct eh_frame_sec_info *sec_info;
+ struct elf_link_hash_table *htab;
struct eh_frame_hdr_info *hdr_info;
unsigned int i;
bfd_byte *p, *buf;
@@ -914,19 +833,13 @@ _bfd_elf_write_section_eh_frame (abfd, sec, ehdrsec, contents)
sec->_raw_size);
sec_info = (struct eh_frame_sec_info *)
elf_section_data (sec)->sec_info;
- hdr_info = NULL;
- if (ehdrsec
- && (elf_section_data (ehdrsec)->sec_info_type
- == ELF_INFO_TYPE_EH_FRAME_HDR))
- {
- hdr_info = (struct eh_frame_hdr_info *)
- elf_section_data (ehdrsec)->sec_info;
- if (hdr_info->table && hdr_info->array == NULL)
- hdr_info->array
- = bfd_malloc (hdr_info->fde_count * sizeof(*hdr_info->array));
- if (hdr_info->array == NULL)
- hdr_info = NULL;
- }
+ htab = elf_hash_table (info);
+ hdr_info = &htab->eh_info;
+ if (hdr_info->table && hdr_info->array == NULL)
+ hdr_info->array
+ = bfd_malloc (hdr_info->fde_count * sizeof(*hdr_info->array));
+ if (hdr_info->array == NULL)
+ hdr_info = NULL;
p = contents;
for (i = 0; i < sec_info->count; ++i)
@@ -1174,24 +1087,21 @@ vma_compare (a, b)
sorted by increasing initial_loc) */
boolean
-_bfd_elf_write_section_eh_frame_hdr (abfd, sec)
+_bfd_elf_write_section_eh_frame_hdr (abfd, info)
bfd *abfd;
- asection *sec;
+ struct bfd_link_info *info;
{
+ struct elf_link_hash_table *htab;
struct eh_frame_hdr_info *hdr_info;
- unsigned int ptr_size;
+ asection *sec;
bfd_byte *contents;
asection *eh_frame_sec;
bfd_size_type size;
- ptr_size = (elf_elfheader (sec->owner)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
-
- BFD_ASSERT (elf_section_data (sec)->sec_info_type
- == ELF_INFO_TYPE_EH_FRAME_HDR);
- hdr_info = (struct eh_frame_hdr_info *)
- elf_section_data (sec)->sec_info;
- if (hdr_info->strip)
+ htab = elf_hash_table (info);
+ hdr_info = &htab->eh_info;
+ sec = hdr_info->hdr_sec;
+ if (sec == NULL)
return true;
size = EH_FRAME_HDR_SIZE;
diff --git a/bfd/elf.c b/bfd/elf.c
index f184c9fb8eb..c5987fe6df3 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2671,18 +2671,17 @@ assign_section_numbers (abfd)
/* Set up the list of section header pointers, in agreement with the
indices. */
amt = section_number * sizeof (Elf_Internal_Shdr *);
- i_shdrp = (Elf_Internal_Shdr **) bfd_alloc (abfd, amt);
+ i_shdrp = (Elf_Internal_Shdr **) bfd_zalloc (abfd, amt);
if (i_shdrp == NULL)
return false;
amt = sizeof (Elf_Internal_Shdr);
- i_shdrp[0] = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
+ i_shdrp[0] = (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);
if (i_shdrp[0] == NULL)
{
bfd_release (abfd, i_shdrp);
return false;
}
- memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
elf_elfsections (abfd) = i_shdrp;
@@ -3450,10 +3449,9 @@ map_sections_to_segments (abfd)
/* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME
segment. */
- eh_frame_hdr = NULL;
- if (elf_tdata (abfd)->eh_frame_hdr)
- eh_frame_hdr = bfd_get_section_by_name (abfd, ".eh_frame_hdr");
- if (eh_frame_hdr != NULL && (eh_frame_hdr->flags & SEC_LOAD))
+ eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr;
+ if (eh_frame_hdr != NULL
+ && (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0)
{
amt = sizeof (struct elf_segment_map);
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
@@ -3462,7 +3460,7 @@ map_sections_to_segments (abfd)
m->next = NULL;
m->p_type = PT_GNU_EH_FRAME;
m->count = 1;
- m->sections[0] = eh_frame_hdr;
+ m->sections[0] = eh_frame_hdr->output_section;
*pm = m;
pm = &m->next;
@@ -3960,11 +3958,6 @@ Error: First section in segment (%s) starts at 0x%x whereas the segment starts a
}
}
- /* If additional nonloadable filepos adjustments are required,
- do them now. */
- if (bed->set_nonloadable_filepos)
- (*bed->set_nonloadable_filepos) (abfd, phdrs);
-
/* Clear out any program headers we allocated but did not use. */
for (; count < alloc; count++, p++)
{
@@ -4038,8 +4031,7 @@ get_program_header_size (abfd)
++segs;
}
- if (elf_tdata (abfd)->eh_frame_hdr
- && bfd_get_section_by_name (abfd, ".eh_frame_hdr") != NULL)
+ if (elf_tdata (abfd)->eh_frame_hdr)
{
/* We need a PT_GNU_EH_FRAME segment. */
++segs;
@@ -4560,13 +4552,6 @@ copy_private_bfd_data (ibfd, obfd)
&& (section->lma + section->_raw_size \
<= SEGMENT_END (segment, base)))
- /* Returns true if the given section is contained within the
- given segment. Filepos addresses are compared in an elf
- backend function. */
-#define IS_CONTAINED_BY_FILEPOS(sec, seg, bed) \
- (bed->is_contained_by_filepos \
- && (*bed->is_contained_by_filepos) (sec, seg))
-
/* Special case: corefile "NOTE" section containing regs, prpsinfo etc. */
#define IS_COREFILE_NOTE(p, s) \
(p->p_type == PT_NOTE \
@@ -4602,9 +4587,7 @@ copy_private_bfd_data (ibfd, obfd)
? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
: IS_CONTAINED_BY_VMA (section, segment)) \
&& (section->flags & SEC_ALLOC) != 0) \
- || IS_COREFILE_NOTE (segment, section) \
- || (IS_CONTAINED_BY_FILEPOS (section, segment, bed) \
- && (section->flags & SEC_ALLOC) == 0)) \
+ || IS_COREFILE_NOTE (segment, section)) \
&& section->output_section != NULL \
&& ! section->segment_mark)
@@ -4849,7 +4832,6 @@ copy_private_bfd_data (ibfd, obfd)
/* Match up the physical address of the segment with the
LMA address of the output section. */
if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
- || IS_CONTAINED_BY_FILEPOS (section, segment, bed)
|| IS_COREFILE_NOTE (segment, section)
|| (bed->want_p_paddr_set_to_zero &&
IS_CONTAINED_BY_VMA (output_section, segment))
@@ -5086,7 +5068,6 @@ copy_private_bfd_data (ibfd, obfd)
#undef SEGMENT_END
#undef IS_CONTAINED_BY_VMA
#undef IS_CONTAINED_BY_LMA
-#undef IS_CONTAINED_BY_FILEPOS
#undef IS_COREFILE_NOTE
#undef IS_SOLARIS_PT_INTERP
#undef INCLUDE_SECTION_IN_SEGMENT
@@ -5106,26 +5087,12 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)
asection *osec;
{
Elf_Internal_Shdr *ihdr, *ohdr;
- const struct elf_backend_data *bed = get_elf_backend_data (ibfd);
if (ibfd->xvec->flavour != bfd_target_elf_flavour
|| obfd->xvec->flavour != bfd_target_elf_flavour)
return true;
- /* Copy over private BFD data if it has not already been copied.
- This must be done here, rather than in the copy_private_bfd_data
- entry point, because the latter is called after the section
- contents have been set, which means that the program headers have
- already been worked out. The backend function provides a way to
- override the test conditions and code path for the call to
- copy_private_bfd_data. */
- if (bed->copy_private_bfd_data_p)
- {
- if ((*bed->copy_private_bfd_data_p) (ibfd, isec, obfd, osec))
- if (! copy_private_bfd_data (ibfd, obfd))
- return false;
- }
- else if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
+ if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
{
asection *s;
@@ -7358,9 +7325,9 @@ _bfd_elf_section_offset (abfd, info, sec, offset)
switch (sec_data->sec_info_type)
{
case ELF_INFO_TYPE_STABS:
- return _bfd_stab_section_offset
- (abfd, &elf_hash_table (info)->merge_info, sec, &sec_data->sec_info,
- offset);
+ return _bfd_stab_section_offset (abfd,
+ &elf_hash_table (info)->merge_info,
+ sec, &sec_data->sec_info, offset);
case ELF_INFO_TYPE_EH_FRAME:
return _bfd_elf_eh_frame_section_offset (abfd, sec, offset);
default:
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index 5901aeaa090..d0e7085ceca 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -367,13 +367,6 @@ static const insn16 t2a1_bx_pc_insn = 0x4778;
static const insn16 t2a2_noop_insn = 0x46c0;
static const insn32 t2a3_b_insn = 0xea000000;
-static const insn16 t2a1_push_insn = 0xb540;
-static const insn16 t2a2_ldr_insn = 0x4e03;
-static const insn16 t2a3_mov_insn = 0x46fe;
-static const insn16 t2a4_bx_insn = 0x4730;
-static const insn32 t2a5_pop_insn = 0xe8bd4040;
-static const insn32 t2a6_bx_insn = 0xe12fff1e;
-
#ifndef ELFARM_NABI_C_INCLUDED
boolean
bfd_elf32_arm_allocate_interworking_sections (info)
@@ -3225,19 +3218,7 @@ elf32_arm_size_dynamic_sections (output_bfd, info)
if (strip)
{
- asection ** spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != NULL;
- spp = &(*spp)->next)
- {
- if (*spp == s->output_section)
- {
- bfd_section_list_remove (s->output_section->owner, spp);
- --s->output_section->owner->section_count;
- break;
- }
- }
+ _bfd_strip_section_from_output (info, s);
continue;
}
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 8eff52dd5ad..dfbdbe75f68 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -1022,7 +1022,8 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
BFD_ASSERT (off != (bfd_vma) -1);
if (!elf_hash_table (info)->dynamic_sections_created
- || (! info->shared && h->dynindx == -1)
+ || (! info->shared
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
|| (info->shared
&& (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index c1c77ec0b43..9cb900b8b20 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -2,21 +2,21 @@
Copyright 1993, 1995, 1998, 1999, 2001, 2002
Free Software Foundation, Inc.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public 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"
@@ -61,8 +61,7 @@ static bfd_reloc_status_type special
/* This does not include any relocation information, but should be
good enough for GDB or objdump to read the file. */
-static reloc_howto_type h8_elf_howto_table[] =
-{
+static reloc_howto_type h8_elf_howto_table[] = {
#define R_H8_NONE_X 0
HOWTO (R_H8_NONE, /* type */
0, /* rightshift */
@@ -221,16 +220,14 @@ static reloc_howto_type h8_elf_howto_table[] =
/* This structure is used to map BFD reloc codes to H8 ELF relocs. */
-struct elf_reloc_map
-{
+struct elf_reloc_map {
bfd_reloc_code_real_type bfd_reloc_val;
unsigned char howto_index;
};
/* An array mapping BFD reloc codes to SH ELF relocs. */
-static const struct elf_reloc_map h8_reloc_map[] =
-{
+static const struct elf_reloc_map h8_reloc_map[] = {
{ BFD_RELOC_NONE, R_H8_NONE_X },
{ BFD_RELOC_32, R_H8_DIR32_X },
{ BFD_RELOC_16, R_H8_DIR16_X },
@@ -271,7 +268,7 @@ elf32_h8_info_to_howto (abfd, bfd_reloc, elf_reloc)
r = ELF32_R_TYPE (elf_reloc->r_info);
for (i = 0; i < sizeof (h8_elf_howto_table) / sizeof (reloc_howto_type); i++)
- if (h8_elf_howto_table[i].type== r)
+ if (h8_elf_howto_table[i].type == r)
{
bfd_reloc->howto = &h8_elf_howto_table[i];
return;
@@ -830,14 +827,34 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
+ /* Get the instruction code being relaxed. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
/* If the previous instruction conditionally jumped around
this instruction, we may be able to reverse the condition
and redirect the previous instruction to the target of
this instruction.
Such sequences are used by the compiler to deal with
- long conditional branches. */
- if ((int) gap <= 130
+ long conditional branches.
+
+ Only perform this optimisation for jumps (code 0x5a) not
+ subroutine calls, as otherwise it could transform:
+
+ mov.w r0,r0
+ beq .L1
+ jsr @_bar
+ .L1: rts
+ _bar: rts
+ into:
+ mov.w r0,r0
+ bne _bar
+ rts
+ _bar: rts
+
+ which changes the call (jsr) into a branch (bne). */
+ if (code == 0x5a
+ && (int) gap <= 130
&& (int) gap >= -128
&& last_reloc
&& ELF32_R_TYPE (last_reloc->r_info) == R_H8_PCREL8
@@ -870,11 +887,10 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
= ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
ELF32_R_TYPE (R_H8_NONE));
- last_reloc->r_info
+ last_reloc->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
- ELF32_R_TYPE (R_H8_PCREL8));
- last_reloc->r_addend = irel->r_addend;
-
+ ELF32_R_TYPE (R_H8_PCREL8));
+ last_reloc->r_addend = irel->r_addend;
code = bfd_get_8 (abfd,
contents + last_reloc->r_offset - 1);
@@ -894,9 +910,6 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
}
}
- /* We could not eliminate this jump, so just shorten it. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
-
if (code == 0x5e)
bfd_put_8 (abfd, 0x55, contents + irel->r_offset - 1);
else if (code == 0x5a)
@@ -938,18 +951,18 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
/* If the distance is within -126..+130 inclusive, then we can
relax this jump. +130 is valid since the target will move
two bytes closer if we do relax this branch. */
- if ((int)gap >= -126 && (int)gap <= 130)
+ if ((int) gap >= -126 && (int) gap <= 130)
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
if (code == 0x58)
{
@@ -967,18 +980,18 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
abort ();
/* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_PCREL8);
- irel->r_offset--;
+ irel->r_offset--;
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
@@ -990,53 +1003,53 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
bfd_vma value = symval + irel->r_addend;
if ((bfd_get_mach (abfd) == bfd_mach_h8300
- && value >= 0xff00
- && value <= 0xffff)
- || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ && value >= 0xff00
+ && value <= 0xffff)
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
|| bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff))
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
- /* Sanity check. */
- if (code != 0x6a)
+ /* Sanity check. */
+ if (code != 0x6a)
abort ();
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- if ((code & 0xf0) == 0x00)
+ if ((code & 0xf0) == 0x00)
bfd_put_8 (abfd,
(code & 0xf) | 0x20,
- contents + irel->r_offset - 2);
- else if ((code & 0xf0) == 0x80)
+ contents + irel->r_offset - 2);
+ else if ((code & 0xf0) == 0x80)
bfd_put_8 (abfd,
(code & 0xf) | 0x30,
- contents + irel->r_offset - 2);
- else
+ contents + irel->r_offset - 2);
+ else
abort ();
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
@@ -1048,52 +1061,52 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
bfd_vma value = symval + irel->r_addend;
if ((bfd_get_mach (abfd) == bfd_mach_h8300
- && value >= 0xff00
- && value <= 0xffff)
- || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ && value >= 0xff00
+ && value <= 0xffff)
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
|| bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff))
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
- /* Sanity check. */
- if (code != 0x6a)
+ /* Sanity check. */
+ if (code != 0x6a)
abort ();
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- if ((code & 0xf0) == 0x00)
+ if ((code & 0xf0) == 0x00)
bfd_put_8 (abfd,
(code & 0xf) | 0x20,
- contents + irel->r_offset - 2);
- else if ((code & 0xf0) == 0x80)
+ contents + irel->r_offset - 2);
+ else if ((code & 0xf0) == 0x80)
bfd_put_8 (abfd,
(code & 0xf) | 0x30,
- contents + irel->r_offset - 2);
- else
+ contents + irel->r_offset - 2);
+ else
abort ();
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec, irel->r_offset, 2))
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec, irel->r_offset, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
}
@@ -1107,34 +1120,34 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
if (value <= 0x7fff || value >= 0xff8000)
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- /* We just need to turn off bit 0x20. */
- code &= ~0x20;
+ /* We just need to turn off bit 0x20. */
+ code &= ~0x20;
- bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR16A8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index e26ee798afb..ed601a76647 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3429,20 +3429,3 @@ elf_i386_post_process_headers (abfd, link_info)
#undef elf_backend_post_process_headers
#undef elf32_bed
-
-/* QNX support. */
-#include "elf32-qnx.h"
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_i386qnx_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elf32-i386-nto"
-
-#define elf32_bed elf32_i386_qnx_bed
-
-#include "elf32-target.h"
-
-#undef elf_backend_set_nonloadable_filepos
-#undef elf_backend_is_contained_by_filepos
-#undef elf_backend_copy_private_bfd_data_p
-#undef elf32_bed
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 56df535f038..243ff1445fc 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -3850,24 +3850,3 @@ ppc_elf_grok_psinfo (abfd, note)
#define elf_backend_reloc_type_class ppc_elf_reloc_type_class
#include "elf32-target.h"
-
-/* QNX support. */
-#include "elf32-qnx.h"
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_powerpcleqnx_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elf32-powerpcle-nto"
-#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_powerpcqnx_vec
-#undef TARGET_BIG_NAME
-#define TARGET_BIG_NAME "elf32-powerpc-nto"
-
-#define elf32_bed elf32_ppc_qnx_bed
-
-#include "elf32-target.h"
-
-#undef elf_backend_set_nonloadable_filepos
-#undef elf_backend_is_contained_by_filepos
-#undef elf_backend_copy_private_bfd_data_p
-#undef elf32_bed
diff --git a/bfd/elf32-qnx.c b/bfd/elf32-qnx.c
deleted file mode 100644
index b397c38f502..00000000000
--- a/bfd/elf32-qnx.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* QNX specific support for 32-bit ELF
- Copyright 2002 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 "elf-bfd.h"
-#include "elf32-qnx.h"
-
-/* Returns the end address of the segment + 1. */
-#define SEGMENT_END(segment, start) \
- (start + (segment->p_memsz > segment->p_filesz \
- ? segment->p_memsz : segment->p_filesz))
-
-boolean
-elf_qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec)
- bfd *ibfd ATTRIBUTE_UNUSED;
- asection *isec;
- bfd *obfd ATTRIBUTE_UNUSED;
- asection *osec ATTRIBUTE_UNUSED;
-{
- return isec->next == NULL;
-}
-
-boolean
-elf_qnx_is_contained_by_filepos (section, segment)
- asection *section;
- Elf_Internal_Phdr *segment;
-{
- return ((bfd_vma) section->filepos >= segment->p_offset
- && ((bfd_vma) section->filepos + section->_raw_size
- <= SEGMENT_END (segment, segment->p_offset)));
-}
-
-void
-elf_qnx_set_nonloadable_filepos (abfd, phdrs)
- bfd *abfd;
- Elf_Internal_Phdr *phdrs;
-{
- struct elf_segment_map *m;
- Elf_Internal_Phdr *p;
- file_ptr off = 0;
-
- for (m = elf_tdata (abfd)->segment_map, p = phdrs;
- m != NULL;
- m = m->next, p++)
- {
- unsigned int i;
- asection **secpp;
-
- for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
- {
- asection *sec;
-
- sec = *secpp;
-
- if (p->p_type == PT_LOAD)
- off = sec->filepos;
- else
- {
- if (i == 0)
- {
- if (sec->filepos)
- p->p_offset = sec->filepos;
- else
- p->p_offset = off;
- }
- if (!sec->filepos)
- {
- off += sec->_raw_size;
- p->p_filesz += sec->_raw_size;
- }
- }
- }
- }
- return;
-}
diff --git a/bfd/elf32-qnx.h b/bfd/elf32-qnx.h
deleted file mode 100644
index 0e79d7e483d..00000000000
--- a/bfd/elf32-qnx.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* QNX specific support for 32-bit ELF
- Copyright 2002 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. */
-
-boolean elf_qnx_copy_private_bfd_data_p
- PARAMS ((bfd *, asection *, bfd *, asection *));
-boolean elf_qnx_is_contained_by_filepos
- PARAMS ((asection *, Elf_Internal_Phdr *));
-void elf_qnx_set_nonloadable_filepos
- PARAMS ((bfd *, Elf_Internal_Phdr *));
-
-#undef elf_backend_set_nonloadable_filepos
-#define elf_backend_set_nonloadable_filepos elf_qnx_set_nonloadable_filepos
-#undef elf_backend_is_contained_by_filepos
-#define elf_backend_is_contained_by_filepos elf_qnx_is_contained_by_filepos
-#undef elf_backend_copy_private_bfd_data_p
-#define elf_backend_copy_private_bfd_data_p elf_qnx_copy_private_bfd_data_p
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 0f681a805cd..f52245bcc34 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -7449,29 +7449,6 @@ elf32_shlin_grok_psinfo (abfd, note)
#include "elf32-target.h"
-/* QNX support. */
-#include "elf32-qnx.h"
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_shlqnx_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elf32-shl-nto"
-#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_shqnx_vec
-#undef TARGET_BIG_NAME
-#define TARGET_BIG_NAME "elf32-sh-nto"
-#undef ELF_MAXPAGESIZE
-#define ELF_MAXPAGESIZE 0x1000
-
-#define elf32_bed elf32_sh_qnx_bed
-
-#include "elf32-target.h"
-
-#undef elf_backend_set_nonloadable_filepos
-#undef elf_backend_is_contained_by_filepos
-#undef elf_backend_copy_private_bfd_data_p
-#undef elf32_bed
-
/* NetBSD support. */
#undef TARGET_BIG_SYM
#define TARGET_BIG_SYM bfd_elf32_shnbsd_vec
diff --git a/bfd/elf32-sh64-com.c b/bfd/elf32-sh64-com.c
index ae2cab4e690..df0c463e263 100644
--- a/bfd/elf32-sh64-com.c
+++ b/bfd/elf32-sh64-com.c
@@ -127,7 +127,7 @@ sh64_address_in_cranges (cranges, addr, rangep)
else
{
cranges_contents
- = bfd_malloc (cranges->_cooked_size == 0
+ = bfd_malloc (cranges->_cooked_size != 0
? cranges->_cooked_size : cranges->_raw_size);
if (cranges_contents == NULL)
return false;
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 57ed958b32f..bf92ccf98f3 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -2388,7 +2388,7 @@ v850_elf_relax_delete_bytes (abfd, sec, addr, toaddr, count)
if (isym.st_value + isym.st_size >= toaddr)
isym.st_size += count;
- bfd_elf32_swap_symbol_out (abfd, & isym, shndx, esym);
+ bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
}
else if (isym.st_shndx == sec_shndx
&& isym.st_value < addr + count)
@@ -2401,7 +2401,7 @@ v850_elf_relax_delete_bytes (abfd, sec, addr, toaddr, count)
&& isym.st_value < addr + count)
isym.st_value = addr;
- bfd_elf32_swap_symbol_out (abfd, & isym, shndx, esym);
+ bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
}
}
@@ -2426,7 +2426,7 @@ v850_elf_relax_delete_bytes (abfd, sec, addr, toaddr, count)
if ((sym_hash)->root.u.def.value + isym.st_size >= toaddr)
{
isym.st_size += count;
- bfd_elf32_swap_symbol_out (abfd, & isym, shndx, esym);
+ bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
}
(sym_hash)->root.u.def.value -= count;
@@ -2445,7 +2445,7 @@ v850_elf_relax_delete_bytes (abfd, sec, addr, toaddr, count)
&& (sym_hash)->root.u.def.value < addr + count)
(sym_hash)->root.u.def.value = addr;
- bfd_elf32_swap_symbol_out (abfd, & isym, shndx, esym);
+ bfd_elf32_swap_symbol_out (abfd, & isym, esym, shndx);
}
if (shndx)
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index bf98c9136c8..f06d0658a7e 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -2073,7 +2073,7 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr)
rela.r_addend = 0;
}
- /* Each entry represents up to three actual relocations. */
+ /* Each entry represents exactly three actual relocations. */
used_sym = false;
used_ssym = false;
@@ -2096,27 +2096,6 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr)
break;
}
- if (type == R_MIPS_NONE)
- {
- /* There are no more relocations in this entry. If this
- is the first entry, we need to generate a dummy
- relocation so that the generic linker knows that
- there has been a break in the sequence of relocations
- applying to a particular address. */
- if (ir == 0)
- {
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- relent->address = rela.r_offset;
- else
- relent->address = rela.r_offset - asect->vma;
- relent->addend = 0;
- relent->howto = &howto_table[(int) R_MIPS_NONE];
- ++relent;
- }
- break;
- }
-
/* Some types require symbols, whereas some do not. */
switch (type)
{
@@ -2194,7 +2173,7 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr)
}
}
- asect->reloc_count += relent - relents;
+ asect->reloc_count += (relent - relents) / 3;
if (allocated != NULL)
free (allocated);
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 8b76f34e038..939d12f7b38 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -2170,8 +2170,11 @@ _bfd_mmix_finalize_linker_allocated_gregs (abfd, link_info)
n_gregs = gregdata->n_allocated_bpo_gregs;
+ /* We need to have a _raw_size contents even though there's only
+ _cooked_size worth of data, since the generic relocation machinery
+ will allocate and copy that much temporarily. */
bpo_gregs_section->contents
- = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->_cooked_size);
+ = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->_raw_size);
if (contents == NULL)
return false;
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index da7c53f6e3a..384348e957e 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -1658,6 +1658,7 @@ ppc64_elf_merge_private_bfd_data (ibfd, obfd)
{
/* Check if we have the same endianess. */
if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+ && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
&& obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
{
const char *msg;
@@ -1785,19 +1786,19 @@ struct ppc_dyn_relocs
ppc_stub_plt_branch:
Similar to the above, but a 24 bit branch in the stub section won't
reach its destination.
- . addis %r12,%r2,xxx@ha
- . ld %r11,xxx@l(%r12)
+ . addis %r12,%r2,xxx@toc@ha
+ . ld %r11,xxx@toc@l(%r12)
. mtctr %r11
. bctr
ppc_stub_plt_call:
Used to call a function in a shared library.
- . addis %r12,%r2,xxx@ha
+ . addis %r12,%r2,xxx@toc@ha
. std %r2,40(%r1)
- . ld %r11,xxx+0@l(%r12)
- . ld %r2,xxx+8@l(%r12)
+ . ld %r11,xxx+0@toc@l(%r12)
+ . ld %r2,xxx+8@toc@l(%r12)
. mtctr %r11
- . ld %r11,xxx+16@l(%r12)
+ . ld %r11,xxx+16@toc@l(%r12)
. bctr
*/
@@ -1971,8 +1972,6 @@ static boolean ppc64_elf_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
static void ppc64_elf_hide_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
-static boolean edit_opd
- PARAMS ((bfd *, struct bfd_link_info *));
static boolean allocate_dynrelocs
PARAMS ((struct elf_link_hash_entry *, PTR));
static boolean readonly_dynrelocs
@@ -3538,8 +3537,8 @@ ppc64_elf_hide_symbol (info, h, force_local)
}
}
-static boolean
-edit_opd (obfd, info)
+boolean
+ppc64_elf_edit_opd (obfd, info)
bfd *obfd;
struct bfd_link_info *info;
{
@@ -3556,6 +3555,7 @@ edit_opd (obfd, info)
Elf_Internal_Sym *local_syms;
struct elf_link_hash_entry **sym_hashes;
bfd_vma offset;
+ bfd_size_type amt;
long *adjust;
boolean need_edit;
@@ -3563,9 +3563,16 @@ edit_opd (obfd, info)
if (sec == NULL)
continue;
+ amt = sec->_raw_size * sizeof (long) / 24;
adjust = (long *) elf_section_data (sec)->tdata;
- BFD_ASSERT (adjust != NULL);
- memset (adjust, 0, (size_t) sec->_raw_size * sizeof (long) / 24);
+ if (adjust == NULL)
+ {
+ /* Must be a ld -r link. ie. check_relocs hasn't been
+ called. */
+ adjust = (long *) bfd_zalloc (obfd, amt);
+ elf_section_data (sec)->tdata = adjust;
+ }
+ memset (adjust, 0, (size_t) amt);
if (sec->output_section == bfd_abs_section_ptr)
continue;
@@ -3768,14 +3775,29 @@ edit_opd (obfd, info)
{
/* Arrange for the function descriptor sym
to be dropped. */
- struct elf_link_hash_entry *fdh;
+ struct ppc_link_hash_entry *fdh;
struct ppc_link_hash_entry *fh;
fh = (struct ppc_link_hash_entry *) h;
- BFD_ASSERT (fh->is_func);
- fdh = fh->oh;
- fdh->root.u.def.value = 0;
- fdh->root.u.def.section = sym_sec;
+ fdh = (struct ppc_link_hash_entry *) fh->oh;
+ if (fdh == NULL)
+ {
+ const char *fd_name;
+ struct ppc_link_hash_table *htab;
+
+ fd_name = h->root.root.string + 1;
+ htab = ppc_hash_table (info);
+ fdh = (struct ppc_link_hash_entry *)
+ elf_link_hash_lookup (&htab->elf, fd_name,
+ false, false, false);
+ fdh->is_func_descriptor = 1;
+ fdh->oh = &fh->elf;
+ fh->is_func = 1;
+ fh->oh = &fdh->elf;
+ }
+
+ fdh->elf.root.u.def.value = 0;
+ fdh->elf.root.u.def.section = sym_sec;
}
}
else
@@ -3788,13 +3810,28 @@ edit_opd (obfd, info)
to this location in the opd section.
We've checked above that opd relocs are
ordered. */
- struct elf_link_hash_entry *fdh;
+ struct ppc_link_hash_entry *fdh;
struct ppc_link_hash_entry *fh;
fh = (struct ppc_link_hash_entry *) h;
- BFD_ASSERT (fh->is_func);
- fdh = fh->oh;
- fdh->root.u.def.value = wptr - sec->contents;
+ fdh = (struct ppc_link_hash_entry *) fh->oh;
+ if (fdh == NULL)
+ {
+ const char *fd_name;
+ struct ppc_link_hash_table *htab;
+
+ fd_name = h->root.root.string + 1;
+ htab = ppc_hash_table (info);
+ fdh = (struct ppc_link_hash_entry *)
+ elf_link_hash_lookup (&htab->elf, fd_name,
+ false, false, false);
+ fdh->is_func_descriptor = 1;
+ fdh->oh = &fh->elf;
+ fh->is_func = 1;
+ fh->oh = &fdh->elf;
+ }
+
+ fdh->elf.root.u.def.value = wptr - sec->contents;
}
else
{
@@ -4144,9 +4181,6 @@ ppc64_elf_size_dynamic_sections (output_bfd, info)
}
}
- if (!edit_opd (output_bfd, info))
- return false;
-
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index cabc38816f0..21178d556d7 100644
--- a/bfd/elf64-ppc.h
+++ b/bfd/elf64-ppc.h
@@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
boolean ppc64_elf_mark_entry_syms
PARAMS ((struct bfd_link_info *));
+boolean ppc64_elf_edit_opd
+ PARAMS ((bfd *, struct bfd_link_info *));
bfd_vma ppc64_elf_toc
PARAMS ((bfd *));
int ppc64_elf_setup_section_lists
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index f79d76c30bd..ae4e57a2266 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1563,6 +1563,9 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
if (s->_raw_size == 0)
s->_raw_size = PLT_HEADER_SIZE;
+ /* To simplify matters later, just store the plt index here. */
+ h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
+
/* If this symbol is not defined in a regular file, and we are
not generating a shared library, then set the symbol to this
location in the .plt. This is required to make function
@@ -1572,12 +1575,9 @@ sparc64_elf_adjust_dynamic_symbol (info, h)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
{
h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
+ h->root.u.def.value = sparc64_elf_plt_entry_offset (h->plt.offset);
}
- /* To simplify matters later, just store the plt index here. */
- h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
-
/* Make room for this entry. */
s->_raw_size += PLT_ENTRY_SIZE;
@@ -2164,11 +2164,9 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
}
else
{
+ outrel.r_addend = relocation + rel->r_addend;
if (r_type == R_SPARC_64)
- {
- outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
- outrel.r_addend = relocation + rel->r_addend;
- }
+ outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
else
{
long indx;
@@ -2198,6 +2196,13 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
osec = sec->output_section;
indx = elf_section_data (osec)->dynindx;
+ /* We are turning this relocation into one
+ against a section symbol, so subtract out
+ the output section's address but not the
+ offset of the input section in the output
+ section. */
+ outrel.r_addend -= osec->vma;
+
/* FIXME: we really should be able to link non-pic
shared libraries. */
if (indx == 0)
@@ -2216,7 +2221,6 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
ELF64_R_TYPE_INFO (
ELF64_R_TYPE_DATA (rel->r_info),
r_type));
- outrel.r_addend = relocation + rel->r_addend;
}
}
@@ -2580,11 +2584,10 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* The Solaris native linker silently disregards
overflows. We don't, but this breaks stabs debugging
info, whose relocations are only 32-bits wide. Ignore
- overflows in this case. */
+ overflows for discarded entries. */
if (r_type == R_SPARC_32
- && (input_section->flags & SEC_DEBUGGING) != 0
- && strcmp (bfd_section_name (input_bfd, input_section),
- ".stab") == 0)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) == (bfd_vma) -1)
break;
if (h != NULL)
diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c
index bd34a14d258..dcf6808226d 100644
--- a/bfd/elfarm-nabi.c
+++ b/bfd/elfarm-nabi.c
@@ -750,26 +750,3 @@ elf32_arm_nabi_grok_psinfo (abfd, note)
#define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
#include "elf32-arm.h"
-
-/* QNX support. */
-#include "elf32-qnx.h"
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_littlearmqnx_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elf32-littlearm-nto"
-#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_bigarmqnx_vec
-#undef TARGET_BIG_NAME
-#define TARGET_BIG_NAME "elf32-bigarm-nto"
-#undef ELF_MAXPAGESIZE
-#define ELF_MAXPAGESIZE 0x1000
-
-#define elf32_bed elf32_arm_qnx_bed
-
-#include "elf32-target.h"
-
-#undef elf_backend_set_nonloadable_filepos
-#undef elf_backend_is_contained_by_filepos
-#undef elf_backend_copy_private_bfd_data_p
-#undef elf32_bed
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 4f54cd35ccc..f523972fab4 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -505,16 +505,6 @@ elf_file_p (x_ehdrp)
&& (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
}
-struct bfd_preserve
-{
- const struct bfd_arch_info *arch_info;
- struct elf_obj_tdata *tdata;
- struct bfd_hash_table section_htab;
- struct sec *sections;
- struct sec **section_tail;
- unsigned int section_count;
-};
-
/* Check to see if the file associated with ABFD matches the target vector
that ABFD points to.
@@ -536,11 +526,10 @@ elf_object_p (abfd)
char *shstrtab; /* Internal copy of section header stringtab */
struct elf_backend_data *ebd;
struct bfd_preserve preserve;
- struct elf_obj_tdata *new_tdata = NULL;
asection *s;
bfd_size_type amt;
- preserve.arch_info = abfd->arch_info;
+ preserve.marker = NULL;
/* Read in the ELF header in external format. */
@@ -584,24 +573,14 @@ elf_object_p (abfd)
the tdata pointer in the bfd. */
amt = sizeof (struct elf_obj_tdata);
- new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
- if (new_tdata == NULL)
+ preserve.marker = bfd_zalloc (abfd, amt);
+ if (preserve.marker == NULL)
goto got_no_match;
- preserve.tdata = elf_tdata (abfd);
- elf_tdata (abfd) = new_tdata;
-
- /* Clear section information, since there might be a recognized bfd that
- we now check if we can replace, and we don't want to append to it. */
- preserve.sections = abfd->sections;
- preserve.section_tail = abfd->section_tail;
- preserve.section_count = abfd->section_count;
- preserve.section_htab = abfd->section_htab;
- abfd->sections = NULL;
- abfd->section_tail = &abfd->sections;
- abfd->section_count = 0;
- if (!bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
+ if (!bfd_preserve_save (abfd, &preserve))
goto got_no_match;
+ elf_tdata (abfd) = preserve.marker;
+
/* Now that we know the byte order, swap in the rest of the header */
i_ehdrp = elf_elfheader (abfd);
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
@@ -633,8 +612,10 @@ elf_object_p (abfd)
/* Check that the ELF e_machine field matches what this particular
BFD format expects. */
if (ebd->elf_machine_code != i_ehdrp->e_machine
- && (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
- && (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
+ && (ebd->elf_machine_alt1 == 0
+ || i_ehdrp->e_machine != ebd->elf_machine_alt1)
+ && (ebd->elf_machine_alt2 == 0
+ || i_ehdrp->e_machine != ebd->elf_machine_alt2))
{
const bfd_target * const *target_ptr;
@@ -844,11 +825,8 @@ elf_object_p (abfd)
}
}
- /* It would be nice to be able to free more memory here, eg. old
- elf_elfsections, old tdata, but that's not possible since these
- blocks are sitting inside obj_alloc'd memory. */
- bfd_hash_table_free (&preserve.section_htab);
- return (abfd->xvec);
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
got_wrong_format_error:
/* There is way too much undoing of half-known state here. The caller,
@@ -863,18 +841,8 @@ elf_object_p (abfd)
bfd_set_error (bfd_error_wrong_format);
got_no_match:
- abfd->arch_info = preserve.arch_info;
- if (new_tdata != NULL)
- {
- /* bfd_release frees all memory more recently bfd_alloc'd than
- its arg, as well as its arg. */
- bfd_release (abfd, new_tdata);
- elf_tdata (abfd) = preserve.tdata;
- abfd->section_htab = preserve.section_htab;
- abfd->sections = preserve.sections;
- abfd->section_tail = preserve.section_tail;
- abfd->section_count = preserve.section_count;
- }
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
return NULL;
}
diff --git a/bfd/elfcore.h b/bfd/elfcore.h
index 7db5f72e333..264ff554fe2 100644
--- a/bfd/elfcore.h
+++ b/bfd/elfcore.h
@@ -85,18 +85,18 @@ elf_core_file_p (abfd)
unsigned int phindex;
struct elf_backend_data *ebd;
struct bfd_preserve preserve;
- struct elf_obj_tdata *new_tdata = NULL;
bfd_size_type amt;
- preserve.arch_info = abfd->arch_info;
+ preserve.marker = NULL;
/* Read in the ELF header in external format. */
if (bfd_bread ((PTR) &x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd)
!= sizeof (x_ehdr))
{
if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
+ goto wrong;
+ else
+ goto fail;
}
/* Check the magic number. */
@@ -126,24 +126,14 @@ elf_core_file_p (abfd)
/* Give abfd an elf_obj_tdata. */
amt = sizeof (struct elf_obj_tdata);
- new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
- if (new_tdata == NULL)
- return NULL;
- preserve.tdata = elf_tdata (abfd);
- elf_tdata (abfd) = new_tdata;
-
- /* Clear section information, since there might be a recognized bfd that
- we now check if we can replace, and we don't want to append to it. */
- preserve.sections = abfd->sections;
- preserve.section_tail = abfd->section_tail;
- preserve.section_count = abfd->section_count;
- preserve.section_htab = abfd->section_htab;
- abfd->sections = NULL;
- abfd->section_tail = &abfd->sections;
- abfd->section_count = 0;
- if (!bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
+ preserve.marker = bfd_zalloc (abfd, amt);
+ if (preserve.marker == NULL)
+ goto fail;
+ if (!bfd_preserve_save (abfd, &preserve))
goto fail;
+ elf_tdata (abfd) = preserve.marker;
+
/* Swap in the rest of the header, now that we have the byte order. */
i_ehdrp = elf_elfheader (abfd);
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
@@ -248,7 +238,7 @@ elf_core_file_p (abfd)
goto wrong;
}
- bfd_hash_table_free (&preserve.section_htab);
+ bfd_preserve_finish (abfd, &preserve);
return abfd->xvec;
wrong:
@@ -264,17 +254,7 @@ wrong:
bfd_set_error (bfd_error_wrong_format);
fail:
- abfd->arch_info = preserve.arch_info;
- if (new_tdata != NULL)
- {
- /* bfd_release frees all memory more recently bfd_alloc'd than
- its arg, as well as its arg. */
- bfd_release (abfd, new_tdata);
- elf_tdata (abfd) = preserve.tdata;
- abfd->section_htab = preserve.section_htab;
- abfd->sections = preserve.sections;
- abfd->section_tail = preserve.section_tail;
- abfd->section_count = preserve.section_count;
- }
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
return NULL;
}
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 03be87acddb..721b361ee31 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -2208,10 +2208,9 @@ elf_link_add_object_symbols (abfd, info)
}
}
- /* If this is a non-traditional, non-relocateable link, try to
- optimize the handling of the .stab/.stabstr sections. */
+ /* If this is a non-traditional link, try to optimize the handling
+ of the .stab/.stabstr sections. */
if (! dynamic
- && ! info->relocateable
&& ! info->traditional_format
&& info->hash->creator->flavour == bfd_target_elf_flavour
&& is_elf_hash_table (info)
@@ -2342,6 +2341,7 @@ elf_link_create_dynamic_sections (abfd, info)
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|| ! bfd_set_section_alignment (abfd, s, 2))
return false;
+ elf_hash_table (info)->eh_info.hdr_sec = s;
}
/* Create sections to hold version informations. These are removed
@@ -4494,6 +4494,8 @@ struct elf_final_link_info
size_t symbuf_count;
/* Number of symbols which fit in symbuf. */
size_t symbuf_size;
+ /* And same for symshndxbuf. */
+ size_t shndxbuf_size;
};
static boolean elf_link_output_sym
@@ -4919,6 +4921,7 @@ elf_bfd_final_link (abfd, info)
Elf_Internal_Sym elfsym;
unsigned int i;
Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Shdr *symtab_shndx_hdr;
Elf_Internal_Shdr *symstrtab_hdr;
struct elf_backend_data *bed = get_elf_backend_data (abfd);
struct elf_outext_info eoinfo;
@@ -4972,6 +4975,7 @@ elf_bfd_final_link (abfd, info)
finfo.symbuf = NULL;
finfo.symshndxbuf = NULL;
finfo.symbuf_count = 0;
+ finfo.shndxbuf_size = 0;
finfo.first_tls_sec = NULL;
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
if ((o->flags & SEC_THREAD_LOCAL) != 0
@@ -5192,9 +5196,7 @@ elf_bfd_final_link (abfd, info)
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
/* sh_name is set in prep_headers. */
symtab_hdr->sh_type = SHT_SYMTAB;
- symtab_hdr->sh_flags = 0;
- symtab_hdr->sh_addr = 0;
- symtab_hdr->sh_size = 0;
+ /* sh_flags, sh_addr and sh_size all start off zero. */
symtab_hdr->sh_entsize = sizeof (Elf_External_Sym);
/* sh_link is set in assign_section_numbers. */
/* sh_info is set below. */
@@ -5221,9 +5223,11 @@ elf_bfd_final_link (abfd, info)
goto error_return;
if (elf_numsections (abfd) > SHN_LORESERVE)
{
- amt = finfo.symbuf_size;
+ /* Wild guess at number of output symbols. realloc'd as needed. */
+ amt = 2 * max_sym_count + elf_numsections (abfd) + 1000;
+ finfo.shndxbuf_size = amt;
amt *= sizeof (Elf_External_Sym_Shndx);
- finfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
+ finfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
if (finfo.symshndxbuf == NULL)
goto error_return;
}
@@ -5283,7 +5287,7 @@ elf_bfd_final_link (abfd, info)
if (! elf_link_output_sym (&finfo, (const char *) NULL,
&elfsym, o))
goto error_return;
- if (i == SHN_LORESERVE)
+ if (i == SHN_LORESERVE - 1)
i += SHN_HIRESERVE + 1 - SHN_LORESERVE;
}
}
@@ -5558,6 +5562,24 @@ elf_bfd_final_link (abfd, info)
/* Now we know the size of the symtab section. */
off += symtab_hdr->sh_size;
+ symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
+ if (symtab_shndx_hdr->sh_name != 0)
+ {
+ symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
+ symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
+ amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_size = amt;
+
+ off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
+ off, true);
+
+ if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_bwrite ((PTR) finfo.symshndxbuf, amt, abfd) != amt))
+ return false;
+ }
+
+
/* Finish up and write out the symbol string table (.strtab)
section. */
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
@@ -5832,17 +5854,10 @@ elf_bfd_final_link (abfd, info)
goto error_return;
}
- if (info->eh_frame_hdr && elf_hash_table (info)->dynobj)
+ if (info->eh_frame_hdr)
{
- o = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
- ".eh_frame_hdr");
- if (o
- && (elf_section_data (o)->sec_info_type
- == ELF_INFO_TYPE_EH_FRAME_HDR))
- {
- if (! _bfd_elf_write_section_eh_frame_hdr (abfd, o))
- goto error_return;
- }
+ if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info))
+ goto error_return;
}
if (finfo.symstrtab != NULL)
@@ -5866,7 +5881,7 @@ elf_bfd_final_link (abfd, info)
if (finfo.symbuf != NULL)
free (finfo.symbuf);
if (finfo.symshndxbuf != NULL)
- free (finfo.symbuf);
+ free (finfo.symshndxbuf);
for (o = abfd->sections; o != NULL; o = o->next)
{
if ((o->flags & SEC_RELOC) != 0
@@ -5900,7 +5915,7 @@ elf_bfd_final_link (abfd, info)
if (finfo.symbuf != NULL)
free (finfo.symbuf);
if (finfo.symshndxbuf != NULL)
- free (finfo.symbuf);
+ free (finfo.symshndxbuf);
for (o = abfd->sections; o != NULL; o = o->next)
{
if ((o->flags & SEC_RELOC) != 0
@@ -5959,11 +5974,24 @@ elf_link_output_sym (finfo, name, elfsym, input_sec)
dest = finfo->symbuf + finfo->symbuf_count;
destshndx = finfo->symshndxbuf;
if (destshndx != NULL)
- destshndx += finfo->symbuf_count;
- elf_swap_symbol_out (finfo->output_bfd, elfsym, (PTR) dest, (PTR) destshndx);
- ++finfo->symbuf_count;
+ {
+ if (bfd_get_symcount (finfo->output_bfd) >= finfo->shndxbuf_size)
+ {
+ bfd_size_type amt;
- ++ bfd_get_symcount (finfo->output_bfd);
+ amt = finfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
+ finfo->symshndxbuf = destshndx = bfd_realloc (destshndx, amt * 2);
+ if (destshndx == NULL)
+ return false;
+ memset ((char *) destshndx + amt, 0, amt);
+ finfo->shndxbuf_size *= 2;
+ }
+ destshndx += bfd_get_symcount (finfo->output_bfd);
+ }
+
+ elf_swap_symbol_out (finfo->output_bfd, elfsym, (PTR) dest, (PTR) destshndx);
+ finfo->symbuf_count += 1;
+ bfd_get_symcount (finfo->output_bfd) += 1;
return true;
}
@@ -5988,20 +6016,6 @@ elf_link_flush_output_syms (finfo)
return false;
hdr->sh_size += amt;
-
- if (finfo->symshndxbuf != NULL)
- {
- hdr = &elf_tdata (finfo->output_bfd)->symtab_shndx_hdr;
- pos = hdr->sh_offset + hdr->sh_size;
- amt = finfo->symbuf_count * sizeof (Elf_External_Sym_Shndx);
- if (bfd_seek (finfo->output_bfd, pos, SEEK_SET) != 0
- || (bfd_bwrite ((PTR) finfo->symshndxbuf, amt, finfo->output_bfd)
- != amt))
- return false;
-
- hdr->sh_size += amt;
- }
-
finfo->symbuf_count = 0;
}
@@ -6818,12 +6832,7 @@ elf_link_input_bfd (finfo, input_bfd)
from discarded sections and section symbols from
removed link-once sections. Complain about relocs
against discarded sections. Zero relocs against removed
- link-once sections. We should really complain if
- anything in the final link tries to use it, but
- DWARF-based exception handling might have an entry in
- .eh_frame to describe a routine in the linkonce section,
- and it turns out to be hard to remove the .eh_frame
- entry too. FIXME. */
+ link-once sections. */
if (!finfo->info->relocateable
&& !elf_section_ignore_discarded_relocs (o))
{
@@ -6972,6 +6981,16 @@ elf_link_input_bfd (finfo, input_bfd)
next_erel = 0;
}
+ irela->r_offset = _bfd_elf_section_offset (output_bfd,
+ finfo->info, o,
+ irela->r_offset);
+ if (irela->r_offset >= (bfd_vma) -2)
+ {
+ /* This is a reloc for a deleted entry or somesuch. */
+ memset (irela, 0, sizeof (*irela));
+ continue;
+ }
+
irela->r_offset += o->output_offset;
/* Relocs in an executable have to be virtual addresses. */
@@ -7145,19 +7164,14 @@ elf_link_input_bfd (finfo, input_bfd)
return false;
break;
case ELF_INFO_TYPE_MERGE:
- if (! (_bfd_write_merged_section
- (output_bfd, o, elf_section_data (o)->sec_info)))
+ if (! _bfd_write_merged_section (output_bfd, o,
+ elf_section_data (o)->sec_info))
return false;
break;
case ELF_INFO_TYPE_EH_FRAME:
{
- asection *ehdrsec;
-
- ehdrsec
- = bfd_get_section_by_name (elf_hash_table (finfo->info)->dynobj,
- ".eh_frame_hdr");
- if (! (_bfd_elf_write_section_eh_frame (output_bfd, o, ehdrsec,
- contents)))
+ if (! _bfd_elf_write_section_eh_frame (output_bfd, finfo->info,
+ o, contents))
return false;
}
break;
@@ -8329,7 +8343,7 @@ elf_reloc_symbol_deleted_p (offset, cookie)
for (; rcookie->rel < rcookie->relend; rcookie->rel++)
{
- unsigned long r_symndx = ELF_R_SYM (rcookie->rel->r_info);
+ unsigned long r_symndx;
if (! rcookie->bad_symtab)
if (rcookie->rel->r_offset > offset)
@@ -8337,6 +8351,10 @@ elf_reloc_symbol_deleted_p (offset, cookie)
if (rcookie->rel->r_offset != offset)
continue;
+ r_symndx = ELF_R_SYM (rcookie->rel->r_info);
+ if (r_symndx == SHN_UNDEF)
+ return true;
+
if (r_symndx >= rcookie->locsymcount
|| ELF_ST_BIND (rcookie->locsyms[r_symndx].st_info) != STB_LOCAL)
{
@@ -8388,24 +8406,18 @@ elf_bfd_discard_info (output_bfd, info)
struct bfd_link_info *info;
{
struct elf_reloc_cookie cookie;
- asection *stab, *eh, *ehdr;
+ asection *stab, *eh;
Elf_Internal_Shdr *symtab_hdr;
struct elf_backend_data *bed;
bfd *abfd;
+ unsigned int count;
boolean ret = false;
- boolean strip = info->strip == strip_all || info->strip == strip_debugger;
- if (info->relocateable
- || info->traditional_format
+ if (info->traditional_format
|| info->hash->creator->flavour != bfd_target_elf_flavour
|| ! is_elf_hash_table (info))
return false;
- ehdr = NULL;
- if (elf_hash_table (info)->dynobj != NULL)
- ehdr = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
- ".eh_frame_hdr");
-
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
{
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
@@ -8416,27 +8428,22 @@ elf_bfd_discard_info (output_bfd, info)
if ((abfd->flags & DYNAMIC) != 0)
continue;
- eh = NULL;
- if (ehdr)
- {
- eh = bfd_get_section_by_name (abfd, ".eh_frame");
- if (eh && (eh->_raw_size == 0
- || bfd_is_abs_section (eh->output_section)))
- eh = NULL;
- }
+ eh = bfd_get_section_by_name (abfd, ".eh_frame");
+ if (eh != NULL
+ && (eh->_raw_size == 0
+ || bfd_is_abs_section (eh->output_section)))
+ eh = NULL;
- stab = NULL;
- if (!strip)
- {
- stab = bfd_get_section_by_name (abfd, ".stab");
- if (stab && (stab->_raw_size == 0
- || bfd_is_abs_section (stab->output_section)))
- stab = NULL;
- }
- if ((! stab
- || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS)
- && ! eh
- && (strip || ! bed->elf_backend_discard_info))
+ stab = bfd_get_section_by_name (abfd, ".stab");
+ if (stab != NULL
+ && (stab->_raw_size == 0
+ || bfd_is_abs_section (stab->output_section)
+ || elf_section_data (stab)->sec_info_type != ELF_INFO_TYPE_STABS))
+ stab = NULL;
+
+ if (stab == NULL
+ && eh == NULL
+ && bed->elf_backend_discard_info == NULL)
continue;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
@@ -8445,8 +8452,7 @@ elf_bfd_discard_info (output_bfd, info)
cookie.bad_symtab = elf_bad_symtab (abfd);
if (cookie.bad_symtab)
{
- cookie.locsymcount =
- symtab_hdr->sh_size / sizeof (Elf_External_Sym);
+ cookie.locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
cookie.extsymoff = 0;
}
else
@@ -8465,16 +8471,19 @@ elf_bfd_discard_info (output_bfd, info)
return false;
}
- if (stab)
+ if (stab != NULL)
{
- cookie.rels = (NAME(_bfd_elf,link_read_relocs)
- (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
- info->keep_memory));
- if (cookie.rels)
+ cookie.rels = NULL;
+ count = stab->reloc_count;
+ if (count != 0)
+ cookie.rels = (NAME(_bfd_elf,link_read_relocs)
+ (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ info->keep_memory));
+ if (cookie.rels != NULL)
{
cookie.rel = cookie.rels;
- cookie.relend =
- cookie.rels + stab->reloc_count * bed->s->int_rels_per_ext_rel;
+ cookie.relend = cookie.rels;
+ cookie.relend += count * bed->s->int_rels_per_ext_rel;
if (_bfd_discard_section_stabs (abfd, stab,
elf_section_data (stab)->sec_info,
elf_reloc_symbol_deleted_p,
@@ -8485,39 +8494,32 @@ elf_bfd_discard_info (output_bfd, info)
}
}
- if (eh)
+ if (eh != NULL)
{
cookie.rels = NULL;
- cookie.rel = NULL;
- cookie.relend = NULL;
- if (eh->reloc_count)
+ count = eh->reloc_count;
+ if (count != 0)
cookie.rels = (NAME(_bfd_elf,link_read_relocs)
(abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL,
info->keep_memory));
- if (cookie.rels)
- {
- cookie.rel = cookie.rels;
- cookie.relend =
- cookie.rels + eh->reloc_count * bed->s->int_rels_per_ext_rel;
- }
- if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr,
+ cookie.rel = cookie.rels;
+ cookie.relend = cookie.rels;
+ if (cookie.rels != NULL)
+ cookie.relend += count * bed->s->int_rels_per_ext_rel;
+
+ if (_bfd_elf_discard_section_eh_frame (abfd, info, eh,
elf_reloc_symbol_deleted_p,
&cookie))
- {
- /* Relocs have been edited. Ensure edited version is
- used later in relocate_section. */
- elf_section_data (eh)->relocs = cookie.rels;
- ret = true;
- }
- if (cookie.rels && elf_section_data (eh)->relocs != cookie.rels)
+ ret = true;
+
+ if (cookie.rels != NULL
+ && elf_section_data (eh)->relocs != cookie.rels)
free (cookie.rels);
}
- if (bed->elf_backend_discard_info)
- {
- if (bed->elf_backend_discard_info (abfd, &cookie, info))
- ret = true;
- }
+ if (bed->elf_backend_discard_info != NULL
+ && (*bed->elf_backend_discard_info) (abfd, &cookie, info))
+ ret = true;
if (cookie.locsyms != NULL
&& symtab_hdr->contents != (unsigned char *) cookie.locsyms)
@@ -8529,8 +8531,10 @@ elf_bfd_discard_info (output_bfd, info)
}
}
- if (ehdr && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr))
+ if (info->eh_frame_hdr
+ && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info))
ret = true;
+
return ret;
}
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index 5da8e43b7f8..ddd86fbfda5 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -3204,13 +3204,11 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
{
Elf_Internal_Rela outrel;
- offset += sec->output_section->vma + sec->output_offset;
-
BFD_ASSERT (dynindx != -1);
outrel.r_info = ELFNN_R_INFO (dynindx, type);
outrel.r_addend = addend;
outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
- if ((outrel.r_offset | 1) == (bfd_vma) -1)
+ if (outrel.r_offset >= (bfd_vma) -2)
{
/* Run for the hills. We shouldn't be outputting a relocation
for this. So do what everyone else does and output a no-op. */
@@ -3218,6 +3216,8 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
outrel.r_addend = 0;
outrel.r_offset = 0;
}
+ else
+ outrel.r_offset += sec->output_section->vma + sec->output_offset;
bfd_elfNN_swap_reloca_out (abfd, &outrel,
((ElfNN_External_Rela *) srel->contents
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 4f5b81c9757..f5b6a35ad02 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -385,15 +385,6 @@
#ifndef elf_backend_write_section
#define elf_backend_write_section NULL
#endif
-#ifndef elf_backend_set_nonloadable_filepos
-#define elf_backend_set_nonloadable_filepos NULL
-#endif
-#ifndef elf_backend_is_contained_by_filepos
-#define elf_backend_is_contained_by_filepos NULL
-#endif
-#ifndef elf_backend_copy_private_bfd_data_p
-#define elf_backend_copy_private_bfd_data_p NULL
-#endif
#ifndef elf_backend_mips_irix_compat
#define elf_backend_mips_irix_compat NULL
#endif
@@ -492,9 +483,6 @@ static const struct elf_backend_data elfNN_bed =
elf_backend_discard_info,
elf_backend_ignore_discarded_relocs,
elf_backend_write_section,
- elf_backend_set_nonloadable_filepos,
- elf_backend_is_contained_by_filepos,
- elf_backend_copy_private_bfd_data_p,
elf_backend_mips_irix_compat,
elf_backend_mips_rtype_to_howto,
elf_backend_ecoff_debug_swap,
diff --git a/bfd/format.c b/bfd/format.c
index ef6b46edfb8..33291d0f944 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -119,8 +119,9 @@ bfd_check_format_matches (abfd, format, matching)
char ***matching;
{
extern const bfd_target binary_vec;
- const bfd_target * const *target, *save_targ, *right_targ, *ar_right_targ;
- char **matching_vector = NULL;
+ const bfd_target * const *target;
+ const bfd_target **matching_vector = NULL;
+ const bfd_target *save_targ, *right_targ, *ar_right_targ;
int match_count;
int ar_match_index;
@@ -145,8 +146,8 @@ bfd_check_format_matches (abfd, format, matching)
bfd_size_type amt;
*matching = NULL;
- amt = sizeof (char *) * 2 * _bfd_target_vector_entries;
- matching_vector = (char **) bfd_malloc (amt);
+ amt = sizeof (*matching_vector) * 2 * _bfd_target_vector_entries;
+ matching_vector = (const bfd_target **) bfd_malloc (amt);
if (!matching_vector)
return false;
}
@@ -170,7 +171,7 @@ bfd_check_format_matches (abfd, format, matching)
abfd->xvec = right_targ; /* Set the target as returned. */
if (matching)
- free (matching_vector);
+ free ((PTR) matching_vector);
return true; /* File position has moved, BTW. */
}
@@ -193,7 +194,7 @@ bfd_check_format_matches (abfd, format, matching)
abfd->format = bfd_unknown;
if (matching)
- free (matching_vector);
+ free ((PTR) matching_vector);
bfd_set_error (bfd_error_file_not_recognized);
@@ -236,7 +237,7 @@ bfd_check_format_matches (abfd, format, matching)
}
if (matching)
- matching_vector[match_count] = temp->name;
+ matching_vector[match_count] = temp;
match_count++;
@@ -259,7 +260,7 @@ bfd_check_format_matches (abfd, format, matching)
if (ar_right_targ != bfd_default_vector[0])
ar_right_targ = *target;
if (matching)
- matching_vector[ar_match_index] = (*target)->name;
+ matching_vector[ar_match_index] = *target;
ar_match_index++;
}
else if (err != bfd_error_wrong_format)
@@ -268,7 +269,7 @@ bfd_check_format_matches (abfd, format, matching)
abfd->format = bfd_unknown;
if (matching)
- free (matching_vector);
+ free ((PTR) matching_vector);
return false;
}
@@ -289,7 +290,27 @@ bfd_check_format_matches (abfd, format, matching)
{
memcpy (matching_vector,
matching_vector + _bfd_target_vector_entries,
- sizeof (char *) * match_count);
+ sizeof (*matching_vector) * match_count);
+ }
+ }
+ }
+
+ if (match_count > 1 && bfd_associated_vector != NULL)
+ {
+ const bfd_target * const *assoc = bfd_associated_vector;
+
+ while ((right_targ = *assoc++) != NULL)
+ {
+ int i = match_count;
+
+ while (--i >= 0)
+ if (matching_vector[i] == right_targ)
+ break;
+
+ if (i >= 0)
+ {
+ match_count = 1;
+ break;
}
}
}
@@ -299,7 +320,7 @@ bfd_check_format_matches (abfd, format, matching)
abfd->xvec = right_targ; /* Change BFD's target permanently. */
if (matching)
- free (matching_vector);
+ free ((PTR) matching_vector);
return true; /* File position has moved, BTW. */
}
@@ -312,7 +333,7 @@ bfd_check_format_matches (abfd, format, matching)
bfd_set_error (bfd_error_file_not_recognized);
if (matching)
- free (matching_vector);
+ free ((PTR) matching_vector);
}
else
{
@@ -320,8 +341,15 @@ bfd_check_format_matches (abfd, format, matching)
if (matching)
{
- *matching = matching_vector;
+ *matching = (char **) matching_vector;
matching_vector[match_count] = NULL;
+ /* Return target names. This is a little nasty. Maybe we
+ should do another bfd_malloc? */
+ while (--match_count >= 0)
+ {
+ const char *name = matching_vector[match_count]->name;
+ *(const char **) &matching_vector[match_count] = name;
+ }
}
}
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 776dcd62f91..00d5bd3a6b9 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -567,6 +567,9 @@ extern bfd *bfd_last_cache;
extern const bfd_target * const *bfd_target_vector;
extern const bfd_target *bfd_default_vector[];
+/* List of associated target vectors. */
+extern const bfd_target * const *bfd_associated_vector;
+
/* Functions shared by the ECOFF and MIPS ELF backends, which have no
other common header files. */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index ef001f33530..6d40e91cbaf 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -572,6 +572,9 @@ extern bfd *bfd_last_cache;
extern const bfd_target * const *bfd_target_vector;
extern const bfd_target *bfd_default_vector[];
+/* List of associated target vectors. */
+extern const bfd_target * const *bfd_associated_vector;
+
/* Functions shared by the ECOFF and MIPS ELF backends, which have no
other common header files. */
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
new file mode 100644
index 00000000000..b271bfc87fe
--- /dev/null
+++ b/bfd/mach-o-target.c
@@ -0,0 +1,117 @@
+/* Mach-O support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef TARGET_NAME
+#error TARGET_NAME must be defined
+#endif /* TARGET_NAME */
+
+#ifndef TARGET_STRING
+#error TARGET_STRING must be defined
+#endif /* TARGET_STRING */
+
+#ifndef TARGET_BIG_ENDIAN
+#error TARGET_BIG_ENDIAN must be defined
+#endif /* TARGET_BIG_ENDIAN */
+
+#ifndef TARGET_ARCHIVE
+#error TARGET_ARCHIVE must be defined
+#endif /* TARGET_ARCHIVE */
+
+#if ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN))
+#error Mach-O fat files must always be big-endian.
+#endif /* ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN)) */
+
+const bfd_target TARGET_NAME =
+{
+ TARGET_STRING, /* Name. */
+ bfd_target_mach_o_flavour,
+#if TARGET_BIG_ENDIAN
+ BFD_ENDIAN_BIG, /* Target byte order. */
+ BFD_ENDIAN_BIG, /* Target headers byte order. */
+#else
+ BFD_ENDIAN_LITTLE, /* Target byte order. */
+ BFD_ENDIAN_LITTLE, /* Target headers byte order. */
+#endif
+ (HAS_RELOC | EXEC_P | /* Object flags. */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
+ '_', /* symbol_leading_char. */
+ ' ', /* ar_pad_char. */
+ 16, /* ar_max_namelen. */
+
+#if TARGET_BIG_ENDIAN
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
+#else
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+#endif /* TARGET_BIG_ENDIAN */
+
+ { /* bfd_check_format. */
+#if TARGET_ARCHIVE
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ bfd_mach_o_archive_p,
+ _bfd_dummy_target,
+#else
+ _bfd_dummy_target,
+ bfd_mach_o_object_p,
+ _bfd_dummy_target,
+ bfd_mach_o_core_p
+#endif
+ },
+ { /* bfd_set_format. */
+ bfd_false,
+ bfd_mach_o_mkobject,
+ bfd_false,
+ bfd_mach_o_mkobject,
+ },
+ { /* bfd_write_contents. */
+ bfd_false,
+ bfd_mach_o_write_contents,
+ bfd_false,
+ bfd_mach_o_write_contents,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_mach_o),
+ BFD_JUMP_TABLE_COPY (bfd_mach_o),
+ BFD_JUMP_TABLE_CORE (bfd_mach_o),
+ BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
+ BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
+ BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
+ BFD_JUMP_TABLE_WRITE (bfd_mach_o),
+ BFD_JUMP_TABLE_LINK (bfd_mach_o),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL,
+
+ NULL
+};
+
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
new file mode 100644
index 00000000000..1daaf985ff7
--- /dev/null
+++ b/bfd/mach-o.c
@@ -0,0 +1,2194 @@
+/* Mach-O support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ 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 "mach-o.h"
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+#include <ctype.h>
+
+#ifndef BFD_IO_FUNCS
+#define BFD_IO_FUNCS 0
+#endif
+
+#define bfd_mach_o_mkarchive _bfd_noarchive_mkarchive
+#define bfd_mach_o_read_ar_hdr _bfd_noarchive_read_ar_hdr
+#define bfd_mach_o_slurp_armap _bfd_noarchive_slurp_armap
+#define bfd_mach_o_slurp_extended_name_table _bfd_noarchive_slurp_extended_name_table
+#define bfd_mach_o_construct_extended_name_table _bfd_noarchive_construct_extended_name_table
+#define bfd_mach_o_truncate_arname _bfd_noarchive_truncate_arname
+#define bfd_mach_o_write_armap _bfd_noarchive_write_armap
+#define bfd_mach_o_get_elt_at_index _bfd_noarchive_get_elt_at_index
+#define bfd_mach_o_generic_stat_arch_elt _bfd_noarchive_generic_stat_arch_elt
+#define bfd_mach_o_update_armap_timestamp _bfd_noarchive_update_armap_timestamp
+#define bfd_mach_o_close_and_cleanup _bfd_generic_close_and_cleanup
+#define bfd_mach_o_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define bfd_mach_o_new_section_hook _bfd_generic_new_section_hook
+#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define bfd_mach_o_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
+#define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define bfd_mach_o_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define bfd_mach_o_read_minisymbols _bfd_generic_read_minisymbols
+#define bfd_mach_o_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#define bfd_mach_o_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
+#define bfd_mach_o_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define bfd_mach_o_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+#define bfd_mach_o_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
+#define bfd_mach_o_bfd_relax_section bfd_generic_relax_section
+#define bfd_mach_o_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define bfd_mach_o_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#define bfd_mach_o_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define bfd_mach_o_bfd_link_just_syms _bfd_generic_link_just_syms
+#define bfd_mach_o_bfd_final_link _bfd_generic_final_link
+#define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section
+#define bfd_mach_o_set_arch_mach bfd_default_set_arch_mach
+#define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#define bfd_mach_o_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+#define bfd_mach_o_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
+#define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents
+#define bfd_mach_o_set_section_contents _bfd_generic_set_section_contents
+#define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections
+#define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
+#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
+
+static boolean bfd_mach_o_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
+static boolean bfd_mach_o_bfd_copy_private_section_data PARAMS ((bfd *, asection *, bfd *, asection *));
+static boolean bfd_mach_o_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+static long bfd_mach_o_count_symbols PARAMS ((bfd *));
+static long bfd_mach_o_get_symtab_upper_bound PARAMS ((bfd *));
+static long bfd_mach_o_get_symtab PARAMS ((bfd *, asymbol **));
+static void bfd_mach_o_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static void bfd_mach_o_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+static void bfd_mach_o_convert_architecture PARAMS ((bfd_mach_o_cpu_type, bfd_mach_o_cpu_subtype, enum bfd_architecture *, unsigned long *));
+static boolean bfd_mach_o_write_contents PARAMS ((bfd *));
+static int bfd_mach_o_sizeof_headers PARAMS ((bfd *, boolean));
+static asymbol * bfd_mach_o_make_empty_symbol PARAMS ((bfd *));
+static int bfd_mach_o_write_header PARAMS ((bfd *, bfd_mach_o_header *));
+static int bfd_mach_o_read_header PARAMS ((bfd *, bfd_mach_o_header *));
+static asection * bfd_mach_o_make_bfd_section PARAMS ((bfd *, bfd_mach_o_section *));
+static int bfd_mach_o_scan_read_section PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
+static int bfd_mach_o_scan_write_section PARAMS ((bfd *, bfd_mach_o_section *, bfd_vma));
+static int bfd_mach_o_scan_write_symtab_symbols PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_thread PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dylinker PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dylib PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_prebound_dylib PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_thread PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_symtab PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_dysymtab PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_symtab PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_segment PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_write_segment PARAMS ((bfd *, bfd_mach_o_load_command *));
+static int bfd_mach_o_scan_read_command PARAMS ((bfd *, bfd_mach_o_load_command *));
+static void bfd_mach_o_flatten_sections PARAMS ((bfd *));
+static const char * bfd_mach_o_i386_flavour_string PARAMS ((unsigned int));
+static const char * bfd_mach_o_ppc_flavour_string PARAMS ((unsigned int));
+
+/* The flags field of a section structure is separated into two parts a section
+ type and section attributes. The section types are mutually exclusive (it
+ can only have one type) but the section attributes are not (it may have more
+ than one attribute). */
+
+#define SECTION_TYPE 0x000000ff /* 256 section types. */
+#define SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes. */
+
+/* Constants for the section attributes part of the flags field of a section
+ structure. */
+
+#define SECTION_ATTRIBUTES_USR 0xff000000 /* User-settable attributes. */
+#define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* Section contains only true machine instructions. */
+#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* System setable attributes. */
+#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* Section contains some machine instructions. */
+#define S_ATTR_EXT_RELOC 0x00000200 /* Section has external relocation entries. */
+#define S_ATTR_LOC_RELOC 0x00000100 /* Section has local relocation entries. */
+
+#define N_STAB 0xe0
+#define N_TYPE 0x1e
+#define N_EXT 0x01
+#define N_UNDF 0x0
+#define N_ABS 0x2
+#define N_SECT 0xe
+#define N_INDR 0xa
+
+boolean
+bfd_mach_o_valid (abfd)
+ bfd *abfd;
+{
+ if (abfd == NULL || abfd->xvec == NULL)
+ return 0;
+
+ if (! ((abfd->xvec == &mach_o_be_vec)
+ || (abfd->xvec == &mach_o_le_vec)
+ || (abfd->xvec == &mach_o_fat_vec)))
+ return 0;
+
+ if (abfd->tdata.mach_o_data == NULL)
+ return 0;
+ return 1;
+}
+
+/* Copy any private info we understand from the input symbol
+ to the output symbol. */
+
+static boolean
+bfd_mach_o_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol)
+ bfd *ibfd ATTRIBUTE_UNUSED;
+ asymbol *isymbol ATTRIBUTE_UNUSED;
+ bfd *obfd ATTRIBUTE_UNUSED;
+ asymbol *osymbol ATTRIBUTE_UNUSED;
+{
+ return true;
+}
+
+/* Copy any private info we understand from the input section
+ to the output section. */
+
+static boolean
+bfd_mach_o_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
+ bfd *ibfd ATTRIBUTE_UNUSED;
+ asection *isection ATTRIBUTE_UNUSED;
+ bfd *obfd ATTRIBUTE_UNUSED;
+ asection *osection ATTRIBUTE_UNUSED;
+{
+ return true;
+}
+
+/* Copy any private info we understand from the input bfd
+ to the output bfd. */
+
+static boolean
+bfd_mach_o_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+{
+ BFD_ASSERT (bfd_mach_o_valid (ibfd));
+ BFD_ASSERT (bfd_mach_o_valid (obfd));
+
+ obfd->tdata.mach_o_data = ibfd->tdata.mach_o_data;
+ obfd->tdata.mach_o_data->ibfd = ibfd;
+ return true;
+}
+
+static long
+bfd_mach_o_count_symbols (abfd)
+ bfd *abfd;
+{
+ bfd_mach_o_data_struct *mdata = NULL;
+ long nsyms = 0;
+ unsigned long i;
+
+ BFD_ASSERT (bfd_mach_o_valid (abfd));
+ mdata = abfd->tdata.mach_o_data;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ if (mdata->commands[i].type == BFD_MACH_O_LC_SYMTAB)
+ {
+ bfd_mach_o_symtab_command *sym = &mdata->commands[i].command.symtab;
+ nsyms += sym->nsyms;
+ }
+
+ return nsyms;
+}
+
+static long
+bfd_mach_o_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ long nsyms = bfd_mach_o_count_symbols (abfd);
+
+ if (nsyms < 0)
+ return nsyms;
+
+ return ((nsyms + 1) * sizeof (asymbol *));
+}
+
+static long
+bfd_mach_o_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ long nsyms = bfd_mach_o_count_symbols (abfd);
+ asymbol **csym = alocation;
+ unsigned long i, j;
+
+ if (nsyms < 0)
+ return nsyms;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ if (mdata->commands[i].type == BFD_MACH_O_LC_SYMTAB)
+ {
+ bfd_mach_o_symtab_command *sym = &mdata->commands[i].command.symtab;
+
+ if (bfd_mach_o_scan_read_symtab_symbols (abfd, &mdata->commands[i].command.symtab) != 0)
+ {
+ fprintf (stderr, "bfd_mach_o_get_symtab: unable to load symbols for section %lu\n", i);
+ return 0;
+ }
+
+ BFD_ASSERT (sym->symbols != NULL);
+
+ for (j = 0; j < sym->nsyms; j++)
+ {
+ BFD_ASSERT (csym < (alocation + nsyms));
+ *csym++ = &sym->symbols[j];
+ }
+ }
+ }
+
+ *csym++ = NULL;
+
+ return nsyms;
+}
+
+static void
+bfd_mach_o_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+static void
+bfd_mach_o_print_symbol (abfd, afile, symbol, how)
+ bfd *abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ default:
+ bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
+ fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
+ }
+}
+
+static void
+bfd_mach_o_convert_architecture (mtype, msubtype, type, subtype)
+ bfd_mach_o_cpu_type mtype;
+ bfd_mach_o_cpu_subtype msubtype ATTRIBUTE_UNUSED;
+ enum bfd_architecture *type;
+ unsigned long *subtype;
+{
+ *subtype = bfd_arch_unknown;
+
+ switch (mtype)
+ {
+ case BFD_MACH_O_CPU_TYPE_VAX: *type = bfd_arch_vax; break;
+ case BFD_MACH_O_CPU_TYPE_MC680x0: *type = bfd_arch_m68k; break;
+ case BFD_MACH_O_CPU_TYPE_I386: *type = bfd_arch_i386; break;
+ case BFD_MACH_O_CPU_TYPE_MIPS: *type = bfd_arch_mips; break;
+ case BFD_MACH_O_CPU_TYPE_MC98000: *type = bfd_arch_m98k; break;
+ case BFD_MACH_O_CPU_TYPE_HPPA: *type = bfd_arch_hppa; break;
+ case BFD_MACH_O_CPU_TYPE_ARM: *type = bfd_arch_arm; break;
+ case BFD_MACH_O_CPU_TYPE_MC88000: *type = bfd_arch_m88k; break;
+ case BFD_MACH_O_CPU_TYPE_SPARC: *type = bfd_arch_sparc; break;
+ case BFD_MACH_O_CPU_TYPE_I860: *type = bfd_arch_i860; break;
+ case BFD_MACH_O_CPU_TYPE_ALPHA: *type = bfd_arch_alpha; break;
+ case BFD_MACH_O_CPU_TYPE_POWERPC: *type = bfd_arch_powerpc; break;
+ default: *type = bfd_arch_unknown; break;
+ }
+
+ switch (*type)
+ {
+ case bfd_arch_i386: *subtype = bfd_mach_i386_i386; break;
+ case bfd_arch_sparc: *subtype = bfd_mach_sparc; break;
+ default:
+ *subtype = bfd_arch_unknown;
+ }
+}
+
+static boolean
+bfd_mach_o_write_contents (abfd)
+ bfd *abfd;
+{
+ unsigned int i;
+ asection *s;
+
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+
+ /* Write data sections first in case they overlap header data to be
+ written later. */
+
+ for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+ ;
+
+#if 0
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ bfd_mach_o_load_command *cur = &mdata->commands[i];
+ if (cur->type != BFD_MACH_O_LC_SEGMENT)
+ break;
+
+ {
+ bfd_mach_o_segment_command *seg = &cur->command.segment;
+ char buf[1024];
+ bfd_vma nbytes = seg->filesize;
+ bfd_vma curoff = seg->fileoff;
+
+ while (nbytes > 0)
+ {
+ bfd_vma thisread = nbytes;
+
+ if (thisread > 1024)
+ thisread = 1024;
+
+ bfd_seek (abfd, curoff, SEEK_SET);
+ if (bfd_bread ((PTR) buf, thisread, abfd) != thisread)
+ return false;
+
+ bfd_seek (abfd, curoff, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, thisread, abfd) != thisread)
+ return false;
+
+ nbytes -= thisread;
+ curoff += thisread;
+ }
+ }
+ }
+#endif
+
+ /* Now write header information. */
+ if (bfd_mach_o_write_header (abfd, &mdata->header) != 0)
+ return false;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ unsigned char buf[8];
+ bfd_mach_o_load_command *cur = &mdata->commands[i];
+ unsigned long typeflag;
+
+ typeflag = cur->type_required ? cur->type & BFD_MACH_O_LC_REQ_DYLD : cur->type;
+
+ bfd_h_put_32 (abfd, typeflag, buf);
+ bfd_h_put_32 (abfd, cur->len, buf + 4);
+
+ bfd_seek (abfd, cur->offset, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 8, abfd) != 8)
+ return false;
+
+ switch (cur->type)
+ {
+ case BFD_MACH_O_LC_SEGMENT:
+ if (bfd_mach_o_scan_write_segment (abfd, cur) != 0)
+ return false;
+ break;
+ case BFD_MACH_O_LC_SYMTAB:
+ if (bfd_mach_o_scan_write_symtab (abfd, cur) != 0)
+ return false;
+ break;
+ case BFD_MACH_O_LC_SYMSEG:
+ break;
+ case BFD_MACH_O_LC_THREAD:
+ case BFD_MACH_O_LC_UNIXTHREAD:
+ if (bfd_mach_o_scan_write_thread (abfd, cur) != 0)
+ return false;
+ break;
+ case BFD_MACH_O_LC_LOADFVMLIB:
+ case BFD_MACH_O_LC_IDFVMLIB:
+ case BFD_MACH_O_LC_IDENT:
+ case BFD_MACH_O_LC_FVMFILE:
+ case BFD_MACH_O_LC_PREPAGE:
+ case BFD_MACH_O_LC_DYSYMTAB:
+ case BFD_MACH_O_LC_LOAD_DYLIB:
+ case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
+ case BFD_MACH_O_LC_ID_DYLIB:
+ case BFD_MACH_O_LC_LOAD_DYLINKER:
+ case BFD_MACH_O_LC_ID_DYLINKER:
+ case BFD_MACH_O_LC_PREBOUND_DYLIB:
+ case BFD_MACH_O_LC_ROUTINES:
+ case BFD_MACH_O_LC_SUB_FRAMEWORK:
+ break;
+ default:
+ fprintf (stderr,
+ "unable to write unknown load command 0x%lx\n",
+ (long) cur->type);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static int
+bfd_mach_o_sizeof_headers (a, b)
+ bfd *a ATTRIBUTE_UNUSED;
+ boolean b ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+/* Make an empty symbol. This is required only because
+ bfd_make_section_anyway wants to create a symbol for the section. */
+
+static asymbol *
+bfd_mach_o_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ if (new == NULL)
+ return new;
+ new->the_bfd = abfd;
+ return new;
+}
+
+static int
+bfd_mach_o_write_header (abfd, header)
+ bfd *abfd;
+ bfd_mach_o_header *header;
+{
+ unsigned char buf[28];
+
+ bfd_h_put_32 (abfd, header->magic, buf + 0);
+ bfd_h_put_32 (abfd, header->cputype, buf + 4);
+ bfd_h_put_32 (abfd, header->cpusubtype, buf + 8);
+ bfd_h_put_32 (abfd, header->filetype, buf + 12);
+ bfd_h_put_32 (abfd, header->ncmds, buf + 16);
+ bfd_h_put_32 (abfd, header->sizeofcmds, buf + 20);
+ bfd_h_put_32 (abfd, header->flags, buf + 24);
+
+ bfd_seek (abfd, 0, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 28, abfd) != 28)
+ return -1;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_read_header (abfd, header)
+ bfd *abfd;
+ bfd_mach_o_header *header;
+{
+ unsigned char buf[28];
+ bfd_vma (*get32) PARAMS ((const bfd_byte *)) = NULL;
+
+ bfd_seek (abfd, 0, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 28, abfd) != 28)
+ return -1;
+
+ if (bfd_getb32 (buf) == 0xfeedface)
+ {
+ header->byteorder = BFD_ENDIAN_BIG;
+ header->magic = 0xfeedface;
+ get32 = bfd_getb32;
+ }
+ else if (bfd_getl32 (buf) == 0xfeedface)
+ {
+ header->byteorder = BFD_ENDIAN_LITTLE;
+ header->magic = 0xfeedface;
+ get32 = bfd_getl32;
+ }
+ else
+ {
+ header->byteorder = BFD_ENDIAN_UNKNOWN;
+ return -1;
+ }
+
+ header->cputype = (*get32) (buf + 4);
+ header->cpusubtype = (*get32) (buf + 8);
+ header->filetype = (*get32) (buf + 12);
+ header->ncmds = (*get32) (buf + 16);
+ header->sizeofcmds = (*get32) (buf + 20);
+ header->flags = (*get32) (buf + 24);
+
+ return 0;
+}
+
+static asection *
+bfd_mach_o_make_bfd_section (abfd, section)
+ bfd *abfd;
+ bfd_mach_o_section *section;
+{
+ asection *bfdsec;
+ char *sname;
+ const char *prefix = "LC_SEGMENT";
+ unsigned int snamelen;
+
+ snamelen = strlen (prefix) + 1
+ + strlen (section->segname) + 1
+ + strlen (section->sectname) + 1;
+
+ sname = (char *) bfd_alloc (abfd, snamelen);
+ if (sname == NULL)
+ return NULL;
+ sprintf (sname, "%s.%s.%s", prefix, section->segname, section->sectname);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return NULL;
+
+ bfdsec->vma = section->addr;
+ bfdsec->lma = section->addr;
+ bfdsec->_raw_size = section->size;
+ bfdsec->filepos = section->offset;
+ bfdsec->alignment_power = section->align;
+
+ if (section->flags & BFD_MACH_O_S_ZEROFILL)
+ bfdsec->flags = SEC_ALLOC;
+ else
+ bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+
+ return bfdsec;
+}
+
+static int
+bfd_mach_o_scan_read_section (abfd, section, offset)
+ bfd *abfd;
+ bfd_mach_o_section *section;
+ bfd_vma offset;
+{
+ unsigned char buf[68];
+
+ bfd_seek (abfd, offset, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 68, abfd) != 68)
+ return -1;
+
+ memcpy (section->sectname, buf, 16);
+ section->sectname[16] = '\0';
+ memcpy (section->segname, buf + 16, 16);
+ section->segname[16] = '\0';
+ section->addr = bfd_h_get_32 (abfd, buf + 32);
+ section->size = bfd_h_get_32 (abfd, buf + 36);
+ section->offset = bfd_h_get_32 (abfd, buf + 40);
+ section->align = bfd_h_get_32 (abfd, buf + 44);
+ section->reloff = bfd_h_get_32 (abfd, buf + 48);
+ section->nreloc = bfd_h_get_32 (abfd, buf + 52);
+ section->flags = bfd_h_get_32 (abfd, buf + 56);
+ section->reserved1 = bfd_h_get_32 (abfd, buf + 60);
+ section->reserved2 = bfd_h_get_32 (abfd, buf + 64);
+ section->bfdsection = bfd_mach_o_make_bfd_section (abfd, section);
+
+ if (section->bfdsection == NULL)
+ return -1;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_write_section (abfd, section, offset)
+ bfd *abfd;
+ bfd_mach_o_section *section;
+ bfd_vma offset;
+{
+ unsigned char buf[68];
+
+ memcpy (buf, section->sectname, 16);
+ memcpy (buf + 16, section->segname, 16);
+ bfd_h_put_32 (abfd, section->addr, buf + 32);
+ bfd_h_put_32 (abfd, section->size, buf + 36);
+ bfd_h_put_32 (abfd, section->offset, buf + 40);
+ bfd_h_put_32 (abfd, section->align, buf + 44);
+ bfd_h_put_32 (abfd, section->reloff, buf + 48);
+ bfd_h_put_32 (abfd, section->nreloc, buf + 52);
+ bfd_h_put_32 (abfd, section->flags, buf + 56);
+ /* bfd_h_put_32 (abfd, section->reserved1, buf + 60); */
+ /* bfd_h_put_32 (abfd, section->reserved2, buf + 64); */
+
+ bfd_seek (abfd, offset, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 68, abfd) != 68)
+ return -1;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_write_symtab_symbols (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_symtab_command *sym = &command->command.symtab;
+ asymbol *s = NULL;
+ unsigned long i;
+
+ for (i = 0; i < sym->nsyms; i++)
+ {
+ unsigned char buf[12];
+ bfd_vma symoff = sym->symoff + (i * 12);
+ unsigned char ntype = 0;
+ unsigned char nsect = 0;
+ short ndesc = 0;
+
+ s = &sym->symbols[i];
+
+ /* Don't set this from the symbol information; use stored values. */
+#if 0
+ if (s->flags & BSF_GLOBAL)
+ ntype |= N_EXT;
+ if (s->flags & BSF_DEBUGGING)
+ ntype |= N_STAB;
+
+ if (s->section == bfd_und_section_ptr)
+ ntype |= N_UNDF;
+ else if (s->section == bfd_abs_section_ptr)
+ ntype |= N_ABS;
+ else
+ ntype |= N_SECT;
+#endif
+
+ /* Instead just set from the stored values. */
+ ntype = (s->udata.i >> 24) & 0xff;
+ nsect = (s->udata.i >> 16) & 0xff;
+ ndesc = s->udata.i & 0xffff;
+
+ bfd_h_put_32 (abfd, s->name - sym->strtab, buf);
+ bfd_h_put_8 (abfd, ntype, buf + 4);
+ bfd_h_put_8 (abfd, nsect, buf + 5);
+ bfd_h_put_16 (abfd, ndesc, buf + 6);
+ bfd_h_put_32 (abfd, s->section->vma + s->value, buf + 8);
+
+ bfd_seek (abfd, symoff, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 12, abfd) != 12)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_write_symtab_symbols: unable to write %d bytes at %lu\n",
+ 12, (unsigned long) symoff);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int
+bfd_mach_o_scan_read_symtab_symbol (abfd, sym, s, i)
+ bfd *abfd;
+ bfd_mach_o_symtab_command *sym;
+ asymbol *s;
+ unsigned long i;
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ bfd_vma symoff = sym->symoff + (i * 12);
+ unsigned char buf[12];
+ unsigned char type = -1;
+ unsigned char section = -1;
+ short desc = -1;
+ unsigned long value = -1;
+ unsigned long stroff = -1;
+ unsigned int symtype = -1;
+
+ BFD_ASSERT (sym->strtab != NULL);
+
+ bfd_seek (abfd, symoff, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 12, abfd) != 12)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: unable to read %d bytes at %lu\n",
+ 12, (unsigned long) symoff);
+ return -1;
+ }
+
+ stroff = bfd_h_get_32 (abfd, buf);
+ type = bfd_h_get_8 (abfd, buf + 4);
+ symtype = (type & 0x0e);
+ section = bfd_h_get_8 (abfd, buf + 5) - 1;
+ desc = bfd_h_get_16 (abfd, buf + 6);
+ value = bfd_h_get_32 (abfd, buf + 8);
+
+ if (stroff >= sym->strsize)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: symbol name out of range (%lu >= %lu)\n",
+ (unsigned long) stroff, (unsigned long) sym->strsize);
+ return -1;
+ }
+
+ s->the_bfd = abfd;
+ s->name = sym->strtab + stroff;
+ s->value = value;
+ s->udata.i = (type << 24) | (section << 16) | desc;
+ s->flags = 0x0;
+
+ if (type & BFD_MACH_O_N_STAB)
+ {
+ s->flags |= BSF_DEBUGGING;
+ s->section = bfd_und_section_ptr;
+ }
+ else
+ {
+ if (type & BFD_MACH_O_N_PEXT)
+ {
+ type &= ~BFD_MACH_O_N_PEXT;
+ s->flags |= BSF_GLOBAL;
+ }
+
+ if (type & BFD_MACH_O_N_EXT)
+ {
+ type &= ~BFD_MACH_O_N_EXT;
+ s->flags |= BSF_GLOBAL;
+ }
+
+ switch (symtype)
+ {
+ case BFD_MACH_O_N_UNDF:
+ s->section = bfd_und_section_ptr;
+ break;
+ case BFD_MACH_O_N_PBUD:
+ s->section = bfd_und_section_ptr;
+ break;
+ case BFD_MACH_O_N_ABS:
+ s->section = bfd_abs_section_ptr;
+ break;
+ case BFD_MACH_O_N_SECT:
+ if ((section > 0) && (section <= mdata->nsects))
+ {
+ s->section = mdata->sections[section - 1]->bfdsection;
+ s->value = s->value - mdata->sections[section - 1]->addr;
+ }
+ else
+ {
+ /* Mach-O uses 0 to mean "no section"; not an error. */
+ if (section != 0)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
+ "symbol \"%s\" specified invalid section %d (max %lu): setting to undefined\n",
+ s->name, section, mdata->nsects);
+ }
+ s->section = bfd_und_section_ptr;
+ }
+ break;
+ case BFD_MACH_O_N_INDR:
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
+ "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined\n",
+ s->name);
+ s->section = bfd_und_section_ptr;
+ break;
+ default:
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
+ "symbol \"%s\" specified invalid type field 0x%x: setting to undefined\n",
+ s->name, symtype);
+ s->section = bfd_und_section_ptr;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int
+bfd_mach_o_scan_read_symtab_strtab (abfd, sym)
+ bfd *abfd;
+ bfd_mach_o_symtab_command *sym;
+{
+ BFD_ASSERT (sym->strtab == NULL);
+
+ if (abfd->flags & BFD_IN_MEMORY)
+ {
+ struct bfd_in_memory *b;
+
+ b = (struct bfd_in_memory *) abfd->iostream;
+
+ if ((sym->stroff + sym->strsize) > b->size)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return -1;
+ }
+ sym->strtab = b->buffer + sym->stroff;
+ return 0;
+ }
+
+ sym->strtab = bfd_alloc (abfd, sym->strsize);
+ if (sym->strtab == NULL)
+ return -1;
+
+ bfd_seek (abfd, sym->stroff, SEEK_SET);
+ if (bfd_bread ((PTR) sym->strtab, sym->strsize, abfd) != sym->strsize)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_strtab: unable to read %lu bytes at %lu\n",
+ sym->strsize, sym->stroff);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+bfd_mach_o_scan_read_symtab_symbols (abfd, sym)
+ bfd *abfd;
+ bfd_mach_o_symtab_command *sym;
+{
+ unsigned long i;
+ int ret;
+
+ BFD_ASSERT (sym->symbols == NULL);
+ sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (asymbol));
+
+ if (sym->symbols == NULL)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbols: unable to allocate memory for symbols\n");
+ return -1;
+ }
+
+ ret = bfd_mach_o_scan_read_symtab_strtab (abfd, sym);
+ if (ret != 0)
+ return ret;
+
+ for (i = 0; i < sym->nsyms; i++)
+ {
+ ret = bfd_mach_o_scan_read_symtab_symbol (abfd, sym, &sym->symbols[i], i);
+ if (ret != 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+int
+bfd_mach_o_scan_read_dysymtab_symbol (abfd, dysym, sym, s, i)
+ bfd *abfd;
+ bfd_mach_o_dysymtab_command *dysym;
+ bfd_mach_o_symtab_command *sym;
+ asymbol *s;
+ unsigned long i;
+{
+ unsigned long isymoff = dysym->indirectsymoff + (i * 4);
+ unsigned long symindex;
+ unsigned char buf[4];
+
+ BFD_ASSERT (i < dysym->nindirectsyms);
+
+ bfd_seek (abfd, isymoff, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 4, abfd) != 4)
+ {
+ fprintf (stderr, "bfd_mach_o_scan_read_dysymtab_symbol: unable to read %lu bytes at %lu\n",
+ (unsigned long) 4, isymoff);
+ return -1;
+ }
+ symindex = bfd_h_get_32 (abfd, buf);
+
+ return bfd_mach_o_scan_read_symtab_symbol (abfd, sym, s, symindex);
+}
+
+static const char *
+bfd_mach_o_i386_flavour_string (flavour)
+ unsigned int flavour;
+{
+ switch ((int) flavour)
+ {
+ case BFD_MACH_O_i386_NEW_THREAD_STATE: return "i386_NEW_THREAD_STATE";
+ case BFD_MACH_O_i386_FLOAT_STATE: return "i386_FLOAT_STATE";
+ case BFD_MACH_O_i386_ISA_PORT_MAP_STATE: return "i386_ISA_PORT_MAP_STATE";
+ case BFD_MACH_O_i386_V86_ASSIST_STATE: return "i386_V86_ASSIST_STATE";
+ case BFD_MACH_O_i386_REGS_SEGS_STATE: return "i386_REGS_SEGS_STATE";
+ case BFD_MACH_O_i386_THREAD_SYSCALL_STATE: return "i386_THREAD_SYSCALL_STATE";
+ case BFD_MACH_O_i386_THREAD_STATE_NONE: return "i386_THREAD_STATE_NONE";
+ case BFD_MACH_O_i386_SAVED_STATE: return "i386_SAVED_STATE";
+ case BFD_MACH_O_i386_THREAD_STATE: return "i386_THREAD_STATE";
+ case BFD_MACH_O_i386_THREAD_FPSTATE: return "i386_THREAD_FPSTATE";
+ case BFD_MACH_O_i386_THREAD_EXCEPTSTATE: return "i386_THREAD_EXCEPTSTATE";
+ case BFD_MACH_O_i386_THREAD_CTHREADSTATE: return "i386_THREAD_CTHREADSTATE";
+ default: return "UNKNOWN";
+ }
+}
+
+static const char *
+bfd_mach_o_ppc_flavour_string (flavour)
+ unsigned int flavour;
+{
+ switch ((int) flavour)
+ {
+ case BFD_MACH_O_PPC_THREAD_STATE: return "PPC_THREAD_STATE";
+ case BFD_MACH_O_PPC_FLOAT_STATE: return "PPC_FLOAT_STATE";
+ case BFD_MACH_O_PPC_EXCEPTION_STATE: return "PPC_EXCEPTION_STATE";
+ case BFD_MACH_O_PPC_VECTOR_STATE: return "PPC_VECTOR_STATE";
+ default: return "UNKNOWN";
+ }
+}
+
+static int
+bfd_mach_o_scan_write_thread (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_thread_command *cmd = &command->command.thread;
+ unsigned int i;
+ unsigned char buf[8];
+ bfd_vma offset;
+ unsigned int nflavours;
+
+ BFD_ASSERT ((command->type == BFD_MACH_O_LC_THREAD)
+ || (command->type == BFD_MACH_O_LC_UNIXTHREAD));
+
+ offset = 8;
+ nflavours = 0;
+ for (i = 0; i < cmd->nflavours; i++)
+ {
+ BFD_ASSERT ((cmd->flavours[i].size % 4) == 0);
+ BFD_ASSERT (cmd->flavours[i].offset == (command->offset + offset + 8));
+
+ bfd_h_put_32 (abfd, cmd->flavours[i].flavour, buf);
+ bfd_h_put_32 (abfd, (cmd->flavours[i].size / 4), buf + 4);
+
+ bfd_seek (abfd, command->offset + offset, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 8, abfd) != 8)
+ return -1;
+
+ offset += cmd->flavours[i].size + 8;
+ }
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_dylinker (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_dylinker_command *cmd = &command->command.dylinker;
+ unsigned char buf[4];
+ unsigned int nameoff;
+ asection *bfdsec;
+ char *sname;
+ const char *prefix;
+
+ BFD_ASSERT ((command->type == BFD_MACH_O_LC_ID_DYLINKER)
+ || (command->type == BFD_MACH_O_LC_LOAD_DYLINKER));
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 4, abfd) != 4)
+ return -1;
+
+ nameoff = bfd_h_get_32 (abfd, buf + 0);
+
+ cmd->name_offset = command->offset + nameoff;
+ cmd->name_len = command->len - nameoff;
+
+ if (command->type == BFD_MACH_O_LC_LOAD_DYLINKER)
+ prefix = "LC_LOAD_DYLINKER";
+ else if (command->type == BFD_MACH_O_LC_ID_DYLINKER)
+ prefix = "LC_ID_DYLINKER";
+ else
+ abort ();
+
+ sname = (char *) bfd_alloc (abfd, strlen (prefix) + 1);
+ if (sname == NULL)
+ return -1;
+ strcpy (sname, prefix);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = command->len - 8;
+ bfdsec->filepos = command->offset + 8;
+ bfdsec->alignment_power = 0;
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ cmd->section = bfdsec;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_dylib (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_dylib_command *cmd = &command->command.dylib;
+ unsigned char buf[16];
+ unsigned int nameoff;
+ asection *bfdsec;
+ char *sname;
+ const char *prefix;
+
+ BFD_ASSERT ((command->type == BFD_MACH_O_LC_ID_DYLIB)
+ || (command->type == BFD_MACH_O_LC_LOAD_DYLIB)
+ || (command->type == BFD_MACH_O_LC_LOAD_WEAK_DYLIB));
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 16, abfd) != 16)
+ return -1;
+
+ nameoff = bfd_h_get_32 (abfd, buf + 0);
+ cmd->timestamp = bfd_h_get_32 (abfd, buf + 4);
+ cmd->current_version = bfd_h_get_32 (abfd, buf + 8);
+ cmd->compatibility_version = bfd_h_get_32 (abfd, buf + 12);
+
+ cmd->name_offset = command->offset + nameoff;
+ cmd->name_len = command->len - nameoff;
+
+ if (command->type == BFD_MACH_O_LC_LOAD_DYLIB)
+ prefix = "LC_LOAD_DYLIB";
+ else if (command->type == BFD_MACH_O_LC_LOAD_WEAK_DYLIB)
+ prefix = "LC_LOAD_WEAK_DYLIB";
+ else if (command->type == BFD_MACH_O_LC_ID_DYLIB)
+ prefix = "LC_ID_DYLIB";
+ else
+ abort ();
+
+ sname = (char *) bfd_alloc (abfd, strlen (prefix) + 1);
+ if (sname == NULL)
+ return -1;
+ strcpy (sname, prefix);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = command->len - 8;
+ bfdsec->filepos = command->offset + 8;
+ bfdsec->alignment_power = 0;
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ cmd->section = bfdsec;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_prebound_dylib (abfd, command)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_mach_o_load_command *command ATTRIBUTE_UNUSED;
+{
+ /* bfd_mach_o_prebound_dylib_command *cmd = &command->command.prebound_dylib; */
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_PREBOUND_DYLIB);
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_thread (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_data_struct *mdata = NULL;
+ bfd_mach_o_thread_command *cmd = &command->command.thread;
+ unsigned char buf[8];
+ bfd_vma offset;
+ unsigned int nflavours;
+ unsigned int i;
+
+ BFD_ASSERT ((command->type == BFD_MACH_O_LC_THREAD)
+ || (command->type == BFD_MACH_O_LC_UNIXTHREAD));
+
+ BFD_ASSERT (bfd_mach_o_valid (abfd));
+ mdata = abfd->tdata.mach_o_data;
+
+ offset = 8;
+ nflavours = 0;
+ while (offset != command->len)
+ {
+ if (offset >= command->len)
+ return -1;
+
+ bfd_seek (abfd, command->offset + offset, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 8, abfd) != 8)
+ return -1;
+
+ offset += 8 + bfd_h_get_32 (abfd, buf + 4) * 4;
+ nflavours++;
+ }
+
+ cmd->flavours =
+ ((bfd_mach_o_thread_flavour *)
+ bfd_alloc (abfd, nflavours * sizeof (bfd_mach_o_thread_flavour)));
+ if (cmd->flavours == NULL)
+ return -1;
+ cmd->nflavours = nflavours;
+
+ offset = 8;
+ nflavours = 0;
+ while (offset != command->len)
+ {
+ if (offset >= command->len)
+ return -1;
+
+ if (nflavours >= cmd->nflavours)
+ return -1;
+
+ bfd_seek (abfd, command->offset + offset, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 8, abfd) != 8)
+ return -1;
+
+ cmd->flavours[nflavours].flavour = bfd_h_get_32 (abfd, buf);
+ cmd->flavours[nflavours].offset = command->offset + offset + 8;
+ cmd->flavours[nflavours].size = bfd_h_get_32 (abfd, buf + 4) * 4;
+ offset += cmd->flavours[nflavours].size + 8;
+ nflavours++;
+ }
+
+ for (i = 0; i < nflavours; i++)
+ {
+ asection *bfdsec;
+ unsigned int snamelen;
+ char *sname;
+ const char *flavourstr;
+ const char *prefix = "LC_THREAD";
+ unsigned int j = 0;
+
+ switch (mdata->header.cputype)
+ {
+ case BFD_MACH_O_CPU_TYPE_POWERPC:
+ flavourstr = bfd_mach_o_ppc_flavour_string (cmd->flavours[i].flavour);
+ break;
+ case BFD_MACH_O_CPU_TYPE_I386:
+ flavourstr = bfd_mach_o_i386_flavour_string (cmd->flavours[i].flavour);
+ break;
+ default:
+ flavourstr = "UNKNOWN_ARCHITECTURE";
+ break;
+ }
+
+ snamelen = strlen (prefix) + 1 + 20 + 1 + strlen (flavourstr) + 1;
+ sname = (char *) bfd_alloc (abfd, snamelen);
+ if (sname == NULL)
+ return -1;
+
+ for (;;)
+ {
+ sprintf (sname, "%s.%s.%u", prefix, flavourstr, j);
+ if (bfd_get_section_by_name (abfd, sname) == NULL)
+ break;
+ j++;
+ }
+
+ bfdsec = bfd_make_section (abfd, sname);
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = cmd->flavours[i].size;
+ bfdsec->filepos = cmd->flavours[i].offset;
+ bfdsec->alignment_power = 0x0;
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ cmd->section = bfdsec;
+ }
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_write_symtab (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_symtab_command *seg = &command->command.symtab;
+ unsigned char buf[16];
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_SYMTAB);
+
+ bfd_h_put_32 (abfd, seg->symoff, buf);
+ bfd_h_put_32 (abfd, seg->nsyms, buf + 4);
+ bfd_h_put_32 (abfd, seg->stroff, buf + 8);
+ bfd_h_put_32 (abfd, seg->strsize, buf + 12);
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 16, abfd) != 16)
+ return -1;
+
+ if (bfd_mach_o_scan_write_symtab_symbols (abfd, command) != 0)
+ return -1;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_dysymtab (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_dysymtab_command *seg = &command->command.dysymtab;
+ unsigned char buf[72];
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_DYSYMTAB);
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 72, abfd) != 72)
+ return -1;
+
+ seg->ilocalsym = bfd_h_get_32 (abfd, buf + 0);
+ seg->nlocalsym = bfd_h_get_32 (abfd, buf + 4);
+ seg->iextdefsym = bfd_h_get_32 (abfd, buf + 8);
+ seg->nextdefsym = bfd_h_get_32 (abfd, buf + 12);
+ seg->iundefsym = bfd_h_get_32 (abfd, buf + 16);
+ seg->nundefsym = bfd_h_get_32 (abfd, buf + 20);
+ seg->tocoff = bfd_h_get_32 (abfd, buf + 24);
+ seg->ntoc = bfd_h_get_32 (abfd, buf + 28);
+ seg->modtaboff = bfd_h_get_32 (abfd, buf + 32);
+ seg->nmodtab = bfd_h_get_32 (abfd, buf + 36);
+ seg->extrefsymoff = bfd_h_get_32 (abfd, buf + 40);
+ seg->nextrefsyms = bfd_h_get_32 (abfd, buf + 44);
+ seg->indirectsymoff = bfd_h_get_32 (abfd, buf + 48);
+ seg->nindirectsyms = bfd_h_get_32 (abfd, buf + 52);
+ seg->extreloff = bfd_h_get_32 (abfd, buf + 56);
+ seg->nextrel = bfd_h_get_32 (abfd, buf + 60);
+ seg->locreloff = bfd_h_get_32 (abfd, buf + 64);
+ seg->nlocrel = bfd_h_get_32 (abfd, buf + 68);
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_symtab (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ bfd_mach_o_symtab_command *seg = &command->command.symtab;
+ unsigned char buf[16];
+ asection *bfdsec;
+ char *sname;
+ const char *prefix = "LC_SYMTAB.stabs";
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_SYMTAB);
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 16, abfd) != 16)
+ return -1;
+
+ seg->symoff = bfd_h_get_32 (abfd, buf);
+ seg->nsyms = bfd_h_get_32 (abfd, buf + 4);
+ seg->stroff = bfd_h_get_32 (abfd, buf + 8);
+ seg->strsize = bfd_h_get_32 (abfd, buf + 12);
+ seg->symbols = NULL;
+ seg->strtab = NULL;
+
+ sname = (char *) bfd_alloc (abfd, strlen (prefix) + 1);
+ if (sname == NULL)
+ return -1;
+ strcpy (sname, prefix);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = seg->nsyms * 12;
+ bfdsec->filepos = seg->symoff;
+ bfdsec->alignment_power = 0;
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ seg->stabs_segment = bfdsec;
+
+ prefix = "LC_SYMTAB.stabstr";
+ sname = (char *) bfd_alloc (abfd, strlen (prefix) + 1);
+ if (sname == NULL)
+ return -1;
+ strcpy (sname, prefix);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = seg->strsize;
+ bfdsec->filepos = seg->stroff;
+ bfdsec->alignment_power = 0;
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ seg->stabstr_segment = bfdsec;
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_segment (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ unsigned char buf[48];
+ bfd_mach_o_segment_command *seg = &command->command.segment;
+ unsigned long i;
+ asection *bfdsec;
+ char *sname;
+ const char *prefix = "LC_SEGMENT";
+ unsigned int snamelen;
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_SEGMENT);
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 48, abfd) != 48)
+ return -1;
+
+ memcpy (seg->segname, buf, 16);
+ seg->vmaddr = bfd_h_get_32 (abfd, buf + 16);
+ seg->vmsize = bfd_h_get_32 (abfd, buf + 20);
+ seg->fileoff = bfd_h_get_32 (abfd, buf + 24);
+ seg->filesize = bfd_h_get_32 (abfd, buf + 28);
+ /* seg->maxprot = bfd_h_get_32 (abfd, buf + 32); */
+ /* seg->initprot = bfd_h_get_32 (abfd, buf + 36); */
+ seg->nsects = bfd_h_get_32 (abfd, buf + 40);
+ seg->flags = bfd_h_get_32 (abfd, buf + 44);
+
+ snamelen = strlen (prefix) + 1 + strlen (seg->segname) + 1;
+ sname = (char *) bfd_alloc (abfd, snamelen);
+ if (sname == NULL)
+ return -1;
+ sprintf (sname, "%s.%s", prefix, seg->segname);
+
+ bfdsec = bfd_make_section_anyway (abfd, sname);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = seg->vmaddr;
+ bfdsec->lma = seg->vmaddr;
+ bfdsec->_raw_size = seg->filesize;
+ bfdsec->filepos = seg->fileoff;
+ bfdsec->alignment_power = 0x0;
+ bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+
+ seg->segment = bfdsec;
+
+ if (seg->nsects != 0)
+ {
+ seg->sections =
+ ((bfd_mach_o_section *)
+ bfd_alloc (abfd, seg->nsects * sizeof (bfd_mach_o_section)));
+ if (seg->sections == NULL)
+ return -1;
+
+ for (i = 0; i < seg->nsects; i++)
+ {
+ bfd_vma segoff = command->offset + 48 + 8 + (i * 68);
+
+ if (bfd_mach_o_scan_read_section (abfd, &seg->sections[i],
+ segoff) != 0)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_write_segment (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ unsigned char buf[48];
+ bfd_mach_o_segment_command *seg = &command->command.segment;
+ unsigned long i;
+
+ BFD_ASSERT (command->type == BFD_MACH_O_LC_SEGMENT);
+
+ memcpy (buf, seg->segname, 16);
+ bfd_h_put_32 (abfd, seg->vmaddr, buf + 16);
+ bfd_h_put_32 (abfd, seg->vmsize, buf + 20);
+ bfd_h_put_32 (abfd, seg->fileoff, buf + 24);
+ bfd_h_put_32 (abfd, seg->filesize, buf + 28);
+ bfd_h_put_32 (abfd, 0 /* seg->maxprot */, buf + 32);
+ bfd_h_put_32 (abfd, 0 /* seg->initprot */, buf + 36);
+ bfd_h_put_32 (abfd, seg->nsects, buf + 40);
+ bfd_h_put_32 (abfd, seg->flags, buf + 44);
+
+ bfd_seek (abfd, command->offset + 8, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, 48, abfd) != 48)
+ return -1;
+
+ {
+ char buf[1024];
+ bfd_vma nbytes = seg->filesize;
+ bfd_vma curoff = seg->fileoff;
+
+ while (nbytes > 0)
+ {
+ bfd_vma thisread = nbytes;
+
+ if (thisread > 1024)
+ thisread = 1024;
+
+ bfd_seek (abfd, curoff, SEEK_SET);
+ if (bfd_bread ((PTR) buf, thisread, abfd) != thisread)
+ return -1;
+
+ bfd_seek (abfd, curoff, SEEK_SET);
+ if (bfd_bwrite ((PTR) buf, thisread, abfd) != thisread)
+ return -1;
+
+ nbytes -= thisread;
+ curoff += thisread;
+ }
+ }
+
+ for (i = 0; i < seg->nsects; i++)
+ {
+ bfd_vma segoff = command->offset + 48 + 8 + (i * 68);
+
+ if (bfd_mach_o_scan_write_section (abfd, &seg->sections[i], segoff) != 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+bfd_mach_o_scan_read_command (abfd, command)
+ bfd *abfd;
+ bfd_mach_o_load_command *command;
+{
+ unsigned char buf[8];
+
+ bfd_seek (abfd, command->offset, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 8, abfd) != 8)
+ return -1;
+
+ command->type = (bfd_h_get_32 (abfd, buf) & ~BFD_MACH_O_LC_REQ_DYLD);
+ command->type_required = (bfd_h_get_32 (abfd, buf) & BFD_MACH_O_LC_REQ_DYLD
+ ? 1 : 0);
+ command->len = bfd_h_get_32 (abfd, buf + 4);
+
+ switch (command->type)
+ {
+ case BFD_MACH_O_LC_SEGMENT:
+ if (bfd_mach_o_scan_read_segment (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_SYMTAB:
+ if (bfd_mach_o_scan_read_symtab (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_SYMSEG:
+ break;
+ case BFD_MACH_O_LC_THREAD:
+ case BFD_MACH_O_LC_UNIXTHREAD:
+ if (bfd_mach_o_scan_read_thread (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_LOAD_DYLINKER:
+ case BFD_MACH_O_LC_ID_DYLINKER:
+ if (bfd_mach_o_scan_read_dylinker (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_LOAD_DYLIB:
+ case BFD_MACH_O_LC_ID_DYLIB:
+ case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
+ if (bfd_mach_o_scan_read_dylib (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_PREBOUND_DYLIB:
+ if (bfd_mach_o_scan_read_prebound_dylib (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_LOADFVMLIB:
+ case BFD_MACH_O_LC_IDFVMLIB:
+ case BFD_MACH_O_LC_IDENT:
+ case BFD_MACH_O_LC_FVMFILE:
+ case BFD_MACH_O_LC_PREPAGE:
+ case BFD_MACH_O_LC_ROUTINES:
+ case BFD_MACH_O_LC_SUB_FRAMEWORK:
+ break;
+ case BFD_MACH_O_LC_DYSYMTAB:
+ if (bfd_mach_o_scan_read_dysymtab (abfd, command) != 0)
+ return -1;
+ break;
+ case BFD_MACH_O_LC_SUB_UMBRELLA:
+ case BFD_MACH_O_LC_SUB_CLIENT:
+ case BFD_MACH_O_LC_SUB_LIBRARY:
+ case BFD_MACH_O_LC_TWOLEVEL_HINTS:
+ case BFD_MACH_O_LC_PREBIND_CKSUM:
+ break;
+ default:
+ fprintf (stderr, "unable to read unknown load command 0x%lx\n",
+ (unsigned long) command->type);
+ break;
+ }
+
+ return 0;
+}
+
+static void
+bfd_mach_o_flatten_sections (abfd)
+ bfd *abfd;
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ long csect = 0;
+ unsigned long i, j;
+
+ mdata->nsects = 0;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
+ {
+ bfd_mach_o_segment_command *seg;
+
+ seg = &mdata->commands[i].command.segment;
+ mdata->nsects += seg->nsects;
+ }
+ }
+
+ mdata->sections = bfd_alloc (abfd,
+ mdata->nsects * sizeof (bfd_mach_o_section *));
+ csect = 0;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
+ {
+ bfd_mach_o_segment_command *seg;
+
+ seg = &mdata->commands[i].command.segment;
+ BFD_ASSERT (csect + seg->nsects <= mdata->nsects);
+
+ for (j = 0; j < seg->nsects; j++)
+ mdata->sections[csect++] = &seg->sections[j];
+ }
+ }
+}
+
+int
+bfd_mach_o_scan_start_address (abfd)
+ bfd *abfd;
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ bfd_mach_o_thread_command *cmd = NULL;
+ unsigned long i;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ if ((mdata->commands[i].type == BFD_MACH_O_LC_THREAD) ||
+ (mdata->commands[i].type == BFD_MACH_O_LC_UNIXTHREAD))
+ {
+ if (cmd == NULL)
+ cmd = &mdata->commands[i].command.thread;
+ else
+ return 0;
+ }
+ }
+
+ if (cmd == NULL)
+ return 0;
+
+ for (i = 0; i < cmd->nflavours; i++)
+ {
+ if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_I386)
+ && (cmd->flavours[i].flavour
+ == (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
+ {
+ unsigned char buf[4];
+
+ bfd_seek (abfd, cmd->flavours[i].offset + 40, SEEK_SET);
+
+ if (bfd_bread (buf, 4, abfd) != 4)
+ return -1;
+
+ abfd->start_address = bfd_h_get_32 (abfd, buf);
+ }
+ else if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_POWERPC)
+ && (cmd->flavours[i].flavour == BFD_MACH_O_PPC_THREAD_STATE))
+ {
+ unsigned char buf[4];
+
+ bfd_seek (abfd, cmd->flavours[i].offset + 0, SEEK_SET);
+
+ if (bfd_bread (buf, 4, abfd) != 4)
+ return -1;
+
+ abfd->start_address = bfd_h_get_32 (abfd, buf);
+ }
+ }
+
+ return 0;
+}
+
+int
+bfd_mach_o_scan (abfd, header, mdata)
+ bfd *abfd;
+ bfd_mach_o_header *header;
+ bfd_mach_o_data_struct *mdata;
+{
+ unsigned int i;
+ enum bfd_architecture cputype;
+ unsigned long cpusubtype;
+
+ mdata->header = *header;
+ mdata->symbols = NULL;
+
+ abfd->flags = (abfd->xvec->object_flags
+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
+ abfd->tdata.mach_o_data = mdata;
+
+ bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype,
+ &cputype, &cpusubtype);
+ if (cputype == bfd_arch_unknown)
+ {
+ fprintf (stderr, "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx\n",
+ header->cputype, header->cpusubtype);
+ return -1;
+ }
+
+ bfd_set_arch_mach (abfd, cputype, cpusubtype);
+
+ if (header->ncmds != 0)
+ {
+ mdata->commands =
+ ((bfd_mach_o_load_command *)
+ bfd_alloc (abfd, header->ncmds * sizeof (bfd_mach_o_load_command)));
+ if (mdata->commands == NULL)
+ return -1;
+
+ for (i = 0; i < header->ncmds; i++)
+ {
+ bfd_mach_o_load_command *cur = &mdata->commands[i];
+
+ if (i == 0)
+ cur->offset = 28;
+ else
+ {
+ bfd_mach_o_load_command *prev = &mdata->commands[i - 1];
+ cur->offset = prev->offset + prev->len;
+ }
+
+ if (bfd_mach_o_scan_read_command (abfd, cur) < 0)
+ return -1;
+ }
+ }
+
+ if (bfd_mach_o_scan_start_address (abfd) < 0)
+ {
+#if 0
+ fprintf (stderr, "bfd_mach_o_scan: unable to scan start address: %s\n",
+ bfd_errmsg (bfd_get_error ()));
+ abfd->tdata.mach_o_data = NULL;
+ return -1;
+#endif
+ }
+
+ bfd_mach_o_flatten_sections (abfd);
+
+ return 0;
+}
+
+boolean
+bfd_mach_o_mkobject (abfd)
+ bfd *abfd;
+{
+ bfd_mach_o_data_struct *mdata = NULL;
+
+ mdata = ((bfd_mach_o_data_struct *)
+ bfd_alloc (abfd, sizeof (bfd_mach_o_data_struct)));
+ if (mdata == NULL)
+ return false;
+ abfd->tdata.mach_o_data = mdata;
+
+ mdata->header.magic = 0;
+ mdata->header.cputype = 0;
+ mdata->header.cpusubtype = 0;
+ mdata->header.filetype = 0;
+ mdata->header.ncmds = 0;
+ mdata->header.sizeofcmds = 0;
+ mdata->header.flags = 0;
+ mdata->header.byteorder = BFD_ENDIAN_UNKNOWN;
+ mdata->commands = NULL;
+ mdata->nsymbols = 0;
+ mdata->symbols = NULL;
+ mdata->nsects = 0;
+ mdata->sections = NULL;
+ mdata->ibfd = NULL;
+
+ return true;
+}
+
+const bfd_target *
+bfd_mach_o_object_p (abfd)
+ bfd *abfd;
+{
+ struct bfd_preserve preserve;
+ bfd_mach_o_header header;
+
+ preserve.marker = NULL;
+ if (bfd_mach_o_read_header (abfd, &header) != 0)
+ goto wrong;
+
+ if (! (header.byteorder == BFD_ENDIAN_BIG
+ || header.byteorder == BFD_ENDIAN_LITTLE))
+ {
+ fprintf (stderr, "unknown header byte-order value 0x%lx\n",
+ (long) header.byteorder);
+ goto wrong;
+ }
+
+ if (! ((header.byteorder == BFD_ENDIAN_BIG
+ && abfd->xvec->byteorder == BFD_ENDIAN_BIG
+ && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
+ || (header.byteorder == BFD_ENDIAN_LITTLE
+ && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
+ && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
+ goto wrong;
+
+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
+ if (preserve.marker == NULL
+ || !bfd_preserve_save (abfd, &preserve))
+ goto fail;
+
+ if (bfd_mach_o_scan (abfd, &header,
+ (bfd_mach_o_data_struct *) preserve.marker) != 0)
+ goto wrong;
+
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
+
+ wrong:
+ bfd_set_error (bfd_error_wrong_format);
+
+ fail:
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
+ return NULL;
+}
+
+const bfd_target *
+bfd_mach_o_core_p (abfd)
+ bfd *abfd;
+{
+ struct bfd_preserve preserve;
+ bfd_mach_o_header header;
+
+ preserve.marker = NULL;
+ if (bfd_mach_o_read_header (abfd, &header) != 0)
+ goto wrong;
+
+ if (! (header.byteorder == BFD_ENDIAN_BIG
+ || header.byteorder == BFD_ENDIAN_LITTLE))
+ {
+ fprintf (stderr, "unknown header byte-order value 0x%lx\n",
+ (long) header.byteorder);
+ abort ();
+ }
+
+ if (! ((header.byteorder == BFD_ENDIAN_BIG
+ && abfd->xvec->byteorder == BFD_ENDIAN_BIG
+ && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
+ || (header.byteorder == BFD_ENDIAN_LITTLE
+ && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
+ && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
+ goto wrong;
+
+ if (header.filetype != BFD_MACH_O_MH_CORE)
+ goto wrong;
+
+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
+ if (preserve.marker == NULL
+ || !bfd_preserve_save (abfd, &preserve))
+ goto fail;
+
+ if (bfd_mach_o_scan (abfd, &header,
+ (bfd_mach_o_data_struct *) preserve.marker) != 0)
+ goto wrong;
+
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
+
+ wrong:
+ bfd_set_error (bfd_error_wrong_format);
+
+ fail:
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
+ return NULL;
+}
+
+typedef struct mach_o_fat_archentry
+{
+ unsigned long cputype;
+ unsigned long cpusubtype;
+ unsigned long offset;
+ unsigned long size;
+ unsigned long align;
+ bfd *abfd;
+} mach_o_fat_archentry;
+
+typedef struct mach_o_fat_data_struct
+{
+ unsigned long magic;
+ unsigned long nfat_arch;
+ mach_o_fat_archentry *archentries;
+} mach_o_fat_data_struct;
+
+const bfd_target *
+bfd_mach_o_archive_p (abfd)
+ bfd *abfd;
+{
+ mach_o_fat_data_struct *adata = NULL;
+ unsigned char buf[20];
+ unsigned long i;
+
+ bfd_seek (abfd, 0, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 8, abfd) != 8)
+ goto error;
+
+ adata = (mach_o_fat_data_struct *)
+ bfd_alloc (abfd, sizeof (mach_o_fat_data_struct));
+ if (adata == NULL)
+ goto error;
+
+ adata->magic = bfd_getb32 (buf);
+ adata->nfat_arch = bfd_getb32 (buf + 4);
+ if (adata->magic != 0xcafebabe)
+ goto error;
+
+ adata->archentries = (mach_o_fat_archentry *)
+ bfd_alloc (abfd, adata->nfat_arch * sizeof (mach_o_fat_archentry));
+ if (adata->archentries == NULL)
+ goto error;
+
+ for (i = 0; i < adata->nfat_arch; i++)
+ {
+ bfd_seek (abfd, 8 + 20 * i, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 20, abfd) != 20)
+ goto error;
+ adata->archentries[i].cputype = bfd_getb32 (buf);
+ adata->archentries[i].cpusubtype = bfd_getb32 (buf + 4);
+ adata->archentries[i].offset = bfd_getb32 (buf + 8);
+ adata->archentries[i].size = bfd_getb32 (buf + 12);
+ adata->archentries[i].align = bfd_getb32 (buf + 16);
+ adata->archentries[i].abfd = NULL;
+ }
+
+ abfd->tdata.mach_o_fat_data = adata;
+ return abfd->xvec;
+
+ error:
+ if (adata != NULL)
+ bfd_release (abfd, adata);
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+}
+
+bfd *
+bfd_mach_o_openr_next_archived_file (archive, prev)
+ bfd *archive;
+ bfd *prev;
+{
+ mach_o_fat_data_struct *adata;
+ mach_o_fat_archentry *entry = NULL;
+ unsigned long i;
+
+ adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
+ BFD_ASSERT (adata != NULL);
+
+ /* Find index of previous entry. */
+ if (prev == NULL)
+ i = 0; /* Start at first one. */
+ else
+ {
+ for (i = 0; i < adata->nfat_arch; i++)
+ {
+ if (adata->archentries[i].abfd == prev)
+ break;
+ }
+
+ if (i == adata->nfat_arch)
+ {
+ /* Not found. */
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+ }
+ i++; /* Get next entry. */
+ }
+
+ if (i >= adata->nfat_arch)
+ {
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return NULL;
+ }
+
+ entry = &adata->archentries[i];
+ if (entry->abfd == NULL)
+ {
+ bfd *nbfd = _bfd_new_bfd_contained_in (archive);
+ char *s = NULL;
+
+ if (nbfd == NULL)
+ return NULL;
+
+ nbfd->origin = entry->offset;
+ s = bfd_malloc (strlen (archive->filename) + 1);
+ if (s == NULL)
+ return NULL;
+ strcpy (s, archive->filename);
+ nbfd->filename = s;
+ nbfd->iostream = NULL;
+ entry->abfd = nbfd;
+ }
+
+ return entry->abfd;
+}
+
+int
+bfd_mach_o_lookup_section (abfd, section, mcommand, msection)
+ bfd *abfd;
+ asection *section;
+ bfd_mach_o_load_command **mcommand;
+ bfd_mach_o_section **msection;
+{
+ struct mach_o_data_struct *md = abfd->tdata.mach_o_data;
+ unsigned int i, j, num;
+
+ bfd_mach_o_load_command *ncmd = NULL;
+ bfd_mach_o_section *nsect = NULL;
+
+ BFD_ASSERT (mcommand != NULL);
+ BFD_ASSERT (msection != NULL);
+
+ num = 0;
+ for (i = 0; i < md->header.ncmds; i++)
+ {
+ struct bfd_mach_o_load_command *cmd = &md->commands[i];
+ struct bfd_mach_o_segment_command *seg = NULL;
+
+ if (cmd->type != BFD_MACH_O_LC_SEGMENT)
+ continue;
+ seg = &cmd->command.segment;
+
+ if (seg->segment == section)
+ {
+ if (num == 0)
+ ncmd = cmd;
+ num++;
+ }
+
+ for (j = 0; j < seg->nsects; j++)
+ {
+ struct bfd_mach_o_section *sect = &seg->sections[j];
+
+ if (sect->bfdsection == section)
+ {
+ if (num == 0)
+ nsect = sect;
+ num++;
+ }
+ }
+ }
+
+ *mcommand = ncmd;
+ *msection = nsect;
+ return num;
+}
+
+int
+bfd_mach_o_lookup_command (abfd, type, mcommand)
+ bfd *abfd;
+ bfd_mach_o_load_command_type type;
+ bfd_mach_o_load_command **mcommand;
+{
+ struct mach_o_data_struct *md = NULL;
+ bfd_mach_o_load_command *ncmd = NULL;
+ unsigned int i, num;
+
+ md = abfd->tdata.mach_o_data;
+
+ BFD_ASSERT (md != NULL);
+ BFD_ASSERT (mcommand != NULL);
+
+ num = 0;
+ for (i = 0; i < md->header.ncmds; i++)
+ {
+ struct bfd_mach_o_load_command *cmd = &md->commands[i];
+
+ if (cmd->type != type)
+ continue;
+
+ if (num == 0)
+ ncmd = cmd;
+ num++;
+ }
+
+ *mcommand = ncmd;
+ return num;
+}
+
+unsigned long
+bfd_mach_o_stack_addr (type)
+ enum bfd_mach_o_cpu_type type;
+{
+ switch (type)
+ {
+ case BFD_MACH_O_CPU_TYPE_MC680x0:
+ return 0x04000000;
+ case BFD_MACH_O_CPU_TYPE_MC88000:
+ return 0xffffe000;
+ case BFD_MACH_O_CPU_TYPE_POWERPC:
+ return 0xc0000000;
+ case BFD_MACH_O_CPU_TYPE_I386:
+ return 0xc0000000;
+ case BFD_MACH_O_CPU_TYPE_SPARC:
+ return 0xf0000000;
+ case BFD_MACH_O_CPU_TYPE_I860:
+ return 0;
+ case BFD_MACH_O_CPU_TYPE_HPPA:
+ return 0xc0000000 - 0x04000000;
+ default:
+ return 0;
+ }
+}
+
+int
+bfd_mach_o_core_fetch_environment (abfd, rbuf, rlen)
+ bfd *abfd;
+ unsigned char **rbuf;
+ unsigned int *rlen;
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ unsigned long stackaddr = bfd_mach_o_stack_addr (mdata->header.cputype);
+ unsigned int i = 0;
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ bfd_mach_o_load_command *cur = &mdata->commands[i];
+ bfd_mach_o_segment_command *seg = NULL;
+
+ if (cur->type != BFD_MACH_O_LC_SEGMENT)
+ continue;
+
+ seg = &cur->command.segment;
+
+ if ((seg->vmaddr + seg->vmsize) == stackaddr)
+ {
+ unsigned long start = seg->fileoff;
+ unsigned long end = seg->fileoff + seg->filesize;
+ unsigned char *buf = bfd_malloc (1024);
+ unsigned long size = 1024;
+
+ for (;;)
+ {
+ bfd_size_type nread = 0;
+ unsigned long offset;
+ int found_nonnull = 0;
+
+ if (size > (end - start))
+ size = (end - start);
+
+ buf = bfd_realloc (buf, size);
+
+ bfd_seek (abfd, end - size, SEEK_SET);
+ nread = bfd_bread (buf, size, abfd);
+
+ if (nread != size)
+ return -1;
+
+ for (offset = 4; offset <= size; offset += 4)
+ {
+ unsigned long val;
+
+ val = *((unsigned long *) (buf + size - offset));
+ if (! found_nonnull)
+ {
+ if (val != 0)
+ found_nonnull = 1;
+ }
+ else if (val == 0x0)
+ {
+ unsigned long bottom;
+ unsigned long top;
+
+ bottom = seg->fileoff + seg->filesize - offset;
+ top = seg->fileoff + seg->filesize - 4;
+ *rbuf = bfd_malloc (top - bottom);
+ *rlen = top - bottom;
+
+ memcpy (*rbuf, buf + size - *rlen, *rlen);
+ return 0;
+ }
+ }
+
+ if (size == (end - start))
+ break;
+
+ size *= 2;
+ }
+ }
+ }
+
+ return -1;
+}
+
+char *
+bfd_mach_o_core_file_failing_command (abfd)
+ bfd *abfd;
+{
+ unsigned char *buf = NULL;
+ unsigned int len = 0;
+ int ret = -1;
+
+ ret = bfd_mach_o_core_fetch_environment (abfd, &buf, &len);
+ if (ret < 0)
+ return NULL;
+
+ return buf;
+}
+
+int
+bfd_mach_o_core_file_failing_signal (abfd)
+ bfd *abfd ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+boolean
+bfd_mach_o_core_file_matches_executable_p (core_bfd, exec_bfd)
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
+{
+ return true;
+}
+
+#define TARGET_NAME mach_o_be_vec
+#define TARGET_STRING "mach-o-be"
+#define TARGET_BIG_ENDIAN 1
+#define TARGET_ARCHIVE 0
+
+#include "mach-o-target.c"
+
+#undef TARGET_NAME
+#undef TARGET_STRING
+#undef TARGET_BIG_ENDIAN
+#undef TARGET_ARCHIVE
+
+#define TARGET_NAME mach_o_le_vec
+#define TARGET_STRING "mach-o-le"
+#define TARGET_BIG_ENDIAN 0
+#define TARGET_ARCHIVE 0
+
+#include "mach-o-target.c"
+
+#undef TARGET_NAME
+#undef TARGET_STRING
+#undef TARGET_BIG_ENDIAN
+#undef TARGET_ARCHIVE
+
+#define TARGET_NAME mach_o_fat_vec
+#define TARGET_STRING "mach-o-fat"
+#define TARGET_BIG_ENDIAN 1
+#define TARGET_ARCHIVE 1
+
+#include "mach-o-target.c"
+
+#undef TARGET_NAME
+#undef TARGET_STRING
+#undef TARGET_BIG_ENDIAN
+#undef TARGET_ARCHIVE
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
new file mode 100644
index 00000000000..f78027321de
--- /dev/null
+++ b/bfd/mach-o.h
@@ -0,0 +1,490 @@
+/* Mach-O support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _BFD_MACH_O_H_
+#define _BFD_MACH_O_H_
+
+#include "bfd.h"
+
+#define BFD_MACH_O_N_STAB 0xe0 /* If any of these bits set, a symbolic debugging entry. */
+#define BFD_MACH_O_N_PEXT 0x10 /* Private external symbol bit. */
+#define BFD_MACH_O_N_TYPE 0x0e /* Mask for the type bits. */
+#define BFD_MACH_O_N_EXT 0x01 /* External symbol bit, set for external symbols. */
+#define BFD_MACH_O_N_UNDF 0x00 /* Undefined, n_sect == NO_SECT. */
+#define BFD_MACH_O_N_ABS 0x02 /* Absolute, n_sect == NO_SECT. */
+#define BFD_MACH_O_N_SECT 0x0e /* Defined in section number n_sect. */
+#define BFD_MACH_O_N_PBUD 0x0c /* Prebound undefined (defined in a dylib). */
+#define BFD_MACH_O_N_INDR 0x0a /* Indirect. */
+
+typedef enum bfd_mach_o_ppc_thread_flavour
+ {
+ BFD_MACH_O_PPC_THREAD_STATE = 1,
+ BFD_MACH_O_PPC_FLOAT_STATE = 2,
+ BFD_MACH_O_PPC_EXCEPTION_STATE = 3,
+ BFD_MACH_O_PPC_VECTOR_STATE = 4
+ }
+bfd_mach_o_ppc_thread_flavour;
+
+typedef enum bfd_mach_o_i386_thread_flavour
+ {
+ BFD_MACH_O_i386_NEW_THREAD_STATE = 1,
+ BFD_MACH_O_i386_FLOAT_STATE = 2,
+ BFD_MACH_O_i386_ISA_PORT_MAP_STATE = 3,
+ BFD_MACH_O_i386_V86_ASSIST_STATE = 4,
+ BFD_MACH_O_i386_REGS_SEGS_STATE = 5,
+ BFD_MACH_O_i386_THREAD_SYSCALL_STATE = 6,
+ BFD_MACH_O_i386_THREAD_STATE_NONE = 7,
+ BFD_MACH_O_i386_SAVED_STATE = 8,
+ BFD_MACH_O_i386_THREAD_STATE = -1,
+ BFD_MACH_O_i386_THREAD_FPSTATE = -2,
+ BFD_MACH_O_i386_THREAD_EXCEPTSTATE = -3,
+ BFD_MACH_O_i386_THREAD_CTHREADSTATE = -4,
+ }
+bfd_mach_o_i386_thread_flavour;
+
+#define BFD_MACH_O_LC_REQ_DYLD 0x80000000
+
+typedef enum bfd_mach_o_load_command_type
+ {
+ BFD_MACH_O_LC_SEGMENT = 0x1, /* File segment to be mapped. */
+ BFD_MACH_O_LC_SYMTAB = 0x2, /* Link-edit stab symbol table info (obsolete). */
+ BFD_MACH_O_LC_SYMSEG = 0x3, /* Link-edit gdb symbol table info. */
+ BFD_MACH_O_LC_THREAD = 0x4, /* Thread. */
+ BFD_MACH_O_LC_UNIXTHREAD = 0x5, /* UNIX thread (includes a stack). */
+ BFD_MACH_O_LC_LOADFVMLIB = 0x6, /* Load a fixed VM shared library. */
+ BFD_MACH_O_LC_IDFVMLIB = 0x7, /* Fixed VM shared library id. */
+ BFD_MACH_O_LC_IDENT = 0x8, /* Object identification information (obsolete). */
+ BFD_MACH_O_LC_FVMFILE = 0x9, /* Fixed VM file inclusion. */
+ BFD_MACH_O_LC_PREPAGE = 0xa, /* Prepage command (internal use). */
+ BFD_MACH_O_LC_DYSYMTAB = 0xb, /* Dynamic link-edit symbol table info. */
+ BFD_MACH_O_LC_LOAD_DYLIB = 0xc, /* Load a dynamicly linked shared library. */
+ BFD_MACH_O_LC_ID_DYLIB = 0xd, /* Dynamicly linked shared lib identification. */
+ BFD_MACH_O_LC_LOAD_DYLINKER = 0xe, /* Load a dynamic linker. */
+ BFD_MACH_O_LC_ID_DYLINKER = 0xf, /* Dynamic linker identification. */
+ BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,/* Modules prebound for a dynamicly. */
+ BFD_MACH_O_LC_ROUTINES = 0x11, /* Image routines. */
+ BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, /* Sub framework. */
+ BFD_MACH_O_LC_SUB_UMBRELLA = 0x13, /* Sub umbrella. */
+ BFD_MACH_O_LC_SUB_CLIENT = 0x14, /* Sub client. */
+ BFD_MACH_O_LC_SUB_LIBRARY = 0x15, /* Sub library. */
+ BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,/* Two-level namespace lookup hints. */
+ BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, /* Prebind checksum. */
+ /* Load a dynamicly linked shared library that is allowed to be
+ missing (weak). */
+ BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
+ }
+bfd_mach_o_load_command_type;
+
+typedef enum bfd_mach_o_cpu_type
+ {
+ BFD_MACH_O_CPU_TYPE_VAX = 1,
+ BFD_MACH_O_CPU_TYPE_MC680x0 = 6,
+ BFD_MACH_O_CPU_TYPE_I386 = 7,
+ BFD_MACH_O_CPU_TYPE_MIPS = 8,
+ BFD_MACH_O_CPU_TYPE_MC98000 = 10,
+ BFD_MACH_O_CPU_TYPE_HPPA = 11,
+ BFD_MACH_O_CPU_TYPE_ARM = 12,
+ BFD_MACH_O_CPU_TYPE_MC88000 = 13,
+ BFD_MACH_O_CPU_TYPE_SPARC = 14,
+ BFD_MACH_O_CPU_TYPE_I860 = 15,
+ BFD_MACH_O_CPU_TYPE_ALPHA = 16,
+ BFD_MACH_O_CPU_TYPE_POWERPC = 18
+ }
+bfd_mach_o_cpu_type;
+
+typedef enum bfd_mach_o_filetype
+ {
+ BFD_MACH_O_MH_OBJECT = 1,
+ BFD_MACH_O_MH_EXECUTE = 2,
+ BFD_MACH_O_MH_FVMLIB = 3,
+ BFD_MACH_O_MH_CORE = 4,
+ BFD_MACH_O_MH_PRELOAD = 5,
+ BFD_MACH_O_MH_DYLIB = 6,
+ BFD_MACH_O_MH_DYLINKER = 7,
+ BFD_MACH_O_MH_BUNDLE = 8
+ }
+bfd_mach_o_filetype;
+
+/* Constants for the type of a section. */
+
+typedef enum bfd_mach_o_section_type
+ {
+ /* Regular section. */
+ BFD_MACH_O_S_REGULAR = 0x0,
+
+ /* Zero fill on demand section. */
+ BFD_MACH_O_S_ZEROFILL = 0x1,
+
+ /* Section with only literal C strings. */
+ BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
+
+ /* Section with only 4 byte literals. */
+ BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
+
+ /* Section with only 8 byte literals. */
+ BFD_MACH_O_S_8BYTE_LITERALS = 0x4,
+
+ /* Section with only pointers to literals. */
+ BFD_MACH_O_S_LITERAL_POINTERS = 0x5,
+
+ /* For the two types of symbol pointers sections and the symbol stubs
+ section they have indirect symbol table entries. For each of the
+ entries in the section the indirect symbol table entries, in
+ corresponding order in the indirect symbol table, start at the index
+ stored in the reserved1 field of the section structure. Since the
+ indirect symbol table entries correspond to the entries in the
+ section the number of indirect symbol table entries is inferred from
+ the size of the section divided by the size of the entries in the
+ section. For symbol pointers sections the size of the entries in
+ the section is 4 bytes and for symbol stubs sections the byte size
+ of the stubs is stored in the reserved2 field of the section
+ structure. */
+
+ /* Section with only non-lazy symbol pointers. */
+ BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
+
+ /* Section with only lazy symbol pointers. */
+ BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
+
+ /* Section with only symbol stubs, byte size of stub in the reserved2 field. */
+ BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
+
+ /* Section with only function pointers for initialization. */
+ BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
+ }
+bfd_mach_o_section_type;
+
+typedef unsigned long bfd_mach_o_cpu_subtype;
+
+typedef struct bfd_mach_o_header
+{
+ unsigned long magic;
+ unsigned long cputype;
+ unsigned long cpusubtype;
+ unsigned long filetype;
+ unsigned long ncmds;
+ unsigned long sizeofcmds;
+ unsigned long flags;
+ enum bfd_endian byteorder;
+}
+bfd_mach_o_header;
+
+typedef struct bfd_mach_o_section
+{
+ asection *bfdsection;
+ char sectname[16 + 1];
+ char segname[16 + 1];
+ bfd_vma addr;
+ bfd_vma size;
+ bfd_vma offset;
+ unsigned long align;
+ bfd_vma reloff;
+ unsigned long nreloc;
+ unsigned long flags;
+ unsigned long reserved1;
+ unsigned long reserved2;
+}
+bfd_mach_o_section;
+
+typedef struct bfd_mach_o_segment_command
+{
+ char segname[16];
+ bfd_vma vmaddr;
+ bfd_vma vmsize;
+ bfd_vma fileoff;
+ unsigned long filesize;
+ unsigned long nsects;
+ unsigned long flags;
+ bfd_mach_o_section *sections;
+ asection *segment;
+}
+bfd_mach_o_segment_command;
+
+typedef struct bfd_mach_o_symtab_command
+{
+ unsigned long symoff;
+ unsigned long nsyms;
+ unsigned long stroff;
+ unsigned long strsize;
+ asymbol *symbols;
+ char *strtab;
+ asection *stabs_segment;
+ asection *stabstr_segment;
+}
+bfd_mach_o_symtab_command;
+
+/* This is the second set of the symbolic information which is used to support
+ the data structures for the dynamicly link editor.
+
+ The original set of symbolic information in the symtab_command which contains
+ the symbol and string tables must also be present when this load command is
+ present. When this load command is present the symbol table is organized
+ into three groups of symbols:
+ local symbols (static and debugging symbols) - grouped by module
+ defined external symbols - grouped by module (sorted by name if not lib)
+ undefined external symbols (sorted by name)
+ In this load command there are offsets and counts to each of the three groups
+ of symbols.
+
+ This load command contains a the offsets and sizes of the following new
+ symbolic information tables:
+ table of contents
+ module table
+ reference symbol table
+ indirect symbol table
+ The first three tables above (the table of contents, module table and
+ reference symbol table) are only present if the file is a dynamicly linked
+ shared library. For executable and object modules, which are files
+ containing only one module, the information that would be in these three
+ tables is determined as follows:
+ table of contents - the defined external symbols are sorted by name
+ module table - the file contains only one module so everything in the
+ file is part of the module.
+ reference symbol table - is the defined and undefined external symbols
+
+ For dynamicly linked shared library files this load command also contains
+ offsets and sizes to the pool of relocation entries for all sections
+ separated into two groups:
+ external relocation entries
+ local relocation entries
+ For executable and object modules the relocation entries continue to hang
+ off the section structures. */
+
+typedef struct bfd_mach_o_dysymtab_command
+{
+ /* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
+ are grouped into the following three groups:
+ local symbols (further grouped by the module they are from)
+ defined external symbols (further grouped by the module they are from)
+ undefined symbols
+
+ The local symbols are used only for debugging. The dynamic binding
+ process may have to use them to indicate to the debugger the local
+ symbols for a module that is being bound.
+
+ The last two groups are used by the dynamic binding process to do the
+ binding (indirectly through the module table and the reference symbol
+ table when this is a dynamicly linked shared library file). */
+
+ unsigned long ilocalsym; /* Index to local symbols. */
+ unsigned long nlocalsym; /* Number of local symbols. */
+ unsigned long iextdefsym; /* Index to externally defined symbols. */
+ unsigned long nextdefsym; /* Number of externally defined symbols. */
+ unsigned long iundefsym; /* Index to undefined symbols. */
+ unsigned long nundefsym; /* Number of undefined symbols. */
+
+ /* For the for the dynamic binding process to find which module a symbol
+ is defined in the table of contents is used (analogous to the ranlib
+ structure in an archive) which maps defined external symbols to modules
+ they are defined in. This exists only in a dynamicly linked shared
+ library file. For executable and object modules the defined external
+ symbols are sorted by name and is use as the table of contents. */
+
+ unsigned long tocoff; /* File offset to table of contents. */
+ unsigned long ntoc; /* Number of entries in table of contents. */
+
+ /* To support dynamic binding of "modules" (whole object files) the symbol
+ table must reflect the modules that the file was created from. This is
+ done by having a module table that has indexes and counts into the merged
+ tables for each module. The module structure that these two entries
+ refer to is described below. This exists only in a dynamicly linked
+ shared library file. For executable and object modules the file only
+ contains one module so everything in the file belongs to the module. */
+
+ unsigned long modtaboff; /* File offset to module table. */
+ unsigned long nmodtab; /* Number of module table entries. */
+
+ /* To support dynamic module binding the module structure for each module
+ indicates the external references (defined and undefined) each module
+ makes. For each module there is an offset and a count into the
+ reference symbol table for the symbols that the module references.
+ This exists only in a dynamicly linked shared library file. For
+ executable and object modules the defined external symbols and the
+ undefined external symbols indicates the external references. */
+
+ unsigned long extrefsymoff; /* Offset to referenced symbol table. */
+ unsigned long nextrefsyms; /* Number of referenced symbol table entries. */
+
+ /* The sections that contain "symbol pointers" and "routine stubs" have
+ indexes and (implied counts based on the size of the section and fixed
+ size of the entry) into the "indirect symbol" table for each pointer
+ and stub. For every section of these two types the index into the
+ indirect symbol table is stored in the section header in the field
+ reserved1. An indirect symbol table entry is simply a 32bit index into
+ the symbol table to the symbol that the pointer or stub is referring to.
+ The indirect symbol table is ordered to match the entries in the section. */
+
+ unsigned long indirectsymoff; /* File offset to the indirect symbol table. */
+ unsigned long nindirectsyms; /* Number of indirect symbol table entries. */
+
+ /* To support relocating an individual module in a library file quickly the
+ external relocation entries for each module in the library need to be
+ accessed efficiently. Since the relocation entries can't be accessed
+ through the section headers for a library file they are separated into
+ groups of local and external entries further grouped by module. In this
+ case the presents of this load command who's extreloff, nextrel,
+ locreloff and nlocrel fields are non-zero indicates that the relocation
+ entries of non-merged sections are not referenced through the section
+ structures (and the reloff and nreloc fields in the section headers are
+ set to zero).
+
+ Since the relocation entries are not accessed through the section headers
+ this requires the r_address field to be something other than a section
+ offset to identify the item to be relocated. In this case r_address is
+ set to the offset from the vmaddr of the first LC_SEGMENT command.
+
+ The relocation entries are grouped by module and the module table
+ entries have indexes and counts into them for the group of external
+ relocation entries for that the module.
+
+ For sections that are merged across modules there must not be any
+ remaining external relocation entries for them (for merged sections
+ remaining relocation entries must be local). */
+
+ unsigned long extreloff; /* Offset to external relocation entries. */
+ unsigned long nextrel; /* Number of external relocation entries. */
+
+ /* All the local relocation entries are grouped together (they are not
+ grouped by their module since they are only used if the object is moved
+ from it staticly link edited address). */
+
+ unsigned long locreloff; /* Offset to local relocation entries. */
+ unsigned long nlocrel; /* Number of local relocation entries. */
+}
+bfd_mach_o_dysymtab_command;
+
+/* An indirect symbol table entry is simply a 32bit index into the symbol table
+ to the symbol that the pointer or stub is refering to. Unless it is for a
+ non-lazy symbol pointer section for a defined symbol which strip(1) as
+ removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
+ symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */
+
+#define INDIRECT_SYMBOL_LOCAL 0x80000000
+#define INDIRECT_SYMBOL_ABS 0x40000000
+
+typedef struct bfd_mach_o_thread_flavour
+{
+ unsigned long flavour;
+ bfd_vma offset;
+ unsigned long size;
+}
+bfd_mach_o_thread_flavour;
+
+typedef struct bfd_mach_o_thread_command
+{
+ unsigned long nflavours;
+ bfd_mach_o_thread_flavour *flavours;
+ asection *section;
+}
+bfd_mach_o_thread_command;
+
+typedef struct bfd_mach_o_dylinker_command
+{
+ unsigned long cmd; /* LC_ID_DYLIB or LC_LOAD_DYLIB. */
+ unsigned long cmdsize; /* Includes pathname string. */
+ unsigned long name_offset; /* Offset to library's path name. */
+ unsigned long name_len; /* Offset to library's path name. */
+ asection *section;
+}
+bfd_mach_o_dylinker_command;
+
+typedef struct bfd_mach_o_dylib_command
+{
+ unsigned long cmd; /* LC_ID_DYLIB or LC_LOAD_DYLIB. */
+ unsigned long cmdsize; /* Includes pathname string. */
+ unsigned long name_offset; /* Offset to library's path name. */
+ unsigned long name_len; /* Offset to library's path name. */
+ unsigned long timestamp; /* Library's build time stamp. */
+ unsigned long current_version; /* Library's current version number. */
+ unsigned long compatibility_version; /* Library's compatibility vers number. */
+ asection *section;
+}
+bfd_mach_o_dylib_command;
+
+typedef struct bfd_mach_o_prebound_dylib_command
+{
+ unsigned long cmd; /* LC_PREBOUND_DYLIB. */
+ unsigned long cmdsize; /* Includes strings. */
+ unsigned long name; /* Library's path name. */
+ unsigned long nmodules; /* Number of modules in library. */
+ unsigned long linked_modules; /* Bit vector of linked modules. */
+ asection *section;
+}
+bfd_mach_o_prebound_dylib_command;
+
+typedef struct bfd_mach_o_load_command
+{
+ bfd_mach_o_load_command_type type;
+ unsigned int type_required;
+ bfd_vma offset;
+ bfd_vma len;
+ union
+ {
+ bfd_mach_o_segment_command segment;
+ bfd_mach_o_symtab_command symtab;
+ bfd_mach_o_dysymtab_command dysymtab;
+ bfd_mach_o_thread_command thread;
+ bfd_mach_o_dylib_command dylib;
+ bfd_mach_o_dylinker_command dylinker;
+ bfd_mach_o_prebound_dylib_command prebound_dylib;
+ }
+ command;
+}
+bfd_mach_o_load_command;
+
+typedef struct mach_o_data_struct
+{
+ bfd_mach_o_header header;
+ bfd_mach_o_load_command *commands;
+ unsigned long nsymbols;
+ asymbol *symbols;
+ unsigned long nsects;
+ bfd_mach_o_section **sections;
+ bfd *ibfd;
+}
+mach_o_data_struct;
+
+typedef struct mach_o_data_struct bfd_mach_o_data_struct;
+
+boolean bfd_mach_o_valid PARAMS ((bfd *));
+int bfd_mach_o_scan_read_symtab_symbol PARAMS ((bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
+int bfd_mach_o_scan_read_symtab_strtab PARAMS ((bfd *, bfd_mach_o_symtab_command *));
+int bfd_mach_o_scan_read_symtab_symbols PARAMS ((bfd *, bfd_mach_o_symtab_command *));
+int bfd_mach_o_scan_read_dysymtab_symbol PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
+int bfd_mach_o_scan_start_address PARAMS ((bfd *));
+int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));
+boolean bfd_mach_o_mkobject PARAMS ((bfd *));
+const bfd_target * bfd_mach_o_object_p PARAMS ((bfd *));
+const bfd_target * bfd_mach_o_core_p PARAMS ((bfd *));
+const bfd_target * bfd_mach_o_archive_p PARAMS ((bfd *));
+bfd * bfd_mach_o_openr_next_archived_file PARAMS ((bfd *, bfd *));
+int bfd_mach_o_lookup_section PARAMS ((bfd *, asection *, bfd_mach_o_load_command **, bfd_mach_o_section **));
+int bfd_mach_o_lookup_command PARAMS ((bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **));
+unsigned long bfd_mach_o_stack_addr PARAMS ((enum bfd_mach_o_cpu_type));
+int bfd_mach_o_core_fetch_environment PARAMS ((bfd *, unsigned char **, unsigned int *));
+char * bfd_mach_o_core_file_failing_command PARAMS ((bfd *));
+int bfd_mach_o_core_file_failing_signal PARAMS ((bfd *));
+boolean bfd_mach_o_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+
+extern const bfd_target mach_o_be_vec;
+extern const bfd_target mach_o_le_vec;
+extern const bfd_target mach_o_fat_vec;
+
+#endif /* _BFD_MACH_O_H_ */
diff --git a/bfd/pef-traceback.h b/bfd/pef-traceback.h
new file mode 100644
index 00000000000..15f43b6e594
--- /dev/null
+++ b/bfd/pef-traceback.h
@@ -0,0 +1,215 @@
+/* PowerPC traceback table support for BFD.
+ Copyright 1993, 1998, 1999, 2000, 2001, 2002
+ 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. */
+
+/* Originally written by Ira Ruben, 06/28/93 */
+
+/* This is a compiler independent representation of the AIX Version 3 traceback table (in
+ sys/debug.h), which occurs, usually, one per procedure (routine). The table is marked by
+ a multiple of 4 32-bit word of zeroes in the instruction space. The traceback table is
+ also referred to as "procedure-end table".
+
+ The AIX traceback table representation on which this header is based is defined as a
+ series of bit field struct specifications. Bit fields are compiler dependent! Thus,
+ the definitions presented here follow the original header and the existing documentation
+ (such as it is), but define the fields as BIT MASKS and other macros. The mask names,
+ however, where chosen as the original field names to give some compatibility with the
+ original header and to agree with the documentation. */
+
+#ifndef __TRACEBACK__
+#define __TRACEBACK__
+
+#define TB_C 0U /* C */
+#define TB_FORTRAN 1U /* FORTRAN */
+#define TB_PASCAL 2U /* Pascal */
+#define TB_ADA 3U /* ADA */
+#define TB_PL1 4U /* PL1 */
+#define TB_BASIC 5U /* Basic */
+#define TB_LISP 6U /* Lisp */
+#define TB_COBOL 7U /* eCobol */
+#define TB_MODULA2 8U /* Modula2 */
+#define TB_CPLUSPLUS 9U /* C++ */
+#define TB_RPG 10U /* RPG */
+#define TB_PL8 11U /* PL8 */
+#define TB_ASM 12U /* Asm */
+
+/* flags 1 */
+
+#define TB_GLOBALLINK 0x80U /* Routine is Global Linkage. */
+#define TB_is_eprol 0x40U /* Out-of-line prolog or epilog routine. */
+#define TB_HAS_TBOFF 0x20U /* tb_offset set (extension field). */
+#define TB_INT_PROC 0x10U /* Internal leaf routine. */
+#define TB_HAS_CTL 0x08U /* Has controlled automatic storage. */
+#define TB_TOCLESS 0X04U /* Routine has no TOC. */
+#define TB_FP_PRESENT 0x02U /* Routine has floating point ops. */
+#define TB_LOG_ABORT 0x01U /* fp_present && log/abort compiler opt. */
+
+/* flags 2 */
+
+#define TB_INT_HNDL 0x80U /* Routine is an interrupt handler. */
+#define TB_NAME_PRESENT 0x40U /* Name_len/name set (extension field). */
+#define TB_USES_ALLOCA 0x20U /* Uses alloca() to allocate storage. */
+#define TB_CL_DIS_inv 0x1CU /* On-condition directives (see below). */
+#define TB_SAVES_CR 0x02U /* Routine saves the CR. */
+#define TB_SAVES_LR 0x01U /* Routine saves the LR. */
+
+/* cl_dis_inv "on condition" settings: */
+
+#define TB_CL_DIS_INV(x) (((x) & cl_dis_inv) >> 2U)
+
+#define TB_WALK_ONCOND 0U /* Walk stack without restoring state. */
+#define TB_DISCARD_ONCOND 1U /* Walk stack and discard. */
+#define TB_INVOKE_ONCOND 2U /* Invoke a specific system routine. */
+
+/* flags 3 */
+
+#define TB_STORES_BC 0x80U /* Routine saves frame ptr of caller. */
+#define TB_SPARE2 0X40U /* Spare bit. */
+#define TB_FPR_SAVED 0x3fU /* Number of FPRs saved (max of 32). */
+ /* (Last reg saved is ALWAYS fpr31). */
+
+#define TB_NUM_FPR_SAVED(x) ((x) & fpr_saved)
+
+/* flags 4 */
+
+#define TB_HAS_VEC_INFO 0x80U /* Routine uses vectors. */
+#define TB_SPARE3 0X40U /* Spare bit. */
+#define TB_GPR_SAVED 0x3fU /* Number of GPRs saved (max of 32). */
+ /* (Last reg saved is ALWAYS gpr31). */
+
+#define TB_NUM_GPR_SAVED(x) ((x) & gpr_saved)
+
+/* flags 5 */
+
+#define TB_FLOATPARAMS 0xfeU /* Number of floating point parameters. */
+#define TB_PARAMSONSTK 0X01U /* All parameters are on the stack. */
+
+#define TB_NUM_FLOATPARAMS(X) (((x) & floatparams) >> 1U)
+
+/* traceback_table (fixed portion). */
+
+struct traceback_table
+{
+ /* Traceback table layout (fixed portion): */
+
+ unsigned char version; /* Traceback format version. */
+ unsigned char lang; /* Language indicators: */
+ unsigned char flags1; /* Flag bits #1: */
+ unsigned char flags2; /* Flag bits #2: */
+ unsigned char flags3; /* Flag bits #3: */
+ unsigned char flags4; /* Flag bits #4: */
+ unsigned char fixedparams; /* Number of fixed point parameters. */
+ unsigned char flags5; /* Flag bits #5: */
+};
+
+/* traceback_table (optional) extensions. */
+
+/* Optional portions exist independently in the order presented below,
+ not as a structure or a union. Whether or not portions exist is
+ determinable from bit-fields within the fixed portion above. */
+
+/* The following is present only if fixedparams or floatparams are non
+ zero and it immediately follows the fixed portion of the traceback
+ table... */
+
+/* Order and type encoding of parameters: */
+struct traceback_table_fixedparams
+{
+ unsigned long paraminfo;
+};
+
+/* Left-justified bit-encoding as follows: */
+#define FIXED_PARAM 0 /* '0' ==> fixed param (1 gpr or word). */
+#define SPFP_PARAM 2 /* '10' ==> single-precision float param. */
+#define DPFP_PARAM 3 /* '11' ==> double-precision float param. */
+
+#define PARAM_ENCODING(x, bit) /* Yields xxx_PARAM as a function of "bit". */ \
+ ((((x)&(1UL<<(31UL-(bit++))))==0UL) /* Values 0:31 (left-to-right). "bit" is */ \
+ ? FIXED_PARAM /* an L-value that's left incremented to */ \
+ : ((((x)&(1UL<<(31UL-(bit++))))==0)/* the next bit position for the next */ \
+ ? SPFP_PARAM /* parameter. This will be 1 or 2 bit */ \
+ : DPFP_PARAM)) /* positions later. */
+
+/* The following is present only if has_tboff (in flags1) in fixed part is present... */
+
+/* Offset from start of code to TracebackTbl. */
+struct traceback_table_tboff
+{
+ unsigned long tb_offset;
+};
+
+/* The following is present only if int_hndl (in flags2) in fixed part is present ... */
+
+/* What interrupts are handled by the routine. */
+struct traceback_table_interrupts
+{
+ long hand_mask;
+};
+
+/* The following are present only if has_ctl (in flags1) in fixed part is present... */
+
+/* Controlled automatic storage info: */
+struct traceback_table_anchors
+{
+ unsigned long ctl_info; /* Number of controlled automatic anchors. */
+ long ctl_info_disp[1]; /* Array of stack displacements where each. */
+}; /* Anchor is located (array STARTS here). */
+
+/* The following are present only if name_present (in flags2) in fixed
+ part is present... */
+
+/* Routine name: */
+struct traceback_table_routine
+{
+ unsigned short name_len; /* Length of name that follows. */
+ char name[1]; /* Name starts here (NOT null terminated). */
+};
+
+/* The following are present only if uses_alloca (in flags2) in fixed
+ part is present... */
+
+/* Register auto storage when alloca() is used. */
+struct traceback_table_alloca
+{
+ char alloca_reg;
+};
+
+/* The following are present only if has_vec_info (in flags4) in fixed
+ part is present... */
+
+/* Vector info: */
+struct traceback_table_vector
+{
+ unsigned char vec_flags1; /* Vec info bits #1: */
+
+#define TB_VR_SAVED 0xFCU /* Number of saved vector registers. */
+#define TB_SAVES_VRSAVE 0x02U /* Saves VRsave. */
+#define TB_HAS_VARARGS 0x01U /* Routine has a variable argument list. */
+
+#define TB_NUM_VR_SAVED(x) (((x) & TB_VR_SAVED) >> 2U)
+
+ unsigned char vec_flags2; /* Vec info bits #2: */
+
+#define TB_VECTORPARAMS 0xfeU /* Number of vector parameters. */
+#define TB_VEC_PRESENT 0x01U /* Routine uses at least one vec instr. */
+
+#define VECPARAMS(x) (((x) & TB_VECTORPARAMS) >> 1U)
+};
+
+#endif
diff --git a/bfd/pef.c b/bfd/pef.c
new file mode 100644
index 00000000000..2f120285ace
--- /dev/null
+++ b/bfd/pef.c
@@ -0,0 +1,1312 @@
+/* PEF support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ 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 <ctype.h>
+
+#include "pef.h"
+#include "pef-traceback.h"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#include "libiberty.h"
+
+#ifndef BFD_IO_FUNCS
+#define BFD_IO_FUNCS 0
+#endif
+
+#define bfd_pef_close_and_cleanup _bfd_generic_close_and_cleanup
+#define bfd_pef_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define bfd_pef_new_section_hook _bfd_generic_new_section_hook
+#define bfd_pef_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define bfd_pef_get_lineno _bfd_nosymbols_get_lineno
+#define bfd_pef_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define bfd_pef_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define bfd_pef_read_minisymbols _bfd_generic_read_minisymbols
+#define bfd_pef_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+
+#define bfd_pef_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
+#define bfd_pef_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define bfd_pef_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define bfd_pef_set_arch_mach _bfd_generic_set_arch_mach
+
+#define bfd_pef_get_section_contents _bfd_generic_get_section_contents
+#define bfd_pef_set_section_contents _bfd_generic_set_section_contents
+
+#define bfd_pef_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define bfd_pef_bfd_relax_section bfd_generic_relax_section
+#define bfd_pef_bfd_gc_sections bfd_generic_gc_sections
+#define bfd_pef_bfd_merge_sections bfd_generic_merge_sections
+#define bfd_pef_bfd_discard_group bfd_generic_discard_group
+#define bfd_pef_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define bfd_pef_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#define bfd_pef_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define bfd_pef_bfd_link_just_syms _bfd_generic_link_just_syms
+#define bfd_pef_bfd_final_link _bfd_generic_final_link
+#define bfd_pef_bfd_link_split_section _bfd_generic_link_split_section
+#define bfd_pef_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
+static void bfd_pef_print_symbol
+PARAMS ((bfd *abfd, PTR afile, asymbol *symbol, bfd_print_symbol_type how));
+static void bfd_pef_convert_architecture
+PARAMS ((unsigned long architecture,
+ enum bfd_architecture *type, unsigned long *subtype));
+static boolean bfd_pef_mkobject PARAMS ((bfd *abfd));
+static int bfd_pef_parse_traceback_table
+PARAMS ((bfd *abfd, asection *section, unsigned char *buf,
+ size_t len, size_t pos, asymbol *sym, FILE *file));
+static const char *bfd_pef_section_name PARAMS ((bfd_pef_section *section));
+static unsigned long bfd_pef_section_flags PARAMS ((bfd_pef_section *section));
+static asection *bfd_pef_make_bfd_section
+PARAMS ((bfd *abfd, bfd_pef_section *section));
+static int bfd_pef_read_header PARAMS ((bfd *abfd, bfd_pef_header *header));
+static const bfd_target *bfd_pef_object_p PARAMS ((bfd *));
+static int bfd_pef_parse_traceback_tables
+PARAMS ((bfd *abfd, asection *sec, unsigned char *buf,
+ size_t len, long *nsym, asymbol **csym));
+static int bfd_pef_parse_function_stub
+PARAMS ((bfd *abfd, unsigned char *buf, size_t len, unsigned long *offset));
+static int bfd_pef_parse_function_stubs
+PARAMS ((bfd *abfd, asection *codesec, unsigned char *codebuf, size_t codelen,
+ unsigned char *loaderbuf, size_t loaderlen, unsigned long *nsym,
+ asymbol **csym));
+static long bfd_pef_parse_symbols PARAMS ((bfd *abfd, asymbol **csym));
+static long bfd_pef_count_symbols PARAMS ((bfd *abfd));
+static long bfd_pef_get_symtab_upper_bound PARAMS ((bfd *));
+static long bfd_pef_get_symtab PARAMS ((bfd *, asymbol **));
+static asymbol *bfd_pef_make_empty_symbol PARAMS ((bfd *));
+static void bfd_pef_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
+static int bfd_pef_sizeof_headers PARAMS ((bfd *, boolean));
+
+static int bfd_pef_xlib_read_header
+PARAMS ((bfd *abfd, bfd_pef_xlib_header *header));
+static int bfd_pef_xlib_scan PARAMS ((bfd *abfd, bfd_pef_xlib_header *header));
+static const bfd_target *bfd_pef_xlib_object_p PARAMS ((bfd *abfd));
+
+static void
+bfd_pef_print_symbol (abfd, afile, symbol, how)
+ bfd *abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
+{
+ FILE *file = (FILE *) afile;
+ switch (how)
+ {
+ case bfd_print_symbol_name:
+ fprintf (file, "%s", symbol->name);
+ break;
+ default:
+ bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
+ fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
+ if (strncmp (symbol->name, "__traceback_", strlen ("__traceback_")) == 0)
+ {
+ char *buf = alloca (symbol->udata.i);
+ size_t offset = symbol->value + 4;
+ size_t len = symbol->udata.i;
+ int ret;
+
+ bfd_get_section_contents (abfd, symbol->section, buf, offset, len);
+ ret = bfd_pef_parse_traceback_table (abfd, symbol->section, buf,
+ len, 0, NULL, file);
+ if (ret < 0)
+ fprintf (file, " [ERROR]");
+ }
+ }
+}
+
+static void
+bfd_pef_convert_architecture (architecture, type, subtype)
+ unsigned long architecture;
+ enum bfd_architecture *type;
+ unsigned long *subtype;
+{
+ const unsigned long ARCH_POWERPC = 0x70777063; /* 'pwpc' */
+ const unsigned long ARCH_M68K = 0x6d36386b; /* 'm68k' */
+
+ *subtype = bfd_arch_unknown;
+ *type = bfd_arch_unknown;
+
+ if (architecture == ARCH_POWERPC)
+ *type = bfd_arch_powerpc;
+ else if (architecture == ARCH_M68K)
+ *type = bfd_arch_m68k;
+}
+
+static boolean
+bfd_pef_mkobject (abfd)
+ bfd *abfd ATTRIBUTE_UNUSED;
+{
+ return true;
+}
+
+static int
+bfd_pef_parse_traceback_table (abfd, section, buf, len, pos, sym, file)
+ bfd *abfd;
+ asection *section;
+ unsigned char *buf;
+ size_t len;
+ size_t pos;
+ asymbol *sym;
+ FILE *file;
+{
+ struct traceback_table table;
+ size_t offset;
+ const char *s;
+ asymbol tmpsymbol;
+
+ if (sym == NULL)
+ sym = &tmpsymbol;
+
+ sym->name = NULL;
+ sym->value = 0;
+ sym->the_bfd = abfd;
+ sym->section = section;
+ sym->flags = 0;
+ sym->udata.i = 0;
+
+ /* memcpy is fine since all fields are unsigned char */
+
+ if ((pos + 8) > len)
+ return -1;
+ memcpy (&table, buf + pos, 8);
+
+ /* calling code relies on returned symbols having a name and
+ correct offset */
+
+ if ((table.lang != TB_C) && (table.lang != TB_CPLUSPLUS))
+ return -1;
+
+ if (! (table.flags2 & TB_NAME_PRESENT))
+ return -1;
+
+ if (! table.flags1 & TB_HAS_TBOFF)
+ return -1;
+
+ offset = 8;
+
+ if ((table.flags5 & TB_FLOATPARAMS) || (table.fixedparams))
+ offset += 4;
+
+ if (table.flags1 & TB_HAS_TBOFF)
+ {
+ struct traceback_table_tboff off;
+
+ if ((pos + offset + 4) > len)
+ return -1;
+ off.tb_offset = bfd_getb32 (buf + pos + offset);
+ offset += 4;
+
+ /* need to subtract 4 because the offset includes the 0x0L
+ preceding the table */
+
+ if (file != NULL)
+ fprintf (file, " [offset = 0x%lx]", off.tb_offset);
+
+ if ((file == NULL) && ((off.tb_offset + 4) > (pos + offset)))
+ return -1;
+
+ sym->value = pos - off.tb_offset - 4;
+ }
+
+ if (table.flags2 & TB_INT_HNDL)
+ offset += 4;
+
+ if (table.flags1 & TB_HAS_CTL)
+ {
+ struct traceback_table_anchors anchors;
+
+ if ((pos + offset + 4) > len)
+ return -1;
+ anchors.ctl_info = bfd_getb32 (buf + pos + offset);
+ offset += 4;
+
+ if (anchors.ctl_info > 1024)
+ return -1;
+
+ offset += anchors.ctl_info * 4;
+ }
+
+ if (table.flags2 & TB_NAME_PRESENT)
+ {
+ struct traceback_table_routine name;
+ char *namebuf;
+
+ if ((pos + offset + 2) > len)
+ return -1;
+ name.name_len = bfd_getb16 (buf + pos + offset);
+ offset += 2;
+
+ if (name.name_len > 4096)
+ return -1;
+
+ if ((pos + offset + name.name_len) > len)
+ return -1;
+
+ namebuf = (char *) bfd_alloc (abfd, name.name_len + 1);
+ if (namebuf == NULL)
+ return -1;
+
+ memcpy (namebuf, buf + pos + offset, name.name_len);
+ namebuf[name.name_len] = '\0';
+
+ /* strip leading period inserted by compiler */
+ if (namebuf[0] == '.')
+ memmove (namebuf, namebuf + 1, name.name_len + 1);
+
+ sym->name = namebuf;
+
+ for (s = sym->name; (*s != '\0'); s++)
+ if (! isprint (*s))
+ return -1;
+
+ offset += name.name_len;
+ }
+
+ if (table.flags2 & TB_USES_ALLOCA)
+ offset += 4;
+
+ if (table.flags4 & TB_HAS_VEC_INFO)
+ offset += 4;
+
+ if (file != NULL)
+ fprintf (file, " [length = 0x%lx]", (long) offset);
+
+ return offset;
+}
+
+static const char *bfd_pef_section_name (section)
+ bfd_pef_section *section;
+{
+ switch (section->section_kind)
+ {
+ case BFD_PEF_SECTION_CODE: return "code";
+ case BFD_PEF_SECTION_UNPACKED_DATA: return "unpacked-data";
+ case BFD_PEF_SECTION_PACKED_DATA: return "packed-data";
+ case BFD_PEF_SECTION_CONSTANT: return "constant";
+ case BFD_PEF_SECTION_LOADER: return "loader";
+ case BFD_PEF_SECTION_DEBUG: return "debug";
+ case BFD_PEF_SECTION_EXEC_DATA: return "exec-data";
+ case BFD_PEF_SECTION_EXCEPTION: return "exception";
+ case BFD_PEF_SECTION_TRACEBACK: return "traceback";
+ default: return "unknown";
+ }
+}
+
+static unsigned long bfd_pef_section_flags (section)
+ bfd_pef_section *section;
+{
+ switch (section->section_kind)
+ {
+ case BFD_PEF_SECTION_CODE:
+ return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+ case BFD_PEF_SECTION_UNPACKED_DATA:
+ case BFD_PEF_SECTION_PACKED_DATA:
+ case BFD_PEF_SECTION_CONSTANT:
+ case BFD_PEF_SECTION_LOADER:
+ case BFD_PEF_SECTION_DEBUG:
+ case BFD_PEF_SECTION_EXEC_DATA:
+ case BFD_PEF_SECTION_EXCEPTION:
+ case BFD_PEF_SECTION_TRACEBACK:
+ default:
+ return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+ }
+}
+
+static asection *
+bfd_pef_make_bfd_section (abfd, section)
+ bfd *abfd;
+ bfd_pef_section *section;
+{
+ asection *bfdsec;
+ const char *name = bfd_pef_section_name (section);
+
+ bfdsec = bfd_make_section_anyway (abfd, name);
+ if (bfdsec == NULL)
+ return NULL;
+
+ bfdsec->vma = section->default_address + section->container_offset;
+ bfdsec->lma = section->default_address + section->container_offset;
+ bfdsec->_raw_size = section->container_length;
+ bfdsec->filepos = section->container_offset;
+ bfdsec->alignment_power = section->alignment;
+
+ bfdsec->flags = bfd_pef_section_flags (section);
+
+ return bfdsec;
+}
+
+int bfd_pef_parse_loader_header (abfd, buf, len, header)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ unsigned char *buf;
+ size_t len;
+ bfd_pef_loader_header *header;
+{
+ BFD_ASSERT (len == 56);
+
+ header->main_section = bfd_getb32 (buf);
+ header->main_offset = bfd_getb32 (buf + 4);
+ header->init_section = bfd_getb32 (buf + 8);
+ header->init_offset = bfd_getb32 (buf + 12);
+ header->term_section = bfd_getb32 (buf + 16);
+ header->term_offset = bfd_getb32 (buf + 20);
+ header->imported_library_count = bfd_getb32 (buf + 24);
+ header->total_imported_symbol_count = bfd_getb32 (buf + 28);
+ header->reloc_section_count = bfd_getb32 (buf + 32);
+ header->reloc_instr_offset = bfd_getb32 (buf + 36);
+ header->loader_strings_offset = bfd_getb32 (buf + 40);
+ header->export_hash_offset = bfd_getb32 (buf + 44);
+ header->export_hash_table_power = bfd_getb32 (buf + 48);
+ header->exported_symbol_count = bfd_getb32 (buf + 52);
+
+ return 0;
+}
+
+int bfd_pef_parse_imported_library (abfd, buf, len, header)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ unsigned char *buf;
+ size_t len;
+ bfd_pef_imported_library *header;
+{
+ BFD_ASSERT (len == 24);
+
+ header->name_offset = bfd_getb32 (buf);
+ header->old_implementation_version = bfd_getb32 (buf + 4);
+ header->current_version = bfd_getb32 (buf + 8);
+ header->imported_symbol_count = bfd_getb32 (buf + 12);
+ header->first_imported_symbol = bfd_getb32 (buf + 16);
+ header->options = buf[20];
+ header->reserved_a = buf[21];
+ header->reserved_b = bfd_getb16 (buf + 22);
+
+ return 0;
+}
+
+int bfd_pef_parse_imported_symbol (abfd, buf, len, symbol)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ unsigned char *buf;
+ size_t len;
+ bfd_pef_imported_symbol *symbol;
+{
+ unsigned long value;
+
+ BFD_ASSERT (len == 4);
+
+ value = bfd_getb32 (buf);
+ symbol->class = value >> 24;
+ symbol->name = value & 0x00ffffff;
+
+ return 0;
+}
+
+int bfd_pef_scan_section (abfd, section)
+ bfd *abfd;
+ bfd_pef_section *section;
+{
+ unsigned char buf[28];
+
+ bfd_seek (abfd, section->header_offset, SEEK_SET);
+ if (bfd_bread ((PTR) buf, 28, abfd) != 28)
+ return -1;
+
+ section->name_offset = bfd_h_get_32 (abfd, buf);
+ section->default_address = bfd_h_get_32 (abfd, buf + 4);
+ section->total_length = bfd_h_get_32 (abfd, buf + 8);
+ section->unpacked_length = bfd_h_get_32 (abfd, buf + 12);
+ section->container_length = bfd_h_get_32 (abfd, buf + 16);
+ section->container_offset = bfd_h_get_32 (abfd, buf + 20);
+ section->section_kind = buf[24];
+ section->share_kind = buf[25];
+ section->alignment = buf[26];
+ section->reserved = buf[27];
+
+ section->bfd_section = bfd_pef_make_bfd_section (abfd, section);
+ if (section->bfd_section == NULL)
+ return -1;
+
+ return 0;
+}
+
+void
+bfd_pef_print_loader_header (abfd, header, file)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_pef_loader_header *header;
+ FILE *file;
+{
+ fprintf (file, "main_section: %ld\n", header->main_section);
+ fprintf (file, "main_offset: %lu\n", header->main_offset);
+ fprintf (file, "init_section: %ld\n", header->init_section);
+ fprintf (file, "init_offset: %lu\n", header->init_offset);
+ fprintf (file, "term_section: %ld\n", header->term_section);
+ fprintf (file, "term_offset: %lu\n", header->term_offset);
+ fprintf (file, "imported_library_count: %lu\n",
+ header->imported_library_count);
+ fprintf (file, "total_imported_symbol_count: %lu\n",
+ header->total_imported_symbol_count);
+ fprintf (file, "reloc_section_count: %lu\n", header->reloc_section_count);
+ fprintf (file, "reloc_instr_offset: %lu\n", header->reloc_instr_offset);
+ fprintf (file, "loader_strings_offset: %lu\n",
+ header->loader_strings_offset);
+ fprintf (file, "export_hash_offset: %lu\n", header->export_hash_offset);
+ fprintf (file, "export_hash_table_power: %lu\n",
+ header->export_hash_table_power);
+ fprintf (file, "exported_symbol_count: %lu\n",
+ header->exported_symbol_count);
+}
+
+int
+bfd_pef_print_loader_section (abfd, file)
+ bfd *abfd;
+ FILE *file;
+{
+ bfd_pef_loader_header header;
+ asection *loadersec = NULL;
+ unsigned char *loaderbuf = NULL;
+ size_t loaderlen = 0;
+ int ret;
+
+ loadersec = bfd_get_section_by_name (abfd, "loader");
+ if (loadersec == NULL)
+ return -1;
+
+ loaderlen = bfd_section_size (abfd, loadersec);
+ loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
+ if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
+ {
+ free (loaderbuf);
+ return -1;
+ }
+ if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
+ {
+ free (loaderbuf);
+ return -1;
+ }
+
+ if (loaderlen < 56)
+ {
+ free (loaderbuf);
+ return -1;
+ }
+ ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
+ if (ret < 0)
+ {
+ free (loaderbuf);
+ return -1;
+ }
+
+ bfd_pef_print_loader_header (abfd, &header, file);
+ return 0;
+}
+
+int
+bfd_pef_scan_start_address (abfd)
+ bfd *abfd;
+{
+ bfd_pef_loader_header header;
+ asection *section;
+
+ asection *loadersec = NULL;
+ unsigned char *loaderbuf = NULL;
+ size_t loaderlen = 0;
+ int ret;
+
+ loadersec = bfd_get_section_by_name (abfd, "loader");
+ if (loadersec == NULL)
+ goto end;
+
+ loaderlen = bfd_section_size (abfd, loadersec);
+ loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
+ if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
+ goto error;
+ if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
+ goto error;
+
+ if (loaderlen < 56)
+ goto error;
+ ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
+ if (ret < 0)
+ goto error;
+
+ if (header.main_section < 0)
+ goto end;
+
+ for (section = abfd->sections; section != NULL; section = section->next)
+ if ((section->index + 1) == header.main_section)
+ break;
+
+ if (section == NULL)
+ goto error;
+
+ abfd->start_address = section->vma + header.main_offset;
+
+ end:
+ if (loaderbuf != NULL)
+ free (loaderbuf);
+ return 0;
+
+ error:
+ if (loaderbuf != NULL)
+ free (loaderbuf);
+ return -1;
+}
+
+int
+bfd_pef_scan (abfd, header, mdata)
+ bfd *abfd;
+ bfd_pef_header *header;
+ bfd_pef_data_struct *mdata;
+{
+ unsigned int i;
+ enum bfd_architecture cputype;
+ unsigned long cpusubtype;
+
+ mdata->header = *header;
+
+ bfd_pef_convert_architecture (header->architecture, &cputype, &cpusubtype);
+ if (cputype == bfd_arch_unknown)
+ {
+ fprintf (stderr, "bfd_pef_scan: unknown architecture 0x%lx\n",
+ header->architecture);
+ return -1;
+ }
+ bfd_set_arch_mach (abfd, cputype, cpusubtype);
+
+ mdata->header = *header;
+
+ abfd->flags = (abfd->xvec->object_flags
+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
+
+ if (header->section_count != 0)
+ {
+ mdata->sections =
+ ((bfd_pef_section *)
+ bfd_alloc (abfd, header->section_count * sizeof (bfd_pef_section)));
+
+ if (mdata->sections == NULL)
+ return -1;
+
+ for (i = 0; i < header->section_count; i++)
+ {
+ bfd_pef_section *cur = &mdata->sections[i];
+ cur->header_offset = 40 + (i * 28);
+ if (bfd_pef_scan_section (abfd, cur) < 0)
+ return -1;
+ }
+ }
+
+ if (bfd_pef_scan_start_address (abfd) < 0)
+ {
+#if 0
+ fprintf (stderr, "bfd_pef_scan: unable to scan start address: %s\n",
+ bfd_errmsg (bfd_get_error ()));
+ return -1;
+#endif
+ }
+
+ abfd->tdata.pef_data = mdata;
+
+ return 0;
+}
+
+static int
+bfd_pef_read_header (abfd, header)
+ bfd *abfd;
+ bfd_pef_header *header;
+{
+ unsigned char buf[40];
+
+ bfd_seek (abfd, 0, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 40, abfd) != 40)
+ return -1;
+
+ header->tag1 = bfd_getb32 (buf);
+ header->tag2 = bfd_getb32 (buf + 4);
+ header->architecture = bfd_getb32 (buf + 8);
+ header->format_version = bfd_getb32 (buf + 12);
+ header->timestamp = bfd_getb32 (buf + 16);
+ header->old_definition_version = bfd_getb32 (buf + 20);
+ header->old_implementation_version = bfd_getb32 (buf + 24);
+ header->current_version = bfd_getb32 (buf + 28);
+ header->section_count = bfd_getb32 (buf + 32) + 1;
+ header->instantiated_section_count = bfd_getb32 (buf + 34);
+ header->reserved = bfd_getb32 (buf + 36);
+
+ return 0;
+}
+
+static const bfd_target *
+bfd_pef_object_p (abfd)
+ bfd *abfd;
+{
+ struct bfd_preserve preserve;
+ bfd_pef_header header;
+
+ preserve.marker = NULL;
+ if (bfd_pef_read_header (abfd, &header) != 0)
+ goto wrong;
+
+ if (header.tag1 != BFD_PEF_TAG1 || header.tag2 != BFD_PEF_TAG2)
+ goto wrong;
+
+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_pef_data_struct));
+ if (preserve.marker == NULL
+ || !bfd_preserve_save (abfd, &preserve))
+ goto fail;
+
+ if (bfd_pef_scan (abfd, &header,
+ (bfd_pef_data_struct *) preserve.marker) != 0)
+ goto wrong;
+
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
+
+ wrong:
+ bfd_set_error (bfd_error_wrong_format);
+
+ fail:
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
+ return NULL;
+}
+
+static int bfd_pef_parse_traceback_tables (abfd, sec, buf, len, nsym, csym)
+ bfd *abfd;
+ asection *sec;
+ unsigned char *buf;
+ size_t len;
+ long *nsym;
+ asymbol **csym;
+{
+ char *name;
+
+ asymbol function;
+ asymbol traceback;
+
+ const char *const tbprefix = "__traceback_";
+ size_t tbnamelen;
+
+ size_t pos = 0;
+ unsigned long count = 0;
+ int ret;
+
+ for (;;)
+ {
+ /* we're reading symbols two at a time */
+
+ if (csym && ((csym[count] == NULL) || (csym[count + 1] == NULL)))
+ break;
+
+ pos += 3;
+ pos -= (pos % 4);
+
+ while ((pos + 4) <= len)
+ {
+ if (bfd_getb32 (buf + pos) == 0)
+ break;
+ pos += 4;
+ }
+
+ if ((pos + 4) > len)
+ break;
+
+ ret = bfd_pef_parse_traceback_table (abfd, sec, buf, len, pos + 4,
+ &function, 0);
+ if (ret < 0)
+ {
+ /* skip over 0x0L to advance to next possible traceback table */
+ pos += 4;
+ continue;
+ }
+
+ BFD_ASSERT (function.name != NULL);
+
+ /* Don't bother to compute the name if we are just
+ counting symbols */
+
+ if (csym)
+ {
+ tbnamelen = strlen (tbprefix) + strlen (function.name);
+ name = bfd_alloc (abfd, tbnamelen + 1);
+ if (name == NULL)
+ {
+ bfd_release (abfd, (PTR) function.name);
+ function.name = NULL;
+ break;
+ }
+ snprintf (name, tbnamelen + 1, "%s%s", tbprefix, function.name);
+ traceback.name = name;
+ traceback.value = pos;
+ traceback.the_bfd = abfd;
+ traceback.section = sec;
+ traceback.flags = 0;
+ traceback.udata.i = ret;
+
+ *(csym[count]) = function;
+ *(csym[count + 1]) = traceback;
+ }
+
+ pos += ret;
+ count += 2;
+ }
+
+ *nsym = count;
+ return 0;
+}
+
+static int bfd_pef_parse_function_stub (abfd, buf, len, offset)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ unsigned char *buf;
+ size_t len;
+ unsigned long *offset;
+{
+ BFD_ASSERT (len == 24);
+
+ if ((bfd_getb32 (buf) & 0xffff0000) != 0x81820000)
+ return -1;
+ if (bfd_getb32 (buf + 4) != 0x90410014)
+ return -1;
+ if (bfd_getb32 (buf + 8) != 0x800c0000)
+ return -1;
+ if (bfd_getb32 (buf + 12) != 0x804c0004)
+ return -1;
+ if (bfd_getb32 (buf + 16) != 0x7c0903a6)
+ return -1;
+ if (bfd_getb32 (buf + 20) != 0x4e800420)
+ return -1;
+
+ if (offset != NULL)
+ *offset = (bfd_getb32 (buf) & 0x0000ffff) / 4;
+
+ return 0;
+}
+
+static int bfd_pef_parse_function_stubs (abfd, codesec, codebuf, codelen,
+ loaderbuf, loaderlen, nsym, csym)
+ bfd *abfd;
+ asection *codesec;
+ unsigned char *codebuf;
+ size_t codelen;
+ unsigned char *loaderbuf;
+ size_t loaderlen;
+ unsigned long *nsym;
+ asymbol **csym;
+{
+ const char *const sprefix = "__stub_";
+
+ size_t codepos = 0;
+ unsigned long count = 0;
+
+ bfd_pef_loader_header header;
+ bfd_pef_imported_library *libraries = NULL;
+ bfd_pef_imported_symbol *imports = NULL;
+
+ unsigned long i;
+ int ret;
+
+ if (loaderlen < 56)
+ goto error;
+
+ ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
+ if (ret < 0)
+ goto error;
+
+ libraries = (bfd_pef_imported_library *) bfd_malloc
+ (header.imported_library_count * sizeof (bfd_pef_imported_library));
+ imports = (bfd_pef_imported_symbol *) bfd_malloc
+ (header.total_imported_symbol_count * sizeof (bfd_pef_imported_symbol));
+
+ if (loaderlen < (56 + (header.imported_library_count * 24)))
+ goto error;
+ for (i = 0; i < header.imported_library_count; i++)
+ {
+ ret = bfd_pef_parse_imported_library
+ (abfd, loaderbuf + 56 + (i * 24), 24, &libraries[i]);
+ if (ret < 0)
+ goto error;
+ }
+
+ if (loaderlen < (56 + (header.imported_library_count * 24)
+ + (header.total_imported_symbol_count * 4)))
+ goto error;
+ for (i = 0; i < header.total_imported_symbol_count; i++)
+ {
+ ret = (bfd_pef_parse_imported_symbol
+ (abfd,
+ loaderbuf + 56 + (header.imported_library_count * 24) + (i * 4),
+ 4, &imports[i]));
+ if (ret < 0)
+ goto error;
+ }
+
+ codepos = 0;
+
+ for (;;)
+ {
+ asymbol sym;
+ const char *symname;
+ char *name;
+ unsigned long index;
+ int ret;
+
+ if (csym && (csym[count] == NULL))
+ break;
+
+ codepos += 3;
+ codepos -= (codepos % 4);
+
+ while ((codepos + 4) <= codelen)
+ {
+ if ((bfd_getb32 (codebuf + codepos) & 0xffff0000) == 0x81820000)
+ break;
+ codepos += 4;
+ }
+
+ if ((codepos + 4) > codelen)
+ break;
+
+ ret = bfd_pef_parse_function_stub (abfd, codebuf + codepos, 24, &index);
+ if (ret < 0)
+ {
+ codepos += 24;
+ continue;
+ }
+
+ if (index >= header.total_imported_symbol_count)
+ {
+ codepos += 24;
+ continue;
+ }
+
+ {
+ size_t max, namelen;
+ const char *s;
+
+ if (loaderlen < (header.loader_strings_offset + imports[index].name))
+ goto error;
+
+ max = loaderlen - (header.loader_strings_offset + imports[index].name);
+ symname = loaderbuf + header.loader_strings_offset + imports[index].name;
+ namelen = 0;
+ for (s = symname; s < (symname + max); s++)
+ {
+ if (*s == '\0')
+ break;
+ if (! isprint (*s))
+ goto error;
+ namelen++;
+ }
+ if (*s != '\0')
+ goto error;
+
+ name = bfd_alloc (abfd, strlen (sprefix) + namelen + 1);
+ if (name == NULL)
+ break;
+
+ snprintf (name, strlen (sprefix) + namelen + 1, "%s%s",
+ sprefix, symname);
+ sym.name = name;
+ }
+
+ sym.value = codepos;
+ sym.the_bfd = abfd;
+ sym.section = codesec;
+ sym.flags = 0;
+ sym.udata.i = 0;
+
+ codepos += 24;
+
+ if (csym != NULL)
+ *(csym[count]) = sym;
+
+ count++;
+ }
+
+ goto end;
+
+ end:
+ if (libraries != NULL)
+ free (libraries);
+ if (imports != NULL)
+ free (imports);
+ *nsym = count;
+ return 0;
+
+ error:
+ if (libraries != NULL)
+ free (libraries);
+ if (imports != NULL)
+ free (imports);
+ *nsym = count;
+ return -1;
+}
+
+static long bfd_pef_parse_symbols (abfd, csym)
+ bfd *abfd;
+ asymbol **csym;
+{
+ unsigned long count = 0;
+
+ asection *codesec = NULL;
+ unsigned char *codebuf = NULL;
+ size_t codelen = 0;
+
+ asection *loadersec = NULL;
+ unsigned char *loaderbuf = NULL;
+ size_t loaderlen = 0;
+
+ codesec = bfd_get_section_by_name (abfd, "code");
+ if (codesec != NULL)
+ {
+ codelen = bfd_section_size (abfd, codesec);
+ codebuf = (unsigned char *) bfd_malloc (codelen);
+ if (bfd_seek (abfd, codesec->filepos, SEEK_SET) < 0)
+ goto end;
+ if (bfd_bread ((PTR) codebuf, codelen, abfd) != codelen)
+ goto end;
+ }
+
+ loadersec = bfd_get_section_by_name (abfd, "loader");
+ if (loadersec != NULL)
+ {
+ loaderlen = bfd_section_size (abfd, loadersec);
+ loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
+ if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
+ goto end;
+ if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
+ goto end;
+ }
+
+ count = 0;
+ if (codesec != NULL)
+ {
+ unsigned long ncount = 0;
+ bfd_pef_parse_traceback_tables (abfd, codesec, codebuf, codelen,
+ &ncount, csym);
+ count += ncount;
+ }
+
+ if ((codesec != NULL) && (loadersec != NULL))
+ {
+ unsigned long ncount = 0;
+ bfd_pef_parse_function_stubs
+ (abfd, codesec, codebuf, codelen, loaderbuf, loaderlen, &ncount,
+ (csym != NULL) ? (csym + count) : NULL);
+ count += ncount;
+ }
+
+ if (csym != NULL)
+ csym[count] = NULL;
+
+ end:
+ if (codebuf != NULL)
+ free (codebuf);
+
+ if (loaderbuf != NULL)
+ free (loaderbuf);
+
+ return count;
+}
+
+static long
+bfd_pef_count_symbols (abfd)
+ bfd *abfd;
+{
+ return bfd_pef_parse_symbols (abfd, NULL);
+}
+
+static long
+bfd_pef_get_symtab_upper_bound (abfd)
+ bfd *abfd;
+{
+ long nsyms = bfd_pef_count_symbols (abfd);
+ if (nsyms < 0)
+ return nsyms;
+ return ((nsyms + 1) * sizeof (asymbol *));
+}
+
+static long
+bfd_pef_get_symtab (abfd, alocation)
+ bfd *abfd;
+ asymbol **alocation;
+{
+ long i;
+ asymbol *syms;
+ long ret;
+
+ long nsyms = bfd_pef_count_symbols (abfd);
+ if (nsyms < 0)
+ return nsyms;
+
+ syms = bfd_alloc (abfd, nsyms * sizeof (asymbol));
+ if (syms == NULL)
+ return -1;
+
+ for (i = 0; i < nsyms; i++)
+ alocation[i] = &syms[i];
+
+ alocation[nsyms] = NULL;
+
+ ret = bfd_pef_parse_symbols (abfd, alocation);
+ if (ret != nsyms)
+ return 0;
+
+ return ret;
+}
+
+static asymbol *
+bfd_pef_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+}
+
+static void
+bfd_pef_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+static int
+bfd_pef_sizeof_headers (abfd, exec)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ boolean exec ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+const bfd_target pef_vec =
+{
+ "pef", /* name */
+ bfd_target_pef_flavour, /* flavour */
+ BFD_ENDIAN_BIG, /* byteorder */
+ BFD_ENDIAN_BIG, /* header_byteorder */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ bfd_pef_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ bfd_pef_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_pef),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (bfd_pef),
+ BFD_JUMP_TABLE_RELOCS (bfd_pef),
+ BFD_JUMP_TABLE_WRITE (bfd_pef),
+ BFD_JUMP_TABLE_LINK (bfd_pef),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL,
+
+ NULL
+};
+
+#define bfd_pef_xlib_close_and_cleanup _bfd_generic_close_and_cleanup
+#define bfd_pef_xlib_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define bfd_pef_xlib_new_section_hook _bfd_generic_new_section_hook
+#define bfd_pef_xlib_get_section_contents _bfd_generic_get_section_contents
+#define bfd_pef_xlib_set_section_contents _bfd_generic_set_section_contents
+#define bfd_pef_xlib_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define bfd_pef_xlib_set_section_contents_in_window _bfd_generic_set_section_contents_in_window
+
+static int
+bfd_pef_xlib_read_header (abfd, header)
+ bfd *abfd;
+ bfd_pef_xlib_header *header;
+{
+ unsigned char buf[76];
+
+ bfd_seek (abfd, 0, SEEK_SET);
+
+ if (bfd_bread ((PTR) buf, 76, abfd) != 76)
+ return -1;
+
+ header->tag1 = bfd_getb32 (buf);
+ header->tag2 = bfd_getb32 (buf + 4);
+ header->current_format = bfd_getb32 (buf + 8);
+ header->container_strings_offset = bfd_getb32 (buf + 12);
+ header->export_hash_offset = bfd_getb32 (buf + 16);
+ header->export_key_offset = bfd_getb32 (buf + 20);
+ header->export_symbol_offset = bfd_getb32 (buf + 24);
+ header->export_names_offset = bfd_getb32 (buf + 28);
+ header->export_hash_table_power = bfd_getb32 (buf + 32);
+ header->exported_symbol_count = bfd_getb32 (buf + 36);
+ header->frag_name_offset = bfd_getb32 (buf + 40);
+ header->frag_name_length = bfd_getb32 (buf + 44);
+ header->dylib_path_offset = bfd_getb32 (buf + 48);
+ header->dylib_path_length = bfd_getb32 (buf + 52);
+ header->cpu_family = bfd_getb32 (buf + 56);
+ header->cpu_model = bfd_getb32 (buf + 60);
+ header->date_time_stamp = bfd_getb32 (buf + 64);
+ header->current_version = bfd_getb32 (buf + 68);
+ header->old_definition_version = bfd_getb32 (buf + 72);
+ header->old_implementation_version = bfd_getb32 (buf + 76);
+
+ return 0;
+}
+
+int
+bfd_pef_xlib_scan (abfd, header)
+ bfd *abfd;
+ bfd_pef_xlib_header *header;
+{
+ bfd_pef_xlib_data_struct *mdata = NULL;
+
+ mdata = ((bfd_pef_xlib_data_struct *)
+ bfd_alloc (abfd, sizeof (bfd_pef_xlib_data_struct)));
+ if (mdata == NULL)
+ return -1;
+
+ mdata->header = *header;
+
+ abfd->flags = (abfd->xvec->object_flags
+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
+
+ abfd->tdata.pef_xlib_data = mdata;
+
+ return 0;
+}
+
+static const bfd_target *
+bfd_pef_xlib_object_p (abfd)
+ bfd *abfd;
+{
+ struct bfd_preserve preserve;
+ bfd_pef_xlib_header header;
+
+ if (bfd_pef_xlib_read_header (abfd, &header) != 0)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if ((header.tag1 != BFD_PEF_XLIB_TAG1)
+ || ((header.tag2 != BFD_PEF_VLIB_TAG2)
+ && (header.tag2 != BFD_PEF_BLIB_TAG2)))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (! bfd_preserve_save (abfd, &preserve))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (bfd_pef_xlib_scan (abfd, &header) != 0)
+ {
+ bfd_preserve_restore (abfd, &preserve);
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
+}
+
+const bfd_target pef_xlib_vec =
+{
+ "pef-xlib", /* name */
+ bfd_target_pef_xlib_flavour, /* flavour */
+ BFD_ENDIAN_BIG, /* byteorder */
+ BFD_ENDIAN_BIG, /* header_byteorder */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ bfd_pef_xlib_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ bfd_pef_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_pef_xlib),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
+ BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+ BFD_JUMP_TABLE_WRITE (_bfd_nowrite),
+ BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL,
+
+ NULL
+};
diff --git a/bfd/pef.h b/bfd/pef.h
new file mode 100644
index 00000000000..caeb710e16e
--- /dev/null
+++ b/bfd/pef.h
@@ -0,0 +1,186 @@
+/* PEF support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ 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 <stdio.h>
+
+struct bfd_pef_header
+{
+ unsigned long tag1;
+ unsigned long tag2;
+ unsigned long architecture;
+ unsigned long format_version;
+ unsigned long timestamp;
+ unsigned long old_definition_version;
+ unsigned long old_implementation_version;
+ unsigned long current_version;
+ unsigned short section_count;
+ unsigned short instantiated_section_count;
+ unsigned long reserved;
+};
+typedef struct bfd_pef_header bfd_pef_header;
+
+struct bfd_pef_loader_header
+{
+ long main_section;
+ unsigned long main_offset;
+ long init_section;
+ unsigned long init_offset;
+ long term_section;
+ unsigned long term_offset;
+ unsigned long imported_library_count;
+ unsigned long total_imported_symbol_count;
+ unsigned long reloc_section_count;
+ unsigned long reloc_instr_offset;
+ unsigned long loader_strings_offset;
+ unsigned long export_hash_offset;
+ unsigned long export_hash_table_power;
+ unsigned long exported_symbol_count;
+};
+typedef struct bfd_pef_loader_header bfd_pef_loader_header;
+
+struct bfd_pef_imported_library
+{
+ unsigned long name_offset;
+ unsigned long old_implementation_version;
+ unsigned long current_version;
+ unsigned long imported_symbol_count;
+ unsigned long first_imported_symbol;
+ unsigned char options;
+ unsigned char reserved_a;
+ unsigned short reserved_b;
+};
+typedef struct bfd_pef_imported_library bfd_pef_imported_library;
+
+enum bfd_pef_imported_library_options
+ {
+ BFD_PEF_WEAK_IMPORT_LIB = 0x40,
+ BFD_PEF_INIT_LIB_BEFORE = 0x80
+ };
+
+struct bfd_pef_imported_symbol
+{
+ unsigned char class;
+ unsigned long name;
+};
+typedef struct bfd_pef_imported_symbol bfd_pef_imported_symbol;
+
+enum bfd_pef_imported_symbol_class
+ {
+ BFD_PEF_CODE_SYMBOL = 0x00,
+ BFD_PEF_DATA_SYMBOL = 0x01,
+ BFD_PEF_TVECTOR_SYMBOL = 0x02,
+ BFD_PEF_TOC_SYMBOL = 0x03,
+ BFD_PEF_GLUE_SYMBOL = 0x04,
+ BFD_PEF_UNDEFINED_SYMBOL = 0x0F,
+ BFD_PEF_WEAK_IMPORT_SYMBOL_MASK = 0x80
+ };
+
+#define BFD_PEF_TAG1 0x4A6F7921 /* 'Joy!' */
+#define BFD_PEF_TAG2 0x70656666 /* 'peff' */
+
+#define BFD_PEF_VERSION 0x00000001
+
+struct bfd_pef_section
+{
+ long name_offset;
+ unsigned long header_offset;
+ unsigned long default_address;
+ unsigned long total_length;
+ unsigned long unpacked_length;
+ unsigned long container_length;
+ unsigned long container_offset;
+ unsigned char section_kind;
+ unsigned char share_kind;
+ unsigned char alignment;
+ unsigned char reserved;
+ asection *bfd_section;
+};
+typedef struct bfd_pef_section bfd_pef_section;
+
+#define BFD_PEF_SECTION_CODE 0
+#define BFD_PEF_SECTION_UNPACKED_DATA 1
+#define BFD_PEF_SECTION_PACKED_DATA 2
+#define BFD_PEF_SECTION_CONSTANT 3
+#define BFD_PEF_SECTION_LOADER 4
+#define BFD_PEF_SECTION_DEBUG 5
+#define BFD_PEF_SECTION_EXEC_DATA 6
+#define BFD_PEF_SECTION_EXCEPTION 7
+#define BFD_PEF_SECTION_TRACEBACK 8
+
+#define BFD_PEF_SHARE_PROCESS 1
+#define BFD_PEF_SHARE_GLOBAL 4
+#define BFD_PEF_SHARE_PROTECTED 5
+
+struct bfd_pef_data_struct
+{
+ bfd_pef_header header;
+ bfd_pef_section *sections;
+ bfd *ibfd;
+};
+typedef struct bfd_pef_data_struct bfd_pef_data_struct;
+
+#define BFD_PEF_XLIB_TAG1 0xF04D6163 /* '?Mac' */
+#define BFD_PEF_VLIB_TAG2 0x564C6962 /* 'VLib' */
+#define BFD_PEF_BLIB_TAG2 0x424C6962 /* 'BLib' */
+
+#define BFD_PEF_XLIB_VERSION 0x00000001
+
+struct bfd_pef_xlib_header
+{
+ unsigned long tag1;
+ unsigned long tag2;
+ unsigned long current_format;
+ unsigned long container_strings_offset;
+ unsigned long export_hash_offset;
+ unsigned long export_key_offset;
+ unsigned long export_symbol_offset;
+ unsigned long export_names_offset;
+ unsigned long export_hash_table_power;
+ unsigned long exported_symbol_count;
+
+ unsigned long frag_name_offset;
+ unsigned long frag_name_length;
+ unsigned long dylib_path_offset;
+ unsigned long dylib_path_length;
+ unsigned long cpu_family;
+ unsigned long cpu_model;
+ unsigned long date_time_stamp;
+ unsigned long current_version;
+ unsigned long old_definition_version;
+ unsigned long old_implementation_version;
+};
+typedef struct bfd_pef_xlib_header bfd_pef_xlib_header;
+
+struct bfd_pef_xlib_data_struct
+{
+ bfd_pef_xlib_header header;
+};
+typedef struct bfd_pef_xlib_data_struct bfd_pef_xlib_data_struct;
+
+int bfd_pef_parse_loader_header PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_loader_header *));
+int bfd_pef_print_loader_section PARAMS ((bfd *, FILE *));
+void bfd_pef_print_loader_header PARAMS ((bfd *, bfd_pef_loader_header *, FILE *));
+int bfd_pef_parse_imported_library PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_library *));
+int bfd_pef_parse_imported_symbol PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *));
+int bfd_pef_scan_section PARAMS ((bfd *, bfd_pef_section *));
+int bfd_pef_scan_start_address PARAMS ((bfd *));
+int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *, bfd_pef_data_struct *));
diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in
index c95e01ead04..e11e31434ec 100644
--- a/bfd/po/SRC-POTFILES.in
+++ b/bfd/po/SRC-POTFILES.in
@@ -152,8 +152,6 @@ elf32-openrisc.c
elf32-or32.c
elf32-pj.c
elf32-ppc.c
-elf32-qnx.c
-elf32-qnx.h
elf32-s390.c
elf32-sh.c
elf32-sh64-com.c
@@ -225,6 +223,8 @@ m68klinux.c
m68klynx.c
m68knetbsd.c
m88kmach3.c
+mach-o.c
+mach-o.h
merge.c
mipsbsd.c
mmo.c
@@ -253,6 +253,9 @@ pe-mcore.c
pe-mips.c
pe-ppc.c
pe-sh.c
+pef-traceback.h
+pef.c
+pef.h
pei-arm.c
pei-i386.c
pei-mcore.c
@@ -293,3 +296,5 @@ vms.c
vms.h
xcoff-target.h
xcofflink.c
+xsym.c
+xsym.h
diff --git a/bfd/po/da.po b/bfd/po/da.po
index 6f184849c06..89ed7d0ec4e 100644
--- a/bfd/po/da.po
+++ b/bfd/po/da.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: bfd 2.12.91\n"
"POT-Creation-Date: 2002-07-23 15:55-0400\n"
-"PO-Revision-Date: 2002-09-07 21:55+0200\n"
+"PO-Revision-Date: 2002-11-09 23:25+0100\n"
"Last-Translator: Keld Simonsen <keld@dkuug.dk>\n"
"Language-Team: Danish <dansk@klid.dk>\n"
"MIME-Version: 1.0\n"
@@ -21,27 +21,27 @@ msgstr "%s: Ukendt sektionstype i a.out.adobe-fil: %x\n"
#: aout-cris.c:208
#, c-format
msgid "%s: Invalid relocation type exported: %d"
-msgstr "%s: Ugyldig relokaliseringstype eksporteret: %d"
+msgstr "%s: Ugyldig relokeringstype eksporteret: %d"
#: aout-cris.c:252
#, c-format
msgid "%s: Invalid relocation type imported: %d"
-msgstr "%s: Ugyldig relokaliseringstype importeret: %d"
+msgstr "%s: Ugyldig relokeringstype importeret: %d"
#: aout-cris.c:263
#, c-format
msgid "%s: Bad relocation record imported: %d"
-msgstr "%s: Fejlagtig relokaliseringstype importeret: %d"
+msgstr "%s: Fejlagtig relokeringstype importeret: %d"
#: aoutx.h:1282 aoutx.h:1699
#, c-format
msgid "%s: can not represent section `%s' in a.out object file format"
-msgstr "%s: kan ikke representere sektionen \"%s\" i a.out-objektfilformat"
+msgstr "%s: kan ikke repræsentere sektionen \"%s\" i a.out-objektfilformat"
#: aoutx.h:1669
#, c-format
msgid "%s: can not represent section for symbol `%s' in a.out object file format"
-msgstr "%s: kan ikke representere sektion for symbolet \"%s\" i a.out-objektfilformat"
+msgstr "%s: kan ikke repræsentere sektion for symbolet \"%s\" i a.out-objektfilformat"
#: aoutx.h:1671
msgid "*unknown*"
@@ -50,7 +50,7 @@ msgstr "*ukendt*"
#: aoutx.h:3732
#, c-format
msgid "%s: relocateable link from %s to %s not supported"
-msgstr "%s: relokaliseringsbar lænke fra %s til %s understøttes inte"
+msgstr "%s: relokérbar lænke fra %s til %s understøttes ikke"
#: archive.c:1826
msgid "Warning: writing archive was slow: rewriting timestamp\n"
@@ -99,7 +99,7 @@ msgstr "Ingen symboler"
#: bfd.c:282
msgid "Archive has no index; run ranlib to add one"
-msgstr "Arkivet har intet index; kør ranlib for at tilføje ét"
+msgstr "Arkivet har intet indeks; kør ranlib til at tilføje ét"
#: bfd.c:283
msgid "No more archived files"
@@ -181,19 +181,19 @@ msgstr "IHIHALF mangler"
#: coff-a29k.c:212 coff-or32.c:229
msgid "Unrecognized reloc"
-msgstr "Ukendt relokalisering"
+msgstr "Ukendt relokering"
#: coff-a29k.c:408
msgid "missing IHCONST reloc"
-msgstr "IHCONST-relokalisering mangler"
+msgstr "IHCONST-relokering mangler"
#: coff-a29k.c:498
msgid "missing IHIHALF reloc"
-msgstr "IHIHALF-relokalisering mangler"
+msgstr "IHIHALF-relokering mangler"
#: coff-alpha.c:881 coff-alpha.c:918 coff-alpha.c:1989 coff-mips.c:1432
msgid "GP relative relocation used when GP not defined"
-msgstr "GP-relativ relokalisering bruges når GP ikke er defineret"
+msgstr "GP-relativ relokering bruges når GP ikke er defineret"
#: coff-alpha.c:1485
msgid "using multiple gp values"
@@ -231,22 +231,22 @@ msgstr " overvej omlænkning med --support-old-code aktiveret"
#: coff-arm.c:1785 coff-tic80.c:686 cofflink.c:3031
#, c-format
msgid "%s: bad reloc address 0x%lx in section `%s'"
-msgstr "%s: fejlagtig relokaliseringsadresse 0x%lx i sektionen \"%s\""
+msgstr "%s: fejlagtig relokeringsadresse 0x%lx i sektionen \"%s\""
#: coff-arm.c:2127
#, c-format
msgid "%s: illegal symbol index in reloc: %d"
-msgstr "%s: utilladt symbolindex i relokalisering: %d"
+msgstr "%s: ikke tilladt symbolindeks i relokering: %d"
#: coff-arm.c:2255
#, c-format
msgid "ERROR: %s is compiled for APCS-%d, whereas %s is compiled for APCS-%d"
-msgstr "FEJL: %s kompileret for APCS-%d, mens %s er kompileret for APCS-%d"
+msgstr "FEJL: %s oversat for APCS-%d, mens %s er oversat for APCS-%d"
#: coff-arm.c:2270 elf32-arm.h:2297
#, c-format
msgid "ERROR: %s passes floats in float registers, whereas %s passes them in integer registers"
-msgstr "FEJL: %s overfører flydende tal i flydende talsregister, mens %s overfører dem i heltalsregister"
+msgstr "FEJL: %s overfører flydende tal i flydendetalsregister, mens %s overfører dem i heltalsregister"
#: coff-arm.c:2273 elf32-arm.h:2302
#, c-format
@@ -256,12 +256,12 @@ msgstr "FEJL: %s overfører flydende tal i heltalsregister, mens %s overfører dem
#: coff-arm.c:2288
#, c-format
msgid "ERROR: %s is compiled as position independent code, whereas target %s is absolute position"
-msgstr "FEJL: %s er kompileret som positionsuafhængig kode, mens målet %s har absolut position"
+msgstr "FEJL: %s er oversat som positionsuafhængig kode, mens målet %s har absolut position"
#: coff-arm.c:2291
#, c-format
msgid "ERROR: %s is compiled as absolute position code, whereas target %s is position independent"
-msgstr "FEJL: %s er kompileret som kode med absolut position, mens målet %s er positionsuafhængigt"
+msgstr "FEJL: %s er oversat som kode med absolut position, mens målet %s er positionsuafhængigt"
#: coff-arm.c:2320 elf32-arm.h:2358
#, c-format
@@ -322,31 +322,31 @@ msgstr "usikker kaldskonvention for ikke-COFF-symbol"
#: coff-m68k.c:481 coff-mips.c:2429 elf32-m68k.c:2157 elf32-mips.c:1844
msgid "unsupported reloc type"
-msgstr "relokaliseringstypen understøttes ikke"
+msgstr "relokeringstypen understøttes ikke"
#: coff-mips.c:874 elf32-mips.c:1062 elf64-mips.c:1609
msgid "GP relative relocation when _gp not defined"
-msgstr "GP-relativ relokalisering når _gp ikke var defineret"
+msgstr "GP-relativ relokering når _gp ikke var defineret"
#. No other sections should appear in -membedded-pic
#. code.
#: coff-mips.c:2466
msgid "reloc against unsupported section"
-msgstr "relokalisering mod sektion som ikke understøttes"
+msgstr "relokering mod sektion som ikke understøttes"
#: coff-mips.c:2474
msgid "reloc not properly aligned"
-msgstr "relokalisering ikke på lige grænse"
+msgstr "relokering ikke på passende afrundet adresse"
#: coff-rs6000.c:2766
#, c-format
msgid "%s: unsupported relocation type 0x%02x"
-msgstr "%s: relokaliseringstypen 0x%02x understøttes ikke"
+msgstr "%s: relokeringstypen 0x%02x understøttes ikke"
#: coff-rs6000.c:2859
#, c-format
msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
-msgstr "%s: TOC-relokalisering ved 0x%x til symbolet \"%s\" uden nogen TOC-post"
+msgstr "%s: TOC-relokering ved 0x%x til symbolet \"%s\" uden nogen TOC-post"
#: coff-rs6000.c:3590 coff64-rs6000.c:2091
#, c-format
@@ -356,17 +356,17 @@ msgstr "%s: symbolet \"%s\" har ukendt smclas %d"
#: coff-tic54x.c:279 coff-tic80.c:449
#, c-format
msgid "Unrecognized reloc type 0x%x"
-msgstr "Ukendt relokaliseringstype 0x%x"
+msgstr "Ukendt relokeringstype 0x%x"
#: coff-tic54x.c:390 coffcode.h:4974
#, c-format
msgid "%s: warning: illegal symbol index %ld in relocs"
-msgstr "%s: advarsel: utilladt symbolindex %ld i relokaliseringerne"
+msgstr "%s: advarsel: ikke tilladt symbolindeks %ld i relokeringerne"
#: coff-w65.c:363
#, c-format
msgid "ignoring reloc %s\n"
-msgstr "ignorerer relokalisering %s\n"
+msgstr "ignorerer relokering %s\n"
#: coffcode.h:1086
#, c-format
@@ -381,7 +381,7 @@ msgstr "Ukendt TI COFF-mål-id \"0x%x\""
#: coffcode.h:4365
#, c-format
msgid "%s: warning: illegal symbol index %ld in line numbers"
-msgstr "%s: advarsel: utilladt symbolindex %ld i linjenummer"
+msgstr "%s: advarsel: ikke tilladt symbolindeks %ld i linjenumre"
#: coffcode.h:4379
#, c-format
@@ -401,7 +401,7 @@ msgstr "advarsel: %s: lokalt symbol \"%s\" har ingen sektion"
#: coffcode.h:5012
#, c-format
msgid "%s: illegal relocation type %d at address 0x%lx"
-msgstr "%s: utilladt relokaliseringstype %d på adresse 0x%lx"
+msgstr "%s: ikke tilladt relokeringstype %d på adresse 0x%lx"
#: coffgen.c:1661
#, c-format
@@ -416,12 +416,12 @@ msgstr "Advarsel: typen på symbol \"%s\" ændredes fra %d til %d i %s"
#: cofflink.c:2321
#, c-format
msgid "%s: relocs in section `%s', but it has no contents"
-msgstr "%s: relokaliseringer i sektionen \"%s\", men den har intet indhold"
+msgstr "%s: relokeringer i sektionen \"%s\", men den har intet indhold"
#: cofflink.c:2664 coffswap.h:877
#, c-format
msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
-msgstr "%s: %s: relokalisering giver overløb: 0x%lx > 0xffff"
+msgstr "%s: %s: relokering giver overløb: 0x%lx > 0xffff"
#: cofflink.c:2673 coffswap.h:864
#, c-format
@@ -444,7 +444,7 @@ msgstr "Dwarf-fejl: Kan ikke finde sektionen .debug_abbrev."
#: dwarf2.c:560
#, c-format
msgid "Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."
-msgstr "Dwarf-fejl: Forkortningsafstanden (%lu) større end eller lig med størrelsen .debug_abbrev (%lu)."
+msgstr "Dwarf-fejl: Forkortelsesafstanden (%lu) større end eller lig med størrelsen .debug_abbrev (%lu)."
#: dwarf2.c:757
#, c-format
@@ -471,7 +471,7 @@ msgstr "Dwarf-fejl: vanskabt linjenummerssektion."
#: dwarf2.c:1355 dwarf2.c:1566
#, c-format
msgid "Dwarf Error: Could not find abbrev number %u."
-msgstr "Dwarf-fejl: Kunne ikke finde forkortningsnumret %u."
+msgstr "Dwarf-fejl: Kunne ikke finde forkortelsesnumret %u."
#: dwarf2.c:1527
#, c-format
@@ -486,7 +486,7 @@ msgstr "Dwarf-fejl: fandt adressestørrelsen \"%u\", denne læser kan ikke håndter
#: dwarf2.c:1557
#, c-format
msgid "Dwarf Error: Bad abbrev number: %u."
-msgstr "Dwarf-fejl: Fejlagtigt forkortningsnummer: %u."
+msgstr "Dwarf-fejl: Fejlagtigt forkortelsesnummer: %u."
#: ecoff.c:1318
#, c-format
@@ -518,7 +518,7 @@ msgid ""
" End+1 symbol: %-7ld Type: %s"
msgstr ""
"\n"
-" Symbol slut+1: %-7ld Typ: %s"
+" Symbol slut+1: %-7ld Type: %s"
#: ecoff.c:1607
#, c-format
@@ -569,21 +569,21 @@ msgstr ""
#: elf64-sh64.c:1659
#, c-format
msgid "%s: warning: unresolvable relocation against symbol `%s' from %s section"
-msgstr "%s: advarsel: uløselig relokalisering mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: advarsel: uløselig relokering mod symbol \"%s\" fra sektionen %s"
#: elf-m10200.c:446 elf-m10300.c:656 elf32-arm.h:2084 elf32-avr.c:833
#: elf32-cris.c:1403 elf32-d10v.c:481 elf32-fr30.c:635 elf32-frv.c:809
#: elf32-h8300.c:548 elf32-i860.c:1031 elf32-m32r.c:1278 elf32-openrisc.c:439
#: elf32-v850.c:1691 elf32-xstormy16.c:933 elf64-mmix.c:1302
msgid "internal error: out of range error"
-msgstr "intern fejl: udenfor intervallet"
+msgstr "intern fejl: uden for intervallet"
#: elf-m10200.c:450 elf-m10300.c:660 elf32-arm.h:2088 elf32-avr.c:837
#: elf32-cris.c:1407 elf32-d10v.c:485 elf32-fr30.c:639 elf32-frv.c:813
#: elf32-h8300.c:552 elf32-i860.c:1035 elf32-m32r.c:1282 elf32-openrisc.c:443
#: elf32-v850.c:1695 elf32-xstormy16.c:937 elf64-mmix.c:1306 elfxx-mips.c:5264
msgid "internal error: unsupported relocation error"
-msgstr "intern fejl: relokaliseringen understøttes ikke"
+msgstr "intern fejl: relokeringen understøttes ikke"
#: elf-m10200.c:454 elf-m10300.c:664 elf32-arm.h:2092 elf32-d10v.c:489
#: elf32-h8300.c:556 elf32-m32r.c:1286
@@ -652,7 +652,7 @@ msgstr " kræves fra %s:\n"
#: elf.c:1902
#, c-format
msgid "%s: invalid link %lu for reloc section %s (index %u)"
-msgstr "%s: ugyldig lænke %lu for relokaliseringssektion %s (index %u)"
+msgstr "%s: ugyldig lænke %lu for relokeringssektion %s (indeks %u)"
#: elf.c:3603
#, c-format
@@ -677,7 +677,7 @@ msgstr "%s: advarsel: allokeret sektion \"%s\" ikke i segment"
#: elf.c:4472
#, c-format
msgid "%s: symbol `%s' required but not present"
-msgstr "%s: symbol \"%s\" kræves men er ikke tilstede"
+msgstr "%s: symbol \"%s\" kræves, men er ikke tilstede"
#: elf.c:4749
#, c-format
@@ -687,7 +687,7 @@ msgstr "%s: advarsel: Tomt indlæsningsbart segment opdaget, er dette meningen?\n
#: elf.c:6193
#, c-format
msgid "%s: unsupported relocation type %s"
-msgstr "%s: relokaliseringstypen %s understøttes ikke"
+msgstr "%s: relokeringstypen %s understøttes ikke"
#: elf32-arm.h:1221
#, c-format
@@ -702,12 +702,12 @@ msgstr "%s: Advarsel: Thumb BLX-instruktionen bruger thumb-funktionen \"%s\" som
#: elf32-arm.h:1914 elf32-sh.c:4125
#, c-format
msgid "%s(%s+0x%lx): %s relocation against SEC_MERGE section"
-msgstr "%s(%s+0x%lx): %s relokalisering mod SEC_MERGE-sektion"
+msgstr "%s(%s+0x%lx): %s relokering mod SEC_MERGE-sektion"
#: elf32-arm.h:2008
#, c-format
msgid "%s: warning: unresolvable relocation %d against symbol `%s' from %s section"
-msgstr "%s: advarsel: uløselig relokalisering %d mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: advarsel: uløselig relokering %d mod symbol \"%s\" fra sektionen %s"
#: elf32-arm.h:2176
#, c-format
@@ -717,12 +717,12 @@ msgstr "Advarsel: Fjerner samvirkendeflaget i %s eftersom ikke-samvirkende kode
#: elf32-arm.h:2271
#, c-format
msgid "ERROR: %s is compiled for EABI version %d, whereas %s is compiled for version %d"
-msgstr "FEJL: %s er kompileret for EABI version %d, mens %s er kompileret for version %d"
+msgstr "FEJL: %s er oversat for EABI version %d, mens %s er oversat for version %d"
#: elf32-arm.h:2285
#, c-format
msgid "ERROR: %s is compiled for APCS-%d, whereas target %s uses APCS-%d"
-msgstr "FEJL: %s er kompileret for APCS-%d, mens målet %s bruger APCS-%d"
+msgstr "FEJL: %s er oversat for APCS-%d, mens målet %s bruger APCS-%d"
#: elf32-arm.h:2313
#, c-format
@@ -794,7 +794,7 @@ msgstr " [Version2 EABI]"
#: elf32-arm.h:2457
msgid " [dynamic symbols use segment index]"
-msgstr " [dynamiske symboler bruger segmentindex]"
+msgstr " [dynamiske symboler bruger segmentindeks]"
#: elf32-arm.h:2460
msgid " [mapping symbols precede others]"
@@ -806,7 +806,7 @@ msgstr " <EABI-version genkendes ikke>"
#: elf32-arm.h:2474
msgid " [relocatable executable]"
-msgstr " [relokaliseringsbar kørbar fil]"
+msgstr " [relokérbar kørbar fil]"
#: elf32-arm.h:2477
msgid " [has entry point]"
@@ -820,17 +820,17 @@ msgstr "<Ukendte flagbit er sat>"
#: elf32-i860.c:1039 elf32-openrisc.c:447 elf32-v850.c:1699
#: elf32-xstormy16.c:941 elf64-mmix.c:1310
msgid "internal error: dangerous relocation"
-msgstr "intern fejl: farlig relokalisering"
+msgstr "intern fejl: farlig relokering"
#: elf32-cris.c:949
#, c-format
msgid "%s: unresolvable relocation %s against symbol `%s' from %s section"
-msgstr "%s: uløselig relokalisering %s mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: uløselig relokering %s mod symbol \"%s\" fra sektionen %s"
#: elf32-cris.c:1012
#, c-format
msgid "%s: No PLT nor GOT for relocation %s against symbol `%s' from %s section"
-msgstr "%s: Hverken nogen PLT eller GOT for relokalisering %s mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: Hverken nogen PLT eller GOT for relokering %s mod symbol \"%s\" fra sektionen %s"
#: elf32-cris.c:1015 elf32-cris.c:1141
msgid "[whose name is lost]"
@@ -839,27 +839,27 @@ msgstr "[hvis navn er tabt]"
#: elf32-cris.c:1130
#, c-format
msgid "%s: relocation %s with non-zero addend %d against local symbol from %s section"
-msgstr "%s: relokalisering %s med ikke-tomt addendum %d mod lokalt symbol fra sektionen %s"
+msgstr "%s: relokering %s med ikke-tomt addendum %d mod lokalt symbol fra sektionen %s"
#: elf32-cris.c:1137
#, c-format
msgid "%s: relocation %s with non-zero addend %d against symbol `%s' from %s section"
-msgstr "%s: relokalisering %s med ikke-tomt addendum %d mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: relokering %s med ikke-tomt addendum %d mod symbol \"%s\" fra sektionen %s"
#: elf32-cris.c:1155
#, c-format
msgid "%s: relocation %s is not allowed for global symbol: `%s' from %s section"
-msgstr "%s: relokaliseringen %s er ikke tilladt for globalt symbol: \"%s\" fra sektionen %s"
+msgstr "%s: relokeringen %s er ikke tilladt for globalt symbol: \"%s\" fra sektionen %s"
#: elf32-cris.c:1170
#, c-format
msgid "%s: relocation %s in section %s with no GOT created"
-msgstr "%s: relokalisering %s i sektionen %s uden GOT oprettet"
+msgstr "%s: relokering %s i sektionen %s uden GOT oprettet"
#: elf32-cris.c:1288
#, c-format
msgid "%s: Internal inconsistency; no relocation section %s"
-msgstr "%s: Intern inkonsistens; ingen relokaliseringssektion %s"
+msgstr "%s: Intern inkonsistens; ingen relokeringssektion %s"
#: elf32-cris.c:2514
#, c-format
@@ -868,31 +868,31 @@ msgid ""
" relocation %s should not be used in a shared object; recompile with -fPIC"
msgstr ""
"%s, sektion %s:\n"
-" relokaliseringen %s bør ikke bruges i et delt objekt; genoversæt med -fPIC"
+" relokeringen %s bør ikke bruges i et delt objekt; genoversæt med -fPIC"
#: elf32-cris.c:2991
msgid " [symbols have a _ prefix]"
-msgstr " [symboler har et _-prefix]"
+msgstr " [symboler har et _-præfiks]"
#: elf32-cris.c:3030
#, c-format
msgid "%s: uses _-prefixed symbols, but writing file with non-prefixed symbols"
-msgstr "%s: bruger symboler med _-prefix, men skriver fil med symboler uden prefix"
+msgstr "%s: bruger symboler med _-præfiks, men skriver fil med symboler uden præfiks"
#: elf32-cris.c:3031
#, c-format
msgid "%s: uses non-prefixed symbols, but writing file with _-prefixed symbols"
-msgstr "%s: bruger symboler uden prefix, men skriver fil med symboler med _-prefix"
+msgstr "%s: bruger symboler uden præfiks, men skriver fil med symboler med _-præfiks"
#: elf32-frv.c:1217
#, c-format
msgid "%s: compiled with %s and linked with modules that use non-pic relocations"
-msgstr "%s: kompileret med %s og lænket med moduler som bruger ikke-pic-relokalisering"
+msgstr "%s: oversat med %s og lænket med moduler som bruger ikke-pic-relokering"
#: elf32-frv.c:1267
#, c-format
msgid "%s: compiled with %s and linked with modules compiled with %s"
-msgstr "%s: kompileret med %s og lænket med moduler som kompileredes med %s"
+msgstr "%s: oversat med %s og lænket med moduler som oversattes med %s"
#: elf32-frv.c:1279
#, c-format
@@ -907,7 +907,7 @@ msgstr "private flag = 0x%lx:"
#: elf32-gen.c:82 elf64-gen.c:82
#, c-format
msgid "%s: Relocations in generic ELF (EM: %d)"
-msgstr "%s: Relokalisering i generisk ELF (EM: %d)"
+msgstr "%s: Relokering i generisk ELF (EM: %d)"
#: elf32-hppa.c:671 elf64-ppc.c:2323
#, c-format
@@ -922,17 +922,17 @@ msgstr "%s(%s+0x%lx): kan ikke nå %s, genoversæt med -ffunction-sections"
#: elf32-hppa.c:1338 elf64-x86-64.c:673
#, c-format
msgid "%s: relocation %s can not be used when making a shared object; recompile with -fPIC"
-msgstr "%s: relokaliseringen %s kan ikke bruges når et delt objekt oprettes; genoversæt med -fPIC"
+msgstr "%s: relokeringen %s kan ikke bruges når et delt objekt oprettes; genoversæt med -fPIC"
#: elf32-hppa.c:1358
#, c-format
msgid "%s: relocation %s should not be used when making a shared object; recompile with -fPIC"
-msgstr "%s: relokaliseringen %s bør ikke bruges når et delt objekt oprettes; genoversæt med -fPIC"
+msgstr "%s: relokeringen %s bør ikke bruges når et delt objekt oprettes; genoversæt med -fPIC"
#: elf32-hppa.c:1551
#, c-format
msgid "Could not find relocation section for %s"
-msgstr "Kunne ikke finde relokaliseringssektion for %s"
+msgstr "Kunne ikke finde relokeringssektion for %s"
#: elf32-hppa.c:2855
#, c-format
@@ -956,12 +956,12 @@ msgstr ".got-sektionen følger ikke umiddelbart efter .plt-sektion"
#: elf32-i386.c:379
#, c-format
msgid "%s: invalid relocation type %d"
-msgstr "%s: ugyldig relokaliseringstype %d"
+msgstr "%s: ugyldig relokeringstype %d"
#: elf32-i386.c:876 elf32-s390.c:649 elf64-s390.c:595 elf64-x86-64.c:591
#, c-format
msgid "%s: bad symbol index: %d"
-msgstr "%s: fejlagtigt symbolindex: %d"
+msgstr "%s: fejlagtigt symbolindeks: %d"
#: elf32-i386.c:948
#, c-format
@@ -972,7 +972,7 @@ msgstr "%s: \"%s\" kaldt både som lokalt normalt symbol og lokalt trådsymbol"
#: elf64-x86-64.c:761
#, c-format
msgid "%s: bad relocation section name `%s'"
-msgstr "%s: fejlagtig relokaliseringssektionsnavn \"%s\""
+msgstr "%s: fejlagtig relokeringssektionsnavn \"%s\""
#: elf32-i386.c:1159 elf64-alpha.c:4768
#, c-format
@@ -983,28 +983,28 @@ msgstr "%s: lokal TLS-eksekveringskode kan ikke lænkes ind i delte objekter"
#: elf64-s390.c:1945 elf64-sparc.c:2578 elf64-x86-64.c:1948
#, c-format
msgid "%s(%s+0x%lx): unresolvable relocation against symbol `%s'"
-msgstr "%s(%s+0x%lx): uløselig relokalisering mod symbol \"%s\""
+msgstr "%s(%s+0x%lx): uløselig relokering mod symbol \"%s\""
#: elf32-i386.c:2784 elf32-s390.c:2019 elf64-ppc.c:5977 elf64-s390.c:1983
#: elf64-x86-64.c:1986
#, c-format
msgid "%s(%s+0x%lx): reloc against `%s': error %d"
-msgstr "%s(%s+0x%lx): relokalisering mod \"%s\": fejl %d"
+msgstr "%s(%s+0x%lx): relokering mod \"%s\": fejl %d"
#: elf32-m32r.c:924
msgid "SDA relocation when _SDA_BASE_ not defined"
-msgstr "SDA-relokalisering når _SDA_BASE_ ikke er defineret"
+msgstr "SDA-relokering når _SDA_BASE_ ikke er defineret"
#: elf32-ia64.c:3687 elf32-m32r.c:1013 elf32-ppc.c:2987 elf64-alpha.c:4185
#: elf64-alpha.c:4313 elf64-ia64.c:3687
#, c-format
msgid "%s: unknown relocation type %d"
-msgstr "%s: ukendt relokaliseringstype %d"
+msgstr "%s: ukendt relokeringstype %d"
#: elf32-m32r.c:1221
#, c-format
msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
-msgstr "%s: Målet (%s) for en %s-relokalisering er i forkert sektion (%s)"
+msgstr "%s: Målet (%s) for en %s-relokering er i forkert sektion (%s)"
#: elf32-m32r.c:1947
#, c-format
@@ -1035,16 +1035,16 @@ msgstr " [m68000]"
#: elf32-mcore.c:354 elf32-mcore.c:457
#, c-format
msgid "%s: Relocation %s (%d) is not currently supported.\n"
-msgstr "%s: Relokalisering %s (%d) understøttes ikke i øjeblikket.\n"
+msgstr "%s: Relokering %s (%d) understøttes ikke i øjeblikket.\n"
#: elf32-mcore.c:442
#, c-format
msgid "%s: Unknown relocation type %d\n"
-msgstr "%s: Ukendt relokaliseringstype %d\n"
+msgstr "%s: Ukendt relokeringstype %d\n"
#: elf32-mips.c:1152 elf64-mips.c:1783
msgid "32bits gp relative relocation occurs for an external symbol"
-msgstr "32-bit gp-relativ relokalisering forekom for et eksternt symbol"
+msgstr "32-bit gp-relativ relokering forekom for et eksternt symbol"
#: elf32-mips.c:1301
#, c-format
@@ -1054,12 +1054,12 @@ msgstr "Lænkning af mips16-objekter til %s-format understøttes ikke"
#: elf32-ppc.c:1460
#, c-format
msgid "%s: compiled with -mrelocatable and linked with modules compiled normally"
-msgstr "%s: kompileret med -mrelocatable og lænket med moduler som kompileredes normalt"
+msgstr "%s: oversat med -mrelocatable og lænket med moduler som oversattes normalt"
#: elf32-ppc.c:1468
#, c-format
msgid "%s: compiled normally and linked with modules compiled with -mrelocatable"
-msgstr "%s: kompileret normalt og lænket med moduler som kompileredes med -mrelocatable"
+msgstr "%s: oversat normalt og lænket med moduler som oversattes med -mrelocatable"
#: elf32-ppc.c:1494 elf64-sparc.c:2989 elfxx-mips.c:7713
#, c-format
@@ -1074,22 +1074,22 @@ msgstr "%s: Ukendt speciallænkertype %d"
#: elf32-ppc.c:2273 elf32-ppc.c:2307 elf32-ppc.c:2342
#, c-format
msgid "%s: relocation %s cannot be used when making a shared object"
-msgstr "%s: relokaliseringen %s kan ikke bruges når et delt objekt oprettes"
+msgstr "%s: relokeringen %s kan ikke bruges når et delt objekt oprettes"
#: elf32-ppc.c:3126 elf64-ppc.c:5473
#, c-format
msgid "%s: unknown relocation type %d for symbol %s"
-msgstr "%s: ukendt relokaliseringstype %d for symbol %s"
+msgstr "%s: ukendt relokeringstype %d for symbol %s"
#: elf32-ppc.c:3482 elf32-ppc.c:3503 elf32-ppc.c:3553
#, c-format
msgid "%s: The target (%s) of a %s relocation is in the wrong output section (%s)"
-msgstr "%s: Målet (%s) for en %s-relokalisering er i forkert uddatasektion (%s)"
+msgstr "%s: Målet (%s) for en %s-relokering er i forkert uddatasektion (%s)"
#: elf32-ppc.c:3619
#, c-format
msgid "%s: Relocation %s is not yet supported for symbol %s."
-msgstr "%s: Relokaliseringen %s understøttes ikke endnu for symbol %s."
+msgstr "%s: Relokeringen %s understøttes ikke endnu for symbol %s."
#: elf32-sh.c:1964
#, c-format
@@ -1109,7 +1109,7 @@ msgstr "%s: 0x%lx: advarsel: fejlagtig R_SH_USES-indlæsningsafstand"
#: elf32-sh.c:2008
#, c-format
msgid "%s: 0x%lx: warning: could not find expected reloc"
-msgstr "%s: 0x%lx: advarsel: kunne ikke finde forventet relokalisering"
+msgstr "%s: 0x%lx: advarsel: kunne ikke finde forventet relokering"
#: elf32-sh.c:2036
#, c-format
@@ -1119,7 +1119,7 @@ msgstr "%s: 0x%lx: advarsel: symbol i uventet sektion"
#: elf32-sh.c:2153
#, c-format
msgid "%s: 0x%lx: warning: could not find expected COUNT reloc"
-msgstr "%s: 0x%lx: advarsel: kunne ikke finde forventet COUNT-relokalisering"
+msgstr "%s: 0x%lx: advarsel: kunne ikke finde forventet COUNT-relokering"
#: elf32-sh.c:2162
#, c-format
@@ -1129,7 +1129,7 @@ msgstr "%s: 0x%lx: advarsel: fejlagtigt antal"
#: elf32-sh.c:2550 elf32-sh.c:2926
#, c-format
msgid "%s: 0x%lx: fatal: reloc overflow while relaxing"
-msgstr "%s: 0x%lx: fatalt: relokalisering giver overløb ved forenklingen"
+msgstr "%s: 0x%lx: fatalt: relokering giver overløb ved forenklingen"
#: elf32-sh.c:4073 elf64-sh64.c:1576
msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled"
@@ -1138,17 +1138,17 @@ msgstr "Uventet STO_SH5_ISA32 på lokalt symbol håndteres ikke"
#: elf32-sh.c:4284
#, c-format
msgid "%s: 0x%lx: fatal: unaligned branch target for relax-support relocation"
-msgstr "%s: 0x%lx: fatalt: ujusteret grenmål for relokalisering for forenklingsunderstøttelse"
+msgstr "%s: 0x%lx: fatalt: ujusteret grenmål for relokering for forenklingsunderstøttelse"
#: elf32-sh64.c:203 elf64-sh64.c:2364
#, c-format
msgid "%s: compiled as 32-bit object and %s is 64-bit"
-msgstr "%s: kompileret som 32-bitsobjekt og %s er 64-bit"
+msgstr "%s: oversat som 32-bitsobjekt og %s er 64-bit"
#: elf32-sh64.c:206 elf64-sh64.c:2367
#, c-format
msgid "%s: compiled as 64-bit object and %s is 32-bit"
-msgstr "%s: kompileret som 64-bitsobjekt og %s er 32-bit"
+msgstr "%s: oversat som 64-bitsobjekt og %s er 32-bit"
#: elf32-sh64.c:208 elf64-sh64.c:2369
#, c-format
@@ -1176,27 +1176,27 @@ msgstr "%s: GAS-fejl: uventet PTB-instruktion med R_SH_PT_16"
#: elf32-sh64.c:593 elf64-sh64.c:1703
#, c-format
msgid "%s: error: unaligned relocation type %d at %08x reloc %08x\n"
-msgstr "%s: fejl: ojusteret relokaliseringstype %d på %08x relokalisering %08x\n"
+msgstr "%s: fejl: ujusteret relokeringstype %d på %08x relokering %08x\n"
#: elf32-sh64.c:677
-#, c-format
+#, fuzzy, c-format
msgid "%s: could not write out added .cranges entries"
-msgstr "%s: kunne ikke udskrive tilføjede .cranges-poster"
+msgstr "%s: kunne ikke udskrive tilføjede .crangives-poster"
#: elf32-sh64.c:739
-#, c-format
+#, fuzzy, c-format
msgid "%s: could not write out sorted .cranges entries"
-msgstr "%s: kunne ikke udskrive sorterede cranges-poster"
+msgstr "%s: kunne ikke udskrive sorterede crangives-poster"
#: elf32-sparc.c:1535 elf64-sparc.c:2224
#, c-format
msgid "%s: probably compiled without -fPIC?"
-msgstr "%s: nok kompileret uden -fPIC?"
+msgstr "%s: nok oversat uden -fPIC?"
#: elf32-sparc.c:2002
#, c-format
msgid "%s: compiled for a 64 bit system and target is 32 bit"
-msgstr "%s: kompileret for et 64-bitssystem og målet er 32-bit"
+msgstr "%s: oversat for et 64-bitssystem og målet er 32-bit"
#: elf32-sparc.c:2016
#, c-format
@@ -1204,22 +1204,22 @@ msgid "%s: linking little endian files with big endian files"
msgstr "%s: lænker little endian-filer med big endian-filer"
#: elf32-v850.c:682
-#, c-format
+#, fuzzy, c-format
msgid "Variable `%s' cannot occupy in multiple small data regions"
msgstr "Variabel \"%s\" kan ikke befinde sig i flere små dataområder"
#: elf32-v850.c:685
-#, c-format
+#, fuzzy, c-format
msgid "Variable `%s' can only be in one of the small, zero, and tiny data regions"
msgstr "Variabel \"%s\" kan kun være i et af de små, tomme og bittesmå dataområder"
#: elf32-v850.c:688
-#, c-format
+#, fuzzy, c-format
msgid "Variable `%s' cannot be in both small and zero data regions simultaneously"
msgstr "Variabel \"%s\" kan ikke være i både små og tomme dataområder samtidigt"
#: elf32-v850.c:691
-#, c-format
+#, fuzzy, c-format
msgid "Variable `%s' cannot be in both small and tiny data regions simultaneously"
msgstr "Variabel \"%s\" kan ikke være i både små og bittesmå dataområder samtidigt"
@@ -1230,7 +1230,7 @@ msgstr "Variabel \"%s\" kan ikke være i både tomme og bittesmå dataområder samti
#: elf32-v850.c:1072
msgid "FAILED to find previous HI16 reloc\n"
-msgstr "MISLYKKEDES med at finde tidligere HI16-relokalisering\n"
+msgstr "MISLYKKEDES med at finde tidligere HI16-relokering\n"
#: elf32-v850.c:1703
msgid "could not locate special linker symbol __gp"
@@ -1291,20 +1291,20 @@ msgstr "%s: advarsel: PLT-addendum %d til \"%s\" fra sektionen %s ignoreredes"
#: elf32-vax.c:1814
#, c-format
msgid "%s: warning: %s relocation against symbol `%s' from %s section"
-msgstr "%s: advarsel: %s-relokalisering mod symbol \"%s\" fra sektionen %s"
+msgstr "%s: advarsel: %s-relokering mod symbol \"%s\" fra sektionen %s"
#: elf32-vax.c:1820
#, c-format
msgid "%s: warning: %s relocation to 0x%x from %s section"
-msgstr "%s: advarsel: %s-relokalisering til 0x%x fra sektionen %s"
+msgstr "%s: advarsel: %s-relokering til 0x%x fra sektionen %s"
#: elf32-ia64.c:2280 elf32-xstormy16.c:414 elf64-ia64.c:2280
msgid "non-zero addend in @fptr reloc"
-msgstr "ikke-tomt addendum i @fptr-relokalisering"
+msgstr "ikke-tomt addendum i @fptr-relokering"
#: elf64-alpha.c:1097
msgid "GPDISP relocation did not find ldah and lda instructions"
-msgstr "GPDISP-relokalisering fandt ingen ldah- og lda-instruktioner"
+msgstr "GPDISP-relokering fandt ingen ldah- og lda-instruktioner"
#: elf64-alpha.c:3675
#, c-format
@@ -1314,12 +1314,12 @@ msgstr "%s: .got-subsegment overskrider 64 kB (størrelse %d)"
#: elf64-alpha.c:4498 elf64-alpha.c:4510
#, c-format
msgid "%s: gp-relative relocation against dynamic symbol %s"
-msgstr "%s: gp-relativ relokalisering mod dynamisk symbol %s"
+msgstr "%s: gp-relativ relokering mod dynamisk symbol %s"
#: elf64-alpha.c:4536 elf64-alpha.c:4676
#, c-format
msgid "%s: pc-relative relocation against dynamic symbol %s"
-msgstr "%s: pc-relativ relokalisering mod dynamisk symbol %s"
+msgstr "%s: pc-relativ relokering mod dynamisk symbol %s"
#: elf64-alpha.c:4564
#, c-format
@@ -1333,27 +1333,27 @@ msgstr "<ukendt>"
#: elf64-alpha.c:4594
#, c-format
msgid "%s: !samegp reloc against symbol without .prologue: %s"
-msgstr "%s: !samegp-relokalisering mod symbol uden .prologue: %s"
+msgstr "%s: !samegp-relokering mod symbol uden .prologue: %s"
#: elf64-alpha.c:4639
#, c-format
msgid "%s: unhandled dynamic relocation against %s"
-msgstr "%s: uhåndteret dynamisk relokalisering mod %s"
+msgstr "%s: uhåndteret dynamisk relokering mod %s"
#: elf64-alpha.c:4752
#, c-format
msgid "%s: dtp-relative relocation against dynamic symbol %s"
-msgstr "%s: dtp-relativ relokalisering mod dynamisk symbol %s"
+msgstr "%s: dtp-relativ relokering mod dynamisk symbol %s"
#: elf64-alpha.c:4775
#, c-format
msgid "%s: tp-relative relocation against dynamic symbol %s"
-msgstr "%s: tp-relativ relokalisering mod dynamisk symbol %s"
+msgstr "%s: tp-relativ relokering mod dynamisk symbol %s"
#: elf64-hppa.c:2080
#, c-format
msgid "stub entry for %s cannot load .plt, dp offset = %ld"
-msgstr "stubpost for %s kan ikke læse in .plt, dp-afstand = %ld"
+msgstr "stubpost for %s kan ikke indlæse .plt, dp-afstand = %ld"
#: elf64-mmix.c:1002
#, c-format
@@ -1361,28 +1361,28 @@ msgid ""
"%s: Internal inconsistency error for value for\n"
" linker-allocated global register: linked: 0x%lx%08lx != relaxed: 0x%lx%08lx\n"
msgstr ""
-"%s: Intern inkkonsistensfejl for værdien for\n"
-" lænkerallokeret globalt register: lænket: 0x%lx%08lx != afslappet: 0x%lx%08lx\n"
+"%s: Intern inkonsistensfejl for værdien for\n"
+" lænkerallokeret globalt register: lænket: 0x%lx%08lx != forenklet: 0x%lx%08lx\n"
#: elf64-mmix.c:1386
#, c-format
msgid "%s: base-plus-offset relocation against register symbol: (unknown) in %s"
-msgstr "%s: base-plus-afstandsrelokalisering mod registersymbol: (ukendt) i %s"
+msgstr "%s: base-plus-afstandsrelokering mod registersymbol: (ukendt) i %s"
#: elf64-mmix.c:1391
#, c-format
msgid "%s: base-plus-offset relocation against register symbol: %s in %s"
-msgstr "%s: base-plus-afstandsrelokalisering mod registersymbol: %s i %s"
+msgstr "%s: base-plus-afstandsrelokering mod registersymbol: %s i %s"
#: elf64-mmix.c:1435
#, c-format
msgid "%s: register relocation against non-register symbol: (unknown) in %s"
-msgstr "%s: registerrelokalisering mod ikke-registersymbol: (ukendt) i %s"
+msgstr "%s: registerrelokering mod ikke-registersymbol: (ukendt) i %s"
#: elf64-mmix.c:1440
#, c-format
msgid "%s: register relocation against non-register symbol: %s in %s"
-msgstr "%s: registerrelokalisering mod ikke-registersymbol: %s i %s"
+msgstr "%s: registerrelokering mod ikke-registersymbol: %s i %s"
#: elf64-mmix.c:1477
#, c-format
@@ -1415,17 +1415,17 @@ msgstr ""
#: elf64-ppc.c:1669 libbfd.c:1435
#, c-format
msgid "%s: compiled for a big endian system and target is little endian"
-msgstr "%s: kompileret for et big endian-system og målet er little endian"
+msgstr "%s: oversat for et big endian-system og målet er little endian"
#: elf64-ppc.c:1671 libbfd.c:1437
#, c-format
msgid "%s: compiled for a little endian system and target is big endian"
-msgstr "%s: kompileret for et little endian-system og målet er big endian"
+msgstr "%s: oversat for et little endian-system og målet er big endian"
#: elf64-ppc.c:3610
#, c-format
msgid "%s: unexpected reloc type %u in .opd section"
-msgstr "%s: uventet relokaliseringstype %u i .opd-sektion"
+msgstr "%s: uventet relokeringstype %u i .opd-sektion"
#: elf64-ppc.c:3630
#, c-format
@@ -1459,17 +1459,17 @@ msgstr "stubbe stemmer ikke overens med beregnet størrelse"
#: elf64-ppc.c:5828
#, c-format
msgid "%s: Relocation %s is not supported for symbol %s."
-msgstr "%s: Relokaliseringen %s understøttes ikke for symbol %s."
+msgstr "%s: Relokeringen %s understøttes ikke for symbol %s."
#: elf64-ppc.c:5872
#, c-format
msgid "%s: error: relocation %s not a multiple of 4"
-msgstr "%s: fejl: relokaliseringen %s er ikke en multipel af 4"
+msgstr "%s: fejl: relokeringen %s er ikke en multipel af 4"
#: elf64-sparc.c:1280
#, c-format
msgid "%s: check_relocs: unhandled reloc type %d"
-msgstr "%s: check_relocs: uhåndteret relokaliseringstype %d"
+msgstr "%s: check_relocs: uhåndteret relokeringstype %d"
#: elf64-sparc.c:1317
#, c-format
@@ -1504,7 +1504,7 @@ msgstr "%s: versionsantal (%ld) stemmer ikke med symbolantal (%ld)"
#: elflink.c:440
#, c-format
msgid "%s: Section %s is too large to add hole of %ld bytes"
-msgstr "%s: Sektionen %s er for stor til at stoppa hul med %ld byte i"
+msgstr "%s: Sektionen %s er for stor til at stoppe hul med %ld byte i"
#: elflink.h:1090
#, c-format
@@ -1547,7 +1547,7 @@ msgstr "Fejl: ikke mere hukommelse"
#: elflink.h:4781
msgid "Not enough memory to sort relocations"
-msgstr "Ikke nok hukommelse til at sortere relokaliseringer"
+msgstr "Ikke nok hukommelse til at sortere relokeringer"
#: elflink.h:5682 elflink.h:5725
#, c-format
@@ -1567,15 +1567,15 @@ msgstr "%s: kunne ikke finde uddatasektionen %s for inddatasektionen %s"
#: elflink.h:6486
#, c-format
msgid "%s: relocation size mismatch in %s section %s"
-msgstr "%s: relokaliseringsstørrelsen stemmer ikke overens i %s-sektionen %s"
+msgstr "%s: relokeringsstørrelsen stemmer ikke overens i %s-sektionen %s"
#: elflink.h:6849
msgid "warning: relocation against removed section; zeroing"
-msgstr "advarsel: relokalisering mod fjernet sektion; nulstiller"
+msgstr "advarsel: relokering mod fjernet sektion; nulstiller"
#: elflink.h:6879
msgid "warning: relocation against removed section"
-msgstr "advarsel: relokalisering mod fjernet sektion"
+msgstr "advarsel: relokering mod fjernet sektion"
#: elflink.h:6892
#, c-format
@@ -1598,12 +1598,12 @@ msgstr "%s: %s+0x%lx: hop til stubrutine som ikke er jal"
#: elfxx-mips.c:4270
#, c-format
msgid "%s: Malformed reloc detected for section %s"
-msgstr "%s: Fejlagtig relokalisering for sektion %s opdaget"
+msgstr "%s: Fejlagtig relokering for sektion %s opdaget"
#: elfxx-mips.c:4348
#, c-format
msgid "%s: CALL16 reloc at 0x%lx not against global symbol"
-msgstr "%s: CALL16-relokalisering ved 0x%lx er ikke mod globalt symbol"
+msgstr "%s: CALL16-relokering ved 0x%lx er ikke mod globalt symbol"
#: elfxx-mips.c:7301
#, c-format
@@ -1763,37 +1763,37 @@ msgstr "%s: uventet type efter ATN"
#: ihex.c:258
#, c-format
msgid "%s:%d: unexpected character `%s' in Intel Hex file\n"
-msgstr "%s:%d: uventet tegn \"%s\" i hexadecimal Intel-fil\n"
+msgstr "%s:%d: uventet tegn \"%s\" i heksadecimal Intel-fil\n"
#: ihex.c:366
#, c-format
msgid "%s:%u: bad checksum in Intel Hex file (expected %u, found %u)"
-msgstr "%s:%u: fejlagtig kontrolsum i hexadecimal Intel-fil (forventede %u, fandt %u)"
+msgstr "%s:%u: fejlagtig kontrolsum i heksadecimal Intel-fil (forventede %u, fandt %u)"
#: ihex.c:420
#, c-format
msgid "%s:%u: bad extended address record length in Intel Hex file"
-msgstr "%s:%u: fejlagtig længde på post for udvidet adresse i hexadecimal Intel-fil"
+msgstr "%s:%u: fejlagtig længde på post for udvidet adresse i heksadecimal Intel-fil"
#: ihex.c:437
#, c-format
msgid "%s:%u: bad extended start address length in Intel Hex file"
-msgstr "%s:%u: fejlagtig længde på udvidet startadresse i hexadecimal Intel-fil"
+msgstr "%s:%u: fejlagtig længde på udvidet startadresse i heksadecimal Intel-fil"
#: ihex.c:454
#, c-format
msgid "%s:%u: bad extended linear address record length in Intel Hex file"
-msgstr "%s:%u: fejlagtig længde på post for udvidet lineær adresse i hexadecimal Intel-fil"
+msgstr "%s:%u: fejlagtig længde på post for udvidet lineær adresse i heksadecimal Intel-fil"
#: ihex.c:471
#, c-format
msgid "%s:%u: bad extended linear start address length in Intel Hex file"
-msgstr "%s:%u: fejlagtig længde på post for udvidet lineær startadresse i hexadecimal Intel-fil"
+msgstr "%s:%u: fejlagtig længde på post for udvidet lineær startadresse i heksadecimal Intel-fil"
#: ihex.c:488
#, c-format
msgid "%s:%u: unrecognized ihex type %u in Intel Hex file\n"
-msgstr "%s:%u: ukendt ihex-type %u i hexadecimal Intel-fil\n"
+msgstr "%s:%u: ukendt ihex-type %u i heksadecimal Intel-fil\n"
#: ihex.c:607
#, c-format
@@ -1808,7 +1808,7 @@ msgstr "%s: fejlagtig sektionslængde i ihex_read_sektion"
#: ihex.c:860
#, c-format
msgid "%s: address 0x%s out of range for Intel Hex file"
-msgstr "%s: adressen 0x%s er udenfor intervallet for hexadecimal Intel-fil"
+msgstr "%s: adressen 0x%s er uden for intervallet for heksadecimal Intel-fil"
#: libbfd.c:492
#, c-format
@@ -1837,7 +1837,7 @@ msgstr "%s: indirekte symbol \"%s\" til \"%s\" er en løkke"
#: linker.c:2776
#, c-format
msgid "Attempt to do relocateable link with %s input and %s output"
-msgstr "Forsøg at lave en relokaliseringsbar lænke med %s-inddata og %s-uddata"
+msgstr "Forsøg at lave en relokérbar lænke med %s-inddata og %s-uddata"
#: merge.c:892
#, c-format
@@ -1852,7 +1852,7 @@ msgstr "%s: Ingen kerne til at allokere sektionsnavn %s\n"
#: mmo.c:536
#, c-format
msgid "%s: No core to allocate a symbol %d bytes long\n"
-msgstr "%s: Ingen kerne for at allokere et %d byte langt symbol\n"
+msgstr "%s: Ingen kerne til at allokere et %d byte langt symbol\n"
#: mmo.c:1245
#, c-format
@@ -1862,12 +1862,12 @@ msgstr "%s: ugyldig mmo-fil: initieringsværdi for $255 er ikke \"Main\"\n"
#: mmo.c:1391
#, c-format
msgid "%s: unsupported wide character sequence 0x%02X 0x%02X after symbol name starting with `%s'\n"
-msgstr "%s: bred tegnsekvens som ikke understøttes 0x%02X 0x%02X efter symbolnavnet som begynder med \"%s\"\n"
+msgstr "%s: bred tegn-sekvens som ikke understøttes 0x%02X 0x%02X efter symbolnavnet som begynder med \"%s\"\n"
#: mmo.c:1633
#, c-format
msgid "%s: invalid mmo file: unsupported lopcode `%d'\n"
-msgstr "%s: ugyldig mmo-fil: lopkod \"%d\" understøttes ikke\n"
+msgstr "%s: ugyldig mmo-fil: lopkode \"%d\" understøttes ikke\n"
#: mmo.c:1643
#, c-format
@@ -2028,7 +2028,7 @@ msgstr "%s: Ukendt maskintype (0x%x) i Import Library Format-arkiv"
#: peicode.h:1174
#, c-format
msgid "%s: Recognised but unhandled machine type (0x%x) in Import Library Format archive"
-msgstr "%s: Kendt men uhåndteret maskintype (0x%x) i Import Library Format-arkiv"
+msgstr "%s: Kendt, men uhåndteret maskintype (0x%x) i Import Library Format-arkiv"
#: peicode.h:1191
#, c-format
@@ -2101,15 +2101,15 @@ msgstr "som_sizeof_headers er ikke implementeret"
msgid "%s:%d: Unexpected character `%s' in S-record file\n"
msgstr "%s:%d: Uventet tegn \"%s\" i S-postfil\n"
-# Vad er stabs?
+# Hvad er stabs?
#: stabs.c:319
#, c-format
msgid "%s(%s+0x%lx): Stabs entry has invalid string index."
-msgstr "%s(%s+0x%lx): Stabpost har ugyldigt strengindex."
+msgstr "%s(%s+0x%lx): Stabpost har ugyldigt strengindeks."
#: syms.c:1044
msgid "Unsupported .stab relocation"
-msgstr ".stab-relokalisering som ikke understøttes"
+msgstr ".stab-relokering som ikke understøttes"
#: vms-gsd.c:356
#, c-format
@@ -2150,7 +2150,7 @@ msgstr "_bfd_vms_output_counted kaldt med nul byte"
#: vms-misc.c:924
msgid "_bfd_vms_output_counted called with too many bytes"
-msgstr "_bfd_vms_output_counted called kaldt med for mange byte"
+msgstr "_bfd_vms_output_counted kaldt med for mange byte"
#: vms-misc.c:1055
#, c-format
@@ -2169,7 +2169,7 @@ msgstr "Ingen hukommelse!"
#: vms-tir.c:362
#, c-format
msgid "bad section index in %s"
-msgstr "fejlagtigt sektionsindex i %s"
+msgstr "fejlagtigt sektionsindeks i %s"
#: vms-tir.c:375
#, c-format
@@ -2263,17 +2263,17 @@ msgstr "objektkode %d kunne ikke findes"
#: vms-tir.c:2019
#, c-format
msgid "SEC_RELOC with no relocs in section %s"
-msgstr "SEC_RELOC uden relokaliseringer i sektion %s"
+msgstr "SEC_RELOC uden relokeringer i sektion %s"
#: vms-tir.c:2307
#, c-format
msgid "Unhandled relocation %s"
-msgstr "Uhåndteret relokalisering %s"
+msgstr "Uhåndteret relokering %s"
#: xcofflink.c:1243
#, c-format
msgid "%s: `%s' has line numbers but no enclosing section"
-msgstr "%s: \"%s\" har linjenumre men ingen omsluttende sektion"
+msgstr "%s: \"%s\" har linjenumre, men ingen omsluttende sektion"
#: xcofflink.c:1296
#, c-format
@@ -2308,7 +2308,7 @@ msgstr "%s: fejlagtigt placeret XTY_LD \"%s\""
#: xcofflink.c:1957
#, c-format
msgid "%s: reloc %s:%d not in csect"
-msgstr "%s: relokaliseringen %s:%d er ikke i csect"
+msgstr "%s: relokeringen %s:%d er ikke i csect"
#: xcofflink.c:2092
#, c-format
@@ -2337,26 +2337,26 @@ msgstr "advarsel: forsøg på at eksportere udefineret symbol \"%s\""
#: xcofflink.c:4447
#, c-format
msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"
-msgstr "TOC giver overløb: 0x%lx > 0x10000; prøv -mminimal-toc ved kompilering"
+msgstr "TOC giver overløb: 0x%lx > 0x10000; prøv -mminimal-toc ved oversættelse"
#: xcofflink.c:5287 xcofflink.c:5756 xcofflink.c:5818 xcofflink.c:6119
#, c-format
msgid "%s: loader reloc in unrecognized section `%s'"
-msgstr "%s: indlæserrelokalisering i ukendt sektion \"%s\""
+msgstr "%s: indlæserrelokering i ukendt sektion \"%s\""
#: xcofflink.c:5309 xcofflink.c:6130
#, c-format
msgid "%s: `%s' in loader reloc but not loader sym"
-msgstr "%s: \"%s\" i indlæserrelokalisering men ikke indlæsersym"
+msgstr "%s: \"%s\" i indlæserrelokering, men ikke indlæsersym"
#: xcofflink.c:5324
#, c-format
msgid "%s: loader reloc in read-only section %s"
-msgstr "%s: indlæserrelokalisering i skrivebeskyttet sektion %s"
+msgstr "%s: indlæserrelokering i skrivebeskyttet sektion %s"
#: elf32-ia64.c:2222 elf64-ia64.c:2222
msgid "@pltoff reloc against local symbol"
-msgstr "@pltoff-relokalisering mod lokalt symbol"
+msgstr "@pltoff-relokering mod lokalt symbol"
#: elf32-ia64.c:3562 elf64-ia64.c:3562
#, c-format
@@ -2376,12 +2376,12 @@ msgstr "%s: lænker ikke-pic-kode i delt bibliotek"
#: elf32-ia64.c:3891 elf64-ia64.c:3891
#, c-format
msgid "%s: @gprel relocation against dynamic symbol %s"
-msgstr "%s: @gprel-relokalisering mod dynamisk symbol %s"
+msgstr "%s: @gprel-relokering mod dynamisk symbol %s"
#: elf32-ia64.c:4030 elf64-ia64.c:4030
#, c-format
msgid "%s: dynamic relocation against speculation fixup"
-msgstr "%s: dynamisk relokalisering uden spekulationsrettelser"
+msgstr "%s: dynamisk relokering uden spekulationsrettelser"
#: elf32-ia64.c:4038 elf64-ia64.c:4038
#, c-format
@@ -2390,7 +2390,7 @@ msgstr "%s: spekulationsfix mod udefineret svagt symbol"
#: elf32-ia64.c:4271 elf64-ia64.c:4271
msgid "unsupported reloc"
-msgstr "relokaliseringen understøttes ikke"
+msgstr "relokeringen understøttes ikke"
#: elf32-ia64.c:4551 elf64-ia64.c:4551
#, c-format
@@ -2425,11 +2425,11 @@ msgstr "%s: linjenummer giver overløb: 0x%lx > 0xffff"
#: peigen.c:979 pepigen.c:979
#, c-format
msgid "%s: reloc overflow 1: 0x%lx > 0xffff"
-msgstr "%s: relokalisering giver overløb 1: 0x%lx > 0xffff"
+msgstr "%s: relokering giver overløb 1: 0x%lx > 0xffff"
#: peigen.c:993 pepigen.c:993
msgid "Export Directory [.edata (or where ever we found it)]"
-msgstr "Exportkatalog [.edata (eller hvor vi fandt det)]"
+msgstr "Eksportkatalog [.edata (eller hvor vi fandt det)]"
#: peigen.c:994 pepigen.c:994
msgid "Import Directory [parts of .idata]"
@@ -2449,7 +2449,7 @@ msgstr "Sikkerhedskatalog"
#: peigen.c:998 pepigen.c:998
msgid "Base Relocation Directory [.reloc]"
-msgstr "Baserelokaliseringskatalog [.reloc]"
+msgstr "Baserelokeringskatalog [.reloc]"
#: peigen.c:999 pepigen.c:999
msgid "Debug Directory"
@@ -2535,7 +2535,7 @@ msgstr ""
"\n"
"Importtabellerne (tolket indhold i %s-sektion)\n"
-# Vad er thunk?
+# Hvad er thunk?
#: peigen.c:1130 pepigen.c:1130
msgid ""
" vma: Hint Time Forward DLL First\n"
@@ -2555,7 +2555,7 @@ msgstr ""
#: peigen.c:1192 pepigen.c:1192
msgid "\tvma: Hint/Ord Member-Name Bound-To\n"
-msgstr "\tvma: Tips/Ordn Medlemsnavn Bundet till\n"
+msgstr "\tvma: Tips/Ordn Medlemsnavn Bundet til\n"
#: peigen.c:1217 pepigen.c:1217
msgid ""
@@ -2580,7 +2580,7 @@ msgid ""
"There is an export table in %s at 0x%lx\n"
msgstr ""
"\n"
-"Det findes en eksporttabel i %s ved 0x%lx\n"
+"Der findes en eksporttabel i %s ved 0x%lx\n"
#: peigen.c:1393 pepigen.c:1393
#, c-format
@@ -2600,7 +2600,7 @@ msgstr "Eksportflag \t\t\t%lx\n"
#: peigen.c:1400 pepigen.c:1400
#, c-format
msgid "Time/Date stamp \t\t%lx\n"
-msgstr "Tids/datostempel \t\t%lx\n"
+msgstr "Tids-/datostempel \t\t%lx\n"
#: peigen.c:1403 pepigen.c:1403
#, c-format
@@ -2694,7 +2694,7 @@ msgid ""
" \t\tAddress Address Handler Data Address Mask\n"
msgstr ""
" vma:\t\tStart- Slut- EH- EH- Prologsluts- Undtagelses-\n"
-" \t\tadresse adresse håndterere data adresse maske\n"
+" \t\tadresse adresse håndterer data adresse maske\n"
#: peigen.c:1624 pepigen.c:1624
msgid " Register save millicode"
@@ -2716,7 +2716,7 @@ msgid ""
msgstr ""
"\n"
"\n"
-"PE-filbaserelokaliseringer (tolket indhold i .reloc-sektionen)\n"
+"PE-filbaserelokeringer (tolket indhold i .reloc-sektionen)\n"
#: peigen.c:1712 pepigen.c:1712
#, c-format
@@ -2730,7 +2730,7 @@ msgstr ""
#: peigen.c:1725 pepigen.c:1725
#, c-format
msgid "\treloc %4d offset %4x [%4lx] %s"
-msgstr "\trelokalisering %4d afstand %4x [%4lx] %s"
+msgstr "\trelokering %4d afstand %4x [%4lx] %s"
#. The MS dumpbin program reportedly ands with 0xff0f before
#. printing the characteristics field. Not sure why. No reason to
diff --git a/bfd/reloc.c b/bfd/reloc.c
index b13f6722c1a..0885e03232e 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
SECTION
@@ -645,7 +645,8 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd,
reloc_target_output_section = symbol->section->output_section;
/* Convert input-section-relative symbol value to absolute. */
- if (output_bfd && ! howto->partial_inplace)
+ if ((output_bfd && ! howto->partial_inplace)
+ || reloc_target_output_section == NULL)
output_base = 0;
else
output_base = reloc_target_output_section->vma;
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
index 1db8daf2aa4..44d4f4f4657 100644
--- a/bfd/reloc16.c
+++ b/bfd/reloc16.c
@@ -199,30 +199,31 @@ bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again)
shrinks = (unsigned *) bfd_zmalloc (amt);
/* Loop until nothing changes in this section. */
- do {
- arelent **parent;
- unsigned int i;
- long j;
-
- another_pass = 0;
-
- for (i = 0, parent = reloc_vector; *parent; parent++, i++)
- {
- /* Let the target/machine dependent code examine each reloc
- in this section and attempt to shrink it. */
- shrink = bfd_coff_reloc16_estimate (abfd, input_section, *parent,
- shrinks[i], link_info);
-
- /* If it shrunk, note it in the shrinks array and set up for
- another pass. */
- if (shrink != shrinks[i])
- {
- another_pass = 1;
- for (j = i + 1; j <= reloc_count; j++)
- shrinks[j] += shrink - shrinks[i];
- }
- }
- }
+ do
+ {
+ arelent **parent;
+ unsigned int i;
+ long j;
+
+ another_pass = 0;
+
+ for (i = 0, parent = reloc_vector; *parent; parent++, i++)
+ {
+ /* Let the target/machine dependent code examine each reloc
+ in this section and attempt to shrink it. */
+ shrink = bfd_coff_reloc16_estimate (abfd, input_section, *parent,
+ shrinks[i], link_info);
+
+ /* If it shrunk, note it in the shrinks array and set up for
+ another pass. */
+ if (shrink != shrinks[i])
+ {
+ another_pass = 1;
+ for (j = i + 1; j <= reloc_count; j++)
+ shrinks[j] += shrink - shrinks[i];
+ }
+ }
+ }
while (another_pass);
shrink = shrinks[reloc_count];
@@ -235,12 +236,12 @@ bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again)
}
bfd_byte *
-bfd_coff_reloc16_get_relocated_section_contents(in_abfd,
- link_info,
- link_order,
- data,
- relocateable,
- symbols)
+bfd_coff_reloc16_get_relocated_section_contents (in_abfd,
+ link_info,
+ link_order,
+ data,
+ relocateable,
+ symbols)
bfd *in_abfd;
struct bfd_link_info *link_info;
struct bfd_link_order *link_order;
@@ -266,11 +267,11 @@ bfd_coff_reloc16_get_relocated_section_contents(in_abfd,
symbols);
/* Read in the section. */
- if (!bfd_get_section_contents(input_bfd,
- input_section,
- data,
- (bfd_vma) 0,
- input_section->_raw_size))
+ if (!bfd_get_section_contents (input_bfd,
+ input_section,
+ data,
+ (bfd_vma) 0,
+ input_section->_raw_size))
return NULL;
reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
diff --git a/bfd/simple.c b/bfd/simple.c
index 10178a40ad4..f0f5ee64123 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -138,6 +138,21 @@ bfd_simple_get_relocated_section_contents (abfd, sec, outbuf)
int storage_needed, number_of_symbols;
asymbol **symbol_table;
+ if (! (sec->flags & SEC_RELOC))
+ {
+ bfd_size_type size = bfd_section_size (abfd, sec);
+
+ if (outbuf == NULL)
+ contents = bfd_malloc (size);
+ else
+ contents = outbuf;
+
+ if (contents)
+ bfd_get_section_contents (abfd, sec, contents, 0, size);
+
+ return contents;
+ }
+
/* In order to use bfd_get_relocated_section_contents, we need
to forge some data structures that it expects. */
diff --git a/bfd/targets.c b/bfd/targets.c
index e665898bc63..6a68eaa13f0 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -4,21 +4,21 @@
Free Software Foundation, Inc.
Written by Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public 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"
@@ -155,7 +155,11 @@ DESCRIPTION
. bfd_target_msdos_flavour,
. bfd_target_ovax_flavour,
. bfd_target_evax_flavour,
-. bfd_target_mmo_flavour
+. bfd_target_mmo_flavour,
+. bfd_target_mach_o_flavour,
+. bfd_target_pef_flavour,
+. bfd_target_pef_xlib_flavour,
+. bfd_target_sym_flavour
.};
.
.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
@@ -508,7 +512,6 @@ extern const bfd_target bfd_elf32_big_generic_vec;
extern const bfd_target bfd_elf32_bigarc_vec;
extern const bfd_target bfd_elf32_bigarm_oabi_vec;
extern const bfd_target bfd_elf32_bigarm_vec;
-extern const bfd_target bfd_elf32_bigarmqnx_vec;
extern const bfd_target bfd_elf32_bigmips_vec;
extern const bfd_target bfd_elf32_cris_vec;
extern const bfd_target bfd_elf32_d10v_vec;
@@ -522,7 +525,6 @@ extern const bfd_target bfd_elf32_hppa_vec;
extern const bfd_target bfd_elf32_i370_vec;
extern const bfd_target bfd_elf32_i386_freebsd_vec;
extern const bfd_target bfd_elf32_i386_vec;
-extern const bfd_target bfd_elf32_i386qnx_vec;
extern const bfd_target bfd_elf32_i860_little_vec;
extern const bfd_target bfd_elf32_i860_vec;
extern const bfd_target bfd_elf32_i960_vec;
@@ -533,7 +535,6 @@ extern const bfd_target bfd_elf32_little_generic_vec;
extern const bfd_target bfd_elf32_littlearc_vec;
extern const bfd_target bfd_elf32_littlearm_oabi_vec;
extern const bfd_target bfd_elf32_littlearm_vec;
-extern const bfd_target bfd_elf32_littlearmqnx_vec;
extern const bfd_target bfd_elf32_littlemips_vec;
extern const bfd_target bfd_elf32_m32r_vec;
extern const bfd_target bfd_elf32_m68hc11_vec;
@@ -554,8 +555,6 @@ 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_powerpcleqnx_vec;
-extern const bfd_target bfd_elf32_powerpcqnx_vec;
extern const bfd_target bfd_elf32_s390_vec;
extern const bfd_target bfd_elf32_sh64_vec;
extern const bfd_target bfd_elf32_sh64l_vec;
@@ -568,9 +567,7 @@ extern const bfd_target bfd_elf32_shblin_vec;
extern const bfd_target bfd_elf32_shl_vec;
extern const bfd_target bfd_elf32_shlin_vec;
extern const bfd_target bfd_elf32_shlnbsd_vec;
-extern const bfd_target bfd_elf32_shlqnx_vec;
extern const bfd_target bfd_elf32_shnbsd_vec;
-extern const bfd_target bfd_elf32_shqnx_vec;
extern const bfd_target bfd_elf32_sparc_vec;
extern const bfd_target bfd_elf32_tradbigmips_vec;
extern const bfd_target bfd_elf32_tradlittlemips_vec;
@@ -652,6 +649,9 @@ extern const bfd_target m68knetbsd_vec;
extern const bfd_target m68ksysvcoff_vec;
extern const bfd_target m88kbcs_vec;
extern const bfd_target m88kmach3_vec;
+extern const bfd_target mach_o_be_vec;
+extern const bfd_target mach_o_le_vec;
+extern const bfd_target mach_o_fat_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;
@@ -668,6 +668,8 @@ extern const bfd_target or32coff_big_vec;
extern const bfd_target pc532machaout_vec;
extern const bfd_target pc532netbsd_vec;
extern const bfd_target pdp11_aout_vec;
+extern const bfd_target pef_vec;
+extern const bfd_target pef_xlib_vec;
extern const bfd_target pmac_xcoff_vec;
extern const bfd_target ppcboot_vec;
extern const bfd_target riscix_vec;
@@ -687,6 +689,7 @@ extern const bfd_target sparclynx_aout_vec;
extern const bfd_target sparclynx_coff_vec;
extern const bfd_target sparcnetbsd_vec;
extern const bfd_target sunos_big_vec;
+extern const bfd_target sym_vec;
extern const bfd_target tic30_aout_vec;
extern const bfd_target tic30_coff_vec;
extern const bfd_target tic4x_coff0_beh_vec;
@@ -793,7 +796,6 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf32_bigarc_vec,
&bfd_elf32_bigarm_oabi_vec,
&bfd_elf32_bigarm_vec,
- &bfd_elf32_bigarmqnx_vec,
&bfd_elf32_bigmips_vec,
&bfd_elf32_cris_vec,
&bfd_elf32_d10v_vec,
@@ -807,7 +809,6 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf32_i370_vec,
&bfd_elf32_i386_freebsd_vec,
&bfd_elf32_i386_vec,
- &bfd_elf32_i386qnx_vec,
&bfd_elf32_i860_little_vec,
&bfd_elf32_i860_vec,
&bfd_elf32_i960_vec,
@@ -820,7 +821,6 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf32_littlearc_vec,
&bfd_elf32_littlearm_oabi_vec,
&bfd_elf32_littlearm_vec,
- &bfd_elf32_littlearmqnx_vec,
&bfd_elf32_littlemips_vec,
&bfd_elf32_m32r_vec,
&bfd_elf32_m68hc11_vec,
@@ -843,22 +843,20 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf32_pjl_vec,
&bfd_elf32_powerpc_vec,
&bfd_elf32_powerpcle_vec,
- &bfd_elf32_powerpcleqnx_vec,
- &bfd_elf32_powerpcqnx_vec,
&bfd_elf32_s390_vec,
&bfd_elf32_sh_vec,
&bfd_elf32_shblin_vec,
&bfd_elf32_shl_vec,
&bfd_elf32_shlin_vec,
&bfd_elf32_shlnbsd_vec,
- &bfd_elf32_shlqnx_vec,
&bfd_elf32_shnbsd_vec,
- &bfd_elf32_shqnx_vec,
#ifdef BFD64
&bfd_elf32_sh64_vec,
&bfd_elf32_sh64l_vec,
&bfd_elf32_sh64lnbsd_vec,
&bfd_elf32_sh64nbsd_vec,
+ &bfd_elf32_sh64lin_vec,
+ &bfd_elf32_sh64blin_vec,
#endif
&bfd_elf32_sparc_vec,
&bfd_elf32_tradbigmips_vec,
@@ -889,6 +887,8 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf64_sh64l_vec,
&bfd_elf64_sh64lnbsd_vec,
&bfd_elf64_sh64nbsd_vec,
+ &bfd_elf64_sh64lin_vec,
+ &bfd_elf64_sh64blin_vec,
#if 0
&bfd_elf64_sparc_vec,
#endif
@@ -967,6 +967,9 @@ static const bfd_target * const _bfd_target_vector[] = {
&m68ksysvcoff_vec,
&m88kbcs_vec,
&m88kmach3_vec,
+ &mach_o_be_vec,
+ &mach_o_le_vec,
+ &mach_o_fat_vec,
&mcore_pe_big_vec,
&mcore_pe_little_vec,
&mcore_pei_big_vec,
@@ -994,6 +997,8 @@ static const bfd_target * const _bfd_target_vector[] = {
&pc532machaout_vec,
&pc532netbsd_vec,
&pdp11_aout_vec,
+ &pef_vec,
+ &pef_xlib_vec,
#if 0
/* This has the same magic number as RS/6000. */
&pmac_xcoff_vec,
@@ -1023,6 +1028,7 @@ static const bfd_target * const _bfd_target_vector[] = {
&sparclynx_coff_vec,
&sparcnetbsd_vec,
&sunos_big_vec,
+ &sym_vec,
&tic30_aout_vec,
&tic30_coff_vec,
&tic54x_coff0_beh_vec,
@@ -1106,6 +1112,17 @@ const bfd_target *bfd_default_vector[] = {
NULL
};
+/* bfd_associated_vector[] contains the associated target vectors used
+ to reduce the ambiguity in bfd_check_format_matches. */
+
+static const bfd_target *_bfd_associated_vector[] = {
+#ifdef ASSOCIATED_VECS
+ ASSOCIATED_VECS,
+#endif
+ NULL
+};
+const bfd_target * const *bfd_associated_vector = _bfd_associated_vector;
+
/* When there is an ambiguous match, bfd_check_format_matches puts the
names of the matching targets in an array. This variable is the maximum
number of entries that the array could possibly need. */
diff --git a/bfd/version.h b/bfd/version.h
index cb9b9a4c491..001aec54aba 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1,3 +1,3 @@
-#define BFD_VERSION_DATE 20021025
+#define BFD_VERSION_DATE 20021115
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_string@
diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c
index 002412232dc..10fbb2d35c7 100644
--- a/bfd/vms-gsd.c
+++ b/bfd/vms-gsd.c
@@ -420,7 +420,7 @@ _bfd_vms_slurp_gsd (abfd, objtype)
{
bfd_set_error (bfd_error_no_memory);
return -1;
- }
+ }
}
}
else
@@ -661,13 +661,13 @@ _bfd_vms_slurp_gsd (abfd, objtype)
}
else /* symbol reference */
{
- symbol->name =
+ symbol->name =
_bfd_vms_save_counted_string (vms_rec+8);
#if VMS_DEBUG
vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount,
symbol->name, old_flags, flag2str(gsyflagdesc, old_flags));
#endif
- symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
+ symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
}
symbol->flags = new_flags;
@@ -901,7 +901,7 @@ _bfd_vms_write_gsd (abfd, objtype)
unsigned long ca_psindx = 0;
unsigned long psindx;
- if (old_flags & BSF_FUNCTION)
+ if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
{
code_address = ((asymbol *) (symbol->udata.p))->value;
ca_psindx = ((asymbol *) (symbol->udata.p))->section->index;
diff --git a/bfd/vms.c b/bfd/vms.c
index fc6bcc3e161..41a9717fcdd 100644
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -382,6 +382,7 @@ vms_object_p (abfd)
const struct bfd_target *target_vector = 0;
const bfd_arch_info_type *arch = 0;
PTR tdata_save = abfd->tdata.any;
+ bfd_vma saddr_save = bfd_get_start_address (abfd);
#if VMS_DEBUG
vms_debug (1, "vms_object_p(%p)\n", abfd);
@@ -519,6 +520,7 @@ vms_object_p (abfd)
if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
bfd_release (abfd, abfd->tdata.any);
abfd->tdata.any = tdata_save;
+ bfd_set_start_address (abfd, saddr_save);
return NULL;
}
diff --git a/bfd/xsym.c b/bfd/xsym.c
new file mode 100644
index 00000000000..e6b3c4b11d5
--- /dev/null
+++ b/bfd/xsym.c
@@ -0,0 +1,2484 @@
+/* xSYM symbol-file support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ 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 "xsym.h"
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+#define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
+#define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define bfd_sym_new_section_hook _bfd_generic_new_section_hook
+#define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
+#define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
+#define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
+#define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+#define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
+#define bfd_sym_get_section_contents _bfd_generic_get_section_contents
+#define bfd_sym_set_section_contents _bfd_generic_set_section_contents
+#define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
+#define bfd_sym_bfd_relax_section bfd_generic_relax_section
+#define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
+#define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
+#define bfd_sym_bfd_discard_group bfd_generic_discard_group
+#define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
+#define bfd_sym_bfd_final_link _bfd_generic_final_link
+#define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
+#define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+
+static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
+static unsigned long compute_offset
+ PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
+
+extern const bfd_target sym_vec;
+
+static int
+pstrcmp (a, b)
+ unsigned char *a;
+ unsigned char *b;
+{
+ unsigned char clen;
+ int ret;
+
+ clen = (a[0] > b[0]) ? a[0] : b[0];
+ ret = memcmp (a + 1, b + 1, clen);
+ if (ret != 0)
+ return ret;
+
+ if (a[0] == b[0])
+ return 0;
+ else if (a[0] < b[0])
+ return -1;
+ else
+ return 0;
+}
+
+static unsigned long
+compute_offset (first_page, page_size, entry_size, index)
+ unsigned long first_page;
+ unsigned long page_size;
+ unsigned long entry_size;
+ unsigned long index;
+{
+ unsigned long entries_per_page = page_size / entry_size;
+ unsigned long page_number = first_page + (index / entries_per_page);
+ unsigned long page_offset = (index % entries_per_page) * entry_size;
+
+ return (page_number * page_size) + page_offset;
+}
+
+boolean
+bfd_sym_mkobject (abfd)
+ bfd *abfd ATTRIBUTE_UNUSED;
+{
+ return (boolean) true;
+}
+
+void
+bfd_sym_print_symbol (abfd, afile, symbol, how)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ PTR afile ATTRIBUTE_UNUSED;
+ asymbol *symbol ATTRIBUTE_UNUSED;
+ bfd_print_symbol_type how ATTRIBUTE_UNUSED;
+{
+ return;
+}
+
+boolean
+bfd_sym_valid (abfd)
+ bfd *abfd;
+{
+ if (abfd == NULL || abfd->xvec == NULL)
+ return 0;
+
+ return abfd->xvec == &sym_vec;
+}
+
+unsigned char *
+bfd_sym_read_name_table (abfd, dshb)
+ bfd *abfd;
+ bfd_sym_header_block *dshb;
+{
+ unsigned char *rstr;
+ long ret;
+ size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
+ size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
+
+ rstr = (unsigned char *) bfd_alloc (abfd, table_size);
+ if (rstr == NULL)
+ return rstr;
+
+ bfd_seek (abfd, table_offset, SEEK_SET);
+ ret = bfd_bread (rstr, table_size, abfd);
+ if (ret < 0 || (unsigned long) ret != table_size)
+ {
+ bfd_release (abfd, rstr);
+ return NULL;
+ }
+
+ return rstr;
+}
+
+void
+bfd_sym_parse_file_reference_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_file_reference *entry;
+{
+ BFD_ASSERT (len == 6);
+
+ entry->fref_frte_index = bfd_getb16 (buf);
+ entry->fref_offset = bfd_getb32 (buf + 2);
+}
+
+void
+bfd_sym_parse_disk_table_v32 (buf, len, table)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_table_info *table;
+{
+ BFD_ASSERT (len == 8);
+
+ table->dti_first_page = bfd_getb16 (buf);
+ table->dti_page_count = bfd_getb16 (buf + 2);
+ table->dti_object_count = bfd_getb32 (buf + 4);
+}
+
+void
+bfd_sym_parse_header_v32 (buf, len, header)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_header_block *header;
+{
+ BFD_ASSERT (len == 154);
+
+ memcpy (header->dshb_id, buf, 32);
+ header->dshb_page_size = bfd_getb16 (buf + 32);
+ header->dshb_hash_page = bfd_getb16 (buf + 34);
+ header->dshb_root_mte = bfd_getb16 (buf + 36);
+ header->dshb_mod_date = bfd_getb32 (buf + 38);
+
+ bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
+ bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
+ bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
+ bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
+ bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
+ bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
+ bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
+ bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
+ bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
+ bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
+ bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
+ bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
+ bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
+
+ memcpy (&header->dshb_file_creator, buf + 146, 4);
+ memcpy (&header->dshb_file_type, buf + 150, 4);
+}
+
+int
+bfd_sym_read_header_v32 (abfd, header)
+ bfd *abfd;
+ bfd_sym_header_block *header;
+{
+ unsigned char buf[154];
+ long ret;
+
+ ret = bfd_bread (buf, 154, abfd);
+ if (ret != 154)
+ return -1;
+
+ bfd_sym_parse_header_v32 (buf, 154, header);
+
+ return 0;
+}
+
+int
+bfd_sym_read_header_v34 (abfd, header)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_sym_header_block *header ATTRIBUTE_UNUSED;
+{
+ abort ();
+}
+
+int
+bfd_sym_read_header (abfd, header, version)
+ bfd *abfd;
+ bfd_sym_header_block *header;
+ bfd_sym_version version;
+{
+ switch (version)
+ {
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ return bfd_sym_read_header_v34 (abfd, header);
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ return bfd_sym_read_header_v32 (abfd, header);
+ case BFD_SYM_VERSION_3_1:
+ default:
+ return false;
+ }
+}
+
+int
+bfd_sym_read_version (abfd, version)
+ bfd *abfd;
+ bfd_sym_version *version;
+{
+ unsigned char version_string[32];
+ long ret;
+
+ ret = bfd_bread (version_string, sizeof (version_string), abfd);
+ if (ret != sizeof (version_string))
+ return -1;
+
+ if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
+ *version = BFD_SYM_VERSION_3_1;
+ else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
+ *version = BFD_SYM_VERSION_3_2;
+ else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
+ *version = BFD_SYM_VERSION_3_3;
+ else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
+ *version = BFD_SYM_VERSION_3_4;
+ else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
+ *version = BFD_SYM_VERSION_3_5;
+ else
+ return -1;
+
+ return 0;
+}
+
+void
+bfd_sym_display_table_summary (f, dti, name)
+ FILE *f;
+ bfd_sym_table_info *dti;
+ const char *name;
+{
+ fprintf (f, "%-6s %13ld %13ld %13ld\n",
+ name,
+ dti->dti_first_page,
+ dti->dti_page_count,
+ dti->dti_object_count);
+}
+
+void
+bfd_sym_display_header (f, dshb)
+ FILE *f;
+ bfd_sym_header_block *dshb;
+{
+ fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
+ fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
+ fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
+ fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
+ fprintf (f, " Modification Date: ");
+ fprintf (f, "[unimplemented]");
+ fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
+
+ fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
+ dshb->dshb_file_creator, dshb->dshb_file_type);
+
+ fprintf (f, "Table Name First Page Page Count Object Count\n");
+ fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+
+ bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
+ bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
+ bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
+
+ fprintf (f, "\n");
+}
+
+void
+bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_resources_table_entry *entry;
+{
+ BFD_ASSERT (len == 18);
+
+ memcpy (&entry->rte_res_type, buf, 4);
+ entry->rte_res_number = bfd_getb16 (buf + 4);
+ entry->rte_nte_index = bfd_getb32 (buf + 6);
+ entry->rte_mte_first = bfd_getb16 (buf + 10);
+ entry->rte_mte_last = bfd_getb16 (buf + 12);
+ entry->rte_res_size = bfd_getb32 (buf + 14);
+}
+
+void
+bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_modules_table_entry *entry;
+{
+ BFD_ASSERT (len == 46);
+
+ entry->mte_rte_index = bfd_getb16 (buf);
+ entry->mte_res_offset = bfd_getb32 (buf + 2);
+ entry->mte_size = bfd_getb32 (buf + 6);
+ entry->mte_kind = buf[10];
+ entry->mte_scope = buf[11];
+ entry->mte_parent = bfd_getb16 (buf + 12);
+ bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
+ entry->mte_imp_end = bfd_getb32 (buf + 20);
+ entry->mte_nte_index = bfd_getb32 (buf + 24);
+ entry->mte_cmte_index = bfd_getb16 (buf + 28);
+ entry->mte_cvte_index = bfd_getb32 (buf + 30);
+ entry->mte_clte_index = bfd_getb16 (buf + 34);
+ entry->mte_ctte_index = bfd_getb16 (buf + 36);
+ entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
+ entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
+}
+
+void
+bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_file_references_table_entry *entry;
+{
+ unsigned int type;
+
+ BFD_ASSERT (len == 10);
+
+ memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
+ type = bfd_getb16 (buf);
+
+ switch (type)
+ {
+ case BFD_SYM_END_OF_LIST_3_2:
+ entry->generic.type = BFD_SYM_END_OF_LIST;
+ break;
+
+ case BFD_SYM_FILE_NAME_INDEX_3_2:
+ entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
+ entry->filename.nte_index = bfd_getb32 (buf + 2);
+ entry->filename.mod_date = bfd_getb32 (buf + 6);
+ break;
+
+ default:
+ entry->entry.mte_index = type;
+ entry->entry.file_offset = bfd_getb32 (buf + 2);
+ }
+}
+
+void
+bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_contained_modules_table_entry *entry;
+{
+ unsigned int type;
+
+ BFD_ASSERT (len == 6);
+
+ memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
+ type = bfd_getb16 (buf);
+
+ switch (type)
+ {
+ case BFD_SYM_END_OF_LIST_3_2:
+ entry->generic.type = BFD_SYM_END_OF_LIST;
+ break;
+
+ default:
+ entry->entry.mte_index = type;
+ entry->entry.nte_index = bfd_getb32 (buf + 2);
+ break;
+ }
+}
+
+void
+bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_contained_variables_table_entry *entry;
+{
+ unsigned int type;
+
+ BFD_ASSERT (len == 26);
+
+ memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
+ type = bfd_getb16 (buf);
+
+ switch (type)
+ {
+ case BFD_SYM_END_OF_LIST_3_2:
+ entry->generic.type = BFD_SYM_END_OF_LIST;
+ break;
+
+ case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
+ entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
+ bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
+ break;
+
+ default:
+ entry->entry.tte_index = type;
+ entry->entry.nte_index = bfd_getb32 (buf + 2);
+ entry->entry.file_delta = bfd_getb16 (buf + 6);
+ entry->entry.scope = buf[8];
+ entry->entry.la_size = buf[9];
+
+ if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
+ {
+ entry->entry.address.scstruct.sca_kind = buf[10];
+ entry->entry.address.scstruct.sca_class = buf[11];
+ entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
+ }
+ else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
+ {
+ memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
+ entry->entry.address.lastruct.la_kind = buf[23];
+ }
+ else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
+ {
+ entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
+ entry->entry.address.biglastruct.big_la_kind = buf[12];
+ }
+ }
+}
+
+void
+bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_contained_statements_table_entry *entry;
+{
+ unsigned int type;
+
+ BFD_ASSERT (len == 8);
+
+ memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
+ type = bfd_getb16 (buf);
+
+ switch (type)
+ {
+ case BFD_SYM_END_OF_LIST_3_2:
+ entry->generic.type = BFD_SYM_END_OF_LIST;
+ break;
+
+ case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
+ entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
+ bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
+ break;
+
+ default:
+ entry->entry.mte_index = type;
+ entry->entry.mte_offset = bfd_getb16 (buf + 2);
+ entry->entry.file_delta = bfd_getb32 (buf + 4);
+ break;
+ }
+}
+
+void
+bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_contained_labels_table_entry *entry;
+{
+ unsigned int type;
+
+ BFD_ASSERT (len == 12);
+
+ memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
+ type = bfd_getb16 (buf);
+
+ switch (type)
+ {
+ case BFD_SYM_END_OF_LIST_3_2:
+ entry->generic.type = BFD_SYM_END_OF_LIST;
+ break;
+
+ case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
+ entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
+ bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
+ break;
+
+ default:
+ entry->entry.mte_index = type;
+ entry->entry.mte_offset = bfd_getb16 (buf + 2);
+ entry->entry.nte_index = bfd_getb32 (buf + 4);
+ entry->entry.file_delta = bfd_getb16 (buf + 8);
+ entry->entry.scope = bfd_getb16 (buf + 10);
+ break;
+ }
+}
+
+void
+bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
+ unsigned char *buf;
+ size_t len;
+ bfd_sym_type_table_entry *entry;
+{
+ BFD_ASSERT (len == 4);
+
+ *entry = bfd_getb32 (buf);
+}
+
+int
+bfd_sym_fetch_resources_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_resources_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_resources_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size;
+ unsigned char buf[18];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ return -1;
+
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 18;
+ parser = bfd_sym_parse_resources_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_1:
+ default:
+ return -1;
+ }
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_modules_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_modules_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_modules_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size;
+ unsigned char buf[46];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ return -1;
+
+ case BFD_SYM_VERSION_3_3:
+ entry_size = 46;
+ parser = bfd_sym_parse_modules_table_entry_v33;
+ break;
+
+ case BFD_SYM_VERSION_3_2:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ return -1;
+ }
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_file_references_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_file_references_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[8];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 10;
+ parser = bfd_sym_parse_file_references_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_contained_modules_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_contained_modules_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[6];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 6;
+ parser = bfd_sym_parse_contained_modules_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_contained_variables_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_contained_variables_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[26];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 26;
+ parser = bfd_sym_parse_contained_variables_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_contained_statements_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_contained_statements_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[8];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 8;
+ parser = bfd_sym_parse_contained_statements_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_contained_labels_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_contained_labels_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[12];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 12;
+ parser = bfd_sym_parse_contained_labels_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_contained_types_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_contained_types_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[0];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 0;
+ parser = NULL;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_file_references_index_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_file_references_index_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[0];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 0;
+ parser = NULL;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_constant_pool_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_constant_pool_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[0];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 0;
+ parser = NULL;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_type_table_entry (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_type_table_entry *entry;
+ unsigned long index;
+{
+ void (*parser) PARAMS ((unsigned char *, size_t,
+ bfd_sym_type_table_entry *));
+ unsigned long offset;
+ unsigned long entry_size = 0;
+ unsigned char buf[4];
+ bfd_sym_data_struct *sdata = NULL;
+
+ parser = NULL;
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ switch (sdata->version)
+ {
+ case BFD_SYM_VERSION_3_3:
+ case BFD_SYM_VERSION_3_2:
+ entry_size = 4;
+ parser = bfd_sym_parse_type_table_entry_v32;
+ break;
+
+ case BFD_SYM_VERSION_3_5:
+ case BFD_SYM_VERSION_3_4:
+ case BFD_SYM_VERSION_3_1:
+ default:
+ break;
+ }
+
+ if (parser == NULL)
+ return -1;
+
+ offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
+ sdata->header.dshb_page_size,
+ entry_size, index);
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+ if (bfd_bread (buf, entry_size, abfd) != entry_size)
+ return -1;
+
+ (*parser) (buf, entry_size, entry);
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
+ bfd *abfd;
+ bfd_sym_type_information_table_entry *entry;
+ unsigned long offset;
+{
+ unsigned char buf[4];
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return -1;
+
+ if (bfd_seek (abfd, offset, SEEK_SET) < 0)
+ return -1;
+
+ if (bfd_bread (buf, 4, abfd) != 4)
+ return -1;
+ entry->nte_index = bfd_getb32 (buf);
+
+ if (bfd_bread (buf, 2, abfd) != 2)
+ return -1;
+ entry->physical_size = bfd_getb16 (buf);
+
+ if (entry->physical_size & 0x8000)
+ {
+ if (bfd_bread (buf, 4, abfd) != 4)
+ return -1;
+ entry->physical_size &= 0x7fff;
+ entry->logical_size = bfd_getb32 (buf);
+ entry->offset = offset + 10;
+ }
+ else
+ {
+ if (bfd_bread (buf, 2, abfd) != 2)
+ return -1;
+ entry->physical_size &= 0x7fff;
+ entry->logical_size = bfd_getb16 (buf);
+ entry->offset = offset + 8;
+ }
+
+ return 0;
+}
+
+int
+bfd_sym_fetch_type_table_information (abfd, entry, index)
+ bfd *abfd;
+ bfd_sym_type_information_table_entry *entry;
+ unsigned long index;
+{
+ bfd_sym_type_table_entry tindex;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (sdata->header.dshb_tte.dti_object_count <= 99)
+ return -1;
+ if (index < 100)
+ return -1;
+
+ if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
+ return -1;
+ if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
+ return -1;
+
+ return 0;
+}
+
+const unsigned char *
+bfd_sym_symbol_name (abfd, index)
+ bfd *abfd;
+ unsigned long index;
+{
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (index == 0)
+ return "";
+
+ index *= 2;
+ if ((index / sdata->header.dshb_page_size)
+ > sdata->header.dshb_nte.dti_page_count)
+ return "\009[INVALID]";
+
+ return (const unsigned char *) sdata->name_table + index;
+}
+
+const unsigned char *
+bfd_sym_module_name (abfd, index)
+ bfd *abfd;
+ unsigned long index;
+{
+ bfd_sym_modules_table_entry entry;
+
+ if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
+ return "\011[INVALID]";
+
+ return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
+}
+
+const char *
+bfd_sym_unparse_storage_kind (kind)
+ enum bfd_sym_storage_kind kind;
+{
+ switch (kind)
+ {
+ case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
+ case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
+ case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
+ case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
+ default: return "[UNKNOWN]";
+ }
+}
+
+const char *
+bfd_sym_unparse_storage_class (kind)
+ enum bfd_sym_storage_class kind;
+{
+ switch (kind)
+ {
+ case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
+ case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
+ case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
+ case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
+ case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
+ case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
+ case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
+ case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
+ default: return "[UNKNOWN]";
+ }
+}
+
+const char *
+bfd_sym_unparse_module_kind (kind)
+ enum bfd_sym_module_kind kind;
+{
+ switch (kind)
+ {
+ case BFD_SYM_MODULE_KIND_NONE: return "NONE";
+ case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
+ case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
+ case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
+ case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
+ case BFD_SYM_MODULE_KIND_DATA: return "DATA";
+ case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
+ default: return "[UNKNOWN]";
+ }
+}
+
+const char *
+bfd_sym_unparse_symbol_scope (scope)
+ enum bfd_sym_symbol_scope scope;
+{
+ switch (scope)
+ {
+ case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
+ case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
+ default:
+ return "[UNKNOWN]";
+ }
+}
+
+void
+bfd_sym_print_file_reference (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_file_reference *entry;
+{
+ bfd_sym_file_references_table_entry frtentry;
+ int ret;
+
+ ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
+ entry->fref_frte_index);
+ fprintf (f, "FILE ");
+
+ if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
+ fprintf (f, "[INVALID]");
+ else
+ fprintf (f, "\"%.*s\"",
+ bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
+ &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
+
+ fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
+}
+
+void
+bfd_sym_print_resources_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_resources_table_entry *entry;
+{
+ fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
+ bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
+ &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
+ entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
+ entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
+}
+
+void
+bfd_sym_print_modules_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_modules_table_entry *entry;
+{
+ fprintf (f, "\"%.*s\" (NTE %lu)",
+ bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
+ &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
+ entry->mte_nte_index);
+
+ fprintf (f, "\n ");
+
+ bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
+ fprintf (f, " range %lu -- %lu",
+ entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
+
+ fprintf (f, "\n ");
+
+ fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
+ fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
+
+ fprintf (f, ", RTE %lu, offset %lu, size %lu",
+ entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
+
+ fprintf (f, "\n ");
+
+ fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
+ entry->mte_cmte_index, entry->mte_cvte_index,
+ entry->mte_clte_index, entry->mte_ctte_index,
+ entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
+
+ if (entry->mte_parent != 0)
+ fprintf (f, ", parent %lu", entry->mte_parent);
+ else
+ fprintf (f, ", no parent");
+
+ if (entry->mte_cmte_index != 0)
+ fprintf (f, ", child %lu", entry->mte_cmte_index);
+ else
+ fprintf (f, ", no child");
+
+#if 0
+ {
+ MTE bfd_sym_modules_table_entry pentry;
+
+ ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
+ if (ret < 0)
+ fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
+ else
+ fprintf (f, " parent MTE %lu \"%.*s\"\n",
+ entry->mte_parent,
+ bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
+ &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
+ }
+#endif
+}
+
+void
+bfd_sym_print_file_references_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_file_references_table_entry *entry;
+{
+ switch (entry->generic.type)
+ {
+ case BFD_SYM_FILE_NAME_INDEX:
+ fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
+ bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
+ &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
+ entry->filename.nte_index);
+
+ fprintf (f, "[UNIMPLEMENTED]");
+ /* printModDate (entry->filename.mod_date); */
+ fprintf (f, " (0x%lx)", entry->filename.mod_date);
+ break;
+
+ case BFD_SYM_END_OF_LIST:
+ fprintf (f, "END");
+ break;
+
+ default:
+ fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
+ bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
+ &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
+ entry->entry.mte_index,
+ entry->entry.file_offset);
+ break;
+ }
+}
+
+void
+bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_contained_modules_table_entry *entry;
+{
+ switch (entry->generic.type)
+ {
+ case BFD_SYM_END_OF_LIST:
+ fprintf (f, "END");
+ break;
+
+ default:
+ fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
+ bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
+ &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
+ entry->entry.mte_index,
+ entry->entry.nte_index);
+ break;
+ }
+}
+
+void
+bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_contained_variables_table_entry *entry;
+{
+ if (entry->generic.type == BFD_SYM_END_OF_LIST)
+ {
+ fprintf (f, "END");
+ return;
+ }
+
+ if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
+ {
+ bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
+ fprintf (f, " offset %lu", entry->file.fref.fref_offset);
+ return;
+ }
+
+ fprintf (f, "\"%.*s\" (NTE %lu)",
+ bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
+ &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
+ entry->entry.nte_index);
+
+ fprintf (f, ", TTE %lu", entry->entry.tte_index);
+ fprintf (f, ", offset %lu", entry->entry.file_delta);
+ fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
+
+ if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
+ fprintf (f, ", latype %s, laclass %s, laoffset %lu",
+ bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
+ bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
+ entry->entry.address.scstruct.sca_offset);
+ else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
+ {
+ unsigned long i;
+
+ fprintf (f, ", la [");
+ for (i = 0; i < entry->entry.la_size; i++)
+ fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
+ fprintf (f, "]");
+ }
+ else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
+ fprintf (f, ", bigla %lu, biglakind %u",
+ entry->entry.address.biglastruct.big_la,
+ entry->entry.address.biglastruct.big_la_kind);
+
+ else
+ fprintf (f, ", la [INVALID]");
+}
+
+void
+bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_contained_statements_table_entry *entry;
+{
+ if (entry->generic.type == BFD_SYM_END_OF_LIST)
+ {
+ fprintf (f, "END");
+ return;
+ }
+
+ if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
+ {
+ bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
+ fprintf (f, " offset %lu", entry->file.fref.fref_offset);
+ return;
+ }
+
+ fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
+ bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
+ &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
+ entry->entry.mte_index,
+ entry->entry.mte_offset,
+ entry->entry.file_delta);
+}
+
+void
+bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_contained_labels_table_entry *entry;
+{
+ if (entry->generic.type == BFD_SYM_END_OF_LIST)
+ {
+ fprintf (f, "END");
+ return;
+ }
+
+ if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
+ {
+ bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
+ fprintf (f, " offset %lu", entry->file.fref.fref_offset);
+ return;
+ }
+
+ fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
+ bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
+ &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
+ entry->entry.mte_index,
+ entry->entry.mte_offset,
+ entry->entry.file_delta,
+ bfd_sym_unparse_symbol_scope (entry->entry.scope));
+}
+
+void
+bfd_sym_print_contained_types_table_entry (abfd, f, entry)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ FILE *f;
+ bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
+{
+ fprintf (f, "[UNIMPLEMENTED]");
+}
+
+const char *
+bfd_sym_type_operator_name (num)
+ unsigned char num;
+{
+ switch (num)
+ {
+ case 1: return "TTE";
+ case 2: return "PointerTo";
+ case 3: return "ScalarOf";
+ case 4: return "ConstantOf";
+ case 5: return "EnumerationOf";
+ case 6: return "VectorOf";
+ case 7: return "RecordOf";
+ case 8: return "UnionOf";
+ case 9: return "SubRangeOf";
+ case 10: return "SetOf";
+ case 11: return "NamedTypeOf";
+ case 12: return "ProcOf";
+ case 13: return "ValueOf";
+ case 14: return "ArrayOf";
+ default: return "[UNKNOWN OPERATOR]";
+ }
+}
+
+const char *
+bfd_sym_type_basic_name (num)
+ unsigned char num;
+{
+ switch (num)
+ {
+ case 0: return "void";
+ case 1: return "pascal string";
+ case 2: return "unsigned long";
+ case 3: return "signed long";
+ case 4: return "extended (10 bytes)";
+ case 5: return "pascal boolean (1 byte)";
+ case 6: return "unsigned byte";
+ case 7: return "signed byte";
+ case 8: return "character (1 byte)";
+ case 9: return "wide character (2 bytes)";
+ case 10: return "unsigned short";
+ case 11: return "signed short";
+ case 12: return "singled";
+ case 13: return "double";
+ case 14: return "extended (12 bytes)";
+ case 15: return "computational (8 bytes)";
+ case 16: return "c string";
+ case 17: return "as-is string";
+ default: return "[UNKNOWN BASIC TYPE]";
+ }
+}
+
+int
+bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
+ unsigned char *buf;
+ unsigned long len;
+ unsigned long offset;
+ unsigned long *offsetptr;
+ long *value;
+{
+ int ret;
+
+ if (offset >= len)
+ {
+ *value = 0;
+ offset += 0;
+ ret = -1;
+ }
+ else if (! (buf[offset] & 0x80))
+ {
+ *value = buf[offset];
+ offset += 1;
+ ret = 0;
+ }
+ else if (buf[offset] == 0xc0)
+ {
+ if ((offset + 5) > len)
+ {
+ *value = 0;
+ offset = len;
+ ret = -1;
+ }
+ else
+ {
+ *value = bfd_getb32 (buf + offset + 1);
+ offset += 5;
+ ret = 0;
+ }
+ }
+ else if ((buf[offset] & 0xc0) == 0xc0)
+ {
+ *value = -(buf[offset] & 0x3f);
+ offset += 1;
+ ret = 0;
+ }
+ else if ((buf[offset] & 0xc0) == 0x80)
+ {
+ if ((offset + 2) > len)
+ {
+ *value = 0;
+ offset = len;
+ ret = -1;
+ }
+ else
+ {
+ *value = bfd_getb16 (buf + offset) & 0x3fff;
+ offset += 2;
+ ret = 0;
+ }
+ }
+ else
+ abort ();
+
+ if (offsetptr != NULL)
+ *offsetptr = offset;
+
+ return ret;
+}
+
+void
+bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
+ bfd *abfd;
+ FILE *f;
+ unsigned char *buf;
+ unsigned long len;
+ unsigned long offset;
+ unsigned long *offsetptr;
+{
+ unsigned int type;
+
+ if (offset >= len)
+ {
+ fprintf (f, "[NULL]");
+
+ if (offsetptr != NULL)
+ *offsetptr = offset;
+ return;
+ }
+
+ type = buf[offset];
+ offset++;
+
+ if (! (type & 0x80))
+ {
+ fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
+
+ if (offsetptr != NULL)
+ *offsetptr = offset;
+ return;
+ }
+
+ if (type & 0x40)
+ fprintf (f, "[packed ");
+ else
+ fprintf (f, "[");
+
+ switch (type & 0x3f)
+ {
+ case 1:
+ {
+ long value;
+ bfd_sym_type_information_table_entry tinfo;
+
+ bfd_sym_fetch_long (buf, len, offset, &offset, &value);
+ if (value <= 0)
+ fprintf (f, "[INVALID]");
+ else
+ {
+ if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
+ fprintf (f, "[INVALID]");
+ else
+ fprintf (f, "\"%.*s\"",
+ bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
+ &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
+ }
+ fprintf (f, " (TTE %lu)", value);
+ break;
+ }
+
+ case 2:
+ fprintf (f, "pointer (0x%x) to ", type);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ break;
+
+ case 3:
+ {
+ unsigned long value;
+
+ fprintf (f, "scalar (0x%x) of ", type);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &value);
+ fprintf (f, " (%lu)", value);
+ break;
+ }
+
+ case 5:
+ {
+ unsigned long lower, upper, nelem;
+ unsigned long i;
+
+ fprintf (f, "enumeration (0x%x) of ", type);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
+ fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
+
+ for (i = 0; i < nelem; i++)
+ {
+ fprintf (f, "\n ");
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ }
+ break;
+ }
+
+ case 6:
+ fprintf (f, "vector (0x%x)", type);
+ fprintf (f, "\n index ");
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ fprintf (f, "\n target ");
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ break;
+
+ case 7:
+ case 8:
+ {
+ long nrec, eloff, i;
+
+ if ((type & 0x3f) == 7)
+ fprintf (f, "record (0x%x) of ", type);
+ else
+ fprintf (f, "union (0x%x) of ", type);
+
+ bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
+ fprintf (f, "%lu elements: ", nrec);
+
+ for (i = 0; i < nrec; i++)
+ {
+ bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
+ fprintf (f, "\n ");
+ fprintf (f, "offset %lu: ", eloff);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ }
+ break;
+ }
+
+ case 9:
+ fprintf (f, "subrange (0x%x) of ", type);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ fprintf (f, " lower ");
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ fprintf (f, " upper ");
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ break;
+
+ case 11:
+ {
+ long value;
+
+ fprintf (f, "named type (0x%x) ", type);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &value);
+ if (value <= 0)
+ fprintf (f, "[INVALID]");
+ else
+ fprintf (f, "\"%.*s\"",
+ bfd_sym_symbol_name (abfd, value)[0],
+ &bfd_sym_symbol_name (abfd, value)[1]);
+
+ fprintf (f, " (NTE %lu) with type ", value);
+ bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
+ break;
+ }
+
+ default:
+ fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
+ break;
+ }
+
+ if (type == (0x40 | 0x6))
+ {
+ /* Vector. */
+ long n, width, m;
+ long l;
+ long i;
+
+ bfd_sym_fetch_long (buf, len, offset, &offset, &n);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &width);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &m);
+ /* fprintf (f, "\n "); */
+ fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
+ for (i = 0; i < m; i++)
+ {
+ bfd_sym_fetch_long (buf, len, offset, &offset, &l);
+ if (i != 0)
+ fprintf (f, " ");
+ fprintf (f, "%ld", l);
+ }
+ }
+ else if (type & 0x40)
+ {
+ /* Other packed type. */
+ long msb, lsb;
+
+ bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
+ bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
+ /* fprintf (f, "\n "); */
+ fprintf (f, " msb %ld, lsb %ld", msb, lsb);
+ }
+
+ fprintf (f, "]");
+
+ if (offsetptr != NULL)
+ *offsetptr = offset;
+}
+
+void
+bfd_sym_print_type_information_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ bfd_sym_type_information_table_entry *entry;
+{
+ unsigned char *buf;
+ unsigned long offset;
+ unsigned int i;
+
+ fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
+ bfd_sym_symbol_name (abfd, entry->nte_index)[0],
+ &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
+ entry->nte_index,
+ entry->physical_size, entry->offset, entry->logical_size);
+
+ fprintf (f, "\n ");
+
+ buf = alloca (entry->physical_size);
+ if (buf == NULL)
+ {
+ fprintf (f, "[ERROR]\n");
+ return;
+ }
+ if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
+ {
+ fprintf (f, "[ERROR]\n");
+ return;
+ }
+ if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
+ {
+ fprintf (f, "[ERROR]\n");
+ return;
+ }
+
+ fprintf (f, "[");
+ for (i = 0; i < entry->physical_size; i++)
+ {
+ if (i == 0)
+ fprintf (f, "0x%02x", buf[i]);
+ else
+ fprintf (f, " 0x%02x", buf[i]);
+ }
+
+ fprintf (f, "]");
+ fprintf (f, "\n ");
+
+ bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
+
+ if (offset != entry->physical_size)
+ fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
+
+void
+bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ FILE *f;
+ bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
+{
+ fprintf (f, "[UNIMPLEMENTED]");
+}
+
+void
+bfd_sym_print_constant_pool_entry (abfd, f, entry)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ FILE *f;
+ bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
+{
+ fprintf (f, "[UNIMPLEMENTED]");
+}
+
+unsigned char *
+bfd_sym_display_name_table_entry (abfd, f, entry)
+ bfd *abfd;
+ FILE *f;
+ unsigned char *entry;
+{
+ unsigned long index;
+ unsigned long offset;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+ index = (entry - sdata->name_table) / 2;
+
+ if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
+ {
+ unsigned short length = bfd_getb16 (entry + 2);
+ fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
+ offset = 2 + length + 1;
+ }
+ else
+ {
+ if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
+ fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
+
+ if (sdata->version >= BFD_SYM_VERSION_3_4)
+ offset = entry[0] + 2;
+ else
+ offset = entry[0] + 1;
+ }
+
+ return (entry + offset + (offset % 2));
+}
+
+void
+bfd_sym_display_name_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long name_table_len;
+ unsigned char *name_table, *name_table_end, *cur;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
+ name_table = sdata->name_table;
+ name_table_end = name_table + name_table_len;
+
+ fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
+
+ cur = name_table;
+ for (;;)
+ {
+ cur = bfd_sym_display_name_table_entry (abfd, f, cur);
+ if (cur >= name_table_end)
+ break;
+ }
+}
+
+void
+bfd_sym_display_resources_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_resources_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
+ sdata->header.dshb_rte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_resources_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_modules_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_modules_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "module table (MTE) contains %lu objects:\n\n",
+ sdata->header.dshb_mte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_modules_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_file_references_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_file_references_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
+ sdata->header.dshb_frte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_file_references_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_contained_modules_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_contained_modules_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
+ sdata->header.dshb_cmte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_contained_variables_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_contained_variables_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
+ sdata->header.dshb_cvte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+
+ fprintf (f, "\n");
+}
+
+void
+bfd_sym_display_contained_statements_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_contained_statements_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
+ sdata->header.dshb_csnte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_contained_labels_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_contained_labels_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
+ sdata->header.dshb_clte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_contained_types_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_contained_types_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
+ sdata->header.dshb_ctte.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_file_references_index_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_file_references_index_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
+ sdata->header.dshb_fite.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_constant_pool (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_constant_pool_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
+ sdata->header.dshb_const.dti_object_count);
+
+ for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] ", i);
+ bfd_sym_print_constant_pool_entry (abfd, f, &entry);
+ fprintf (f, "\n");
+ }
+ }
+}
+
+void
+bfd_sym_display_type_information_table (abfd, f)
+ bfd *abfd;
+ FILE *f;
+{
+ unsigned long i;
+ bfd_sym_type_table_entry index;
+ bfd_sym_type_information_table_entry entry;
+ bfd_sym_data_struct *sdata = NULL;
+
+ BFD_ASSERT (bfd_sym_valid (abfd));
+ sdata = abfd->tdata.sym_data;
+
+ if (sdata->header.dshb_tte.dti_object_count > 99)
+ fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
+ sdata->header.dshb_tte.dti_object_count - 99);
+ else
+ {
+ fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
+ return;
+ }
+
+ for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
+ {
+ if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
+ fprintf (f, " [%8lu] [INVALID]\n", i);
+ else
+ {
+ fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
+
+ if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
+ fprintf (f, "[INVALID]");
+ else
+ bfd_sym_print_type_information_table_entry (abfd, f, &entry);
+
+ fprintf (f, "\n");
+ }
+ }
+}
+
+int
+bfd_sym_scan (abfd, version, mdata)
+ bfd *abfd;
+ bfd_sym_version version;
+ bfd_sym_data_struct *mdata;
+{
+ asection *bfdsec;
+ const char *name = "symbols";
+
+ mdata->name_table = 0;
+ mdata->sbfd = abfd;
+ mdata->version = version;
+
+ bfd_seek (abfd, 0, SEEK_SET);
+ if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
+ return -1;
+
+ mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
+ if (mdata->name_table == NULL)
+ return -1;
+
+ bfdsec = bfd_make_section_anyway (abfd, name);
+ if (bfdsec == NULL)
+ return -1;
+
+ bfdsec->vma = 0;
+ bfdsec->lma = 0;
+ bfdsec->_raw_size = 0;
+ bfdsec->filepos = 0;
+ bfdsec->alignment_power = 0;
+
+ bfdsec->flags = SEC_HAS_CONTENTS;
+
+ abfd->tdata.sym_data = mdata;
+
+ return 0;
+}
+
+const bfd_target *
+bfd_sym_object_p (abfd)
+ bfd *abfd;
+{
+ struct bfd_preserve preserve;
+ bfd_sym_version version = -1;
+
+ preserve.marker = NULL;
+ bfd_seek (abfd, 0, SEEK_SET);
+ if (bfd_sym_read_version (abfd, &version) != 0)
+ goto wrong;
+
+ preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
+ if (preserve.marker == NULL
+ || ! bfd_preserve_save (abfd, &preserve))
+ goto fail;
+
+ if (bfd_sym_scan (abfd, version,
+ (bfd_sym_data_struct *) preserve.marker) != 0)
+ goto wrong;
+
+ bfd_preserve_finish (abfd, &preserve);
+ return abfd->xvec;
+
+ wrong:
+ bfd_set_error (bfd_error_wrong_format);
+
+ fail:
+ if (preserve.marker != NULL)
+ bfd_preserve_restore (abfd, &preserve);
+ return NULL;
+}
+
+asymbol *
+bfd_sym_make_empty_symbol (abfd)
+ bfd *abfd;
+{
+ return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+}
+
+void
+bfd_sym_get_symbol_info (abfd, symbol, ret)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ asymbol *symbol;
+ symbol_info *ret;
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+long
+bfd_sym_get_symtab_upper_bound (abfd)
+ bfd *abfd ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+long
+bfd_sym_get_symtab (abfd, sym)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ asymbol **sym ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+int
+bfd_sym_sizeof_headers (abfd, exec)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ boolean exec ATTRIBUTE_UNUSED;
+{
+ return 0;
+}
+
+const bfd_target sym_vec =
+{
+ "sym", /* name */
+ bfd_target_sym_flavour, /* flavour */
+ BFD_ENDIAN_BIG, /* byteorder */
+ BFD_ENDIAN_BIG, /* header_byteorder */
+ (HAS_RELOC | EXEC_P | /* object flags */
+ HAS_LINENO | HAS_DEBUG |
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
+ | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
+ 0, /* symbol_leading_char */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+ { /* bfd_check_format */
+ _bfd_dummy_target,
+ bfd_sym_object_p, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ { /* bfd_set_format */
+ bfd_false,
+ bfd_sym_mkobject,
+ bfd_false,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ bfd_true,
+ bfd_false,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (bfd_sym),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
+ BFD_JUMP_TABLE_RELOCS (bfd_sym),
+ BFD_JUMP_TABLE_WRITE (bfd_sym),
+ BFD_JUMP_TABLE_LINK (bfd_sym),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL,
+
+ NULL
+};
+
diff --git a/bfd/xsym.h b/bfd/xsym.h
new file mode 100644
index 00000000000..a381c5538d3
--- /dev/null
+++ b/bfd/xsym.h
@@ -0,0 +1,701 @@
+/* xSYM symbol-file support for BFD.
+ Copyright 1999, 2000, 2001, 2002
+ 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 <stdio.h>
+
+#ifndef __xSYM_H__
+#define __xSYM_H__
+
+#define BFD_SYM_VERSION_STR_3_1 "\013Version 3.1"
+#define BFD_SYM_VERSION_STR_3_2 "\013Version 3.2"
+#define BFD_SYM_VERSION_STR_3_3 "\013Version 3.3"
+#define BFD_SYM_VERSION_STR_3_4 "\013Version 3.4"
+#define BFD_SYM_VERSION_STR_3_5 "\013Version 3.5"
+#define BFD_SYM_END_OF_LIST_3_2 0xffff
+#define BFD_SYM_END_OF_LIST_3_4 0xffffffff
+#define BFD_SYM_END_OF_LIST BFD_SYM_END_OF_LIST_3_4
+#define BFD_SYM_FILE_NAME_INDEX_3_2 0xfffe
+#define BFD_SYM_FILE_NAME_INDEX_3_4 0xfffffffe
+#define BFD_SYM_FILE_NAME_INDEX BFD_SYM_FILE_NAME_INDEX_3_4
+#define BFD_SYM_SOURCE_FILE_CHANGE_3_2 0xfffe
+#define BFD_SYM_SOURCE_FILE_CHANGE_3_4 0xfffffffe
+#define BFD_SYM_SOURCE_FILE_CHANGE BFD_SYM_SOURCE_FILE_CHANGE_3_4
+#define BFD_SYM_MAXIMUM_LEGAL_INDEX_3_2 0xfffd
+#define BFD_SYM_MAXIMUM_LEGAL_INDEX_3_4 0xfffffffd
+#define BFD_SYM_MAXIMUM_LEGAL_INDEX BFD_SYM_MAXIMUM_LEGAL_INDEX_3_4
+
+enum bfd_sym_storage_class
+{
+ BFD_SYM_STORAGE_CLASS_REGISTER = 0,
+ BFD_SYM_STORAGE_CLASS_GLOBAL = 1,
+ BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE = 2,
+ BFD_SYM_STORAGE_CLASS_STACK_RELATIVE = 3,
+ BFD_SYM_STORAGE_CLASS_ABSOLUTE = 4,
+ BFD_SYM_STORAGE_CLASS_CONSTANT = 5,
+ BFD_SYM_STORAGE_CLASS_BIGCONSTANT = 6,
+ BFD_SYM_STORAGE_CLASS_RESOURCE = 99
+};
+typedef enum bfd_sym_storage_class bfd_sym_storage_class;
+
+enum bfd_sym_storage_kind
+{
+ BFD_SYM_STORAGE_KIND_LOCAL = 0,
+ BFD_SYM_STORAGE_KIND_VALUE = 1,
+ BFD_SYM_STORAGE_KIND_REFERENCE = 2,
+ BFD_SYM_STORAGE_KIND_WITH = 3
+};
+typedef enum bfd_sym_storage_kind bfd_sym_storage_kind;
+
+enum bfd_sym_version
+{
+ BFD_SYM_VERSION_3_1,
+ BFD_SYM_VERSION_3_2,
+ BFD_SYM_VERSION_3_3,
+ BFD_SYM_VERSION_3_4,
+ BFD_SYM_VERSION_3_5
+};
+typedef enum bfd_sym_version bfd_sym_version;
+
+enum bfd_sym_module_kind
+{
+ BFD_SYM_MODULE_KIND_NONE = 0,
+ BFD_SYM_MODULE_KIND_PROGRAM = 1,
+ BFD_SYM_MODULE_KIND_UNIT = 2,
+ BFD_SYM_MODULE_KIND_PROCEDURE = 3,
+ BFD_SYM_MODULE_KIND_FUNCTION = 4,
+ BFD_SYM_MODULE_KIND_DATA = 5,
+ BFD_SYM_MODULE_KIND_BLOCK = 6
+};
+typedef enum bfd_sym_module_kind bfd_sym_module_kind;
+
+enum bfd_sym_symbol_scope
+{
+ BFD_SYM_SYMBOL_SCOPE_LOCAL = 0, /* Object is seen only inside current scope. */
+ BFD_SYM_SYMBOL_SCOPE_GLOBAL = 1 /* Object has global scope. */
+};
+typedef enum bfd_sym_symbol_scope bfd_sym_symbol_scope;
+
+struct bfd_sym_file_reference
+{
+ unsigned long fref_frte_index; /* File reference table index. */
+ unsigned long fref_offset; /* Absolute offset into source file. */
+};
+typedef struct bfd_sym_file_reference bfd_sym_file_reference;
+
+/* NAME TABLE (NTE). */
+
+/* RESOURCES TABLE (RTE)
+
+ All code and data is *defined* to reside in a resource. Even A5
+ relative data is defined to reside in a dummy resource of ResType
+ 'gbld'. Code always resides in a resource. Because a code/data
+ is built of many modules, when walking through a resource we must
+ point back to the modules in the order they were defined. This is
+ done by requiring the entries in the Modules Entry table to be
+ ordered by resource/resource-number and by the location in that
+ resource. Hence, the resource table entry points to the first
+ module making up that resource. All modules table entries following
+ that first one with the same restype/resnum are contiguous and offset
+ from that first entry. */
+
+struct bfd_sym_resources_table_entry
+{
+ unsigned char rte_res_type[4]; /* Resource Type. */
+ unsigned short rte_res_number; /* Resource Number. */
+ unsigned long rte_nte_index; /* Name of the resource. */
+ unsigned long rte_mte_first; /* Index of first module in the resource. */
+ unsigned long rte_mte_last; /* Index of the last module in the resource. */
+ unsigned long rte_res_size; /* Size of the resource. */
+};
+typedef struct bfd_sym_resources_table_entry bfd_sym_resources_table_entry;
+
+/* MODULES TABLE (MTE)
+
+ Modules table entries are ordered by their appearance in a resource.
+ (Note that having a single module copied into two resources is not
+ possible). Modules map back to their resource via an index into the
+ resource table and an offset into the resource. Modules also point
+ to their source files, both the definition module and implemention
+ module. Because modules can be textually nested within other
+ modules, a link to the parent (containing) module is required. This
+ module can textually contain other modules. A link to the contiguous
+ list of child (contained) modules is required. Variables, statements,
+ and types defined in the module are pointed to by indexing the head of
+ the contiguous lists of contained variables, contained statements,
+ and contained types. */
+
+struct bfd_sym_modules_table_entry
+{
+ unsigned long mte_rte_index; /* Which resource it is in. */
+ unsigned long mte_res_offset; /* Offset into the resource. */
+ unsigned long mte_size; /* Size of module. */
+ char mte_kind; /* What kind of module this is. */
+ char mte_scope; /* How visible is it? */
+ unsigned long mte_parent; /* Containing module. */
+ bfd_sym_file_reference mte_imp_fref; /* Implementation source. */
+ unsigned long mte_imp_end; /* End of implementation source. */
+ unsigned long mte_nte_index; /* The name of the module. */
+ unsigned long mte_cmte_index; /* Modules contained in this. */
+ unsigned long mte_cvte_index; /* Variables contained in this. */
+ unsigned long mte_clte_index; /* Local labels defined here. */
+ unsigned long mte_ctte_index; /* Types contained in this. */
+ unsigned long mte_csnte_idx_1; /* CSNTE index of mte_snbr_first. */
+ unsigned long mte_csnte_idx_2; /* CSNTE index of mte_snbr_last. */
+};
+typedef struct bfd_sym_modules_table_entry bfd_sym_modules_table_entry;
+
+/* FILE REFERENCES TABLE (FRTE)
+
+ The FILE REFERENCES TABLE maps from source file to module & offset.
+ The table is ordered by increasing file offset. Each new offset
+ references a module.
+
+ FRT = FILE_SOURCE_START
+ FILE_SOURCE_INCREMENT*
+ END_OF_LIST.
+
+ *** THIS MECHANISM IS VERY SLOW FOR FILE+STATEMENT_NUMBER TO
+ *** MODULE/CODE ADDRESS OPERATIONS. ANOTHER MECHANISM IS
+ *** REQUIRED!! */
+
+union bfd_sym_file_references_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, FILE_NAME_INDEX, or module table entry. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ /* FILE_NAME_INDEX. */
+ unsigned long type;
+ unsigned long nte_index;
+ unsigned long mod_date;
+ }
+ filename;
+
+ struct
+ {
+ /* < FILE_NAME_INDEX. */
+ unsigned long mte_index;
+ unsigned long file_offset;
+ }
+ entry;
+};
+typedef union bfd_sym_file_references_table_entry bfd_sym_file_references_table_entry;
+
+/* CONTAINED MODULES TABLE (CMTE)
+
+ Contained Modules are lists of indices into the modules table. The
+ lists are terminated by an END_OF_LIST index. All entries are of the
+ same size, hence mapping an index into a CMTE list is simple.
+
+ CMT = MTE_INDEX* END_OF_LIST. */
+
+union bfd_sym_contained_modules_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, index. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ unsigned long mte_index; /* Index into the Modules Table. */
+ unsigned long nte_index; /* The name of the module. */
+ }
+ entry;
+};
+typedef union bfd_sym_contained_modules_table_entry bfd_sym_contained_modules_table_entry;
+
+/* CONTAINED VARIABLES TABLE (CVTE)
+
+ Contained Variables map into the module table, file table, name table, and type
+ table. Contained Variables are a contiguous list of source file change record,
+ giving the name of and offset into the source file corresponding to all variables
+ following. Variable definition records contain an index into the name table (giving
+ the text of the variable as it appears in the source code), an index into the type
+ table giving the type of the variable, an increment added to the source file
+ offset giving the start of the implementation of the variable, and a storage
+ class address, giving information on variable's runtime address.
+
+ CVT = SOURCE_FILE_CHANGE SYMBOL_INFO* END_OF_LIST.
+ SYMBOL_INFO = SYMBOL_DEFINITION | SOURCE_FILE_CHANGE .
+
+ All entries are of the same size, making the fetching of data simple. The
+ variable entries in the list are in ALPHABETICAL ORDER to simplify the display of
+ available variables for several of the debugger's windows. */
+
+/* 'la_size' determines the variant used below:
+
+ == BFD_SYM_CVTE_SCA
+ Traditional STORAGE_CLASS_ADDRESS;
+
+ <= BFD_SYM_CVTE_LA_MAX_SIZE
+ That many logical address bytes ("in-situ");
+
+ == BFD_SYM_CVTE_BIG_LA
+ Logical address bytes in constant pool, at offset 'big_la'. */
+
+#define BFD_SYM_CVTE_SCA 0 /* Indicate SCA variant of CVTE. */
+#define BFD_SYM_CVTE_LA_MAX_SIZE 13 /* Max# of logical address bytes in a CVTE. */
+#define BFD_SYM_CVTE_BIG_LA 127 /* Indicates LA redirection to constant pool. */
+
+union bfd_sym_contained_variables_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, SOURCE_FILE_CHANGE, or type table entry. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ /* SOURCE_FILE_CHANGE. */
+ unsigned long type;
+ bfd_sym_file_reference fref;
+ }
+ file;
+
+ struct
+ {
+ /* < SOURCE_FILE_CHANGE. */
+ unsigned long tte_index;
+ unsigned long nte_index;
+ unsigned long file_delta; /* Increment from previous source. */
+ unsigned char scope;
+ unsigned char la_size; /* #bytes of LAs below. */
+
+ union
+ {
+ /* la_size == BFD_SYM_CVTE_SCA. */
+ struct
+ {
+ unsigned char sca_kind; /* Distinguish local from value/var formal. */
+ unsigned char sca_class; /* The storage class itself. */
+ unsigned long sca_offset;
+ }
+ scstruct;
+
+ /* la_size <= BFD_SYM_CVTE_LA_MAX_SIZE. */
+ struct {
+ unsigned char la[BFD_SYM_CVTE_LA_MAX_SIZE]; /* Logical address bytes. */
+ unsigned char la_kind; /* Eqv. cvte_location.sca_kind. */
+ }
+ lastruct;
+
+ /* la_size == BFD_SYM_CVTE_BIG_LA 127. */
+ struct
+ {
+ unsigned long big_la; /* Logical address bytes in constant pool. */
+ unsigned char big_la_kind; /* Eqv. cvte_location.sca_kind. */
+ }
+ biglastruct;
+ }
+ address;
+ }
+ entry;
+};
+typedef union bfd_sym_contained_variables_table_entry bfd_sym_contained_variables_table_entry;
+
+/* CONTAINED STATEMENTS TABLE (CSNTE)
+
+ Contained Statements table. This table is similar to the Contained
+ Variables table except that instead of VARIABLE_DEFINITION entries, this
+ module contains STATEMENT_NUMBER_DEFINITION entries. A statement number
+ definition points back to the containing module (via an index into
+ the module entry table) and contains the file and resource deltas
+ to add to the previous values to get to this statement.
+ All entries are of the same size, making the fetching of data simple. The
+ entries in the table are in order of increasing statement number within the
+ source file.
+
+ The Contained Statements table is indexed from two places. An MTE contains
+ an index to the first statement number within the module. An FRTE contains
+ an index to the first statement in the table (Possibly. This is slow.) Or
+ a table of fast statement number to CSNTE entry mappings indexes into the
+ table. Choice not yet made. */
+
+union bfd_sym_contained_statements_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, SOURCE_FILE_CHANGE, or statement table entry. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ /* SOURCE_FILE_CHANGE. */
+ unsigned long type;
+ bfd_sym_file_reference fref; /* File name table. */
+ }
+ file;
+
+ struct
+ {
+ unsigned long mte_index; /* Which module contains it. */
+ unsigned long file_delta; /* Where it is defined. */
+ unsigned long mte_offset; /* Where it is in the module. */
+ }
+ entry;
+};
+typedef union bfd_sym_contained_statements_table_entry bfd_sym_contained_statements_table_entry;
+
+/* CONTAINED LABELS TABLE (CLTE)
+
+ Contained Labels table names those labels local to the module. It is similar
+ to the Contained Statements table. */
+
+union bfd_sym_contained_labels_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, SOURCE_FILE_CHANGE, index. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ /* SOURCE_FILE_CHANGE. */
+ unsigned long type;
+ bfd_sym_file_reference fref;
+ }
+ file;
+
+ struct
+ {
+ /* < SOURCE_FILE_CHANGE. */
+ unsigned long mte_index; /* Which module contains us. */
+ unsigned long mte_offset; /* Where it is in the module. */
+ unsigned long nte_index; /* The name of the label. */
+ unsigned long file_delta; /* Where it is defined. */
+ unsigned short scope; /* How visible the label is. */
+ }
+ entry;
+};
+typedef union bfd_sym_contained_labels_table_entry bfd_sym_contained_labels_table_entry;
+
+/* CONTAINED TYPES TABLE (CTTE)
+
+ Contained Types define the named types that are in the module. It is used to
+ map name indices into type indices. The type entries in the table are in
+ alphabetical order by type name. */
+
+union bfd_sym_contained_types_table_entry
+{
+ struct
+ {
+ /* END_OF_LIST, SOURCE_FILE_CHANGE, or type table entry. */
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ /* SOURCE_FILE_CHANGE. */
+ unsigned long type;
+ bfd_sym_file_reference fref;
+ }
+ file;
+
+ struct
+ {
+ /* < SOURCE_FILE_CHANGE. */
+ unsigned long tte_index;
+ unsigned long nte_index;
+ unsigned long file_delta; /* From last file definition. */
+ }
+ entry;
+};
+typedef union bfd_sym_contained_types_table_entry bfd_sym_contained_types_table_entry;
+
+/* TYPE TABLE (TTE). */
+
+typedef unsigned long bfd_sym_type_table_entry;
+
+/* TYPE INFORMATION TABLE (TINFO). */
+
+struct bfd_sym_type_information_table_entry
+{
+ unsigned long nte_index;
+ unsigned long physical_size;
+ unsigned long logical_size;
+ unsigned long offset;
+};
+typedef struct bfd_sym_type_information_table_entry bfd_sym_type_information_table_entry;
+
+/* FILE REFERENCES INDEX TABLE (FITE)
+
+ The FRTE INDEX TABLE indexes into the FILE REFERENCE TABLE above. The FRTE
+ at that index is the FILE_SOURCE_START for a series of files. The FRTEs are
+ indexed from 1. The list is terminated with an END_OF_LIST. */
+
+union bfd_sym_file_references_index_table_entry
+{
+ struct
+ {
+ unsigned long type;
+ }
+ generic;
+
+ struct
+ {
+ unsigned long frte_index; /* Index into the FRTE table. */
+ unsigned long nte_index; /* Name table index, gives filename. */
+ }
+ entry;
+};
+typedef union bfd_sym_file_references_index_table_entry bfd_sym_file_references_index_table_entry;
+
+/* CONSTANT POOL (CONST)
+
+ The CONSTANT_POOL consists of entries that start on word boundaries. The entries
+ are referenced by byte index into the constant pool, not by record number.
+
+ Each entry takes the form:
+
+ <16-bit size>
+ <that many bytes of stuff>
+
+ Entries do not cross page boundaries. */
+
+typedef short bfd_sym_constant_pool_entry;
+
+/* The DISK_SYMBOL_HEADER_BLOCK is the first record in a .SYM file,
+ defining the physical characteristics of the symbolic information.
+ The remainder of the * .SYM file is stored in fixed block
+ allocations. For the purposes of paging, the * file is considered
+ to be an array of dshb_page_size blocks, with block 0 (and *
+ possibly more) devoted to the DISK_SYMBOL_HEADER_BLOCK.
+
+ The dti_object_count field means that the allowed indices for that
+ type of object are 0 .. dti_object_count. An index of 0, although
+ allowed, is never done. However, an 0th entry is created in the
+ table. That entry is filled with all zeroes. The reason for this
+ is to avoid off-by-one programming errors that would otherwise
+ occur: an index of k *MEANS* k, not k-1 when going to the disk
+ table. */
+
+struct bfd_sym_table_info
+{
+ unsigned long dti_first_page; /* First page for this table. */
+ unsigned long dti_page_count; /* Number of pages for the table. */
+ unsigned long dti_object_count; /* Number of objects in the table. */
+};
+typedef struct bfd_sym_table_info bfd_sym_table_info;
+
+struct bfd_sym_header_block
+{
+ unsigned char dshb_id[32]; /* Version information. */
+ unsigned short dshb_page_size; /* Size of the pages/blocks. */
+ unsigned long dshb_hash_page; /* Disk page for the hash table. */
+ unsigned long dshb_root_mte; /* MTE index of the program root. */
+ unsigned long dshb_mod_date; /* modification date of executable. */
+ bfd_sym_table_info dshb_frte; /* Per TABLE information. */
+ bfd_sym_table_info dshb_rte;
+ bfd_sym_table_info dshb_mte;
+ bfd_sym_table_info dshb_cmte;
+ bfd_sym_table_info dshb_cvte;
+ bfd_sym_table_info dshb_csnte;
+ bfd_sym_table_info dshb_clte;
+ bfd_sym_table_info dshb_ctte;
+ bfd_sym_table_info dshb_tte;
+ bfd_sym_table_info dshb_nte;
+ bfd_sym_table_info dshb_tinfo;
+ bfd_sym_table_info dshb_fite; /* File information. */
+ bfd_sym_table_info dshb_const; /* Constant pool. */
+
+ unsigned char dshb_file_creator[4]; /* Executable's creator. */
+ unsigned char dshb_file_type[4]; /* Executable's file type. */
+};
+typedef struct bfd_sym_header_block bfd_sym_header_block;
+
+struct bfd_sym_data_struct
+{
+ unsigned char *name_table;
+ bfd_sym_header_block header;
+ bfd_sym_version version;
+ bfd *sbfd;
+};
+typedef struct bfd_sym_data_struct bfd_sym_data_struct;
+
+extern boolean bfd_sym_mkobject
+ PARAMS ((bfd *));
+extern void bfd_sym_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+extern boolean bfd_sym_valid
+ PARAMS ((bfd *));
+extern unsigned char * bfd_sym_read_name_table
+ PARAMS ((bfd *, bfd_sym_header_block *));
+extern void bfd_sym_parse_file_reference_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_file_reference *));
+extern void bfd_sym_parse_disk_table_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_table_info *));
+extern void bfd_sym_parse_header_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_header_block *));
+extern int bfd_sym_read_header_v32
+ PARAMS ((bfd *, bfd_sym_header_block *));
+extern int bfd_sym_read_header_v34
+ PARAMS ((bfd *, bfd_sym_header_block *));
+extern int bfd_sym_read_header
+ PARAMS ((bfd *, bfd_sym_header_block *, bfd_sym_version));
+extern int bfd_sym_read_version
+ PARAMS ((bfd *, bfd_sym_version *));
+extern void bfd_sym_display_table_summary
+ PARAMS ((FILE *, bfd_sym_table_info *, const char *));
+extern void bfd_sym_display_header
+ PARAMS ((FILE *, bfd_sym_header_block *));
+extern void bfd_sym_parse_resources_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_resources_table_entry *));
+extern void bfd_sym_parse_modules_table_entry_v33
+ PARAMS ((unsigned char *, size_t, bfd_sym_modules_table_entry *));
+extern void bfd_sym_parse_file_references_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_file_references_table_entry *));
+extern void bfd_sym_parse_contained_modules_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_contained_modules_table_entry *));
+extern void bfd_sym_parse_contained_variables_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_contained_variables_table_entry *));
+extern void bfd_sym_parse_contained_statements_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_contained_statements_table_entry *));
+extern void bfd_sym_parse_contained_labels_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_contained_labels_table_entry *));
+extern void bfd_sym_parse_type_table_entry_v32
+ PARAMS ((unsigned char *, size_t, bfd_sym_type_table_entry *));
+extern int bfd_sym_fetch_resources_table_entry
+ PARAMS ((bfd *, bfd_sym_resources_table_entry *, unsigned long));
+extern int bfd_sym_fetch_modules_table_entry
+ PARAMS ((bfd *, bfd_sym_modules_table_entry *, unsigned long));
+extern int bfd_sym_fetch_file_references_table_entry
+ PARAMS ((bfd *, bfd_sym_file_references_table_entry *, unsigned long));
+extern int bfd_sym_fetch_contained_modules_table_entry
+ PARAMS ((bfd *, bfd_sym_contained_modules_table_entry *, unsigned long));
+extern int bfd_sym_fetch_contained_variables_table_entry
+ PARAMS ((bfd *, bfd_sym_contained_variables_table_entry *, unsigned long));
+extern int bfd_sym_fetch_contained_statements_table_entry
+ PARAMS ((bfd *, bfd_sym_contained_statements_table_entry *, unsigned long));
+extern int bfd_sym_fetch_contained_labels_table_entry
+ PARAMS ((bfd *, bfd_sym_contained_labels_table_entry *, unsigned long));
+extern int bfd_sym_fetch_contained_types_table_entry
+ PARAMS ((bfd *, bfd_sym_contained_types_table_entry *, unsigned long));
+extern int bfd_sym_fetch_file_references_index_table_entry
+ PARAMS ((bfd *, bfd_sym_file_references_index_table_entry *, unsigned long));
+extern int bfd_sym_fetch_constant_pool_entry
+ PARAMS ((bfd *, bfd_sym_constant_pool_entry *, unsigned long));
+extern int bfd_sym_fetch_type_table_entry
+ PARAMS ((bfd *, bfd_sym_type_table_entry *, unsigned long));
+extern int bfd_sym_fetch_type_information_table_entry
+ PARAMS ((bfd *, bfd_sym_type_information_table_entry *, unsigned long));
+extern int bfd_sym_fetch_type_table_information
+ PARAMS ((bfd *, bfd_sym_type_information_table_entry *, unsigned long));
+extern const unsigned char * bfd_sym_symbol_name
+ PARAMS ((bfd *, unsigned long));
+extern const unsigned char * bfd_sym_module_name
+ PARAMS ((bfd *, unsigned long));
+extern const char * bfd_sym_unparse_storage_kind
+ PARAMS ((enum bfd_sym_storage_kind));
+extern const char * bfd_sym_unparse_storage_class
+ PARAMS ((enum bfd_sym_storage_class));
+extern const char * bfd_sym_unparse_module_kind
+ PARAMS ((enum bfd_sym_module_kind));
+extern const char * bfd_sym_unparse_symbol_scope
+ PARAMS ((enum bfd_sym_symbol_scope));
+extern void bfd_sym_print_file_reference
+ PARAMS ((bfd *, FILE *, bfd_sym_file_reference *));
+extern void bfd_sym_print_resources_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_resources_table_entry *));
+extern void bfd_sym_print_modules_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_modules_table_entry *));
+extern void bfd_sym_print_file_references_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_file_references_table_entry *));
+extern void bfd_sym_print_contained_modules_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_contained_modules_table_entry *));
+extern void bfd_sym_print_contained_variables_table_entry
+ PARAMS ((bfd *, FILE *f, bfd_sym_contained_variables_table_entry *));
+extern void bfd_sym_print_contained_statements_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_contained_statements_table_entry *));
+extern void bfd_sym_print_contained_labels_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_contained_labels_table_entry *));
+extern void bfd_sym_print_contained_types_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_contained_types_table_entry *));
+extern const char * bfd_sym_type_operator_name
+ PARAMS ((unsigned char));
+extern const char * bfd_sym_type_basic_name
+ PARAMS ((unsigned char));
+extern int bfd_sym_fetch_long
+ PARAMS ((unsigned char *, unsigned long, unsigned long, unsigned long *, long *));
+extern void bfd_sym_print_type_information
+ PARAMS ((bfd *, FILE *, unsigned char *, unsigned long, unsigned long, unsigned long *));
+extern void bfd_sym_print_type_information_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_type_information_table_entry *));
+extern void bfd_sym_print_file_references_index_table_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_file_references_index_table_entry *));
+extern void bfd_sym_print_constant_pool_entry
+ PARAMS ((bfd *, FILE *, bfd_sym_constant_pool_entry *));
+extern unsigned char * bfd_sym_display_name_table_entry
+ PARAMS ((bfd *, FILE *, unsigned char *));
+extern void bfd_sym_display_name_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_resources_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_modules_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_file_references_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_contained_modules_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_contained_variables_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_contained_statements_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_contained_labels_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_contained_types_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_file_references_index_table
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_constant_pool
+ PARAMS ((bfd *, FILE *));
+extern void bfd_sym_display_type_information_table
+ PARAMS ((bfd *, FILE *));
+extern int bfd_sym_scan
+ PARAMS ((bfd *, bfd_sym_version, bfd_sym_data_struct *));
+extern const bfd_target * bfd_sym_object_p
+ PARAMS ((bfd *));
+extern asymbol * bfd_sym_make_empty_symbol
+ PARAMS ((bfd *));
+extern void bfd_sym_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+extern long bfd_sym_get_symtab_upper_bound
+ PARAMS ((bfd *));
+extern long bfd_sym_get_symtab
+ PARAMS ((bfd *, asymbol **));
+extern int bfd_sym_sizeof_headers
+ PARAMS ((bfd *, boolean));
+
+#endif /* __xSYM_H__ */