• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisãoe84d6fca26caaf6b02718efa0f1a4fb0d344348c (tree)
Hora2002-11-13 00:44:24
AutorAlan Modra <amodra@gmai...>
CommiterAlan Modra

Mensagem de Log

* 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.
(elf_core_file_p): Likewise.
* targets.c (_bfd_target_vector): Revert 2002-11-08 change.

Mudança Sumário

Diff

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,30 @@
1+2002-11-13 Klee Dienes <kdienes@apple.com>
2+ Alan Modra <amodra@bigpond.net.au>
3+
4+ * bfd.c (struct bfd_preserve): New.
5+ (bfd_preserve_save): New function.
6+ (bfd_preserve_restore): Ditto.
7+ (bfd_preserve_finish): Ditto.
8+ * bfd-in2.h: Regenerate.
9+ * mach-o.c: Formatting.
10+ (bfd_mach_o_scan_read_symtab_symbol): Make "value" unsigned.
11+ (bfd_mach_o_object_p): Use bfd_preserve_save/restore/finish.
12+ (bfd_mach_o_core_p): Ditto.
13+ (bfd_mach_o_scan): Pass in mdata.
14+ * mach-o.h (bfd_mach_o_scan): Update prototype.
15+ * pef.c: Formatting.
16+ (bfd_pef_object_p): Use bfd_preserve_save/restore/finish.
17+ (bfd_pef_xlib_object_p): Ditto.
18+ (bfd_pef_scan): Pass in mdata. Move version check to bfd_pef_object_p.
19+ * pef.h (bfd_pef_scan): Update prototype.
20+ * xsym.c: Formatting, K&R fixes.
21+ (bfd_sym_object_p): Use bfd_preserve_save/restore/finish.
22+ (bfd_sym_scan): New function split out from bfd_sym_object_p.
23+ * xsym.h (bfd_sym_scan): Declare.
24+ * elfcode.h (elf_object_p): Use bfd_preserve_save/restore/finish.
25+ (elf_core_file_p): Likewise.
26+ * targets.c (_bfd_target_vector): Revert 2002-11-08 change.
27+
128 2002-11-12 Nick Clifton <nickc@redhat.com>
229
330 * po/da.po: Updated Danish translation.
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -3739,6 +3739,27 @@ extern bfd_byte *bfd_get_relocated_section_contents
37393739 boolean
37403740 bfd_alt_mach_code PARAMS ((bfd *abfd, int alternative));
37413741
3742+struct bfd_preserve
3743+{
3744+ PTR marker;
3745+ PTR tdata;
3746+ flagword flags;
3747+ const struct bfd_arch_info *arch_info;
3748+ struct sec *sections;
3749+ struct sec **section_tail;
3750+ unsigned int section_count;
3751+ struct bfd_hash_table section_htab;
3752+};
3753+
3754+boolean
3755+bfd_preserve_save PARAMS ((bfd *, struct bfd_preserve *));
3756+
3757+void
3758+bfd_preserve_restore PARAMS ((bfd *, struct bfd_preserve *));
3759+
3760+void
3761+bfd_preserve_finish PARAMS ((bfd *, struct bfd_preserve *));
3762+
37423763 /* Extracted from archive.c. */
37433764 symindex
37443765 bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1392,3 +1392,133 @@ bfd_alt_mach_code (abfd, alternative)
13921392
13931393 return false;
13941394 }
1395+
1396+/*
1397+CODE_FRAGMENT
1398+
1399+.struct bfd_preserve
1400+.{
1401+. PTR marker;
1402+. PTR tdata;
1403+. flagword flags;
1404+. const struct bfd_arch_info *arch_info;
1405+. struct sec *sections;
1406+. struct sec **section_tail;
1407+. unsigned int section_count;
1408+. struct bfd_hash_table section_htab;
1409+.};
1410+.
1411+*/
1412+
1413+/*
1414+FUNCTION
1415+ bfd_preserve_save
1416+
1417+SYNOPSIS
1418+ boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
1419+
1420+DESCRIPTION
1421+ When testing an object for compatibility with a particular
1422+ target back-end, the back-end object_p function needs to set
1423+ up certain fields in the bfd on successfully recognizing the
1424+ object. This typically happens in a piecemeal fashion, with
1425+ failures possible at many points. On failure, the bfd is
1426+ supposed to be restored to its initial state, which is
1427+ virtually impossible. However, restoring a subset of the bfd
1428+ state works in practice. This function stores the subset and
1429+ reinitializes the bfd.
1430+
1431+*/
1432+
1433+boolean
1434+bfd_preserve_save (abfd, preserve)
1435+ bfd *abfd;
1436+ struct bfd_preserve *preserve;
1437+{
1438+ preserve->tdata = abfd->tdata.any;
1439+ preserve->arch_info = abfd->arch_info;
1440+ preserve->flags = abfd->flags;
1441+
1442+ preserve->sections = abfd->sections;
1443+ preserve->section_tail = abfd->section_tail;
1444+ preserve->section_count = abfd->section_count;
1445+ preserve->section_htab = abfd->section_htab;
1446+
1447+ if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
1448+ return false;
1449+
1450+ abfd->tdata.any = NULL;
1451+ abfd->arch_info = &bfd_default_arch_struct;
1452+ abfd->flags = 0;
1453+
1454+ abfd->sections = NULL;
1455+ abfd->section_tail = &abfd->sections;
1456+ abfd->section_count = 0;
1457+
1458+ return true;
1459+}
1460+
1461+/*
1462+FUNCTION
1463+ bfd_preserve_restore
1464+
1465+SYNOPSIS
1466+ void bfd_preserve_restore (bfd *, struct bfd_preserve *);
1467+
1468+DESCRIPTION
1469+ This function restores bfd state saved by bfd_preserve_save.
1470+ If MARKER is non-NULL in struct bfd_preserve then that block
1471+ and all subsequently bfd_alloc'd memory is freed.
1472+
1473+*/
1474+
1475+void
1476+bfd_preserve_restore (abfd, preserve)
1477+ bfd *abfd;
1478+ struct bfd_preserve *preserve;
1479+{
1480+ bfd_hash_table_free (&abfd->section_htab);
1481+
1482+ abfd->tdata.any = preserve->tdata;
1483+ abfd->arch_info = preserve->arch_info;
1484+ abfd->flags = preserve->flags;
1485+
1486+ abfd->section_htab = preserve->section_htab;
1487+ abfd->sections = preserve->sections;
1488+ abfd->section_tail = preserve->section_tail;
1489+ abfd->section_count = preserve->section_count;
1490+
1491+ /* bfd_release frees all memory more recently bfd_alloc'd than
1492+ its arg, as well as its arg. */
1493+ if (preserve->marker != NULL)
1494+ {
1495+ bfd_release (abfd, preserve->marker);
1496+ preserve->marker = NULL;
1497+ }
1498+}
1499+
1500+/*
1501+FUNCTION
1502+ bfd_preserve_finish
1503+
1504+SYNOPSIS
1505+ void bfd_preserve_finish (bfd *, struct bfd_preserve *);
1506+
1507+DESCRIPTION
1508+ This function should be called when the bfd state saved by
1509+ bfd_preserve_save is no longer needed. ie. when the back-end
1510+ object_p function returns with success.
1511+
1512+*/
1513+
1514+void
1515+bfd_preserve_finish (abfd, preserve)
1516+ bfd *abfd ATTRIBUTE_UNUSED;
1517+ struct bfd_preserve *preserve;
1518+{
1519+ /* It would be nice to be able to free more memory here, eg. old
1520+ tdata, but that's not possible since these blocks are sitting
1521+ inside bfd_alloc'd memory. The section hash is on a separate
1522+ objalloc. */
1523+ bfd_hash_table_free (&preserve->section_htab);
1524+}
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -505,16 +505,6 @@ elf_file_p (x_ehdrp)
505505 && (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
506506 }
507507
508-struct bfd_preserve
509-{
510- const struct bfd_arch_info *arch_info;
511- struct elf_obj_tdata *tdata;
512- struct bfd_hash_table section_htab;
513- struct sec *sections;
514- struct sec **section_tail;
515- unsigned int section_count;
516-};
517-
518508 /* Check to see if the file associated with ABFD matches the target vector
519509 that ABFD points to.
520510
@@ -536,11 +526,10 @@ elf_object_p (abfd)
536526 char *shstrtab; /* Internal copy of section header stringtab */
537527 struct elf_backend_data *ebd;
538528 struct bfd_preserve preserve;
539- struct elf_obj_tdata *new_tdata = NULL;
540529 asection *s;
541530 bfd_size_type amt;
542531
543- preserve.arch_info = abfd->arch_info;
532+ preserve.marker = NULL;
544533
545534 /* Read in the ELF header in external format. */
546535
@@ -584,24 +573,14 @@ elf_object_p (abfd)
584573 the tdata pointer in the bfd. */
585574
586575 amt = sizeof (struct elf_obj_tdata);
587- new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
588- if (new_tdata == NULL)
576+ preserve.marker = bfd_zalloc (abfd, amt);
577+ if (preserve.marker == NULL)
589578 goto got_no_match;
590- preserve.tdata = elf_tdata (abfd);
591- elf_tdata (abfd) = new_tdata;
592-
593- /* Clear section information, since there might be a recognized bfd that
594- we now check if we can replace, and we don't want to append to it. */
595- preserve.sections = abfd->sections;
596- preserve.section_tail = abfd->section_tail;
597- preserve.section_count = abfd->section_count;
598- preserve.section_htab = abfd->section_htab;
599- abfd->sections = NULL;
600- abfd->section_tail = &abfd->sections;
601- abfd->section_count = 0;
602- if (!bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
579+ if (!bfd_preserve_save (abfd, &preserve))
603580 goto got_no_match;
604581
582+ elf_tdata (abfd) = preserve.marker;
583+
605584 /* Now that we know the byte order, swap in the rest of the header */
606585 i_ehdrp = elf_elfheader (abfd);
607586 elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
@@ -633,8 +612,10 @@ elf_object_p (abfd)
633612 /* Check that the ELF e_machine field matches what this particular
634613 BFD format expects. */
635614 if (ebd->elf_machine_code != i_ehdrp->e_machine
636- && (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
637- && (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
615+ && (ebd->elf_machine_alt1 == 0
616+ || i_ehdrp->e_machine != ebd->elf_machine_alt1)
617+ && (ebd->elf_machine_alt2 == 0
618+ || i_ehdrp->e_machine != ebd->elf_machine_alt2))
638619 {
639620 const bfd_target * const *target_ptr;
640621
@@ -844,11 +825,8 @@ elf_object_p (abfd)
844825 }
845826 }
846827
847- /* It would be nice to be able to free more memory here, eg. old
848- elf_elfsections, old tdata, but that's not possible since these
849- blocks are sitting inside obj_alloc'd memory. */
850- bfd_hash_table_free (&preserve.section_htab);
851- return (abfd->xvec);
828+ bfd_preserve_finish (abfd, &preserve);
829+ return abfd->xvec;
852830
853831 got_wrong_format_error:
854832 /* There is way too much undoing of half-known state here. The caller,
@@ -864,17 +842,8 @@ elf_object_p (abfd)
864842
865843 got_no_match:
866844 abfd->arch_info = preserve.arch_info;
867- if (new_tdata != NULL)
868- {
869- /* bfd_release frees all memory more recently bfd_alloc'd than
870- its arg, as well as its arg. */
871- bfd_release (abfd, new_tdata);
872- elf_tdata (abfd) = preserve.tdata;
873- abfd->section_htab = preserve.section_htab;
874- abfd->sections = preserve.sections;
875- abfd->section_tail = preserve.section_tail;
876- abfd->section_count = preserve.section_count;
877- }
845+ if (preserve.marker != NULL)
846+ bfd_preserve_restore (abfd, &preserve);
878847 return NULL;
879848 }
880849
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -691,7 +691,7 @@ bfd_mach_o_scan_read_symtab_symbol (abfd, sym, s, i)
691691 unsigned char type = -1;
692692 unsigned char section = -1;
693693 short desc = -1;
694- long value = -1;
694+ unsigned long value = -1;
695695 unsigned long stroff = -1;
696696 unsigned int symtype = -1;
697697
@@ -1374,7 +1374,8 @@ bfd_mach_o_scan_read_segment (abfd, command)
13741374 {
13751375 bfd_vma segoff = command->offset + 48 + 8 + (i * 68);
13761376
1377- if (bfd_mach_o_scan_read_section (abfd, &seg->sections[i], segoff) != 0)
1377+ if (bfd_mach_o_scan_read_section (abfd, &seg->sections[i],
1378+ segoff) != 0)
13781379 return -1;
13791380 }
13801381 }
@@ -1455,7 +1456,8 @@ bfd_mach_o_scan_read_command (abfd, command)
14551456 return -1;
14561457
14571458 command->type = (bfd_h_get_32 (abfd, buf) & ~BFD_MACH_O_LC_REQ_DYLD);
1458- command->type_required = (bfd_h_get_32 (abfd, buf) & BFD_MACH_O_LC_REQ_DYLD) ? 1 : 0;
1459+ command->type_required = (bfd_h_get_32 (abfd, buf) & BFD_MACH_O_LC_REQ_DYLD
1460+ ? 1 : 0);
14591461 command->len = bfd_h_get_32 (abfd, buf + 4);
14601462
14611463 switch (command->type)
@@ -1531,20 +1533,24 @@ bfd_mach_o_flatten_sections (abfd)
15311533 {
15321534 if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
15331535 {
1534- bfd_mach_o_segment_command *seg = &mdata->commands[i].command.segment;
1536+ bfd_mach_o_segment_command *seg;
1537+
1538+ seg = &mdata->commands[i].command.segment;
15351539 mdata->nsects += seg->nsects;
15361540 }
15371541 }
15381542
1539- mdata->sections = bfd_alloc (abfd, mdata->nsects * sizeof (bfd_mach_o_section *));
1543+ mdata->sections = bfd_alloc (abfd,
1544+ mdata->nsects * sizeof (bfd_mach_o_section *));
15401545 csect = 0;
15411546
15421547 for (i = 0; i < mdata->header.ncmds; i++)
15431548 {
15441549 if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
15451550 {
1546- bfd_mach_o_segment_command *seg = &mdata->commands[i].command.segment;
1551+ bfd_mach_o_segment_command *seg;
15471552
1553+ seg = &mdata->commands[i].command.segment;
15481554 BFD_ASSERT (csect + seg->nsects <= mdata->nsects);
15491555
15501556 for (j = 0; j < seg->nsects; j++)
@@ -1579,7 +1585,8 @@ bfd_mach_o_scan_start_address (abfd)
15791585 for (i = 0; i < cmd->nflavours; i++)
15801586 {
15811587 if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_I386)
1582- && (cmd->flavours[i].flavour == (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
1588+ && (cmd->flavours[i].flavour
1589+ == (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
15831590 {
15841591 unsigned char buf[4];
15851592
@@ -1608,27 +1615,24 @@ bfd_mach_o_scan_start_address (abfd)
16081615 }
16091616
16101617 int
1611-bfd_mach_o_scan (abfd, header)
1618+bfd_mach_o_scan (abfd, header, mdata)
16121619 bfd *abfd;
16131620 bfd_mach_o_header *header;
1621+ bfd_mach_o_data_struct *mdata;
16141622 {
16151623 unsigned int i;
1616- bfd_mach_o_data_struct *mdata = NULL;
16171624 enum bfd_architecture cputype;
16181625 unsigned long cpusubtype;
16191626
1620- mdata = ((bfd_mach_o_data_struct *)
1621- bfd_alloc (abfd, sizeof (bfd_mach_o_data_struct)));
1622- if (mdata == NULL)
1623- return -1;
1624-
16251627 mdata->header = *header;
16261628 mdata->symbols = NULL;
16271629
1628- abfd->flags = abfd->xvec->object_flags | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS));
1630+ abfd->flags = (abfd->xvec->object_flags
1631+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
16291632 abfd->tdata.mach_o_data = mdata;
16301633
1631- bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype, &cputype, &cpusubtype);
1634+ bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype,
1635+ &cputype, &cpusubtype);
16321636 if (cputype == bfd_arch_unknown)
16331637 {
16341638 fprintf (stderr, "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx\n",
@@ -1712,84 +1716,99 @@ const bfd_target *
17121716 bfd_mach_o_object_p (abfd)
17131717 bfd *abfd;
17141718 {
1719+ struct bfd_preserve preserve;
17151720 bfd_mach_o_header header;
17161721
1722+ preserve.marker = NULL;
17171723 if (bfd_mach_o_read_header (abfd, &header) != 0)
1718- {
1719- bfd_set_error (bfd_error_wrong_format);
1720- return NULL;
1721- }
1724+ goto wrong;
17221725
1723- if (! ((header.byteorder == BFD_ENDIAN_BIG)
1724- || (header.byteorder == BFD_ENDIAN_LITTLE)))
1726+ if (! (header.byteorder == BFD_ENDIAN_BIG
1727+ || header.byteorder == BFD_ENDIAN_LITTLE))
17251728 {
1726- fprintf (stderr, "unknown header byte-order value 0x%lx\n", (long) header.byteorder);
1727- bfd_set_error (bfd_error_wrong_format);
1728- return NULL;
1729+ fprintf (stderr, "unknown header byte-order value 0x%lx\n",
1730+ (long) header.byteorder);
1731+ goto wrong;
17291732 }
17301733
1731- if (! (((header.byteorder == BFD_ENDIAN_BIG)
1732- && (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
1733- && (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG))
1734- ||
1735- ((header.byteorder == BFD_ENDIAN_LITTLE)
1736- && (abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
1737- && (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE))))
1738- {
1739- bfd_set_error (bfd_error_wrong_format);
1740- return NULL;
1741- }
1734+ if (! ((header.byteorder == BFD_ENDIAN_BIG
1735+ && abfd->xvec->byteorder == BFD_ENDIAN_BIG
1736+ && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
1737+ || (header.byteorder == BFD_ENDIAN_LITTLE
1738+ && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
1739+ && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
1740+ goto wrong;
17421741
1743- abfd->tdata.mach_o_data = NULL;
1742+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
1743+ if (preserve.marker == NULL
1744+ || !bfd_preserve_save (abfd, &preserve))
1745+ goto fail;
17441746
1745- if (bfd_mach_o_scan (abfd, &header) != 0)
1746- {
1747- abfd->tdata.mach_o_data = NULL;
1748- bfd_set_error (bfd_error_wrong_format);
1749- return NULL;
1750- }
1747+ if (bfd_mach_o_scan (abfd, &header,
1748+ (bfd_mach_o_data_struct *) preserve.marker) != 0)
1749+ goto wrong;
17511750
1751+ bfd_preserve_finish (abfd, &preserve);
17521752 return abfd->xvec;
1753+
1754+ wrong:
1755+ bfd_set_error (bfd_error_wrong_format);
1756+
1757+ fail:
1758+ if (preserve.marker != NULL)
1759+ bfd_preserve_restore (abfd, &preserve);
1760+ return NULL;
17531761 }
17541762
17551763 const bfd_target *
17561764 bfd_mach_o_core_p (abfd)
17571765 bfd *abfd;
17581766 {
1767+ struct bfd_preserve preserve;
17591768 bfd_mach_o_header header;
17601769
1761- bfd_set_error (bfd_error_wrong_format);
1762-
1770+ preserve.marker = NULL;
17631771 if (bfd_mach_o_read_header (abfd, &header) != 0)
1764- return NULL;
1772+ goto wrong;
17651773
1766- if (! ((header.byteorder == BFD_ENDIAN_BIG)
1767- || (header.byteorder == BFD_ENDIAN_LITTLE)))
1774+ if (! (header.byteorder == BFD_ENDIAN_BIG
1775+ || header.byteorder == BFD_ENDIAN_LITTLE))
17681776 {
1769- fprintf (stderr, "unknown header byte-order value 0x%lx\n", (long) header.byteorder);
1777+ fprintf (stderr, "unknown header byte-order value 0x%lx\n",
1778+ (long) header.byteorder);
17701779 abort ();
17711780 }
17721781
1773- if (! (((header.byteorder == BFD_ENDIAN_BIG)
1774- && (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
1775- && (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG))
1776- ||
1777- ((header.byteorder == BFD_ENDIAN_LITTLE)
1778- && (abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
1779- && (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE))))
1780- return NULL;
1782+ if (! ((header.byteorder == BFD_ENDIAN_BIG
1783+ && abfd->xvec->byteorder == BFD_ENDIAN_BIG
1784+ && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
1785+ || (header.byteorder == BFD_ENDIAN_LITTLE
1786+ && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
1787+ && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
1788+ goto wrong;
17811789
17821790 if (header.filetype != BFD_MACH_O_MH_CORE)
1783- return NULL;
1791+ goto wrong;
17841792
1785- abfd->tdata.mach_o_data = NULL;
1786- if (bfd_mach_o_scan (abfd, &header) != 0)
1787- {
1788- abfd->tdata.mach_o_data = NULL;
1789- return NULL;
1790- }
1793+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
1794+ if (preserve.marker == NULL
1795+ || !bfd_preserve_save (abfd, &preserve))
1796+ goto fail;
17911797
1798+ if (bfd_mach_o_scan (abfd, &header,
1799+ (bfd_mach_o_data_struct *) preserve.marker) != 0)
1800+ goto wrong;
1801+
1802+ bfd_preserve_finish (abfd, &preserve);
17921803 return abfd->xvec;
1804+
1805+ wrong:
1806+ bfd_set_error (bfd_error_wrong_format);
1807+
1808+ fail:
1809+ if (preserve.marker != NULL)
1810+ bfd_preserve_restore (abfd, &preserve);
1811+ return NULL;
17931812 }
17941813
17951814 typedef struct mach_o_fat_archentry
@@ -1813,35 +1832,35 @@ const bfd_target *
18131832 bfd_mach_o_archive_p (abfd)
18141833 bfd *abfd;
18151834 {
1816- mach_o_fat_data_struct *adata;
1835+ mach_o_fat_data_struct *adata = NULL;
18171836 unsigned char buf[20];
18181837 unsigned long i;
18191838
18201839 bfd_seek (abfd, 0, SEEK_SET);
18211840 if (bfd_bread ((PTR) buf, 8, abfd) != 8)
1822- return NULL;
1841+ goto error;
18231842
18241843 adata = (mach_o_fat_data_struct *)
18251844 bfd_alloc (abfd, sizeof (mach_o_fat_data_struct));
18261845 if (adata == NULL)
1827- return NULL;
1846+ goto error;
18281847
18291848 adata->magic = bfd_getb32 (buf);
18301849 adata->nfat_arch = bfd_getb32 (buf + 4);
18311850 if (adata->magic != 0xcafebabe)
1832- return NULL;
1851+ goto error;
18331852
18341853 adata->archentries = (mach_o_fat_archentry *)
18351854 bfd_alloc (abfd, adata->nfat_arch * sizeof (mach_o_fat_archentry));
18361855 if (adata->archentries == NULL)
1837- return NULL;
1856+ goto error;
18381857
18391858 for (i = 0; i < adata->nfat_arch; i++)
18401859 {
18411860 bfd_seek (abfd, 8 + 20 * i, SEEK_SET);
18421861
18431862 if (bfd_bread ((PTR) buf, 20, abfd) != 20)
1844- return NULL;
1863+ goto error;
18451864 adata->archentries[i].cputype = bfd_getb32 (buf);
18461865 adata->archentries[i].cpusubtype = bfd_getb32 (buf + 4);
18471866 adata->archentries[i].offset = bfd_getb32 (buf + 8);
@@ -1852,6 +1871,12 @@ bfd_mach_o_archive_p (abfd)
18521871
18531872 abfd->tdata.mach_o_fat_data = adata;
18541873 return abfd->xvec;
1874+
1875+ error:
1876+ if (adata != NULL)
1877+ bfd_release (abfd, adata);
1878+ bfd_set_error (bfd_error_wrong_format);
1879+ return NULL;
18551880 }
18561881
18571882 bfd *
@@ -1859,10 +1884,11 @@ bfd_mach_o_openr_next_archived_file (archive, prev)
18591884 bfd *archive;
18601885 bfd *prev;
18611886 {
1862- mach_o_fat_data_struct *adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
1887+ mach_o_fat_data_struct *adata;
18631888 mach_o_fat_archentry *entry = NULL;
18641889 unsigned long i;
18651890
1891+ adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
18661892 BFD_ASSERT (adata != NULL);
18671893
18681894 /* Find index of previous entry. */
@@ -1913,9 +1939,12 @@ bfd_mach_o_openr_next_archived_file (archive, prev)
19131939 return entry->abfd;
19141940 }
19151941
1916-int bfd_mach_o_lookup_section
1917- (bfd *abfd, asection *section,
1918- bfd_mach_o_load_command **mcommand, bfd_mach_o_section **msection)
1942+int
1943+bfd_mach_o_lookup_section (abfd, section, mcommand, msection)
1944+ bfd *abfd;
1945+ asection *section;
1946+ bfd_mach_o_load_command **mcommand;
1947+ bfd_mach_o_section **msection;
19191948 {
19201949 struct mach_o_data_struct *md = abfd->tdata.mach_o_data;
19211950 unsigned int i, j, num;
@@ -1962,9 +1991,10 @@ int bfd_mach_o_lookup_section
19621991 }
19631992
19641993 int
1965-bfd_mach_o_lookup_command
1966- (bfd *abfd, bfd_mach_o_load_command_type type,
1967- bfd_mach_o_load_command **mcommand)
1994+bfd_mach_o_lookup_command (abfd, type, mcommand)
1995+ bfd *abfd;
1996+ bfd_mach_o_load_command_type type;
1997+ bfd_mach_o_load_command **mcommand;
19681998 {
19691999 struct mach_o_data_struct *md = NULL;
19702000 bfd_mach_o_load_command *ncmd = NULL;
@@ -2011,7 +2041,7 @@ bfd_mach_o_stack_addr (type)
20112041 case BFD_MACH_O_CPU_TYPE_I860:
20122042 return 0;
20132043 case BFD_MACH_O_CPU_TYPE_HPPA:
2014- return (0xc0000000-0x04000000);
2044+ return 0xc0000000 - 0x04000000;
20152045 default:
20162046 return 0;
20172047 }
@@ -2063,8 +2093,9 @@ bfd_mach_o_core_fetch_environment (abfd, rbuf, rlen)
20632093
20642094 for (offset = 4; offset <= size; offset += 4)
20652095 {
2066- unsigned long val = *((unsigned long *) (buf + size - offset));
2096+ unsigned long val;
20672097
2098+ val = *((unsigned long *) (buf + size - offset));
20682099 if (! found_nonnull)
20692100 {
20702101 if (val != 0)
@@ -2072,9 +2103,11 @@ bfd_mach_o_core_fetch_environment (abfd, rbuf, rlen)
20722103 }
20732104 else if (val == 0x0)
20742105 {
2075- unsigned long bottom = seg->fileoff + seg->filesize - offset;
2076- unsigned long top = seg->fileoff + seg->filesize - 4;
2106+ unsigned long bottom;
2107+ unsigned long top;
20772108
2109+ bottom = seg->fileoff + seg->filesize - offset;
2110+ top = seg->fileoff + seg->filesize - 4;
20782111 *rbuf = bfd_malloc (top - bottom);
20792112 *rlen = top - bottom;
20802113
@@ -2159,4 +2192,3 @@ bfd_mach_o_core_file_matches_executable_p (core_bfd, exec_bfd)
21592192 #undef TARGET_STRING
21602193 #undef TARGET_BIG_ENDIAN
21612194 #undef TARGET_ARCHIVE
2162-
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -15,7 +15,7 @@
1515 GNU General Public License for more details.
1616
1717 You should have received a copy of the GNU General Public License
18- along with this program; if not, write to the Free Software
18+ along with this program; if not, write to the Free Software
1919 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2020
2121 #ifndef _BFD_MACH_O_H_
@@ -127,13 +127,13 @@ bfd_mach_o_filetype;
127127 typedef enum bfd_mach_o_section_type
128128 {
129129 /* Regular section. */
130- BFD_MACH_O_S_REGULAR = 0x0,
130+ BFD_MACH_O_S_REGULAR = 0x0,
131131
132132 /* Zero fill on demand section. */
133133 BFD_MACH_O_S_ZEROFILL = 0x1,
134134
135135 /* Section with only literal C strings. */
136- BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
136+ BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
137137
138138 /* Section with only 4 byte literals. */
139139 BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
@@ -159,13 +159,13 @@ typedef enum bfd_mach_o_section_type
159159
160160 /* Section with only non-lazy symbol pointers. */
161161 BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
162-
162+
163163 /* Section with only lazy symbol pointers. */
164164 BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
165-
165+
166166 /* Section with only symbol stubs, byte size of stub in the reserved2 field. */
167167 BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
168-
168+
169169 /* Section with only function pointers for initialization. */
170170 BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
171171 }
@@ -232,7 +232,7 @@ bfd_mach_o_symtab_command;
232232
233233 /* This is the second set of the symbolic information which is used to support
234234 the data structures for the dynamicly link editor.
235-
235+
236236 The original set of symbolic information in the symtab_command which contains
237237 the symbol and string tables must also be present when this load command is
238238 present. When this load command is present the symbol table is organized
@@ -242,7 +242,7 @@ bfd_mach_o_symtab_command;
242242 undefined external symbols (sorted by name)
243243 In this load command there are offsets and counts to each of the three groups
244244 of symbols.
245-
245+
246246 This load command contains a the offsets and sizes of the following new
247247 symbolic information tables:
248248 table of contents
@@ -258,7 +258,7 @@ bfd_mach_o_symtab_command;
258258 module table - the file contains only one module so everything in the
259259 file is part of the module.
260260 reference symbol table - is the defined and undefined external symbols
261-
261+
262262 For dynamicly linked shared library files this load command also contains
263263 offsets and sizes to the pool of relocation entries for all sections
264264 separated into two groups:
@@ -274,11 +274,11 @@ typedef struct bfd_mach_o_dysymtab_command
274274 local symbols (further grouped by the module they are from)
275275 defined external symbols (further grouped by the module they are from)
276276 undefined symbols
277-
277+
278278 The local symbols are used only for debugging. The dynamic binding
279279 process may have to use them to indicate to the debugger the local
280280 symbols for a module that is being bound.
281-
281+
282282 The last two groups are used by the dynamic binding process to do the
283283 binding (indirectly through the module table and the reference symbol
284284 table when this is a dynamicly linked shared library file). */
@@ -368,11 +368,11 @@ typedef struct bfd_mach_o_dysymtab_command
368368 unsigned long locreloff; /* Offset to local relocation entries. */
369369 unsigned long nlocrel; /* Number of local relocation entries. */
370370 }
371-bfd_mach_o_dysymtab_command;
371+bfd_mach_o_dysymtab_command;
372372
373-/* An indirect symbol table entry is simply a 32bit index into the symbol table
373+/* An indirect symbol table entry is simply a 32bit index into the symbol table
374374 to the symbol that the pointer or stub is refering to. Unless it is for a
375- non-lazy symbol pointer section for a defined symbol which strip(1) as
375+ non-lazy symbol pointer section for a defined symbol which strip(1) as
376376 removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
377377 symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */
378378
@@ -390,7 +390,7 @@ bfd_mach_o_thread_flavour;
390390 typedef struct bfd_mach_o_thread_command
391391 {
392392 unsigned long nflavours;
393- bfd_mach_o_thread_flavour *flavours;
393+ bfd_mach_o_thread_flavour *flavours;
394394 asection *section;
395395 }
396396 bfd_mach_o_thread_command;
@@ -469,7 +469,7 @@ int bfd_mach_o_scan_read_symtab_strtab PARAMS ((bfd *, bfd_mach
469469 int bfd_mach_o_scan_read_symtab_symbols PARAMS ((bfd *, bfd_mach_o_symtab_command *));
470470 int bfd_mach_o_scan_read_dysymtab_symbol PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
471471 int bfd_mach_o_scan_start_address PARAMS ((bfd *));
472-int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *));
472+int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));
473473 boolean bfd_mach_o_mkobject PARAMS ((bfd *));
474474 const bfd_target * bfd_mach_o_object_p PARAMS ((bfd *));
475475 const bfd_target * bfd_mach_o_core_p PARAMS ((bfd *));
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -15,7 +15,7 @@
1515 GNU General Public License for more details.
1616
1717 You should have received a copy of the GNU General Public License
18- along with this program; if not, write to the Free Software
18+ along with this program; if not, write to the Free Software
1919 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2020
2121 #include <ctype.h>
@@ -70,7 +70,7 @@
7070 static void bfd_pef_print_symbol
7171 PARAMS ((bfd *abfd, PTR afile, asymbol *symbol, bfd_print_symbol_type how));
7272 static void bfd_pef_convert_architecture
73-PARAMS ((unsigned long architecture,
73+PARAMS ((unsigned long architecture,
7474 enum bfd_architecture *type, unsigned long *subtype));
7575 static boolean bfd_pef_mkobject PARAMS ((bfd *abfd));
7676 static int bfd_pef_parse_traceback_table
@@ -78,7 +78,8 @@ PARAMS ((bfd *abfd, asection *section, unsigned char *buf,
7878 size_t len, size_t pos, asymbol *sym, FILE *file));
7979 static const char *bfd_pef_section_name PARAMS ((bfd_pef_section *section));
8080 static unsigned long bfd_pef_section_flags PARAMS ((bfd_pef_section *section));
81-static asection *bfd_pef_make_bfd_section PARAMS ((bfd *abfd, bfd_pef_section *section));
81+static asection *bfd_pef_make_bfd_section
82+PARAMS ((bfd *abfd, bfd_pef_section *section));
8283 static int bfd_pef_read_header PARAMS ((bfd *abfd, bfd_pef_header *header));
8384 static const bfd_target *bfd_pef_object_p PARAMS ((bfd *));
8485 static int bfd_pef_parse_traceback_tables
@@ -86,9 +87,10 @@ PARAMS ((bfd *abfd, asection *sec, unsigned char *buf,
8687 size_t len, long *nsym, asymbol **csym));
8788 static int bfd_pef_parse_function_stub
8889 PARAMS ((bfd *abfd, unsigned char *buf, size_t len, unsigned long *offset));
89-static int bfd_pef_parse_function_stubs
90+static int bfd_pef_parse_function_stubs
9091 PARAMS ((bfd *abfd, asection *codesec, unsigned char *codebuf, size_t codelen,
91- unsigned char *loaderbuf, size_t loaderlen, unsigned long *nsym, asymbol **csym));
92+ unsigned char *loaderbuf, size_t loaderlen, unsigned long *nsym,
93+ asymbol **csym));
9294 static long bfd_pef_parse_symbols PARAMS ((bfd *abfd, asymbol **csym));
9395 static long bfd_pef_count_symbols PARAMS ((bfd *abfd));
9496 static long bfd_pef_get_symtab_upper_bound PARAMS ((bfd *));
@@ -97,7 +99,8 @@ static asymbol *bfd_pef_make_empty_symbol PARAMS ((bfd *));
9799 static void bfd_pef_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
98100 static int bfd_pef_sizeof_headers PARAMS ((bfd *, boolean));
99101
100-static int bfd_pef_xlib_read_header PARAMS ((bfd *abfd, bfd_pef_xlib_header *header));
102+static int bfd_pef_xlib_read_header
103+PARAMS ((bfd *abfd, bfd_pef_xlib_header *header));
101104 static int bfd_pef_xlib_scan PARAMS ((bfd *abfd, bfd_pef_xlib_header *header));
102105 static const bfd_target *bfd_pef_xlib_object_p PARAMS ((bfd *abfd));
103106
@@ -109,29 +112,32 @@ bfd_pef_print_symbol (abfd, afile, symbol, how)
109112 bfd_print_symbol_type how;
110113 {
111114 FILE *file = (FILE *) afile;
112- switch (how) {
113- case bfd_print_symbol_name:
114- fprintf (file, "%s", symbol->name);
115- break;
116- default:
117- bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
118- fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
119- if (strncmp (symbol->name, "__traceback_", strlen ("__traceback_")) == 0) {
120- char *buf = alloca (symbol->udata.i);
121- size_t offset = symbol->value + 4;
122- size_t len = symbol->udata.i;
123- int ret;
124-
125- bfd_get_section_contents (abfd, symbol->section, buf, offset, len);
126- ret = bfd_pef_parse_traceback_table (abfd, symbol->section, buf, len, 0, NULL, file);
127- if (ret < 0) {
128- fprintf (file, " [ERROR]");
129- }
115+ switch (how)
116+ {
117+ case bfd_print_symbol_name:
118+ fprintf (file, "%s", symbol->name);
119+ break;
120+ default:
121+ bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
122+ fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
123+ if (strncmp (symbol->name, "__traceback_", strlen ("__traceback_")) == 0)
124+ {
125+ char *buf = alloca (symbol->udata.i);
126+ size_t offset = symbol->value + 4;
127+ size_t len = symbol->udata.i;
128+ int ret;
129+
130+ bfd_get_section_contents (abfd, symbol->section, buf, offset, len);
131+ ret = bfd_pef_parse_traceback_table (abfd, symbol->section, buf,
132+ len, 0, NULL, file);
133+ if (ret < 0)
134+ fprintf (file, " [ERROR]");
135+ }
130136 }
131- }
132137 }
133138
134-static void bfd_pef_convert_architecture (architecture, type, subtype)
139+static void
140+bfd_pef_convert_architecture (architecture, type, subtype)
135141 unsigned long architecture;
136142 enum bfd_architecture *type;
137143 unsigned long *subtype;
@@ -141,7 +147,7 @@ static void bfd_pef_convert_architecture (architecture, type, subtype)
141147
142148 const unsigned long ARCH_POWERPC = 0x70777063; /* 'pwpc' */
143149 const unsigned long ARCH_M68K = 0x6d36386b; /* 'm68k' */
144-
150+
145151 if (architecture == ARCH_POWERPC)
146152 *type = bfd_arch_powerpc;
147153 else if (architecture == ARCH_M68K)
@@ -169,8 +175,9 @@ bfd_pef_parse_traceback_table (abfd, section, buf, len, pos, sym, file)
169175 size_t offset;
170176 const char *s;
171177 asymbol tmpsymbol;
172-
173- if (sym == NULL) { sym = &tmpsymbol; }
178+
179+ if (sym == NULL)
180+ sym = &tmpsymbol;
174181
175182 sym->name = NULL;
176183 sym->value = 0;
@@ -181,150 +188,150 @@ bfd_pef_parse_traceback_table (abfd, section, buf, len, pos, sym, file)
181188
182189 /* memcpy is fine since all fields are unsigned char */
183190
184- if ((pos + 8) > len) { return -1; }
191+ if ((pos + 8) > len)
192+ return -1;
185193 memcpy (&table, buf + pos, 8);
186-
187- /* calling code relies on returned symbols having a name and correct offset */
188194
189- if ((table.lang != TB_C) && (table.lang != TB_CPLUSPLUS)) {
195+ /* calling code relies on returned symbols having a name and
196+ correct offset */
197+
198+ if ((table.lang != TB_C) && (table.lang != TB_CPLUSPLUS))
190199 return -1;
191- }
192- if (! (table.flags2 & TB_NAME_PRESENT)) {
200+
201+ if (! (table.flags2 & TB_NAME_PRESENT))
193202 return -1;
194- }
195- if (! table.flags1 & TB_HAS_TBOFF) {
203+
204+ if (! table.flags1 & TB_HAS_TBOFF)
196205 return -1;
197- }
198206
199207 offset = 8;
200208
201- if ((table.flags5 & TB_FLOATPARAMS) || (table.fixedparams)) {
202- offset += 4;
203- }
209+ if ((table.flags5 & TB_FLOATPARAMS) || (table.fixedparams))
210+ offset += 4;
204211
205- if (table.flags1 & TB_HAS_TBOFF) {
212+ if (table.flags1 & TB_HAS_TBOFF)
213+ {
214+ struct traceback_table_tboff off;
206215
207- struct traceback_table_tboff off;
208-
209- if ((pos + offset + 4) > len) { return -1; }
210- off.tb_offset = bfd_getb32 (buf + pos + offset);
211- offset += 4;
216+ if ((pos + offset + 4) > len)
217+ return -1;
218+ off.tb_offset = bfd_getb32 (buf + pos + offset);
219+ offset += 4;
212220
213- /* need to subtract 4 because the offset includes the 0x0L
214- preceding the table */
221+ /* need to subtract 4 because the offset includes the 0x0L
222+ preceding the table */
215223
216- if (file != NULL) {
217- fprintf (file, " [offset = 0x%lx]", off.tb_offset);
218- }
224+ if (file != NULL)
225+ fprintf (file, " [offset = 0x%lx]", off.tb_offset);
219226
220- if ((file == NULL) && ((off.tb_offset + 4) > (pos + offset))) {
221- return -1;
227+ if ((file == NULL) && ((off.tb_offset + 4) > (pos + offset)))
228+ return -1;
229+
230+ sym->value = pos - off.tb_offset - 4;
222231 }
223- sym->value = pos - off.tb_offset - 4;
224- }
225232
226- if (table.flags2 & TB_INT_HNDL) {
233+ if (table.flags2 & TB_INT_HNDL)
227234 offset += 4;
228- }
229235
230- if (table.flags1 & TB_HAS_CTL) {
236+ if (table.flags1 & TB_HAS_CTL)
237+ {
238+ struct traceback_table_anchors anchors;
231239
232- struct traceback_table_anchors anchors;
240+ if ((pos + offset + 4) > len)
241+ return -1;
242+ anchors.ctl_info = bfd_getb32 (buf + pos + offset);
243+ offset += 4;
233244
234- if ((pos + offset + 4) > len) { return -1; }
235- anchors.ctl_info = bfd_getb32 (buf + pos + offset);
236- offset += 4;
245+ if (anchors.ctl_info > 1024)
246+ return -1;
237247
238- if (anchors.ctl_info > 1024) {
239- return -1;
248+ offset += anchors.ctl_info * 4;
240249 }
241250
242- offset += anchors.ctl_info * 4;
243- }
251+ if (table.flags2 & TB_NAME_PRESENT)
252+ {
253+ struct traceback_table_routine name;
254+ char *namebuf;
244255
245- if (table.flags2 & TB_NAME_PRESENT) {
256+ if ((pos + offset + 2) > len)
257+ return -1;
258+ name.name_len = bfd_getb16 (buf + pos + offset);
259+ offset += 2;
246260
247- struct traceback_table_routine name;
248- char *namebuf;
261+ if (name.name_len > 4096)
262+ return -1;
249263
250- if ((pos + offset + 2) > len) { return -1; }
251- name.name_len = bfd_getb16 (buf + pos + offset);
252- offset += 2;
264+ if ((pos + offset + name.name_len) > len)
265+ return -1;
253266
254- if (name.name_len > 4096) { return -1; }
267+ namebuf = (char *) bfd_alloc (abfd, name.name_len + 1);
268+ if (namebuf == NULL)
269+ return -1;
255270
256- if ((pos + offset + name.name_len) > len) { return -1; }
271+ memcpy (namebuf, buf + pos + offset, name.name_len);
272+ namebuf[name.name_len] = '\0';
257273
258- namebuf = (char *) bfd_alloc (abfd, name.name_len + 1);
259- if (namebuf == NULL) { return -1; }
274+ /* strip leading period inserted by compiler */
275+ if (namebuf[0] == '.')
276+ memmove (namebuf, namebuf + 1, name.name_len + 1);
260277
261- memcpy (namebuf, buf + pos + offset, name.name_len);
262- namebuf[name.name_len] = '\0';
263-
264- /* strip leading period inserted by compiler */
265- if (namebuf[0] == '.') {
266- memmove (namebuf, namebuf + 1, name.name_len + 1);
267- }
278+ sym->name = namebuf;
268279
269- sym->name = namebuf;
280+ for (s = sym->name; (*s != '\0'); s++)
281+ if (! isprint (*s))
282+ return -1;
270283
271- for (s = sym->name; (*s != '\0'); s++) {
272- if (! isprint (*s)) {
273- return -1;
274- }
284+ offset += name.name_len;
275285 }
276286
277- offset += name.name_len;
278- }
279-
280- if (table.flags2 & TB_USES_ALLOCA) {
287+ if (table.flags2 & TB_USES_ALLOCA)
281288 offset += 4;
282- }
283289
284- if (table.flags4 & TB_HAS_VEC_INFO) {
290+ if (table.flags4 & TB_HAS_VEC_INFO)
285291 offset += 4;
286- }
287292
288- if (file != NULL) {
293+ if (file != NULL)
289294 fprintf (file, " [length = 0x%lx]", (long) offset);
290- }
295+
291296 return offset;
292297 }
293298
294299 static const char *bfd_pef_section_name (section)
295300 bfd_pef_section *section;
296301 {
297- switch (section->section_kind) {
298- case BFD_PEF_SECTION_CODE: return "code";
299- case BFD_PEF_SECTION_UNPACKED_DATA: return "unpacked-data";
300- case BFD_PEF_SECTION_PACKED_DATA: return "packed-data";
301- case BFD_PEF_SECTION_CONSTANT: return "constant";
302- case BFD_PEF_SECTION_LOADER: return "loader";
303- case BFD_PEF_SECTION_DEBUG: return "debug";
304- case BFD_PEF_SECTION_EXEC_DATA: return "exec-data";
305- case BFD_PEF_SECTION_EXCEPTION: return "exception";
306- case BFD_PEF_SECTION_TRACEBACK: return "traceback";
307- default: return "unknown";
308- }
302+ switch (section->section_kind)
303+ {
304+ case BFD_PEF_SECTION_CODE: return "code";
305+ case BFD_PEF_SECTION_UNPACKED_DATA: return "unpacked-data";
306+ case BFD_PEF_SECTION_PACKED_DATA: return "packed-data";
307+ case BFD_PEF_SECTION_CONSTANT: return "constant";
308+ case BFD_PEF_SECTION_LOADER: return "loader";
309+ case BFD_PEF_SECTION_DEBUG: return "debug";
310+ case BFD_PEF_SECTION_EXEC_DATA: return "exec-data";
311+ case BFD_PEF_SECTION_EXCEPTION: return "exception";
312+ case BFD_PEF_SECTION_TRACEBACK: return "traceback";
313+ default: return "unknown";
314+ }
309315 }
310316
311317 static unsigned long bfd_pef_section_flags (section)
312318 bfd_pef_section *section;
313319 {
314- switch (section->section_kind) {
315- case BFD_PEF_SECTION_CODE:
316- return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
317- case BFD_PEF_SECTION_UNPACKED_DATA:
318- case BFD_PEF_SECTION_PACKED_DATA:
319- case BFD_PEF_SECTION_CONSTANT:
320- case BFD_PEF_SECTION_LOADER:
321- case BFD_PEF_SECTION_DEBUG:
322- case BFD_PEF_SECTION_EXEC_DATA:
323- case BFD_PEF_SECTION_EXCEPTION:
324- case BFD_PEF_SECTION_TRACEBACK:
325- default:
326- return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
327- }
320+ switch (section->section_kind)
321+ {
322+ case BFD_PEF_SECTION_CODE:
323+ return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
324+ case BFD_PEF_SECTION_UNPACKED_DATA:
325+ case BFD_PEF_SECTION_PACKED_DATA:
326+ case BFD_PEF_SECTION_CONSTANT:
327+ case BFD_PEF_SECTION_LOADER:
328+ case BFD_PEF_SECTION_DEBUG:
329+ case BFD_PEF_SECTION_EXEC_DATA:
330+ case BFD_PEF_SECTION_EXCEPTION:
331+ case BFD_PEF_SECTION_TRACEBACK:
332+ default:
333+ return SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
334+ }
328335 }
329336
330337 static asection *
@@ -336,8 +343,9 @@ bfd_pef_make_bfd_section (abfd, section)
336343 const char *name = bfd_pef_section_name (section);
337344
338345 bfdsec = bfd_make_section_anyway (abfd, name);
339- if (bfdsec == NULL) { return NULL; }
340-
346+ if (bfdsec == NULL)
347+ return NULL;
348+
341349 bfdsec->vma = section->default_address + section->container_offset;
342350 bfdsec->lma = section->default_address + section->container_offset;
343351 bfdsec->_raw_size = section->container_length;
@@ -417,9 +425,10 @@ int bfd_pef_scan_section (abfd, section)
417425 bfd_pef_section *section;
418426 {
419427 unsigned char buf[28];
420-
428+
421429 bfd_seek (abfd, section->header_offset, SEEK_SET);
422- if (bfd_bread ((PTR) buf, 28, abfd) != 28) { return -1; }
430+ if (bfd_bread ((PTR) buf, 28, abfd) != 28)
431+ return -1;
423432
424433 section->name_offset = bfd_h_get_32 (abfd, buf);
425434 section->default_address = bfd_h_get_32 (abfd, buf + 4);
@@ -433,7 +442,8 @@ int bfd_pef_scan_section (abfd, section)
433442 section->reserved = buf[27];
434443
435444 section->bfd_section = bfd_pef_make_bfd_section (abfd, section);
436- if (section->bfd_section == NULL) { return -1; }
445+ if (section->bfd_section == NULL)
446+ return -1;
437447
438448 return 0;
439449 }
@@ -450,14 +460,19 @@ bfd_pef_print_loader_header (abfd, header, file)
450460 fprintf (file, "init_offset: %lu\n", header->init_offset);
451461 fprintf (file, "term_section: %ld\n", header->term_section);
452462 fprintf (file, "term_offset: %lu\n", header->term_offset);
453- fprintf (file, "imported_library_count: %lu\n", header->imported_library_count);
454- fprintf (file, "total_imported_symbol_count: %lu\n", header->total_imported_symbol_count);
463+ fprintf (file, "imported_library_count: %lu\n",
464+ header->imported_library_count);
465+ fprintf (file, "total_imported_symbol_count: %lu\n",
466+ header->total_imported_symbol_count);
455467 fprintf (file, "reloc_section_count: %lu\n", header->reloc_section_count);
456468 fprintf (file, "reloc_instr_offset: %lu\n", header->reloc_instr_offset);
457- fprintf (file, "loader_strings_offset: %lu\n", header->loader_strings_offset);
469+ fprintf (file, "loader_strings_offset: %lu\n",
470+ header->loader_strings_offset);
458471 fprintf (file, "export_hash_offset: %lu\n", header->export_hash_offset);
459- fprintf (file, "export_hash_table_power: %lu\n", header->export_hash_table_power);
460- fprintf (file, "exported_symbol_count: %lu\n", header->exported_symbol_count);
472+ fprintf (file, "export_hash_table_power: %lu\n",
473+ header->export_hash_table_power);
474+ fprintf (file, "exported_symbol_count: %lu\n",
475+ header->exported_symbol_count);
461476 }
462477
463478 int
@@ -472,18 +487,33 @@ bfd_pef_print_loader_section (abfd, file)
472487 int ret;
473488
474489 loadersec = bfd_get_section_by_name (abfd, "loader");
475- if (loadersec == NULL) { return -1; }
476-
490+ if (loadersec == NULL)
491+ return -1;
492+
477493 loaderlen = bfd_section_size (abfd, loadersec);
478494 loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
479495 if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
480- { free (loaderbuf); return -1; }
496+ {
497+ free (loaderbuf);
498+ return -1;
499+ }
481500 if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
482- { free (loaderbuf); return -1; }
501+ {
502+ free (loaderbuf);
503+ return -1;
504+ }
483505
484- if (loaderlen < 56) { free (loaderbuf); return -1; }
506+ if (loaderlen < 56)
507+ {
508+ free (loaderbuf);
509+ return -1;
510+ }
485511 ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
486- if (ret < 0) { free (loaderbuf); return -1; }
512+ if (ret < 0)
513+ {
514+ free (loaderbuf);
515+ return -1;
516+ }
487517
488518 bfd_pef_print_loader_header (abfd, &header, file);
489519 return 0;
@@ -502,89 +532,97 @@ bfd_pef_scan_start_address (abfd)
502532 int ret;
503533
504534 loadersec = bfd_get_section_by_name (abfd, "loader");
505- if (loadersec == NULL) { goto end; }
506-
535+ if (loadersec == NULL)
536+ goto end;
537+
507538 loaderlen = bfd_section_size (abfd, loadersec);
508539 loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
509- if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) { goto error; }
510- if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen) { goto error; }
540+ if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
541+ goto error;
542+ if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
543+ goto error;
511544
512- if (loaderlen < 56) { goto error; }
545+ if (loaderlen < 56)
546+ goto error;
513547 ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
514- if (ret < 0) { goto error; }
548+ if (ret < 0)
549+ goto error;
550+
551+ if (header.main_section < 0)
552+ goto end;
553+
554+ for (section = abfd->sections; section != NULL; section = section->next)
555+ if ((section->index + 1) == header.main_section)
556+ break;
515557
516- if (header.main_section < 0) { goto end; }
558+ if (section == NULL)
559+ goto error;
517560
518- for (section = abfd->sections; section != NULL; section = section->next) {
519- if ((section->index + 1) == header.main_section) { break; }
520- }
521-
522- if (section == NULL) { goto error; }
523-
524561 abfd->start_address = section->vma + header.main_offset;
525562
526563 end:
527- if (loaderbuf != NULL) { free (loaderbuf); }
564+ if (loaderbuf != NULL)
565+ free (loaderbuf);
528566 return 0;
529567
530568 error:
531- if (loaderbuf != NULL) { free (loaderbuf); }
569+ if (loaderbuf != NULL)
570+ free (loaderbuf);
532571 return -1;
533572 }
534573
535574 int
536-bfd_pef_scan (abfd, header)
575+bfd_pef_scan (abfd, header, mdata)
537576 bfd *abfd;
538577 bfd_pef_header *header;
578+ bfd_pef_data_struct *mdata;
539579 {
540580 unsigned int i;
541- bfd_pef_data_struct *mdata = NULL;
542581 enum bfd_architecture cputype;
543582 unsigned long cpusubtype;
544583
545- if ((header->tag1 != BFD_PEF_TAG1) || (header->tag2 != BFD_PEF_TAG2)) {
546- return -1;
547- }
584+ mdata->header = *header;
548585
549- mdata = ((bfd_pef_data_struct *)
550- bfd_alloc (abfd, sizeof (bfd_pef_data_struct)));
551- if (mdata == NULL) { return -1; }
552-
553586 bfd_pef_convert_architecture (header->architecture, &cputype, &cpusubtype);
554- if (cputype == bfd_arch_unknown) {
555- fprintf (stderr, "bfd_pef_scan: unknown architecture 0x%lx\n", header->architecture);
556- return -1;
557- }
587+ if (cputype == bfd_arch_unknown)
588+ {
589+ fprintf (stderr, "bfd_pef_scan: unknown architecture 0x%lx\n",
590+ header->architecture);
591+ return -1;
592+ }
558593 bfd_set_arch_mach (abfd, cputype, cpusubtype);
559594
560595 mdata->header = *header;
561596
562- abfd->flags = abfd->xvec->object_flags | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS));
597+ abfd->flags = (abfd->xvec->object_flags
598+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
563599
564- if (header->section_count != 0) {
565-
566- mdata->sections =
567- ((bfd_pef_section *)
568- bfd_alloc (abfd, header->section_count * sizeof (bfd_pef_section)));
569- if (mdata->sections == NULL) { return -1; }
600+ if (header->section_count != 0)
601+ {
602+ mdata->sections =
603+ ((bfd_pef_section *)
604+ bfd_alloc (abfd, header->section_count * sizeof (bfd_pef_section)));
570605
571- for (i = 0; i < header->section_count; i++) {
572- bfd_pef_section *cur = &mdata->sections[i];
573- cur->header_offset = 40 + (i * 28);
574- if (bfd_pef_scan_section (abfd, cur) < 0) {
606+ if (mdata->sections == NULL)
575607 return -1;
576- }
608+
609+ for (i = 0; i < header->section_count; i++)
610+ {
611+ bfd_pef_section *cur = &mdata->sections[i];
612+ cur->header_offset = 40 + (i * 28);
613+ if (bfd_pef_scan_section (abfd, cur) < 0)
614+ return -1;
615+ }
577616 }
578- }
579617
580- if (bfd_pef_scan_start_address (abfd) < 0) {
618+ if (bfd_pef_scan_start_address (abfd) < 0)
619+ {
581620 #if 0
582- fprintf (stderr, "bfd_pef_scan: unable to scan start address: %s\n",
583- bfd_errmsg (bfd_get_error ()));
584- abfd->tdata.pef_data = NULL;
585- return -1;
621+ fprintf (stderr, "bfd_pef_scan: unable to scan start address: %s\n",
622+ bfd_errmsg (bfd_get_error ()));
623+ return -1;
586624 #endif
587- }
625+ }
588626
589627 abfd->tdata.pef_data = mdata;
590628
@@ -600,7 +638,8 @@ bfd_pef_read_header (abfd, header)
600638
601639 bfd_seek (abfd, 0, SEEK_SET);
602640
603- if (bfd_bread ((PTR) buf, 40, abfd) != 40) { return -1; }
641+ if (bfd_bread ((PTR) buf, 40, abfd) != 40)
642+ return -1;
604643
605644 header->tag1 = bfd_getb32 (buf);
606645 header->tag2 = bfd_getb32 (buf + 4);
@@ -621,23 +660,35 @@ static const bfd_target *
621660 bfd_pef_object_p (abfd)
622661 bfd *abfd;
623662 {
663+ struct bfd_preserve preserve;
624664 bfd_pef_header header;
625-
626- abfd->tdata.pef_data = NULL;
627665
628- if (bfd_pef_read_header (abfd, &header) != 0) {
629- abfd->tdata.pef_data = NULL;
630- bfd_set_error (bfd_error_wrong_format);
631- return NULL;
632- }
666+ preserve.marker = NULL;
667+ if (bfd_pef_read_header (abfd, &header) != 0)
668+ goto wrong;
633669
634- if (bfd_pef_scan (abfd, &header) != 0) {
635- abfd->tdata.pef_data = NULL;
636- bfd_set_error (bfd_error_wrong_format);
637- return NULL;
638- }
670+ if (header.tag1 != BFD_PEF_TAG1 || header.tag2 != BFD_PEF_TAG2)
671+ goto wrong;
672+
673+ preserve.marker = bfd_zalloc (abfd, sizeof (bfd_pef_data_struct));
674+ if (preserve.marker == NULL
675+ || !bfd_preserve_save (abfd, &preserve))
676+ goto fail;
639677
678+ if (bfd_pef_scan (abfd, &header,
679+ (bfd_pef_data_struct *) preserve.marker) != 0)
680+ goto wrong;
681+
682+ bfd_preserve_finish (abfd, &preserve);
640683 return abfd->xvec;
684+
685+ wrong:
686+ bfd_set_error (bfd_error_wrong_format);
687+
688+ fail:
689+ if (preserve.marker != NULL)
690+ bfd_preserve_restore (abfd, &preserve);
691+ return NULL;
641692 }
642693
643694 static int bfd_pef_parse_traceback_tables (abfd, sec, buf, len, nsym, csym)
@@ -660,64 +711,65 @@ static int bfd_pef_parse_traceback_tables (abfd, sec, buf, len, nsym, csym)
660711 unsigned long count = 0;
661712 int ret;
662713
663- for (;;) {
664-
665- /* we're reading symbols two at a time */
714+ for (;;)
715+ {
716+ /* we're reading symbols two at a time */
666717
667- if (csym && ((csym[count] == NULL) || (csym[count + 1] == NULL))) {
668- break;
669- }
718+ if (csym && ((csym[count] == NULL) || (csym[count + 1] == NULL)))
719+ break;
670720
671- pos += 3;
672- pos -= (pos % 4);
721+ pos += 3;
722+ pos -= (pos % 4);
673723
674- while ((pos + 4) <= len) {
675- if (bfd_getb32 (buf + pos) == 0) {
676- break;
677- }
678- pos += 4;
679- }
724+ while ((pos + 4) <= len)
725+ {
726+ if (bfd_getb32 (buf + pos) == 0)
727+ break;
728+ pos += 4;
729+ }
680730
681- if ((pos + 4) > len) {
682- break;
683- }
684-
685- ret = bfd_pef_parse_traceback_table (abfd, sec, buf, len, pos + 4, &function, 0);
686- if (ret < 0) {
687- /* skip over 0x0L to advance to next possible traceback table */
688- pos += 4;
689- continue;
690- }
691-
692- BFD_ASSERT (function.name != NULL);
731+ if ((pos + 4) > len)
732+ break;
693733
694- /* Don't bother to compute the name if we are just
695- counting symbols */
734+ ret = bfd_pef_parse_traceback_table (abfd, sec, buf, len, pos + 4,
735+ &function, 0);
736+ if (ret < 0)
737+ {
738+ /* skip over 0x0L to advance to next possible traceback table */
739+ pos += 4;
740+ continue;
741+ }
696742
697- if (csym)
698- {
699- tbnamelen = strlen (tbprefix) + strlen (function.name);
700- name = bfd_alloc (abfd, tbnamelen + 1);
701- if (name == NULL) {
702- bfd_release (abfd, (PTR) function.name);
703- function.name = NULL;
704- break;
743+ BFD_ASSERT (function.name != NULL);
744+
745+ /* Don't bother to compute the name if we are just
746+ counting symbols */
747+
748+ if (csym)
749+ {
750+ tbnamelen = strlen (tbprefix) + strlen (function.name);
751+ name = bfd_alloc (abfd, tbnamelen + 1);
752+ if (name == NULL)
753+ {
754+ bfd_release (abfd, (PTR) function.name);
755+ function.name = NULL;
756+ break;
757+ }
758+ snprintf (name, tbnamelen + 1, "%s%s", tbprefix, function.name);
759+ traceback.name = name;
760+ traceback.value = pos;
761+ traceback.the_bfd = abfd;
762+ traceback.section = sec;
763+ traceback.flags = 0;
764+ traceback.udata.i = ret;
765+
766+ *(csym[count]) = function;
767+ *(csym[count + 1]) = traceback;
705768 }
706- snprintf (name, tbnamelen + 1, "%s%s", tbprefix, function.name);
707- traceback.name = name;
708- traceback.value = pos;
709- traceback.the_bfd = abfd;
710- traceback.section = sec;
711- traceback.flags = 0;
712- traceback.udata.i = ret;
713-
714- *(csym[count]) = function;
715- *(csym[count + 1]) = traceback;
716- }
717769
718- pos += ret;
719- count += 2;
720- }
770+ pos += ret;
771+ count += 2;
772+ }
721773
722774 *nsym = count;
723775 return 0;
@@ -731,21 +783,27 @@ static int bfd_pef_parse_function_stub (abfd, buf, len, offset)
731783 {
732784 BFD_ASSERT (len == 24);
733785
734- if ((bfd_getb32 (buf) & 0xffff0000) != 0x81820000) { return -1; }
735- if (bfd_getb32 (buf + 4) != 0x90410014) { return -1; }
736- if (bfd_getb32 (buf + 8) != 0x800c0000) { return -1; }
737- if (bfd_getb32 (buf + 12) != 0x804c0004) { return -1; }
738- if (bfd_getb32 (buf + 16) != 0x7c0903a6) { return -1; }
739- if (bfd_getb32 (buf + 20) != 0x4e800420) { return -1; }
740-
741- if (offset != NULL) {
786+ if ((bfd_getb32 (buf) & 0xffff0000) != 0x81820000)
787+ return -1;
788+ if (bfd_getb32 (buf + 4) != 0x90410014)
789+ return -1;
790+ if (bfd_getb32 (buf + 8) != 0x800c0000)
791+ return -1;
792+ if (bfd_getb32 (buf + 12) != 0x804c0004)
793+ return -1;
794+ if (bfd_getb32 (buf + 16) != 0x7c0903a6)
795+ return -1;
796+ if (bfd_getb32 (buf + 20) != 0x4e800420)
797+ return -1;
798+
799+ if (offset != NULL)
742800 *offset = (bfd_getb32 (buf) & 0x0000ffff) / 4;
743- }
744801
745802 return 0;
746803 }
747804
748-static int bfd_pef_parse_function_stubs (abfd, codesec, codebuf, codelen, loaderbuf, loaderlen, nsym, csym)
805+static int bfd_pef_parse_function_stubs (abfd, codesec, codebuf, codelen,
806+ loaderbuf, loaderlen, nsym, csym)
749807 bfd *abfd;
750808 asection *codesec;
751809 unsigned char *codebuf;
@@ -767,113 +825,142 @@ static int bfd_pef_parse_function_stubs (abfd, codesec, codebuf, codelen, loader
767825 unsigned long i;
768826 int ret;
769827
770- if (loaderlen < 56) { goto error; }
828+ if (loaderlen < 56)
829+ goto error;
771830
772831 ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
773- if (ret < 0) { goto error; }
832+ if (ret < 0)
833+ goto error;
774834
775835 libraries = (bfd_pef_imported_library *) bfd_malloc
776836 (header.imported_library_count * sizeof (bfd_pef_imported_library));
777837 imports = (bfd_pef_imported_symbol *) bfd_malloc
778838 (header.total_imported_symbol_count * sizeof (bfd_pef_imported_symbol));
779-
780- if (loaderlen < (56 + (header.imported_library_count * 24))) { goto error; }
781- for (i = 0; i < header.imported_library_count; i++) {
782- ret = bfd_pef_parse_imported_library
783- (abfd, loaderbuf + 56 + (i * 24), 24, &libraries[i]);
784- if (ret < 0) { goto error; }
785- }
786-
787- if (loaderlen < (56 + (header.imported_library_count * 24) + (header.total_imported_symbol_count * 4)))
788- { goto error; }
789- for (i = 0; i < header.total_imported_symbol_count; i++) {
790- ret = bfd_pef_parse_imported_symbol
791- (abfd, loaderbuf + 56 + (header.imported_library_count * 24) + (i * 4), 4, &imports[i]);
792- if (ret < 0) { goto error; }
793- }
794-
839+
840+ if (loaderlen < (56 + (header.imported_library_count * 24)))
841+ goto error;
842+ for (i = 0; i < header.imported_library_count; i++)
843+ {
844+ ret = bfd_pef_parse_imported_library
845+ (abfd, loaderbuf + 56 + (i * 24), 24, &libraries[i]);
846+ if (ret < 0)
847+ goto error;
848+ }
849+
850+ if (loaderlen < (56 + (header.imported_library_count * 24)
851+ + (header.total_imported_symbol_count * 4)))
852+ goto error;
853+ for (i = 0; i < header.total_imported_symbol_count; i++)
854+ {
855+ ret = (bfd_pef_parse_imported_symbol
856+ (abfd,
857+ loaderbuf + 56 + (header.imported_library_count * 24) + (i * 4),
858+ 4, &imports[i]));
859+ if (ret < 0)
860+ goto error;
861+ }
862+
795863 codepos = 0;
796864
797- for (;;) {
865+ for (;;)
866+ {
867+ asymbol sym;
868+ const char *symname;
869+ char *name;
870+ unsigned long index;
871+ int ret;
798872
799- asymbol sym;
800- const char *symname;
801- char *name;
802- unsigned long index;
803- int ret;
873+ if (csym && (csym[count] == NULL))
874+ break;
804875
805- if (csym && (csym[count] == NULL)) { break; }
876+ codepos += 3;
877+ codepos -= (codepos % 4);
806878
807- codepos += 3;
808- codepos -= (codepos % 4);
879+ while ((codepos + 4) <= codelen)
880+ {
881+ if ((bfd_getb32 (codebuf + codepos) & 0xffff0000) == 0x81820000)
882+ break;
883+ codepos += 4;
884+ }
809885
810- while ((codepos + 4) <= codelen) {
811- if ((bfd_getb32 (codebuf + codepos) & 0xffff0000) == 0x81820000) {
886+ if ((codepos + 4) > codelen)
812887 break;
813- }
814- codepos += 4;
815- }
816888
817- if ((codepos + 4) > codelen) {
818- break;
819- }
889+ ret = bfd_pef_parse_function_stub (abfd, codebuf + codepos, 24, &index);
890+ if (ret < 0)
891+ {
892+ codepos += 24;
893+ continue;
894+ }
820895
821- ret = bfd_pef_parse_function_stub (abfd, codebuf + codepos, 24, &index);
822- if (ret < 0) { codepos += 24; continue; }
823-
824- if (index >= header.total_imported_symbol_count) { codepos += 24; continue; }
896+ if (index >= header.total_imported_symbol_count)
897+ {
898+ codepos += 24;
899+ continue;
900+ }
825901
826- {
827- size_t max, namelen;
828- const char *s;
829-
830- if (loaderlen < (header.loader_strings_offset + imports[index].name)) { goto error; }
831-
832- max = loaderlen - (header.loader_strings_offset + imports[index].name);
833- symname = loaderbuf + header.loader_strings_offset + imports[index].name;
834- namelen = 0;
835- for (s = symname; s < (symname + max); s++) {
836- if (*s == '\0') { break; }
837- if (! isprint (*s)) { goto error; }
838- namelen++;
839- }
840- if (*s != '\0') { goto error; }
902+ {
903+ size_t max, namelen;
904+ const char *s;
905+
906+ if (loaderlen < (header.loader_strings_offset + imports[index].name))
907+ goto error;
908+
909+ max = loaderlen - (header.loader_strings_offset + imports[index].name);
910+ symname = loaderbuf + header.loader_strings_offset + imports[index].name;
911+ namelen = 0;
912+ for (s = symname; s < (symname + max); s++)
913+ {
914+ if (*s == '\0')
915+ break;
916+ if (! isprint (*s))
917+ goto error;
918+ namelen++;
919+ }
920+ if (*s != '\0')
921+ goto error;
922+
923+ name = bfd_alloc (abfd, strlen (sprefix) + namelen + 1);
924+ if (name == NULL)
925+ break;
841926
842- name = bfd_alloc (abfd, strlen (sprefix) + namelen + 1);
843- if (name == NULL) { break; }
927+ snprintf (name, strlen (sprefix) + namelen + 1, "%s%s",
928+ sprefix, symname);
929+ sym.name = name;
930+ }
844931
845- snprintf (name, strlen (sprefix) + namelen + 1, "%s%s", sprefix, symname);
846- sym.name = name;
847- }
932+ sym.value = codepos;
933+ sym.the_bfd = abfd;
934+ sym.section = codesec;
935+ sym.flags = 0;
936+ sym.udata.i = 0;
848937
849- sym.value = codepos;
850- sym.the_bfd = abfd;
851- sym.section = codesec;
852- sym.flags = 0;
853- sym.udata.i = 0;
938+ codepos += 24;
854939
855- codepos += 24;
940+ if (csym != NULL)
941+ *(csym[count]) = sym;
856942
857- if (csym != NULL) {
858- *(csym[count]) = sym;
943+ count++;
859944 }
860- count++;
861- }
862945
863946 goto end;
864947
865948 end:
866- if (libraries != NULL) { free (libraries); }
867- if (imports != NULL) { free (imports); }
949+ if (libraries != NULL)
950+ free (libraries);
951+ if (imports != NULL)
952+ free (imports);
868953 *nsym = count;
869954 return 0;
870955
871956 error:
872- if (libraries != NULL) { free (libraries); }
873- if (imports != NULL) { free (imports); }
957+ if (libraries != NULL)
958+ free (libraries);
959+ if (imports != NULL)
960+ free (imports);
874961 *nsym = count;
875962 return -1;
876-}
963+}
877964
878965 static long bfd_pef_parse_symbols (abfd, csym)
879966 bfd *abfd;
@@ -894,8 +981,10 @@ static long bfd_pef_parse_symbols (abfd, csym)
894981 {
895982 codelen = bfd_section_size (abfd, codesec);
896983 codebuf = (unsigned char *) bfd_malloc (codelen);
897- if (bfd_seek (abfd, codesec->filepos, SEEK_SET) < 0) { goto end; }
898- if (bfd_bread ((PTR) codebuf, codelen, abfd) != codelen) { goto end; }
984+ if (bfd_seek (abfd, codesec->filepos, SEEK_SET) < 0)
985+ goto end;
986+ if (bfd_bread ((PTR) codebuf, codelen, abfd) != codelen)
987+ goto end;
899988 }
900989
901990 loadersec = bfd_get_section_by_name (abfd, "loader");
@@ -903,15 +992,18 @@ static long bfd_pef_parse_symbols (abfd, csym)
903992 {
904993 loaderlen = bfd_section_size (abfd, loadersec);
905994 loaderbuf = (unsigned char *) bfd_malloc (loaderlen);
906- if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) { goto end; }
907- if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen) { goto end; }
995+ if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
996+ goto end;
997+ if (bfd_bread ((PTR) loaderbuf, loaderlen, abfd) != loaderlen)
998+ goto end;
908999 }
909-
1000+
9101001 count = 0;
9111002 if (codesec != NULL)
9121003 {
9131004 unsigned long ncount = 0;
914- bfd_pef_parse_traceback_tables (abfd, codesec, codebuf, codelen, &ncount, csym);
1005+ bfd_pef_parse_traceback_tables (abfd, codesec, codebuf, codelen,
1006+ &ncount, csym);
9151007 count += ncount;
9161008 }
9171009
@@ -923,18 +1015,17 @@ static long bfd_pef_parse_symbols (abfd, csym)
9231015 (csym != NULL) ? (csym + count) : NULL);
9241016 count += ncount;
9251017 }
926-
927- if (csym != NULL) {
1018+
1019+ if (csym != NULL)
9281020 csym[count] = NULL;
929- }
930-
1021+
9311022 end:
932- if (codebuf != NULL)
1023+ if (codebuf != NULL)
9331024 free (codebuf);
9341025
935- if (loaderbuf != NULL)
936- free (loaderbuf);
937-
1026+ if (loaderbuf != NULL)
1027+ free (loaderbuf);
1028+
9381029 return count;
9391030 }
9401031
@@ -950,7 +1041,8 @@ bfd_pef_get_symtab_upper_bound (abfd)
9501041 bfd *abfd;
9511042 {
9521043 long nsyms = bfd_pef_count_symbols (abfd);
953- if (nsyms < 0) { return nsyms; }
1044+ if (nsyms < 0)
1045+ return nsyms;
9541046 return ((nsyms + 1) * sizeof (asymbol *));
9551047 }
9561048
@@ -964,20 +1056,21 @@ bfd_pef_get_symtab (abfd, alocation)
9641056 long ret;
9651057
9661058 long nsyms = bfd_pef_count_symbols (abfd);
967- if (nsyms < 0) { return nsyms; }
1059+ if (nsyms < 0)
1060+ return nsyms;
9681061
9691062 syms = bfd_alloc (abfd, nsyms * sizeof (asymbol));
970- if (syms == NULL) { return -1; }
1063+ if (syms == NULL)
1064+ return -1;
9711065
972- for (i = 0; i < nsyms; i++) {
1066+ for (i = 0; i < nsyms; i++)
9731067 alocation[i] = &syms[i];
974- }
1068+
9751069 alocation[nsyms] = NULL;
9761070
9771071 ret = bfd_pef_parse_symbols (abfd, alocation);
978- if (ret != nsyms) {
1072+ if (ret != nsyms)
9791073 return 0;
980- }
9811074
9821075 return ret;
9831076 }
@@ -1056,7 +1149,7 @@ const bfd_target pef_vec =
10561149 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
10571150
10581151 NULL,
1059-
1152+
10601153 NULL
10611154 };
10621155
@@ -1077,7 +1170,8 @@ bfd_pef_xlib_read_header (abfd, header)
10771170
10781171 bfd_seek (abfd, 0, SEEK_SET);
10791172
1080- if (bfd_bread ((PTR) buf, 76, abfd) != 76) { return -1; }
1173+ if (bfd_bread ((PTR) buf, 76, abfd) != 76)
1174+ return -1;
10811175
10821176 header->tag1 = bfd_getb32 (buf);
10831177 header->tag2 = bfd_getb32 (buf + 4);
@@ -1110,18 +1204,15 @@ bfd_pef_xlib_scan (abfd, header)
11101204 {
11111205 bfd_pef_xlib_data_struct *mdata = NULL;
11121206
1113- if ((header->tag1 != BFD_PEF_XLIB_TAG1)
1114- || ((header->tag2 != BFD_PEF_VLIB_TAG2) && (header->tag2 != BFD_PEF_BLIB_TAG2))) {
1207+ mdata = ((bfd_pef_xlib_data_struct *)
1208+ bfd_alloc (abfd, sizeof (bfd_pef_xlib_data_struct)));
1209+ if (mdata == NULL)
11151210 return -1;
1116- }
11171211
1118- mdata = ((bfd_pef_xlib_data_struct *)
1119- bfd_alloc (abfd, sizeof (bfd_pef_xlib_data_struct)));
1120- if (mdata == NULL) { return -1; }
1121-
11221212 mdata->header = *header;
11231213
1124- abfd->flags = abfd->xvec->object_flags | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS));
1214+ abfd->flags = (abfd->xvec->object_flags
1215+ | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
11251216
11261217 abfd->tdata.pef_xlib_data = mdata;
11271218
@@ -1132,22 +1223,37 @@ static const bfd_target *
11321223 bfd_pef_xlib_object_p (abfd)
11331224 bfd *abfd;
11341225 {
1226+ struct bfd_preserve preserve;
11351227 bfd_pef_xlib_header header;
1136-
1137- abfd->tdata.pef_xlib_data = NULL;
11381228
1139- if (bfd_pef_xlib_read_header (abfd, &header) != 0) {
1140- abfd->tdata.pef_xlib_data = NULL;
1141- bfd_set_error (bfd_error_wrong_format);
1142- return NULL;
1143- }
1229+ if (bfd_pef_xlib_read_header (abfd, &header) != 0)
1230+ {
1231+ bfd_set_error (bfd_error_wrong_format);
1232+ return NULL;
1233+ }
11441234
1145- if (bfd_pef_xlib_scan (abfd, &header) != 0) {
1146- abfd->tdata.pef_xlib_data = NULL;
1147- bfd_set_error (bfd_error_wrong_format);
1148- return NULL;
1149- }
1235+ if ((header.tag1 != BFD_PEF_XLIB_TAG1)
1236+ || ((header.tag2 != BFD_PEF_VLIB_TAG2)
1237+ && (header.tag2 != BFD_PEF_BLIB_TAG2)))
1238+ {
1239+ bfd_set_error (bfd_error_wrong_format);
1240+ return NULL;
1241+ }
11501242
1243+ if (! bfd_preserve_save (abfd, &preserve))
1244+ {
1245+ bfd_set_error (bfd_error_wrong_format);
1246+ return NULL;
1247+ }
1248+
1249+ if (bfd_pef_xlib_scan (abfd, &header) != 0)
1250+ {
1251+ bfd_preserve_restore (abfd, &preserve);
1252+ bfd_set_error (bfd_error_wrong_format);
1253+ return NULL;
1254+ }
1255+
1256+ bfd_preserve_finish (abfd, &preserve);
11511257 return abfd->xvec;
11521258 }
11531259
@@ -1201,7 +1307,6 @@ const bfd_target pef_xlib_vec =
12011307 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
12021308
12031309 NULL,
1204-
1310+
12051311 NULL
12061312 };
1207-
--- a/bfd/pef.h
+++ b/bfd/pef.h
@@ -15,7 +15,7 @@
1515 GNU General Public License for more details.
1616
1717 You should have received a copy of the GNU General Public License
18- along with this program; if not, write to the Free Software
18+ along with this program; if not, write to the Free Software
1919 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2020
2121 #include "bfd.h"
@@ -43,7 +43,7 @@ struct bfd_pef_loader_header
4343 long main_section;
4444 unsigned long main_offset;
4545 long init_section;
46- unsigned long init_offset;
46+ unsigned long init_offset;
4747 long term_section;
4848 unsigned long term_offset;
4949 unsigned long imported_library_count;
@@ -183,4 +183,4 @@ int bfd_pef_parse_imported_library PARAMS ((bfd *, unsigned char *, size_t, bfd
183183 int bfd_pef_parse_imported_symbol PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *));
184184 int bfd_pef_scan_section PARAMS ((bfd *, bfd_pef_section *));
185185 int bfd_pef_scan_start_address PARAMS ((bfd *));
186-int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *));
186+int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *, bfd_pef_data_struct *));
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -997,11 +997,8 @@ static const bfd_target * const _bfd_target_vector[] = {
997997 &pc532machaout_vec,
998998 &pc532netbsd_vec,
999999 &pdp11_aout_vec,
1000-#if 0
1001- /* bfd_pef_object_p and bfd_pef_xlib_object_p are broken. */
10021000 &pef_vec,
10031001 &pef_xlib_vec,
1004-#endif
10051002 #if 0
10061003 /* This has the same magic number as RS/6000. */
10071004 &pmac_xcoff_vec,
@@ -1031,10 +1028,7 @@ static const bfd_target * const _bfd_target_vector[] = {
10311028 &sparclynx_coff_vec,
10321029 &sparcnetbsd_vec,
10331030 &sunos_big_vec,
1034-#if 0
1035- /* bfd_sym_object_p is broken. */
10361031 &sym_vec,
1037-#endif
10381032 &tic30_aout_vec,
10391033 &tic30_coff_vec,
10401034 &tic54x_coff0_beh_vec,
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -15,7 +15,7 @@
1515 GNU General Public License for more details.
1616
1717 You should have received a copy of the GNU General Public License
18- along with this program; if not, write to the Free Software
18+ along with this program; if not, write to the Free Software
1919 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2020
2121 #include "xsym.h"
@@ -116,7 +116,7 @@ bfd_sym_valid (abfd)
116116 if (abfd == NULL || abfd->xvec == NULL)
117117 return 0;
118118
119- return (abfd->xvec == &sym_vec);
119+ return abfd->xvec == &sym_vec;
120120 }
121121
122122 unsigned char *
@@ -128,19 +128,19 @@ bfd_sym_read_name_table (abfd, dshb)
128128 long ret;
129129 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
130130 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
131-
131+
132132 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
133133 if (rstr == NULL)
134134 return rstr;
135135
136136 bfd_seek (abfd, table_offset, SEEK_SET);
137137 ret = bfd_bread (rstr, table_size, abfd);
138- if ((ret < 0) || ((unsigned long) ret != table_size))
138+ if (ret < 0 || (unsigned long) ret != table_size)
139139 {
140140 bfd_release (abfd, rstr);
141141 return NULL;
142142 }
143-
143+
144144 return rstr;
145145 }
146146
@@ -163,11 +163,11 @@ bfd_sym_parse_disk_table_v32 (buf, len, table)
163163 bfd_sym_table_info *table;
164164 {
165165 BFD_ASSERT (len == 8);
166-
166+
167167 table->dti_first_page = bfd_getb16 (buf);
168168 table->dti_page_count = bfd_getb16 (buf + 2);
169169 table->dti_object_count = bfd_getb32 (buf + 4);
170-}
170+}
171171
172172 void
173173 bfd_sym_parse_header_v32 (buf, len, header)
@@ -176,13 +176,13 @@ bfd_sym_parse_header_v32 (buf, len, header)
176176 bfd_sym_header_block *header;
177177 {
178178 BFD_ASSERT (len == 154);
179-
179+
180180 memcpy (header->dshb_id, buf, 32);
181181 header->dshb_page_size = bfd_getb16 (buf + 32);
182182 header->dshb_hash_page = bfd_getb16 (buf + 34);
183183 header->dshb_root_mte = bfd_getb16 (buf + 36);
184184 header->dshb_mod_date = bfd_getb32 (buf + 38);
185-
185+
186186 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
187187 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
188188 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
@@ -196,7 +196,7 @@ bfd_sym_parse_header_v32 (buf, len, header)
196196 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
197197 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
198198 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
199-
199+
200200 memcpy (&header->dshb_file_creator, buf + 146, 4);
201201 memcpy (&header->dshb_file_type, buf + 150, 4);
202202 }
@@ -208,13 +208,13 @@ bfd_sym_read_header_v32 (abfd, header)
208208 {
209209 unsigned char buf[154];
210210 long ret;
211-
211+
212212 ret = bfd_bread (buf, 154, abfd);
213213 if (ret != 154)
214214 return -1;
215-
215+
216216 bfd_sym_parse_header_v32 (buf, 154, header);
217-
217+
218218 return 0;
219219 }
220220
@@ -253,11 +253,11 @@ bfd_sym_read_version (abfd, version)
253253 {
254254 unsigned char version_string[32];
255255 long ret;
256-
256+
257257 ret = bfd_bread (version_string, sizeof (version_string), abfd);
258258 if (ret != sizeof (version_string))
259259 return -1;
260-
260+
261261 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
262262 *version = BFD_SYM_VERSION_3_1;
263263 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
@@ -270,7 +270,7 @@ bfd_sym_read_version (abfd, version)
270270 *version = BFD_SYM_VERSION_3_5;
271271 else
272272 return -1;
273-
273+
274274 return 0;
275275 }
276276
@@ -302,10 +302,10 @@ bfd_sym_display_header (f, dshb)
302302
303303 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
304304 dshb->dshb_file_creator, dshb->dshb_file_type);
305-
305+
306306 fprintf (f, "Table Name First Page Page Count Object Count\n");
307307 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
308-
308+
309309 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
310310 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
311311 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
@@ -319,7 +319,7 @@ bfd_sym_display_header (f, dshb)
319319 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
320320 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
321321 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
322-
322+
323323 fprintf (f, "\n");
324324 }
325325
@@ -371,7 +371,7 @@ bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
371371 bfd_sym_file_references_table_entry *entry;
372372 {
373373 unsigned int type;
374-
374+
375375 BFD_ASSERT (len == 10);
376376
377377 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
@@ -407,7 +407,7 @@ bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
407407
408408 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
409409 type = bfd_getb16 (buf);
410-
410+
411411 switch (type)
412412 {
413413 case BFD_SYM_END_OF_LIST_3_2:
@@ -428,7 +428,7 @@ bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
428428 bfd_sym_contained_variables_table_entry *entry;
429429 {
430430 unsigned int type;
431-
431+
432432 BFD_ASSERT (len == 26);
433433
434434 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
@@ -483,7 +483,7 @@ bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
483483
484484 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
485485 type = bfd_getb16 (buf);
486-
486+
487487 switch (type)
488488 {
489489 case BFD_SYM_END_OF_LIST_3_2:
@@ -515,7 +515,7 @@ bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
515515
516516 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
517517 type = bfd_getb16 (buf);
518-
518+
519519 switch (type)
520520 {
521521 case BFD_SYM_END_OF_LIST_3_2:
@@ -544,7 +544,7 @@ bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
544544 bfd_sym_type_table_entry *entry;
545545 {
546546 BFD_ASSERT (len == 4);
547-
547+
548548 *entry = bfd_getb32 (buf);
549549 }
550550
@@ -554,12 +554,14 @@ bfd_sym_fetch_resources_table_entry (abfd, entry, index)
554554 bfd_sym_resources_table_entry *entry;
555555 unsigned long index;
556556 {
557- void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *) = NULL;
557+ void (*parser) PARAMS ((unsigned char *, size_t,
558+ bfd_sym_resources_table_entry *));
558559 unsigned long offset;
559560 unsigned long entry_size;
560561 unsigned char buf[18];
561562 bfd_sym_data_struct *sdata = NULL;
562563
564+ parser = NULL;
563565 BFD_ASSERT (bfd_sym_valid (abfd));
564566 sdata = abfd->tdata.sym_data;
565567
@@ -588,14 +590,14 @@ bfd_sym_fetch_resources_table_entry (abfd, entry, index)
588590 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
589591 sdata->header.dshb_page_size,
590592 entry_size, index);
591-
593+
592594 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
593595 return -1;
594596 if (bfd_bread (buf, entry_size, abfd) != entry_size)
595597 return -1;
596598
597599 (*parser) (buf, entry_size, entry);
598-
600+
599601 return 0;
600602 }
601603
@@ -605,12 +607,14 @@ bfd_sym_fetch_modules_table_entry (abfd, entry, index)
605607 bfd_sym_modules_table_entry *entry;
606608 unsigned long index;
607609 {
608- void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *) = NULL;
610+ void (*parser) PARAMS ((unsigned char *, size_t,
611+ bfd_sym_modules_table_entry *));
609612 unsigned long offset;
610613 unsigned long entry_size;
611614 unsigned char buf[46];
612615 bfd_sym_data_struct *sdata = NULL;
613616
617+ parser = NULL;
614618 BFD_ASSERT (bfd_sym_valid (abfd));
615619 sdata = abfd->tdata.sym_data;
616620
@@ -639,14 +643,14 @@ bfd_sym_fetch_modules_table_entry (abfd, entry, index)
639643 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
640644 sdata->header.dshb_page_size,
641645 entry_size, index);
642-
646+
643647 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
644648 return -1;
645649 if (bfd_bread (buf, entry_size, abfd) != entry_size)
646650 return -1;
647651
648652 (*parser) (buf, entry_size, entry);
649-
653+
650654 return 0;
651655 }
652656
@@ -656,12 +660,14 @@ bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
656660 bfd_sym_file_references_table_entry *entry;
657661 unsigned long index;
658662 {
659- void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *) = NULL;
663+ void (*parser) PARAMS ((unsigned char *, size_t,
664+ bfd_sym_file_references_table_entry *));
660665 unsigned long offset;
661666 unsigned long entry_size = 0;
662667 unsigned char buf[8];
663668 bfd_sym_data_struct *sdata = NULL;
664669
670+ parser = NULL;
665671 BFD_ASSERT (bfd_sym_valid (abfd));
666672 sdata = abfd->tdata.sym_data;
667673
@@ -689,14 +695,14 @@ bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
689695 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
690696 sdata->header.dshb_page_size,
691697 entry_size, index);
692-
698+
693699 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
694700 return -1;
695701 if (bfd_bread (buf, entry_size, abfd) != entry_size)
696702 return -1;
697703
698704 (*parser) (buf, entry_size, entry);
699-
705+
700706 return 0;
701707 }
702708
@@ -706,12 +712,14 @@ bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
706712 bfd_sym_contained_modules_table_entry *entry;
707713 unsigned long index;
708714 {
709- void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *) = NULL;
715+ void (*parser) PARAMS ((unsigned char *, size_t,
716+ bfd_sym_contained_modules_table_entry *));
710717 unsigned long offset;
711718 unsigned long entry_size = 0;
712719 unsigned char buf[6];
713720 bfd_sym_data_struct *sdata = NULL;
714721
722+ parser = NULL;
715723 BFD_ASSERT (bfd_sym_valid (abfd));
716724 sdata = abfd->tdata.sym_data;
717725
@@ -739,14 +747,14 @@ bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
739747 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
740748 sdata->header.dshb_page_size,
741749 entry_size, index);
742-
750+
743751 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
744752 return -1;
745753 if (bfd_bread (buf, entry_size, abfd) != entry_size)
746754 return -1;
747755
748756 (*parser) (buf, entry_size, entry);
749-
757+
750758 return 0;
751759 }
752760
@@ -756,12 +764,14 @@ bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
756764 bfd_sym_contained_variables_table_entry *entry;
757765 unsigned long index;
758766 {
759- void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *) = NULL;
767+ void (*parser) PARAMS ((unsigned char *, size_t,
768+ bfd_sym_contained_variables_table_entry *));
760769 unsigned long offset;
761770 unsigned long entry_size = 0;
762771 unsigned char buf[26];
763772 bfd_sym_data_struct *sdata = NULL;
764773
774+ parser = NULL;
765775 BFD_ASSERT (bfd_sym_valid (abfd));
766776 sdata = abfd->tdata.sym_data;
767777
@@ -789,14 +799,14 @@ bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
789799 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
790800 sdata->header.dshb_page_size,
791801 entry_size, index);
792-
802+
793803 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
794804 return -1;
795805 if (bfd_bread (buf, entry_size, abfd) != entry_size)
796806 return -1;
797807
798808 (*parser) (buf, entry_size, entry);
799-
809+
800810 return 0;
801811 }
802812
@@ -806,12 +816,14 @@ bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
806816 bfd_sym_contained_statements_table_entry *entry;
807817 unsigned long index;
808818 {
809- void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *) = NULL;
819+ void (*parser) PARAMS ((unsigned char *, size_t,
820+ bfd_sym_contained_statements_table_entry *));
810821 unsigned long offset;
811822 unsigned long entry_size = 0;
812823 unsigned char buf[8];
813824 bfd_sym_data_struct *sdata = NULL;
814825
826+ parser = NULL;
815827 BFD_ASSERT (bfd_sym_valid (abfd));
816828 sdata = abfd->tdata.sym_data;
817829
@@ -839,14 +851,14 @@ bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
839851 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
840852 sdata->header.dshb_page_size,
841853 entry_size, index);
842-
854+
843855 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
844856 return -1;
845857 if (bfd_bread (buf, entry_size, abfd) != entry_size)
846858 return -1;
847859
848860 (*parser) (buf, entry_size, entry);
849-
861+
850862 return 0;
851863 }
852864
@@ -856,12 +868,14 @@ bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
856868 bfd_sym_contained_labels_table_entry *entry;
857869 unsigned long index;
858870 {
859- void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *) = NULL;
871+ void (*parser) PARAMS ((unsigned char *, size_t,
872+ bfd_sym_contained_labels_table_entry *));
860873 unsigned long offset;
861874 unsigned long entry_size = 0;
862875 unsigned char buf[12];
863876 bfd_sym_data_struct *sdata = NULL;
864877
878+ parser = NULL;
865879 BFD_ASSERT (bfd_sym_valid (abfd));
866880 sdata = abfd->tdata.sym_data;
867881
@@ -889,14 +903,14 @@ bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
889903 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
890904 sdata->header.dshb_page_size,
891905 entry_size, index);
892-
906+
893907 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
894908 return -1;
895909 if (bfd_bread (buf, entry_size, abfd) != entry_size)
896910 return -1;
897911
898912 (*parser) (buf, entry_size, entry);
899-
913+
900914 return 0;
901915 }
902916
@@ -906,12 +920,14 @@ bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
906920 bfd_sym_contained_types_table_entry *entry;
907921 unsigned long index;
908922 {
909- void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *) = NULL;
923+ void (*parser) PARAMS ((unsigned char *, size_t,
924+ bfd_sym_contained_types_table_entry *));
910925 unsigned long offset;
911926 unsigned long entry_size = 0;
912927 unsigned char buf[0];
913928 bfd_sym_data_struct *sdata = NULL;
914929
930+ parser = NULL;
915931 BFD_ASSERT (bfd_sym_valid (abfd));
916932 sdata = abfd->tdata.sym_data;
917933
@@ -939,14 +955,14 @@ bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
939955 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
940956 sdata->header.dshb_page_size,
941957 entry_size, index);
942-
958+
943959 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
944960 return -1;
945961 if (bfd_bread (buf, entry_size, abfd) != entry_size)
946962 return -1;
947963
948964 (*parser) (buf, entry_size, entry);
949-
965+
950966 return 0;
951967 }
952968
@@ -956,12 +972,14 @@ bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
956972 bfd_sym_file_references_index_table_entry *entry;
957973 unsigned long index;
958974 {
959- void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *) = NULL;
975+ void (*parser) PARAMS ((unsigned char *, size_t,
976+ bfd_sym_file_references_index_table_entry *));
960977 unsigned long offset;
961978 unsigned long entry_size = 0;
962979 unsigned char buf[0];
963980 bfd_sym_data_struct *sdata = NULL;
964981
982+ parser = NULL;
965983 BFD_ASSERT (bfd_sym_valid (abfd));
966984 sdata = abfd->tdata.sym_data;
967985
@@ -989,14 +1007,14 @@ bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
9891007 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
9901008 sdata->header.dshb_page_size,
9911009 entry_size, index);
992-
1010+
9931011 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
9941012 return -1;
9951013 if (bfd_bread (buf, entry_size, abfd) != entry_size)
9961014 return -1;
9971015
9981016 (*parser) (buf, entry_size, entry);
999-
1017+
10001018 return 0;
10011019 }
10021020
@@ -1006,12 +1024,14 @@ bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
10061024 bfd_sym_constant_pool_entry *entry;
10071025 unsigned long index;
10081026 {
1009- void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *) = NULL;
1027+ void (*parser) PARAMS ((unsigned char *, size_t,
1028+ bfd_sym_constant_pool_entry *));
10101029 unsigned long offset;
10111030 unsigned long entry_size = 0;
10121031 unsigned char buf[0];
10131032 bfd_sym_data_struct *sdata = NULL;
10141033
1034+ parser = NULL;
10151035 BFD_ASSERT (bfd_sym_valid (abfd));
10161036 sdata = abfd->tdata.sym_data;
10171037
@@ -1039,14 +1059,14 @@ bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
10391059 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
10401060 sdata->header.dshb_page_size,
10411061 entry_size, index);
1042-
1062+
10431063 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
10441064 return -1;
10451065 if (bfd_bread (buf, entry_size, abfd) != entry_size)
10461066 return -1;
10471067
10481068 (*parser) (buf, entry_size, entry);
1049-
1069+
10501070 return 0;
10511071 }
10521072
@@ -1056,12 +1076,14 @@ bfd_sym_fetch_type_table_entry (abfd, entry, index)
10561076 bfd_sym_type_table_entry *entry;
10571077 unsigned long index;
10581078 {
1059- void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *) = NULL;
1079+ void (*parser) PARAMS ((unsigned char *, size_t,
1080+ bfd_sym_type_table_entry *));
10601081 unsigned long offset;
10611082 unsigned long entry_size = 0;
10621083 unsigned char buf[4];
10631084 bfd_sym_data_struct *sdata = NULL;
10641085
1086+ parser = NULL;
10651087 BFD_ASSERT (bfd_sym_valid (abfd));
10661088 sdata = abfd->tdata.sym_data;
10671089
@@ -1086,14 +1108,14 @@ bfd_sym_fetch_type_table_entry (abfd, entry, index)
10861108 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
10871109 sdata->header.dshb_page_size,
10881110 entry_size, index);
1089-
1111+
10901112 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
10911113 return -1;
10921114 if (bfd_bread (buf, entry_size, abfd) != entry_size)
10931115 return -1;
10941116
10951117 (*parser) (buf, entry_size, entry);
1096-
1118+
10971119 return 0;
10981120 }
10991121
@@ -1118,11 +1140,11 @@ bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
11181140 if (bfd_bread (buf, 4, abfd) != 4)
11191141 return -1;
11201142 entry->nte_index = bfd_getb32 (buf);
1121-
1143+
11221144 if (bfd_bread (buf, 2, abfd) != 2)
11231145 return -1;
11241146 entry->physical_size = bfd_getb16 (buf);
1125-
1147+
11261148 if (entry->physical_size & 0x8000)
11271149 {
11281150 if (bfd_bread (buf, 4, abfd) != 4)
@@ -1180,12 +1202,13 @@ bfd_sym_symbol_name (abfd, index)
11801202
11811203 if (index == 0)
11821204 return "";
1183-
1205+
11841206 index *= 2;
1185- if ((index / sdata->header.dshb_page_size) > sdata->header.dshb_nte.dti_page_count)
1207+ if ((index / sdata->header.dshb_page_size)
1208+ > sdata->header.dshb_nte.dti_page_count)
11861209 return "\009[INVALID]";
1187-
1188- return ((const unsigned char *) sdata->name_table + index);
1210+
1211+ return (const unsigned char *) sdata->name_table + index;
11891212 }
11901213
11911214 const unsigned char *
@@ -1194,7 +1217,7 @@ bfd_sym_module_name (abfd, index)
11941217 unsigned long index;
11951218 {
11961219 bfd_sym_modules_table_entry entry;
1197-
1220+
11981221 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
11991222 return "\011[INVALID]";
12001223
@@ -1272,7 +1295,8 @@ bfd_sym_print_file_reference (abfd, f, entry)
12721295 bfd_sym_file_references_table_entry frtentry;
12731296 int ret;
12741297
1275- ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry, entry->fref_frte_index);
1298+ ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1299+ entry->fref_frte_index);
12761300 fprintf (f, "FILE ");
12771301
12781302 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
@@ -1296,7 +1320,7 @@ bfd_sym_print_resources_table_entry (abfd, f, entry)
12961320 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
12971321 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
12981322 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1299-}
1323+}
13001324
13011325 void
13021326 bfd_sym_print_modules_table_entry (abfd, f, entry)
@@ -1308,27 +1332,28 @@ bfd_sym_print_modules_table_entry (abfd, f, entry)
13081332 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
13091333 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
13101334 entry->mte_nte_index);
1311-
1312- fprintf (f, "\n ");
1335+
1336+ fprintf (f, "\n ");
13131337
13141338 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1315- fprintf (f, " range %lu -- %lu", entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1339+ fprintf (f, " range %lu -- %lu",
1340+ entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
13161341
1317- fprintf (f, "\n ");
1342+ fprintf (f, "\n ");
13181343
13191344 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
13201345 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1321-
1346+
13221347 fprintf (f, ", RTE %lu, offset %lu, size %lu",
13231348 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
13241349
1325- fprintf (f, "\n ");
1350+ fprintf (f, "\n ");
13261351
1327- fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1352+ fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
13281353 entry->mte_cmte_index, entry->mte_cvte_index,
13291354 entry->mte_clte_index, entry->mte_ctte_index,
13301355 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1331-
1356+
13321357 if (entry->mte_parent != 0)
13331358 fprintf (f, ", parent %lu", entry->mte_parent);
13341359 else
@@ -1364,7 +1389,7 @@ bfd_sym_print_file_references_table_entry (abfd, f, entry)
13641389 switch (entry->generic.type)
13651390 {
13661391 case BFD_SYM_FILE_NAME_INDEX:
1367- fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1392+ fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
13681393 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
13691394 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
13701395 entry->filename.nte_index);
@@ -1421,19 +1446,19 @@ bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
14211446 fprintf (f, "END");
14221447 return;
14231448 }
1424-
1449+
14251450 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
14261451 {
14271452 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
14281453 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
14291454 return;
14301455 }
1431-
1456+
14321457 fprintf (f, "\"%.*s\" (NTE %lu)",
14331458 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
14341459 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
14351460 entry->entry.nte_index);
1436-
1461+
14371462 fprintf (f, ", TTE %lu", entry->entry.tte_index);
14381463 fprintf (f, ", offset %lu", entry->entry.file_delta);
14391464 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
@@ -1454,7 +1479,7 @@ bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
14541479 }
14551480 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
14561481 fprintf (f, ", bigla %lu, biglakind %u",
1457- entry->entry.address.biglastruct.big_la,
1482+ entry->entry.address.biglastruct.big_la,
14581483 entry->entry.address.biglastruct.big_la_kind);
14591484
14601485 else
@@ -1472,7 +1497,7 @@ bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
14721497 fprintf (f, "END");
14731498 return;
14741499 }
1475-
1500+
14761501 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
14771502 {
14781503 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
@@ -1661,9 +1686,9 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
16611686
16621687 if (offsetptr != NULL)
16631688 *offsetptr = offset;
1664- return;
1689+ return;
16651690 }
1666-
1691+
16671692 type = buf[offset];
16681693 offset++;
16691694
@@ -1688,7 +1713,7 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
16881713 long value;
16891714 bfd_sym_type_information_table_entry tinfo;
16901715
1691- bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1716+ bfd_sym_fetch_long (buf, len, offset, &offset, &value);
16921717 if (value <= 0)
16931718 fprintf (f, "[INVALID]");
16941719 else
@@ -1696,7 +1721,7 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
16961721 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
16971722 fprintf (f, "[INVALID]");
16981723 else
1699- fprintf (f, "\"%.*s\"",
1724+ fprintf (f, "\"%.*s\"",
17001725 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
17011726 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
17021727 }
@@ -1719,7 +1744,7 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
17191744 fprintf (f, " (%lu)", value);
17201745 break;
17211746 }
1722-
1747+
17231748 case 5:
17241749 {
17251750 unsigned long lower, upper, nelem;
@@ -1727,9 +1752,9 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
17271752
17281753 fprintf (f, "enumeration (0x%x) of ", type);
17291754 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1730- bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1731- bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1732- bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1755+ bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1756+ bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1757+ bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
17331758 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
17341759
17351760 for (i = 0; i < nelem; i++)
@@ -1757,15 +1782,15 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
17571782 fprintf (f, "record (0x%x) of ", type);
17581783 else
17591784 fprintf (f, "union (0x%x) of ", type);
1760-
1761- bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1762- fprintf (f, "%lu elements: ", nrec);
1785+
1786+ bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1787+ fprintf (f, "%lu elements: ", nrec);
17631788
17641789 for (i = 0; i < nrec; i++)
17651790 {
1766- bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1791+ bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
17671792 fprintf (f, "\n ");
1768- fprintf (f, "offset %lu: ", eloff);
1793+ fprintf (f, "offset %lu: ", eloff);
17691794 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
17701795 }
17711796 break;
@@ -1785,11 +1810,11 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
17851810 long value;
17861811
17871812 fprintf (f, "named type (0x%x) ", type);
1788- bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1813+ bfd_sym_fetch_long (buf, len, offset, &offset, &value);
17891814 if (value <= 0)
17901815 fprintf (f, "[INVALID]");
17911816 else
1792- fprintf (f, "\"%.*s\"",
1817+ fprintf (f, "\"%.*s\"",
17931818 bfd_sym_symbol_name (abfd, value)[0],
17941819 &bfd_sym_symbol_name (abfd, value)[1]);
17951820
@@ -1802,7 +1827,7 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
18021827 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
18031828 break;
18041829 }
1805-
1830+
18061831 if (type == (0x40 | 0x6))
18071832 {
18081833 /* Vector. */
@@ -1810,14 +1835,14 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
18101835 long l;
18111836 long i;
18121837
1813- bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1814- bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1815- bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1838+ bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1839+ bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1840+ bfd_sym_fetch_long (buf, len, offset, &offset, &m);
18161841 /* fprintf (f, "\n "); */
18171842 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
18181843 for (i = 0; i < m; i++)
18191844 {
1820- bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1845+ bfd_sym_fetch_long (buf, len, offset, &offset, &l);
18211846 if (i != 0)
18221847 fprintf (f, " ");
18231848 fprintf (f, "%ld", l);
@@ -1828,8 +1853,8 @@ bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
18281853 /* Other packed type. */
18291854 long msb, lsb;
18301855
1831- bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1832- bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1856+ bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1857+ bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
18331858 /* fprintf (f, "\n "); */
18341859 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
18351860 }
@@ -1856,7 +1881,7 @@ bfd_sym_print_type_information_table_entry (abfd, f, entry)
18561881 entry->nte_index,
18571882 entry->physical_size, entry->offset, entry->logical_size);
18581883
1859- fprintf (f, "\n ");
1884+ fprintf (f, "\n ");
18601885
18611886 buf = alloca (entry->physical_size);
18621887 if (buf == NULL)
@@ -1885,7 +1910,7 @@ bfd_sym_print_type_information_table_entry (abfd, f, entry)
18851910 }
18861911
18871912 fprintf (f, "]");
1888- fprintf (f, "\n ");
1913+ fprintf (f, "\n ");
18891914
18901915 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
18911916
@@ -1923,16 +1948,16 @@ bfd_sym_display_name_table_entry (abfd, f, entry)
19231948 BFD_ASSERT (bfd_sym_valid (abfd));
19241949 sdata = abfd->tdata.sym_data;
19251950 index = (entry - sdata->name_table) / 2;
1926-
1927- if ((sdata->version >= BFD_SYM_VERSION_3_4) && (entry[0] == 255) && (entry[1] == 0))
1951+
1952+ if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
19281953 {
1929- unsigned short length = bfd_getb16 (entry + 2);
1954+ unsigned short length = bfd_getb16 (entry + 2);
19301955 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
19311956 offset = 2 + length + 1;
19321957 }
19331958 else
19341959 {
1935- if (! ((entry[0] == 0) || ((entry[0] == 1) && (entry[1] == '\0'))))
1960+ if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
19361961 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
19371962
19381963 if (sdata->version >= BFD_SYM_VERSION_3_4)
@@ -1959,9 +1984,9 @@ bfd_sym_display_name_table (abfd, f)
19591984 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
19601985 name_table = sdata->name_table;
19611986 name_table_end = name_table + name_table_len;
1962-
1987+
19631988 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1964-
1989+
19651990 cur = name_table;
19661991 for (;;)
19671992 {
@@ -1985,7 +2010,7 @@ bfd_sym_display_resources_table (abfd, f)
19852010
19862011 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
19872012 sdata->header.dshb_rte.dti_object_count);
1988-
2013+
19892014 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
19902015 {
19912016 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
@@ -2061,7 +2086,7 @@ bfd_sym_display_contained_modules_table (abfd, f)
20612086 FILE *f;
20622087 {
20632088 unsigned long i;
2064- bfd_sym_contained_modules_table_entry entry;
2089+ bfd_sym_contained_modules_table_entry entry;
20652090 bfd_sym_data_struct *sdata = NULL;
20662091
20672092 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2069,7 +2094,7 @@ bfd_sym_display_contained_modules_table (abfd, f)
20692094
20702095 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
20712096 sdata->header.dshb_cmte.dti_object_count);
2072-
2097+
20732098 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
20742099 {
20752100 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
@@ -2097,7 +2122,7 @@ bfd_sym_display_contained_variables_table (abfd, f)
20972122
20982123 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
20992124 sdata->header.dshb_cvte.dti_object_count);
2100-
2125+
21012126 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
21022127 {
21032128 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
@@ -2119,7 +2144,7 @@ bfd_sym_display_contained_statements_table (abfd, f)
21192144 FILE *f;
21202145 {
21212146 unsigned long i;
2122- bfd_sym_contained_statements_table_entry entry;
2147+ bfd_sym_contained_statements_table_entry entry;
21232148 bfd_sym_data_struct *sdata = NULL;
21242149
21252150 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2127,7 +2152,7 @@ bfd_sym_display_contained_statements_table (abfd, f)
21272152
21282153 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
21292154 sdata->header.dshb_csnte.dti_object_count);
2130-
2155+
21312156 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
21322157 {
21332158 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
@@ -2155,7 +2180,7 @@ bfd_sym_display_contained_labels_table (abfd, f)
21552180
21562181 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
21572182 sdata->header.dshb_clte.dti_object_count);
2158-
2183+
21592184 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
21602185 {
21612186 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
@@ -2175,7 +2200,7 @@ bfd_sym_display_contained_types_table (abfd, f)
21752200 FILE *f;
21762201 {
21772202 unsigned long i;
2178- bfd_sym_contained_types_table_entry entry;
2203+ bfd_sym_contained_types_table_entry entry;
21792204 bfd_sym_data_struct *sdata = NULL;
21802205
21812206 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2183,7 +2208,7 @@ bfd_sym_display_contained_types_table (abfd, f)
21832208
21842209 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
21852210 sdata->header.dshb_ctte.dti_object_count);
2186-
2211+
21872212 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
21882213 {
21892214 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
@@ -2203,7 +2228,7 @@ bfd_sym_display_file_references_index_table (abfd, f)
22032228 FILE *f;
22042229 {
22052230 unsigned long i;
2206- bfd_sym_file_references_index_table_entry entry;
2231+ bfd_sym_file_references_index_table_entry entry;
22072232 bfd_sym_data_struct *sdata = NULL;
22082233
22092234 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2211,7 +2236,7 @@ bfd_sym_display_file_references_index_table (abfd, f)
22112236
22122237 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
22132238 sdata->header.dshb_fite.dti_object_count);
2214-
2239+
22152240 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
22162241 {
22172242 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
@@ -2231,7 +2256,7 @@ bfd_sym_display_constant_pool (abfd, f)
22312256 FILE *f;
22322257 {
22332258 unsigned long i;
2234- bfd_sym_constant_pool_entry entry;
2259+ bfd_sym_constant_pool_entry entry;
22352260 bfd_sym_data_struct *sdata = NULL;
22362261
22372262 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2239,7 +2264,7 @@ bfd_sym_display_constant_pool (abfd, f)
22392264
22402265 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
22412266 sdata->header.dshb_const.dti_object_count);
2242-
2267+
22432268 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
22442269 {
22452270 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
@@ -2260,7 +2285,7 @@ bfd_sym_display_type_information_table (abfd, f)
22602285 {
22612286 unsigned long i;
22622287 bfd_sym_type_table_entry index;
2263- bfd_sym_type_information_table_entry entry;
2288+ bfd_sym_type_information_table_entry entry;
22642289 bfd_sym_data_struct *sdata = NULL;
22652290
22662291 BFD_ASSERT (bfd_sym_valid (abfd));
@@ -2274,7 +2299,7 @@ bfd_sym_display_type_information_table (abfd, f)
22742299 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
22752300 return;
22762301 }
2277-
2302+
22782303 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
22792304 {
22802305 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
@@ -2293,65 +2318,75 @@ bfd_sym_display_type_information_table (abfd, f)
22932318 }
22942319 }
22952320
2296-const bfd_target *
2297-bfd_sym_object_p (abfd)
2321+int
2322+bfd_sym_scan (abfd, version, mdata)
22982323 bfd *abfd;
2324+ bfd_sym_version version;
2325+ bfd_sym_data_struct *mdata;
22992326 {
2300- bfd_sym_data_struct *mdata = NULL;
23012327 asection *bfdsec;
23022328 const char *name = "symbols";
2303-
2304- mdata = ((bfd_sym_data_struct *)
2305- bfd_alloc (abfd, sizeof (bfd_sym_data_struct)));
2306- if (mdata == NULL)
2307- return NULL;
2308-
2309- abfd->tdata.sym_data = mdata;
23102329
23112330 mdata->name_table = 0;
23122331 mdata->sbfd = abfd;
2332+ mdata->version = version;
23132333
23142334 bfd_seek (abfd, 0, SEEK_SET);
2315- if (bfd_sym_read_version (abfd, &mdata->version) != 0)
2316- {
2317- abfd->tdata.sym_data = NULL;
2318- bfd_set_error (bfd_error_wrong_format);
2319- return NULL;
2320- }
2321-
2322- bfd_seek (abfd, 0, SEEK_SET);
23232335 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2324- {
2325- abfd->tdata.sym_data = NULL;
2326- bfd_set_error (bfd_error_wrong_format);
2327- return NULL;
2328- }
2336+ return -1;
23292337
23302338 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
23312339 if (mdata->name_table == NULL)
2332- {
2333- abfd->tdata.sym_data = NULL;
2334- bfd_set_error (bfd_error_wrong_format);
2335- return NULL;
2336- }
2340+ return -1;
23372341
23382342 bfdsec = bfd_make_section_anyway (abfd, name);
23392343 if (bfdsec == NULL)
2340- {
2341- abfd->tdata.sym_data = NULL;
2342- bfd_set_error (bfd_error_wrong_format);
2343- return NULL;
2344- }
2345-
2344+ return -1;
2345+
23462346 bfdsec->vma = 0;
23472347 bfdsec->lma = 0;
23482348 bfdsec->_raw_size = 0;
23492349 bfdsec->filepos = 0;
23502350 bfdsec->alignment_power = 0;
2351-
2351+
23522352 bfdsec->flags = SEC_HAS_CONTENTS;
23532353
2354+ abfd->tdata.sym_data = mdata;
2355+
2356+ return 0;
2357+}
2358+
2359+const bfd_target *
2360+bfd_sym_object_p (abfd)
2361+ bfd *abfd;
2362+{
2363+ struct bfd_preserve preserve;
2364+ bfd_sym_version version = -1;
2365+
2366+ preserve.marker = NULL;
2367+ bfd_seek (abfd, 0, SEEK_SET);
2368+ if (bfd_sym_read_version (abfd, &version) != 0)
2369+ goto wrong;
2370+
2371+ preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2372+ if (preserve.marker == NULL
2373+ || ! bfd_preserve_save (abfd, &preserve))
2374+ goto fail;
2375+
2376+ if (bfd_sym_scan (abfd, version,
2377+ (bfd_sym_data_struct *) preserve.marker) != 0)
2378+ goto wrong;
2379+
2380+ bfd_preserve_finish (abfd, &preserve);
23542381 return abfd->xvec;
2382+
2383+ wrong:
2384+ bfd_set_error (bfd_error_wrong_format);
2385+
2386+ fail:
2387+ if (preserve.marker != NULL)
2388+ bfd_preserve_restore (abfd, &preserve);
2389+ return NULL;
23552390 }
23562391
23572392 asymbol *
@@ -2443,7 +2478,7 @@ const bfd_target sym_vec =
24432478 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
24442479
24452480 NULL,
2446-
2481+
24472482 NULL
24482483 };
24492484
--- a/bfd/xsym.h
+++ b/bfd/xsym.h
@@ -15,7 +15,7 @@
1515 GNU General Public License for more details.
1616
1717 You should have received a copy of the GNU General Public License
18- along with this program; if not, write to the Free Software
18+ along with this program; if not, write to the Free Software
1919 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2020
2121 #include "bfd.h"
@@ -103,7 +103,7 @@ typedef struct bfd_sym_file_reference bfd_sym_file_reference;
103103 /* NAME TABLE (NTE). */
104104
105105 /* RESOURCES TABLE (RTE)
106-
106+
107107 All code and data is *defined* to reside in a resource. Even A5
108108 relative data is defined to reside in a dummy resource of ResType
109109 'gbld'. Code always resides in a resource. Because a code/data
@@ -128,7 +128,7 @@ struct bfd_sym_resources_table_entry
128128 typedef struct bfd_sym_resources_table_entry bfd_sym_resources_table_entry;
129129
130130 /* MODULES TABLE (MTE)
131-
131+
132132 Modules table entries are ordered by their appearance in a resource.
133133 (Note that having a single module copied into two resources is not
134134 possible). Modules map back to their resource via an index into the
@@ -159,19 +159,19 @@ struct bfd_sym_modules_table_entry
159159 unsigned long mte_ctte_index; /* Types contained in this. */
160160 unsigned long mte_csnte_idx_1; /* CSNTE index of mte_snbr_first. */
161161 unsigned long mte_csnte_idx_2; /* CSNTE index of mte_snbr_last. */
162-};
162+};
163163 typedef struct bfd_sym_modules_table_entry bfd_sym_modules_table_entry;
164164
165165 /* FILE REFERENCES TABLE (FRTE)
166-
166+
167167 The FILE REFERENCES TABLE maps from source file to module & offset.
168168 The table is ordered by increasing file offset. Each new offset
169169 references a module.
170-
170+
171171 FRT = FILE_SOURCE_START
172172 FILE_SOURCE_INCREMENT*
173173 END_OF_LIST.
174-
174+
175175 *** THIS MECHANISM IS VERY SLOW FOR FILE+STATEMENT_NUMBER TO
176176 *** MODULE/CODE ADDRESS OPERATIONS. ANOTHER MECHANISM IS
177177 *** REQUIRED!! */
@@ -193,7 +193,7 @@ union bfd_sym_file_references_table_entry
193193 unsigned long mod_date;
194194 }
195195 filename;
196-
196+
197197 struct
198198 {
199199 /* < FILE_NAME_INDEX. */
@@ -209,7 +209,7 @@ typedef union bfd_sym_file_references_table_entry bfd_sym_file_references_table_
209209 Contained Modules are lists of indices into the modules table. The
210210 lists are terminated by an END_OF_LIST index. All entries are of the
211211 same size, hence mapping an index into a CMTE list is simple.
212-
212+
213213 CMT = MTE_INDEX* END_OF_LIST. */
214214
215215 union bfd_sym_contained_modules_table_entry
@@ -220,7 +220,7 @@ union bfd_sym_contained_modules_table_entry
220220 unsigned long type;
221221 }
222222 generic;
223-
223+
224224 struct
225225 {
226226 unsigned long mte_index; /* Index into the Modules Table. */
@@ -231,7 +231,7 @@ union bfd_sym_contained_modules_table_entry
231231 typedef union bfd_sym_contained_modules_table_entry bfd_sym_contained_modules_table_entry;
232232
233233 /* CONTAINED VARIABLES TABLE (CVTE)
234-
234+
235235 Contained Variables map into the module table, file table, name table, and type
236236 table. Contained Variables are a contiguous list of source file change record,
237237 giving the name of and offset into the source file corresponding to all variables
@@ -240,25 +240,25 @@ typedef union bfd_sym_contained_modules_table_entry bfd_sym_contained_modules_ta
240240 table giving the type of the variable, an increment added to the source file
241241 offset giving the start of the implementation of the variable, and a storage
242242 class address, giving information on variable's runtime address.
243-
243+
244244 CVT = SOURCE_FILE_CHANGE SYMBOL_INFO* END_OF_LIST.
245245 SYMBOL_INFO = SYMBOL_DEFINITION | SOURCE_FILE_CHANGE .
246-
246+
247247 All entries are of the same size, making the fetching of data simple. The
248248 variable entries in the list are in ALPHABETICAL ORDER to simplify the display of
249249 available variables for several of the debugger's windows. */
250250
251251 /* 'la_size' determines the variant used below:
252-
252+
253253 == BFD_SYM_CVTE_SCA
254254 Traditional STORAGE_CLASS_ADDRESS;
255-
255+
256256 <= BFD_SYM_CVTE_LA_MAX_SIZE
257257 That many logical address bytes ("in-situ");
258-
258+
259259 == BFD_SYM_CVTE_BIG_LA
260260 Logical address bytes in constant pool, at offset 'big_la'. */
261-
261+
262262 #define BFD_SYM_CVTE_SCA 0 /* Indicate SCA variant of CVTE. */
263263 #define BFD_SYM_CVTE_LA_MAX_SIZE 13 /* Max# of logical address bytes in a CVTE. */
264264 #define BFD_SYM_CVTE_BIG_LA 127 /* Indicates LA redirection to constant pool. */
@@ -322,7 +322,7 @@ union bfd_sym_contained_variables_table_entry
322322 typedef union bfd_sym_contained_variables_table_entry bfd_sym_contained_variables_table_entry;
323323
324324 /* CONTAINED STATEMENTS TABLE (CSNTE)
325-
325+
326326 Contained Statements table. This table is similar to the Contained
327327 Variables table except that instead of VARIABLE_DEFINITION entries, this
328328 module contains STATEMENT_NUMBER_DEFINITION entries. A statement number
@@ -332,7 +332,7 @@ typedef union bfd_sym_contained_variables_table_entry bfd_sym_contained_variable
332332 All entries are of the same size, making the fetching of data simple. The
333333 entries in the table are in order of increasing statement number within the
334334 source file.
335-
335+
336336 The Contained Statements table is indexed from two places. An MTE contains
337337 an index to the first statement number within the module. An FRTE contains
338338 an index to the first statement in the table (Possibly. This is slow.) Or
@@ -367,7 +367,7 @@ union bfd_sym_contained_statements_table_entry
367367 typedef union bfd_sym_contained_statements_table_entry bfd_sym_contained_statements_table_entry;
368368
369369 /* CONTAINED LABELS TABLE (CLTE)
370-
370+
371371 Contained Labels table names those labels local to the module. It is similar
372372 to the Contained Statements table. */
373373
@@ -402,7 +402,7 @@ union bfd_sym_contained_labels_table_entry
402402 typedef union bfd_sym_contained_labels_table_entry bfd_sym_contained_labels_table_entry;
403403
404404 /* CONTAINED TYPES TABLE (CTTE)
405-
405+
406406 Contained Types define the named types that are in the module. It is used to
407407 map name indices into type indices. The type entries in the table are in
408408 alphabetical order by type name. */
@@ -427,7 +427,7 @@ union bfd_sym_contained_types_table_entry
427427 struct
428428 {
429429 /* < SOURCE_FILE_CHANGE. */
430- unsigned long tte_index;
430+ unsigned long tte_index;
431431 unsigned long nte_index;
432432 unsigned long file_delta; /* From last file definition. */
433433 }
@@ -451,7 +451,7 @@ struct bfd_sym_type_information_table_entry
451451 typedef struct bfd_sym_type_information_table_entry bfd_sym_type_information_table_entry;
452452
453453 /* FILE REFERENCES INDEX TABLE (FITE)
454-
454+
455455 The FRTE INDEX TABLE indexes into the FILE REFERENCE TABLE above. The FRTE
456456 at that index is the FILE_SOURCE_START for a series of files. The FRTEs are
457457 indexed from 1. The list is terminated with an END_OF_LIST. */
@@ -463,7 +463,7 @@ union bfd_sym_file_references_index_table_entry
463463 unsigned long type;
464464 }
465465 generic;
466-
466+
467467 struct
468468 {
469469 unsigned long frte_index; /* Index into the FRTE table. */
@@ -474,15 +474,15 @@ union bfd_sym_file_references_index_table_entry
474474 typedef union bfd_sym_file_references_index_table_entry bfd_sym_file_references_index_table_entry;
475475
476476 /* CONSTANT POOL (CONST)
477-
477+
478478 The CONSTANT_POOL consists of entries that start on word boundaries. The entries
479479 are referenced by byte index into the constant pool, not by record number.
480-
480+
481481 Each entry takes the form:
482-
482+
483483 <16-bit size>
484484 <that many bytes of stuff>
485-
485+
486486 Entries do not cross page boundaries. */
487487
488488 typedef short bfd_sym_constant_pool_entry;
@@ -493,7 +493,7 @@ typedef short bfd_sym_constant_pool_entry;
493493 allocations. For the purposes of paging, the * file is considered
494494 to be an array of dshb_page_size blocks, with block 0 (and *
495495 possibly more) devoted to the DISK_SYMBOL_HEADER_BLOCK.
496-
496+
497497 The dti_object_count field means that the allowed indices for that
498498 type of object are 0 .. dti_object_count. An index of 0, although
499499 allowed, is never done. However, an 0th entry is created in the
@@ -510,7 +510,7 @@ struct bfd_sym_table_info
510510 };
511511 typedef struct bfd_sym_table_info bfd_sym_table_info;
512512
513-struct bfd_sym_header_block
513+struct bfd_sym_header_block
514514 {
515515 unsigned char dshb_id[32]; /* Version information. */
516516 unsigned short dshb_page_size; /* Size of the pages/blocks. */
@@ -683,6 +683,8 @@ extern void bfd_sym_display_constant_pool
683683 PARAMS ((bfd *, FILE *));
684684 extern void bfd_sym_display_type_information_table
685685 PARAMS ((bfd *, FILE *));
686+extern int bfd_sym_scan
687+ PARAMS ((bfd *, bfd_sym_version, bfd_sym_data_struct *));
686688 extern const bfd_target * bfd_sym_object_p
687689 PARAMS ((bfd *));
688690 extern asymbol * bfd_sym_make_empty_symbol