summaryrefslogtreecommitdiffstats
path: root/contrib/gdb/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gdb/bfd')
-rw-r--r--contrib/gdb/bfd/COPYING339
-rw-r--r--contrib/gdb/bfd/Makefile.in1090
-rw-r--r--contrib/gdb/bfd/PORTING83
-rw-r--r--contrib/gdb/bfd/TODO25
-rw-r--r--contrib/gdb/bfd/VERSION1
-rw-r--r--contrib/gdb/bfd/aclocal.m443
-rw-r--r--contrib/gdb/bfd/aout-target.h607
-rw-r--r--contrib/gdb/bfd/aout32.c23
-rw-r--r--contrib/gdb/bfd/aoutx.h5525
-rw-r--r--contrib/gdb/bfd/archive.c2094
-rw-r--r--contrib/gdb/bfd/archures.c720
-rw-r--r--contrib/gdb/bfd/bfd-in.h668
-rw-r--r--contrib/gdb/bfd/bfd.c1144
-rw-r--r--contrib/gdb/bfd/binary.c348
-rw-r--r--contrib/gdb/bfd/cache.c347
-rw-r--r--contrib/gdb/bfd/coff-i386.c493
-rw-r--r--contrib/gdb/bfd/coffcode.h3612
-rw-r--r--contrib/gdb/bfd/coffgen.c2121
-rw-r--r--contrib/gdb/bfd/coffswap.h807
-rw-r--r--contrib/gdb/bfd/config.bfd491
-rw-r--r--contrib/gdb/bfd/config.in67
-rw-r--r--contrib/gdb/bfd/configure2439
-rw-r--r--contrib/gdb/bfd/configure.host128
-rw-r--r--contrib/gdb/bfd/configure.in577
-rw-r--r--contrib/gdb/bfd/corefile.c106
-rw-r--r--contrib/gdb/bfd/cpu-i386.c38
-rw-r--r--contrib/gdb/bfd/dep-in.sed24
-rw-r--r--contrib/gdb/bfd/doc/ChangeLog268
-rw-r--r--contrib/gdb/bfd/doc/Makefile.in311
-rw-r--r--contrib/gdb/bfd/doc/bfd.texinfo348
-rw-r--r--contrib/gdb/bfd/doc/bfdsumm.texi148
-rw-r--r--contrib/gdb/bfd/doc/chew.c1551
-rw-r--r--contrib/gdb/bfd/doc/doc.str158
-rw-r--r--contrib/gdb/bfd/doc/proto.str135
-rw-r--r--contrib/gdb/bfd/ecoff.c4740
-rw-r--r--contrib/gdb/bfd/ecofflink.c2452
-rw-r--r--contrib/gdb/bfd/elf-bfd.h858
-rw-r--r--contrib/gdb/bfd/elf.c3318
-rw-r--r--contrib/gdb/bfd/format.c319
-rw-r--r--contrib/gdb/bfd/freebsd.h125
-rw-r--r--contrib/gdb/bfd/genlink.h106
-rw-r--r--contrib/gdb/bfd/hash.c734
-rw-r--r--contrib/gdb/bfd/hosts/alphalinux.h6
-rw-r--r--contrib/gdb/bfd/hosts/decstation.h17
-rw-r--r--contrib/gdb/bfd/hosts/delta68.h18
-rw-r--r--contrib/gdb/bfd/hosts/dpx2.h8
-rw-r--r--contrib/gdb/bfd/hosts/hp300bsd.h13
-rw-r--r--contrib/gdb/bfd/hosts/i386bsd.h25
-rw-r--r--contrib/gdb/bfd/hosts/i386linux.h8
-rw-r--r--contrib/gdb/bfd/hosts/i386mach3.h25
-rw-r--r--contrib/gdb/bfd/hosts/i386sco.h19
-rw-r--r--contrib/gdb/bfd/hosts/i860mach3.h27
-rw-r--r--contrib/gdb/bfd/hosts/m68kaux.h16
-rw-r--r--contrib/gdb/bfd/hosts/m68klinux.h6
-rw-r--r--contrib/gdb/bfd/hosts/m88kmach3.h11
-rw-r--r--contrib/gdb/bfd/hosts/mipsbsd.h12
-rw-r--r--contrib/gdb/bfd/hosts/mipsmach3.h10
-rw-r--r--contrib/gdb/bfd/hosts/news-mips.h12
-rw-r--r--contrib/gdb/bfd/hosts/news.h9
-rw-r--r--contrib/gdb/bfd/hosts/pc532mach.h24
-rw-r--r--contrib/gdb/bfd/hosts/riscos.h10
-rw-r--r--contrib/gdb/bfd/hosts/symmetry.h20
-rw-r--r--contrib/gdb/bfd/hosts/tahoe.h12
-rw-r--r--contrib/gdb/bfd/hosts/vaxbsd.h19
-rw-r--r--contrib/gdb/bfd/hosts/vaxult.h8
-rw-r--r--contrib/gdb/bfd/hosts/vaxult2.h8
-rw-r--r--contrib/gdb/bfd/i386aout.c68
-rw-r--r--contrib/gdb/bfd/i386bsd.c46
-rw-r--r--contrib/gdb/bfd/i386freebsd.c33
-rw-r--r--contrib/gdb/bfd/ihex.c1005
-rw-r--r--contrib/gdb/bfd/init.c50
-rw-r--r--contrib/gdb/bfd/libaout.h608
-rw-r--r--contrib/gdb/bfd/libbfd.c1197
-rw-r--r--contrib/gdb/bfd/libbfd.h735
-rw-r--r--contrib/gdb/bfd/libcoff.h823
-rw-r--r--contrib/gdb/bfd/libecoff.h352
-rw-r--r--contrib/gdb/bfd/linker.c2781
-rw-r--r--contrib/gdb/bfd/opncls.c604
-rw-r--r--contrib/gdb/bfd/reloc.c2391
-rw-r--r--contrib/gdb/bfd/section.c976
-rw-r--r--contrib/gdb/bfd/srec.c1324
-rw-r--r--contrib/gdb/bfd/stab-syms.c57
-rw-r--r--contrib/gdb/bfd/syms.c1084
-rw-r--r--contrib/gdb/bfd/sysdep.h114
-rw-r--r--contrib/gdb/bfd/targets.c886
-rw-r--r--contrib/gdb/bfd/tekhex.c1031
-rw-r--r--contrib/gdb/bfd/trad-core.c315
87 files changed, 0 insertions, 56354 deletions
diff --git a/contrib/gdb/bfd/COPYING b/contrib/gdb/bfd/COPYING
deleted file mode 100644
index a43ea21..0000000
--- a/contrib/gdb/bfd/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/gdb/bfd/Makefile.in b/contrib/gdb/bfd/Makefile.in
deleted file mode 100644
index e531cf8..0000000
--- a/contrib/gdb/bfd/Makefile.in
+++ /dev/null
@@ -1,1090 +0,0 @@
-# Makefile template for Configure for the BFD library.
-# Copyright (C) 1990, 91, 92, 93, 94, 95, 1996
-# Free Software Foundation, Inc.
-# Written by Cygnus Support.
-#
-# This file is part of BFD, the Binary File Descriptor library.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-
-prefix = @prefix@
-
-program_transform_name = @program_transform_name@
-exec_prefix = @exec_prefix@
-bindir = $(exec_prefix)/bin
-libdir = $(exec_prefix)/lib
-
-datadir = $(prefix)/lib
-mandir = $(prefix)/man
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = $(prefix)/info
-includedir = $(prefix)/include
-oldincludedir =
-docdir = doc
-
-SHELL = /bin/sh
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-AR = @AR@
-AR_FLAGS = rc
-CC = @CC@
-CFLAGS = @CFLAGS@
-MAKEINFO = makeinfo
-RANLIB = @RANLIB@
-
-ALLLIBS = @ALLLIBS@
-
-PICFLAG = @PICFLAG@
-SHLIB = @SHLIB@
-SHLIB_CC = @SHLIB_CC@
-SHLIB_CFLAGS = @SHLIB_CFLAGS@
-COMMON_SHLIB = @COMMON_SHLIB@
-SHLINK = @SHLINK@
-
-SONAME = lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`
-
-CC_FOR_BUILD = @CC_FOR_BUILD@
-
-INCDIR = $(srcdir)/../include
-CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
-DEP = mkdep
-
-SUBDIRS = doc
-
-TARGETLIB = libbfd.a
-
-# bfd.h goes here, for now
-BFD_H = bfd.h
-
-# Some of these files should be in BFD*_BACKENDS below, but some programs
-# won't link without them. So, in order for some of the minimal-bfd
-# hacks to work, they're also included here for now.
-# gdb: elf.o
-# objdump: elf.o
-#
-# Also, Jim Kingdon notes:
-# Writing S-records should be included in all (or at least most)
-# *-*-coff, *-*-aout, etc., configurations, because people will want to
-# be able to use objcopy to create S-records. (S-records are not useful
-# for the debugger, so if you are downloading things as S-records you
-# need two copies of the executable, one to download and one for the
-# debugger).
-BFD_LIBS = \
- archive.o archures.o bfd.o cache.o coffgen.o corefile.o \
- format.o init.o libbfd.o opncls.o reloc.o \
- section.o syms.o targets.o hash.o linker.o \
- elf.o srec.o binary.o tekhex.o ihex.o stab-syms.o
-
-BFD_LIBS_CFILES = \
- archive.c archures.c bfd.c cache.c coffgen.c corefile.c \
- format.c init.c libbfd.c opncls.c reloc.c \
- section.c syms.c targets.c hash.c linker.c \
- elf.c srec.c binary.c tekhex.c ihex.c stab-syms.c
-
-# This list is alphabetized to make it easier to keep in sync
-# with the decls and initializer in archures.c.
-ALL_MACHINES = \
- cpu-a29k.o \
- cpu-alpha.o \
- cpu-arm.o \
- cpu-h8300.o \
- cpu-h8500.o \
- cpu-hppa.o \
- cpu-i386.o \
- cpu-i860.o \
- cpu-i960.o \
- cpu-m68k.o \
- cpu-m88k.o \
- cpu-mips.o \
- cpu-ns32k.o \
- cpu-powerpc.o \
- cpu-rs6000.o \
- cpu-sh.o \
- cpu-sparc.o \
- cpu-vax.o \
- cpu-we32k.o \
- cpu-w65.o \
- cpu-z8k.o
-
-ALL_MACHINES_CFILES = \
- cpu-a29k.c \
- cpu-alpha.c \
- cpu-arm.c \
- cpu-h8300.c \
- cpu-h8500.c \
- cpu-hppa.c \
- cpu-i386.c \
- cpu-i860.c \
- cpu-i960.c \
- cpu-m68k.c \
- cpu-m88k.c \
- cpu-mips.c \
- cpu-ns32k.c \
- cpu-powerpc.c \
- cpu-rs6000.c \
- cpu-sh.c \
- cpu-sparc.c \
- cpu-vax.c \
- cpu-we32k.c \
- cpu-w65.c \
- cpu-z8k.c
-
-# The .o files needed by all of the 32 bit vectors that are configured into
-# target_vector in targets.c if configured with --enable-targets=all.
-BFD32_BACKENDS = \
- aout-adobe.o \
- aout-ns32k.o \
- aout0.o \
- aout32.o \
- bout.o \
- cf-i386lynx.o \
- cf-m68klynx.o \
- cf-sparclynx.o \
- coff-a29k.o \
- coff-apollo.o \
- coff-arm.o \
- coff-aux.o \
- coff-h8300.o \
- coff-h8500.o \
- coff-i386.o \
- coff-go32.o \
- coff-i860.o \
- coff-i960.o \
- coff-m68k.o \
- coff-m88k.o \
- coff-mips.o \
- coff-pmac.o \
- coff-rs6000.o \
- coff-sh.o \
- coff-sparc.o \
- coff-u68k.o \
- coff-we32k.o \
- coff-w65.o \
- coff-z8k.o \
- cofflink.o \
- ecoff.o \
- ecofflink.o \
- elf32-gen.o \
- elf32-hppa.o \
- elf32-i386.o \
- elf32-i860.o \
- elf32-m68k.o \
- elf32-m88k.o \
- elf32-mips.o \
- elf32-ppc.o \
- elf32-sparc.o \
- elf32.o \
- elflink.o \
- hp300hpux.o \
- som.o \
- i386aout.o \
- i386bsd.o \
- i386freebsd.o \
- i386linux.o \
- i386lynx.o \
- i386msdos.o \
- i386netbsd.o \
- i386mach3.o \
- i386os9k.o \
- ieee.o \
- m68klinux.o \
- m68klynx.o \
- m68knetbsd.o \
- m88kmach3.o \
- mipsbsd.o \
- newsos3.o \
- nlm.o \
- nlm32-i386.o \
- nlm32-sparc.o \
- nlm32-ppc.o \
- nlm32.o \
- ns32knetbsd.o \
- oasys.o \
- pc532-mach.o \
- pe-arm.o \
- pei-arm.o \
- pe-i386.o \
- pei-i386.o \
- pe-ppc.o \
- pei-ppc.o \
- reloc16.o \
- sparclynx.o \
- sparcnetbsd.o \
- sunos.o \
- tekhex.o \
- versados.o \
- xcofflink.o
-
-BFD32_BACKENDS_CFILES = \
- aout-adobe.c \
- aout-ns32k.c \
- aout0.c \
- aout32.c \
- bout.c \
- cf-i386lynx.c \
- cf-m68klynx.c \
- cf-sparclynx.c \
- coff-a29k.c \
- coff-apollo.c \
- coff-arm.c \
- coff-aux.c \
- coff-h8300.c \
- coff-h8500.c \
- coff-i386.c \
- coff-i860.c \
- coff-go32.c \
- coff-i960.c \
- coff-m68k.c \
- coff-m88k.c \
- coff-mips.c \
- coff-pmac.c \
- coff-rs6000.c \
- coff-sh.c \
- coff-sparc.c \
- coff-u68k.c \
- coff-we32k.c \
- coff-w65.c \
- coff-z8k.c \
- cofflink.c \
- ecoff.c \
- ecofflink.c \
- elf32-gen.c \
- elf32-hppa.c \
- elf32-i386.c \
- elf32-i860.c \
- elf32-m68k.c \
- elf32-m88k.c \
- elf32-mips.c \
- elf32-ppc.c \
- elf32-sparc.c \
- elf32.c \
- elflink.c \
- hp300hpux.c \
- som.c \
- i386aout.c \
- i386bsd.c \
- i386freebsd.c \
- i386linux.c \
- i386lynx.c \
- i386msdos.c \
- i386netbsd.c \
- i386mach3.c \
- i386os9k.c \
- ieee.c \
- m68klinux.c \
- m68klynx.c \
- m68knetbsd.c \
- m88kmach3.c \
- mipsbsd.c \
- newsos3.c \
- nlm.c \
- nlm32-i386.c \
- nlm32-sparc.c \
- nlm32-ppc.c \
- nlm32.c \
- ns32knetbsd.c \
- oasys.c \
- pc532-mach.c \
- pe-arm.c \
- pei-arm.c \
- pe-i386.c \
- pei-i386.c \
- pe-ppc.c \
- pei-ppc.c \
- reloc16.c \
- sparclynx.c \
- sparcnetbsd.c \
- sunos.c \
- tekhex.c \
- versados.c \
- xcofflink.c
-
-# The .o files needed by all of the 64 bit vectors that are configured into
-# target_vector in targets.c if configured with --enable-targets=all
-# and --enable-64-bit-bfd.
-BFD64_BACKENDS = \
- aout64.o \
- coff-alpha.o \
- demo64.o \
- elf64-gen.o \
- elf64-sparc.o \
- elf64.o \
- nlm32-alpha.o \
- nlm64.o
-
-BFD64_BACKENDS_CFILES = \
- aout64.c \
- coff-alpha.c \
- demo64.c \
- elf64-gen.c \
- elf64-sparc.c \
- elf64.c \
- nlm32-alpha.c \
- nlm64.c
-
-OPTIONAL_BACKENDS = \
- aix386-core.o \
- hpux-core.o \
- irix-core.o \
- lynx-core.o \
- osf-core.o \
- trad-core.o \
- cisco-core.o
-
-OPTIONAL_BACKENDS_CFILES = \
- aix386-core.c \
- hpux-core.c \
- irix-core.c \
- lynx-core.c \
- osf-core.c \
- trad-core.c \
- cisco-core.c
-
-# These are defined by configure.in:
-WORDSIZE = @wordsize@
-ALL_BACKENDS = @all_backends@
-BFD_BACKENDS = @bfd_backends@
-BFD_MACHINES = @bfd_machines@
-TDEFAULTS = @tdefaults@
-
-all:
-
-FLAGS_TO_PASS = \
- "prefix=$(prefix)" \
- "exec_prefix=$(exec_prefix)" \
- "against=$(against)" \
- "AR=$(AR)" \
- "AR_FLAGS=$(AR_FLAGS)" \
- "CC=$(CC)" \
- "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
- "CFLAGS=$(CFLAGS)" \
- "RANLIB=$(RANLIB)" \
- "MAKEINFO=$(MAKEINFO)" \
- "INSTALL=$(INSTALL)" \
- "INSTALL_DATA=$(INSTALL_DATA)" \
- "INSTALL_PROGRAM=$(INSTALL_PROGRAM)"
-
-ALL_CFLAGS=@HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) $(CFLAGS)
-.c.o:
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(ALL_CFLAGS) $< -o pic/$@; \
- else true; fi
- $(CC) -c $(ALL_CFLAGS) $<
-
-bfd_libs_here =
-all_machines_here =
-bfd32_backends_here =
-core_files_here =
-configs_not_included_in_all_targets_option_here =
-
-# C source files that correspond to .o's.
-CFILES = \
- $(BFD_LIBS_CFILES) \
- $(ALL_MACHINES_CFILES) \
- $(BFD32_BACKENDS_CFILES) \
- $(BFD64_BACKENDS_CFILES) \
- $(OPTIONAL_BACKENDS_CFILES) \
- i386dynix.c hp300bsd.c
-
-HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \
- coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \
- elfcode.h hppa_stubs.h libaout.h libbfd.h \
- libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h libnlm.h \
- liboasys.h nlm-target.h nlmcode.h som.h genlink.h netbsd.h
-
-all: Makefile $(ALLLIBS) @PICLIST@
- @$(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-.NOEXPORT:
-MAKEOVERRIDES=
-
-.PHONY: check installcheck
-check:
- @echo No testsuites exist for the BFD library. Nothing to check.
-
-installcheck:
- @echo No testsuites exist for the BFD library. Nothing to check.
-
-info dvi : force
- @$(MAKE) subdir_do DO=$@ "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-clean-info:
- @$(MAKE) subdir_do DO=clean-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-install-info: force
- @$(MAKE) subdir_do DO=install-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-
-diststuff: info
-
-# Various kinds of .o files to put in libbfd.a:
-# BFD_LIBS Generic routines, always needed.
-# BFD_BACKENDS Routines the configured targets need.
-# BFD_MACHINES Architecture-specific routines the configured targets need.
-# COREFILE Core file routines for a native configuration
-OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@
-
-stamp-ofiles: Makefile
- rm -f tofiles
- f=""; \
- for i in $(OFILES) ; do \
- case " $$f " in \
- *" $$i "*) ;; \
- *) f="$$f $$i" ;; \
- esac ; \
- done ; \
- echo $$f > tofiles
- $(srcdir)/../move-if-change tofiles ofiles
- touch stamp-ofiles
-
-ofiles: stamp-ofiles ; @true
-
-$(TARGETLIB): $(OFILES) ofiles
- rm -f $(TARGETLIB)
- @echo ofiles = `cat ofiles`
- $(AR) $(AR_FLAGS) $(TARGETLIB) `cat ofiles`
- $(RANLIB) $(TARGETLIB)
-
-stamp-piclist: ofiles
- rm -f tpiclist
- if [ -n "$(PICFLAG)" ]; then \
- sed -e 's,\([^ ][^ ]*\),pic/\1,g' ofiles > tpiclist; \
- else \
- cp ofiles tpiclist; \
- fi
- $(srcdir)/../move-if-change tpiclist piclist
- touch stamp-piclist
-
-piclist: stamp-piclist ; @true
-
-$(SHLIB): stamp-picdir $(OFILES) piclist
- rm -f $(SHLIB)
- $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) `cat piclist`
-
-# We make a link from libbfd.so to libbfd.so.VERSION for linking, and
-# also a link from libTARGET-bfd.so.VERSION for running.
-$(SHLINK): $(SHLIB)
- ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed -e '$(program_transform_name)'`; \
- if [ "$$ts" != "$(SHLIB)" ]; then \
- rm -f $$ts; \
- ln -sf $(SHLIB) $$ts; \
- else true; fi
- rm -f $(SHLINK)
- ln -sf $(SHLIB) $(SHLINK)
-
-# This target creates libTARGET-bfd.so.VERSION as a symlink to
-# libbfd.so.VERSION. It is used on SunOS, which does not have SONAME.
-stamp-tshlink: $(SHLIB)
- tf=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- if [ "$$tf" != "$(SHLIB)" ]; then \
- rm -f $$tf; \
- ln -sf $(SHLIB) $$tf; \
- else true; fi
- touch stamp-tshlink
-
-# When compiling archures.c and targets.c, supply the default target
-# info from configure.
-
-targets.o: targets.c Makefile
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/targets.c -o pic/targets.o; \
- else true; fi
- $(CC) -c $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/targets.c
-
-archures.o: archures.c Makefile
- if [ -n "$(PICFLAG)" ]; then \
- $(CC) -c $(PICFLAG) $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/archures.c -o pic/archures.o; \
- else true; fi
- $(CC) -c $(TDEFAULTS) $(ALL_CFLAGS) $(srcdir)/archures.c
-
-elf32-target.h : elfxx-target.h
- rm -f elf32-target.h
- sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new
- mv -f elf32-target.new elf32-target.h
-
-elf64-target.h : elfxx-target.h
- rm -f elf64-target.h
- sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
- mv -f elf64-target.new elf64-target.h
-
-subdir_do: force
- @for i in $(DODIRS); do \
- if [ -d ./$$i ] ; then \
- if (cd ./$$i; \
- $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
- else exit 1 ; fi ; \
- else true ; fi ; \
- done
-
-tags etags: TAGS
-
-TAGS: force
- etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c
-
-do_mostlyclean:
- rm -f *.o *~ core *.E *.p *.ip aout-params.h gen-aout config.log \
- pic/*.o
-do_clean: do_mostlyclean
- rm -f libbfd.a TAGS bfd.h stmp-bfd.h ofiles stamp-ofiles \
- elf32-target.h elf64-target.h $(SHLIB) $(SHLINK) \
- piclist stamp-piclist
-do_distclean: do_clean
- rm -f Makefile config.status config.cache config.h stamp-h
- rm -rf pic stamp-picdir
-do_maintainer_clean: do_distclean
- rm -f $(srcdir)/bfd-in2.h $(srcdir)/libbfd.h $(srcdir)/libcoff.h
-
-mostlyclean: do_mostlyclean
- $(MAKE) subdir_do DO=mostlyclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-clean: do_clean
- $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
-distclean:
- $(MAKE) subdir_do DO=distclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
- $(MAKE) do_distclean
-clobber maintainer-clean realclean:
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
- $(MAKE) subdir_do DO=maintainer-clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
- $(MAKE) do_maintainer_clean
-
-BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/obstack.h
-LOCAL_H_DEPS= libbfd.h sysdep.h config.h
-$(BFD_LIBS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(BFD_MACHINES): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(BFD_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-$(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
-
-# Get around a Sun Make bug in SunOS 4.1.1 with VPATH
-cpu-i386.o:cpu-i386.c
-cpu-z8k.o: cpu-z8k.c
-cpu-h8500.o: cpu-h8500.c
-cpu-we32k.o: cpu-we32k.c
-
-saber:
- #suppress 65 on bfd_map_over_sections
- #suppress 66 on bfd_map_over_sections
- #suppress 67 on bfd_map_over_sections
- #suppress 68 on bfd_map_over_sections
- #suppress 69 on bfd_map_over_sections
- #suppress 70 on bfd_map_over_sections
- #suppress 110 in bfd_map_over_sections
- #suppress 112 in bfd_map_over_sections
- #suppress 530
- #suppress 590 in swap_exec_header
- #suppress 590 in _bfd_dummy_core_file_matches_executable_p
- #suppress 590 in bfd_dont_truncate_arname
- #suppress 590 on ignore
- #suppress 590 on abfd
- #setopt load_flags $(CFLAGS)
- #load $(CFILES)
-
-
-#-----------------------------------------------------------------------------
-# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
-#
-# 'VERSION' file must be present and contain a string of the form "x.y"
-#-----------------------------------------------------------------------------
-
-ver960.c: FORCE
- rm -f ver960.c
- echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
-
-
-# This target should be invoked before building a new release.
-# 'VERSION' file must be present and contain a string of the form "x.y"
-#
-roll:
- @V=`cat VERSION` ; \
- MAJ=`sed 's/\..*//' VERSION` ; \
- MIN=`sed 's/.*\.//' VERSION` ; \
- V=$$MAJ.`expr $$MIN + 1` ; \
- rm -f VERSION ; \
- echo $$V >VERSION ; \
- echo Version $$V
-
-# Dummy target to force execution of dependent targets.
-#
-force:
-
-install: $(ALLLIBS)
- for f in $(ALLLIBS); do \
- if [ "$$f" = "stamp-tshlink" ]; then \
- continue; \
- fi; \
- tf=lib`echo $$f | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- rm -f $(libdir)/$$tf; \
- if [ "$$f" = "$(SHLINK)" ]; then \
- ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \
- ln -sf $$ts $(libdir)/$$tf; \
- elif [ "$$f" = "$(SHLIB)" ]; then \
- $(INSTALL_PROGRAM) $$f $(libdir)/$$tf; \
- else \
- $(INSTALL_DATA) $$f $(libdir)/$$tf; \
- $(RANLIB) $(libdir)/$$tf; \
- chmod a-x $(libdir)/$$tf; \
- fi; \
- done
-# Install BFD include file, and others that it needs. Install them
-# both in GCC's include directory, and in the system include dir
-# if configured as $(oldincludedir) -- which it usually isnt.
- $(INSTALL_DATA) $(BFD_H) $(includedir)/bfd.h
- $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(includedir)/ansidecl.h
- $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(includedir)/bfdlink.h
- $(INSTALL_DATA) $(INCDIR)/obstack.h $(includedir)/obstack.h
- -if test -z "$(oldincludedir)"; then true; else \
- test -d $(oldincludedir) || mkdir $(oldincludedir); \
- $(INSTALL_DATA) $(BFD_H) $(oldincludedir)/bfd.h; \
- $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(oldincludedir)/ansidecl.h; \
- $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(oldincludedir)/bfdlink.h; \
- $(INSTALL_DATA) $(INCDIR)/obstack.h $(oldincludedir)/obstack.h; \
- $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS); \
- fi
-
-Makefile: Makefile.in config.status
- CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
-
-config.h: stamp-h ; @true
-stamp-h: config.in config.status
- CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
-
-config.status: configure configure.host config.bfd
- $(SHELL) config.status --recheck
-
-# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES).
-.dep: dep.sed $(CFILES) $(HFILES) bfd.h
- rm -f .dep1
- $(MAKE) DEP=$(DEP) .dep1
- sed -f dep.sed <.dep1 >.dep
-
-# This rule really wants a mkdep that runs "gcc -MM".
-# The NetBSD mkdep overwrites any existing file contents, and doesn't insert
-# the "DO NOT DELETE" line.
-# Other mkdep versions require a file that already exists, and do insert it.
-# Hence the weirdness....
-.dep1: $(CFILES)
- rm -f .dep2 .dep2a
- echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2
- echo > .dep2a
- $(DEP) -f .dep2a $(ALL_CFLAGS) $?
- sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2
- rm -f .dep2a
- $(srcdir)/../move-if-change .dep2 .dep1
-
-dep.sed: dep-in.sed config.status
- sed <$(srcdir)/dep-in.sed >dep.sed \
- -e 's!@BFD_H@!$(BFD_H)!' \
- -e 's!@INCDIR@!$(INCDIR)!' \
- -e 's!@SRCDIR@!$(srcdir)!'
-
-dep: .dep
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
- cat .dep >> tmp-Makefile
- $(srcdir)/../move-if-change tmp-Makefile Makefile
-
-dep-in: .dep
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
- cat .dep >> tmp-Makefile.in
- $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
-
-host-aout.o: Makefile
-
-# The following program can be used to generate a simple config file
-# which can be folded into an h-XXX file for a new host, with some editing.
-aout-params.h: gen-aout
- ./gen-aout host > aout-params.h
-gen-aout: $(srcdir)/gen-aout.c Makefile
- $(CC) -o gen-aout $(CFLAGS) $(LFLAGS) $(srcdir)/gen-aout.c
-
-BFDIN_H= $(srcdir)/bfd-in2.h
-
-$(BFD_H): stmp-bfd.h ; @true
-
-stmp-bfd.h : $(srcdir)/bfd-in2.h Makefile
- rm -f bfd.h-new
- sed -e 's/@WORDSIZE@/$(WORDSIZE)/' \
- -e "s/@VERSION@/`cat $(srcdir)/VERSION`/" \
- -e 's/@BFD_HOST_64BIT_LONG@/@HOST_64BIT_LONG@/' \
- < $(srcdir)/bfd-in2.h \
- > bfd.h-new
- $(srcdir)/../move-if-change bfd.h-new $(BFD_H)
- touch stmp-bfd.h
-
-# Could really use a "copy-if-change"...
-headers:
- (cd $(docdir); $(MAKE) protos $(FLAGS_TO_PASS))
- cp $(docdir)/bfd.h bfd-in2.h-new
- $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
- cp $(docdir)/libbfd.h libbfd.h-new
- $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
- cp $(docdir)/libcoff.h libcoff.h-new
- $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
-
-# The rules for the generated header files are here so that people can
-# type `make bfd-in2.h' if they remove it. They are not run by default.
-$(srcdir)/bfd-in2.h:
- (cd $(docdir); $(MAKE) bfd.h $(FLAGS_TO_PASS))
- cp $(docdir)/bfd.h bfd-in2.h-new
- $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
-$(srcdir)/libbfd.h:
- (cd $(docdir); $(MAKE) libbfd.h $(FLAGS_TO_PASS))
- cp $(docdir)/libbfd.h libbfd.h-new
- $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
-$(srcdir)/libcoff.h:
- (cd $(docdir); $(MAKE) libcoff.h $(FLAGS_TO_PASS))
- cp $(docdir)/libcoff.h libcoff.h-new
- $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
-
-bfd.info:
- (cd $(docdir); $(MAKE) bfd.info $(FLAGS_TO_PASS))
-
-bfd.dvi:
- (cd $(docdir); $(MAKE) bfd.dvi $(FLAGS_TO_PASS))
-
-bfd.ps:
- (cd $(docdir); $(MAKE) bfd.ps $(FLAGS_TO_PASS))
-
-
-$(OFILES): stamp-picdir
-
-stamp-picdir:
- if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \
- mkdir pic; \
- else true; fi
- touch stamp-picdir
-
-# What appears below is generated by a hacked mkdep using gcc -MM.
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-archive.o: archive.c $(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h
-archures.o: archures.c
-bfd.o: bfd.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h libcoff.h libecoff.h $(INCDIR)/coff/ecoff.h \
- elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
- $(INCDIR)/elf/external.h
-cache.o: cache.c
-coffgen.o: coffgen.c $(INCDIR)/coff/internal.h libcoff.h \
- $(INCDIR)/bfdlink.h
-corefile.o: corefile.c
-format.o: format.c
-init.o: init.c
-libbfd.o: libbfd.c
-opncls.o: opncls.c
-reloc.o: reloc.c $(INCDIR)/bfdlink.h
-section.o: section.c
-syms.o: syms.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def
-targets.o: targets.c
-hash.o: hash.c
-linker.o: linker.c $(INCDIR)/bfdlink.h genlink.h
-elf.o: elf.c $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
-srec.o: srec.c $(INCDIR)/libiberty.h
-binary.o: binary.c
-tekhex.o: tekhex.c $(INCDIR)/libiberty.h
-ihex.o: ihex.c $(INCDIR)/libiberty.h
-stab-syms.o: stab-syms.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab.def
-cpu-a29k.o: cpu-a29k.c
-cpu-alpha.o: cpu-alpha.c
-cpu-arm.o: cpu-arm.c
-cpu-h8300.o: cpu-h8300.c
-cpu-h8500.o: cpu-h8500.c
-cpu-hppa.o: cpu-hppa.c
-cpu-i386.o: cpu-i386.c
-cpu-i860.o: cpu-i860.c
-cpu-i960.o: cpu-i960.c
-cpu-m68k.o: cpu-m68k.c
-cpu-m88k.o: cpu-m88k.c
-cpu-mips.o: cpu-mips.c
-cpu-ns32k.o: cpu-ns32k.c
-cpu-powerpc.o: cpu-powerpc.c
-cpu-rs6000.o: cpu-rs6000.c
-cpu-sh.o: cpu-sh.c
-cpu-sparc.o: cpu-sparc.c
-cpu-vax.o: cpu-vax.c
-cpu-we32k.o: cpu-we32k.c
-cpu-w65.o: cpu-w65.c
-cpu-z8k.o: cpu-z8k.c
-aout-adobe.o: aout-adobe.c $(INCDIR)/aout/adobe.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def libaout.h $(INCDIR)/bfdlink.h
-aout-ns32k.o: aout-ns32k.c $(INCDIR)/aout/aout64.h \
- libaout.h $(INCDIR)/bfdlink.h
-aout0.o: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-aout32.o: aout32.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- $(INCDIR)/aout/ar.h
-bout.o: bout.c $(INCDIR)/bfdlink.h genlink.h $(INCDIR)/bout.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h
-cf-i386lynx.o: cf-i386lynx.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-cf-m68klynx.o: cf-m68klynx.c coff-m68k.c $(INCDIR)/coff/m68k.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-cf-sparclynx.o: cf-sparclynx.c coff-sparc.c $(INCDIR)/coff/sparc.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-a29k.o: coff-a29k.c $(INCDIR)/coff/a29k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-apollo.o: coff-apollo.c $(INCDIR)/coff/apollo.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-arm.o: coff-arm.c $(INCDIR)/coff/arm.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-aux.o: coff-aux.c $(INCDIR)/coff/aux-coff.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/m68k.h coff-m68k.c libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-h8300.o: coff-h8300.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8300.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-h8500.o: coff-h8500.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/h8500.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-i386.o: coff-i386.c $(INCDIR)/coff/i386.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-i860.o: coff-i860.c $(INCDIR)/coff/i860.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-go32.o: coff-go32.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-i960.o: coff-i960.c $(INCDIR)/coff/i960.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-m68k.o: coff-m68k.c $(INCDIR)/coff/m68k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-m88k.o: coff-m88k.c $(INCDIR)/coff/m88k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-mips.o: coff-mips.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- $(INCDIR)/coff/mips.h libcoff.h libecoff.h coffswap.h \
- ecoffswap.h
-coff-pmac.o: coff-pmac.c coff-rs6000.c $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-rs6000.o: coff-rs6000.c $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/rs6000.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-sh.o: coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-sparc.o: coff-sparc.c $(INCDIR)/coff/sparc.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-u68k.o: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
- coffcode.h coffswap.h
-coff-we32k.o: coff-we32k.c $(INCDIR)/coff/we32k.h $(INCDIR)/coff/internal.h \
- libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
-coff-w65.o: coff-w65.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/w65.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-coff-z8k.o: coff-z8k.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/z8k.h \
- $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
-cofflink.o: cofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- libcoff.h
-ecoff.o: ecoff.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/ar.h \
- $(INCDIR)/aout/ranlib.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- libaout.h $(INCDIR)/aout/aout64.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- libcoff.h libecoff.h
-ecofflink.o: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \
- $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h
-elf32-gen.o: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-hppa.o: elf32-hppa.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-hppa.h libhppa.h $(INCDIR)/elf/hppa.h hppa_stubs.h \
- elf32-target.h
-elf32-i386.o: elf32-i386.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-target.h
-elf32-i860.o: elf32-i860.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-m68k.o: elf32-m68k.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elf32-target.h
-elf32-m88k.o: elf32-m88k.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf32-target.h
-elf32-mips.o: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \
- elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
- $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/coff/sym.h \
- $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
- elf32-target.h
-elf32-ppc.o: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/elf/ppc.h elf32-target.h
-elf32-sparc.o: elf32-sparc.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- $(INCDIR)/elf/sparc.h elf32-target.h
-elf32.o: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elfcore.h elflink.h
-elflink.o: elflink.c $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
-hp300hpux.o: hp300hpux.c $(INCDIR)/aout/hp300hpux.h \
- aoutx.h $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
- aout-target.h
-som.o: som.c
-i386aout.o: i386aout.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386bsd.o: i386bsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386freebsd.o: i386freebsd.c freebsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386linux.o: i386linux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-i386lynx.o: i386lynx.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386msdos.o: i386msdos.c libaout.h $(INCDIR)/bfdlink.h
-i386netbsd.o: i386netbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-i386mach3.o: i386mach3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-i386os9k.o: i386os9k.c $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/os9k.h
-ieee.o: ieee.c $(INCDIR)/ieee.h libieee.h
-m68klinux.o: m68klinux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-m68klynx.o: m68klynx.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-m68knetbsd.o: m68knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-m88kmach3.o: m88kmach3.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-mipsbsd.o: mipsbsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-newsos3.o: newsos3.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \
- $(INCDIR)/bfdlink.h aout-target.h
-nlm.o: nlm.c libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h
-nlm32-i386.o: nlm32-i386.c $(INCDIR)/nlm/i386-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm32-sparc.o: nlm32-sparc.c $(INCDIR)/nlm/sparc32-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm32-ppc.o: nlm32-ppc.c $(INCDIR)/nlm/ppc-ext.h libnlm.h \
- $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h \
- nlmswap.h nlm-target.h
-nlm32.o: nlm32.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
- $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
-ns32knetbsd.o: ns32knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-oasys.o: oasys.c $(INCDIR)/oasys.h liboasys.h
-pc532-mach.o: pc532-mach.c libaout.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/aout/aout64.h aout-target.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-pe-arm.o: pe-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-arm.o: pei-arm.c coff-arm.c $(INCDIR)/coff/arm.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pe-i386.o: pe-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-i386.o: pei-i386.c coff-i386.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pe-ppc.o: pe-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-pei-ppc.o: pei-ppc.c coff-ppc.c $(INCDIR)/coff/powerpc.h \
- $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
- $(INCDIR)/bfdlink.h coffcode.h peicode.h
-reloc16.o: reloc16.c $(INCDIR)/bfdlink.h genlink.h \
- $(INCDIR)/coff/internal.h libcoff.h
-sparclynx.o: sparclynx.c $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-sparcnetbsd.o: sparcnetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-sunos.o: sunos.c $(INCDIR)/bfdlink.h libaout.h aoutf1.h \
- $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-versados.o: versados.c $(INCDIR)/libiberty.h
-xcofflink.o: xcofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- libcoff.h
-aout64.o: aout64.c aoutx.h $(INCDIR)/bfdlink.h libaout.h \
- $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- $(INCDIR)/aout/ar.h
-coff-alpha.o: coff-alpha.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \
- $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
- $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
- libecoff.h coffswap.h ecoffswap.h
-demo64.o: demo64.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-elf64-gen.o: elf64-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- elf64-target.h
-elf64-sparc.o: elf64-sparc.c elf-bfd.h $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/elf/sparc.h elf64-target.h
-elf64.o: elf64.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \
- $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
- elfcore.h elflink.h
-nlm32-alpha.o: nlm32-alpha.c $(INCDIR)/nlm/alpha-ext.h \
- libnlm.h $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
- $(INCDIR)/nlm/external.h nlmswap.h nlm-target.h
-nlm64.o: nlm64.c nlmcode.h libnlm.h $(INCDIR)/nlm/common.h \
- $(INCDIR)/nlm/internal.h $(INCDIR)/nlm/external.h
-aix386-core.o: aix386-core.c $(INCDIR)/coff/i386.h \
- $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h
-hpux-core.o: hpux-core.c
-irix-core.o: irix-core.c
-lynx-core.o: lynx-core.c
-osf-core.o: osf-core.c
-trad-core.o: trad-core.c libaout.h $(INCDIR)/bfdlink.h
-cisco-core.o: cisco-core.c
-i386dynix.o: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \
- $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
- $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \
- aout-target.h
-hp300bsd.o: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \
- aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
- $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/contrib/gdb/bfd/PORTING b/contrib/gdb/bfd/PORTING
deleted file mode 100644
index c8bfd77..0000000
--- a/contrib/gdb/bfd/PORTING
+++ /dev/null
@@ -1,83 +0,0 @@
- Preliminary Notes on Porting BFD
- --------------------------------
-
-The 'host' is the system a tool runs *on*.
-The 'target' is the system a tool runs *for*, i.e.
-a tool can read/write the binaries of the target.
-
-Porting to a new host
----------------------
-Pick a name for your host. Call that <host>.
-(<host> might be sun4, ...)
-Create a file hosts/<host>.mh.
-
-Porting to a new target
------------------------
-Pick a name for your target. Call that <target>.
-Call the name for your CPU architecture <cpu>.
-You need to create <target>.c and config/<target>.mt,
-and add a case for it to a case statements in bfd/configure.host and
-bfd/config.bfd, which associates each canonical host type with a BFD
-host type (used as the base of the makefile fragment names), and to the
-table in bfd/configure.in which associates each target vector with
-the .o files it uses.
-
-config/<target>.mt is a Makefile fragment.
-The following is usually enough:
-DEFAULT_VECTOR=<target>_vec
-SELECT_ARCHITECTURES=bfd_<cpu>_arch
-
-See the list of cpu types in archures.c, or "ls cpu-*.c".
-If your architecture is new, you need to add it to the tables
-in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
-
-For more information about .mt and .mh files, see config/README.
-
-The file <target>.c is the hard part. It implements the
-bfd_target <target>_vec, which includes pointers to
-functions that do the actual <target>-specific methods.
-
-Porting to a <target> that uses the a.out binary format
--------------------------------------------------------
-
-In this case, the include file aout-target.h probaby does most
-of what you need. The program gen-aout generates <target>.c for
-you automatically for many a.out systems. Do:
- make gen-aout
- ./gen-aout <target> > <target>.c
-(This only works if you are building on the target ("native").
-If you must make a cross-port from scratch, copy the most
-similar existing file that includes aout-target.h, and fix what is wrong.)
-
-Check the parameters in <target>.c, and fix anything that is wrong.
-(Also let us know about it; perhaps we can improve gen-aout.c.)
-
-TARGET_IS_BIG_ENDIAN_P
- Should be defined if <target> is big-endian.
-
-N_HEADER_IN_TEXT(x)
- See discussion in ../include/aout/aout64.h.
-
-BYTES_IN_WORD
- Number of bytes per word. (Usually 4 but can be 8.)
-
-ARCH
- Number of bits per word. (Usually 32, but can be 64.)
-
-ENTRY_CAN_BE_ZERO
- Define if the extry point (start address of an
- executable program) can be 0x0.
-
-TEXT_START_ADDR
- The address of the start of the text segemnt in
- virtual memory. Normally, the same as the entry point.
-
-TARGET_PAGE_SIZE
-
-SEGMENT_SIZE
- Usually, the same as the TARGET_PAGE_SIZE.
- Alignment needed for the data segment.
-
-TARGETNAME
- The name of the target, for run-time lookups.
- Usually "a.out-<target>"
diff --git a/contrib/gdb/bfd/TODO b/contrib/gdb/bfd/TODO
deleted file mode 100644
index 08a3641..0000000
--- a/contrib/gdb/bfd/TODO
+++ /dev/null
@@ -1,25 +0,0 @@
-Things that still need to be done: -*- Text -*-
-
- o - A source of space lossage is that all the target-dependent code
- is in a single bfd_target structure. Hence all the code for
- *writing* object files is still pulled into all the applications
- that only care about *reading* (gdb, nm, objdump), while gas has
- to carry along all the unneded baggage for reading objects. And
- so on. This would be a substantial change, and the payoff would
- not all that great (essentially none if bfd is used as a shared
- library).
-
- o - The storage needed by BFD data structures is also larger than strictly
- needed. This may be difficult to do much about.
-
- o - implement bfd_abort, which should close the bfd but not alter the
- filesystem.
-
- o - update the bfd doc; write a how-to-write-a-backend doc, take out
- the stupid quips and fill in all the blanks.
-
- o - upgrade the reloc handling as per Steve's suggestion.
-
-
-
-
diff --git a/contrib/gdb/bfd/VERSION b/contrib/gdb/bfd/VERSION
deleted file mode 100644
index 9ddf6b5..0000000
--- a/contrib/gdb/bfd/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-cygnus-2.6
diff --git a/contrib/gdb/bfd/aclocal.m4 b/contrib/gdb/bfd/aclocal.m4
deleted file mode 100644
index 1f5027e..0000000
--- a/contrib/gdb/bfd/aclocal.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
-AC_DEFUN(BFD_BINARY_FOPEN,
-[AC_REQUIRE([AC_CANONICAL_SYSTEM])
-case "${host}" in
-changequote(,)dnl
-i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32)
-changequote([,])dnl
- AC_DEFINE(USE_BINARY_FOPEN) ;;
-esac])dnl
-
-dnl Get a default for CC_FOR_BUILD to put into Makefile.
-AC_DEFUN(BFD_CC_FOR_BUILD,
-[# Put a plausible default for CC_FOR_BUILD in Makefile.
-AC_REQUIRE([AC_C_CROSS])dnl
-if test -z "$CC_FOR_BUILD"; then
- if test "x$cross_compiling" = "xno"; then
- CC_FOR_BUILD='$(CC)'
- else
- CC_FOR_BUILD=gcc
- fi
-fi
-AC_SUBST(CC_FOR_BUILD)])dnl
-
-dnl See whether we need a declaration for a function.
-AC_DEFUN(BFD_NEED_DECLARATION,
-[AC_MSG_CHECKING([whether $1 must be declared])
-AC_CACHE_VAL(bfd_cv_decl_needed_$1,
-[AC_TRY_COMPILE([
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif],
-[char *(*pfn) = (char *(*)) $1],
-bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
-AC_MSG_RESULT($bfd_cv_decl_needed_$1)
-if test $bfd_cv_decl_needed_$1 = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- AC_DEFINE_UNQUOTED($bfd_tr_decl)
-fi
-])dnl
diff --git a/contrib/gdb/bfd/aout-target.h b/contrib/gdb/bfd/aout-target.h
deleted file mode 100644
index 6711a71..0000000
--- a/contrib/gdb/bfd/aout-target.h
+++ /dev/null
@@ -1,607 +0,0 @@
-/* Define a target vector and some small routines for a variant of a.out.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-/*#include "libaout.h"*/
-
-extern reloc_howto_type * NAME(aout,reloc_type_lookup) ();
-
-/* Set parameters about this a.out file that are machine-dependent.
- This routine is called from some_aout_object_p just before it returns. */
-#ifndef MY_callback
-static const bfd_target *
-MY(callback) (abfd)
- bfd *abfd;
-{
- struct internal_exec *execp = exec_hdr (abfd);
- unsigned int arch_align_power;
- unsigned long arch_align;
-
- /* Calculate the file positions of the parts of a newly read aout header */
- obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
-
- /* The virtual memory addresses of the sections */
- obj_textsec (abfd)->vma = N_TXTADDR(*execp);
- obj_datasec (abfd)->vma = N_DATADDR(*execp);
- obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
-
- obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
- obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
- obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
-
- /* The file offsets of the sections */
- obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
- obj_datasec (abfd)->filepos = N_DATOFF (*execp);
-
- /* The file offsets of the relocation info */
- obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
- obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
-
- /* The file offsets of the string table and symbol table. */
- obj_sym_filepos (abfd) = N_SYMOFF (*execp);
- obj_str_filepos (abfd) = N_STROFF (*execp);
-
- /* Determine the architecture and machine type of the object file. */
-#ifdef SET_ARCH_MACH
- SET_ARCH_MACH(abfd, *execp);
-#else
- bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
-#endif
-
- /* Now that we know the architecture, set the alignments of the
- sections. This is normally done by NAME(aout,new_section_hook),
- but when the initial sections were created the architecture had
- not yet been set. However, for backward compatibility, we don't
- set the alignment power any higher than as required by the size
- of the section. */
- arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
- arch_align = 1 << arch_align_power;
- if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
- == obj_textsec (abfd)->_raw_size)
- && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
- == obj_datasec (abfd)->_raw_size)
- && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
- == obj_bsssec (abfd)->_raw_size))
- {
- obj_textsec (abfd)->alignment_power = arch_align_power;
- obj_datasec (abfd)->alignment_power = arch_align_power;
- obj_bsssec (abfd)->alignment_power = arch_align_power;
- }
-
- /* Don't set sizes now -- can't be sure until we know arch & mach.
- Sizes get set in set_sizes callback, later. */
-#if 0
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-#endif
-
- return abfd->xvec;
-}
-#endif
-
-#ifndef MY_object_p
-/* Finish up the reading of an a.out file header */
-
-static const bfd_target *
-MY(object_p) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes; /* Raw exec header from file */
- struct internal_exec exec; /* Cleaned-up exec header */
- const bfd_target *target;
-
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
-#ifdef SWAP_MAGIC
- exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
-#else
- exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
-#endif /* SWAP_MAGIC */
-
- if (N_BADMAG (exec)) return 0;
-#ifdef MACHTYPE_OK
- if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
-#endif
-
- NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
-
-#ifdef SWAP_MAGIC
- /* swap_exec_header_in read in a_info with the wrong byte order */
- exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
-#endif /* SWAP_MAGIC */
-
- target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
-
-#ifdef ENTRY_CAN_BE_ZERO
- /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
- * means that it isn't obvious if EXEC_P should be set.
- * All of the following must be true for an executable:
- * There must be no relocations, the bfd can be neither an
- * archive nor an archive element, and the file must be executable. */
-
- if (exec.a_trsize + exec.a_drsize == 0
- && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
- {
- struct stat buf;
-#ifndef S_IXUSR
-#define S_IXUSR 0100 /* Execute by owner. */
-#endif
- if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
- abfd->flags |= EXEC_P;
- }
-#endif /* ENTRY_CAN_BE_ZERO */
-
- return target;
-}
-#define MY_object_p MY(object_p)
-#endif
-
-
-#ifndef MY_mkobject
-static boolean
-MY(mkobject) (abfd)
- bfd *abfd;
-{
- if (NAME(aout,mkobject)(abfd) == false)
- return false;
-#if 0 /* Sizes get set in set_sizes callback, later, after we know
- the architecture and machine. */
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-#endif
- return true;
-}
-#define MY_mkobject MY(mkobject)
-#endif
-
-#ifndef MY_bfd_copy_private_section_data
-
-/* Copy private section data. This actually does nothing with the
- sections. It copies the subformat field. We copy it here, because
- we need to know whether this is a QMAGIC file before we set the
- section contents, and copy_private_bfd_data is not called until
- after the section contents have been set. */
-
-/*ARGSUSED*/
-static boolean
-MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
- bfd *ibfd;
- asection *isec;
- bfd *obfd;
- asection *osec;
-{
- if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
- obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
- return true;
-}
-
-#endif
-
-/* Write an object file.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-#ifndef MY_write_object_contents
-static boolean
-MY(write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
-#if CHOOSE_RELOC_SIZE
- CHOOSE_RELOC_SIZE(abfd);
-#else
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-#endif
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-#define MY_write_object_contents MY(write_object_contents)
-#endif
-
-#ifndef MY_set_sizes
-static boolean
-MY(set_sizes) (abfd)
- bfd *abfd;
-{
- adata(abfd).page_size = TARGET_PAGE_SIZE;
-
-#ifdef SEGMENT_SIZE
- adata(abfd).segment_size = SEGMENT_SIZE;
-#else
- adata(abfd).segment_size = TARGET_PAGE_SIZE;
-#endif
-
-#ifdef ZMAGIC_DISK_BLOCK_SIZE
- adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
-#else
- adata(abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
-#endif
-
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
-}
-#define MY_set_sizes MY(set_sizes)
-#endif
-
-#ifndef MY_exec_hdr_flags
-#define MY_exec_hdr_flags 0
-#endif
-
-#ifndef MY_backend_data
-
-#ifndef MY_zmagic_contiguous
-#define MY_zmagic_contiguous 0
-#endif
-#ifndef MY_text_includes_header
-#define MY_text_includes_header 0
-#endif
-#ifndef MY_exec_header_not_counted
-#define MY_exec_header_not_counted 0
-#endif
-#ifndef MY_add_dynamic_symbols
-#define MY_add_dynamic_symbols 0
-#endif
-#ifndef MY_add_one_symbol
-#define MY_add_one_symbol 0
-#endif
-#ifndef MY_link_dynamic_object
-#define MY_link_dynamic_object 0
-#endif
-#ifndef MY_write_dynamic_symbol
-#define MY_write_dynamic_symbol 0
-#endif
-#ifndef MY_check_dynamic_reloc
-#define MY_check_dynamic_reloc 0
-#endif
-#ifndef MY_finish_dynamic_link
-#define MY_finish_dynamic_link 0
-#endif
-
-static CONST struct aout_backend_data MY(backend_data) = {
- MY_zmagic_contiguous,
- MY_text_includes_header,
- MY_exec_hdr_flags,
- 0, /* text vma? */
- MY_set_sizes,
- MY_exec_header_not_counted,
- MY_add_dynamic_symbols,
- MY_add_one_symbol,
- MY_link_dynamic_object,
- MY_write_dynamic_symbol,
- MY_check_dynamic_reloc,
- MY_finish_dynamic_link
-};
-#define MY_backend_data &MY(backend_data)
-#endif
-
-#ifndef MY_final_link_callback
-
-/* Callback for the final_link routine to set the section offsets. */
-
-static void MY_final_link_callback
- PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-
-static void
-MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
- bfd *abfd;
- file_ptr *ptreloff;
- file_ptr *pdreloff;
- file_ptr *psymoff;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- *ptreloff = N_TRELOFF (*execp);
- *pdreloff = N_DRELOFF (*execp);
- *psymoff = N_SYMOFF (*execp);
-}
-
-#endif
-
-#ifndef MY_bfd_final_link
-
-/* Final link routine. We need to use a call back to get the correct
- offsets in the output file. */
-
-static boolean
-MY_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
-}
-
-#endif
-
-/* We assume BFD generic archive files. */
-#ifndef MY_openr_next_archived_file
-#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
-#endif
-#ifndef MY_get_elt_at_index
-#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
-#endif
-#ifndef MY_generic_stat_arch_elt
-#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#endif
-#ifndef MY_slurp_armap
-#define MY_slurp_armap bfd_slurp_bsd_armap
-#endif
-#ifndef MY_slurp_extended_name_table
-#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
-#endif
-#ifndef MY_construct_extended_name_table
-#define MY_construct_extended_name_table \
- _bfd_archive_bsd_construct_extended_name_table
-#endif
-#ifndef MY_write_armap
-#define MY_write_armap bsd_write_armap
-#endif
-#ifndef MY_read_ar_hdr
-#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
-#endif
-#ifndef MY_truncate_arname
-#define MY_truncate_arname bfd_bsd_truncate_arname
-#endif
-#ifndef MY_update_armap_timestamp
-#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
-#endif
-
-/* No core file defined here -- configure in trad-core.c separately. */
-#ifndef MY_core_file_failing_command
-#define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
-#endif
-#ifndef MY_core_file_failing_signal
-#define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
-#endif
-#ifndef MY_core_file_matches_executable_p
-#define MY_core_file_matches_executable_p \
- _bfd_nocore_core_file_matches_executable_p
-#endif
-#ifndef MY_core_file_p
-#define MY_core_file_p _bfd_dummy_target
-#endif
-
-#ifndef MY_bfd_debug_info_start
-#define MY_bfd_debug_info_start bfd_void
-#endif
-#ifndef MY_bfd_debug_info_end
-#define MY_bfd_debug_info_end bfd_void
-#endif
-#ifndef MY_bfd_debug_info_accumulate
-#define MY_bfd_debug_info_accumulate \
- (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
-#endif
-
-#ifndef MY_core_file_failing_command
-#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
-#endif
-#ifndef MY_core_file_failing_signal
-#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
-#endif
-#ifndef MY_core_file_matches_executable_p
-#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
-#endif
-#ifndef MY_set_section_contents
-#define MY_set_section_contents NAME(aout,set_section_contents)
-#endif
-#ifndef MY_get_section_contents
-#define MY_get_section_contents NAME(aout,get_section_contents)
-#endif
-#ifndef MY_get_section_contents_in_window
-#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
-#endif
-#ifndef MY_new_section_hook
-#define MY_new_section_hook NAME(aout,new_section_hook)
-#endif
-#ifndef MY_get_symtab_upper_bound
-#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
-#endif
-#ifndef MY_get_symtab
-#define MY_get_symtab NAME(aout,get_symtab)
-#endif
-#ifndef MY_get_reloc_upper_bound
-#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
-#endif
-#ifndef MY_canonicalize_reloc
-#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
-#endif
-#ifndef MY_make_empty_symbol
-#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
-#endif
-#ifndef MY_print_symbol
-#define MY_print_symbol NAME(aout,print_symbol)
-#endif
-#ifndef MY_get_symbol_info
-#define MY_get_symbol_info NAME(aout,get_symbol_info)
-#endif
-#ifndef MY_get_lineno
-#define MY_get_lineno NAME(aout,get_lineno)
-#endif
-#ifndef MY_set_arch_mach
-#define MY_set_arch_mach NAME(aout,set_arch_mach)
-#endif
-#ifndef MY_find_nearest_line
-#define MY_find_nearest_line NAME(aout,find_nearest_line)
-#endif
-#ifndef MY_sizeof_headers
-#define MY_sizeof_headers NAME(aout,sizeof_headers)
-#endif
-#ifndef MY_bfd_get_relocated_section_contents
-#define MY_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#endif
-#ifndef MY_bfd_relax_section
-#define MY_bfd_relax_section bfd_generic_relax_section
-#endif
-#ifndef MY_bfd_reloc_type_lookup
-#define MY_bfd_reloc_type_lookup NAME(aout,reloc_type_lookup)
-#endif
-#ifndef MY_bfd_make_debug_symbol
-#define MY_bfd_make_debug_symbol 0
-#endif
-#ifndef MY_read_minisymbols
-#define MY_read_minisymbols NAME(aout,read_minisymbols)
-#endif
-#ifndef MY_minisymbol_to_symbol
-#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
-#endif
-#ifndef MY_bfd_link_hash_table_create
-#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
-#endif
-#ifndef MY_bfd_link_add_symbols
-#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
-#endif
-#ifndef MY_bfd_link_split_section
-#define MY_bfd_link_split_section _bfd_generic_link_split_section
-#endif
-
-
-#ifndef MY_bfd_copy_private_bfd_data
-#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
-#endif
-
-#ifndef MY_bfd_merge_private_bfd_data
-#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
-#endif
-
-#ifndef MY_bfd_copy_private_symbol_data
-#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
-#endif
-
-#ifndef MY_bfd_print_private_bfd_data
-#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
-#endif
-
-#ifndef MY_bfd_set_private_flags
-#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-#endif
-
-#ifndef MY_bfd_is_local_label
-#define MY_bfd_is_local_label bfd_generic_is_local_label
-#endif
-
-#ifndef MY_bfd_free_cached_info
-#define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
-#endif
-
-#ifndef MY_close_and_cleanup
-#define MY_close_and_cleanup MY_bfd_free_cached_info
-#endif
-
-#ifndef MY_get_dynamic_symtab_upper_bound
-#define MY_get_dynamic_symtab_upper_bound \
- _bfd_nodynamic_get_dynamic_symtab_upper_bound
-#endif
-#ifndef MY_canonicalize_dynamic_symtab
-#define MY_canonicalize_dynamic_symtab \
- _bfd_nodynamic_canonicalize_dynamic_symtab
-#endif
-#ifndef MY_get_dynamic_reloc_upper_bound
-#define MY_get_dynamic_reloc_upper_bound \
- _bfd_nodynamic_get_dynamic_reloc_upper_bound
-#endif
-#ifndef MY_canonicalize_dynamic_reloc
-#define MY_canonicalize_dynamic_reloc \
- _bfd_nodynamic_canonicalize_dynamic_reloc
-#endif
-
-/* Aout symbols normally have leading underscores */
-#ifndef MY_symbol_leading_char
-#define MY_symbol_leading_char '_'
-#endif
-
-/* Aout archives normally use spaces for padding */
-#ifndef AR_PAD_CHAR
-#define AR_PAD_CHAR ' '
-#endif
-
-#ifndef MY_BFD_TARGET
-const bfd_target MY(vec) =
-{
- TARGETNAME, /* name */
- bfd_target_aout_flavour,
-#ifdef TARGET_IS_BIG_ENDIAN_P
- BFD_ENDIAN_BIG, /* target byte order (big) */
- BFD_ENDIAN_BIG, /* target headers byte order (big) */
-#else
- BFD_ENDIAN_LITTLE, /* target byte order (little) */
- BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
-#endif
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- MY_symbol_leading_char,
- AR_PAD_CHAR, /* ar_pad_char */
- 15, /* ar_max_namelen */
-#ifdef TARGET_IS_BIG_ENDIAN_P
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-#else
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-#endif
- {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
- bfd_generic_archive_p, MY_core_file_p},
- {bfd_false, MY_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, MY_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (MY),
- BFD_JUMP_TABLE_COPY (MY),
- BFD_JUMP_TABLE_CORE (MY),
- BFD_JUMP_TABLE_ARCHIVE (MY),
- BFD_JUMP_TABLE_SYMBOLS (MY),
- BFD_JUMP_TABLE_RELOCS (MY),
- BFD_JUMP_TABLE_WRITE (MY),
- BFD_JUMP_TABLE_LINK (MY),
- BFD_JUMP_TABLE_DYNAMIC (MY),
-
- (PTR) MY_backend_data,
-};
-#endif /* MY_BFD_TARGET */
diff --git a/contrib/gdb/bfd/aout32.c b/contrib/gdb/bfd/aout32.c
deleted file mode 100644
index bfc40b4..0000000
--- a/contrib/gdb/bfd/aout32.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* BFD back-end for 32-bit a.out files.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 32
-
-#include "aoutx.h"
diff --git a/contrib/gdb/bfd/aoutx.h b/contrib/gdb/bfd/aoutx.h
deleted file mode 100644
index 4b04943..0000000
--- a/contrib/gdb/bfd/aoutx.h
+++ /dev/null
@@ -1,5525 +0,0 @@
-/* BFD semi-generic back-end for a.out binaries.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- a.out backends
-
-
-DESCRIPTION
-
- BFD supports a number of different flavours of a.out format,
- though the major differences are only the sizes of the
- structures on disk, and the shape of the relocation
- information.
-
- The support is split into a basic support file @file{aoutx.h}
- and other files which derive functions from the base. One
- derivation file is @file{aoutf1.h} (for a.out flavour 1), and
- adds to the basic a.out functions support for sun3, sun4, 386
- and 29k a.out files, to create a target jump vector for a
- specific target.
-
- This information is further split out into more specific files
- for each machine, including @file{sunos.c} for sun3 and sun4,
- @file{newsos3.c} for the Sony NEWS, and @file{demo64.c} for a
- demonstration of a 64 bit a.out format.
-
- The base file @file{aoutx.h} defines general mechanisms for
- reading and writing records to and from disk and various
- other methods which BFD requires. It is included by
- @file{aout32.c} and @file{aout64.c} to form the names
- <<aout_32_swap_exec_header_in>>, <<aout_64_swap_exec_header_in>>, etc.
-
- As an example, this is what goes on to make the back end for a
- sun4, from @file{aout32.c}:
-
-| #define ARCH_SIZE 32
-| #include "aoutx.h"
-
- Which exports names:
-
-| ...
-| aout_32_canonicalize_reloc
-| aout_32_find_nearest_line
-| aout_32_get_lineno
-| aout_32_get_reloc_upper_bound
-| ...
-
- from @file{sunos.c}:
-
-| #define TARGET_NAME "a.out-sunos-big"
-| #define VECNAME sunos_big_vec
-| #include "aoutf1.h"
-
- requires all the names from @file{aout32.c}, and produces the jump vector
-
-| sunos_big_vec
-
- The file @file{host-aout.c} is a special case. It is for a large set
- of hosts that use ``more or less standard'' a.out files, and
- for which cross-debugging is not interesting. It uses the
- standard 32-bit a.out support routines, but determines the
- file offsets and addresses of the text, data, and BSS
- sections, the machine architecture and machine type, and the
- entry point address, in a host-dependent manner. Once these
- values have been determined, generic code is used to handle
- the object file.
-
- When porting it to run on a new system, you must supply:
-
-| HOST_PAGE_SIZE
-| HOST_SEGMENT_SIZE
-| HOST_MACHINE_ARCH (optional)
-| HOST_MACHINE_MACHINE (optional)
-| HOST_TEXT_START_ADDR
-| HOST_STACK_END_ADDR
-
- in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These
- values, plus the structures and macros defined in @file{a.out.h} on
- your host system, will produce a BFD target that will access
- ordinary a.out files on your host. To configure a new machine
- to use @file{host-aout.c}, specify:
-
-| TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
-| TDEPFILES= host-aout.o trad-core.o
-
- in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
- to use the
- @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
- configuration is selected.
-
-*/
-
-/* Some assumptions:
- * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
- Doesn't matter what the setting of WP_TEXT is on output, but it'll
- get set on input.
- * Any BFD with D_PAGED clear and WP_TEXT set is NMAGIC.
- * Any BFD with both flags clear is OMAGIC.
- (Just want to make these explicit, so the conditions tested in this
- file make sense if you're more familiar with a.out than with BFD.) */
-
-#define KEEPIT udata.i
-
-#include <string.h> /* For strchr and friends */
-#include <ctype.h>
-#include "bfd.h"
-#include <sysdep.h>
-#include "bfdlink.h"
-
-#include "libaout.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-
-static boolean aout_get_external_symbols PARAMS ((bfd *));
-static boolean translate_from_native_sym_flags
- PARAMS ((bfd *, aout_symbol_type *));
-static boolean translate_to_native_sym_flags
- PARAMS ((bfd *, asymbol *, struct external_nlist *));
-
-/*
-SUBSECTION
- Relocations
-
-DESCRIPTION
- The file @file{aoutx.h} provides for both the @emph{standard}
- and @emph{extended} forms of a.out relocation records.
-
- The standard records contain only an
- address, a symbol index, and a type field. The extended records
- (used on 29ks and sparcs) also have a full integer for an
- addend.
-
-*/
-#ifndef CTOR_TABLE_RELOC_HOWTO
-#define CTOR_TABLE_RELOC_IDX 2
-#define CTOR_TABLE_RELOC_HOWTO(BFD) ((obj_reloc_entry_size(BFD) == RELOC_EXT_SIZE \
- ? howto_table_ext : howto_table_std) \
- + CTOR_TABLE_RELOC_IDX)
-#endif
-
-#ifndef MY_swap_std_reloc_in
-#define MY_swap_std_reloc_in NAME(aout,swap_std_reloc_in)
-#endif
-
-#ifndef MY_swap_std_reloc_out
-#define MY_swap_std_reloc_out NAME(aout,swap_std_reloc_out)
-#endif
-
-#ifndef MY_final_link_relocate
-#define MY_final_link_relocate _bfd_final_link_relocate
-#endif
-
-#ifndef MY_relocate_contents
-#define MY_relocate_contents _bfd_relocate_contents
-#endif
-
-#define howto_table_ext NAME(aout,ext_howto_table)
-#define howto_table_std NAME(aout,std_howto_table)
-
-reloc_howto_type howto_table_ext[] =
-{
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
- HOWTO(RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", false, 0,0x000000ff, false),
- HOWTO(RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", false, 0,0x0000ffff, false),
- HOWTO(RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", false, 0,0xffffffff, false),
- HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, complain_overflow_signed,0,"DISP8", false, 0,0x000000ff, false),
- HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, complain_overflow_signed,0,"DISP16", false, 0,0x0000ffff, false),
- HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, complain_overflow_signed,0,"DISP32", false, 0,0xffffffff, false),
- HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, complain_overflow_signed,0,"WDISP30", false, 0,0x3fffffff, false),
- HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, complain_overflow_signed,0,"WDISP22", false, 0,0x003fffff, false),
- HOWTO(RELOC_HI22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"HI22", false, 0,0x003fffff, false),
- HOWTO(RELOC_22, 0, 2, 22, false, 0, complain_overflow_bitfield,0,"22", false, 0,0x003fffff, false),
- HOWTO(RELOC_13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"13", false, 0,0x00001fff, false),
- HOWTO(RELOC_LO10, 0, 2, 10, false, 0, complain_overflow_dont,0,"LO10", false, 0,0x000003ff, false),
- HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, complain_overflow_bitfield,0,"SFA_BASE", false, 0,0xffffffff, false),
- HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, complain_overflow_bitfield,0,"SFA_OFF13",false, 0,0xffffffff, false),
- HOWTO(RELOC_BASE10, 0, 2, 10, false, 0, complain_overflow_dont,0,"BASE10", false, 0,0x000003ff, false),
- HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"BASE13", false, 0,0x00001fff, false),
- HOWTO(RELOC_BASE22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"BASE22", false, 0,0x003fffff, false),
- HOWTO(RELOC_PC10, 0, 2, 10, true, 0, complain_overflow_dont,0,"PC10", false, 0,0x000003ff, true),
- HOWTO(RELOC_PC22, 10, 2, 22, true, 0, complain_overflow_signed,0,"PC22", false, 0,0x003fffff, true),
- HOWTO(RELOC_JMP_TBL,2, 2, 30, true, 0, complain_overflow_signed,0,"JMP_TBL", false, 0,0x3fffffff, false),
- HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, complain_overflow_bitfield,0,"SEGOFF16", false, 0,0x00000000, false),
- HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"GLOB_DAT", false, 0,0x00000000, false),
- HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_SLOT", false, 0,0x00000000, false),
- HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
-};
-
-/* Convert standard reloc records to "arelent" format (incl byte swap). */
-
-reloc_howto_type howto_table_std[] = {
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
-HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
-HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
-HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
-HOWTO( 3, 0, 4, 64, false, 0, complain_overflow_bitfield,0,"64", true, 0xdeaddead,0xdeaddead, false),
-HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, false),
-HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, false),
-HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, false),
-HOWTO( 7, 0, 4, 64, true, 0, complain_overflow_signed, 0,"DISP64", true, 0xfeedface,0xfeedface, false),
-HOWTO( 8, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"GOT_REL", false, 0,0x00000000, false),
-HOWTO( 9, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"BASE16", false,0xffffffff,0xffffffff, false),
-HOWTO(10, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"BASE32", false,0xffffffff,0xffffffff, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
- HOWTO(16, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_TABLE", false, 0,0x00000000, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
- HOWTO(32, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
-{ -1 },
- HOWTO(40, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"BASEREL", false, 0,0x00000000, false),
-};
-
-#define TABLE_SIZE(TABLE) (sizeof(TABLE)/sizeof(TABLE[0]))
-
-reloc_howto_type *
-NAME(aout,reloc_type_lookup) (abfd,code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-#define EXT(i,j) case i: return &howto_table_ext[j]
-#define STD(i,j) case i: return &howto_table_std[j]
- int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- case 64:
- code = BFD_RELOC_64;
- break;
- }
- if (ext)
- switch (code)
- {
- EXT (BFD_RELOC_32, 2);
- EXT (BFD_RELOC_HI22, 8);
- EXT (BFD_RELOC_LO10, 11);
- EXT (BFD_RELOC_32_PCREL_S2, 6);
- EXT (BFD_RELOC_SPARC_WDISP22, 7);
- EXT (BFD_RELOC_SPARC13, 10);
- EXT (BFD_RELOC_SPARC_GOT10, 14);
- EXT (BFD_RELOC_SPARC_BASE13, 15);
- EXT (BFD_RELOC_SPARC_GOT13, 15);
- EXT (BFD_RELOC_SPARC_GOT22, 16);
- EXT (BFD_RELOC_SPARC_PC10, 17);
- EXT (BFD_RELOC_SPARC_PC22, 18);
- EXT (BFD_RELOC_SPARC_WPLT30, 19);
- default: return (reloc_howto_type *) NULL;
- }
- else
- /* std relocs */
- switch (code)
- {
- STD (BFD_RELOC_16, 1);
- STD (BFD_RELOC_32, 2);
- STD (BFD_RELOC_8_PCREL, 4);
- STD (BFD_RELOC_16_PCREL, 5);
- STD (BFD_RELOC_32_PCREL, 6);
- STD (BFD_RELOC_16_BASEREL, 9);
- STD (BFD_RELOC_32_BASEREL, 10);
- default: return (reloc_howto_type *) NULL;
- }
-}
-
-/*
-SUBSECTION
- Internal entry points
-
-DESCRIPTION
- @file{aoutx.h} exports several routines for accessing the
- contents of an a.out file, which are gathered and exported in
- turn by various format specific files (eg sunos.c).
-
-*/
-
-/*
-FUNCTION
- aout_@var{size}_swap_exec_header_in
-
-SYNOPSIS
- void aout_@var{size}_swap_exec_header_in,
- (bfd *abfd,
- struct external_exec *raw_bytes,
- struct internal_exec *execp);
-
-DESCRIPTION
- Swap the information in an executable header @var{raw_bytes} taken
- from a raw byte stream memory image into the internal exec header
- structure @var{execp}.
-*/
-
-#ifndef NAME_swap_exec_header_in
-void
-NAME(aout,swap_exec_header_in) (abfd, raw_bytes, execp)
- bfd *abfd;
- struct external_exec *raw_bytes;
- struct internal_exec *execp;
-{
- struct external_exec *bytes = (struct external_exec *)raw_bytes;
-
- /* The internal_exec structure has some fields that are unused in this
- configuration (IE for i960), so ensure that all such uninitialized
- fields are zero'd out. There are places where two of these structs
- are memcmp'd, and thus the contents do matter. */
- memset ((PTR) execp, 0, sizeof (struct internal_exec));
- /* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
- execp->a_text = GET_WORD (abfd, bytes->e_text);
- execp->a_data = GET_WORD (abfd, bytes->e_data);
- execp->a_bss = GET_WORD (abfd, bytes->e_bss);
- execp->a_syms = GET_WORD (abfd, bytes->e_syms);
- execp->a_entry = GET_WORD (abfd, bytes->e_entry);
- execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
- execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
-}
-#define NAME_swap_exec_header_in NAME(aout,swap_exec_header_in)
-#endif
-
-/*
-FUNCTION
- aout_@var{size}_swap_exec_header_out
-
-SYNOPSIS
- void aout_@var{size}_swap_exec_header_out
- (bfd *abfd,
- struct internal_exec *execp,
- struct external_exec *raw_bytes);
-
-DESCRIPTION
- Swap the information in an internal exec header structure
- @var{execp} into the buffer @var{raw_bytes} ready for writing to disk.
-*/
-void
-NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes)
- bfd *abfd;
- struct internal_exec *execp;
- struct external_exec *raw_bytes;
-{
- struct external_exec *bytes = (struct external_exec *)raw_bytes;
-
- /* Now fill in fields in the raw data, from the fields in the exec struct. */
- bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
- PUT_WORD (abfd, execp->a_text , bytes->e_text);
- PUT_WORD (abfd, execp->a_data , bytes->e_data);
- PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
- PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
- PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
- PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
- PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
-}
-
-/* Make all the section for an a.out file. */
-
-boolean
-NAME(aout,make_sections) (abfd)
- bfd *abfd;
-{
- if (obj_textsec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".text") == (asection *) NULL)
- return false;
- if (obj_datasec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".data") == (asection *) NULL)
- return false;
- if (obj_bsssec (abfd) == (asection *) NULL
- && bfd_make_section (abfd, ".bss") == (asection *) NULL)
- return false;
- return true;
-}
-
-/*
-FUNCTION
- aout_@var{size}_some_aout_object_p
-
-SYNOPSIS
- const bfd_target *aout_@var{size}_some_aout_object_p
- (bfd *abfd,
- const bfd_target *(*callback_to_real_object_p)());
-
-DESCRIPTION
- Some a.out variant thinks that the file open in @var{abfd}
- checking is an a.out file. Do some more checking, and set up
- for access if it really is. Call back to the calling
- environment's "finish up" function just before returning, to
- handle any last-minute setup.
-*/
-
-const bfd_target *
-NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
- bfd *abfd;
- struct internal_exec *execp;
- const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
-{
- struct aout_data_struct *rawptr, *oldrawptr;
- const bfd_target *result;
-
- rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
- if (rawptr == NULL)
- return 0;
-
- oldrawptr = abfd->tdata.aout_data;
- abfd->tdata.aout_data = rawptr;
-
- /* Copy the contents of the old tdata struct.
- In particular, we want the subformat, since for hpux it was set in
- hp300hpux.c:swap_exec_header_in and will be used in
- hp300hpux.c:callback. */
- if (oldrawptr != NULL)
- *abfd->tdata.aout_data = *oldrawptr;
-
- abfd->tdata.aout_data->a.hdr = &rawptr->e;
- *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec struct */
- execp = abfd->tdata.aout_data->a.hdr;
-
- /* Set the file flags */
- abfd->flags = NO_FLAGS;
- if (execp->a_drsize || execp->a_trsize)
- abfd->flags |= HAS_RELOC;
- /* Setting of EXEC_P has been deferred to the bottom of this function */
- if (execp->a_syms)
- abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
- if (N_DYNAMIC(*execp))
- abfd->flags |= DYNAMIC;
-
- if (N_MAGIC (*execp) == ZMAGIC)
- {
- abfd->flags |= D_PAGED | WP_TEXT;
- adata (abfd).magic = z_magic;
- }
- else if (N_MAGIC (*execp) == QMAGIC)
- {
- abfd->flags |= D_PAGED | WP_TEXT;
- adata (abfd).magic = z_magic;
- adata (abfd).subformat = q_magic_format;
- }
- else if (N_MAGIC (*execp) == NMAGIC)
- {
- abfd->flags |= WP_TEXT;
- adata (abfd).magic = n_magic;
- }
- else if (N_MAGIC (*execp) == OMAGIC
- || N_MAGIC (*execp) == BMAGIC)
- adata (abfd).magic = o_magic;
- else
- {
- /* Should have been checked with N_BADMAG before this routine
- was called. */
- abort ();
- }
-
- bfd_get_start_address (abfd) = execp->a_entry;
-
- obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
- bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
-
- /* The default relocation entry size is that of traditional V7 Unix. */
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-
- /* The default symbol entry size is that of traditional Unix. */
- obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
-
-#ifdef USE_MMAP
- bfd_init_window (&obj_aout_sym_window (abfd));
- bfd_init_window (&obj_aout_string_window (abfd));
-#endif
- obj_aout_external_syms (abfd) = NULL;
- obj_aout_external_strings (abfd) = NULL;
- obj_aout_sym_hashes (abfd) = NULL;
-
- if (! NAME(aout,make_sections) (abfd))
- return NULL;
-
- obj_datasec (abfd)->_raw_size = execp->a_data;
- obj_bsssec (abfd)->_raw_size = execp->a_bss;
-
- obj_textsec (abfd)->flags =
- (execp->a_trsize != 0
- ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
- : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
- obj_datasec (abfd)->flags =
- (execp->a_drsize != 0
- ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
- : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
- obj_bsssec (abfd)->flags = SEC_ALLOC;
-
-#ifdef THIS_IS_ONLY_DOCUMENTATION
- /* The common code can't fill in these things because they depend
- on either the start address of the text segment, the rounding
- up of virtual addresses between segments, or the starting file
- position of the text segment -- all of which varies among different
- versions of a.out. */
-
- /* Call back to the format-dependent code to fill in the rest of the
- fields and do any further cleanup. Things that should be filled
- in by the callback: */
-
- struct exec *execp = exec_hdr (abfd);
-
- obj_textsec (abfd)->size = N_TXTSIZE(*execp);
- obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);
- /* data and bss are already filled in since they're so standard */
-
- /* The virtual memory addresses of the sections */
- obj_textsec (abfd)->vma = N_TXTADDR(*execp);
- obj_datasec (abfd)->vma = N_DATADDR(*execp);
- obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
-
- /* The file offsets of the sections */
- obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
- obj_datasec (abfd)->filepos = N_DATOFF(*execp);
-
- /* The file offsets of the relocation info */
- obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
- obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
-
- /* The file offsets of the string table and symbol table. */
- obj_str_filepos (abfd) = N_STROFF (*execp);
- obj_sym_filepos (abfd) = N_SYMOFF (*execp);
-
- /* Determine the architecture and machine type of the object file. */
- switch (N_MACHTYPE (*exec_hdr (abfd))) {
- default:
- abfd->obj_arch = bfd_arch_obscure;
- break;
- }
-
- adata(abfd)->page_size = TARGET_PAGE_SIZE;
- adata(abfd)->segment_size = SEGMENT_SIZE;
- adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
-
- return abfd->xvec;
-
- /* The architecture is encoded in various ways in various a.out variants,
- or is not encoded at all in some of them. The relocation size depends
- on the architecture and the a.out variant. Finally, the return value
- is the bfd_target vector in use. If an error occurs, return zero and
- set bfd_error to the appropriate error code.
-
- Formats such as b.out, which have additional fields in the a.out
- header, should cope with them in this callback as well. */
-#endif /* DOCUMENTATION */
-
- result = (*callback_to_real_object_p)(abfd);
-
- /* Now that the segment addresses have been worked out, take a better
- guess at whether the file is executable. If the entry point
- is within the text segment, assume it is. (This makes files
- executable even if their entry point address is 0, as long as
- their text starts at zero.). */
- if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
- (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
- abfd->flags |= EXEC_P;
-#ifdef STAT_FOR_EXEC
- else
- {
- struct stat stat_buf;
-
- /* The original heuristic doesn't work in some important cases.
- The a.out file has no information about the text start
- address. For files (like kernels) linked to non-standard
- addresses (ld -Ttext nnn) the entry point may not be between
- the default text start (obj_textsec(abfd)->vma) and
- (obj_textsec(abfd)->vma) + text size. This is not just a mach
- issue. Many kernels are loaded at non standard addresses. */
- if (abfd->iostream != NULL
- && (abfd->flags & BFD_IN_MEMORY) == 0
- && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
- && ((stat_buf.st_mode & 0111) != 0))
- abfd->flags |= EXEC_P;
- }
-#endif /* STAT_FOR_EXEC */
-
- if (result)
- {
-#if 0 /* These should be set correctly anyways. */
- abfd->sections = obj_textsec (abfd);
- obj_textsec (abfd)->next = obj_datasec (abfd);
- obj_datasec (abfd)->next = obj_bsssec (abfd);
-#endif
- }
- else
- {
- free (rawptr);
- abfd->tdata.aout_data = oldrawptr;
- }
- return result;
-}
-
-/*
-FUNCTION
- aout_@var{size}_mkobject
-
-SYNOPSIS
- boolean aout_@var{size}_mkobject, (bfd *abfd);
-
-DESCRIPTION
- Initialize BFD @var{abfd} for use with a.out files.
-*/
-
-boolean
-NAME(aout,mkobject) (abfd)
- bfd *abfd;
-{
- struct aout_data_struct *rawptr;
-
- bfd_set_error (bfd_error_system_call);
-
- /* Use an intermediate variable for clarity */
- rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
-
- if (rawptr == NULL)
- return false;
-
- abfd->tdata.aout_data = rawptr;
- exec_hdr (abfd) = &(rawptr->e);
-
- obj_textsec (abfd) = (asection *)NULL;
- obj_datasec (abfd) = (asection *)NULL;
- obj_bsssec (abfd) = (asection *)NULL;
-
- return true;
-}
-
-
-/*
-FUNCTION
- aout_@var{size}_machine_type
-
-SYNOPSIS
- enum machine_type aout_@var{size}_machine_type
- (enum bfd_architecture arch,
- unsigned long machine));
-
-DESCRIPTION
- Keep track of machine architecture and machine type for
- a.out's. Return the <<machine_type>> for a particular
- architecture and machine, or <<M_UNKNOWN>> if that exact architecture
- and machine can't be represented in a.out format.
-
- If the architecture is understood, machine type 0 (default)
- is always understood.
-*/
-
-enum machine_type
-NAME(aout,machine_type) (arch, machine, unknown)
- enum bfd_architecture arch;
- unsigned long machine;
- boolean *unknown;
-{
- enum machine_type arch_flags;
-
- arch_flags = M_UNKNOWN;
- *unknown = true;
-
- switch (arch) {
- case bfd_arch_sparc:
- if (machine == 0
- || machine == bfd_mach_sparc
- || machine == bfd_mach_sparc_v9)
- arch_flags = M_SPARC;
- break;
-
- case bfd_arch_m68k:
- switch (machine) {
- case 0: arch_flags = M_68010; break;
- case 68000: arch_flags = M_UNKNOWN; *unknown = false; break;
- case 68010: arch_flags = M_68010; break;
- case 68020: arch_flags = M_68020; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_i386:
- if (machine == 0) arch_flags = M_386;
- break;
-
- case bfd_arch_a29k:
- if (machine == 0) arch_flags = M_29K;
- break;
-
- case bfd_arch_arm:
- if (machine == 0) arch_flags = M_ARM;
- break;
-
- case bfd_arch_mips:
- switch (machine) {
- case 0:
- case 2000:
- case 3000: arch_flags = M_MIPS1; break;
- case 4000: /* mips3 */
- case 4400:
- case 8000: /* mips4 */
- /* real mips2: */
- case 6000: arch_flags = M_MIPS2; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_ns32k:
- switch (machine) {
- case 0: arch_flags = M_NS32532; break;
- case 32032: arch_flags = M_NS32032; break;
- case 32532: arch_flags = M_NS32532; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
-
- case bfd_arch_vax:
- *unknown = false;
- break;
-
-
- default:
- arch_flags = M_UNKNOWN;
- }
-
- if (arch_flags != M_UNKNOWN)
- *unknown = false;
-
- return arch_flags;
-}
-
-
-/*
-FUNCTION
- aout_@var{size}_set_arch_mach
-
-SYNOPSIS
- boolean aout_@var{size}_set_arch_mach,
- (bfd *,
- enum bfd_architecture arch,
- unsigned long machine));
-
-DESCRIPTION
- Set the architecture and the machine of the BFD @var{abfd} to the
- values @var{arch} and @var{machine}. Verify that @var{abfd}'s format
- can support the architecture required.
-*/
-
-boolean
-NAME(aout,set_arch_mach) (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- if (! bfd_default_set_arch_mach (abfd, arch, machine))
- return false;
-
- if (arch != bfd_arch_unknown)
- {
- boolean unknown;
-
- NAME(aout,machine_type) (arch, machine, &unknown);
- if (unknown)
- return false;
- }
-
- /* Determine the size of a relocation entry */
- switch (arch) {
- case bfd_arch_sparc:
- case bfd_arch_a29k:
- case bfd_arch_mips:
- obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
- break;
- default:
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
- break;
- }
-
- return (*aout_backend_info(abfd)->set_sizes) (abfd);
-}
-
-static void
-adjust_o_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- file_ptr pos = adata (abfd).exec_bytes_size;
- bfd_vma vma = 0;
- int pad = 0;
-
- /* Text. */
- obj_textsec(abfd)->filepos = pos;
- if (!obj_textsec(abfd)->user_set_vma)
- obj_textsec(abfd)->vma = vma;
- else
- vma = obj_textsec(abfd)->vma;
-
- pos += obj_textsec(abfd)->_raw_size;
- vma += obj_textsec(abfd)->_raw_size;
-
- /* Data. */
- if (!obj_datasec(abfd)->user_set_vma)
- {
-#if 0 /* ?? Does alignment in the file image really matter? */
- pad = align_power (vma, obj_datasec(abfd)->alignment_power) - vma;
-#endif
- obj_textsec(abfd)->_raw_size += pad;
- pos += pad;
- vma += pad;
- obj_datasec(abfd)->vma = vma;
- }
- else
- vma = obj_datasec(abfd)->vma;
- obj_datasec(abfd)->filepos = pos;
- pos += obj_datasec(abfd)->_raw_size;
- vma += obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- {
-#if 0
- pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
-#endif
- obj_datasec(abfd)->_raw_size += pad;
- pos += pad;
- vma += pad;
- obj_bsssec(abfd)->vma = vma;
- }
- else
- {
- /* The VMA of the .bss section is set by the the VMA of the
- .data section plus the size of the .data section. We may
- need to add padding bytes to make this true. */
- pad = obj_bsssec (abfd)->vma - vma;
- if (pad > 0)
- {
- obj_datasec (abfd)->_raw_size += pad;
- pos += pad;
- }
- }
- obj_bsssec(abfd)->filepos = pos;
-
- /* Fix up the exec header. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- execp->a_data = obj_datasec(abfd)->_raw_size;
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
- N_SET_MAGIC (*execp, OMAGIC);
-}
-
-static void
-adjust_z_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- bfd_size_type data_pad, text_pad;
- file_ptr text_end;
- CONST struct aout_backend_data *abdp;
- int ztih; /* Nonzero if text includes exec header. */
-
- abdp = aout_backend_info (abfd);
-
- /* Text. */
- ztih = (abdp != NULL
- && (abdp->text_includes_header
- || obj_aout_subformat (abfd) == q_magic_format));
- obj_textsec(abfd)->filepos = (ztih
- ? adata(abfd).exec_bytes_size
- : adata(abfd).zmagic_disk_block_size);
- if (! obj_textsec(abfd)->user_set_vma)
- {
- /* ?? Do we really need to check for relocs here? */
- obj_textsec(abfd)->vma = ((abfd->flags & HAS_RELOC)
- ? 0
- : (ztih
- ? (abdp->default_text_vma
- + adata(abfd).exec_bytes_size)
- : abdp->default_text_vma));
- text_pad = 0;
- }
- else
- {
- /* The .text section is being loaded at an unusual address. We
- may need to pad it such that the .data section starts at a page
- boundary. */
- if (ztih)
- text_pad = ((obj_textsec (abfd)->filepos - obj_textsec (abfd)->vma)
- & (adata (abfd).page_size - 1));
- else
- text_pad = ((- obj_textsec (abfd)->vma)
- & (adata (abfd).page_size - 1));
- }
-
- /* Find start of data. */
- if (ztih)
- {
- text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size;
- text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
- }
- else
- {
- /* Note that if page_size == zmagic_disk_block_size, then
- filepos == page_size, and this case is the same as the ztih
- case. */
- text_end = obj_textsec (abfd)->_raw_size;
- text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
- text_end += obj_textsec (abfd)->filepos;
- }
- obj_textsec(abfd)->_raw_size += text_pad;
- text_end += text_pad;
-
- /* Data. */
- if (!obj_datasec(abfd)->user_set_vma)
- {
- bfd_vma vma;
- vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size;
- obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
- }
- if (abdp && abdp->zmagic_mapped_contiguous)
- {
- text_pad = (obj_datasec(abfd)->vma
- - obj_textsec(abfd)->vma
- - obj_textsec(abfd)->_raw_size);
- obj_textsec(abfd)->_raw_size += text_pad;
- }
- obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
- + obj_textsec(abfd)->_raw_size);
-
- /* Fix up exec header while we're at it. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
- execp->a_text += adata(abfd).exec_bytes_size;
- if (obj_aout_subformat (abfd) == q_magic_format)
- N_SET_MAGIC (*execp, QMAGIC);
- else
- N_SET_MAGIC (*execp, ZMAGIC);
-
- /* Spec says data section should be rounded up to page boundary. */
- obj_datasec(abfd)->_raw_size
- = align_power (obj_datasec(abfd)->_raw_size,
- obj_bsssec(abfd)->alignment_power);
- execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size,
- adata(abfd).page_size);
- data_pad = execp->a_data - obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma
- + obj_datasec(abfd)->_raw_size);
- /* If the BSS immediately follows the data section and extra space
- in the page is left after the data section, fudge data
- in the header so that the bss section looks smaller by that
- amount. We'll start the bss section there, and lie to the OS.
- (Note that a linker script, as well as the above assignment,
- could have explicitly set the BSS vma to immediately follow
- the data section.) */
- if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power)
- == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size)
- execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 :
- obj_bsssec(abfd)->_raw_size - data_pad;
- else
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
-}
-
-static void
-adjust_n_magic (abfd, execp)
- bfd *abfd;
- struct internal_exec *execp;
-{
- file_ptr pos = adata(abfd).exec_bytes_size;
- bfd_vma vma = 0;
- int pad;
-
- /* Text. */
- obj_textsec(abfd)->filepos = pos;
- if (!obj_textsec(abfd)->user_set_vma)
- obj_textsec(abfd)->vma = vma;
- else
- vma = obj_textsec(abfd)->vma;
- pos += obj_textsec(abfd)->_raw_size;
- vma += obj_textsec(abfd)->_raw_size;
-
- /* Data. */
- obj_datasec(abfd)->filepos = pos;
- if (!obj_datasec(abfd)->user_set_vma)
- obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
- vma = obj_datasec(abfd)->vma;
-
- /* Since BSS follows data immediately, see if it needs alignment. */
- vma += obj_datasec(abfd)->_raw_size;
- pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
- obj_datasec(abfd)->_raw_size += pad;
- pos += obj_datasec(abfd)->_raw_size;
-
- /* BSS. */
- if (!obj_bsssec(abfd)->user_set_vma)
- obj_bsssec(abfd)->vma = vma;
- else
- vma = obj_bsssec(abfd)->vma;
-
- /* Fix up exec header. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- execp->a_data = obj_datasec(abfd)->_raw_size;
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
- N_SET_MAGIC (*execp, NMAGIC);
-}
-
-boolean
-NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
- bfd *abfd;
- bfd_size_type *text_size;
- file_ptr *text_end;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- if (! NAME(aout,make_sections) (abfd))
- return false;
-
- if (adata(abfd).magic != undecided_magic)
- return true;
-
- obj_textsec(abfd)->_raw_size =
- align_power(obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->alignment_power);
-
- *text_size = obj_textsec (abfd)->_raw_size;
- /* Rule (heuristic) for when to pad to a new page. Note that there
- are (at least) two ways demand-paged (ZMAGIC) files have been
- handled. Most Berkeley-based systems start the text segment at
- (TARGET_PAGE_SIZE). However, newer versions of SUNOS start the text
- segment right after the exec header; the latter is counted in the
- text segment size, and is paged in by the kernel with the rest of
- the text. */
-
- /* This perhaps isn't the right way to do this, but made it simpler for me
- to understand enough to implement it. Better would probably be to go
- right from BFD flags to alignment/positioning characteristics. But the
- old code was sloppy enough about handling the flags, and had enough
- other magic, that it was a little hard for me to understand. I think
- I understand it better now, but I haven't time to do the cleanup this
- minute. */
-
- if (abfd->flags & D_PAGED)
- /* Whether or not WP_TEXT is set -- let D_PAGED override. */
- adata(abfd).magic = z_magic;
- else if (abfd->flags & WP_TEXT)
- adata(abfd).magic = n_magic;
- else
- adata(abfd).magic = o_magic;
-
-#ifdef BFD_AOUT_DEBUG /* requires gcc2 */
-#if __GNUC__ >= 2
- fprintf (stderr, "%s text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x,%x>\n",
- ({ char *str;
- switch (adata(abfd).magic) {
- case n_magic: str = "NMAGIC"; break;
- case o_magic: str = "OMAGIC"; break;
- case z_magic: str = "ZMAGIC"; break;
- default: abort ();
- }
- str;
- }),
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->alignment_power,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
- obj_datasec(abfd)->alignment_power,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size,
- obj_bsssec(abfd)->alignment_power);
-#endif
-#endif
-
- switch (adata(abfd).magic)
- {
- case o_magic:
- adjust_o_magic (abfd, execp);
- break;
- case z_magic:
- adjust_z_magic (abfd, execp);
- break;
- case n_magic:
- adjust_n_magic (abfd, execp);
- break;
- default:
- abort ();
- }
-
-#ifdef BFD_AOUT_DEBUG
- fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
- obj_textsec(abfd)->filepos,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
- obj_datasec(abfd)->filepos,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size);
-#endif
-
- return true;
-}
-
-/*
-FUNCTION
- aout_@var{size}_new_section_hook
-
-SYNOPSIS
- boolean aout_@var{size}_new_section_hook,
- (bfd *abfd,
- asection *newsect));
-
-DESCRIPTION
- Called by the BFD in response to a @code{bfd_make_section}
- request.
-*/
-boolean
-NAME(aout,new_section_hook) (abfd, newsect)
- bfd *abfd;
- asection *newsect;
-{
- /* align to double at least */
- newsect->alignment_power = bfd_get_arch_info(abfd)->section_align_power;
-
-
- if (bfd_get_format (abfd) == bfd_object)
- {
- if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) {
- obj_textsec(abfd)= newsect;
- newsect->target_index = N_TEXT;
- return true;
- }
-
- if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) {
- obj_datasec(abfd) = newsect;
- newsect->target_index = N_DATA;
- return true;
- }
-
- if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) {
- obj_bsssec(abfd) = newsect;
- newsect->target_index = N_BSS;
- return true;
- }
-
- }
-
- /* We allow more than three sections internally */
- return true;
-}
-
-boolean
-NAME(aout,set_section_contents) (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- file_ptr text_end;
- bfd_size_type text_size;
-
- if (! abfd->output_has_begun)
- {
- if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
- return false;
- }
-
- if (section == obj_bsssec (abfd))
- {
- bfd_set_error (bfd_error_no_contents);
- return false;
- }
-
- if (section != obj_textsec (abfd)
- && section != obj_datasec (abfd))
- {
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- if (count != 0)
- {
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
- }
-
- return true;
-}
-
-/* Read the external symbols from an a.out file. */
-
-static boolean
-aout_get_external_symbols (abfd)
- bfd *abfd;
-{
- if (obj_aout_external_syms (abfd) == (struct external_nlist *) NULL)
- {
- bfd_size_type count;
- struct external_nlist *syms;
-
- count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
-
-#ifdef USE_MMAP
- if (bfd_get_file_window (abfd,
- obj_sym_filepos (abfd), exec_hdr (abfd)->a_syms,
- &obj_aout_sym_window (abfd), true) == false)
- return false;
- syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
-#else
- /* We allocate using malloc to make the values easy to free
- later on. If we put them on the obstack it might not be
- possible to free them. */
- syms = ((struct external_nlist *)
- bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
- if (syms == (struct external_nlist *) NULL && count != 0)
- return false;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
- != exec_hdr (abfd)->a_syms))
- {
- free (syms);
- return false;
- }
-#endif
-
- obj_aout_external_syms (abfd) = syms;
- obj_aout_external_sym_count (abfd) = count;
- }
-
- if (obj_aout_external_strings (abfd) == NULL
- && exec_hdr (abfd)->a_syms != 0)
- {
- unsigned char string_chars[BYTES_IN_WORD];
- bfd_size_type stringsize;
- char *strings;
-
- /* Get the size of the strings. */
- if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
- || (bfd_read ((PTR) string_chars, BYTES_IN_WORD, 1, abfd)
- != BYTES_IN_WORD))
- return false;
- stringsize = GET_WORD (abfd, string_chars);
-
-#ifdef USE_MMAP
- if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
- &obj_aout_string_window (abfd), true) == false)
- return false;
- strings = (char *) obj_aout_string_window (abfd).data;
-#else
- strings = (char *) bfd_malloc ((size_t) stringsize + 1);
- if (strings == NULL)
- return false;
-
- /* Skip space for the string count in the buffer for convenience
- when using indexes. */
- if (bfd_read (strings + BYTES_IN_WORD, 1, stringsize - BYTES_IN_WORD,
- abfd)
- != stringsize - BYTES_IN_WORD)
- {
- free (strings);
- return false;
- }
-#endif
-
- /* Ensure that a zero index yields an empty string. */
- strings[0] = '\0';
-
- strings[stringsize - 1] = 0;
-
- obj_aout_external_strings (abfd) = strings;
- obj_aout_external_string_size (abfd) = stringsize;
- }
-
- return true;
-}
-
-/* Translate an a.out symbol into a BFD symbol. The desc, other, type
- and symbol->value fields of CACHE_PTR will be set from the a.out
- nlist structure. This function is responsible for setting
- symbol->flags and symbol->section, and adjusting symbol->value. */
-
-static boolean
-translate_from_native_sym_flags (abfd, cache_ptr)
- bfd *abfd;
- aout_symbol_type *cache_ptr;
-{
- flagword visible;
-
- if ((cache_ptr->type & N_STAB) != 0
- || cache_ptr->type == N_FN)
- {
- asection *sec;
-
- /* This is a debugging symbol. */
-
- cache_ptr->symbol.flags = BSF_DEBUGGING;
-
- /* Work out the symbol section. */
- switch (cache_ptr->type & N_TYPE)
- {
- case N_TEXT:
- case N_FN:
- sec = obj_textsec (abfd);
- break;
- case N_DATA:
- sec = obj_datasec (abfd);
- break;
- case N_BSS:
- sec = obj_bsssec (abfd);
- break;
- default:
- case N_ABS:
- sec = bfd_abs_section_ptr;
- break;
- }
-
- cache_ptr->symbol.section = sec;
- cache_ptr->symbol.value -= sec->vma;
-
- return true;
- }
-
- /* Get the default visibility. This does not apply to all types, so
- we just hold it in a local variable to use if wanted. */
- if ((cache_ptr->type & N_EXT) == 0)
- visible = BSF_LOCAL;
- else
- visible = BSF_GLOBAL;
-
- switch (cache_ptr->type)
- {
- default:
- case N_ABS: case N_ABS | N_EXT:
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_UNDF | N_EXT:
- if (cache_ptr->symbol.value != 0)
- {
- /* This is a common symbol. */
- cache_ptr->symbol.flags = BSF_GLOBAL;
- cache_ptr->symbol.section = bfd_com_section_ptr;
- }
- else
- {
- cache_ptr->symbol.flags = 0;
- cache_ptr->symbol.section = bfd_und_section_ptr;
- }
- break;
-
- case N_TEXT: case N_TEXT | N_EXT:
- cache_ptr->symbol.section = obj_textsec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- /* N_SETV symbols used to represent set vectors placed in the
- data section. They are no longer generated. Theoretically,
- it was possible to extract the entries and combine them with
- new ones, although I don't know if that was ever actually
- done. Unless that feature is restored, treat them as data
- symbols. */
- case N_SETV: case N_SETV | N_EXT:
- case N_DATA: case N_DATA | N_EXT:
- cache_ptr->symbol.section = obj_datasec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_BSS: case N_BSS | N_EXT:
- cache_ptr->symbol.section = obj_bsssec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = visible;
- break;
-
- case N_SETA: case N_SETA | N_EXT:
- case N_SETT: case N_SETT | N_EXT:
- case N_SETD: case N_SETD | N_EXT:
- case N_SETB: case N_SETB | N_EXT:
- {
- asection *section;
- arelent_chain *reloc;
- asection *into_section;
-
- /* This is a set symbol. The name of the symbol is the name
- of the set (e.g., __CTOR_LIST__). The value of the symbol
- is the value to add to the set. We create a section with
- the same name as the symbol, and add a reloc to insert the
- appropriate value into the section.
-
- This action is actually obsolete; it used to make the
- linker do the right thing, but the linker no longer uses
- this function. */
-
- section = bfd_get_section_by_name (abfd, cache_ptr->symbol.name);
- if (section == NULL)
- {
- char *copy;
-
- copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
- if (copy == NULL)
- return false;
-
- strcpy (copy, cache_ptr->symbol.name);
- section = bfd_make_section (abfd, copy);
- if (section == NULL)
- return false;
- }
-
- reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
- if (reloc == NULL)
- return false;
-
- /* Build a relocation entry for the constructor. */
- switch (cache_ptr->type & N_TYPE)
- {
- case N_SETA:
- into_section = bfd_abs_section_ptr;
- cache_ptr->type = N_ABS;
- break;
- case N_SETT:
- into_section = obj_textsec (abfd);
- cache_ptr->type = N_TEXT;
- break;
- case N_SETD:
- into_section = obj_datasec (abfd);
- cache_ptr->type = N_DATA;
- break;
- case N_SETB:
- into_section = obj_bsssec (abfd);
- cache_ptr->type = N_BSS;
- break;
- }
-
- /* Build a relocation pointing into the constructor section
- pointing at the symbol in the set vector specified. */
- reloc->relent.addend = cache_ptr->symbol.value;
- cache_ptr->symbol.section = into_section;
- reloc->relent.sym_ptr_ptr = into_section->symbol_ptr_ptr;
-
- /* We modify the symbol to belong to a section depending upon
- the name of the symbol, and add to the size of the section
- to contain a pointer to the symbol. Build a reloc entry to
- relocate to this symbol attached to this section. */
- section->flags = SEC_CONSTRUCTOR | SEC_RELOC;
-
- section->reloc_count++;
- section->alignment_power = 2;
-
- reloc->next = section->constructor_chain;
- section->constructor_chain = reloc;
- reloc->relent.address = section->_raw_size;
- section->_raw_size += BYTES_IN_WORD;
-
- reloc->relent.howto = CTOR_TABLE_RELOC_HOWTO(abfd);
-
- cache_ptr->symbol.flags |= BSF_CONSTRUCTOR;
- }
- break;
-
- case N_WARNING:
- /* This symbol is the text of a warning message. The next
- symbol is the symbol to associate the warning with. If a
- reference is made to that symbol, a warning is issued. */
- cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING;
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- break;
-
- case N_INDR: case N_INDR | N_EXT:
- /* An indirect symbol. This consists of two symbols in a row.
- The first symbol is the name of the indirection. The second
- symbol is the name of the target. A reference to the first
- symbol becomes a reference to the second. */
- cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_INDIRECT | visible;
- cache_ptr->symbol.section = bfd_ind_section_ptr;
- break;
-
- case N_WEAKU:
- cache_ptr->symbol.section = bfd_und_section_ptr;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKA:
- cache_ptr->symbol.section = bfd_abs_section_ptr;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKT:
- cache_ptr->symbol.section = obj_textsec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKD:
- cache_ptr->symbol.section = obj_datasec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
-
- case N_WEAKB:
- cache_ptr->symbol.section = obj_bsssec (abfd);
- cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
- cache_ptr->symbol.flags = BSF_WEAK;
- break;
- }
-
- return true;
-}
-
-/* Set the fields of SYM_POINTER according to CACHE_PTR. */
-
-static boolean
-translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
- bfd *abfd;
- asymbol *cache_ptr;
- struct external_nlist *sym_pointer;
-{
- bfd_vma value = cache_ptr->value;
- asection *sec;
- bfd_vma off;
-
- /* Mask out any existing type bits in case copying from one section
- to another. */
- sym_pointer->e_type[0] &= ~N_TYPE;
-
- sec = bfd_get_section (cache_ptr);
- off = 0;
-
- if (sec == NULL)
- {
- /* This case occurs, e.g., for the *DEBUG* section of a COFF
- file. */
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- if (sec->output_section != NULL)
- {
- off = sec->output_offset;
- sec = sec->output_section;
- }
-
- if (bfd_is_abs_section (sec))
- sym_pointer->e_type[0] |= N_ABS;
- else if (sec == obj_textsec (abfd))
- sym_pointer->e_type[0] |= N_TEXT;
- else if (sec == obj_datasec (abfd))
- sym_pointer->e_type[0] |= N_DATA;
- else if (sec == obj_bsssec (abfd))
- sym_pointer->e_type[0] |= N_BSS;
- else if (bfd_is_und_section (sec))
- sym_pointer->e_type[0] = N_UNDF | N_EXT;
- else if (bfd_is_ind_section (sec))
- sym_pointer->e_type[0] = N_INDR;
- else if (bfd_is_com_section (sec))
- sym_pointer->e_type[0] = N_UNDF | N_EXT;
- else
- {
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in a.out object file format",
- bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- /* Turn the symbol from section relative to absolute again */
- value += sec->vma + off;
-
- if ((cache_ptr->flags & BSF_WARNING) != 0)
- sym_pointer->e_type[0] = N_WARNING;
-
- if ((cache_ptr->flags & BSF_DEBUGGING) != 0)
- sym_pointer->e_type[0] = ((aout_symbol_type *) cache_ptr)->type;
- else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
- sym_pointer->e_type[0] |= N_EXT;
-
- if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
- {
- int type = ((aout_symbol_type *) cache_ptr)->type;
- switch (type)
- {
- case N_ABS: type = N_SETA; break;
- case N_TEXT: type = N_SETT; break;
- case N_DATA: type = N_SETD; break;
- case N_BSS: type = N_SETB; break;
- }
- sym_pointer->e_type[0] = type;
- }
-
- if ((cache_ptr->flags & BSF_WEAK) != 0)
- {
- int type;
-
- switch (sym_pointer->e_type[0] & N_TYPE)
- {
- default:
- case N_ABS: type = N_WEAKA; break;
- case N_TEXT: type = N_WEAKT; break;
- case N_DATA: type = N_WEAKD; break;
- case N_BSS: type = N_WEAKB; break;
- case N_UNDF: type = N_WEAKU; break;
- }
- sym_pointer->e_type[0] = type;
- }
-
- PUT_WORD(abfd, value, sym_pointer->e_value);
-
- return true;
-}
-
-/* Native-level interface to symbols. */
-
-asymbol *
-NAME(aout,make_empty_symbol) (abfd)
- bfd *abfd;
-{
- aout_symbol_type *new =
- (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
- if (!new)
- return NULL;
- new->symbol.the_bfd = abfd;
-
- return &new->symbol;
-}
-
-/* Translate a set of internal symbols into external symbols. */
-
-boolean
-NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
- bfd *abfd;
- aout_symbol_type *in;
- struct external_nlist *ext;
- bfd_size_type count;
- char *str;
- bfd_size_type strsize;
- boolean dynamic;
-{
- struct external_nlist *ext_end;
-
- ext_end = ext + count;
- for (; ext < ext_end; ext++, in++)
- {
- bfd_vma x;
-
- x = GET_WORD (abfd, ext->e_strx);
- in->symbol.the_bfd = abfd;
-
- /* For the normal symbols, the zero index points at the number
- of bytes in the string table but is to be interpreted as the
- null string. For the dynamic symbols, the number of bytes in
- the string table is stored in the __DYNAMIC structure and the
- zero index points at an actual string. */
- if (x == 0 && ! dynamic)
- in->symbol.name = "";
- else if (x < strsize)
- in->symbol.name = str + x;
- else
- return false;
-
- in->symbol.value = GET_SWORD (abfd, ext->e_value);
- in->desc = bfd_h_get_16 (abfd, ext->e_desc);
- in->other = bfd_h_get_8 (abfd, ext->e_other);
- in->type = bfd_h_get_8 (abfd, ext->e_type);
- in->symbol.udata.p = NULL;
-
- if (! translate_from_native_sym_flags (abfd, in))
- return false;
-
- if (dynamic)
- in->symbol.flags |= BSF_DYNAMIC;
- }
-
- return true;
-}
-
-/* We read the symbols into a buffer, which is discarded when this
- function exits. We read the strings into a buffer large enough to
- hold them all plus all the cached symbol entries. */
-
-boolean
-NAME(aout,slurp_symbol_table) (abfd)
- bfd *abfd;
-{
- struct external_nlist *old_external_syms;
- aout_symbol_type *cached;
- size_t cached_size;
-
- /* If there's no work to be done, don't do any */
- if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
- return true;
-
- old_external_syms = obj_aout_external_syms (abfd);
-
- if (! aout_get_external_symbols (abfd))
- return false;
-
- cached_size = (obj_aout_external_sym_count (abfd)
- * sizeof (aout_symbol_type));
- cached = (aout_symbol_type *) bfd_malloc (cached_size);
- if (cached == NULL && cached_size != 0)
- return false;
- if (cached_size != 0)
- memset (cached, 0, cached_size);
-
- /* Convert from external symbol information to internal. */
- if (! (NAME(aout,translate_symbol_table)
- (abfd, cached,
- obj_aout_external_syms (abfd),
- obj_aout_external_sym_count (abfd),
- obj_aout_external_strings (abfd),
- obj_aout_external_string_size (abfd),
- false)))
- {
- free (cached);
- return false;
- }
-
- bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
-
- obj_aout_symbols (abfd) = cached;
-
- /* It is very likely that anybody who calls this function will not
- want the external symbol information, so if it was allocated
- because of our call to aout_get_external_symbols, we free it up
- right away to save space. */
- if (old_external_syms == (struct external_nlist *) NULL
- && obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_sym_window (abfd));
-#else
- free (obj_aout_external_syms (abfd));
-#endif
- obj_aout_external_syms (abfd) = NULL;
- }
-
- return true;
-}
-
-/* We use a hash table when writing out symbols so that we only write
- out a particular string once. This helps particularly when the
- linker writes out stabs debugging entries, because each different
- contributing object file tends to have many duplicate stabs
- strings.
-
- This hash table code breaks dbx on SunOS 4.1.3, so we don't do it
- if BFD_TRADITIONAL_FORMAT is set. */
-
-static bfd_size_type add_to_stringtab
- PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, boolean));
-static boolean emit_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *));
-
-/* Get the index of a string in a strtab, adding it if it is not
- already present. */
-
-static INLINE bfd_size_type
-add_to_stringtab (abfd, tab, str, copy)
- bfd *abfd;
- struct bfd_strtab_hash *tab;
- const char *str;
- boolean copy;
-{
- boolean hash;
- bfd_size_type index;
-
- /* An index of 0 always means the empty string. */
- if (str == 0 || *str == '\0')
- return 0;
-
- /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx
- doesn't understand a hashed string table. */
- hash = true;
- if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
-
- index = _bfd_stringtab_add (tab, str, hash, copy);
-
- if (index != (bfd_size_type) -1)
- {
- /* Add BYTES_IN_WORD to the return value to account for the
- space taken up by the string table size. */
- index += BYTES_IN_WORD;
- }
-
- return index;
-}
-
-/* Write out a strtab. ABFD is already at the right location in the
- file. */
-
-static boolean
-emit_stringtab (abfd, tab)
- register bfd *abfd;
- struct bfd_strtab_hash *tab;
-{
- bfd_byte buffer[BYTES_IN_WORD];
-
- /* The string table starts with the size. */
- PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
- if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
- return false;
-
- return _bfd_stringtab_emit (abfd, tab);
-}
-
-boolean
-NAME(aout,write_syms) (abfd)
- bfd *abfd;
-{
- unsigned int count ;
- asymbol **generic = bfd_get_outsymbols (abfd);
- struct bfd_strtab_hash *strtab;
-
- strtab = _bfd_stringtab_init ();
- if (strtab == NULL)
- return false;
-
- for (count = 0; count < bfd_get_symcount (abfd); count++)
- {
- asymbol *g = generic[count];
- bfd_size_type indx;
- struct external_nlist nsp;
-
- indx = add_to_stringtab (abfd, strtab, g->name, false);
- if (indx == (bfd_size_type) -1)
- goto error_return;
- PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
-
- if (bfd_asymbol_flavour(g) == abfd->xvec->flavour)
- {
- bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc);
- bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other);
- bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type);
- }
- else
- {
- bfd_h_put_16(abfd,0, nsp.e_desc);
- bfd_h_put_8(abfd, 0, nsp.e_other);
- bfd_h_put_8(abfd, 0, nsp.e_type);
- }
-
- if (! translate_to_native_sym_flags (abfd, g, &nsp))
- goto error_return;
-
- if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd)
- != EXTERNAL_NLIST_SIZE)
- goto error_return;
-
- /* NB: `KEEPIT' currently overlays `udata.p', so set this only
- here, at the end. */
- g->KEEPIT = count;
- }
-
- if (! emit_stringtab (abfd, strtab))
- goto error_return;
-
- _bfd_stringtab_free (strtab);
-
- return true;
-
-error_return:
- _bfd_stringtab_free (strtab);
- return false;
-}
-
-
-long
-NAME(aout,get_symtab) (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- unsigned int counter = 0;
- aout_symbol_type *symbase;
-
- if (!NAME(aout,slurp_symbol_table)(abfd))
- return -1;
-
- for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);)
- *(location++) = (asymbol *)( symbase++);
- *location++ =0;
- return bfd_get_symcount (abfd);
-}
-
-
-/* Standard reloc stuff */
-/* Output standard relocation information to a file in target byte order. */
-
-void
-NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- struct reloc_std_external *natptr;
-{
- int r_index;
- asymbol *sym = *(g->sym_ptr_ptr);
- int r_extern;
- unsigned int r_length;
- int r_pcrel;
- int r_baserel, r_jmptable, r_relative;
- asection *output_section = sym->section->output_section;
-
- PUT_WORD(abfd, g->address, natptr->r_address);
-
- r_length = g->howto->size ; /* Size as a power of two */
- r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
- /* XXX This relies on relocs coming from a.out files. */
- r_baserel = (g->howto->type & 8) != 0;
- r_jmptable = (g->howto->type & 16) != 0;
- r_relative = (g->howto->type & 32) != 0;
-
-#if 0
- /* For a standard reloc, the addend is in the object file. */
- r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-#endif
-
- /* name was clobbered by aout_write_syms to be symbol index */
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here
- */
-
-
- if (bfd_is_com_section (output_section)
- || bfd_is_abs_section (output_section)
- || bfd_is_und_section (output_section))
- {
- if (bfd_abs_section_ptr->symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
- r_extern = 1;
- r_index = (*(g->sym_ptr_ptr))->KEEPIT;
-
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- natptr->r_index[0] = r_index >> 16;
- natptr->r_index[1] = r_index >> 8;
- natptr->r_index[2] = r_index;
- natptr->r_type[0] =
- (r_extern? RELOC_STD_BITS_EXTERN_BIG: 0)
- | (r_pcrel? RELOC_STD_BITS_PCREL_BIG: 0)
- | (r_baserel? RELOC_STD_BITS_BASEREL_BIG: 0)
- | (r_jmptable? RELOC_STD_BITS_JMPTABLE_BIG: 0)
- | (r_relative? RELOC_STD_BITS_RELATIVE_BIG: 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
- } else {
- natptr->r_index[2] = r_index >> 16;
- natptr->r_index[1] = r_index >> 8;
- natptr->r_index[0] = r_index;
- natptr->r_type[0] =
- (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
- | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
- | (r_baserel? RELOC_STD_BITS_BASEREL_LITTLE: 0)
- | (r_jmptable? RELOC_STD_BITS_JMPTABLE_LITTLE: 0)
- | (r_relative? RELOC_STD_BITS_RELATIVE_LITTLE: 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE);
- }
-}
-
-
-/* Extended stuff */
-/* Output extended relocation information to a file in target byte order. */
-
-void
-NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- register struct reloc_ext_external *natptr;
-{
- int r_index;
- int r_extern;
- unsigned int r_type;
- unsigned int r_addend;
- asymbol *sym = *(g->sym_ptr_ptr);
- asection *output_section = sym->section->output_section;
-
- PUT_WORD (abfd, g->address, natptr->r_address);
-
- r_type = (unsigned int) g->howto->type;
-
- r_addend = g->addend;
- if ((sym->flags & BSF_SECTION_SYM) != 0)
- r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here. */
-
- if (bfd_is_abs_section (bfd_get_section (sym)))
- {
- r_extern = 0;
- r_index = 0;
- }
- else if ((sym->flags & BSF_SECTION_SYM) == 0)
- {
- if (bfd_is_und_section (bfd_get_section (sym))
- || (sym->flags & BSF_GLOBAL) != 0)
- r_extern = 1;
- else
- r_extern = 0;
- r_index = (*(g->sym_ptr_ptr))->KEEPIT;
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- natptr->r_index[0] = r_index >> 16;
- natptr->r_index[1] = r_index >> 8;
- natptr->r_index[2] = r_index;
- natptr->r_type[0] =
- ((r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0)
- | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG));
- } else {
- natptr->r_index[2] = r_index >> 16;
- natptr->r_index[1] = r_index >> 8;
- natptr->r_index[0] = r_index;
- natptr->r_type[0] =
- (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0)
- | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
- }
-
- PUT_WORD (abfd, r_addend, natptr->r_addend);
-}
-
-/* BFD deals internally with all things based from the section they're
- in. so, something in 10 bytes into a text section with a base of
- 50 would have a symbol (.text+10) and know .text vma was 50.
-
- Aout keeps all it's symbols based from zero, so the symbol would
- contain 60. This macro subs the base of each section from the value
- to give the true offset from the section */
-
-
-#define MOVE_ADDRESS(ad) \
- if (r_extern) { \
- /* undefined symbol */ \
- cache_ptr->sym_ptr_ptr = symbols + r_index; \
- cache_ptr->addend = ad; \
- } else { \
- /* defined, section relative. replace symbol with pointer to \
- symbol which points to section */ \
- switch (r_index) { \
- case N_TEXT: \
- case N_TEXT | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->textsec->vma; \
- break; \
- case N_DATA: \
- case N_DATA | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->datasec->vma; \
- break; \
- case N_BSS: \
- case N_BSS | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->bsssec->vma; \
- break; \
- default: \
- case N_ABS: \
- case N_ABS | N_EXT: \
- cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
- cache_ptr->addend = ad; \
- break; \
- } \
- } \
-
-void
-NAME(aout,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_ext_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- unsigned int r_index;
- int r_extern;
- unsigned int r_type;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- r_index = (bytes->r_index[0] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[2];
- r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
- r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG;
- } else {
- r_index = (bytes->r_index[2] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[0];
- r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
- r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
- >> RELOC_EXT_BITS_TYPE_SH_LITTLE;
- }
-
- cache_ptr->howto = howto_table_ext + r_type;
-
- /* Base relative relocs are always against the symbol table,
- regardless of the setting of r_extern. r_extern just reflects
- whether the symbol the reloc is against is local or global. */
- if (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- r_extern = 1;
-
- if (r_extern && r_index > symcount)
- {
- /* We could arrange to return an error, but it might be useful
- to see the file even if it is bad. */
- r_extern = 0;
- r_index = N_ABS;
- }
-
- MOVE_ADDRESS(GET_SWORD(abfd, bytes->r_addend));
-}
-
-void
-NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_std_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- unsigned int r_index;
- int r_extern;
- unsigned int r_length;
- int r_pcrel;
- int r_baserel, r_jmptable, r_relative;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
- unsigned int howto_idx;
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd)) {
- r_index = (bytes->r_index[0] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[2];
- r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
- r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
- r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
- r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG));
- r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
- >> RELOC_STD_BITS_LENGTH_SH_BIG;
- } else {
- r_index = (bytes->r_index[2] << 16)
- | (bytes->r_index[1] << 8)
- | bytes->r_index[0];
- r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
- r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE));
- r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
- r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_LITTLE));
- r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
- }
-
- howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel
- + 16 * r_jmptable + 32 * r_relative;
- BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
- cache_ptr->howto = howto_table_std + howto_idx;
- BFD_ASSERT (cache_ptr->howto->type != (unsigned int) -1);
-
- /* Base relative relocs are always against the symbol table,
- regardless of the setting of r_extern. r_extern just reflects
- whether the symbol the reloc is against is local or global. */
- if (r_baserel)
- r_extern = 1;
-
- if (r_extern && r_index > symcount)
- {
- /* We could arrange to return an error, but it might be useful
- to see the file even if it is bad. */
- r_extern = 0;
- r_index = N_ABS;
- }
-
- MOVE_ADDRESS(0);
-}
-
-/* Read and swap the relocs for a section. */
-
-boolean
-NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
- bfd *abfd;
- sec_ptr asect;
- asymbol **symbols;
-{
- unsigned int count;
- bfd_size_type reloc_size;
- PTR relocs;
- arelent *reloc_cache;
- size_t each_size;
- unsigned int counter = 0;
- arelent *cache_ptr;
-
- if (asect->relocation)
- return true;
-
- if (asect->flags & SEC_CONSTRUCTOR)
- return true;
-
- if (asect == obj_datasec (abfd))
- reloc_size = exec_hdr(abfd)->a_drsize;
- else if (asect == obj_textsec (abfd))
- reloc_size = exec_hdr(abfd)->a_trsize;
- else if (asect == obj_bsssec (abfd))
- reloc_size = 0;
- else
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
- return false;
-
- each_size = obj_reloc_entry_size (abfd);
-
- count = reloc_size / each_size;
-
- reloc_cache = (arelent *) bfd_malloc ((size_t) (count * sizeof (arelent)));
- if (reloc_cache == NULL && count != 0)
- return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
-
- relocs = bfd_malloc ((size_t) reloc_size);
- if (relocs == NULL && reloc_size != 0)
- {
- free (reloc_cache);
- return false;
- }
-
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
- {
- free (relocs);
- free (reloc_cache);
- return false;
- }
-
- cache_ptr = reloc_cache;
- if (each_size == RELOC_EXT_SIZE)
- {
- register struct reloc_ext_external *rptr =
- (struct reloc_ext_external *) relocs;
-
- for (; counter < count; counter++, rptr++, cache_ptr++)
- NAME(aout,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
- else
- {
- register struct reloc_std_external *rptr =
- (struct reloc_std_external *) relocs;
-
- for (; counter < count; counter++, rptr++, cache_ptr++)
- MY_swap_std_reloc_in (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
-
- free (relocs);
-
- asect->relocation = reloc_cache;
- asect->reloc_count = cache_ptr - reloc_cache;
-
- return true;
-}
-
-/* Write out a relocation section into an object file. */
-
-boolean
-NAME(aout,squirt_out_relocs) (abfd, section)
- bfd *abfd;
- asection *section;
-{
- arelent **generic;
- unsigned char *native, *natptr;
- size_t each_size;
-
- unsigned int count = section->reloc_count;
- size_t natsize;
-
- if (count == 0) return true;
-
- each_size = obj_reloc_entry_size (abfd);
- natsize = each_size * count;
- native = (unsigned char *) bfd_zalloc (abfd, natsize);
- if (!native)
- return false;
-
- generic = section->orelocation;
-
- if (each_size == RELOC_EXT_SIZE)
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- NAME(aout,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *)natptr);
- }
- else
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- MY_swap_std_reloc_out(abfd, *generic, (struct reloc_std_external *)natptr);
- }
-
- if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
- bfd_release(abfd, native);
- return false;
- }
- bfd_release (abfd, native);
-
- return true;
-}
-
-/* This is stupid. This function should be a boolean predicate */
-long
-NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count;
-
- if (section == obj_bsssec (abfd))
- {
- *relptr = NULL;
- return 0;
- }
-
- if (!(tblptr || NAME(aout,slurp_reloc_table)(abfd, section, symbols)))
- return -1;
-
- if (section->flags & SEC_CONSTRUCTOR) {
- arelent_chain *chain = section->constructor_chain;
- for (count = 0; count < section->reloc_count; count ++) {
- *relptr ++ = &chain->relent;
- chain = chain->next;
- }
- }
- else {
- tblptr = section->relocation;
-
- for (count = 0; count++ < section->reloc_count;)
- {
- *relptr++ = tblptr++;
- }
- }
- *relptr = 0;
-
- return section->reloc_count;
-}
-
-long
-NAME(aout,get_reloc_upper_bound) (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (bfd_get_format (abfd) != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- if (asect->flags & SEC_CONSTRUCTOR) {
- return (sizeof (arelent *) * (asect->reloc_count+1));
- }
-
- if (asect == obj_datasec (abfd))
- return (sizeof (arelent *)
- * ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd))
- + 1));
-
- if (asect == obj_textsec (abfd))
- return (sizeof (arelent *)
- * ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
- + 1));
-
- if (asect == obj_bsssec (abfd))
- return sizeof (arelent *);
-
- if (asect == obj_bsssec (abfd))
- return 0;
-
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
-}
-
-
-long
-NAME(aout,get_symtab_upper_bound) (abfd)
- bfd *abfd;
-{
- if (!NAME(aout,slurp_symbol_table)(abfd))
- return -1;
-
- return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *));
-}
-
-/*ARGSUSED*/
- alent *
-NAME(aout,get_lineno) (ignore_abfd, ignore_symbol)
- bfd *ignore_abfd;
- asymbol *ignore_symbol;
-{
-return (alent *)NULL;
-}
-
-/*ARGSUSED*/
-void
-NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-
- if (ret->type == '?')
- {
- int type_code = aout_symbol(symbol)->type & 0xff;
- const char *stab_name = bfd_get_stab_name (type_code);
- static char buf[10];
-
- if (stab_name == NULL)
- {
- sprintf(buf, "(%d)", type_code);
- stab_name = buf;
- }
- ret->type = '-';
- ret->stab_type = type_code;
- ret->stab_other = (unsigned)(aout_symbol(symbol)->other & 0xff);
- ret->stab_desc = (unsigned)(aout_symbol(symbol)->desc & 0xffff);
- ret->stab_name = stab_name;
- }
-}
-
-/*ARGSUSED*/
-void
-NAME(aout,print_symbol) (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *)afile;
-
- switch (how) {
- case bfd_print_symbol_name:
- if (symbol->name)
- fprintf(file,"%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
- (unsigned)(aout_symbol(symbol)->other & 0xff),
- (unsigned)(aout_symbol(symbol)->type));
- break;
- case bfd_print_symbol_all:
- {
- CONST char *section_name = symbol->section->name;
-
-
- bfd_print_symbol_vandf((PTR)file,symbol);
-
- fprintf(file," %-5s %04x %02x %02x",
- section_name,
- (unsigned)(aout_symbol(symbol)->desc & 0xffff),
- (unsigned)(aout_symbol(symbol)->other & 0xff),
- (unsigned)(aout_symbol(symbol)->type & 0xff));
- if (symbol->name)
- fprintf(file," %s", symbol->name);
- }
- break;
- }
-}
-
-/* If we don't have to allocate more than 1MB to hold the generic
- symbols, we use the generic minisymbol methord: it's faster, since
- it only translates the symbols once, not multiple times. */
-#define MINISYM_THRESHOLD (1000000 / sizeof (asymbol))
-
-/* Read minisymbols. For minisymbols, we use the unmodified a.out
- symbols. The minisymbol_to_symbol function translates these into
- BFD asymbol structures. */
-
-long
-NAME(aout,read_minisymbols) (abfd, dynamic, minisymsp, sizep)
- bfd *abfd;
- boolean dynamic;
- PTR *minisymsp;
- unsigned int *sizep;
-{
- if (dynamic)
- {
- /* We could handle the dynamic symbols here as well, but it's
- easier to hand them off. */
- return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
- }
-
- if (! aout_get_external_symbols (abfd))
- return -1;
-
- if (obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
- return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
-
- *minisymsp = (PTR) obj_aout_external_syms (abfd);
-
- /* By passing the external symbols back from this routine, we are
- giving up control over the memory block. Clear
- obj_aout_external_syms, so that we do not try to free it
- ourselves. */
- obj_aout_external_syms (abfd) = NULL;
-
- *sizep = EXTERNAL_NLIST_SIZE;
- return obj_aout_external_sym_count (abfd);
-}
-
-/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
- unmodified a.out symbol. The SYM argument is a structure returned
- by bfd_make_empty_symbol, which we fill in here. */
-
-asymbol *
-NAME(aout,minisymbol_to_symbol) (abfd, dynamic, minisym, sym)
- bfd *abfd;
- boolean dynamic;
- const PTR minisym;
- asymbol *sym;
-{
- if (dynamic
- || obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
- return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
-
- memset (sym, 0, sizeof (aout_symbol_type));
-
- /* We call translate_symbol_table to translate a single symbol. */
- if (! (NAME(aout,translate_symbol_table)
- (abfd,
- (aout_symbol_type *) sym,
- (struct external_nlist *) minisym,
- (bfd_size_type) 1,
- obj_aout_external_strings (abfd),
- obj_aout_external_string_size (abfd),
- false)))
- return NULL;
-
- return sym;
-}
-
-/*
- provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location.
-*/
-
-boolean
-NAME(aout,find_nearest_line)
- (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *line_ptr;
-{
- /* Run down the file looking for the filename, function and linenumber */
- asymbol **p;
- CONST char *directory_name = NULL;
- CONST char *main_file_name = NULL;
- CONST char *current_file_name = NULL;
- CONST char *line_file_name = NULL; /* Value of current_file_name at line number. */
- bfd_vma low_line_vma = 0;
- bfd_vma low_func_vma = 0;
- asymbol *func = 0;
- size_t filelen, funclen;
- char *buf;
-
- *filename_ptr = abfd->filename;
- *functionname_ptr = 0;
- *line_ptr = 0;
- if (symbols != (asymbol **)NULL) {
- for (p = symbols; *p; p++) {
- aout_symbol_type *q = (aout_symbol_type *)(*p);
- next:
- switch (q->type){
- case N_SO:
- main_file_name = current_file_name = q->symbol.name;
- /* Look ahead to next symbol to check if that too is an N_SO. */
- p++;
- if (*p == NULL)
- break;
- q = (aout_symbol_type *)(*p);
- if (q->type != (int)N_SO)
- goto next;
-
- /* Found a second N_SO First is directory; second is filename. */
- directory_name = current_file_name;
- main_file_name = current_file_name = q->symbol.name;
- if (obj_textsec(abfd) != section)
- goto done;
- break;
- case N_SOL:
- current_file_name = q->symbol.name;
- break;
-
- case N_SLINE:
-
- case N_DSLINE:
- case N_BSLINE:
- /* We'll keep this if it resolves nearer than the one we have
- already. */
- if (q->symbol.value >= low_line_vma
- && q->symbol.value <= offset)
- {
- *line_ptr = q->desc;
- low_line_vma = q->symbol.value;
- line_file_name = current_file_name;
- }
- break;
- case N_FUN:
- {
- /* We'll keep this if it is nearer than the one we have already */
- if (q->symbol.value >= low_func_vma &&
- q->symbol.value <= offset) {
- low_func_vma = q->symbol.value;
- func = (asymbol *)q;
- }
- else if (q->symbol.value > offset)
- goto done;
- }
- break;
- }
- }
- }
-
- done:
- if (*line_ptr != 0)
- main_file_name = line_file_name;
-
- if (main_file_name == NULL
- || main_file_name[0] == '/'
- || directory_name == NULL)
- filelen = 0;
- else
- filelen = strlen (directory_name) + strlen (main_file_name);
- if (func == NULL)
- funclen = 0;
- else
- funclen = strlen (bfd_asymbol_name (func));
-
- if (adata (abfd).line_buf != NULL)
- free (adata (abfd).line_buf);
- if (filelen + funclen == 0)
- adata (abfd).line_buf = buf = NULL;
- else
- {
- buf = (char *) bfd_malloc (filelen + funclen + 2);
- adata (abfd).line_buf = buf;
- if (buf == NULL)
- return false;
- }
-
- if (main_file_name != NULL)
- {
- if (main_file_name[0] == '/' || directory_name == NULL)
- *filename_ptr = main_file_name;
- else
- {
- sprintf (buf, "%s%s", directory_name, main_file_name);
- *filename_ptr = buf;
- buf += filelen + 1;
- }
- }
-
- if (func)
- {
- const char *function = func->name;
- char *p;
-
- /* The caller expects a symbol name. We actually have a
- function name, without the leading underscore. Put the
- underscore back in, so that the caller gets a symbol name. */
- if (bfd_get_symbol_leading_char (abfd) == '\0')
- strcpy (buf, function);
- else
- {
- buf[0] = bfd_get_symbol_leading_char (abfd);
- strcpy (buf + 1, function);
- }
- /* Have to remove : stuff */
- p = strchr (buf, ':');
- if (p != NULL)
- *p = '\0';
- *functionname_ptr = buf;
- }
-
- return true;
-}
-
-/*ARGSUSED*/
-int
-NAME(aout,sizeof_headers) (abfd, execable)
- bfd *abfd;
- boolean execable;
-{
- return adata(abfd).exec_bytes_size;
-}
-
-/* Free all information we have cached for this BFD. We can always
- read it again later if we need it. */
-
-boolean
-NAME(aout,bfd_free_cached_info) (abfd)
- bfd *abfd;
-{
- asection *o;
-
- if (bfd_get_format (abfd) != bfd_object)
- return true;
-
-#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
- BFCI_FREE (obj_aout_symbols (abfd));
-#ifdef USE_MMAP
- obj_aout_external_syms (abfd) = 0;
- bfd_free_window (&obj_aout_sym_window (abfd));
- bfd_free_window (&obj_aout_string_window (abfd));
- obj_aout_external_strings (abfd) = 0;
-#else
- BFCI_FREE (obj_aout_external_syms (abfd));
- BFCI_FREE (obj_aout_external_strings (abfd));
-#endif
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- BFCI_FREE (o->relocation);
-#undef BFCI_FREE
-
- return true;
-}
-
-/* a.out link code. */
-
-static boolean aout_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean aout_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static boolean aout_link_free_symbols PARAMS ((bfd *));
-static boolean aout_link_check_ar_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean aout_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Routine to create an entry in an a.out link hash table. */
-
-struct bfd_hash_entry *
-NAME(aout,link_hash_newfunc) (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct aout_link_hash_entry *ret = (struct aout_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct aout_link_hash_entry *) NULL)
- ret = ((struct aout_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
- if (ret == (struct aout_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct aout_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret)
- {
- /* Set local fields. */
- ret->written = false;
- ret->indx = -1;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an a.out link hash table. */
-
-boolean
-NAME(aout,link_hash_table_init) (table, abfd, newfunc)
- struct aout_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
-}
-
-/* Create an a.out link hash table. */
-
-struct bfd_link_hash_table *
-NAME(aout,link_hash_table_create) (abfd)
- bfd *abfd;
-{
- struct aout_link_hash_table *ret;
-
- ret = ((struct aout_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
- if (ret == NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! NAME(aout,link_hash_table_init) (ret, abfd,
- NAME(aout,link_hash_newfunc)))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Given an a.out BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-NAME(aout,link_add_symbols) (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return aout_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return _bfd_generic_link_add_archive_symbols
- (abfd, info, aout_link_check_archive_element);
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add symbols from an a.out object file. */
-
-static boolean
-aout_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (! aout_get_external_symbols (abfd))
- return false;
- if (! aout_link_add_symbols (abfd, info))
- return false;
- if (! info->keep_memory)
- {
- if (! aout_link_free_symbols (abfd))
- return false;
- }
- return true;
-}
-
-/* Check a single archive element to see if we need to include it in
- the link. *PNEEDED is set according to whether this element is
- needed in the link or not. This is called from
- _bfd_generic_link_add_archive_symbols. */
-
-static boolean
-aout_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- if (! aout_get_external_symbols (abfd))
- return false;
-
- if (! aout_link_check_ar_symbols (abfd, info, pneeded))
- return false;
-
- if (*pneeded)
- {
- if (! aout_link_add_symbols (abfd, info))
- return false;
- }
-
- if (! info->keep_memory || ! *pneeded)
- {
- if (! aout_link_free_symbols (abfd))
- return false;
- }
-
- return true;
-}
-
-/* Free up the internal symbols read from an a.out file. */
-
-static boolean
-aout_link_free_symbols (abfd)
- bfd *abfd;
-{
- if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_sym_window (abfd));
-#else
- free ((PTR) obj_aout_external_syms (abfd));
-#endif
- obj_aout_external_syms (abfd) = (struct external_nlist *) NULL;
- }
- if (obj_aout_external_strings (abfd) != (char *) NULL)
- {
-#ifdef USE_MMAP
- bfd_free_window (&obj_aout_string_window (abfd));
-#else
- free ((PTR) obj_aout_external_strings (abfd));
-#endif
- obj_aout_external_strings (abfd) = (char *) NULL;
- }
- return true;
-}
-
-/* Look through the internal symbols to see if this object file should
- be included in the link. We should include this object file if it
- defines any symbols which are currently undefined. If this object
- file defines a common symbol, then we may adjust the size of the
- known symbol but we do not include the object file in the link
- (unless there is some other reason to include it). */
-
-static boolean
-aout_link_check_ar_symbols (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- register struct external_nlist *p;
- struct external_nlist *pend;
- char *strings;
-
- *pneeded = false;
-
- /* Look through all the symbols. */
- p = obj_aout_external_syms (abfd);
- pend = p + obj_aout_external_sym_count (abfd);
- strings = obj_aout_external_strings (abfd);
- for (; p < pend; p++)
- {
- int type = bfd_h_get_8 (abfd, p->e_type);
- const char *name;
- struct bfd_link_hash_entry *h;
-
- /* Ignore symbols that are not externally visible. This is an
- optimization only, as we check the type more thoroughly
- below. */
- if (((type & N_EXT) == 0
- || (type & N_STAB) != 0
- || type == N_FN)
- && type != N_WEAKA
- && type != N_WEAKT
- && type != N_WEAKD
- && type != N_WEAKB)
- {
- if (type == N_WARNING
- || type == N_INDR)
- ++p;
- continue;
- }
-
- name = strings + GET_WORD (abfd, p->e_strx);
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* We are only interested in symbols that are currently
- undefined or common. */
- if (h == (struct bfd_link_hash_entry *) NULL
- || (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common))
- {
- if (type == (N_INDR | N_EXT))
- ++p;
- continue;
- }
-
- if (type == (N_TEXT | N_EXT)
- || type == (N_DATA | N_EXT)
- || type == (N_BSS | N_EXT)
- || type == (N_ABS | N_EXT)
- || type == (N_INDR | N_EXT))
- {
- /* This object file defines this symbol. We must link it
- in. This is true regardless of whether the current
- definition of the symbol is undefined or common. If the
- current definition is common, we have a case in which we
- have already seen an object file including
- int a;
- and this object file from the archive includes
- int a = 5;
- In such a case we must include this object file.
-
- FIXME: The SunOS 4.1.3 linker will pull in the archive
- element if the symbol is defined in the .data section,
- but not if it is defined in the .text section. That
- seems a bit crazy to me, and I haven't implemented it.
- However, it might be correct. */
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
-
- if (type == (N_UNDF | N_EXT))
- {
- bfd_vma value;
-
- value = GET_WORD (abfd, p->e_value);
- if (value != 0)
- {
- /* This symbol is common in the object from the archive
- file. */
- if (h->type == bfd_link_hash_undefined)
- {
- bfd *symbfd;
- unsigned int power;
-
- symbfd = h->u.undef.abfd;
- if (symbfd == (bfd *) NULL)
- {
- /* This symbol was created as undefined from
- outside BFD. We assume that we should link
- in the object file. This is done for the -u
- option in the linker. */
- if (! (*info->callbacks->add_archive_element) (info,
- abfd,
- name))
- return false;
- *pneeded = true;
- return true;
- }
- /* Turn the current link symbol into a common
- symbol. It is already on the undefs list. */
- h->type = bfd_link_hash_common;
- h->u.c.p = ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- h->u.c.size = value;
-
- /* FIXME: This isn't quite right. The maximum
- alignment of a common symbol should be set by the
- architecture of the output file, not of the input
- file. */
- power = bfd_log2 (value);
- if (power > bfd_get_arch_info (abfd)->section_align_power)
- power = bfd_get_arch_info (abfd)->section_align_power;
- h->u.c.p->alignment_power = power;
-
- h->u.c.p->section = bfd_make_section_old_way (symbfd,
- "COMMON");
- }
- else
- {
- /* Adjust the size of the common symbol if
- necessary. */
- if (value > h->u.c.size)
- h->u.c.size = value;
- }
- }
- }
-
- if (type == N_WEAKA
- || type == N_WEAKT
- || type == N_WEAKD
- || type == N_WEAKB)
- {
- /* This symbol is weak but defined. We must pull it in if
- the current link symbol is undefined, but we don't want
- it if the current link symbol is common. */
- if (h->type == bfd_link_hash_undefined)
- {
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
- }
- }
-
- /* We do not need this object file. */
- return true;
-}
-
-/* Add all symbols from an object file to the hash table. */
-
-static boolean
-aout_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
- const char *, flagword, asection *,
- bfd_vma, const char *, boolean,
- boolean,
- struct bfd_link_hash_entry **));
- struct external_nlist *syms;
- bfd_size_type sym_count;
- char *strings;
- boolean copy;
- struct aout_link_hash_entry **sym_hash;
- register struct external_nlist *p;
- struct external_nlist *pend;
-
- syms = obj_aout_external_syms (abfd);
- sym_count = obj_aout_external_sym_count (abfd);
- strings = obj_aout_external_strings (abfd);
- if (info->keep_memory)
- copy = false;
- else
- copy = true;
-
- if ((abfd->flags & DYNAMIC) != 0
- && aout_backend_info (abfd)->add_dynamic_symbols != NULL)
- {
- if (! ((*aout_backend_info (abfd)->add_dynamic_symbols)
- (abfd, info, &syms, &sym_count, &strings)))
- return false;
- }
-
- /* We keep a list of the linker hash table entries that correspond
- to particular symbols. We could just look them up in the hash
- table, but keeping the list is more efficient. Perhaps this
- should be conditional on info->keep_memory. */
- sym_hash = ((struct aout_link_hash_entry **)
- bfd_alloc (abfd,
- ((size_t) sym_count
- * sizeof (struct aout_link_hash_entry *))));
- if (sym_hash == NULL && sym_count != 0)
- return false;
- obj_aout_sym_hashes (abfd) = sym_hash;
-
- add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
- if (add_one_symbol == NULL)
- add_one_symbol = _bfd_generic_link_add_one_symbol;
-
- p = syms;
- pend = p + sym_count;
- for (; p < pend; p++, sym_hash++)
- {
- int type;
- const char *name;
- bfd_vma value;
- asection *section;
- flagword flags;
- const char *string;
-
- *sym_hash = NULL;
-
- type = bfd_h_get_8 (abfd, p->e_type);
-
- /* Ignore debugging symbols. */
- if ((type & N_STAB) != 0)
- continue;
-
- name = strings + GET_WORD (abfd, p->e_strx);
- value = GET_WORD (abfd, p->e_value);
- flags = BSF_GLOBAL;
- string = NULL;
- switch (type)
- {
- default:
- abort ();
-
- case N_UNDF:
- case N_ABS:
- case N_TEXT:
- case N_DATA:
- case N_BSS:
- case N_FN_SEQ:
- case N_COMM:
- case N_SETV:
- case N_FN:
- /* Ignore symbols that are not externally visible. */
- continue;
- case N_INDR:
- /* Ignore local indirect symbol. */
- ++p;
- ++sym_hash;
- continue;
-
- case N_UNDF | N_EXT:
- if (value == 0)
- {
- section = bfd_und_section_ptr;
- flags = 0;
- }
- else
- section = bfd_com_section_ptr;
- break;
- case N_ABS | N_EXT:
- section = bfd_abs_section_ptr;
- break;
- case N_TEXT | N_EXT:
- section = obj_textsec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_DATA | N_EXT:
- case N_SETV | N_EXT:
- /* Treat N_SETV symbols as N_DATA symbol; see comment in
- translate_from_native_sym_flags. */
- section = obj_datasec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_BSS | N_EXT:
- section = obj_bsssec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_INDR | N_EXT:
- /* An indirect symbol. The next symbol is the symbol
- which this one really is. */
- BFD_ASSERT (p + 1 < pend);
- ++p;
- string = strings + GET_WORD (abfd, p->e_strx);
- section = bfd_ind_section_ptr;
- flags |= BSF_INDIRECT;
- break;
- case N_COMM | N_EXT:
- section = bfd_com_section_ptr;
- break;
- case N_SETA: case N_SETA | N_EXT:
- section = bfd_abs_section_ptr;
- flags |= BSF_CONSTRUCTOR;
- break;
- case N_SETT: case N_SETT | N_EXT:
- section = obj_textsec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_SETD: case N_SETD | N_EXT:
- section = obj_datasec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_SETB: case N_SETB | N_EXT:
- section = obj_bsssec (abfd);
- flags |= BSF_CONSTRUCTOR;
- value -= bfd_get_section_vma (abfd, section);
- break;
- case N_WARNING:
- /* A warning symbol. The next symbol is the one to warn
- about. */
- BFD_ASSERT (p + 1 < pend);
- ++p;
- string = name;
- name = strings + GET_WORD (abfd, p->e_strx);
- section = bfd_und_section_ptr;
- flags |= BSF_WARNING;
- break;
- case N_WEAKU:
- section = bfd_und_section_ptr;
- flags = BSF_WEAK;
- break;
- case N_WEAKA:
- section = bfd_abs_section_ptr;
- flags = BSF_WEAK;
- break;
- case N_WEAKT:
- section = obj_textsec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- case N_WEAKD:
- section = obj_datasec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- case N_WEAKB:
- section = obj_bsssec (abfd);
- value -= bfd_get_section_vma (abfd, section);
- flags = BSF_WEAK;
- break;
- }
-
- if (! ((*add_one_symbol)
- (info, abfd, name, flags, section, value, string, copy, false,
- (struct bfd_link_hash_entry **) sym_hash)))
- return false;
-
- /* Restrict the maximum alignment of a common symbol based on
- the architecture, since a.out has no way to represent
- alignment requirements of a section in a .o file. FIXME:
- This isn't quite right: it should use the architecture of the
- output file, not the input files. */
- if ((*sym_hash)->root.type == bfd_link_hash_common
- && ((*sym_hash)->root.u.c.p->alignment_power >
- bfd_get_arch_info (abfd)->section_align_power))
- (*sym_hash)->root.u.c.p->alignment_power =
- bfd_get_arch_info (abfd)->section_align_power;
-
- /* If this is a set symbol, and we are not building sets, then
- it is possible for the hash entry to not have been set. In
- such a case, treat the symbol as not globally defined. */
- if ((*sym_hash)->root.type == bfd_link_hash_new)
- {
- BFD_ASSERT ((flags & BSF_CONSTRUCTOR) != 0);
- *sym_hash = NULL;
- }
-
- if (type == (N_INDR | N_EXT) || type == N_WARNING)
- ++sym_hash;
- }
-
- return true;
-}
-
-/* A hash table used for header files with N_BINCL entries. */
-
-struct aout_link_includes_table
-{
- struct bfd_hash_table root;
-};
-
-/* A linked list of totals that we have found for a particular header
- file. */
-
-struct aout_link_includes_totals
-{
- struct aout_link_includes_totals *next;
- bfd_vma total;
-};
-
-/* An entry in the header file hash table. */
-
-struct aout_link_includes_entry
-{
- struct bfd_hash_entry root;
- /* List of totals we have found for this file. */
- struct aout_link_includes_totals *totals;
-};
-
-/* Look up an entry in an the header file hash table. */
-
-#define aout_link_includes_lookup(table, string, create, copy) \
- ((struct aout_link_includes_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-/* During the final link step we need to pass around a bunch of
- information, so we do it in an instance of this structure. */
-
-struct aout_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output bfd. */
- bfd *output_bfd;
- /* Reloc file positions. */
- file_ptr treloff, dreloff;
- /* File position of symbols. */
- file_ptr symoff;
- /* String table. */
- struct bfd_strtab_hash *strtab;
- /* Header file hash table. */
- struct aout_link_includes_table includes;
- /* A buffer large enough to hold the contents of any section. */
- bfd_byte *contents;
- /* A buffer large enough to hold the relocs of any section. */
- PTR relocs;
- /* A buffer large enough to hold the symbol map of any input BFD. */
- int *symbol_map;
- /* A buffer large enough to hold output symbols of any input BFD. */
- struct external_nlist *output_syms;
-};
-
-static struct bfd_hash_entry *aout_link_includes_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static boolean aout_link_input_bfd
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
-static boolean aout_link_write_symbols
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
-static boolean aout_link_write_other_symbol
- PARAMS ((struct aout_link_hash_entry *, PTR));
-static boolean aout_link_input_section
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, file_ptr *reloff_ptr,
- bfd_size_type rel_size));
-static boolean aout_link_input_section_std
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, struct reloc_std_external *,
- bfd_size_type rel_size, bfd_byte *contents));
-static boolean aout_link_input_section_ext
- PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
- asection *input_section, struct reloc_ext_external *,
- bfd_size_type rel_size, bfd_byte *contents));
-static INLINE asection *aout_reloc_index_to_section
- PARAMS ((bfd *, int));
-static boolean aout_link_reloc_link_order
- PARAMS ((struct aout_final_link_info *, asection *,
- struct bfd_link_order *));
-
-/* The function to create a new entry in the header file hash table. */
-
-static struct bfd_hash_entry *
-aout_link_includes_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct aout_link_includes_entry *ret =
- (struct aout_link_includes_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct aout_link_includes_entry *) NULL)
- ret = ((struct aout_link_includes_entry *)
- bfd_hash_allocate (table,
- sizeof (struct aout_link_includes_entry)));
- if (ret == (struct aout_link_includes_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct aout_link_includes_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
- if (ret)
- {
- /* Set local fields. */
- ret->totals = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Do the final link step. This is called on the output BFD. The
- INFO structure should point to a list of BFDs linked through the
- link_next field which can be used to find each BFD which takes part
- in the output. Also, each section in ABFD should point to a list
- of bfd_link_order structures which list all the input sections for
- the output section. */
-
-boolean
-NAME(aout,final_link) (abfd, info, callback)
- bfd *abfd;
- struct bfd_link_info *info;
- void (*callback) PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-{
- struct aout_final_link_info aout_info;
- boolean includes_hash_initialized = false;
- register bfd *sub;
- bfd_size_type trsize, drsize;
- size_t max_contents_size;
- size_t max_relocs_size;
- size_t max_sym_count;
- bfd_size_type text_size;
- file_ptr text_end;
- register struct bfd_link_order *p;
- asection *o;
- boolean have_link_order_relocs;
-
- if (info->shared)
- abfd->flags |= DYNAMIC;
-
- aout_info.info = info;
- aout_info.output_bfd = abfd;
- aout_info.contents = NULL;
- aout_info.relocs = NULL;
- aout_info.symbol_map = NULL;
- aout_info.output_syms = NULL;
-
- if (! bfd_hash_table_init_n (&aout_info.includes.root,
- aout_link_includes_newfunc,
- 251))
- goto error_return;
- includes_hash_initialized = true;
-
- /* Figure out the largest section size. Also, if generating
- relocateable output, count the relocs. */
- trsize = 0;
- drsize = 0;
- max_contents_size = 0;
- max_relocs_size = 0;
- max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- size_t sz;
-
- if (info->relocateable)
- {
- if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
- {
- trsize += exec_hdr (sub)->a_trsize;
- drsize += exec_hdr (sub)->a_drsize;
- }
- else
- {
- /* FIXME: We need to identify the .text and .data sections
- and call get_reloc_upper_bound and canonicalize_reloc to
- work out the number of relocs needed, and then multiply
- by the reloc size. */
- (*_bfd_error_handler)
- ("%s: relocateable link from %s to %s not supported",
- bfd_get_filename (abfd),
- sub->xvec->name, abfd->xvec->name);
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
- }
-
- if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
- {
- sz = bfd_section_size (sub, obj_textsec (sub));
- if (sz > max_contents_size)
- max_contents_size = sz;
- sz = bfd_section_size (sub, obj_datasec (sub));
- if (sz > max_contents_size)
- max_contents_size = sz;
-
- sz = exec_hdr (sub)->a_trsize;
- if (sz > max_relocs_size)
- max_relocs_size = sz;
- sz = exec_hdr (sub)->a_drsize;
- if (sz > max_relocs_size)
- max_relocs_size = sz;
-
- sz = obj_aout_external_sym_count (sub);
- if (sz > max_sym_count)
- max_sym_count = sz;
- }
- }
-
- if (info->relocateable)
- {
- if (obj_textsec (abfd) != (asection *) NULL)
- trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
- ->link_order_head)
- * obj_reloc_entry_size (abfd));
- if (obj_datasec (abfd) != (asection *) NULL)
- drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
- ->link_order_head)
- * obj_reloc_entry_size (abfd));
- }
-
- exec_hdr (abfd)->a_trsize = trsize;
- exec_hdr (abfd)->a_drsize = drsize;
-
- exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
-
- /* Adjust the section sizes and vmas according to the magic number.
- This sets a_text, a_data and a_bss in the exec_hdr and sets the
- filepos for each section. */
- if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
- goto error_return;
-
- /* The relocation and symbol file positions differ among a.out
- targets. We are passed a callback routine from the backend
- specific code to handle this.
- FIXME: At this point we do not know how much space the symbol
- table will require. This will not work for any (nonstandard)
- a.out target that needs to know the symbol table size before it
- can compute the relocation file positions. This may or may not
- be the case for the hp300hpux target, for example. */
- (*callback) (abfd, &aout_info.treloff, &aout_info.dreloff,
- &aout_info.symoff);
- obj_textsec (abfd)->rel_filepos = aout_info.treloff;
- obj_datasec (abfd)->rel_filepos = aout_info.dreloff;
- obj_sym_filepos (abfd) = aout_info.symoff;
-
- /* We keep a count of the symbols as we output them. */
- obj_aout_external_sym_count (abfd) = 0;
-
- /* We accumulate the string table as we write out the symbols. */
- aout_info.strtab = _bfd_stringtab_init ();
- if (aout_info.strtab == NULL)
- goto error_return;
-
- /* Allocate buffers to hold section contents and relocs. */
- aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- aout_info.relocs = (PTR) bfd_malloc (max_relocs_size);
- aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
- aout_info.output_syms = ((struct external_nlist *)
- bfd_malloc ((max_sym_count + 1)
- * sizeof (struct external_nlist)));
- if ((aout_info.contents == NULL && max_contents_size != 0)
- || (aout_info.relocs == NULL && max_relocs_size != 0)
- || (aout_info.symbol_map == NULL && max_sym_count != 0)
- || aout_info.output_syms == NULL)
- goto error_return;
-
- /* If we have a symbol named __DYNAMIC, force it out now. This is
- required by SunOS. Doing this here rather than in sunos.c is a
- hack, but it's easier than exporting everything which would be
- needed. */
- {
- struct aout_link_hash_entry *h;
-
- h = aout_link_hash_lookup (aout_hash_table (info), "__DYNAMIC",
- false, false, false);
- if (h != NULL)
- aout_link_write_other_symbol (h, &aout_info);
- }
-
- /* The most time efficient way to do the link would be to read all
- the input object files into memory and then sort out the
- information into the output file. Unfortunately, that will
- probably use too much memory. Another method would be to step
- through everything that composes the text section and write it
- out, and then everything that composes the data section and write
- it out, and then write out the relocs, and then write out the
- symbols. Unfortunately, that requires reading stuff from each
- input file several times, and we will not be able to keep all the
- input files open simultaneously, and reopening them will be slow.
-
- What we do is basically process one input file at a time. We do
- everything we need to do with an input file once--copy over the
- section contents, handle the relocation information, and write
- out the symbols--and then we throw away the information we read
- from it. This approach requires a lot of lseeks of the output
- file, which is unfortunate but still faster than reopening a lot
- of files.
-
- We use the output_has_begun field of the input BFDs to see
- whether we have already handled it. */
- for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
- sub->output_has_begun = false;
-
- have_link_order_relocs = false;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_aout_flavour))
- {
- bfd *input_bfd;
-
- input_bfd = p->u.indirect.section->owner;
- if (! input_bfd->output_has_begun)
- {
- if (! aout_link_input_bfd (&aout_info, input_bfd))
- goto error_return;
- input_bfd->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- /* These are handled below. */
- have_link_order_relocs = true;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
- /* Write out any symbols that we have not already written out. */
- aout_link_hash_traverse (aout_hash_table (info),
- aout_link_write_other_symbol,
- (PTR) &aout_info);
-
- /* Now handle any relocs we were asked to create by the linker.
- These did not come from any input file. We must do these after
- we have written out all the symbols, so that we know the symbol
- indices to use. */
- if (have_link_order_relocs)
- {
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! aout_link_reloc_link_order (&aout_info, o, p))
- goto error_return;
- }
- }
- }
- }
-
- if (aout_info.contents != NULL)
- {
- free (aout_info.contents);
- aout_info.contents = NULL;
- }
- if (aout_info.relocs != NULL)
- {
- free (aout_info.relocs);
- aout_info.relocs = NULL;
- }
- if (aout_info.symbol_map != NULL)
- {
- free (aout_info.symbol_map);
- aout_info.symbol_map = NULL;
- }
- if (aout_info.output_syms != NULL)
- {
- free (aout_info.output_syms);
- aout_info.output_syms = NULL;
- }
- if (includes_hash_initialized)
- {
- bfd_hash_table_free (&aout_info.includes.root);
- includes_hash_initialized = false;
- }
-
- /* Finish up any dynamic linking we may be doing. */
- if (aout_backend_info (abfd)->finish_dynamic_link != NULL)
- {
- if (! (*aout_backend_info (abfd)->finish_dynamic_link) (abfd, info))
- goto error_return;
- }
-
- /* Update the header information. */
- abfd->symcount = obj_aout_external_sym_count (abfd);
- exec_hdr (abfd)->a_syms = abfd->symcount * EXTERNAL_NLIST_SIZE;
- obj_str_filepos (abfd) = obj_sym_filepos (abfd) + exec_hdr (abfd)->a_syms;
- obj_textsec (abfd)->reloc_count =
- exec_hdr (abfd)->a_trsize / obj_reloc_entry_size (abfd);
- obj_datasec (abfd)->reloc_count =
- exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
-
- /* Write out the string table. */
- if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0)
- goto error_return;
- return emit_stringtab (abfd, aout_info.strtab);
-
- error_return:
- if (aout_info.contents != NULL)
- free (aout_info.contents);
- if (aout_info.relocs != NULL)
- free (aout_info.relocs);
- if (aout_info.symbol_map != NULL)
- free (aout_info.symbol_map);
- if (aout_info.output_syms != NULL)
- free (aout_info.output_syms);
- if (includes_hash_initialized)
- bfd_hash_table_free (&aout_info.includes.root);
- return false;
-}
-
-/* Link an a.out input BFD into the output file. */
-
-static boolean
-aout_link_input_bfd (finfo, input_bfd)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
-{
- bfd_size_type sym_count;
-
- BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
-
- /* If this is a dynamic object, it may need special handling. */
- if ((input_bfd->flags & DYNAMIC) != 0
- && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
- {
- return ((*aout_backend_info (input_bfd)->link_dynamic_object)
- (finfo->info, input_bfd));
- }
-
- /* Get the symbols. We probably have them already, unless
- finfo->info->keep_memory is false. */
- if (! aout_get_external_symbols (input_bfd))
- return false;
-
- sym_count = obj_aout_external_sym_count (input_bfd);
-
- /* Write out the symbols and get a map of the new indices. The map
- is placed into finfo->symbol_map. */
- if (! aout_link_write_symbols (finfo, input_bfd))
- return false;
-
- /* Relocate and write out the sections. These functions use the
- symbol map created by aout_link_write_symbols. */
- if (! aout_link_input_section (finfo, input_bfd,
- obj_textsec (input_bfd),
- &finfo->treloff,
- exec_hdr (input_bfd)->a_trsize)
- || ! aout_link_input_section (finfo, input_bfd,
- obj_datasec (input_bfd),
- &finfo->dreloff,
- exec_hdr (input_bfd)->a_drsize))
- return false;
-
- /* If we are not keeping memory, we don't need the symbols any
- longer. We still need them if we are keeping memory, because the
- strings in the hash table point into them. */
- if (! finfo->info->keep_memory)
- {
- if (! aout_link_free_symbols (input_bfd))
- return false;
- }
-
- return true;
-}
-
-/* Adjust and write out the symbols for an a.out file. Set the new
- symbol indices into a symbol_map. */
-
-static boolean
-aout_link_write_symbols (finfo, input_bfd)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
-{
- bfd *output_bfd;
- bfd_size_type sym_count;
- char *strings;
- enum bfd_link_strip strip;
- enum bfd_link_discard discard;
- struct external_nlist *outsym;
- bfd_size_type strtab_index;
- register struct external_nlist *sym;
- struct external_nlist *sym_end;
- struct aout_link_hash_entry **sym_hash;
- int *symbol_map;
- boolean pass;
- boolean skip_next;
-
- output_bfd = finfo->output_bfd;
- sym_count = obj_aout_external_sym_count (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- strip = finfo->info->strip;
- discard = finfo->info->discard;
- outsym = finfo->output_syms;
-
- /* First write out a symbol for this object file, unless we are
- discarding such symbols. */
- if (strip != strip_all
- && (strip != strip_some
- || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
- false, false) != NULL)
- && discard != discard_all)
- {
- bfd_h_put_8 (output_bfd, N_TEXT, outsym->e_type);
- bfd_h_put_8 (output_bfd, 0, outsym->e_other);
- bfd_h_put_16 (output_bfd, (bfd_vma) 0, outsym->e_desc);
- strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
- input_bfd->filename, false);
- if (strtab_index == (bfd_size_type) -1)
- return false;
- PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
- PUT_WORD (output_bfd,
- (bfd_get_section_vma (output_bfd,
- obj_textsec (input_bfd)->output_section)
- + obj_textsec (input_bfd)->output_offset),
- outsym->e_value);
- ++obj_aout_external_sym_count (output_bfd);
- ++outsym;
- }
-
- pass = false;
- skip_next = false;
- sym = obj_aout_external_syms (input_bfd);
- sym_end = sym + sym_count;
- sym_hash = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
- memset (symbol_map, 0, sym_count * sizeof *symbol_map);
- for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
- {
- const char *name;
- int type;
- struct aout_link_hash_entry *h;
- boolean skip;
- asection *symsec;
- bfd_vma val = 0;
- boolean copy;
-
- /* We set *symbol_map to 0 above for all symbols. If it has
- already been set to -1 for this symbol, it means that we are
- discarding it because it appears in a duplicate header file.
- See the N_BINCL code below. */
- if (*symbol_map == -1)
- continue;
-
- /* Initialize *symbol_map to -1, which means that the symbol was
- not copied into the output file. We will change it later if
- we do copy the symbol over. */
- *symbol_map = -1;
-
- type = bfd_h_get_8 (input_bfd, sym->e_type);
- name = strings + GET_WORD (input_bfd, sym->e_strx);
-
- h = NULL;
-
- if (pass)
- {
- /* Pass this symbol through. It is the target of an
- indirect or warning symbol. */
- val = GET_WORD (input_bfd, sym->e_value);
- pass = false;
- }
- else if (skip_next)
- {
- /* Skip this symbol, which is the target of an indirect
- symbol that we have changed to no longer be an indirect
- symbol. */
- skip_next = false;
- continue;
- }
- else
- {
- struct aout_link_hash_entry *hresolve;
-
- /* We have saved the hash table entry for this symbol, if
- there is one. Note that we could just look it up again
- in the hash table, provided we first check that it is an
- external symbol. */
- h = *sym_hash;
-
- /* Use the name from the hash table, in case the symbol was
- wrapped. */
- if (h != NULL)
- name = h->root.root.string;
-
- /* If this is an indirect or warning symbol, then change
- hresolve to the base symbol. We also change *sym_hash so
- that the relocation routines relocate against the real
- symbol. */
- hresolve = h;
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning))
- {
- hresolve = (struct aout_link_hash_entry *) h->root.u.i.link;
- while (hresolve->root.type == bfd_link_hash_indirect
- || hresolve->root.type == bfd_link_hash_warning)
- hresolve = ((struct aout_link_hash_entry *)
- hresolve->root.u.i.link);
- *sym_hash = hresolve;
- }
-
- /* If the symbol has already been written out, skip it. */
- if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type != bfd_link_hash_warning
- && h->written)
- {
- if ((type & N_TYPE) == N_INDR
- || type == N_WARNING)
- skip_next = true;
- *symbol_map = h->indx;
- continue;
- }
-
- /* See if we are stripping this symbol. */
- skip = false;
- switch (strip)
- {
- case strip_none:
- break;
- case strip_debugger:
- if ((type & N_STAB) != 0)
- skip = true;
- break;
- case strip_some:
- if (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
- == NULL)
- skip = true;
- break;
- case strip_all:
- skip = true;
- break;
- }
- if (skip)
- {
- if (h != (struct aout_link_hash_entry *) NULL)
- h->written = true;
- continue;
- }
-
- /* Get the value of the symbol. */
- if ((type & N_TYPE) == N_TEXT
- || type == N_WEAKT)
- symsec = obj_textsec (input_bfd);
- else if ((type & N_TYPE) == N_DATA
- || type == N_WEAKD)
- symsec = obj_datasec (input_bfd);
- else if ((type & N_TYPE) == N_BSS
- || type == N_WEAKB)
- symsec = obj_bsssec (input_bfd);
- else if ((type & N_TYPE) == N_ABS
- || type == N_WEAKA)
- symsec = bfd_abs_section_ptr;
- else if (((type & N_TYPE) == N_INDR
- && (hresolve == (struct aout_link_hash_entry *) NULL
- || (hresolve->root.type != bfd_link_hash_defined
- && hresolve->root.type != bfd_link_hash_defweak
- && hresolve->root.type != bfd_link_hash_common)))
- || type == N_WARNING)
- {
- /* Pass the next symbol through unchanged. The
- condition above for indirect symbols is so that if
- the indirect symbol was defined, we output it with
- the correct definition so the debugger will
- understand it. */
- pass = true;
- val = GET_WORD (input_bfd, sym->e_value);
- symsec = NULL;
- }
- else if ((type & N_STAB) != 0)
- {
- val = GET_WORD (input_bfd, sym->e_value);
- symsec = NULL;
- }
- else
- {
- /* If we get here with an indirect symbol, it means that
- we are outputting it with a real definition. In such
- a case we do not want to output the next symbol,
- which is the target of the indirection. */
- if ((type & N_TYPE) == N_INDR)
- skip_next = true;
-
- symsec = NULL;
-
- /* We need to get the value from the hash table. We use
- hresolve so that if we have defined an indirect
- symbol we output the final definition. */
- if (h == (struct aout_link_hash_entry *) NULL)
- {
- switch (type & N_TYPE)
- {
- case N_SETT:
- symsec = obj_textsec (input_bfd);
- break;
- case N_SETD:
- symsec = obj_datasec (input_bfd);
- break;
- case N_SETB:
- symsec = obj_bsssec (input_bfd);
- break;
- case N_SETA:
- symsec = bfd_abs_section_ptr;
- break;
- default:
- val = 0;
- break;
- }
- }
- else if (hresolve->root.type == bfd_link_hash_defined
- || hresolve->root.type == bfd_link_hash_defweak)
- {
- asection *input_section;
- asection *output_section;
-
- /* This case usually means a common symbol which was
- turned into a defined symbol. */
- input_section = hresolve->root.u.def.section;
- output_section = input_section->output_section;
- BFD_ASSERT (bfd_is_abs_section (output_section)
- || output_section->owner == output_bfd);
- val = (hresolve->root.u.def.value
- + bfd_get_section_vma (output_bfd, output_section)
- + input_section->output_offset);
-
- /* Get the correct type based on the section. If
- this is a constructed set, force it to be
- globally visible. */
- if (type == N_SETT
- || type == N_SETD
- || type == N_SETB
- || type == N_SETA)
- type |= N_EXT;
-
- type &=~ N_TYPE;
-
- if (output_section == obj_textsec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_TEXT
- : N_WEAKT);
- else if (output_section == obj_datasec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_DATA
- : N_WEAKD);
- else if (output_section == obj_bsssec (output_bfd))
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_BSS
- : N_WEAKB);
- else
- type |= (hresolve->root.type == bfd_link_hash_defined
- ? N_ABS
- : N_WEAKA);
- }
- else if (hresolve->root.type == bfd_link_hash_common)
- val = hresolve->root.u.c.size;
- else if (hresolve->root.type == bfd_link_hash_undefweak)
- {
- val = 0;
- type = N_WEAKU;
- }
- else
- val = 0;
- }
- if (symsec != (asection *) NULL)
- val = (symsec->output_section->vma
- + symsec->output_offset
- + (GET_WORD (input_bfd, sym->e_value)
- - symsec->vma));
-
- /* If this is a global symbol set the written flag, and if
- it is a local symbol see if we should discard it. */
- if (h != (struct aout_link_hash_entry *) NULL)
- {
- h->written = true;
- h->indx = obj_aout_external_sym_count (output_bfd);
- }
- else if ((type & N_TYPE) != N_SETT
- && (type & N_TYPE) != N_SETD
- && (type & N_TYPE) != N_SETB
- && (type & N_TYPE) != N_SETA)
- {
- switch (discard)
- {
- case discard_none:
- break;
- case discard_l:
- if (*name == *finfo->info->lprefix
- && (finfo->info->lprefix_len == 1
- || strncmp (name, finfo->info->lprefix,
- finfo->info->lprefix_len) == 0))
- skip = true;
- break;
- case discard_all:
- skip = true;
- break;
- }
- if (skip)
- {
- pass = false;
- continue;
- }
- }
-
- /* An N_BINCL symbol indicates the start of the stabs
- entries for a header file. We need to scan ahead to the
- next N_EINCL symbol, ignoring nesting, adding up all the
- characters in the symbol names, not including the file
- numbers in types (the first number after an open
- parenthesis). */
- if (type == N_BINCL)
- {
- struct external_nlist *incl_sym;
- int nest;
- struct aout_link_includes_entry *incl_entry;
- struct aout_link_includes_totals *t;
-
- val = 0;
- nest = 0;
- for (incl_sym = sym + 1; incl_sym < sym_end; incl_sym++)
- {
- int incl_type;
-
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
- if (incl_type == N_EINCL)
- {
- if (nest == 0)
- break;
- --nest;
- }
- else if (incl_type == N_BINCL)
- ++nest;
- else if (nest == 0)
- {
- const char *s;
-
- s = strings + GET_WORD (input_bfd, incl_sym->e_strx);
- for (; *s != '\0'; s++)
- {
- val += *s;
- if (*s == '(')
- {
- /* Skip the file number. */
- ++s;
- while (isdigit ((unsigned char) *s))
- ++s;
- --s;
- }
- }
- }
- }
-
- /* If we have already included a header file with the
- same value, then replace this one with an N_EXCL
- symbol. */
- copy = ! finfo->info->keep_memory;
- incl_entry = aout_link_includes_lookup (&finfo->includes,
- name, true, copy);
- if (incl_entry == NULL)
- return false;
- for (t = incl_entry->totals; t != NULL; t = t->next)
- if (t->total == val)
- break;
- if (t == NULL)
- {
- /* This is the first time we have seen this header
- file with this set of stabs strings. */
- t = ((struct aout_link_includes_totals *)
- bfd_hash_allocate (&finfo->includes.root,
- sizeof *t));
- if (t == NULL)
- return false;
- t->total = val;
- t->next = incl_entry->totals;
- incl_entry->totals = t;
- }
- else
- {
- int *incl_map;
-
- /* This is a duplicate header file. We must change
- it to be an N_EXCL entry, and mark all the
- included symbols to prevent outputting them. */
- type = N_EXCL;
-
- nest = 0;
- for (incl_sym = sym + 1, incl_map = symbol_map + 1;
- incl_sym < sym_end;
- incl_sym++, incl_map++)
- {
- int incl_type;
-
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
- if (incl_type == N_EINCL)
- {
- if (nest == 0)
- {
- *incl_map = -1;
- break;
- }
- --nest;
- }
- else if (incl_type == N_BINCL)
- ++nest;
- else if (nest == 0)
- *incl_map = -1;
- }
- }
- }
- }
-
- /* Copy this symbol into the list of symbols we are going to
- write out. */
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
- bfd_h_put_8 (output_bfd, bfd_h_get_8 (input_bfd, sym->e_other),
- outsym->e_other);
- bfd_h_put_16 (output_bfd, bfd_h_get_16 (input_bfd, sym->e_desc),
- outsym->e_desc);
- copy = false;
- if (! finfo->info->keep_memory)
- {
- /* name points into a string table which we are going to
- free. If there is a hash table entry, use that string.
- Otherwise, copy name into memory. */
- if (h != (struct aout_link_hash_entry *) NULL)
- name = h->root.root.string;
- else
- copy = true;
- }
- strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
- name, copy);
- if (strtab_index == (bfd_size_type) -1)
- return false;
- PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
- PUT_WORD (output_bfd, val, outsym->e_value);
- *symbol_map = obj_aout_external_sym_count (output_bfd);
- ++obj_aout_external_sym_count (output_bfd);
- ++outsym;
- }
-
- /* Write out the output symbols we have just constructed. */
- if (outsym > finfo->output_syms)
- {
- bfd_size_type outsym_count;
-
- if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
- return false;
- outsym_count = outsym - finfo->output_syms;
- if (bfd_write ((PTR) finfo->output_syms,
- (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) outsym_count, output_bfd)
- != outsym_count * EXTERNAL_NLIST_SIZE)
- return false;
- finfo->symoff += outsym_count * EXTERNAL_NLIST_SIZE;
- }
-
- return true;
-}
-
-/* Write out a symbol that was not associated with an a.out input
- object. */
-
-static boolean
-aout_link_write_other_symbol (h, data)
- struct aout_link_hash_entry *h;
- PTR data;
-{
- struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
- bfd *output_bfd;
- int type;
- bfd_vma val;
- struct external_nlist outsym;
- bfd_size_type indx;
-
- output_bfd = finfo->output_bfd;
-
- if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
- {
- if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
- (output_bfd, finfo->info, h)))
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
- }
-
- if (h->written)
- return true;
-
- h->written = true;
-
- /* An indx of -2 means the symbol must be written. */
- if (h->indx != -2
- && (finfo->info->strip == strip_all
- || (finfo->info->strip == strip_some
- && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
- false, false) == NULL)))
- return true;
-
- switch (h->root.type)
- {
- default:
- abort ();
- /* Avoid variable not initialized warnings. */
- return true;
- case bfd_link_hash_new:
- /* This can happen for set symbols when sets are not being
- built. */
- return true;
- case bfd_link_hash_undefined:
- type = N_UNDF | N_EXT;
- val = 0;
- break;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- {
- asection *sec;
-
- sec = h->root.u.def.section->output_section;
- BFD_ASSERT (bfd_is_abs_section (sec)
- || sec->owner == output_bfd);
- if (sec == obj_textsec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_TEXT : N_WEAKT;
- else if (sec == obj_datasec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_DATA : N_WEAKD;
- else if (sec == obj_bsssec (output_bfd))
- type = h->root.type == bfd_link_hash_defined ? N_BSS : N_WEAKB;
- else
- type = h->root.type == bfd_link_hash_defined ? N_ABS : N_WEAKA;
- type |= N_EXT;
- val = (h->root.u.def.value
- + sec->vma
- + h->root.u.def.section->output_offset);
- }
- break;
- case bfd_link_hash_common:
- type = N_UNDF | N_EXT;
- val = h->root.u.c.size;
- break;
- case bfd_link_hash_undefweak:
- type = N_WEAKU;
- val = 0;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: Ignore these for now. The circumstances under which
- they should be written out are not clear to me. */
- return true;
- }
-
- bfd_h_put_8 (output_bfd, type, outsym.e_type);
- bfd_h_put_8 (output_bfd, 0, outsym.e_other);
- bfd_h_put_16 (output_bfd, 0, outsym.e_desc);
- indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
- false);
- if (indx == (bfd_size_type) -1)
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
- PUT_WORD (output_bfd, indx, outsym.e_strx);
- PUT_WORD (output_bfd, val, outsym.e_value);
-
- if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
- || bfd_write ((PTR) &outsym, (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) 1, output_bfd) != EXTERNAL_NLIST_SIZE)
- {
- /* FIXME: No way to handle errors. */
- abort ();
- }
-
- finfo->symoff += EXTERNAL_NLIST_SIZE;
- h->indx = obj_aout_external_sym_count (output_bfd);
- ++obj_aout_external_sym_count (output_bfd);
-
- return true;
-}
-
-/* Link an a.out section into the output file. */
-
-static boolean
-aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
- rel_size)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- file_ptr *reloff_ptr;
- bfd_size_type rel_size;
-{
- bfd_size_type input_size;
- PTR relocs;
-
- /* Get the section contents. */
- input_size = bfd_section_size (input_bfd, input_section);
- if (! bfd_get_section_contents (input_bfd, input_section,
- (PTR) finfo->contents,
- (file_ptr) 0, input_size))
- return false;
-
- /* Read in the relocs if we haven't already done it. */
- if (aout_section_data (input_section) != NULL
- && aout_section_data (input_section)->relocs != NULL)
- relocs = aout_section_data (input_section)->relocs;
- else
- {
- relocs = finfo->relocs;
- if (rel_size > 0)
- {
- if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, input_bfd) != rel_size)
- return false;
- }
- }
-
- /* Relocate the section contents. */
- if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
- {
- if (! aout_link_input_section_std (finfo, input_bfd, input_section,
- (struct reloc_std_external *) relocs,
- rel_size, finfo->contents))
- return false;
- }
- else
- {
- if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
- (struct reloc_ext_external *) relocs,
- rel_size, finfo->contents))
- return false;
- }
-
- /* Write out the section contents. */
- if (! bfd_set_section_contents (finfo->output_bfd,
- input_section->output_section,
- (PTR) finfo->contents,
- input_section->output_offset,
- input_size))
- return false;
-
- /* If we are producing relocateable output, the relocs were
- modified, and we now write them out. */
- if (finfo->info->relocateable && rel_size > 0)
- {
- if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
- return false;
- if (bfd_write (relocs, (bfd_size_type) 1, rel_size, finfo->output_bfd)
- != rel_size)
- return false;
- *reloff_ptr += rel_size;
-
- /* Assert that the relocs have not run into the symbols, and
- that if these are the text relocs they have not run into the
- data relocs. */
- BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
- && (reloff_ptr != &finfo->treloff
- || (*reloff_ptr
- <= obj_datasec (finfo->output_bfd)->rel_filepos)));
- }
-
- return true;
-}
-
-/* Get the section corresponding to a reloc index. */
-
-static INLINE asection *
-aout_reloc_index_to_section (abfd, indx)
- bfd *abfd;
- int indx;
-{
- switch (indx & N_TYPE)
- {
- case N_TEXT:
- return obj_textsec (abfd);
- case N_DATA:
- return obj_datasec (abfd);
- case N_BSS:
- return obj_bsssec (abfd);
- case N_ABS:
- case N_UNDF:
- return bfd_abs_section_ptr;
- default:
- abort ();
- }
-}
-
-/* Relocate an a.out section using standard a.out relocs. */
-
-static boolean
-aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
- rel_size, contents)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- struct reloc_std_external *relocs;
- bfd_size_type rel_size;
- bfd_byte *contents;
-{
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
- bfd *, asection *,
- struct aout_link_hash_entry *,
- PTR, bfd_byte *, boolean *,
- bfd_vma *));
- bfd *output_bfd;
- boolean relocateable;
- struct external_nlist *syms;
- char *strings;
- struct aout_link_hash_entry **sym_hashes;
- int *symbol_map;
- bfd_size_type reloc_count;
- register struct reloc_std_external *rel;
- struct reloc_std_external *rel_end;
-
- output_bfd = finfo->output_bfd;
- check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
-
- BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
- BFD_ASSERT (input_bfd->xvec->header_byteorder
- == output_bfd->xvec->header_byteorder);
-
- relocateable = finfo->info->relocateable;
- syms = obj_aout_external_syms (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- sym_hashes = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
-
- reloc_count = rel_size / RELOC_STD_SIZE;
- rel = relocs;
- rel_end = rel + reloc_count;
- for (; rel < rel_end; rel++)
- {
- bfd_vma r_addr;
- int r_index;
- int r_extern;
- int r_pcrel;
- int r_baserel = 0;
- reloc_howto_type *howto;
- struct aout_link_hash_entry *h = NULL;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_addr = GET_SWORD (input_bfd, rel->r_address);
-
-#ifdef MY_reloc_howto
- howto = MY_reloc_howto(input_bfd, rel, r_index, r_extern, r_pcrel);
-#else
- {
- int r_jmptable;
- int r_relative;
- int r_length;
- unsigned int howto_idx;
-
- if (bfd_header_big_endian (input_bfd))
- {
- r_index = ((rel->r_index[0] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[2]);
- r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
- r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
- r_baserel = (0 != (rel->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
- r_jmptable= (0 != (rel->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- r_relative= (0 != (rel->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
- >> RELOC_STD_BITS_LENGTH_SH_BIG);
- }
- else
- {
- r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0]);
- r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
- r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_baserel = (0 != (rel->r_type[0]
- & RELOC_STD_BITS_BASEREL_LITTLE));
- r_jmptable= (0 != (rel->r_type[0]
- & RELOC_STD_BITS_JMPTABLE_LITTLE));
- r_relative= (0 != (rel->r_type[0]
- & RELOC_STD_BITS_RELATIVE_LITTLE));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
- }
-
- howto_idx = (r_length + 4 * r_pcrel + 8 * r_baserel
- + 16 * r_jmptable + 32 * r_relative);
- BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
- howto = howto_table_std + howto_idx;
- }
-#endif
-
- if (relocateable)
- {
- /* We are generating a relocateable output file, and must
- modify the reloc accordingly. */
- if (r_extern)
- {
- /* If we know the symbol this relocation is against,
- convert it into a relocation against a section. This
- is what the native linker does. */
- h = sym_hashes[r_index];
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- asection *output_section;
-
- /* Change the r_extern value. */
- if (bfd_header_big_endian (output_bfd))
- rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_BIG;
- else
- rel->r_type[0] &=~ RELOC_STD_BITS_EXTERN_LITTLE;
-
- /* Compute a new r_index. */
- output_section = h->root.u.def.section->output_section;
- if (output_section == obj_textsec (output_bfd))
- r_index = N_TEXT;
- else if (output_section == obj_datasec (output_bfd))
- r_index = N_DATA;
- else if (output_section == obj_bsssec (output_bfd))
- r_index = N_BSS;
- else
- r_index = N_ABS;
-
- /* Add the symbol value and the section VMA to the
- addend stored in the contents. */
- relocation = (h->root.u.def.value
- + output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else
- {
- /* We must change r_index according to the symbol
- map. */
- r_index = symbol_map[r_index];
-
- if (r_index == -1)
- {
- if (h != NULL)
- {
- /* We decided to strip this symbol, but it
- turns out that we can't. Note that we
- lose the other and desc information here.
- I don't think that will ever matter for a
- global symbol. */
- if (h->indx < 0)
- {
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h,
- (PTR) finfo))
- return false;
- }
- r_index = h->indx;
- }
- else
- {
- const char *name;
-
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
- }
- }
-
- relocation = 0;
- }
-
- /* Write out the new r_index value. */
- if (bfd_header_big_endian (output_bfd))
- {
- rel->r_index[0] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[2] = r_index;
- }
- else
- {
- rel->r_index[2] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[0] = r_index;
- }
- }
- else
- {
- asection *section;
-
- /* This is a relocation against a section. We must
- adjust by the amount that the section moved. */
- section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (section->output_section->vma
- + section->output_offset
- - section->vma);
- }
-
- /* Change the address of the relocation. */
- PUT_WORD (output_bfd,
- r_addr + input_section->output_offset,
- rel->r_address);
-
- /* Adjust a PC relative relocation by removing the reference
- to the original address in the section and including the
- reference to the new address. */
- if (r_pcrel)
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
-#ifdef MY_relocatable_reloc
- MY_relocatable_reloc (howto, output_bfd, rel, relocation, r_addr);
-#endif
-
- if (relocation == 0)
- r = bfd_reloc_ok;
- else
- r = MY_relocate_contents (howto,
- input_bfd, relocation,
- contents + r_addr);
- }
- else
- {
- boolean hundef;
-
- /* We are generating an executable, and must do a full
- relocation. */
- hundef = false;
- if (r_extern)
- {
- h = sym_hashes[r_index];
-
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- relocation = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- hundef = true;
- relocation = 0;
- }
- }
- else
- {
- asection *section;
-
- section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (section->output_section->vma
- + section->output_offset
- - section->vma);
- if (r_pcrel)
- relocation += input_section->vma;
- }
-
- if (check_dynamic_reloc != NULL)
- {
- boolean skip;
-
- if (! ((*check_dynamic_reloc)
- (finfo->info, input_bfd, input_section, h,
- (PTR) rel, contents, &skip, &relocation)))
- return false;
- if (skip)
- continue;
- }
-
- /* Now warn if a global symbol is undefined. We could not
- do this earlier, because check_dynamic_reloc might want
- to skip this reloc. */
- if (hundef && ! finfo->info->shared && ! r_baserel)
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->undefined_symbol)
- (finfo->info, name, input_bfd, input_section, r_addr)))
- return false;
- }
-
- r = MY_final_link_relocate (howto,
- input_bfd, input_section,
- contents, r_addr, relocation,
- (bfd_vma) 0);
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (r_extern)
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- else
- {
- asection *s;
-
- s = aout_reloc_index_to_section (input_bfd, r_index);
- name = bfd_section_name (input_bfd, s);
- }
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info, name, howto->name,
- (bfd_vma) 0, input_bfd, input_section, r_addr)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Relocate an a.out section using extended a.out relocs. */
-
-static boolean
-aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
- rel_size, contents)
- struct aout_final_link_info *finfo;
- bfd *input_bfd;
- asection *input_section;
- struct reloc_ext_external *relocs;
- bfd_size_type rel_size;
- bfd_byte *contents;
-{
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
- bfd *, asection *,
- struct aout_link_hash_entry *,
- PTR, bfd_byte *, boolean *,
- bfd_vma *));
- bfd *output_bfd;
- boolean relocateable;
- struct external_nlist *syms;
- char *strings;
- struct aout_link_hash_entry **sym_hashes;
- int *symbol_map;
- bfd_size_type reloc_count;
- register struct reloc_ext_external *rel;
- struct reloc_ext_external *rel_end;
-
- output_bfd = finfo->output_bfd;
- check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
-
- BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
- BFD_ASSERT (input_bfd->xvec->header_byteorder
- == output_bfd->xvec->header_byteorder);
-
- relocateable = finfo->info->relocateable;
- syms = obj_aout_external_syms (input_bfd);
- strings = obj_aout_external_strings (input_bfd);
- sym_hashes = obj_aout_sym_hashes (input_bfd);
- symbol_map = finfo->symbol_map;
-
- reloc_count = rel_size / RELOC_EXT_SIZE;
- rel = relocs;
- rel_end = rel + reloc_count;
- for (; rel < rel_end; rel++)
- {
- bfd_vma r_addr;
- int r_index;
- int r_extern;
- unsigned int r_type;
- bfd_vma r_addend;
- struct aout_link_hash_entry *h = NULL;
- asection *r_section = NULL;
- bfd_vma relocation;
-
- r_addr = GET_SWORD (input_bfd, rel->r_address);
-
- if (bfd_header_big_endian (input_bfd))
- {
- r_index = ((rel->r_index[0] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[2]);
- r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
- r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG);
- }
- else
- {
- r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0]);
- r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
- r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
- >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
- }
-
- r_addend = GET_SWORD (input_bfd, rel->r_addend);
-
- BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
-
- if (relocateable)
- {
- /* We are generating a relocateable output file, and must
- modify the reloc accordingly. */
- if (r_extern)
- {
- /* If we know the symbol this relocation is against,
- convert it into a relocation against a section. This
- is what the native linker does. */
- h = sym_hashes[r_index];
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- asection *output_section;
-
- /* Change the r_extern value. */
- if (bfd_header_big_endian (output_bfd))
- rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_BIG;
- else
- rel->r_type[0] &=~ RELOC_EXT_BITS_EXTERN_LITTLE;
-
- /* Compute a new r_index. */
- output_section = h->root.u.def.section->output_section;
- if (output_section == obj_textsec (output_bfd))
- r_index = N_TEXT;
- else if (output_section == obj_datasec (output_bfd))
- r_index = N_DATA;
- else if (output_section == obj_bsssec (output_bfd))
- r_index = N_BSS;
- else
- r_index = N_ABS;
-
- /* Add the symbol value and the section VMA to the
- addend. */
- relocation = (h->root.u.def.value
- + output_section->vma
- + h->root.u.def.section->output_offset);
-
- /* Now RELOCATION is the VMA of the final
- destination. If this is a PC relative reloc,
- then ADDEND is the negative of the source VMA.
- We want to set ADDEND to the difference between
- the destination VMA and the source VMA, which
- means we must adjust RELOCATION by the change in
- the source VMA. This is done below. */
- }
- else
- {
- /* We must change r_index according to the symbol
- map. */
- r_index = symbol_map[r_index];
-
- if (r_index == -1)
- {
- if (h != NULL)
- {
- /* We decided to strip this symbol, but it
- turns out that we can't. Note that we
- lose the other and desc information here.
- I don't think that will ever matter for a
- global symbol. */
- if (h->indx < 0)
- {
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h,
- (PTR) finfo))
- return false;
- }
- r_index = h->indx;
- }
- else
- {
- const char *name;
-
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
- }
- }
-
- relocation = 0;
-
- /* If this is a PC relative reloc, then the addend
- is the negative of the source VMA. We must
- adjust it by the change in the source VMA. This
- is done below. */
- }
-
- /* Write out the new r_index value. */
- if (bfd_header_big_endian (output_bfd))
- {
- rel->r_index[0] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[2] = r_index;
- }
- else
- {
- rel->r_index[2] = r_index >> 16;
- rel->r_index[1] = r_index >> 8;
- rel->r_index[0] = r_index;
- }
- }
- else
- {
- /* This is a relocation against a section. We must
- adjust by the amount that the section moved. */
- r_section = aout_reloc_index_to_section (input_bfd, r_index);
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- - r_section->vma);
-
- /* If this is a PC relative reloc, then the addend is
- the difference in VMA between the destination and the
- source. We have just adjusted for the change in VMA
- of the destination, so we must also adjust by the
- change in VMA of the source. This is done below. */
- }
-
- /* As described above, we must always adjust a PC relative
- reloc by the change in VMA of the source. */
- if (howto_table_ext[r_type].pc_relative)
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
- /* Change the addend if necessary. */
- if (relocation != 0)
- PUT_WORD (output_bfd, r_addend + relocation, rel->r_addend);
-
- /* Change the address of the relocation. */
- PUT_WORD (output_bfd,
- r_addr + input_section->output_offset,
- rel->r_address);
- }
- else
- {
- boolean hundef;
- bfd_reloc_status_type r;
-
- /* We are generating an executable, and must do a full
- relocation. */
- hundef = false;
- if (r_extern)
- {
- h = sym_hashes[r_index];
-
- if (h != (struct aout_link_hash_entry *) NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- relocation = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- }
- else if (h != (struct aout_link_hash_entry *) NULL
- && h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- hundef = true;
- relocation = 0;
- }
- }
- else if (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- {
- struct external_nlist *sym;
- int type;
-
- /* For base relative relocs, r_index is always an index
- into the symbol table, even if r_extern is 0. */
- sym = syms + r_index;
- type = bfd_h_get_8 (input_bfd, sym->e_type);
- if ((type & N_TYPE) == N_TEXT
- || type == N_WEAKT)
- r_section = obj_textsec (input_bfd);
- else if ((type & N_TYPE) == N_DATA
- || type == N_WEAKD)
- r_section = obj_datasec (input_bfd);
- else if ((type & N_TYPE) == N_BSS
- || type == N_WEAKB)
- r_section = obj_bsssec (input_bfd);
- else if ((type & N_TYPE) == N_ABS
- || type == N_WEAKA)
- r_section = bfd_abs_section_ptr;
- else
- abort ();
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- + (GET_WORD (input_bfd, sym->e_value)
- - r_section->vma));
- }
- else
- {
- r_section = aout_reloc_index_to_section (input_bfd, r_index);
-
- /* If this is a PC relative reloc, then R_ADDEND is the
- difference between the two vmas, or
- old_dest_sec + old_dest_off - (old_src_sec + old_src_off)
- where
- old_dest_sec == section->vma
- and
- old_src_sec == input_section->vma
- and
- old_src_off == r_addr
-
- _bfd_final_link_relocate expects RELOCATION +
- R_ADDEND to be the VMA of the destination minus
- r_addr (the minus r_addr is because this relocation
- is not pcrel_offset, which is a bit confusing and
- should, perhaps, be changed), or
- new_dest_sec
- where
- new_dest_sec == output_section->vma + output_offset
- We arrange for this to happen by setting RELOCATION to
- new_dest_sec + old_src_sec - old_dest_sec
-
- If this is not a PC relative reloc, then R_ADDEND is
- simply the VMA of the destination, so we set
- RELOCATION to the change in the destination VMA, or
- new_dest_sec - old_dest_sec
- */
- relocation = (r_section->output_section->vma
- + r_section->output_offset
- - r_section->vma);
- if (howto_table_ext[r_type].pc_relative)
- relocation += input_section->vma;
- }
-
- if (check_dynamic_reloc != NULL)
- {
- boolean skip;
-
- if (! ((*check_dynamic_reloc)
- (finfo->info, input_bfd, input_section, h,
- (PTR) rel, contents, &skip, &relocation)))
- return false;
- if (skip)
- continue;
- }
-
- /* Now warn if a global symbol is undefined. We could not
- do this earlier, because check_dynamic_reloc might want
- to skip this reloc. */
- if (hundef
- && ! finfo->info->shared
- && r_type != RELOC_BASE10
- && r_type != RELOC_BASE13
- && r_type != RELOC_BASE22)
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->undefined_symbol)
- (finfo->info, name, input_bfd, input_section, r_addr)))
- return false;
- }
-
- r = MY_final_link_relocate (howto_table_ext + r_type,
- input_bfd, input_section,
- contents, r_addr, relocation,
- r_addend);
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (r_extern
- || r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- else
- {
- asection *s;
-
- s = aout_reloc_index_to_section (input_bfd, r_index);
- name = bfd_section_name (input_bfd, s);
- }
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info, name, howto_table_ext[r_type].name,
- r_addend, input_bfd, input_section, r_addr)))
- return false;
- }
- break;
- }
- }
- }
- }
-
- return true;
-}
-
-/* Handle a link order which is supposed to generate a reloc. */
-
-static boolean
-aout_link_reloc_link_order (finfo, o, p)
- struct aout_final_link_info *finfo;
- asection *o;
- struct bfd_link_order *p;
-{
- struct bfd_link_order_reloc *pr;
- int r_index;
- int r_extern;
- reloc_howto_type *howto;
- file_ptr *reloff_ptr;
- struct reloc_std_external srel;
- struct reloc_ext_external erel;
- PTR rel_ptr;
-
- pr = p->u.reloc.p;
-
- if (p->type == bfd_section_reloc_link_order)
- {
- r_extern = 0;
- if (bfd_is_abs_section (pr->u.section))
- r_index = N_ABS | N_EXT;
- else
- {
- BFD_ASSERT (pr->u.section->owner == finfo->output_bfd);
- r_index = pr->u.section->target_index;
- }
- }
- else
- {
- struct aout_link_hash_entry *h;
-
- BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
- r_extern = 1;
- h = ((struct aout_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
- pr->u.name, false, false, true));
- if (h != (struct aout_link_hash_entry *) NULL
- && h->indx >= 0)
- r_index = h->indx;
- else if (h != NULL)
- {
- /* We decided to strip this symbol, but it turns out that we
- can't. Note that we lose the other and desc information
- here. I don't think that will ever matter for a global
- symbol. */
- h->indx = -2;
- h->written = false;
- if (! aout_link_write_other_symbol (h, (PTR) finfo))
- return false;
- r_index = h->indx;
- }
- else
- {
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, pr->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- r_index = 0;
- }
- }
-
- howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
- if (howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (o == obj_textsec (finfo->output_bfd))
- reloff_ptr = &finfo->treloff;
- else if (o == obj_datasec (finfo->output_bfd))
- reloff_ptr = &finfo->dreloff;
- else
- abort ();
-
- if (obj_reloc_entry_size (finfo->output_bfd) == RELOC_STD_SIZE)
- {
-#ifdef MY_put_reloc
- MY_put_reloc(finfo->output_bfd, r_extern, r_index, p->offset, howto,
- &srel);
-#else
- {
- int r_pcrel;
- int r_baserel;
- int r_jmptable;
- int r_relative;
- int r_length;
-
- r_pcrel = howto->pc_relative;
- r_baserel = (howto->type & 8) != 0;
- r_jmptable = (howto->type & 16) != 0;
- r_relative = (howto->type & 32) != 0;
- r_length = howto->size;
-
- PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
- if (bfd_header_big_endian (finfo->output_bfd))
- {
- srel.r_index[0] = r_index >> 16;
- srel.r_index[1] = r_index >> 8;
- srel.r_index[2] = r_index;
- srel.r_type[0] =
- ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
- | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
- | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
- | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
- | (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
- }
- else
- {
- srel.r_index[2] = r_index >> 16;
- srel.r_index[1] = r_index >> 8;
- srel.r_index[0] = r_index;
- srel.r_type[0] =
- ((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
- | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
- | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
- | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
- | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
- }
- }
-#endif
- rel_ptr = (PTR) &srel;
-
- /* We have to write the addend into the object file, since
- standard a.out relocs are in place. It would be more
- reliable if we had the current contents of the file here,
- rather than assuming zeroes, but we can't read the file since
- it was opened using bfd_openw. */
- if (pr->addend != 0)
- {
- bfd_size_type size;
- bfd_reloc_status_type r;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- r = MY_relocate_contents (howto, finfo->output_bfd,
- pr->addend, buf);
- switch (r)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info,
- (p->type == bfd_section_reloc_link_order
- ? bfd_section_name (finfo->output_bfd,
- pr->u.section)
- : pr->u.name),
- howto->name, pr->addend, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (finfo->output_bfd, o,
- (PTR) buf,
- (file_ptr) p->offset,
- size);
- free (buf);
- if (! ok)
- return false;
- }
- }
- else
- {
- PUT_WORD (finfo->output_bfd, p->offset, erel.r_address);
-
- if (bfd_header_big_endian (finfo->output_bfd))
- {
- erel.r_index[0] = r_index >> 16;
- erel.r_index[1] = r_index >> 8;
- erel.r_index[2] = r_index;
- erel.r_type[0] =
- ((r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
- | (howto->type << RELOC_EXT_BITS_TYPE_SH_BIG));
- }
- else
- {
- erel.r_index[2] = r_index >> 16;
- erel.r_index[1] = r_index >> 8;
- erel.r_index[0] = r_index;
- erel.r_type[0] =
- (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
- | (howto->type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
- }
-
- PUT_WORD (finfo->output_bfd, pr->addend, erel.r_addend);
-
- rel_ptr = (PTR) &erel;
- }
-
- if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
- || (bfd_write (rel_ptr, (bfd_size_type) 1,
- obj_reloc_entry_size (finfo->output_bfd),
- finfo->output_bfd)
- != obj_reloc_entry_size (finfo->output_bfd)))
- return false;
-
- *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
-
- /* Assert that the relocs have not run into the symbols, and that n
- the text relocs have not run into the data relocs. */
- BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
- && (reloff_ptr != &finfo->treloff
- || (*reloff_ptr
- <= obj_datasec (finfo->output_bfd)->rel_filepos)));
-
- return true;
-}
diff --git a/contrib/gdb/bfd/archive.c b/contrib/gdb/bfd/archive.c
deleted file mode 100644
index 248b918..0000000
--- a/contrib/gdb/bfd/archive.c
+++ /dev/null
@@ -1,2094 +0,0 @@
-/* BFD back-end for archive files (libraries).
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-@setfilename archive-info
-SECTION
- Archives
-
-DESCRIPTION
- An archive (or library) is just another BFD. It has a symbol
- table, although there's not much a user program will do with it.
-
- The big difference between an archive BFD and an ordinary BFD
- is that the archive doesn't have sections. Instead it has a
- chain of BFDs that are considered its contents. These BFDs can
- be manipulated like any other. The BFDs contained in an
- archive opened for reading will all be opened for reading. You
- may put either input or output BFDs into an archive opened for
- output; they will be handled correctly when the archive is closed.
-
- Use <<bfd_openr_next_archived_file>> to step through
- the contents of an archive opened for input. You don't
- have to read the entire archive if you don't want
- to! Read it until you find what you want.
-
- Archive contents of output BFDs are chained through the
- <<next>> pointer in a BFD. The first one is findable through
- the <<archive_head>> slot of the archive. Set it with
- <<bfd_set_archive_head>> (q.v.). A given BFD may be in only one
- open output archive at a time.
-
- As expected, the BFD archive code is more general than the
- archive code of any given environment. BFD archives may
- contain files of different formats (e.g., a.out and coff) and
- even different architectures. You may even place archives
- recursively into archives!
-
- This can cause unexpected confusion, since some archive
- formats are more expressive than others. For instance, Intel
- COFF archives can preserve long filenames; SunOS a.out archives
- cannot. If you move a file from the first to the second
- format and back again, the filename may be truncated.
- Likewise, different a.out environments have different
- conventions as to how they truncate filenames, whether they
- preserve directory names in filenames, etc. When
- interoperating with native tools, be sure your files are
- homogeneous.
-
- Beware: most of these formats do not react well to the
- presence of spaces in filenames. We do the best we can, but
- can't always handle this case due to restrictions in the format of
- archives. Many Unix utilities are braindead in regards to
- spaces and such in filenames anyway, so this shouldn't be much
- of a restriction.
-
- Archives are supported in BFD in <<archive.c>>.
-
-*/
-
-/* Assumes:
- o - all archive elements start on an even boundary, newline padded;
- o - all arch headers are char *;
- o - all arch headers are the same size (across architectures).
-*/
-
-/* Some formats provide a way to cram a long filename into the short
- (16 chars) space provided by a BSD archive. The trick is: make a
- special "file" in the front of the archive, sort of like the SYMDEF
- entry. If the filename is too long to fit, put it in the extended
- name table, and use its index as the filename. To prevent
- confusion prepend the index with a space. This means you can't
- have filenames that start with a space, but then again, many Unix
- utilities can't handle that anyway.
-
- This scheme unfortunately requires that you stand on your head in
- order to write an archive since you need to put a magic file at the
- front, and need to touch every entry to do so. C'est la vie.
-
- We support two variants of this idea:
- The SVR4 format (extended name table is named "//"),
- and an extended pseudo-BSD variant (extended name table is named
- "ARFILENAMES/"). The origin of the latter format is uncertain.
-
- BSD 4.4 uses a third scheme: It writes a long filename
- directly after the header. This allows 'ar q' to work.
- We currently can read BSD 4.4 archives, but not write them.
-*/
-
-/* Summary of archive member names:
-
- Symbol table (must be first):
- "__.SYMDEF " - Symbol table, Berkeley style, produced by ranlib.
- "/ " - Symbol table, system 5 style.
-
- Long name table (must be before regular file members):
- "// " - Long name table, System 5 R4 style.
- "ARFILENAMES/ " - Long name table, non-standard extended BSD (not BSD 4.4).
-
- Regular file members with short names:
- "filename.o/ " - Regular file, System 5 style (embedded spaces ok).
- "filename.o " - Regular file, Berkeley style (no embedded spaces).
-
- Regular files with long names (or embedded spaces, for BSD variants):
- "/18 " - SVR4 style, name at offset 18 in name table.
- "#1/23 " - Long name (or embedded paces) 23 characters long,
- BSD 4.4 style, full name follows header.
- Implemented for reading, not writing.
- " 18 " - Long name 18 characters long, extended pseudo-BSD.
- */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/ar.h"
-#include "aout/ranlib.h"
-#include <errno.h>
-#include <string.h> /* For memchr, strrchr and friends */
-#include <ctype.h>
-
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef GNU960
-#define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB)
-#endif
-
-/* Can't define this in hosts/foo.h, because (e.g. in gprof) the hosts file
- is included, then obstack.h, which thinks if offsetof is defined, it
- doesn't need to include stddef.h. */
-/* Define offsetof for those systems which lack it */
-
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
-
-/* We keep a cache of archive filepointers to archive elements to
- speed up searching the archive by filepos. We only add an entry to
- the cache when we actually read one. We also don't sort the cache;
- it's generally short enough to search linearly.
- Note that the pointers here point to the front of the ar_hdr, not
- to the front of the contents!
-*/
-struct ar_cache
-{
- file_ptr ptr;
- bfd *arelt;
- struct ar_cache *next;
-};
-
-#define ar_padchar(abfd) ((abfd)->xvec->ar_pad_char)
-#define ar_maxnamelen(abfd) ((abfd)->xvec->ar_max_namelen)
-
-#define arch_eltdata(bfd) ((struct areltdata *)((bfd)->arelt_data))
-#define arch_hdr(bfd) ((struct ar_hdr *)arch_eltdata(bfd)->arch_header)
-
-static char *get_extended_arelt_filename PARAMS ((bfd *arch,
- const char *name));
-static boolean do_slurp_bsd_armap PARAMS ((bfd *abfd));
-static boolean do_slurp_coff_armap PARAMS ((bfd *abfd));
-static const char *normalize PARAMS ((bfd *, const char *file));
-static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,
- const char *));
-
-boolean
-_bfd_generic_mkarchive (abfd)
- bfd *abfd;
-{
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
-
- if (bfd_ardata (abfd) == NULL)
- return false;
-
- bfd_ardata (abfd)->cache = NULL;
- bfd_ardata (abfd)->archive_head = NULL;
- bfd_ardata (abfd)->symdefs = NULL;
- bfd_ardata (abfd)->extended_names = NULL;
- bfd_ardata (abfd)->tdata = NULL;
-
- return true;
-}
-
-/*
-FUNCTION
- bfd_get_next_mapent
-
-SYNOPSIS
- symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);
-
-DESCRIPTION
- Step through archive @var{abfd}'s symbol table (if it
- has one). Successively update @var{sym} with the next symbol's
- information, returning that symbol's (internal) index into the
- symbol table.
-
- Supply <<BFD_NO_MORE_SYMBOLS>> as the @var{previous} entry to get
- the first one; returns <<BFD_NO_MORE_SYMBOLS>> when you've already
- got the last one.
-
- A <<carsym>> is a canonical archive symbol. The only
- user-visible element is its name, a null-terminated string.
-*/
-
-symindex
-bfd_get_next_mapent (abfd, prev, entry)
- bfd *abfd;
- symindex prev;
- carsym **entry;
-{
- if (!bfd_has_map (abfd))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return BFD_NO_MORE_SYMBOLS;
- }
-
- if (prev == BFD_NO_MORE_SYMBOLS)
- prev = 0;
- else
- ++prev;
- if (prev >= bfd_ardata (abfd)->symdef_count)
- return BFD_NO_MORE_SYMBOLS;
-
- *entry = (bfd_ardata (abfd)->symdefs + prev);
- return prev;
-}
-
-/* To be called by backends only */
-
-bfd *
-_bfd_create_empty_archive_element_shell (obfd)
- bfd *obfd;
-{
- return _bfd_new_bfd_contained_in (obfd);
-}
-
-/*
-FUNCTION
- bfd_set_archive_head
-
-SYNOPSIS
- boolean bfd_set_archive_head(bfd *output, bfd *new_head);
-
-DESCRIPTION
- Set the head of the chain of
- BFDs contained in the archive @var{output} to @var{new_head}.
-*/
-
-boolean
-bfd_set_archive_head (output_archive, new_head)
- bfd *output_archive;
- bfd *new_head;
-{
-
- output_archive->archive_head = new_head;
- return true;
-}
-
-bfd *
-_bfd_look_for_bfd_in_cache (arch_bfd, filepos)
- bfd *arch_bfd;
- file_ptr filepos;
-{
- struct ar_cache *current;
-
- for (current = bfd_ardata (arch_bfd)->cache; current != NULL;
- current = current->next)
- if (current->ptr == filepos)
- return current->arelt;
-
- return NULL;
-}
-
-/* Kind of stupid to call cons for each one, but we don't do too many */
-boolean
-_bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
- bfd *arch_bfd, *new_elt;
- file_ptr filepos;
-{
- struct ar_cache *new_cache = ((struct ar_cache *)
- bfd_zalloc (arch_bfd,
- sizeof (struct ar_cache)));
-
- if (new_cache == NULL)
- return false;
-
- new_cache->ptr = filepos;
- new_cache->arelt = new_elt;
- new_cache->next = (struct ar_cache *) NULL;
- if (bfd_ardata (arch_bfd)->cache == NULL)
- bfd_ardata (arch_bfd)->cache = new_cache;
- else
- {
- struct ar_cache *current = bfd_ardata (arch_bfd)->cache;
-
- while (current->next != NULL)
- current = current->next;
- current->next = new_cache;
- }
-
- return true;
-}
-
-/* The name begins with space. Hence the rest of the name is an index into
- the string table. */
-
-static char *
-get_extended_arelt_filename (arch, name)
- bfd *arch;
- const char *name;
-{
- unsigned long index = 0;
-
- /* Should extract string so that I can guarantee not to overflow into
- the next region, but I'm too lazy. */
- errno = 0;
- /* Skip first char, which is '/' in SVR4 or ' ' in some other variants. */
- index = strtol (name + 1, NULL, 10);
- if (errno != 0)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- return bfd_ardata (arch)->extended_names + index;
-}
-
-/* This functions reads an arch header and returns an areltdata pointer, or
- NULL on error.
-
- Presumes the file pointer is already in the right place (ie pointing
- to the ar_hdr in the file). Moves the file pointer; on success it
- should be pointing to the front of the file contents; on failure it
- could have been moved arbitrarily.
-*/
-
-PTR
-_bfd_generic_read_ar_hdr (abfd)
- bfd *abfd;
-{
- return _bfd_generic_read_ar_hdr_mag (abfd, (const char *) NULL);
-}
-
-/* Alpha ECOFF uses an optional different ARFMAG value, so we have a
- variant of _bfd_generic_read_ar_hdr which accepts a magic string. */
-
-PTR
-_bfd_generic_read_ar_hdr_mag (abfd, mag)
- bfd *abfd;
- const char *mag;
-{
- struct ar_hdr hdr;
- char *hdrp = (char *) &hdr;
- unsigned int parsed_size;
- struct areltdata *ared;
- char *filename = NULL;
- unsigned int namelen = 0;
- unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
- char *allocptr = 0;
-
- if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
- if (strncmp (hdr.ar_fmag, ARFMAG, 2) != 0
- && (mag == NULL
- || strncmp (hdr.ar_fmag, mag, 2) != 0))
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- errno = 0;
- parsed_size = strtol (hdr.ar_size, NULL, 10);
- if (errno != 0)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
-
- /* Extract the filename from the archive - there are two ways to
- specify an extendend name table, either the first char of the
- name is a space, or it's a slash. */
- if ((hdr.ar_name[0] == '/'
- || (hdr.ar_name[0] == ' '
- && memchr (hdr.ar_name, '/', ar_maxnamelen (abfd)) == NULL))
- && bfd_ardata (abfd)->extended_names != NULL)
- {
- filename = get_extended_arelt_filename (abfd, hdr.ar_name);
- if (filename == NULL)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
- }
- }
- /* BSD4.4-style long filename.
- Only implemented for reading, so far! */
- else if (hdr.ar_name[0] == '#' && hdr.ar_name[1] == '1'
- && hdr.ar_name[2] == '/' && isdigit (hdr.ar_name[3]))
- {
- /* BSD-4.4 extended name */
- namelen = atoi (&hdr.ar_name[3]);
- allocsize += namelen + 1;
- parsed_size -= namelen;
-
- allocptr = bfd_zalloc (abfd, allocsize);
- if (allocptr == NULL)
- return NULL;
- filename = (allocptr
- + sizeof (struct areltdata)
- + sizeof (struct ar_hdr));
- if (bfd_read (filename, 1, namelen, abfd) != namelen)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
- filename[namelen] = '\0';
- }
- else
- {
- /* We judge the end of the name by looking for '/' or ' '.
- Note: The SYSV format (terminated by '/') allows embedded
- spaces, so only look for ' ' if we don't find '/'. */
-
- namelen = 0;
- while (hdr.ar_name[namelen] != '\0' &&
- hdr.ar_name[namelen] != '/')
- {
- namelen++;
- if (namelen == (unsigned) ar_maxnamelen (abfd))
- {
- namelen = 0;
- while (hdr.ar_name[namelen] != ' '
- && namelen < (unsigned) ar_maxnamelen (abfd))
- namelen++;
- break;
- }
- }
-
- allocsize += namelen + 1;
- }
-
- if (!allocptr)
- {
- allocptr = bfd_zalloc (abfd, allocsize);
- if (allocptr == NULL)
- return NULL;
- }
-
- ared = (struct areltdata *) allocptr;
-
- ared->arch_header = allocptr + sizeof (struct areltdata);
- memcpy ((char *) ared->arch_header, (char *) &hdr, sizeof (struct ar_hdr));
- ared->parsed_size = parsed_size;
-
- if (filename != NULL)
- ared->filename = filename;
- else
- {
- ared->filename = allocptr + (sizeof (struct areltdata) +
- sizeof (struct ar_hdr));
- if (namelen)
- memcpy (ared->filename, hdr.ar_name, namelen);
- ared->filename[namelen] = '\0';
- }
-
- return (PTR) ared;
-}
-
-/* This is an internal function; it's mainly used when indexing
- through the archive symbol table, but also used to get the next
- element, since it handles the bookkeeping so nicely for us. */
-
-bfd *
-_bfd_get_elt_at_filepos (archive, filepos)
- bfd *archive;
- file_ptr filepos;
-{
- struct areltdata *new_areldata;
- bfd *n_nfd;
-
- n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
- if (n_nfd)
- return n_nfd;
-
- if (0 > bfd_seek (archive, filepos, SEEK_SET))
- return NULL;
-
- if ((new_areldata = (struct areltdata *) _bfd_read_ar_hdr (archive)) == NULL)
- return NULL;
-
- n_nfd = _bfd_create_empty_archive_element_shell (archive);
- if (n_nfd == NULL)
- {
- bfd_release (archive, (PTR) new_areldata);
- return NULL;
- }
-
- n_nfd->origin = bfd_tell (archive);
- n_nfd->arelt_data = (PTR) new_areldata;
- n_nfd->filename = new_areldata->filename;
-
- if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
- return n_nfd;
-
- /* huh? */
- bfd_release (archive, (PTR) n_nfd);
- bfd_release (archive, (PTR) new_areldata);
- return NULL;
-}
-
-/* Return the BFD which is referenced by the symbol in ABFD indexed by
- INDEX. INDEX should have been returned by bfd_get_next_mapent. */
-
-bfd *
-_bfd_generic_get_elt_at_index (abfd, index)
- bfd *abfd;
- symindex index;
-{
- carsym *entry;
-
- entry = bfd_ardata (abfd)->symdefs + index;
- return _bfd_get_elt_at_filepos (abfd, entry->file_offset);
-}
-
-/*
-FUNCTION
- bfd_openr_next_archived_file
-
-SYNOPSIS
- bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);
-
-DESCRIPTION
- Provided a BFD, @var{archive}, containing an archive and NULL, open
- an input BFD on the first contained element and returns that.
- Subsequent calls should pass
- the archive and the previous return value to return a created
- BFD to the next contained element. NULL is returned when there
- are no more.
-
-*/
-
-bfd *
-bfd_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- if ((bfd_get_format (archive) != bfd_archive) ||
- (archive->direction == write_direction))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
-
- return BFD_SEND (archive,
- openr_next_archived_file,
- (archive,
- last_file));
-}
-
-bfd *
-bfd_generic_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- file_ptr filestart;
-
- if (!last_file)
- filestart = bfd_ardata (archive)->first_file_filepos;
- else
- {
- unsigned int size = arelt_size (last_file);
- /* Pad to an even boundary...
- Note that last_file->origin can be odd in the case of
- BSD-4.4-style element with a long odd size. */
- filestart = last_file->origin + size;
- filestart += filestart % 2;
- }
-
- return _bfd_get_elt_at_filepos (archive, filestart);
-}
-
-
-const bfd_target *
-bfd_generic_archive_p (abfd)
- bfd *abfd;
-{
- struct artdata *tdata_hold;
- char armag[SARMAG + 1];
-
- tdata_hold = abfd->tdata.aout_ar_data;
-
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
-#ifdef GNU960
- if (strncmp (armag, BFD_GNU960_ARMAG (abfd), SARMAG) != 0)
- return 0;
-#else
- if (strncmp (armag, ARMAG, SARMAG) != 0 &&
- strncmp (armag, ARMAGB, SARMAG) != 0)
- return 0;
-#endif
-
- /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
- involves a cast, we can't do it as the left operand of assignment. */
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
-
- if (bfd_ardata (abfd) == NULL)
- return NULL;
-
- bfd_ardata (abfd)->first_file_filepos = SARMAG;
- bfd_ardata (abfd)->cache = NULL;
- bfd_ardata (abfd)->archive_head = NULL;
- bfd_ardata (abfd)->symdefs = NULL;
- bfd_ardata (abfd)->extended_names = NULL;
- bfd_ardata (abfd)->tdata = NULL;
-
- if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- return NULL;
- }
-
- if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- return NULL;
- }
-
- if (bfd_has_map (abfd))
- {
- bfd *first;
-
- /* This archive has a map, so we may presume that the contents
- are object files. Make sure that if the first file in the
- archive can be recognized as an object file, it is for this
- target. If not, assume that this is the wrong format. If
- the first file is not an object file, somebody is doing
- something weird, and we permit it so that ar -t will work.
-
- This is done because any normal format will recognize any
- normal archive, regardless of the format of the object files.
- We do accept an empty archive. */
-
- first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
- if (first != NULL)
- {
- boolean fail;
-
- first->target_defaulted = false;
- fail = false;
- if (bfd_check_format (first, bfd_object)
- && first->xvec != abfd->xvec)
- {
- (void) bfd_close (first);
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* We ought to close first here, but we can't, because we
- have no way to remove it from the archive cache. FIXME. */
- }
- }
-
- return abfd->xvec;
-}
-
-/* Some constants for a 32 bit BSD archive structure. We do not
- support 64 bit archives presently; so far as I know, none actually
- exist. Supporting them would require changing these constants, and
- changing some bfd_h_get_32 to bfd_h_get_64. */
-
-/* The size of an external symdef structure. */
-#define BSD_SYMDEF_SIZE 8
-
-/* The offset from the start of a symdef structure to the file offset. */
-#define BSD_SYMDEF_OFFSET_SIZE 4
-
-/* The size of the symdef count. */
-#define BSD_SYMDEF_COUNT_SIZE 4
-
-/* The size of the string count. */
-#define BSD_STRING_COUNT_SIZE 4
-
-/* Returns false on error, true otherwise */
-
-static boolean
-do_slurp_bsd_armap (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- unsigned int counter;
- bfd_byte *raw_armap, *rbase;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int parsed_size;
- carsym *set;
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
-
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
- if (raw_armap == (bfd_byte *) NULL)
- return false;
-
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- byebye:
- bfd_release (abfd, (PTR) raw_armap);
- return false;
- }
-
- ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
-
- if (ardata->symdef_count * BSD_SYMDEF_SIZE >
- parsed_size - BSD_SYMDEF_COUNT_SIZE)
- {
- /* Probably we're using the wrong byte ordering. */
- bfd_set_error (bfd_error_wrong_format);
- goto byebye;
- }
-
- ardata->cache = 0;
- rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;
- stringbase = ((char *) rbase
- + ardata->symdef_count * BSD_SYMDEF_SIZE
- + BSD_STRING_COUNT_SIZE);
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
- if (!ardata->symdefs)
- return false;
-
- for (counter = 0, set = ardata->symdefs;
- counter < ardata->symdef_count;
- counter++, set++, rbase += BSD_SYMDEF_SIZE)
- {
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
- /* FIXME, we should provide some way to free raw_ardata when
- we are done using the strings from it. For now, it seems
- to be allocated on an obstack anyway... */
- bfd_has_map (abfd) = true;
- return true;
-}
-
-/* Returns false on error, true otherwise */
-static boolean
-do_slurp_coff_armap (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- int *raw_armap, *rawptr;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int stringsize;
- unsigned int parsed_size;
- carsym *carsyms;
- unsigned int nsymz; /* Number of symbols in armap. */
- bfd_vma (*swap) PARAMS ((const bfd_byte *));
- char int_buf[sizeof (long)];
- unsigned int carsym_size, ptrsize, i;
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
-
- if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
- /* It seems that all numeric information in a coff archive is always
- in big endian format, nomatter the host or target. */
- swap = bfd_getb32;
- nsymz = bfd_getb32 ((PTR) int_buf);
- stringsize = parsed_size - (4 * nsymz) - 4;
-
-#if 1
- /* ... except that some archive formats are broken, and it may be our
- fault - the i960 little endian coff sometimes has big and sometimes
- little, because our tools changed. Here's a horrible hack to clean
- up the crap. */
-
- if (stringsize > 0xfffff)
- {
- /* This looks dangerous, let's do it the other way around */
- nsymz = bfd_getl32 ((PTR) int_buf);
- stringsize = parsed_size - (4 * nsymz) - 4;
- swap = bfd_getl32;
- }
-#endif
-
- /* The coff armap must be read sequentially. So we construct a
- bsd-style one in core all at once, for simplicity. */
-
- carsym_size = (nsymz * sizeof (carsym));
- ptrsize = (4 * nsymz);
-
- ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
- if (ardata->symdefs == NULL)
- return false;
- carsyms = ardata->symdefs;
- stringbase = ((char *) ardata->symdefs) + carsym_size;
-
- /* Allocate and read in the raw offsets. */
- raw_armap = (int *) bfd_alloc (abfd, ptrsize);
- if (raw_armap == NULL)
- goto release_symdefs;
- if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
- || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- goto release_raw_armap;
- }
-
- /* OK, build the carsyms */
- for (i = 0; i < nsymz; i++)
- {
- rawptr = raw_armap + i;
- carsyms->file_offset = swap ((PTR) rawptr);
- carsyms->name = stringbase;
- stringbase += strlen (stringbase) + 1;
- carsyms++;
- }
- *stringbase = 0;
-
- ardata->symdef_count = nsymz;
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
-
-
- bfd_has_map (abfd) = true;
- bfd_release (abfd, (PTR) raw_armap);
-
-
- /* Check for a second archive header (as used by PE) */
- {
- struct areltdata *tmp;
-
- bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
- tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (tmp != NULL)
- {
- if (tmp->arch_header[0] == '/'
- && tmp->arch_header[1] == ' ')
- {
- ardata->first_file_filepos +=
- (tmp->parsed_size + sizeof(struct ar_hdr) + 1) & ~1;
- }
- bfd_release (abfd, tmp);
- }
- }
-
- return true;
-
-release_raw_armap:
- bfd_release (abfd, (PTR) raw_armap);
-release_symdefs:
- bfd_release (abfd, (PTR) (ardata)->symdefs);
- return false;
-}
-
-/* This routine can handle either coff-style or bsd-style armaps.
- Returns false on error, true otherwise */
-
-boolean
-bfd_slurp_armap (abfd)
- bfd *abfd;
-{
- char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
-
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
- return false;
-
- if (!strncmp (nextname, "__.SYMDEF ", 16)
- || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
- return do_slurp_bsd_armap (abfd);
- else if (!strncmp (nextname, "/ ", 16))
- return do_slurp_coff_armap (abfd);
-
- bfd_has_map (abfd) = false;
- return true;
-}
-
-/* Returns false on error, true otherwise */
-/* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
- header is in a slightly different order and the map name is '/'.
- This flavour is used by hp300hpux. */
-
-#define HPUX_SYMDEF_COUNT_SIZE 2
-
-boolean
-bfd_slurp_bsd_armap_f2 (abfd)
- bfd *abfd;
-{
- struct areltdata *mapdata;
- char nextname[17];
- unsigned int counter;
- bfd_byte *raw_armap, *rbase;
- struct artdata *ardata = bfd_ardata (abfd);
- char *stringbase;
- unsigned int stringsize;
- carsym *set;
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
-
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- /* The archive has at least 16 bytes in it */
- if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
- return false;
-
- if (!strncmp (nextname, "__.SYMDEF ", 16)
- || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */
- return do_slurp_bsd_armap (abfd);
-
- if (strncmp (nextname, "/ ", 16))
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == NULL)
- return false;
-
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
- if (raw_armap == NULL)
- {
- byebye:
- bfd_release (abfd, (PTR) mapdata);
- return false;
- }
-
- if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
- mapdata->parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- byebyebye:
- bfd_release (abfd, (PTR) raw_armap);
- goto byebye;
- }
-
- ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);
-
- if (ardata->symdef_count * BSD_SYMDEF_SIZE
- > mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
- {
- /* Probably we're using the wrong byte ordering. */
- bfd_set_error (bfd_error_wrong_format);
- goto byebyebye;
- }
-
- ardata->cache = 0;
-
- stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
- /* skip sym count and string sz */
- stringbase = ((char *) raw_armap
- + HPUX_SYMDEF_COUNT_SIZE
- + BSD_STRING_COUNT_SIZE);
- rbase = (bfd_byte *) stringbase + stringsize;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * BSD_SYMDEF_SIZE));
- if (!ardata->symdefs)
- return false;
-
- for (counter = 0, set = ardata->symdefs;
- counter < ardata->symdef_count;
- counter++, set++, rbase += BSD_SYMDEF_SIZE)
- {
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary if you have to */
- ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
- /* FIXME, we should provide some way to free raw_ardata when
- we are done using the strings from it. For now, it seems
- to be allocated on an obstack anyway... */
- bfd_has_map (abfd) = true;
- return true;
-}
-
-/** Extended name table.
-
- Normally archives support only 14-character filenames.
-
- Intel has extended the format: longer names are stored in a special
- element (the first in the archive, or second if there is an armap);
- the name in the ar_hdr is replaced by <space><index into filename
- element>. Index is the P.R. of an int (decimal). Data General have
- extended the format by using the prefix // for the special element */
-
-/* Returns false on error, true otherwise */
-boolean
-_bfd_slurp_extended_name_table (abfd)
- bfd *abfd;
-{
- char nextname[17];
- struct areltdata *namedata;
-
- /* FIXME: Formatting sucks here, and in case of failure of BFD_READ,
- we probably don't want to return true. */
- bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
- if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
- {
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
- return false;
-
- if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 &&
- strncmp (nextname, "// ", 16) != 0)
- {
- bfd_ardata (abfd)->extended_names = NULL;
- return true;
- }
-
- namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (namedata == NULL)
- return false;
-
- bfd_ardata (abfd)->extended_names =
- bfd_zalloc (abfd, namedata->parsed_size);
- if (bfd_ardata (abfd)->extended_names == NULL)
- {
- byebye:
- bfd_release (abfd, (PTR) namedata);
- return false;
- }
-
- if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
- namedata->parsed_size, abfd) != namedata->parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
- bfd_ardata (abfd)->extended_names = NULL;
- goto byebye;
- }
-
- /* Since the archive is supposed to be printable if it contains
- text, the entries in the list are newline-padded, not null
- padded. In SVR4-style archives, the names also have a
- trailing '/'. DOS/NT created archive often have \ in them
- We'll fix all problems here.. */
- {
- char *temp = bfd_ardata (abfd)->extended_names;
- char *limit = temp + namedata->parsed_size;
- for (; temp < limit; ++temp) {
- if (*temp == '\012')
- temp[temp[-1] == '/' ? -1 : 0] = '\0';
- if (*temp == '\\')
- *temp = '/';
- }
- }
-
- /* Pad to an even boundary if you have to */
- bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd);
- bfd_ardata (abfd)->first_file_filepos +=
- (bfd_ardata (abfd)->first_file_filepos) % 2;
-
- /* FIXME, we can't release namedata here because it was allocated
- below extended_names on the obstack... */
- /* bfd_release (abfd, namedata); */
- }
- return true;
-}
-
-#ifdef VMS
-
-/* Return a copy of the stuff in the filename between any :]> and a
- semicolon */
-static const char *
-normalize (abfd, file)
- bfd *abfd;
- const char *file;
-{
- CONST char *first;
- CONST char *last;
- char *copy;
-
- first = file + strlen (file) - 1;
- last = first + 1;
-
- while (first != file)
- {
- if (*first == ';')
- last = first;
- if (*first == ':' || *first == ']' || *first == '>')
- {
- first++;
- break;
- }
- first--;
- }
-
- copy = (char *) bfd_alloc (abfd, last - first + 1);
- if (copy == NULL)
- return NULL;
-
- memcpy (copy, first, last - first);
- copy[last - first] = 0;
-
- return copy;
-}
-
-#else
-static const char *
-normalize (abfd, file)
- bfd *abfd;
- const char *file;
-{
- const char *filename = strrchr (file, '/');
-
- if (filename != (char *) NULL)
- filename++;
- else
- filename = file;
- return filename;
-}
-#endif
-
-/* Build a BFD style extended name table. */
-
-boolean
-_bfd_archive_bsd_construct_extended_name_table (abfd, tabloc, tablen, name)
- bfd *abfd;
- char **tabloc;
- bfd_size_type *tablen;
- const char **name;
-{
- *name = "ARFILENAMES/";
- return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
-}
-
-/* Build an SVR4 style extended name table. */
-
-boolean
-_bfd_archive_coff_construct_extended_name_table (abfd, tabloc, tablen, name)
- bfd *abfd;
- char **tabloc;
- bfd_size_type *tablen;
- const char **name;
-{
- *name = "//";
- return _bfd_construct_extended_name_table (abfd, true, tabloc, tablen);
-}
-
-/* Follows archive_head and produces an extended name table if
- necessary. Returns (in tabloc) a pointer to an extended name
- table, and in tablen the length of the table. If it makes an entry
- it clobbers the filename so that the element may be written without
- further massage. Returns true if it ran successfully, false if
- something went wrong. A successful return may still involve a
- zero-length tablen! */
-
-boolean
-_bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
- bfd *abfd;
- boolean trailing_slash;
- char **tabloc;
- bfd_size_type *tablen;
-{
- unsigned int maxname = abfd->xvec->ar_max_namelen;
- unsigned int total_namelen = 0;
- bfd *current;
- char *strptr;
-
- *tablen = 0;
-
- /* Figure out how long the table should be */
- for (current = abfd->archive_head; current != NULL; current = current->next)
- {
- const char *normal;
- unsigned int thislen;
-
- normal = normalize (current, current->filename);
- if (normal == NULL)
- return false;
-
- thislen = strlen (normal);
-
- if (thislen > maxname
- && (bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
- thislen = maxname;
-
- if (thislen > maxname)
- {
- /* Add one to leave room for \n. */
- total_namelen += thislen + 1;
- if (trailing_slash)
- {
- /* Leave room for trailing slash. */
- ++total_namelen;
- }
- }
- else
- {
- struct ar_hdr *hdr = arch_hdr (current);
- if (strncmp (normal, hdr->ar_name, thislen) != 0
- || (thislen < sizeof hdr->ar_name
- && hdr->ar_name[thislen] != ar_padchar (current)))
- {
- /* Must have been using extended format even though it
- didn't need to. Fix it to use normal format. */
- memcpy (hdr->ar_name, normal, thislen);
- if (thislen < maxname
- || (thislen == maxname && thislen < sizeof hdr->ar_name))
- hdr->ar_name[thislen] = ar_padchar (current);
- }
- }
- }
-
- if (total_namelen == 0)
- return true;
-
- *tabloc = bfd_zalloc (abfd, total_namelen);
- if (*tabloc == NULL)
- return false;
-
- *tablen = total_namelen;
- strptr = *tabloc;
-
- for (current = abfd->archive_head; current != NULL; current =
- current->next)
- {
- const char *normal;
- unsigned int thislen;
-
- normal = normalize (current, current->filename);
- if (normal == NULL)
- return false;
-
- thislen = strlen (normal);
- if (thislen > maxname)
- {
- /* Works for now; may need to be re-engineered if we
- encounter an oddball archive format and want to
- generalise this hack. */
- struct ar_hdr *hdr = arch_hdr (current);
- strcpy (strptr, normal);
- if (! trailing_slash)
- strptr[thislen] = '\012';
- else
- {
- strptr[thislen] = '/';
- strptr[thislen + 1] = '\012';
- }
- hdr->ar_name[0] = ar_padchar (current);
- /* We know there will always be enough room (one of the few
- cases where you may safely use sprintf). */
- sprintf ((hdr->ar_name) + 1, "%-d", (unsigned) (strptr - *tabloc));
- /* Kinda Kludgy. We should just use the returned value of
- sprintf but not all implementations get this right */
- {
- char *temp = hdr->ar_name + 2;
- for (; temp < hdr->ar_name + maxname; temp++)
- if (*temp == '\0')
- *temp = ' ';
- }
- strptr += thislen + 1;
- if (trailing_slash)
- ++strptr;
- }
- }
-
- return true;
-}
-
-/** A couple of functions for creating ar_hdrs */
-
-/* Takes a filename, returns an arelt_data for it, or NULL if it can't
- make one. The filename must refer to a filename in the filesystem.
- The filename field of the ar_hdr will NOT be initialized */
-
-static struct areltdata *
-bfd_ar_hdr_from_filesystem (abfd, filename)
- bfd *abfd;
- const char *filename;
-{
- struct stat status;
- struct areltdata *ared;
- struct ar_hdr *hdr;
- char *temp, *temp1;
-
- if (stat (filename, &status) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
- sizeof (struct areltdata));
- if (ared == NULL)
- return NULL;
- hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
-
- /* ar headers are space padded, not null padded! */
- memset ((PTR) hdr, ' ', sizeof (struct ar_hdr));
-
- strncpy (hdr->ar_fmag, ARFMAG, 2);
-
- /* Goddamned sprintf doesn't permit MAXIMUM field lengths */
- sprintf ((hdr->ar_date), "%-12ld", (long) status.st_mtime);
- sprintf ((hdr->ar_uid), "%ld", (long) status.st_uid);
- sprintf ((hdr->ar_gid), "%ld", (long) status.st_gid);
- sprintf ((hdr->ar_mode), "%-8o", (unsigned int) status.st_mode);
- sprintf ((hdr->ar_size), "%-10ld", (long) status.st_size);
- /* Correct for a lossage in sprintf whereby it null-terminates. I cannot
- understand how these C losers could design such a ramshackle bunch of
- IO operations */
- temp = (char *) hdr;
- temp1 = temp + sizeof (struct ar_hdr) - 2;
- for (; temp < temp1; temp++)
- {
- if (*temp == '\0')
- *temp = ' ';
- }
- strncpy (hdr->ar_fmag, ARFMAG, 2);
- ared->parsed_size = status.st_size;
- ared->arch_header = (char *) hdr;
-
- return ared;
-}
-
-/* This is magic required by the "ar" program. Since it's
- undocumented, it's undocumented. You may think that it would take
- a strong stomach to write this, and it does, but it takes even a
- stronger stomach to try to code around such a thing! */
-
-struct ar_hdr *
-bfd_special_undocumented_glue (abfd, filename)
- bfd *abfd;
- char *filename;
-{
- struct areltdata *ar_elt = bfd_ar_hdr_from_filesystem (abfd, filename);
- if (ar_elt == NULL)
- return NULL;
- return (struct ar_hdr *) ar_elt->arch_header;
-}
-
-
-/* Analogous to stat call */
-int
-bfd_generic_stat_arch_elt (abfd, buf)
- bfd *abfd;
- struct stat *buf;
-{
- struct ar_hdr *hdr;
- char *aloser;
-
- if (abfd->arelt_data == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- hdr = arch_hdr (abfd);
-
-#define foo(arelt, stelt, size) \
- buf->stelt = strtol (hdr->arelt, &aloser, size); \
- if (aloser == hdr->arelt) return -1;
-
- foo (ar_date, st_mtime, 10);
- foo (ar_uid, st_uid, 10);
- foo (ar_gid, st_gid, 10);
- foo (ar_mode, st_mode, 8);
-
- buf->st_size = arch_eltdata (abfd)->parsed_size;
-
- return 0;
-}
-
-void
-bfd_dont_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- /* FIXME: This interacts unpleasantly with ar's quick-append option.
- Fortunately ic960 users will never use that option. Fixing this
- is very hard; fortunately I know how to do it and will do so once
- intel's release is out the door. */
-
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- size_t length;
- const char *filename;
- size_t maxlen = ar_maxnamelen (abfd);
-
- if ((bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
- {
- bfd_bsd_truncate_arname (abfd, pathname, arhdr);
- return;
- }
-
- filename = normalize (abfd, pathname);
- if (filename == NULL)
- {
- /* FIXME */
- abort ();
- }
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
-
- /* Add the padding character if there is room for it. */
- if (length < maxlen
- || (length == maxlen && length < sizeof hdr->ar_name))
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-void
-bfd_bsd_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
- else
- {
- /* pathname: meet procrustes */
- memcpy (hdr->ar_name, filename, maxlen);
- length = maxlen;
- }
-
- if (length < maxlen)
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-/* Store name into ar header. Truncates the name to fit.
- 1> strip pathname to be just the basename.
- 2> if it's short enuf to fit, stuff it in.
- 3> If it doesn't end with .o, truncate it to fit
- 4> truncate it before the .o, append .o, stuff THAT in. */
-
-/* This is what gnu ar does. It's better but incompatible with the
- bsd ar. */
-
-void
-bfd_gnu_truncate_arname (abfd, pathname, arhdr)
- bfd *abfd;
- CONST char *pathname;
- char *arhdr;
-{
- struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
- length = strlen (filename);
-
- if (length <= maxlen)
- memcpy (hdr->ar_name, filename, length);
- else
- { /* pathname: meet procrustes */
- memcpy (hdr->ar_name, filename, maxlen);
- if ((filename[length - 2] == '.') && (filename[length - 1] == 'o'))
- {
- hdr->ar_name[maxlen - 2] = '.';
- hdr->ar_name[maxlen - 1] = 'o';
- }
- length = maxlen;
- }
-
- if (length < 16)
- (hdr->ar_name)[length] = ar_padchar (abfd);
-}
-
-/* The BFD is open for write and has its format set to bfd_archive */
-
-boolean
-_bfd_write_archive_contents (arch)
- bfd *arch;
-{
- bfd *current;
- char *etable = NULL;
- bfd_size_type elength = 0;
- const char *ename = NULL;
- boolean makemap = bfd_has_map (arch);
- boolean hasobjects = false; /* if no .o's, don't bother to make a map */
- bfd_size_type wrote;
- unsigned int i;
- int tries;
-
- /* Verify the viability of all entries; if any of them live in the
- filesystem (as opposed to living in an archive open for input)
- then construct a fresh ar_hdr for them. */
- for (current = arch->archive_head; current; current = current->next)
- {
- if (bfd_write_p (current))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- if (!current->arelt_data)
- {
- current->arelt_data =
- (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename);
- if (!current->arelt_data)
- return false;
-
- /* Put in the file name */
- BFD_SEND (arch, _bfd_truncate_arname, (arch,
- current->filename,
- (char *) arch_hdr (current)));
- }
-
- if (makemap && ! hasobjects)
- { /* don't bother if we won't make a map! */
- if ((bfd_check_format (current, bfd_object))
-#if 0 /* FIXME -- these are not set correctly */
- && ((bfd_get_file_flags (current) & HAS_SYMS))
-#endif
- )
- hasobjects = true;
- }
- }
-
- if (!BFD_SEND (arch, _bfd_construct_extended_name_table,
- (arch, &etable, &elength, &ename)))
- return false;
-
- if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
- return false;
-#ifdef GNU960
- wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
-#else
- wrote = bfd_write (ARMAG, 1, SARMAG, arch);
-#endif
- if (wrote != SARMAG)
- return false;
-
- if (makemap && hasobjects)
- {
- if (_bfd_compute_and_write_armap (arch, elength) != true)
- return false;
- }
-
- if (elength != 0)
- {
- struct ar_hdr hdr;
-
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- strcpy (hdr.ar_name, ename);
- /* Round size up to even number in archive header. */
- sprintf (&(hdr.ar_size[0]), "%-10d",
- (int) ((elength + 1) & ~1));
- strncpy (hdr.ar_fmag, ARFMAG, 2);
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
- if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- || bfd_write (etable, 1, elength, arch) != elength)
- return false;
- if ((elength % 2) == 1)
- {
- if (bfd_write ("\012", 1, 1, arch) != 1)
- return false;
- }
- }
-
- for (current = arch->archive_head; current; current = current->next)
- {
- char buffer[DEFAULT_BUFFERSIZE];
- unsigned int remaining = arelt_size (current);
- struct ar_hdr *hdr = arch_hdr (current);
-
- /* write ar header */
- if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
- return false;
- if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- while (remaining)
- {
- unsigned int amt = DEFAULT_BUFFERSIZE;
- if (amt > remaining)
- amt = remaining;
- errno = 0;
- if (bfd_read (buffer, amt, 1, current) != amt)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
- if (bfd_write (buffer, amt, 1, arch) != amt)
- return false;
- remaining -= amt;
- }
- if ((arelt_size (current) % 2) == 1)
- {
- if (bfd_write ("\012", 1, 1, arch) != 1)
- return false;
- }
- }
-
- if (makemap && hasobjects)
- {
- /* Verify the timestamp in the archive file. If it would not be
- accepted by the linker, rewrite it until it would be. If
- anything odd happens, break out and just return. (The
- Berkeley linker checks the timestamp and refuses to read the
- table-of-contents if it is >60 seconds less than the file's
- modified-time. That painful hack requires this painful hack. */
- tries = 1;
- do
- {
- if (bfd_update_armap_timestamp (arch))
- break;
- (*_bfd_error_handler)
- ("Warning: writing archive was slow: rewriting timestamp\n");
- }
- while (++tries < 6);
- }
-
- return true;
-}
-
-/* Note that the namidx for the first symbol is 0 */
-
-boolean
-_bfd_compute_and_write_armap (arch, elength)
- bfd *arch;
- unsigned int elength;
-{
- char *first_name = NULL;
- bfd *current;
- file_ptr elt_no = 0;
- struct orl *map = NULL;
- int orl_max = 1024; /* fine initial default */
- int orl_count = 0;
- int stridx = 0; /* string index */
- asymbol **syms = NULL;
- long syms_max = 0;
- boolean ret;
-
- /* Dunno if this is the best place for this info... */
- if (elength != 0)
- elength += sizeof (struct ar_hdr);
- elength += elength % 2;
-
- map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
- if (map == NULL)
- goto error_return;
-
- /* We put the symbol names on the arch obstack, and then discard
- them when done. */
- first_name = bfd_alloc (arch, 1);
- if (first_name == NULL)
- goto error_return;
-
- /* Drop all the files called __.SYMDEF, we're going to make our
- own */
- while (arch->archive_head &&
- strcmp (arch->archive_head->filename, "__.SYMDEF") == 0)
- arch->archive_head = arch->archive_head->next;
-
- /* Map over each element */
- for (current = arch->archive_head;
- current != (bfd *) NULL;
- current = current->next, elt_no++)
- {
- if ((bfd_check_format (current, bfd_object) == true)
- && ((bfd_get_file_flags (current) & HAS_SYMS)))
- {
- long storage;
- long symcount;
- long src_count;
-
- storage = bfd_get_symtab_upper_bound (current);
- if (storage < 0)
- goto error_return;
-
- if (storage != 0)
- {
- if (storage > syms_max)
- {
- if (syms_max > 0)
- free (syms);
- syms_max = storage;
- syms = (asymbol **) bfd_malloc ((size_t) syms_max);
- if (syms == NULL)
- goto error_return;
- }
- symcount = bfd_canonicalize_symtab (current, syms);
- if (symcount < 0)
- goto error_return;
-
- /* Now map over all the symbols, picking out the ones we want */
- for (src_count = 0; src_count < symcount; src_count++)
- {
- flagword flags = (syms[src_count])->flags;
- asection *sec = syms[src_count]->section;
-
- if ((flags & BSF_GLOBAL ||
- flags & BSF_WEAK ||
- flags & BSF_INDIRECT ||
- bfd_is_com_section (sec))
- && ! bfd_is_und_section (sec))
- {
- size_t namelen;
- struct orl *new_map;
-
- /* This symbol will go into the archive header */
- if (orl_count == orl_max)
- {
- orl_max *= 2;
- new_map =
- ((struct orl *)
- bfd_realloc (map, orl_max * sizeof (struct orl)));
- if (new_map == (struct orl *) NULL)
- goto error_return;
-
- map = new_map;
- }
-
- namelen = strlen (syms[src_count]->name);
- map[orl_count].name = ((char **)
- bfd_alloc (arch,
- sizeof (char *)));
- if (map[orl_count].name == NULL)
- goto error_return;
- *(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
- if (*(map[orl_count].name) == NULL)
- goto error_return;
- strcpy (*(map[orl_count].name), syms[src_count]->name);
- (map[orl_count]).pos = (file_ptr) current;
- (map[orl_count]).namidx = stridx;
-
- stridx += namelen + 1;
- ++orl_count;
- }
- }
- }
-
- /* Now ask the BFD to free up any cached information, so we
- don't fill all of memory with symbol tables. */
- if (! bfd_free_cached_info (current))
- goto error_return;
- }
- }
-
- /* OK, now we have collected all the data, let's write them out */
- ret = BFD_SEND (arch, write_armap,
- (arch, elength, map, orl_count, stridx));
-
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
- if (first_name != NULL)
- bfd_release (arch, first_name);
-
- return ret;
-
- error_return:
- if (syms_max > 0)
- free (syms);
- if (map != NULL)
- free (map);
- if (first_name != NULL)
- bfd_release (arch, first_name);
-
- return false;
-}
-
-boolean
-bsd_write_armap (arch, elength, map, orl_count, stridx)
- bfd *arch;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- int padit = stridx & 1;
- unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
- unsigned int stringsize = stridx + padit;
- /* Include 8 bytes to store ranlibsize and stringsize in output. */
- unsigned int mapsize = ranlibsize + stringsize + 8;
- file_ptr firstreal;
- bfd *current = arch->archive_head;
- bfd *last_elt = current; /* last element arch seen */
- bfd_byte temp[4];
- unsigned int count;
- struct ar_hdr hdr;
- struct stat statbuf;
- unsigned int i;
-
- firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
-
- stat (arch->filename, &statbuf);
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- sprintf (hdr.ar_name, RANLIBMAG);
- /* Remember the timestamp, to keep it holy. But fudge it a little. */
- bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
- bfd_ardata (arch)->armap_datepos = (SARMAG
- + offsetof (struct ar_hdr, ar_date[0]));
- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
- sprintf (hdr.ar_uid, "%ld", (long) getuid ());
- sprintf (hdr.ar_gid, "%ld", (long) getgid ());
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
- strncpy (hdr.ar_fmag, ARFMAG, 2);
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
- if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- return false;
- bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
- return false;
-
- for (count = 0; count < orl_count; count++)
- {
- bfd_byte buf[BSD_SYMDEF_SIZE];
-
- if (((bfd *) (map[count]).pos) != last_elt)
- {
- do
- {
- firstreal += arelt_size (current) + sizeof (struct ar_hdr);
- firstreal += firstreal % 2;
- current = current->next;
- }
- while (current != (bfd *) (map[count]).pos);
- } /* if new archive element */
-
- last_elt = current;
- bfd_h_put_32 (arch, map[count].namidx, buf);
- bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
- if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
- return false;
- }
-
- /* now write the strings themselves */
- bfd_h_put_32 (arch, stringsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
- return false;
- for (count = 0; count < orl_count; count++)
- {
- size_t len = strlen (*map[count].name) + 1;
-
- if (bfd_write (*map[count].name, 1, len, arch) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for sun's ar we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, arch) != 1)
- return false;
- }
-
- return true;
-}
-
-/* At the end of archive file handling, update the timestamp in the
- file, so the linker will accept it.
-
- Return true if the timestamp was OK, or an unusual problem happened.
- Return false if we updated the timestamp. */
-
-boolean
-_bfd_archive_bsd_update_armap_timestamp (arch)
- bfd *arch;
-{
- struct stat archstat;
- struct ar_hdr hdr;
- unsigned int i;
-
- /* Flush writes, get last-write timestamp from file, and compare it
- to the timestamp IN the file. */
- bfd_flush (arch);
- if (bfd_stat (arch, &archstat) == -1)
- {
- perror ("Reading archive file mod timestamp");
- return true; /* Can't read mod time for some reason */
- }
- if (archstat.st_mtime <= bfd_ardata (arch)->armap_timestamp)
- return true; /* OK by the linker's rules */
-
- /* Update the timestamp. */
- bfd_ardata (arch)->armap_timestamp = archstat.st_mtime + ARMAP_TIME_OFFSET;
-
- /* Prepare an ASCII version suitable for writing. */
- memset (hdr.ar_date, 0, sizeof (hdr.ar_date));
- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
- for (i = 0; i < sizeof (hdr.ar_date); i++)
- if (hdr.ar_date[i] == '\0')
- (hdr.ar_date)[i] = ' ';
-
- /* Write it into the file. */
- bfd_ardata (arch)->armap_datepos = (SARMAG
- + offsetof (struct ar_hdr, ar_date[0]));
- if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
- || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
- != sizeof (hdr.ar_date)))
- {
- /* FIXME: bfd can't call perror. */
- perror ("Writing updated armap timestamp");
- return true; /* Some error while writing */
- }
-
- return false; /* We updated the timestamp successfully. */
-}
-
-/* A coff armap looks like :
- lARMAG
- struct ar_hdr with name = '/'
- number of symbols
- offset of file for symbol 0
- offset of file for symbol 1
-
- offset of file for symbol n-1
- symbol name 0
- symbol name 1
-
- symbol name n-1
-*/
-
-boolean
-coff_write_armap (arch, elength, map, symbol_count, stridx)
- bfd *arch;
- unsigned int elength;
- struct orl *map;
- unsigned int symbol_count;
- int stridx;
-{
- /* The size of the ranlib is the number of exported symbols in the
- archive * the number of bytes in a int, + an int for the count */
- unsigned int ranlibsize = (symbol_count * 4) + 4;
- unsigned int stringsize = stridx;
- unsigned int mapsize = stringsize + ranlibsize;
- file_ptr archive_member_file_ptr;
- bfd *current = arch->archive_head;
- unsigned int count;
- struct ar_hdr hdr;
- unsigned int i;
- int padit = mapsize & 1;
-
- if (padit)
- mapsize++;
-
- /* work out where the first object file will go in the archive */
- archive_member_file_ptr = (mapsize
- + elength
- + sizeof (struct ar_hdr)
- + SARMAG);
-
- memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- hdr.ar_name[0] = '/';
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
- sprintf (hdr.ar_date, "%ld", (long) time (NULL));
- /* This, at least, is what Intel coff sets the values to.: */
- sprintf ((hdr.ar_uid), "%d", 0);
- sprintf ((hdr.ar_gid), "%d", 0);
- sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
- strncpy (hdr.ar_fmag, ARFMAG, 2);
-
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
-
- /* Write the ar header for this item and the number of symbols */
-
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
- != sizeof (struct ar_hdr))
- return false;
-
- bfd_write_bigendian_4byte_int (arch, symbol_count);
-
- /* Two passes, first write the file offsets for each symbol -
- remembering that each offset is on a two byte boundary. */
-
- /* Write out the file offset for the file associated with each
- symbol, and remember to keep the offsets padded out. */
-
- current = arch->archive_head;
- count = 0;
- while (current != (bfd *) NULL && count < symbol_count)
- {
- /* For each symbol which is used defined in this object, write out
- the object file's address in the archive */
-
- while (((bfd *) (map[count]).pos) == current)
- {
- bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
- count++;
- }
- /* Add size of this archive entry */
- archive_member_file_ptr += (arelt_size (current)
- + sizeof (struct ar_hdr));
- /* remember aboout the even alignment */
- archive_member_file_ptr += archive_member_file_ptr % 2;
- current = current->next;
- }
-
- /* now write the strings themselves */
- for (count = 0; count < symbol_count; count++)
- {
- size_t len = strlen (*map[count].name) + 1;
-
- if (bfd_write (*map[count].name, 1, len, arch) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for arc960 we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, arch) != 1)
- return false;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/archures.c b/contrib/gdb/bfd/archures.c
deleted file mode 100644
index 1db8bc2..0000000
--- a/contrib/gdb/bfd/archures.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/* BFD library support routines for architectures.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include <ctype.h>
-
-/*
-
-SECTION
- Architectures
-
- BFD keeps one atom in a BFD describing the
- architecture of the data attached to the BFD: a pointer to a
- <<bfd_arch_info_type>>.
-
- Pointers to structures can be requested independently of a BFD
- so that an architecture's information can be interrogated
- without access to an open BFD.
-
- The architecture information is provided by each architecture package.
- The set of default architectures is selected by the macro
- <<SELECT_ARCHITECTURES>>. This is normally set up in the
- @file{config/@var{target}.mt} file of your choice. If the name is not
- defined, then all the architectures supported are included.
-
- When BFD starts up, all the architectures are called with an
- initialize method. It is up to the architecture back end to
- insert as many items into the list of architectures as it wants to;
- generally this would be one for each machine and one for the
- default case (an item with a machine field of 0).
-
- BFD's idea of an architecture is implemented in @file{archures.c}.
-*/
-
-/*
-
-SUBSECTION
- bfd_architecture
-
-DESCRIPTION
- This enum gives the object file's CPU architecture, in a
- global sense---i.e., what processor family does it belong to?
- Another field indicates which processor within
- the family is in use. The machine gives a number which
- distinguishes different versions of the architecture,
- containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
- and 68020 and 68030 for Motorola 68020 and 68030.
-
-.enum bfd_architecture
-.{
-. bfd_arch_unknown, {* File arch not known *}
-. bfd_arch_obscure, {* Arch known, not one of these *}
-. bfd_arch_m68k, {* Motorola 68xxx *}
-. bfd_arch_vax, {* DEC Vax *}
-. bfd_arch_i960, {* Intel 960 *}
-. {* The order of the following is important.
-. lower number indicates a machine type that
-. only accepts a subset of the instructions
-. available to machines with higher numbers.
-. The exception is the "ca", which is
-. incompatible with all other machines except
-. "core". *}
-.
-.#define bfd_mach_i960_core 1
-.#define bfd_mach_i960_ka_sa 2
-.#define bfd_mach_i960_kb_sb 3
-.#define bfd_mach_i960_mc 4
-.#define bfd_mach_i960_xa 5
-.#define bfd_mach_i960_ca 6
-.#define bfd_mach_i960_jx 7
-.#define bfd_mach_i960_hx 8
-.
-. bfd_arch_a29k, {* AMD 29000 *}
-. bfd_arch_sparc, {* SPARC *}
-.#define bfd_mach_sparc 1
-.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
-.#define bfd_mach_sparc_v8plus 2
-.#define bfd_mach_sparc_v8plusa 3 {* with ultrasparc add'ns *}
-.#define bfd_mach_sparc_v9 4
-.#define bfd_mach_sparc_v9a 5 {* with ultrasparc add'ns *}
-.{* Nonzero if MACH has the v9 instruction set. *}
-.#define bfd_mach_sparc_v9_p(mach) ((mach) != bfd_mach_sparc)
-. bfd_arch_mips, {* MIPS Rxxxx *}
-. bfd_arch_i386, {* Intel 386 *}
-. bfd_arch_we32k, {* AT&T WE32xxx *}
-. bfd_arch_tahoe, {* CCI/Harris Tahoe *}
-. bfd_arch_i860, {* Intel 860 *}
-. bfd_arch_romp, {* IBM ROMP PC/RT *}
-. bfd_arch_alliant, {* Alliant *}
-. bfd_arch_convex, {* Convex *}
-. bfd_arch_m88k, {* Motorola 88xxx *}
-. bfd_arch_pyramid, {* Pyramid Technology *}
-. bfd_arch_h8300, {* Hitachi H8/300 *}
-.#define bfd_mach_h8300 1
-.#define bfd_mach_h8300h 2
-. bfd_arch_powerpc, {* PowerPC *}
-. bfd_arch_rs6000, {* IBM RS/6000 *}
-. bfd_arch_hppa, {* HP PA RISC *}
-. bfd_arch_z8k, {* Zilog Z8000 *}
-.#define bfd_mach_z8001 1
-.#define bfd_mach_z8002 2
-. bfd_arch_h8500, {* Hitachi H8/500 *}
-. bfd_arch_sh, {* Hitachi SH *}
-. bfd_arch_alpha, {* Dec Alpha *}
-. bfd_arch_arm, {* Advanced Risc Machines ARM *}
-. bfd_arch_ns32k, {* National Semiconductors ns32000 *}
-. bfd_arch_w65, {* WDC 65816 *}
-. bfd_arch_last
-. };
-
-
-*/
-
-/*
-
-SUBSECTION
- bfd_arch_info
-
-DESCRIPTION
- This structure contains information on architectures for use
- within BFD.
-
-.
-.typedef struct bfd_arch_info
-.{
-. int bits_per_word;
-. int bits_per_address;
-. int bits_per_byte;
-. enum bfd_architecture arch;
-. unsigned long mach;
-. const char *arch_name;
-. const char *printable_name;
-. unsigned int section_align_power;
-. {* true if this is the default machine for the architecture *}
-. boolean the_default;
-. const struct bfd_arch_info * (*compatible)
-. PARAMS ((const struct bfd_arch_info *a,
-. const struct bfd_arch_info *b));
-.
-. boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
-.
-. const struct bfd_arch_info *next;
-.} bfd_arch_info_type;
-*/
-
-extern const bfd_arch_info_type bfd_a29k_arch;
-extern const bfd_arch_info_type bfd_alpha_arch;
-extern const bfd_arch_info_type bfd_arm_arch;
-extern const bfd_arch_info_type bfd_h8300_arch;
-extern const bfd_arch_info_type bfd_h8500_arch;
-extern const bfd_arch_info_type bfd_hppa_arch;
-extern const bfd_arch_info_type bfd_i386_arch;
-extern const bfd_arch_info_type bfd_i860_arch;
-extern const bfd_arch_info_type bfd_i960_arch;
-extern const bfd_arch_info_type bfd_m68k_arch;
-extern const bfd_arch_info_type bfd_m88k_arch;
-extern const bfd_arch_info_type bfd_mips_arch;
-extern const bfd_arch_info_type bfd_powerpc_arch;
-extern const bfd_arch_info_type bfd_rs6000_arch;
-extern const bfd_arch_info_type bfd_sh_arch;
-extern const bfd_arch_info_type bfd_sparc_arch;
-extern const bfd_arch_info_type bfd_vax_arch;
-extern const bfd_arch_info_type bfd_we32k_arch;
-extern const bfd_arch_info_type bfd_z8k_arch;
-extern const bfd_arch_info_type bfd_ns32k_arch;
-extern const bfd_arch_info_type bfd_w65_arch;
-
-static const bfd_arch_info_type * const bfd_archures_list[] =
-{
-#ifdef SELECT_ARCHITECTURES
- SELECT_ARCHITECTURES,
-#else
- &bfd_a29k_arch,
- &bfd_alpha_arch,
- &bfd_arm_arch,
- &bfd_h8300_arch,
- &bfd_h8500_arch,
- &bfd_hppa_arch,
- &bfd_i386_arch,
- &bfd_i860_arch,
- &bfd_i960_arch,
- &bfd_m68k_arch,
- &bfd_m88k_arch,
- &bfd_mips_arch,
- &bfd_powerpc_arch,
- &bfd_rs6000_arch,
- &bfd_sh_arch,
- &bfd_sparc_arch,
- &bfd_vax_arch,
- &bfd_we32k_arch,
- &bfd_z8k_arch,
- &bfd_ns32k_arch,
- &bfd_w65_arch,
-#endif
- 0
-};
-
-/*
-FUNCTION
- bfd_printable_name
-
-SYNOPSIS
- const char *bfd_printable_name(bfd *abfd);
-
-DESCRIPTION
- Return a printable string representing the architecture and machine
- from the pointer to the architecture info structure.
-
-*/
-
-const char *
-bfd_printable_name (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->printable_name;
-}
-
-
-
-/*
-FUNCTION
- bfd_scan_arch
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_scan_arch(const char *string);
-
-DESCRIPTION
- Figure out if BFD supports any cpu which could be described with
- the name @var{string}. Return a pointer to an <<arch_info>>
- structure if a machine is found, otherwise NULL.
-
-*/
-
-const bfd_arch_info_type *
-bfd_scan_arch (string)
- const char *string;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- /* Look through all the installed architectures */
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->scan (ap, string))
- return ap;
- }
- }
-
- return NULL;
-}
-
-
-
-/*
-FUNCTION
- bfd_arch_get_compatible
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_arch_get_compatible(
- const bfd *abfd,
- const bfd *bbfd);
-
-DESCRIPTION
- Determine whether two BFDs'
- architectures and machine types are compatible. Calculates
- the lowest common denominator between the two architectures
- and machine types implied by the BFDs and returns a pointer to
- an <<arch_info>> structure describing the compatible machine.
-*/
-
-const bfd_arch_info_type *
-bfd_arch_get_compatible (abfd, bbfd)
- const bfd *abfd;
- const bfd *bbfd;
-{
- /* If either architecture is unknown, then all we can do is assume
- the user knows what he's doing. */
- if (abfd->arch_info->arch == bfd_arch_unknown)
- return bbfd->arch_info;
- if (bbfd->arch_info->arch == bfd_arch_unknown)
- return abfd->arch_info;
-
- /* Otherwise architecture-specific code has to decide. */
- return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
-}
-
-
-/*
-INTERNAL_DEFINITION
- bfd_default_arch_struct
-
-DESCRIPTION
- The <<bfd_default_arch_struct>> is an item of
- <<bfd_arch_info_type>> which has been initialized to a fairly
- generic state. A BFD starts life by pointing to this
- structure, until the correct back end has determined the real
- architecture of the file.
-
-.extern const bfd_arch_info_type bfd_default_arch_struct;
-
-*/
-
-const bfd_arch_info_type bfd_default_arch_struct =
-{
- 32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
- bfd_default_compatible,
- bfd_default_scan,
- 0,
-};
-
-/*
-FUNCTION
- bfd_set_arch_info
-
-SYNOPSIS
- void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
-
-DESCRIPTION
- Set the architecture info of @var{abfd} to @var{arg}.
-*/
-
-void
-bfd_set_arch_info (abfd, arg)
- bfd *abfd;
- const bfd_arch_info_type *arg;
-{
- abfd->arch_info = arg;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_default_set_arch_mach
-
-SYNOPSIS
- boolean bfd_default_set_arch_mach(bfd *abfd,
- enum bfd_architecture arch,
- unsigned long mach);
-
-DESCRIPTION
- Set the architecture and machine type in BFD @var{abfd}
- to @var{arch} and @var{mach}. Find the correct
- pointer to a structure and insert it into the <<arch_info>>
- pointer.
-*/
-
-boolean
-bfd_default_set_arch_mach (abfd, arch, mach)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long mach;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->arch == arch
- && (ap->mach == mach
- || (mach == 0 && ap->the_default)))
- {
- abfd->arch_info = ap;
- return true;
- }
- }
- }
-
- abfd->arch_info = &bfd_default_arch_struct;
- bfd_set_error (bfd_error_bad_value);
- return false;
-}
-
-
-/*
-FUNCTION
- bfd_get_arch
-
-SYNOPSIS
- enum bfd_architecture bfd_get_arch(bfd *abfd);
-
-DESCRIPTION
- Return the enumerated type which describes the BFD @var{abfd}'s
- architecture.
-
-*/
-
-enum bfd_architecture
-bfd_get_arch (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->arch;
-}
-
-/*
-FUNCTION
- bfd_get_mach
-
-SYNOPSIS
- unsigned long bfd_get_mach(bfd *abfd);
-
-DESCRIPTION
- Return the long type which describes the BFD @var{abfd}'s
- machine.
-*/
-
-unsigned long
-bfd_get_mach (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->mach;
-}
-
-/*
-FUNCTION
- bfd_arch_bits_per_byte
-
-SYNOPSIS
- unsigned int bfd_arch_bits_per_byte(bfd *abfd);
-
-DESCRIPTION
- Return the number of bits in one of the BFD @var{abfd}'s
- architecture's bytes.
-
-*/
-
-unsigned int
-bfd_arch_bits_per_byte (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->bits_per_byte;
-}
-
-/*
-FUNCTION
- bfd_arch_bits_per_address
-
-SYNOPSIS
- unsigned int bfd_arch_bits_per_address(bfd *abfd);
-
-DESCRIPTION
- Return the number of bits in one of the BFD @var{abfd}'s
- architecture's addresses.
-*/
-
-unsigned int
-bfd_arch_bits_per_address (abfd)
- bfd *abfd;
-{
- return abfd->arch_info->bits_per_address;
-}
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_compatible
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_default_compatible
- (const bfd_arch_info_type *a,
- const bfd_arch_info_type *b);
-
-DESCRIPTION
- The default function for testing for compatibility.
-*/
-
-const bfd_arch_info_type *
-bfd_default_compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->arch != b->arch)
- return NULL;
-
- if (a->mach > b->mach)
- return a;
-
- if (b->mach > a->mach)
- return b;
-
- return a;
-}
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_scan
-
-SYNOPSIS
- boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
-
-DESCRIPTION
- The default function for working out whether this is an
- architecture hit and a machine hit.
-*/
-
-boolean
-bfd_default_scan (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- const char *ptr_src;
- const char *ptr_tst;
- unsigned long number;
- enum bfd_architecture arch;
-
- /* First test for an exact match */
- if (strcmp (string, info->printable_name) == 0)
- return true;
-
- /* See how much of the supplied string matches with the
- architecture, eg the string m68k:68020 would match the 68k entry
- up to the :, then we get left with the machine number */
-
- for (ptr_src = string, ptr_tst = info->arch_name;
- *ptr_src && *ptr_tst;
- ptr_src++, ptr_tst++)
- {
- if (*ptr_src != *ptr_tst) break;
- }
-
- /* Chewed up as much of the architecture as will match, skip any
- colons */
- if (*ptr_src == ':')
- ptr_src++;
-
- if (*ptr_src == 0)
- {
- /* nothing more, then only keep this one if it is the default
- machine for this architecture */
- return info->the_default;
- }
-
- number = 0;
- while (isdigit(*ptr_src))
- {
- number = number * 10 + *ptr_src - '0';
- ptr_src++;
- }
-
- switch (number)
- {
- case 65:
- arch = bfd_arch_w65;
- break;
-
- case 300:
- arch = bfd_arch_h8300;
- break;
-
- case 500:
- arch = bfd_arch_h8500;
- break;
-
- case 68010:
- case 68020:
- case 68030:
- case 68040:
- case 68332:
- case 68050:
- case 68000:
- arch = bfd_arch_m68k;
- break;
-
- case 386:
- case 80386:
- case 486:
- case 80486:
- arch = bfd_arch_i386;
- break;
-
- case 29000:
- arch = bfd_arch_a29k;
- break;
-
- case 8000:
- arch = bfd_arch_z8k;
- break;
-
- case 32000:
- arch = bfd_arch_we32k;
- break;
-
- case 860:
- case 80860:
- arch = bfd_arch_i860;
- break;
- case 960:
- case 80960:
- arch = bfd_arch_i960;
- break;
-
- case 2000:
- case 3000:
- case 4000:
- case 4400:
- arch = bfd_arch_mips;
- break;
-
- case 6000:
- arch = bfd_arch_rs6000;
- break;
-
- default:
- return false;
- }
-
- if (arch != info->arch)
- return false;
-
- if (number != info->mach)
- return false;
-
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_get_arch_info
-
-SYNOPSIS
- const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
-
-DESCRIPTION
- Return the architecture info struct in @var{abfd}.
-*/
-
-const bfd_arch_info_type *
-bfd_get_arch_info (abfd)
- bfd *abfd;
-{
- return abfd->arch_info;
-}
-
-
-/*
-FUNCTION
- bfd_lookup_arch
-
-SYNOPSIS
- const bfd_arch_info_type *bfd_lookup_arch
- (enum bfd_architecture
- arch,
- unsigned long machine);
-
-DESCRIPTION
- Look for the architecure info structure which matches the
- arguments @var{arch} and @var{machine}. A machine of 0 matches the
- machine/architecture structure which marks itself as the
- default.
-*/
-
-const bfd_arch_info_type *
-bfd_lookup_arch (arch, machine)
- enum bfd_architecture arch;
- unsigned long machine;
-{
- const bfd_arch_info_type * const *app, *ap;
-
- for (app = bfd_archures_list; *app != NULL; app++)
- {
- for (ap = *app; ap != NULL; ap = ap->next)
- {
- if (ap->arch == arch
- && (ap->mach == machine
- || (machine == 0 && ap->the_default)))
- return ap;
- }
- }
-
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_printable_arch_mach
-
-SYNOPSIS
- const char *bfd_printable_arch_mach
- (enum bfd_architecture arch, unsigned long machine);
-
-DESCRIPTION
- Return a printable string representing the architecture and
- machine type.
-
- This routine is depreciated.
-*/
-
-const char *
-bfd_printable_arch_mach (arch, machine)
- enum bfd_architecture arch;
- unsigned long machine;
-{
- const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
-
- if (ap)
- return ap->printable_name;
- return "UNKNOWN!";
-}
diff --git a/contrib/gdb/bfd/bfd-in.h b/contrib/gdb/bfd/bfd-in.h
deleted file mode 100644
index d291239..0000000
--- a/contrib/gdb/bfd/bfd-in.h
+++ /dev/null
@@ -1,668 +0,0 @@
-/* Main header file for the bfd library -- portable access to object files.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
-** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
-** instead, change bfd-in.h or the other BFD source files processed to
-** generate these files.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* bfd.h -- The only header file required by users of the bfd library
-
-The bfd.h file is generated from bfd-in.h and various .c files; if you
-change it, your changes will probably be lost.
-
-All the prototypes and definitions following the comment "THE FOLLOWING
-IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
-BFD. If you change it, someone oneday will extract it from the source
-again, and your changes will be lost. To save yourself from this bind,
-change the definitions in the source in the bfd directory. Type "make
-docs" and then "make headers" in that directory, and magically this file
-will change to reflect your changes.
-
-If you don't have the tools to perform the extraction, then you are
-safe from someone on your system trampling over your header files.
-You should still maintain the equivalence between the source and this
-file though; every change you make to the .c file should be reflected
-here. */
-
-#ifndef __BFD_H_SEEN__
-#define __BFD_H_SEEN__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "ansidecl.h"
-#include "obstack.h"
-
-/* These two lines get substitutions done by commands in Makefile.in. */
-#define BFD_VERSION "@VERSION@"
-#define BFD_ARCH_SIZE @WORDSIZE@
-#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
-
-#if BFD_ARCH_SIZE >= 64
-#define BFD64
-#endif
-
-#ifndef INLINE
-#if __GNUC__ >= 2
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-#endif
-
-/* forward declaration */
-typedef struct _bfd bfd;
-
-/* To squelch erroneous compiler warnings ("illegal pointer
- combination") from the SVR3 compiler, we would like to typedef
- boolean to int (it doesn't like functions which return boolean.
- Making sure they are never implicitly declared to return int
- doesn't seem to help). But this file is not configured based on
- the host. */
-/* General rules: functions which are boolean return true on success
- and false on failure (unless they're a predicate). -- bfd.doc */
-/* I'm sure this is going to break something and someone is going to
- force me to change it. */
-/* typedef enum boolean {false, true} boolean; */
-/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
-/* It gets worse if the host also defines a true/false enum... -sts */
-/* And even worse if your compiler has built-in boolean types... -law */
-#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif
-#ifdef MPW
-/* Pre-emptive strike - get the file with the enum. */
-#include <Types.h>
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif /* MPW */
-#ifndef TRUE_FALSE_ALREADY_DEFINED
-typedef enum bfd_boolean {false, true} boolean;
-#define BFD_TRUE_FALSE
-#else
-/* Use enum names that will appear nowhere else. */
-typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
-#endif
-
-/* A pointer to a position in a file. */
-/* FIXME: This should be using off_t from <sys/types.h>.
- For now, try to avoid breaking stuff by not including <sys/types.h> here.
- This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
- Probably the best long-term answer is to avoid using file_ptr AND off_t
- in this header file, and to handle this in the BFD implementation
- rather than in its interface. */
-/* typedef off_t file_ptr; */
-typedef long int file_ptr;
-
-/* Support for different sizes of target format ints and addresses.
- If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
- set to 1 above. Otherwise, if gcc is being used, this code will
- use gcc's "long long" type. Otherwise, the compilation will fail
- if 64-bit targets are requested. */
-
-#ifdef BFD64
-
-#ifndef BFD_HOST_64_BIT
-#if BFD_HOST_64BIT_LONG
-#define BFD_HOST_64_BIT long
-#else
-#ifdef __GNUC__
-#define BFD_HOST_64_BIT long long
-#endif /* defined (__GNUC__) */
-#endif /* ! BFD_HOST_64BIT_LONG */
-#endif /* ! defined (BFD_HOST_64_BIT) */
-
-typedef unsigned BFD_HOST_64_BIT bfd_vma;
-typedef BFD_HOST_64_BIT bfd_signed_vma;
-typedef unsigned BFD_HOST_64_BIT bfd_size_type;
-typedef unsigned BFD_HOST_64_BIT symvalue;
-
-#ifndef fprintf_vma
-#if BFD_HOST_64BIT_LONG
-#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
-#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
-#else
-#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
-#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
-#define fprintf_vma(s,x) \
- fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#define sprintf_vma(s,x) \
- sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#endif
-#endif
-
-#else /* not BFD64 */
-
-/* Represent a target address. Also used as a generic unsigned type
- which is guaranteed to be big enough to hold any arithmetic types
- we need to deal with. */
-typedef unsigned long bfd_vma;
-
-/* A generic signed type which is guaranteed to be big enough to hold any
- arithmetic types we need to deal with. Can be assumed to be compatible
- with bfd_vma in the same way that signed and unsigned ints are compatible
- (as parameters, in assignment, etc). */
-typedef long bfd_signed_vma;
-
-typedef unsigned long symvalue;
-typedef unsigned long bfd_size_type;
-
-/* Print a bfd_vma x on stream s. */
-#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
-#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
-#endif /* not BFD64 */
-#define printf_vma(x) fprintf_vma(stdout,x)
-
-typedef unsigned int flagword; /* 32 bits of flags */
-typedef unsigned char bfd_byte;
-
-/** File formats */
-
-typedef enum bfd_format {
- bfd_unknown = 0, /* file format is unknown */
- bfd_object, /* linker/assember/compiler output */
- bfd_archive, /* object archive file */
- bfd_core, /* core dump */
- bfd_type_end} /* marks the end; don't use it! */
- bfd_format;
-
-/* Values that may appear in the flags field of a BFD. These also
- appear in the object_flags field of the bfd_target structure, where
- they indicate the set of flags used by that backend (not all flags
- are meaningful for all object file formats) (FIXME: at the moment,
- the object_flags values have mostly just been copied from backend
- to another, and are not necessarily correct). */
-
-/* No flags. */
-#define NO_FLAGS 0x00
-
-/* BFD contains relocation entries. */
-#define HAS_RELOC 0x01
-
-/* BFD is directly executable. */
-#define EXEC_P 0x02
-
-/* BFD has line number information (basically used for F_LNNO in a
- COFF header). */
-#define HAS_LINENO 0x04
-
-/* BFD has debugging information. */
-#define HAS_DEBUG 0x08
-
-/* BFD has symbols. */
-#define HAS_SYMS 0x10
-
-/* BFD has local symbols (basically used for F_LSYMS in a COFF
- header). */
-#define HAS_LOCALS 0x20
-
-/* BFD is a dynamic object. */
-#define DYNAMIC 0x40
-
-/* Text section is write protected (if D_PAGED is not set, this is
- like an a.out NMAGIC file) (the linker sets this by default, but
- clears it for -r or -N). */
-#define WP_TEXT 0x80
-
-/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
- linker sets this by default, but clears it for -r or -n or -N). */
-#define D_PAGED 0x100
-
-/* BFD is relaxable (this means that bfd_relax_section may be able to
- do something) (sometimes bfd_relax_section can do something even if
- this is not set). */
-#define BFD_IS_RELAXABLE 0x200
-
-/* This may be set before writing out a BFD to request using a
- traditional format. For example, this is used to request that when
- writing out an a.out object the symbols not be hashed to eliminate
- duplicates. */
-#define BFD_TRADITIONAL_FORMAT 0x400
-
-/* This flag indicates that the BFD contents are actually cached in
- memory. If this is set, iostream points to a bfd_in_memory struct. */
-#define BFD_IN_MEMORY 0x800
-
-/* symbols and relocation */
-
-/* A count of carsyms (canonical archive symbols). */
-typedef unsigned long symindex;
-
-/* How to perform a relocation. */
-typedef const struct reloc_howto_struct reloc_howto_type;
-
-#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
-
-/* General purpose part of a symbol X;
- target specific parts are in libcoff.h, libaout.h, etc. */
-
-#define bfd_get_section(x) ((x)->section)
-#define bfd_get_output_section(x) ((x)->section->output_section)
-#define bfd_set_section(x,y) ((x)->section) = (y)
-#define bfd_asymbol_base(x) ((x)->section->vma)
-#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
-#define bfd_asymbol_name(x) ((x)->name)
-/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
-#define bfd_asymbol_bfd(x) ((x)->the_bfd)
-#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
-
-/* A canonical archive symbol. */
-/* This is a type pun with struct ranlib on purpose! */
-typedef struct carsym {
- char *name;
- file_ptr file_offset; /* look here to find the file */
-} carsym; /* to make these you call a carsymogen */
-
-
-/* Used in generating armaps (archive tables of contents).
- Perhaps just a forward definition would do? */
-struct orl { /* output ranlib */
- char **name; /* symbol name */
- file_ptr pos; /* bfd* or file position */
- int namidx; /* index into string table */
-};
-
-
-/* Linenumber stuff */
-typedef struct lineno_cache_entry {
- unsigned int line_number; /* Linenumber from start of function*/
- union {
- struct symbol_cache_entry *sym; /* Function name */
- unsigned long offset; /* Offset into section */
- } u;
-} alent;
-
-/* object and core file sections */
-
-#define align_power(addr, align) \
- ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
-
-typedef struct sec *sec_ptr;
-
-#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
-#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
-#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
-#define bfd_section_name(bfd, ptr) ((ptr)->name)
-#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
-#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
-#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
-#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
-#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
-
-#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
-
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
-
-typedef struct stat stat_type;
-
-typedef enum bfd_print_symbol
-{
- bfd_print_symbol_name,
- bfd_print_symbol_more,
- bfd_print_symbol_all
-} bfd_print_symbol_type;
-
-/* Information about a symbol that nm needs. */
-
-typedef struct _symbol_info
-{
- symvalue value;
- char type;
- CONST char *name; /* Symbol name. */
- unsigned char stab_type; /* Stab type. */
- char stab_other; /* Stab other. */
- short stab_desc; /* Stab desc. */
- CONST char *stab_name; /* String for stab type. */
-} symbol_info;
-
-/* Get the name of a stabs type code. */
-
-extern const char *bfd_get_stab_name PARAMS ((int));
-
-/* Hash table routines. There is no way to free up a hash table. */
-
-/* An element in the hash table. Most uses will actually use a larger
- structure, and an instance of this will be the first field. */
-
-struct bfd_hash_entry
-{
- /* Next entry for this hash code. */
- struct bfd_hash_entry *next;
- /* String being hashed. */
- const char *string;
- /* Hash code. This is the full hash code, not the index into the
- table. */
- unsigned long hash;
-};
-
-/* A hash table. */
-
-struct bfd_hash_table
-{
- /* The hash array. */
- struct bfd_hash_entry **table;
- /* The number of slots in the hash table. */
- unsigned int size;
- /* A function used to create new elements in the hash table. The
- first entry is itself a pointer to an element. When this
- function is first invoked, this pointer will be NULL. However,
- having the pointer permits a hierarchy of method functions to be
- built each of which calls the function in the superclass. Thus
- each function should be written to allocate a new block of memory
- only if the argument is NULL. */
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
- /* An obstack for this hash table. */
- struct obstack memory;
-};
-
-/* Initialize a hash table. */
-extern boolean bfd_hash_table_init
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Initialize a hash table specifying a size. */
-extern boolean bfd_hash_table_init_n
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *),
- unsigned int size));
-
-/* Free up a hash table. */
-extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
-
-/* Look up a string in a hash table. If CREATE is true, a new entry
- will be created for this string if one does not already exist. The
- COPY argument must be true if this routine should copy the string
- into newly allocated memory when adding an entry. */
-extern struct bfd_hash_entry *bfd_hash_lookup
- PARAMS ((struct bfd_hash_table *, const char *, boolean create,
- boolean copy));
-
-/* Replace an entry in a hash table. */
-extern void bfd_hash_replace
- PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
- struct bfd_hash_entry *nw));
-
-/* Base method for creating a hash table entry. */
-extern struct bfd_hash_entry *bfd_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-
-/* Grab some space for a hash table entry. */
-extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
- unsigned int));
-
-/* Traverse a hash table in a random order, calling a function on each
- element. If the function returns false, the traversal stops. The
- INFO argument is passed to the function. */
-extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
- boolean (*) (struct bfd_hash_entry *,
- PTR),
- PTR info));
-
-/* Semi-portable string concatenation in cpp.
- The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
- The problem is, "32_" is not a valid preprocessing token, and we don't
- want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
- inner CAT macros to be evaluated first, producing still-valid pp-tokens.
- Then the final concatenation can be done. (Sigh.) */
-#ifndef CAT
-#ifdef SABER
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define CAT4(a,b,c,d) a##b##c##d
-#else
-#if defined(__STDC__) || defined(ALMOST_STDC)
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define XCAT2(a,b) CAT(a,b)
-#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
-#else
-#define CAT(a,b) a/**/b
-#define CAT3(a,b,c) a/**/b/**/c
-#define CAT4(a,b,c,d) a/**/b/**/c/**/d
-#endif
-#endif
-#endif
-
-#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
-
-/* User program access to BFD facilities */
-
-/* Direct I/O routines, for programs which know more about the object
- file than BFD does. Use higher level routines if possible. */
-
-extern bfd_size_type bfd_read
- PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern bfd_size_type bfd_write
- PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
-extern long bfd_tell PARAMS ((bfd *abfd));
-extern int bfd_flush PARAMS ((bfd *abfd));
-extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
-
-
-/* Cast from const char * to char * so that caller can assign to
- a char * without a warning. */
-#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
-#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
-#define bfd_get_format(abfd) ((abfd)->format)
-#define bfd_get_target(abfd) ((abfd)->xvec->name)
-#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
-#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
-#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_header_big_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
-#define bfd_header_little_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_get_file_flags(abfd) ((abfd)->flags)
-#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
-#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
-#define bfd_my_archive(abfd) ((abfd)->my_archive)
-#define bfd_has_map(abfd) ((abfd)->has_armap)
-
-#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
-#define bfd_usrdata(abfd) ((abfd)->usrdata)
-
-#define bfd_get_start_address(abfd) ((abfd)->start_address)
-#define bfd_get_symcount(abfd) ((abfd)->symcount)
-#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
-#define bfd_count_sections(abfd) ((abfd)->section_count)
-
-#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
-
-extern boolean bfd_record_phdr
- PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
- boolean, boolean, unsigned int, struct sec **));
-
-/* Byte swapping routines. */
-
-bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
-void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
-
-/* Externally visible ECOFF routines. */
-
-#if defined(__STDC__) || defined(ALMOST_STDC)
-struct ecoff_debug_info;
-struct ecoff_debug_swap;
-struct ecoff_extr;
-struct symbol_cache_entry;
-struct bfd_link_info;
-struct bfd_link_hash_entry;
-#endif
-extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
-extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
-extern boolean bfd_ecoff_set_regmasks
- PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
- unsigned long *cprmask));
-extern PTR bfd_ecoff_debug_init
- PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern void bfd_ecoff_debug_free
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- bfd *input_bfd, struct ecoff_debug_info *input_debug,
- const struct ecoff_debug_swap *input_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate_other
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_externals
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- boolean relocateable,
- boolean (*get_extr) (struct symbol_cache_entry *,
- struct ecoff_extr *),
- void (*set_index) (struct symbol_cache_entry *,
- bfd_size_type)));
-extern boolean bfd_ecoff_debug_one_external
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- const char *name, struct ecoff_extr *esym));
-extern bfd_size_type bfd_ecoff_debug_size
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap));
-extern boolean bfd_ecoff_write_debug
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap, file_ptr where));
-extern boolean bfd_ecoff_write_accumulated_debug
- PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- struct bfd_link_info *info, file_ptr where));
-extern boolean bfd_mips_ecoff_create_embedded_relocs
- PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
- char **));
-
-/* Externally visible ELF routines. */
-
-struct bfd_link_needed_list
-{
- struct bfd_link_needed_list *next;
- bfd *by;
- const char *name;
-};
-
-extern boolean bfd_elf32_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern boolean bfd_elf64_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern struct bfd_link_needed_list *bfd_elf_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf32_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern boolean bfd_elf64_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
-extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
-
-/* SunOS shared library support routines for the linker. */
-
-extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_sunos_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_sunos_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
- struct sec **));
-
-/* Linux shared library support routines for the linker. */
-
-extern boolean bfd_i386linux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_m68klinux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* mmap hacks */
-
-struct _bfd_window_internal;
-typedef struct _bfd_window_internal bfd_window_internal;
-
-typedef struct _bfd_window {
- /* What the user asked for. */
- PTR data;
- bfd_size_type size;
- /* The actual window used by BFD. Small user-requested read-only
- regions sharing a page may share a single window into the object
- file. Read-write versions shouldn't until I've fixed things to
- keep track of which portions have been claimed by the
- application; don't want to give the same region back when the
- application wants two writable copies! */
- struct _bfd_window_internal *i;
-} bfd_window;
-
-extern void bfd_init_window PARAMS ((bfd_window *));
-extern void bfd_free_window PARAMS ((bfd_window *));
-extern boolean bfd_get_file_window
- PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
-
-/* XCOFF support routines for the linker. */
-
-extern boolean bfd_xcoff_link_record_set
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_size_type));
-extern boolean bfd_xcoff_import_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_vma, const char *, const char *, const char *));
-extern boolean bfd_xcoff_export_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- boolean));
-extern boolean bfd_xcoff_link_count_reloc
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
- unsigned long, unsigned long, unsigned long, boolean,
- int, boolean, boolean, struct sec **));
-
-/* And more from the source. */
diff --git a/contrib/gdb/bfd/bfd.c b/contrib/gdb/bfd/bfd.c
deleted file mode 100644
index 10ec67e..0000000
--- a/contrib/gdb/bfd/bfd.c
+++ /dev/null
@@ -1,1144 +0,0 @@
-/* Generic BFD library interface and support routines.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- <<typedef bfd>>
-
- A BFD has type <<bfd>>; objects of this type are the
- cornerstone of any application using BFD. Using BFD
- consists of making references though the BFD and to data in the BFD.
-
- Here is the structure that defines the type <<bfd>>. It
- contains the major data about the file and pointers
- to the rest of the data.
-
-CODE_FRAGMENT
-.
-.struct _bfd
-.{
-. {* The filename the application opened the BFD with. *}
-. CONST char *filename;
-.
-. {* A pointer to the target jump table. *}
-. const struct bfd_target *xvec;
-.
-. {* To avoid dragging too many header files into every file that
-. includes `<<bfd.h>>', IOSTREAM has been declared as a "char
-. *", and MTIME as a "long". Their correct types, to which they
-. are cast when used, are "FILE *" and "time_t". The iostream
-. is the result of an fopen on the filename. However, if the
-. BFD_IN_MEMORY flag is set, then iostream is actually a pointer
-. to a bfd_in_memory struct. *}
-. PTR iostream;
-.
-. {* Is the file descriptor being cached? That is, can it be closed as
-. needed, and re-opened when accessed later? *}
-.
-. boolean cacheable;
-.
-. {* Marks whether there was a default target specified when the
-. BFD was opened. This is used to select which matching algorithm
-. to use to choose the back end. *}
-.
-. boolean target_defaulted;
-.
-. {* The caching routines use these to maintain a
-. least-recently-used list of BFDs *}
-.
-. struct _bfd *lru_prev, *lru_next;
-.
-. {* When a file is closed by the caching routines, BFD retains
-. state information on the file here: *}
-.
-. file_ptr where;
-.
-. {* and here: (``once'' means at least once) *}
-.
-. boolean opened_once;
-.
-. {* Set if we have a locally maintained mtime value, rather than
-. getting it from the file each time: *}
-.
-. boolean mtime_set;
-.
-. {* File modified time, if mtime_set is true: *}
-.
-. long mtime;
-.
-. {* Reserved for an unimplemented file locking extension.*}
-.
-. int ifd;
-.
-. {* The format which belongs to the BFD. (object, core, etc.) *}
-.
-. bfd_format format;
-.
-. {* The direction the BFD was opened with*}
-.
-. enum bfd_direction {no_direction = 0,
-. read_direction = 1,
-. write_direction = 2,
-. both_direction = 3} direction;
-.
-. {* Format_specific flags*}
-.
-. flagword flags;
-.
-. {* Currently my_archive is tested before adding origin to
-. anything. I believe that this can become always an add of
-. origin, with origin set to 0 for non archive files. *}
-.
-. file_ptr origin;
-.
-. {* Remember when output has begun, to stop strange things
-. from happening. *}
-. boolean output_has_begun;
-.
-. {* Pointer to linked list of sections*}
-. struct sec *sections;
-.
-. {* The number of sections *}
-. unsigned int section_count;
-.
-. {* Stuff only useful for object files:
-. The start address. *}
-. bfd_vma start_address;
-.
-. {* Used for input and output*}
-. unsigned int symcount;
-.
-. {* Symbol table for output BFD (with symcount entries) *}
-. struct symbol_cache_entry **outsymbols;
-.
-. {* Pointer to structure which contains architecture information*}
-. const struct bfd_arch_info *arch_info;
-.
-. {* Stuff only useful for archives:*}
-. PTR arelt_data;
-. struct _bfd *my_archive; {* The containing archive BFD. *}
-. struct _bfd *next; {* The next BFD in the archive. *}
-. struct _bfd *archive_head; {* The first BFD in the archive. *}
-. boolean has_armap;
-.
-. {* A chain of BFD structures involved in a link. *}
-. struct _bfd *link_next;
-.
-. {* A field used by _bfd_generic_link_add_archive_symbols. This will
-. be used only for archive elements. *}
-. int archive_pass;
-.
-. {* Used by the back end to hold private data. *}
-.
-. union
-. {
-. struct aout_data_struct *aout_data;
-. struct artdata *aout_ar_data;
-. struct _oasys_data *oasys_obj_data;
-. struct _oasys_ar_data *oasys_ar_data;
-. struct coff_tdata *coff_obj_data;
-. struct pe_tdata *pe_obj_data;
-. struct xcoff_tdata *xcoff_obj_data;
-. struct ecoff_tdata *ecoff_obj_data;
-. struct ieee_data_struct *ieee_data;
-. struct ieee_ar_data_struct *ieee_ar_data;
-. struct srec_data_struct *srec_data;
-. struct ihex_data_struct *ihex_data;
-. struct tekhex_data_struct *tekhex_data;
-. struct elf_obj_tdata *elf_obj_data;
-. struct nlm_obj_tdata *nlm_obj_data;
-. struct bout_data_struct *bout_data;
-. struct sun_core_struct *sun_core_data;
-. struct trad_core_struct *trad_core_data;
-. struct som_data_struct *som_data;
-. struct hpux_core_struct *hpux_core_data;
-. struct hppabsd_core_struct *hppabsd_core_data;
-. struct sgi_core_struct *sgi_core_data;
-. struct lynx_core_struct *lynx_core_data;
-. struct osf_core_struct *osf_core_data;
-. struct cisco_core_struct *cisco_core_data;
-. struct versados_data_struct *versados_data;
-. struct netbsd_core_struct *netbsd_core_data;
-. PTR any;
-. } tdata;
-.
-. {* Used by the application to hold private data*}
-. PTR usrdata;
-.
-. {* Where all the allocated stuff under this BFD goes *}
-. struct obstack memory;
-.};
-.
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "libcoff.h"
-#include "libecoff.h"
-#undef obj_symbols
-#include "elf-bfd.h"
-
-#include <ctype.h>
-
-/* provide storage for subsystem, stack and heap data which may have been
- passed in on the command line. Ld puts this data into a bfd_link_info
- struct which ultimately gets passed in to the bfd. When it arrives, copy
- it to the following struct so that the data will be available in coffcode.h
- where it is needed. The typedef's used are defined in bfd.h */
-
-
-
-/*
-SECTION
- Error reporting
-
- Most BFD functions return nonzero on success (check their
- individual documentation for precise semantics). On an error,
- they call <<bfd_set_error>> to set an error condition that callers
- can check by calling <<bfd_get_error>>.
- If that returns <<bfd_error_system_call>>, then check
- <<errno>>.
-
- The easiest way to report a BFD error to the user is to
- use <<bfd_perror>>.
-
-SUBSECTION
- Type <<bfd_error_type>>
-
- The values returned by <<bfd_get_error>> are defined by the
- enumerated type <<bfd_error_type>>.
-
-CODE_FRAGMENT
-.
-.typedef enum bfd_error
-.{
-. bfd_error_no_error = 0,
-. bfd_error_system_call,
-. bfd_error_invalid_target,
-. bfd_error_wrong_format,
-. bfd_error_invalid_operation,
-. bfd_error_no_memory,
-. bfd_error_no_symbols,
-. bfd_error_no_armap,
-. bfd_error_no_more_archived_files,
-. bfd_error_malformed_archive,
-. bfd_error_file_not_recognized,
-. bfd_error_file_ambiguously_recognized,
-. bfd_error_no_contents,
-. bfd_error_nonrepresentable_section,
-. bfd_error_no_debug_section,
-. bfd_error_bad_value,
-. bfd_error_file_truncated,
-. bfd_error_file_too_big,
-. bfd_error_invalid_error_code
-.} bfd_error_type;
-.
-*/
-
-#undef strerror
-extern char *strerror();
-
-static bfd_error_type bfd_error = bfd_error_no_error;
-
-CONST char *CONST bfd_errmsgs[] = {
- "No error",
- "System call error",
- "Invalid bfd target",
- "File in wrong format",
- "Invalid operation",
- "Memory exhausted",
- "No symbols",
- "Archive has no index; run ranlib to add one",
- "No more archived files",
- "Malformed archive",
- "File format not recognized",
- "File format is ambiguous",
- "Section has no contents",
- "Nonrepresentable section on output",
- "Symbol needs debug section which does not exist",
- "Bad value",
- "File truncated",
- "File too big",
- "#<Invalid error code>"
- };
-
-/*
-FUNCTION
- bfd_get_error
-
-SYNOPSIS
- bfd_error_type bfd_get_error (void);
-
-DESCRIPTION
- Return the current BFD error condition.
-*/
-
-bfd_error_type
-bfd_get_error ()
-{
- return bfd_error;
-}
-
-/*
-FUNCTION
- bfd_set_error
-
-SYNOPSIS
- void bfd_set_error (bfd_error_type error_tag);
-
-DESCRIPTION
- Set the BFD error condition to be @var{error_tag}.
-*/
-
-void
-bfd_set_error (error_tag)
- bfd_error_type error_tag;
-{
- bfd_error = error_tag;
-}
-
-/*
-FUNCTION
- bfd_errmsg
-
-SYNOPSIS
- CONST char *bfd_errmsg (bfd_error_type error_tag);
-
-DESCRIPTION
- Return a string describing the error @var{error_tag}, or
- the system error if @var{error_tag} is <<bfd_error_system_call>>.
-*/
-
-CONST char *
-bfd_errmsg (error_tag)
- bfd_error_type error_tag;
-{
-#ifndef errno
- extern int errno;
-#endif
- if (error_tag == bfd_error_system_call)
- {
- const char *errmsg;
-
- errmsg = strerror (errno);
- if (errmsg == NULL)
- {
- static char buf[32];
-
- sprintf (buf, "Error %d", errno);
- errmsg = buf;
- }
- return errmsg;
- }
-
- if ((((int)error_tag <(int) bfd_error_no_error) ||
- ((int)error_tag > (int)bfd_error_invalid_error_code)))
- error_tag = bfd_error_invalid_error_code;/* sanity check */
-
- return bfd_errmsgs [(int)error_tag];
-}
-
-/*
-FUNCTION
- bfd_perror
-
-SYNOPSIS
- void bfd_perror (CONST char *message);
-
-DESCRIPTION
- Print to the standard error stream a string describing the
- last BFD error that occurred, or the last system error if
- the last BFD error was a system call failure. If @var{message}
- is non-NULL and non-empty, the error string printed is preceded
- by @var{message}, a colon, and a space. It is followed by a newline.
-*/
-
-void
-bfd_perror (message)
- CONST char *message;
-{
- if (bfd_get_error () == bfd_error_system_call)
- perror((char *)message); /* must be system error then... */
- else {
- if (message == NULL || *message == '\0')
- fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
- else
- fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
- }
-}
-
-/*
-SUBSECTION
- BFD error handler
-
- Some BFD functions want to print messages describing the
- problem. They call a BFD error handler function. This
- function may be overriden by the program.
-
- The BFD error handler acts like printf.
-
-CODE_FRAGMENT
-.
-.typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
-.
-*/
-
-/* The program name used when printing BFD error messages. */
-
-static const char *_bfd_error_program_name;
-
-/* This is the default routine to handle BFD error messages. */
-
-#ifdef ANSI_PROTOTYPES
-
-static void _bfd_default_error_handler PARAMS ((const char *s, ...));
-
-static void
-_bfd_default_error_handler (const char *s, ...)
-{
- va_list p;
-
- if (_bfd_error_program_name != NULL)
- fprintf (stderr, "%s: ", _bfd_error_program_name);
-
- va_start (p, s);
-
- vfprintf (stderr, s, p);
-
- va_end (p);
-
- fprintf (stderr, "\n");
-}
-
-#else /* ! defined (ANSI_PROTOTYPES) */
-
-static void _bfd_default_error_handler ();
-
-static void
-_bfd_default_error_handler (va_alist)
- va_dcl
-{
- va_list p;
- const char *s;
-
- if (_bfd_error_program_name != NULL)
- fprintf (stderr, "%s: ", _bfd_error_program_name);
-
- va_start (p);
-
- s = va_arg (p, const char *);
- vfprintf (stderr, s, p);
-
- va_end (p);
-
- fprintf (stderr, "\n");
-}
-
-#endif /* ! defined (ANSI_PROTOTYPES) */
-
-/* This is a function pointer to the routine which should handle BFD
- error messages. It is called when a BFD routine encounters an
- error for which it wants to print a message. Going through a
- function pointer permits a program linked against BFD to intercept
- the messages and deal with them itself. */
-
-bfd_error_handler_type _bfd_error_handler = _bfd_default_error_handler;
-
-/*
-FUNCTION
- bfd_set_error_handler
-
-SYNOPSIS
- bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
-
-DESCRIPTION
- Set the BFD error handler function. Returns the previous
- function.
-*/
-
-bfd_error_handler_type
-bfd_set_error_handler (pnew)
- bfd_error_handler_type pnew;
-{
- bfd_error_handler_type pold;
-
- pold = _bfd_error_handler;
- _bfd_error_handler = pnew;
- return pold;
-}
-
-/*
-FUNCTION
- bfd_set_error_program_name
-
-SYNOPSIS
- void bfd_set_error_program_name (const char *);
-
-DESCRIPTION
- Set the program name to use when printing a BFD error. This
- is printed before the error message followed by a colon and
- space. The string must not be changed after it is passed to
- this function.
-*/
-
-void
-bfd_set_error_program_name (name)
- const char *name;
-{
- _bfd_error_program_name = name;
-}
-
-/*
-SECTION
- Symbols
-*/
-
-/*
-FUNCTION
- bfd_get_reloc_upper_bound
-
-SYNOPSIS
- long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
-
-DESCRIPTION
- Return the number of bytes required to store the
- relocation information associated with section @var{sect}
- attached to bfd @var{abfd}. If an error occurs, return -1.
-
-*/
-
-
-long
-bfd_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
-}
-
-/*
-FUNCTION
- bfd_canonicalize_reloc
-
-SYNOPSIS
- long bfd_canonicalize_reloc
- (bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms);
-
-DESCRIPTION
- Call the back end associated with the open BFD
- @var{abfd} and translate the external form of the relocation
- information attached to @var{sec} into the internal canonical
- form. Place the table into memory at @var{loc}, which has
- been preallocated, usually by a call to
- <<bfd_get_reloc_upper_bound>>. Returns the number of relocs, or
- -1 on error.
-
- The @var{syms} table is also needed for horrible internal magic
- reasons.
-
-
-*/
-long
-bfd_canonicalize_reloc (abfd, asect, location, symbols)
- bfd *abfd;
- sec_ptr asect;
- arelent **location;
- asymbol **symbols;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- return BFD_SEND (abfd, _bfd_canonicalize_reloc,
- (abfd, asect, location, symbols));
-}
-
-/*
-FUNCTION
- bfd_set_reloc
-
-SYNOPSIS
- void bfd_set_reloc
- (bfd *abfd, asection *sec, arelent **rel, unsigned int count)
-
-DESCRIPTION
- Set the relocation pointer and count within
- section @var{sec} to the values @var{rel} and @var{count}.
- The argument @var{abfd} is ignored.
-
-*/
-/*ARGSUSED*/
-void
-bfd_set_reloc (ignore_abfd, asect, location, count)
- bfd *ignore_abfd;
- sec_ptr asect;
- arelent **location;
- unsigned int count;
-{
- asect->orelocation = location;
- asect->reloc_count = count;
-}
-
-/*
-FUNCTION
- bfd_set_file_flags
-
-SYNOPSIS
- boolean bfd_set_file_flags(bfd *abfd, flagword flags);
-
-DESCRIPTION
- Set the flag word in the BFD @var{abfd} to the value @var{flags}.
-
- Possible errors are:
- o <<bfd_error_wrong_format>> - The target bfd was not of object format.
- o <<bfd_error_invalid_operation>> - The target bfd was open for reading.
- o <<bfd_error_invalid_operation>> -
- The flag word contained a bit which was not applicable to the
- type of file. E.g., an attempt was made to set the <<D_PAGED>> bit
- on a BFD format which does not support demand paging.
-
-*/
-
-boolean
-bfd_set_file_flags (abfd, flags)
- bfd *abfd;
- flagword flags;
-{
- if (abfd->format != bfd_object) {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- if (bfd_read_p (abfd)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- bfd_get_file_flags (abfd) = flags;
- if ((flags & bfd_applicable_file_flags (abfd)) != flags) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
-return true;
-}
-
-void
-bfd_assert (file, line)
- const char *file;
- int line;
-{
- (*_bfd_error_handler) ("bfd assertion fail %s:%d", file, line);
-}
-
-
-/*
-FUNCTION
- bfd_set_start_address
-
-SYNOPSIS
- boolean bfd_set_start_address(bfd *abfd, bfd_vma vma);
-
-DESCRIPTION
- Make @var{vma} the entry point of output BFD @var{abfd}.
-
-RETURNS
- Returns <<true>> on success, <<false>> otherwise.
-*/
-
-boolean
-bfd_set_start_address(abfd, vma)
-bfd *abfd;
-bfd_vma vma;
-{
- abfd->start_address = vma;
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_get_mtime
-
-SYNOPSIS
- long bfd_get_mtime(bfd *abfd);
-
-DESCRIPTION
- Return the file modification time (as read from the file system, or
- from the archive header for archive members).
-
-*/
-
-long
-bfd_get_mtime (abfd)
- bfd *abfd;
-{
- FILE *fp;
- struct stat buf;
-
- if (abfd->mtime_set)
- return abfd->mtime;
-
- fp = bfd_cache_lookup (abfd);
- if (0 != fstat (fileno (fp), &buf))
- return 0;
-
- abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
- return buf.st_mtime;
-}
-
-/*
-FUNCTION
- bfd_get_size
-
-SYNOPSIS
- long bfd_get_size(bfd *abfd);
-
-DESCRIPTION
- Return the file size (as read from file system) for the file
- associated with BFD @var{abfd}.
-
- The initial motivation for, and use of, this routine is not
- so we can get the exact size of the object the BFD applies to, since
- that might not be generally possible (archive members for example).
- It would be ideal if someone could eventually modify
- it so that such results were guaranteed.
-
- Instead, we want to ask questions like "is this NNN byte sized
- object I'm about to try read from file offset YYY reasonable?"
- As as example of where we might do this, some object formats
- use string tables for which the first <<sizeof(long)>> bytes of the
- table contain the size of the table itself, including the size bytes.
- If an application tries to read what it thinks is one of these
- string tables, without some way to validate the size, and for
- some reason the size is wrong (byte swapping error, wrong location
- for the string table, etc.), the only clue is likely to be a read
- error when it tries to read the table, or a "virtual memory
- exhausted" error when it tries to allocate 15 bazillon bytes
- of space for the 15 bazillon byte table it is about to read.
- This function at least allows us to answer the quesion, "is the
- size reasonable?".
-*/
-
-long
-bfd_get_size (abfd)
- bfd *abfd;
-{
- FILE *fp;
- struct stat buf;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return ((struct bfd_in_memory *) abfd->iostream)->size;
-
- fp = bfd_cache_lookup (abfd);
- if (0 != fstat (fileno (fp), &buf))
- return 0;
-
- return buf.st_size;
-}
-
-/*
-FUNCTION
- bfd_get_gp_size
-
-SYNOPSIS
- int bfd_get_gp_size(bfd *abfd);
-
-DESCRIPTION
- Return the maximum size of objects to be optimized using the GP
- register under MIPS ECOFF. This is typically set by the <<-G>>
- argument to the compiler, assembler or linker.
-*/
-
-int
-bfd_get_gp_size (abfd)
- bfd *abfd;
-{
- if (abfd->format == bfd_object)
- {
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- return ecoff_data (abfd)->gp_size;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- return elf_gp_size (abfd);
- }
- return 0;
-}
-
-/*
-FUNCTION
- bfd_set_gp_size
-
-SYNOPSIS
- void bfd_set_gp_size(bfd *abfd, int i);
-
-DESCRIPTION
- Set the maximum size of objects to be optimized using the GP
- register under ECOFF or MIPS ELF. This is typically set by
- the <<-G>> argument to the compiler, assembler or linker.
-*/
-
-void
-bfd_set_gp_size (abfd, i)
- bfd *abfd;
- int i;
-{
- /* Don't try to set GP size on an archive or core file! */
- if (abfd->format != bfd_object)
- return;
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- ecoff_data (abfd)->gp_size = i;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- elf_gp_size (abfd) = i;
-}
-
-/* Get the GP value. This is an internal function used by some of the
- relocation special_function routines on targets which support a GP
- register. */
-
-bfd_vma
-_bfd_get_gp_value (abfd)
- bfd *abfd;
-{
- if (abfd->format == bfd_object)
- {
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- return ecoff_data (abfd)->gp;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- return elf_gp (abfd);
- }
- return 0;
-}
-
-/* Set the GP value. */
-
-void
-_bfd_set_gp_value (abfd, v)
- bfd *abfd;
- bfd_vma v;
-{
- if (abfd->format != bfd_object)
- return;
- if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
- ecoff_data (abfd)->gp = v;
- else if (abfd->xvec->flavour == bfd_target_elf_flavour)
- elf_gp (abfd) = v;
-}
-
-/*
-FUNCTION
- bfd_scan_vma
-
-SYNOPSIS
- bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
-
-DESCRIPTION
- Convert, like <<strtoul>>, a numerical expression
- @var{string} into a <<bfd_vma>> integer, and return that integer.
- (Though without as many bells and whistles as <<strtoul>>.)
- The expression is assumed to be unsigned (i.e., positive).
- If given a @var{base}, it is used as the base for conversion.
- A base of 0 causes the function to interpret the string
- in hex if a leading "0x" or "0X" is found, otherwise
- in octal if a leading zero is found, otherwise in decimal.
-
- Overflow is not detected.
-*/
-
-bfd_vma
-bfd_scan_vma (string, end, base)
- CONST char *string;
- CONST char **end;
- int base;
-{
- bfd_vma value;
- int digit;
-
- /* Let the host do it if possible. */
- if (sizeof(bfd_vma) <= sizeof(unsigned long))
- return (bfd_vma) strtoul (string, (char **) end, base);
-
- /* A negative base makes no sense, and we only need to go as high as hex. */
- if ((base < 0) || (base > 16))
- return (bfd_vma) 0;
-
- if (base == 0)
- {
- if (string[0] == '0')
- {
- if ((string[1] == 'x') || (string[1] == 'X'))
- base = 16;
- /* XXX should we also allow "0b" or "0B" to set base to 2? */
- else
- base = 8;
- }
- else
- base = 10;
- }
- if ((base == 16) &&
- (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')))
- string += 2;
- /* XXX should we also skip over "0b" or "0B" if base is 2? */
-
-/* Speed could be improved with a table like hex_value[] in gas. */
-#define HEX_VALUE(c) \
- (isxdigit(c) ? \
- (isdigit(c) ? \
- (c - '0') : \
- (10 + c - (islower(c) ? 'a' : 'A'))) : \
- 42)
-
- for (value = 0; (digit = HEX_VALUE(*string)) < base; string++)
- {
- value = value * base + digit;
- }
-
- if (end)
- *end = string;
-
- return value;
-}
-
-/*
-FUNCTION
- bfd_copy_private_bfd_data
-
-SYNOPSIS
- boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd);
-
-DESCRIPTION
- Copy private BFD information from the BFD @var{ibfd} to the
- the BFD @var{obfd}. Return <<true>> on success, <<false>> on error.
- Possible error returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_copy_private_bfd_data(ibfd, obfd) \
-. BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \
-. (ibfd, obfd))
-
-*/
-
-/*
-FUNCTION
- bfd_merge_private_bfd_data
-
-SYNOPSIS
- boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd);
-
-DESCRIPTION
- Merge private BFD information from the BFD @var{ibfd} to the
- the output file BFD @var{obfd} when linking. Return <<true>>
- on success, <<false>> on error. Possible error returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_merge_private_bfd_data(ibfd, obfd) \
-. BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \
-. (ibfd, obfd))
-
-*/
-
-/*
-FUNCTION
- bfd_set_private_flags
-
-SYNOPSIS
- boolean bfd_set_private_flags(bfd *abfd, flagword flags);
-
-DESCRIPTION
- Set private BFD flag information in the BFD @var{abfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_set_private_flags(abfd, flags) \
-. BFD_SEND (abfd, _bfd_set_private_flags, \
-. (abfd, flags))
-
-*/
-
-/*
-FUNCTION
- stuff
-
-DESCRIPTION
- Stuff which should be documented:
-
-.#define bfd_sizeof_headers(abfd, reloc) \
-. BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
-.
-.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
-. BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
-.
-. {* Do these three do anything useful at all, for any back end? *}
-.#define bfd_debug_info_start(abfd) \
-. BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
-.
-.#define bfd_debug_info_end(abfd) \
-. BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
-.
-.#define bfd_debug_info_accumulate(abfd, section) \
-. BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
-.
-.
-.#define bfd_stat_arch_elt(abfd, stat) \
-. BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
-.
-.#define bfd_update_armap_timestamp(abfd) \
-. BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
-.
-.#define bfd_set_arch_mach(abfd, arch, mach)\
-. BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-.
-.#define bfd_relax_section(abfd, section, link_info, again) \
-. BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
-.
-.#define bfd_link_hash_table_create(abfd) \
-. BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
-.
-.#define bfd_link_add_symbols(abfd, info) \
-. BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
-.
-.#define bfd_final_link(abfd, info) \
-. BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-.
-.#define bfd_free_cached_info(abfd) \
-. BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
-.
-.#define bfd_get_dynamic_symtab_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
-.
-.#define bfd_print_private_bfd_data(abfd, file)\
-. BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
-.
-.#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
-. BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
-.
-.#define bfd_get_dynamic_reloc_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
-.
-.#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
-. BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
-.
-.extern bfd_byte *bfd_get_relocated_section_contents
-. PARAMS ((bfd *, struct bfd_link_info *,
-. struct bfd_link_order *, bfd_byte *,
-. boolean, asymbol **));
-.
-
-*/
-
-bfd_byte *
-bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
- relocateable, symbols)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- bfd *abfd2;
- bfd_byte *(*fn) PARAMS ((bfd *, struct bfd_link_info *,
- struct bfd_link_order *, bfd_byte *, boolean,
- asymbol **));
-
- if (link_order->type == bfd_indirect_link_order)
- {
- abfd2 = link_order->u.indirect.section->owner;
- if (abfd2 == 0)
- abfd2 = abfd;
- }
- else
- abfd2 = abfd;
- fn = abfd2->xvec->_bfd_get_relocated_section_contents;
-
- return (*fn) (abfd, link_info, link_order, data, relocateable, symbols);
-}
-
-/* Record information about an ELF program header. */
-
-boolean
-bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at,
- includes_filehdr, includes_phdrs, count, secs)
- bfd *abfd;
- unsigned long type;
- boolean flags_valid;
- flagword flags;
- boolean at_valid;
- bfd_vma at;
- boolean includes_filehdr;
- boolean includes_phdrs;
- unsigned int count;
- asection **secs;
-{
- struct elf_segment_map *m, **pm;
-
- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
- return true;
-
- m = ((struct elf_segment_map *)
- bfd_alloc (abfd,
- (sizeof (struct elf_segment_map)
- + (count - 1) * sizeof (asection *))));
- if (m == NULL)
- return false;
-
- m->next = NULL;
- m->p_type = type;
- m->p_flags = flags;
- m->p_paddr = at;
- m->p_flags_valid = flags_valid;
- m->p_paddr_valid = at_valid;
- m->includes_filehdr = includes_filehdr;
- m->includes_phdrs = includes_phdrs;
- m->count = count;
- if (count > 0)
- memcpy (m->sections, secs, count * sizeof (asection *));
-
- for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
- ;
- *pm = m;
-
- return true;
-}
diff --git a/contrib/gdb/bfd/binary.c b/contrib/gdb/bfd/binary.c
deleted file mode 100644
index a480e46..0000000
--- a/contrib/gdb/bfd/binary.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/* BFD back-end for binary objects.
- Copyright 1994 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is a BFD backend which may be used to write binary objects.
- It may only be used for output, not input. The intention is that
- this may be used as an output format for objcopy in order to
- generate raw binary data.
-
- This is very simple. The only complication is that the real data
- will start at some address X, and in some cases we will not want to
- include X zeroes just to get to that point. Since the start
- address is not meaningful for this object file format, we use it
- instead to indicate the number of zeroes to skip at the start of
- the file. objcopy cooperates by specially setting the start
- address to zero by default. */
-
-#include <ctype.h>
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* Any bfd we create by reading a binary file has three symbols:
- a start symbol, an end symbol, and an absolute length symbol. */
-#define BIN_SYMS 3
-
-static boolean binary_mkobject PARAMS ((bfd *));
-static const bfd_target *binary_object_p PARAMS ((bfd *));
-static boolean binary_get_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static long binary_get_symtab_upper_bound PARAMS ((bfd *));
-static char *mangle_name PARAMS ((bfd *, char *));
-static long binary_get_symtab PARAMS ((bfd *, asymbol **));
-static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
-static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static boolean binary_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static int binary_sizeof_headers PARAMS ((bfd *, boolean));
-
-/* Create a binary object. Invoked via bfd_set_format. */
-
-static boolean
-binary_mkobject (abfd)
- bfd *abfd;
-{
- return true;
-}
-
-/* Any file may be considered to be a binary file, provided the target
- was not defaulted. That is, it must be explicitly specified as
- being binary. */
-
-static const bfd_target *
-binary_object_p (abfd)
- bfd *abfd;
-{
- struct stat statbuf;
- asection *sec;
-
- if (abfd->target_defaulted)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- abfd->symcount = BIN_SYMS;
-
- /* Find the file size. */
- if (bfd_stat (abfd, &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- /* One data section. */
- sec = bfd_make_section (abfd, ".data");
- if (sec == NULL)
- return NULL;
- sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
- sec->vma = 0;
- sec->_raw_size = statbuf.st_size;
- sec->filepos = 0;
-
- abfd->tdata.any = (PTR) sec;
-
- return abfd->xvec;
-}
-
-#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
-#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define binary_new_section_hook _bfd_generic_new_section_hook
-
-/* Get contents of the only section. */
-
-static boolean
-binary_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (bfd_seek (abfd, offset, SEEK_SET) != 0
- || bfd_read (location, 1, count, abfd) != count)
- return false;
- return true;
-}
-
-/* Return the amount of memory needed to read the symbol table. */
-
-static long
-binary_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (BIN_SYMS + 1) * sizeof (asymbol *);
-}
-
-/* Create a symbol name based on the bfd's filename. */
-
-static char *
-mangle_name (abfd, suffix)
- bfd *abfd;
- char *suffix;
-{
- int size;
- char *buf;
- char *p;
-
- size = (strlen (bfd_get_filename (abfd))
- + strlen (suffix)
- + sizeof "_binary__");
-
- buf = (char *) bfd_alloc (abfd, size);
- if (buf == NULL)
- return "";
-
- sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
-
- /* Change any non-alphanumeric characters to underscores. */
- for (p = buf; *p; p++)
- if (! isalnum (*p))
- *p = '_';
-
- return buf;
-}
-
-/* Return the symbol table. */
-
-static long
-binary_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- asection *sec = (asection *) abfd->tdata.any;
- asymbol *syms;
- unsigned int i;
-
- syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
- if (syms == NULL)
- return false;
-
- /* Start symbol. */
- syms[0].the_bfd = abfd;
- syms[0].name = mangle_name (abfd, "start");
- syms[0].value = 0;
- syms[0].flags = BSF_GLOBAL;
- syms[0].section = sec;
- syms[0].udata.p = NULL;
-
- /* End symbol. */
- syms[1].the_bfd = abfd;
- syms[1].name = mangle_name (abfd, "end");
- syms[1].value = sec->_raw_size;
- syms[1].flags = BSF_GLOBAL;
- syms[1].section = sec;
- syms[1].udata.p = NULL;
-
- /* Size symbol. */
- syms[2].the_bfd = abfd;
- syms[2].name = mangle_name (abfd, "size");
- syms[2].value = sec->_raw_size;
- syms[2].flags = BSF_GLOBAL;
- syms[2].section = bfd_abs_section_ptr;
- syms[2].udata.p = NULL;
-
- for (i = 0; i < BIN_SYMS; i++)
- *alocation++ = syms++;
- *alocation = NULL;
-
- return BIN_SYMS;
-}
-
-/* Make an empty symbol. */
-
-static asymbol *
-binary_make_empty_symbol (abfd)
- bfd *abfd;
-{
- return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
-}
-
-#define binary_print_symbol _bfd_nosymbols_print_symbol
-
-/* Get information about a symbol. */
-
-static void
-binary_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-#define binary_bfd_is_local_label bfd_generic_is_local_label
-#define binary_get_lineno _bfd_nosymbols_get_lineno
-#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define binary_read_minisymbols _bfd_generic_read_minisymbols
-#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define binary_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define binary_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-/* Set the architecture of a binary file. */
-#define binary_set_arch_mach _bfd_generic_set_arch_mach
-
-/* Write section contents of a binary file. */
-
-static boolean
-binary_set_section_contents (abfd, sec, data, offset, size)
- bfd *abfd;
- asection *sec;
- PTR data;
- file_ptr offset;
- bfd_size_type size;
-{
- if (! abfd->output_has_begun)
- {
- bfd_vma low;
- asection *s;
-
- /* The lowest section VMA sets the virtual address of the start
- of the file. We use the set the file position of all the
- sections. */
- low = abfd->sections->vma;
- for (s = abfd->sections->next; s != NULL; s = s->next)
- if (s->vma < low)
- low = s->vma;
-
- for (s = abfd->sections; s != NULL; s = s->next)
- s->filepos = s->vma - low;
-
- abfd->output_has_begun = true;
- }
-
- return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
-}
-
-/* No space is required for header information. */
-
-static int
-binary_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-#define binary_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define binary_bfd_relax_section bfd_generic_relax_section
-#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define binary_bfd_final_link _bfd_generic_final_link
-#define binary_bfd_link_split_section _bfd_generic_link_split_section
-#define binary_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-const bfd_target binary_vec =
-{
- "binary", /* name */
- bfd_target_unknown_flavour, /* flavour */
- BFD_ENDIAN_UNKNOWN, /* byteorder */
- BFD_ENDIAN_UNKNOWN, /* header_byteorder */
- EXEC_P, /* object_flags */
- (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
- | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
- 0, /* symbol_leading_char */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- { /* bfd_check_format */
- _bfd_dummy_target,
- binary_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- { /* bfd_set_format */
- bfd_false,
- binary_mkobject,
- bfd_false,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- bfd_true,
- bfd_false,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (binary),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (binary),
- BFD_JUMP_TABLE_RELOCS (binary),
- BFD_JUMP_TABLE_WRITE (binary),
- BFD_JUMP_TABLE_LINK (binary),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- NULL
-};
diff --git a/contrib/gdb/bfd/cache.c b/contrib/gdb/bfd/cache.c
deleted file mode 100644
index ef15877..0000000
--- a/contrib/gdb/bfd/cache.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* BFD library -- caching of file descriptors.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- File caching
-
- The file caching mechanism is embedded within BFD and allows
- the application to open as many BFDs as it wants without
- regard to the underlying operating system's file descriptor
- limit (often as low as 20 open files). The module in
- <<cache.c>> maintains a least recently used list of
- <<BFD_CACHE_MAX_OPEN>> files, and exports the name
- <<bfd_cache_lookup>>, which runs around and makes sure that
- the required BFD is open. If not, then it chooses a file to
- close, closes it and opens the one wanted, returning its file
- handle.
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-static void insert PARAMS ((bfd *));
-static void snip PARAMS ((bfd *));
-static boolean close_one PARAMS ((void));
-static boolean bfd_cache_delete PARAMS ((bfd *));
-
-/*
-INTERNAL_FUNCTION
- BFD_CACHE_MAX_OPEN macro
-
-DESCRIPTION
- The maximum number of files which the cache will keep open at
- one time.
-
-.#define BFD_CACHE_MAX_OPEN 10
-
-*/
-
-/* The number of BFD files we have open. */
-
-static int open_files;
-
-/*
-INTERNAL_FUNCTION
- bfd_last_cache
-
-SYNOPSIS
- extern bfd *bfd_last_cache;
-
-DESCRIPTION
- Zero, or a pointer to the topmost BFD on the chain. This is
- used by the <<bfd_cache_lookup>> macro in @file{libbfd.h} to
- determine when it can avoid a function call.
-*/
-
-bfd *bfd_last_cache;
-
-/*
- INTERNAL_FUNCTION
- bfd_cache_lookup
-
- DESCRIPTION
- Check to see if the required BFD is the same as the last one
- looked up. If so, then it can use the stream in the BFD with
- impunity, since it can't have changed since the last lookup;
- otherwise, it has to perform the complicated lookup function.
-
- .#define bfd_cache_lookup(x) \
- . ((x)==bfd_last_cache? \
- . (FILE*)(bfd_last_cache->iostream): \
- . bfd_cache_lookup_worker(x))
-
-
- */
-
-/* Insert a BFD into the cache. */
-
-static INLINE void
-insert (abfd)
- bfd *abfd;
-{
- if (bfd_last_cache == NULL)
- {
- abfd->lru_next = abfd;
- abfd->lru_prev = abfd;
- }
- else
- {
- abfd->lru_next = bfd_last_cache;
- abfd->lru_prev = bfd_last_cache->lru_prev;
- abfd->lru_prev->lru_next = abfd;
- abfd->lru_next->lru_prev = abfd;
- }
- bfd_last_cache = abfd;
-}
-
-/* Remove a BFD from the cache. */
-
-static INLINE void
-snip (abfd)
- bfd *abfd;
-{
- abfd->lru_prev->lru_next = abfd->lru_next;
- abfd->lru_next->lru_prev = abfd->lru_prev;
- if (abfd == bfd_last_cache)
- {
- bfd_last_cache = abfd->lru_next;
- if (abfd == bfd_last_cache)
- bfd_last_cache = NULL;
- }
-}
-
-/* We need to open a new file, and the cache is full. Find the least
- recently used cacheable BFD and close it. */
-
-static boolean
-close_one ()
-{
- register bfd *kill;
-
- if (bfd_last_cache == NULL)
- kill = NULL;
- else
- {
- for (kill = bfd_last_cache->lru_prev;
- ! kill->cacheable;
- kill = kill->lru_prev)
- {
- if (kill == bfd_last_cache)
- {
- kill = NULL;
- break;
- }
- }
- }
-
- if (kill == NULL)
- {
- /* There are no open cacheable BFD's. */
- return true;
- }
-
- kill->where = ftell ((FILE *) kill->iostream);
-
- return bfd_cache_delete (kill);
-}
-
-/* Close a BFD and remove it from the cache. */
-
-static boolean
-bfd_cache_delete (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- if (fclose ((FILE *) abfd->iostream) == 0)
- ret = true;
- else
- {
- ret = false;
- bfd_set_error (bfd_error_system_call);
- }
-
- snip (abfd);
-
- abfd->iostream = NULL;
- --open_files;
-
- return ret;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_init
-
-SYNOPSIS
- boolean bfd_cache_init (bfd *abfd);
-
-DESCRIPTION
- Add a newly opened BFD to the cache.
-*/
-
-boolean
-bfd_cache_init (abfd)
- bfd *abfd;
-{
- BFD_ASSERT (abfd->iostream != NULL);
- if (open_files >= BFD_CACHE_MAX_OPEN)
- {
- if (! close_one ())
- return false;
- }
- insert (abfd);
- ++open_files;
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_close
-
-SYNOPSIS
- boolean bfd_cache_close (bfd *abfd);
-
-DESCRIPTION
- Remove the BFD @var{abfd} from the cache. If the attached file is open,
- then close it too.
-
-RETURNS
- <<false>> is returned if closing the file fails, <<true>> is
- returned if all is well.
-*/
-
-boolean
-bfd_cache_close (abfd)
- bfd *abfd;
-{
- if (abfd->iostream == NULL
- || (abfd->flags & BFD_IN_MEMORY) != 0)
- return true;
-
- return bfd_cache_delete (abfd);
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_open_file
-
-SYNOPSIS
- FILE* bfd_open_file(bfd *abfd);
-
-DESCRIPTION
- Call the OS to open a file for @var{abfd}. Return the <<FILE *>>
- (possibly <<NULL>>) that results from this operation. Set up the
- BFD so that future accesses know the file is open. If the <<FILE *>>
- returned is <<NULL>>, then it won't have been put in the
- cache, so it won't have to be removed from it.
-*/
-
-FILE *
-bfd_open_file (abfd)
- bfd *abfd;
-{
- abfd->cacheable = true; /* Allow it to be closed later. */
-
- if (open_files >= BFD_CACHE_MAX_OPEN)
- {
- if (! close_one ())
- return NULL;
- }
-
- switch (abfd->direction)
- {
- case read_direction:
- case no_direction:
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
- break;
- case both_direction:
- case write_direction:
- if (abfd->opened_once == true)
- {
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
- if (abfd->iostream == NULL)
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
- }
- else
- {
- /*open for creat */
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WB);
- abfd->opened_once = true;
- }
- break;
- }
-
- if (abfd->iostream != NULL)
- {
- if (! bfd_cache_init (abfd))
- return NULL;
- }
-
- return (FILE *) abfd->iostream;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_cache_lookup_worker
-
-SYNOPSIS
- FILE *bfd_cache_lookup_worker(bfd *abfd);
-
-DESCRIPTION
- Called when the macro <<bfd_cache_lookup>> fails to find a
- quick answer. Find a file descriptor for @var{abfd}. If
- necessary, it open it. If there are already more than
- <<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
- avoid running out of file descriptors.
-*/
-
-FILE *
-bfd_cache_lookup_worker (abfd)
- bfd *abfd;
-{
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- if (abfd->my_archive)
- abfd = abfd->my_archive;
-
- if (abfd->iostream != NULL)
- {
- /* Move the file to the start of the cache. */
- if (abfd != bfd_last_cache)
- {
- snip (abfd);
- insert (abfd);
- }
- }
- else
- {
- if (bfd_open_file (abfd) == NULL)
- return NULL;
- if (fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
- return NULL;
- }
-
- return (FILE *) abfd->iostream;
-}
diff --git a/contrib/gdb/bfd/coff-i386.c b/contrib/gdb/bfd/coff-i386.c
deleted file mode 100644
index d905b53..0000000
--- a/contrib/gdb/bfd/coff-i386.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/* BFD back-end for Intel 386 COFF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-#include "coff/i386.h"
-
-#include "coff/internal.h"
-
-#ifdef COFF_WITH_PE
-#include "coff/pe.h"
-#endif
-
-#include "libcoff.h"
-
-static bfd_reloc_status_type coff_i386_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_i386_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
-
- bfd_vma *));
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-/* The page size is a guess based on ELF. */
-
-#define COFF_PAGE_SIZE 0x1000
-
-/* For some reason when using i386 COFF the value stored in the .text
- section for a reference to a common symbol is the value itself plus
- any desired offset. Ian Taylor, Cygnus Support. */
-
-/* If we are producing relocateable output, we need to do some
- adjustments to the object file that are not done by the
- bfd_perform_relocation function. This function is called by every
- reloc type to make any required adjustments. */
-
-static bfd_reloc_status_type
-coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- symvalue diff;
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
-
- if (bfd_is_com_section (symbol->section))
- {
- /* We are relocating a common symbol. The current value in the
- object file is ORIG + OFFSET, where ORIG is the value of the
- common symbol as seen by the object file when it was compiled
- (this may be zero if the symbol was undefined) and OFFSET is
- the offset into the common symbol (normally zero, but may be
- non-zero when referring to a field in a common structure).
- ORIG is the negative of reloc_entry->addend, which is set by
- the CALC_ADDEND macro below. We want to replace the value in
- the object file with NEW + OFFSET, where NEW is the value of
- the common symbol which we are going to put in the final
- object file. NEW is symbol->value. */
- diff = symbol->value + reloc_entry->addend;
- }
- else
- {
- /* For some reason bfd_perform_relocation always effectively
- ignores the addend for a COFF target when producing
- relocateable output. This seems to be always wrong for 386
- COFF, so we handle the addend here instead. */
- diff = reloc_entry->addend;
- }
-
-
-#ifdef COFF_WITH_PE
- if (reloc_entry->howto->type == 7)
- {
-/* diff -= coff_data(output_bfd)->link_info->pe_info.image_base.value;*/
- exit(1);
- }
-#endif
-
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
-
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
- }
- break;
-
- default:
- abort ();
- }
- }
-
- /* Now let bfd_perform_relocation finish everything up. */
- return bfd_reloc_continue;
-}
-
-#ifdef COFF_WITH_PE
-/* Return true if this relocation should
- appear in the output .reloc section. */
-
-static boolean in_reloc_p(abfd, howto)
- bfd * abfd;
- reloc_howto_type *howto;
-{
- return ! howto->pc_relative && howto->type != R_IMAGEBASE;
-}
-#endif
-
-#ifndef PCRELOFFSET
-#define PCRELOFFSET false
-#endif
-
-static reloc_howto_type howto_table[] =
-{
- {0},
- {1},
- {2},
- {3},
- {4},
- {5},
- HOWTO (R_DIR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "dir32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
- /* {7}, */
- HOWTO (R_IMAGEBASE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "rva32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
- {010},
- {011},
- {012},
- {013},
- {014},
- {015},
- {016},
- HOWTO (R_RELBYTE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "8", /* name */
- true, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_RELWORD, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_RELLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRBYTE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "DISP8", /* name */
- true, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRWORD, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "DISP16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i386_reloc, /* special_function */
- "DISP32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- PCRELOFFSET) /* pcrel_offset */
-};
-
-/* Turn a howto into a reloc nunmber */
-
-#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
-#define BADMAG(x) I386BADMAG(x)
-#define I386 1 /* Customize coffcode.h */
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
-
-/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
- library. On some other COFF targets STYP_BSS is normally
- STYP_NOLOAD. */
-#define BSS_NOLOAD_IS_SHARED_LIBRARY
-
-/* Compute the addend of a reloc. If the reloc is to a common symbol,
- the object file contains the value of the common symbol. By the
- time this is called, the linker may be using a different symbol
- from a different object file with a different value. Therefore, we
- hack wildly to locate the original symbol from this file so that we
- can make the correct adjustment. This macro sets coffsym to the
- symbol from the original file, and uses it to set the addend value
- correctly. If this is not a common symbol, the usual addend
- calculation is done, except that an additional tweak is needed for
- PC relative relocs.
- FIXME: This macro refers to symbols and asect; these are from the
- calling function, not the macro arguments. */
-
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = - coffsym->native->u.syment.n_value; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if (ptr && howto_table[reloc.r_type].pc_relative) \
- cache_ptr->addend += asect->vma; \
- }
-
-/* We use the special COFF backend linker. */
-#define coff_relocate_section _bfd_coff_generic_relocate_section
-
-static reloc_howto_type *
-coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
-
- reloc_howto_type *howto;
-
- howto = howto_table + rel->r_type;
-
-#ifdef COFF_WITH_PE
- *addendp = 0;
-#endif
-
- if (howto->pc_relative)
- *addendp += sec->vma;
-
- if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
- {
- /* This is a common symbol. The section contents include the
- size (sym->n_value) as an addend. The relocate_section
- function will be adding in the final value of the symbol. We
- need to subtract out the current size in order to get the
- correct result. */
-
- BFD_ASSERT (h != NULL);
-
-
-#ifndef COFF_WITH_PE
- /* I think we *do* want to bypass this. If we don't, I have seen some data
- parameters get the wrong relcation address. If I link two versions
- with and without this section bypassed and then do a binary comparison,
- the addresses which are different can be looked up in the map. The
- case in which this section has been bypassed has addresses which correspond
- to values I can find in the map */
- *addendp -= sym->n_value;
-#endif
- }
-
- /* If the output symbol is common (in which case this must be a
- relocateable link), we need to add in the final size of the
- common symbol. */
- if (h != NULL && h->root.type == bfd_link_hash_common)
- *addendp += h->root.u.c.size;
-
-
-#ifdef COFF_WITH_PE
- if (howto->pc_relative)
- *addendp -= 4;
-
- if (rel->r_type == R_IMAGEBASE)
- {
- *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
- }
-#endif
-
- return howto;
-}
-
-
-#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
-
-
-static reloc_howto_type *
-coff_i386_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_RVA:
- return howto_table +R_IMAGEBASE;
- case BFD_RELOC_32:
- return howto_table + R_DIR32;
- case BFD_RELOC_32_PCREL:
- return howto_table + R_PCRLONG;
- default:
- BFD_FAIL ();
- return 0;
- }
-}
-
-
-
-#define coff_rtype_to_howto coff_i386_rtype_to_howto
-
-#include "coffcode.h"
-
-static const bfd_target *
-i3coff_object_p(a)
- bfd *a;
-{
- return coff_object_p(a);
-}
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- i386coff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "coff-i386", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-#ifdef TARGET_UNDERSCORE
- TARGET_UNDERSCORE, /* leading underscore */
-#else
- 0, /* leading underscore */
-#endif
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
-/* Note that we allow an object file to be treated as a core file as well. */
- {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, i3coff_object_p},
- {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
- bfd_false},
- {bfd_false, coff_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coffcode.h b/contrib/gdb/bfd/coffcode.h
deleted file mode 100644
index 22babd0..0000000
--- a/contrib/gdb/bfd/coffcode.h
+++ /dev/null
@@ -1,3612 +0,0 @@
-/* Support for the generic parts of most COFF variants, for BFD.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-Most of this hacked by Steve Chamberlain,
- sac@cygnus.com
-*/
-/*
-
-SECTION
- coff backends
-
- BFD supports a number of different flavours of coff format.
- The major differences between formats are the sizes and
- alignments of fields in structures on disk, and the occasional
- extra field.
-
- Coff in all its varieties is implemented with a few common
- files and a number of implementation specific files. For
- example, The 88k bcs coff format is implemented in the file
- @file{coff-m88k.c}. This file @code{#include}s
- @file{coff/m88k.h} which defines the external structure of the
- coff format for the 88k, and @file{coff/internal.h} which
- defines the internal structure. @file{coff-m88k.c} also
- defines the relocations used by the 88k format
- @xref{Relocations}.
-
- The Intel i960 processor version of coff is implemented in
- @file{coff-i960.c}. This file has the same structure as
- @file{coff-m88k.c}, except that it includes @file{coff/i960.h}
- rather than @file{coff-m88k.h}.
-
-SUBSECTION
- Porting to a new version of coff
-
- The recommended method is to select from the existing
- implementations the version of coff which is most like the one
- you want to use. For example, we'll say that i386 coff is
- the one you select, and that your coff flavour is called foo.
- Copy @file{i386coff.c} to @file{foocoff.c}, copy
- @file{../include/coff/i386.h} to @file{../include/coff/foo.h},
- and add the lines to @file{targets.c} and @file{Makefile.in}
- so that your new back end is used. Alter the shapes of the
- structures in @file{../include/coff/foo.h} so that they match
- what you need. You will probably also have to add
- @code{#ifdef}s to the code in @file{coff/internal.h} and
- @file{coffcode.h} if your version of coff is too wild.
-
- You can verify that your new BFD backend works quite simply by
- building @file{objdump} from the @file{binutils} directory,
- and making sure that its version of what's going on and your
- host system's idea (assuming it has the pretty standard coff
- dump utility, usually called @code{att-dump} or just
- @code{dump}) are the same. Then clean up your code, and send
- what you've done to Cygnus. Then your stuff will be in the
- next release, and you won't have to keep integrating it.
-
-SUBSECTION
- How the coff backend works
-
-SUBSUBSECTION
- File layout
-
- The Coff backend is split into generic routines that are
- applicable to any Coff target and routines that are specific
- to a particular target. The target-specific routines are
- further split into ones which are basically the same for all
- Coff targets except that they use the external symbol format
- or use different values for certain constants.
-
- The generic routines are in @file{coffgen.c}. These routines
- work for any Coff target. They use some hooks into the target
- specific code; the hooks are in a @code{bfd_coff_backend_data}
- structure, one of which exists for each target.
-
- The essentially similar target-specific routines are in
- @file{coffcode.h}. This header file includes executable C code.
- The various Coff targets first include the appropriate Coff
- header file, make any special defines that are needed, and
- then include @file{coffcode.h}.
-
- Some of the Coff targets then also have additional routines in
- the target source file itself.
-
- For example, @file{coff-i960.c} includes
- @file{coff/internal.h} and @file{coff/i960.h}. It then
- defines a few constants, such as @code{I960}, and includes
- @file{coffcode.h}. Since the i960 has complex relocation
- types, @file{coff-i960.c} also includes some code to
- manipulate the i960 relocs. This code is not in
- @file{coffcode.h} because it would not be used by any other
- target.
-
-SUBSUBSECTION
- Bit twiddling
-
- Each flavour of coff supported in BFD has its own header file
- describing the external layout of the structures. There is also
- an internal description of the coff layout, in
- @file{coff/internal.h}. A major function of the
- coff backend is swapping the bytes and twiddling the bits to
- translate the external form of the structures into the normal
- internal form. This is all performed in the
- @code{bfd_swap}_@i{thing}_@i{direction} routines. Some
- elements are different sizes between different versions of
- coff; it is the duty of the coff version specific include file
- to override the definitions of various packing routines in
- @file{coffcode.h}. E.g., the size of line number entry in coff is
- sometimes 16 bits, and sometimes 32 bits. @code{#define}ing
- @code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the
- correct one. No doubt, some day someone will find a version of
- coff which has a varying field size not catered to at the
- moment. To port BFD, that person will have to add more @code{#defines}.
- Three of the bit twiddling routines are exported to
- @code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in}
- and @code{coff_swap_linno_in}. @code{GDB} reads the symbol
- table on its own, but uses BFD to fix things up. More of the
- bit twiddlers are exported for @code{gas};
- @code{coff_swap_aux_out}, @code{coff_swap_sym_out},
- @code{coff_swap_lineno_out}, @code{coff_swap_reloc_out},
- @code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out},
- @code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track
- of all the symbol table and reloc drudgery itself, thereby
- saving the internal BFD overhead, but uses BFD to swap things
- on the way out, making cross ports much safer. Doing so also
- allows BFD (and thus the linker) to use the same header files
- as @code{gas}, which makes one avenue to disaster disappear.
-
-SUBSUBSECTION
- Symbol reading
-
- The simple canonical form for symbols used by BFD is not rich
- enough to keep all the information available in a coff symbol
- table. The back end gets around this problem by keeping the original
- symbol table around, "behind the scenes".
-
- When a symbol table is requested (through a call to
- @code{bfd_canonicalize_symtab}), a request gets through to
- @code{coff_get_normalized_symtab}. This reads the symbol table from
- the coff file and swaps all the structures inside into the
- internal form. It also fixes up all the pointers in the table
- (represented in the file by offsets from the first symbol in
- the table) into physical pointers to elements in the new
- internal table. This involves some work since the meanings of
- fields change depending upon context: a field that is a
- pointer to another structure in the symbol table at one moment
- may be the size in bytes of a structure at the next. Another
- pass is made over the table. All symbols which mark file names
- (<<C_FILE>> symbols) are modified so that the internal
- string points to the value in the auxent (the real filename)
- rather than the normal text associated with the symbol
- (@code{".file"}).
-
- At this time the symbol names are moved around. Coff stores
- all symbols less than nine characters long physically
- within the symbol table; longer strings are kept at the end of
- the file in the string table. This pass moves all strings
- into memory and replaces them with pointers to the strings.
-
-
- The symbol table is massaged once again, this time to create
- the canonical table used by the BFD application. Each symbol
- is inspected in turn, and a decision made (using the
- @code{sclass} field) about the various flags to set in the
- @code{asymbol}. @xref{Symbols}. The generated canonical table
- shares strings with the hidden internal symbol table.
-
- Any linenumbers are read from the coff file too, and attached
- to the symbols which own the functions the linenumbers belong to.
-
-SUBSUBSECTION
- Symbol writing
-
- Writing a symbol to a coff file which didn't come from a coff
- file will lose any debugging information. The @code{asymbol}
- structure remembers the BFD from which the symbol was taken, and on
- output the back end makes sure that the same destination target as
- source target is present.
-
- When the symbols have come from a coff file then all the
- debugging information is preserved.
-
- Symbol tables are provided for writing to the back end in a
- vector of pointers to pointers. This allows applications like
- the linker to accumulate and output large symbol tables
- without having to do too much byte copying.
-
- This function runs through the provided symbol table and
- patches each symbol marked as a file place holder
- (@code{C_FILE}) to point to the next file place holder in the
- list. It also marks each @code{offset} field in the list with
- the offset from the first symbol of the current symbol.
-
- Another function of this procedure is to turn the canonical
- value form of BFD into the form used by coff. Internally, BFD
- expects symbol values to be offsets from a section base; so a
- symbol physically at 0x120, but in a section starting at
- 0x100, would have the value 0x20. Coff expects symbols to
- contain their final value, so symbols have their values
- changed at this point to reflect their sum with their owning
- section. This transformation uses the
- <<output_section>> field of the @code{asymbol}'s
- @code{asection} @xref{Sections}.
-
- o <<coff_mangle_symbols>>
-
- This routine runs though the provided symbol table and uses
- the offsets generated by the previous pass and the pointers
- generated when the symbol table was read in to create the
- structured hierachy required by coff. It changes each pointer
- to a symbol into the index into the symbol table of the asymbol.
-
- o <<coff_write_symbols>>
-
- This routine runs through the symbol table and patches up the
- symbols from their internal form into the coff way, calls the
- bit twiddlers, and writes out the table to the file.
-
-*/
-
-/*
-INTERNAL_DEFINITION
- coff_symbol_type
-
-DESCRIPTION
- The hidden information for an <<asymbol>> is described in a
- <<combined_entry_type>>:
-
-CODE_FRAGMENT
-.
-.typedef struct coff_ptr_struct
-.{
-.
-. {* Remembers the offset from the first symbol in the file for
-. this symbol. Generated by coff_renumber_symbols. *}
-.unsigned int offset;
-.
-. {* Should the value of this symbol be renumbered. Used for
-. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. *}
-.unsigned int fix_value : 1;
-.
-. {* Should the tag field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_tag : 1;
-.
-. {* Should the endidx field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_end : 1;
-.
-. {* Should the x_csect.x_scnlen field be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_scnlen : 1;
-.
-. {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
-. index into the line number entries. Set by
-. coff_slurp_symbol_table. *}
-.unsigned int fix_line : 1;
-.
-. {* The container for the symbol structure as read and translated
-. from the file. *}
-.
-.union {
-. union internal_auxent auxent;
-. struct internal_syment syment;
-. } u;
-.} combined_entry_type;
-.
-.
-.{* Each canonical asymbol really looks like this: *}
-.
-.typedef struct coff_symbol_struct
-.{
-. {* The actual symbol which the rest of BFD works with *}
-.asymbol symbol;
-.
-. {* A pointer to the hidden information for this symbol *}
-.combined_entry_type *native;
-.
-. {* A pointer to the linenumber information for this symbol *}
-.struct lineno_cache_entry *lineno;
-.
-. {* Have the line numbers been relocated yet ? *}
-.boolean done_lineno;
-.} coff_symbol_type;
-
-
-*/
-
-#ifdef COFF_WITH_PE
-#include "peicode.h"
-#else
-#include "coffswap.h"
-#endif
-
-
-/* void warning(); */
-
-/*
- * Return a word with STYP_* (scnhdr.s_flags) flags set to represent the
- * incoming SEC_* flags. The inverse of this function is styp_to_sec_flags().
- * NOTE: If you add to/change this routine, you should mirror the changes
- * in styp_to_sec_flags().
- */
-static long
-sec_to_styp_flags (sec_name, sec_flags)
- CONST char *sec_name;
- flagword sec_flags;
-{
- long styp_flags = 0;
-
- if (!strcmp (sec_name, _TEXT))
- {
- styp_flags = STYP_TEXT;
- }
- else if (!strcmp (sec_name, _DATA))
- {
- styp_flags = STYP_DATA;
- }
- else if (!strcmp (sec_name, _BSS))
- {
- styp_flags = STYP_BSS;
-#ifdef _COMMENT
- }
- else if (!strcmp (sec_name, _COMMENT))
- {
- styp_flags = STYP_INFO;
-#endif /* _COMMENT */
-#ifdef _LIB
- }
- else if (!strcmp (sec_name, _LIB))
- {
- styp_flags = STYP_LIB;
-#endif /* _LIB */
-#ifdef _LIT
- }
- else if (!strcmp (sec_name, _LIT))
- {
- styp_flags = STYP_LIT;
-#endif /* _LIT */
- }
- else if (!strcmp (sec_name, ".debug"))
- {
-#ifdef STYP_DEBUG
- styp_flags = STYP_DEBUG;
-#else
- styp_flags = STYP_INFO;
-#endif
- }
- else if (!strncmp (sec_name, ".stab", 5))
- {
- styp_flags = STYP_INFO;
- }
-#ifdef COFF_WITH_PE
- else if (!strcmp (sec_name, ".edata"))
- {
- styp_flags = STYP_DATA;
- }
-#endif
-#ifdef RS6000COFF_C
- else if (!strcmp (sec_name, _PAD))
- {
- styp_flags = STYP_PAD;
- }
- else if (!strcmp (sec_name, _LOADER))
- {
- styp_flags = STYP_LOADER;
- }
-#endif
- /* Try and figure out what it should be */
- else if (sec_flags & SEC_CODE)
- {
- styp_flags = STYP_TEXT;
- }
- else if (sec_flags & SEC_DATA)
- {
- styp_flags = STYP_DATA;
- }
- else if (sec_flags & SEC_READONLY)
- {
-#ifdef STYP_LIT /* 29k readonly text/data section */
- styp_flags = STYP_LIT;
-#else
- styp_flags = STYP_TEXT;
-#endif /* STYP_LIT */
- }
- else if (sec_flags & SEC_LOAD)
- {
- styp_flags = STYP_TEXT;
- }
- else if (sec_flags & SEC_ALLOC)
- {
- styp_flags = STYP_BSS;
- }
-
-#ifdef STYP_NOLOAD
- if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
- styp_flags |= STYP_NOLOAD;
-#endif
-
- return (styp_flags);
-}
-/*
- * Return a word with SEC_* flags set to represent the incoming
- * STYP_* flags (from scnhdr.s_flags). The inverse of this
- * function is sec_to_styp_flags().
- * NOTE: If you add to/change this routine, you should mirror the changes
- * in sec_to_styp_flags().
- */
-static flagword
-styp_to_sec_flags (abfd, hdr, name)
- bfd *abfd;
- PTR hdr;
- const char *name;
-{
- struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
- long styp_flags = internal_s->s_flags;
- flagword sec_flags = 0;
-
-#ifdef STYP_NOLOAD
- if (styp_flags & STYP_NOLOAD)
- {
- sec_flags |= SEC_NEVER_LOAD;
- }
-#endif /* STYP_NOLOAD */
-
- /* For 386 COFF, at least, an unloadable text or data section is
- actually a shared library section. */
- if (styp_flags & STYP_TEXT)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if (styp_flags & STYP_DATA)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- }
- else if (styp_flags & STYP_BSS)
- {
-#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
- else
-#endif
- sec_flags |= SEC_ALLOC;
- }
- else if (styp_flags & STYP_INFO)
- {
- /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
- defined. coff_compute_section_file_positions uses
- COFF_PAGE_SIZE to ensure that the low order bits of the
- section VMA and the file offset match. If we don't know
- COFF_PAGE_SIZE, we can't ensure the correct correspondence,
- and demand page loading of the file will fail. */
-#ifdef COFF_PAGE_SIZE
- sec_flags |= SEC_DEBUGGING;
-#endif
- }
- else if (styp_flags & STYP_PAD)
- {
- sec_flags = 0;
- }
- else if (strcmp (name, _TEXT) == 0)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if (strcmp (name, _DATA) == 0)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- }
- else if (strcmp (name, _BSS) == 0)
- {
-#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
- else
-#endif
- sec_flags |= SEC_ALLOC;
- }
- else if (strcmp (name, ".debug") == 0
-#ifdef _COMMENT
- || strcmp (name, _COMMENT) == 0
-#endif
- || strncmp (name, ".stab", 5) == 0)
- {
-#ifdef COFF_PAGE_SIZE
- sec_flags |= SEC_DEBUGGING;
-#endif
- }
-#ifdef _LIB
- else if (strcmp (name, _LIB) == 0)
- ;
-#endif
-#ifdef _LIT
- else if (strcmp (name, _LIT) == 0)
- {
- sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- }
-#endif
- else
- {
- sec_flags |= SEC_ALLOC | SEC_LOAD;
- }
-
-#ifdef STYP_LIT /* A29k readonly text/data section type */
- if ((styp_flags & STYP_LIT) == STYP_LIT)
- {
- sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
- }
-#endif /* STYP_LIT */
-#ifdef STYP_OTHER_LOAD /* Other loaded sections */
- if (styp_flags & STYP_OTHER_LOAD)
- {
- sec_flags = (SEC_LOAD | SEC_ALLOC);
- }
-#endif /* STYP_SDATA */
-
- return (sec_flags);
-}
-
-#define get_index(symbol) ((symbol)->udata.i)
-
-/*
-INTERNAL_DEFINITION
- bfd_coff_backend_data
-
-CODE_FRAGMENT
-
-Special entry points for gdb to swap in coff symbol table parts:
-.typedef struct
-.{
-. void (*_bfd_coff_swap_aux_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR in));
-.
-. void (*_bfd_coff_swap_sym_in) PARAMS ((
-. bfd *abfd ,
-. PTR ext,
-. PTR in));
-.
-. void (*_bfd_coff_swap_lineno_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-.
-
-Special entry points for gas to swap out coff parts:
-
-. unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
-.
-. unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
-. bfd *abfd,
-. PTR src,
-. PTR dst));
-.
-. unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-. unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-. unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
-.
-
-Special entry points for generic COFF routines to call target
-dependent COFF routines:
-
-. unsigned int _bfd_filhsz;
-. unsigned int _bfd_aoutsz;
-. unsigned int _bfd_scnhsz;
-. unsigned int _bfd_symesz;
-. unsigned int _bfd_auxesz;
-. unsigned int _bfd_relsz;
-. unsigned int _bfd_linesz;
-. boolean _bfd_coff_long_filenames;
-. void (*_bfd_coff_swap_filehdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_reloc_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. boolean (*_bfd_coff_bad_format_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. PTR (*_bfd_coff_mkobject_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr,
-. PTR internal_aouthdr));
-. flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_scnhdr,
-. const char *name));
-. void (*_bfd_set_alignment_hook) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. PTR internal_scnhdr));
-. boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_symname_in_debug) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *sym));
-. boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
-. bfd *abfd,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. unsigned int indaux,
-. combined_entry_type *aux));
-. boolean (*_bfd_coff_print_aux) PARAMS ((
-. bfd *abfd,
-. FILE *file,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. combined_entry_type *aux,
-. unsigned int indaux));
-. void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
-. bfd *abfd,
-. struct bfd_link_info *link_info,
-. struct bfd_link_order *link_order,
-. arelent *reloc,
-. bfd_byte *data,
-. unsigned int *src_ptr,
-. unsigned int *dst_ptr));
-. int (*_bfd_coff_reloc16_estimate) PARAMS ((
-. bfd *abfd,
-. asection *input_section,
-. arelent *r,
-. unsigned int shrink,
-. struct bfd_link_info *link_info));
-. boolean (*_bfd_coff_sym_is_global) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *));
-. void (*_bfd_coff_compute_section_file_positions) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_start_final_link) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info));
-. boolean (*_bfd_coff_relocate_section) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info,
-. bfd *input_bfd,
-. asection *input_section,
-. bfd_byte *contents,
-. struct internal_reloc *relocs,
-. struct internal_syment *syms,
-. asection **sections));
-. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. struct internal_reloc *rel,
-. struct coff_link_hash_entry *h,
-. struct internal_syment *sym,
-. bfd_vma *addendp));
-. boolean (*_bfd_coff_adjust_symndx) PARAMS ((
-. bfd *obfd,
-. struct bfd_link_info *info,
-. bfd *ibfd,
-. asection *sec,
-. struct internal_reloc *reloc,
-. boolean *adjustedp));
-. boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
-. struct bfd_link_info *info,
-. bfd *abfd,
-. const char *name,
-. flagword flags,
-. asection *section,
-. bfd_vma value,
-. const char *string,
-. boolean copy,
-. boolean collect,
-. struct bfd_link_hash_entry **hashp));
-.
-.} bfd_coff_backend_data;
-.
-.#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
-.
-.#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
-.
-.#define bfd_coff_swap_sym_in(a,e,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
-.
-.#define bfd_coff_swap_lineno_in(a,e,i) \
-. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
-.
-.#define bfd_coff_swap_reloc_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_lineno_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
-.
-.#define bfd_coff_swap_sym_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_filehdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
-.
-.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
-.
-.#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
-.#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
-.#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
-.#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
-.#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
-.#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
-.#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
-.#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
-.#define bfd_coff_swap_filehdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
-.
-.#define bfd_coff_swap_reloc_in(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
-.
-.#define bfd_coff_bad_format_hook(abfd, filehdr) \
-. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
-.
-.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
-.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
-.
-.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
-. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
-.
-.#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
-. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
-.
-.#define bfd_coff_slurp_symbol_table(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
-.
-.#define bfd_coff_symname_in_debug(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
-.
-.#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
-. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
-. (abfd, file, base, symbol, aux, indaux))
-.
-.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
-. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
-.
-.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
-. (abfd, section, reloc, shrink, link_info))
-.
-.#define bfd_coff_sym_is_global(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
-. (abfd, sym))
-.
-.#define bfd_coff_compute_section_file_positions(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
-. (abfd))
-.
-.#define bfd_coff_start_final_link(obfd, info)\
-. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
-. (obfd, info))
-.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
-. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
-. (obfd, info, ibfd, o, con, rel, isyms, secs))
-.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
-. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
-. (abfd, sec, rel, h, sym, addendp))
-.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
-. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
-. (obfd, info, ibfd, sec, rel, adjustedp))
-.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
-. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
-. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
-.
-*/
-
-/* See whether the magic number matches. */
-
-static boolean
-coff_bad_format_hook (abfd, filehdr)
- bfd * abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- if (BADMAG (*internal_f))
- return false;
-
- /* if the optional header is NULL or not the correct size then
- quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
- and Intel 960 readwrite headers (I960WRMAGIC) is that the
- optional header is of a different size.
-
- But the mips keeps extra stuff in it's opthdr, so dont check
- when doing that
- */
-
-#if defined(M88) || defined(I960)
- if (internal_f->f_opthdr != 0 && AOUTSZ != internal_f->f_opthdr)
- return false;
-#endif
-
- return true;
-}
-
-/*
- initialize a section structure with information peculiar to this
- particular implementation of coff
-*/
-
-static boolean
-coff_new_section_hook (abfd, section)
- bfd * abfd;
- asection * section;
-{
- section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
-
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->text_align_power != 0
- && strcmp (bfd_get_section_name (abfd, section), ".text") == 0)
- section->alignment_power = xcoff_data (abfd)->text_align_power;
- if (xcoff_data (abfd)->data_align_power != 0
- && strcmp (bfd_get_section_name (abfd, section), ".data") == 0)
- section->alignment_power = xcoff_data (abfd)->data_align_power;
-#endif
-
- /* Allocate aux records for section symbols, to store size and
- related info.
-
- @@ Shouldn't use constant multiplier here! */
- coffsymbol (section->symbol)->native =
- (combined_entry_type *) bfd_zalloc (abfd,
- sizeof (combined_entry_type) * 10);
-
- /* The .stab section must be aligned to 2**2 at most, because
- otherwise there may be gaps in the section which gdb will not
- know how to interpret. Examining the section name is a hack, but
- that is also how gdb locates the section.
- We need to handle the .ctors and .dtors sections similarly, to
- avoid introducing null words in the tables. */
- if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2
- && (strncmp (section->name, ".stab", 5) == 0
- || strcmp (section->name, ".ctors") == 0
- || strcmp (section->name, ".dtors") == 0))
- section->alignment_power = 2;
-
- /* Similarly, the .stabstr section must be aligned to 2**0 at most. */
- if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 0
- && strncmp (section->name, ".stabstr", 8) == 0)
- section->alignment_power = 0;
-
- return true;
-}
-
-#ifdef I960
-
-/* Set the alignment of a BFD section. */
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd * abfd;
- asection * section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
- unsigned int i;
-
- for (i = 0; i < 32; i++)
- if ((1 << i) >= hdr->s_align)
- break;
- section->alignment_power = i;
-}
-
-#else /* ! I960 */
-#ifdef COFF_WITH_PE
-
-/* a couple of macros to help setting the alignment power field */
-#define ALIGN_SET(field,x,y) \
- if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
- {\
- section->alignment_power = y;\
- }
-
-#define ELIFALIGN_SET(field,x,y) \
- else if (( (field) & IMAGE_SCN_ALIGN_64BYTES) == x ) \
- {\
- section->alignment_power = y;\
- }
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd * abfd;
- asection * section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
-
- ALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_16BYTES, 4)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_8BYTES, 3)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_4BYTES, 2)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_2BYTES, 1)
- ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_1BYTES, 0)
-
-#ifdef POWERPC_LE_PE
- if (strcmp (section->name, ".idata$2") == 0)
- {
- section->alignment_power = 0;
- }
- else if (strcmp (section->name, ".idata$3") == 0)
- {
- section->alignment_power = 0;
- }
- else if (strcmp (section->name, ".idata$4") == 0)
- {
- section->alignment_power = 2;
- }
- else if (strcmp (section->name, ".idata$5") == 0)
- {
- section->alignment_power = 2;
- }
- else if (strcmp (section->name, ".idata$6") == 0)
- {
- section->alignment_power = 1;
- }
- else if (strcmp (section->name, ".reloc") == 0)
- {
- section->alignment_power = 1;
- }
- else if (strncmp (section->name, ".stab", 5) == 0)
- {
- section->alignment_power = 2;
- }
-#endif
-}
-#undef ALIGN_SET
-#undef ELIFALIGN_SET
-
-#else /* ! COFF_WITH_PE */
-#ifdef RS6000COFF_C
-
-/* We grossly abuse this function to handle XCOFF overflow headers.
- When we see one, we correct the reloc and line number counts in the
- real header, and remove the section we just created. */
-
-static void
-coff_set_alignment_hook (abfd, section, scnhdr)
- bfd *abfd;
- asection *section;
- PTR scnhdr;
-{
- struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
- asection *real_sec;
- asection **ps;
-
- if ((hdr->s_flags & STYP_OVRFLO) == 0)
- return;
-
- real_sec = coff_section_from_bfd_index (abfd, hdr->s_nreloc);
- if (real_sec == NULL)
- return;
-
- real_sec->reloc_count = hdr->s_paddr;
- real_sec->lineno_count = hdr->s_vaddr;
-
- for (ps = &abfd->sections; *ps != NULL; ps = &(*ps)->next)
- {
- if (*ps == section)
- {
- *ps = (*ps)->next;
- --abfd->section_count;
- break;
- }
- }
-}
-
-#else /* ! RS6000COFF_C */
-
-#define coff_set_alignment_hook \
- ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
-
-#endif /* ! RS6000COFF_C */
-#endif /* ! COFF_WITH_PE */
-#endif /* ! I960 */
-
-#ifndef coff_mkobject
-static boolean
-coff_mkobject (abfd)
- bfd * abfd;
-{
- coff_data_type *coff;
-
- abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
- if (abfd->tdata.coff_obj_data == 0)
- return false;
- coff = coff_data (abfd);
- coff->symbols = (coff_symbol_type *) NULL;
- coff->conversion_table = (unsigned int *) NULL;
- coff->raw_syments = (struct coff_ptr_struct *) NULL;
- coff->relocbase = 0;
- coff->local_toc_sym_map = 0;
-
-/* make_abs_section(abfd);*/
-
- return true;
-}
-#endif
-
-/* Create the COFF backend specific information. */
-#ifndef coff_mkobject_hook
-static PTR
-coff_mkobject_hook (abfd, filehdr, aouthdr)
- bfd * abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- coff_data_type *coff;
-
- if (coff_mkobject (abfd) == false)
- return NULL;
-
- coff = coff_data (abfd);
-
- coff->sym_filepos = internal_f->f_symptr;
-
- /* These members communicate important constants about the symbol
- table to GDB's symbol-reading code. These `constants'
- unfortunately vary among coff implementations... */
- coff->local_n_btmask = N_BTMASK;
- coff->local_n_btshft = N_BTSHFT;
- coff->local_n_tmask = N_TMASK;
- coff->local_n_tshift = N_TSHIFT;
- coff->local_symesz = SYMESZ;
- coff->local_auxesz = AUXESZ;
- coff->local_linesz = LINESZ;
-
- obj_raw_syment_count (abfd) =
- obj_conv_table_size (abfd) =
- internal_f->f_nsyms;
-
-#ifdef RS6000COFF_C
- if ((internal_f->f_flags & F_SHROBJ) != 0)
- abfd->flags |= DYNAMIC;
- if (aouthdr != NULL && internal_f->f_opthdr >= AOUTSZ)
- {
- struct internal_aouthdr *internal_a =
- (struct internal_aouthdr *) aouthdr;
- struct xcoff_tdata *xcoff;
-
- xcoff = xcoff_data (abfd);
- xcoff->full_aouthdr = true;
- xcoff->toc = internal_a->o_toc;
- xcoff->sntoc = internal_a->o_sntoc;
- xcoff->snentry = internal_a->o_snentry;
- xcoff->text_align_power = internal_a->o_algntext;
- xcoff->data_align_power = internal_a->o_algndata;
- xcoff->modtype = internal_a->o_modtype;
- xcoff->cputype = internal_a->o_cputype;
- xcoff->maxdata = internal_a->o_maxdata;
- xcoff->maxstack = internal_a->o_maxstack;
- }
-#endif
-
- return (PTR) coff;
-}
-#endif
-
-/* Determine the machine architecture and type. FIXME: This is target
- dependent because the magic numbers are defined in the target
- dependent header files. But there is no particular need for this.
- If the magic numbers were moved to a separate file, this function
- would be target independent and would also be much more successful
- at linking together COFF files for different architectures. */
-
-static boolean
-coff_set_arch_mach_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- long machine;
- enum bfd_architecture arch;
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- machine = 0;
- switch (internal_f->f_magic)
- {
-#ifdef PPCMAGIC
- case PPCMAGIC:
- arch = bfd_arch_powerpc;
- machine = 0; /* what does this mean? (krk) */
- break;
-#endif
-#ifdef I386MAGIC
- case I386MAGIC:
- case I386PTXMAGIC:
- case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler */
- case LYNXCOFFMAGIC: /* shadows the m68k Lynx number below, sigh */
- arch = bfd_arch_i386;
- machine = 0;
- break;
-#endif
-#ifdef A29K_MAGIC_BIG
- case A29K_MAGIC_BIG:
- case A29K_MAGIC_LITTLE:
- arch = bfd_arch_a29k;
- machine = 0;
- break;
-#endif
-#ifdef ARMMAGIC
- case ARMMAGIC:
- arch = bfd_arch_arm;
- machine =0;
- break;
-#endif
-#ifdef MC68MAGIC
- case MC68MAGIC:
- case M68MAGIC:
-#ifdef MC68KBCSMAGIC
- case MC68KBCSMAGIC:
-#endif
-#ifdef APOLLOM68KMAGIC
- case APOLLOM68KMAGIC:
-#endif
-#ifdef LYNXCOFFMAGIC
- case LYNXCOFFMAGIC:
-#endif
- arch = bfd_arch_m68k;
- machine = 68020;
- break;
-#endif
-#ifdef MC88MAGIC
- case MC88MAGIC:
- case MC88DMAGIC:
- case MC88OMAGIC:
- arch = bfd_arch_m88k;
- machine = 88100;
- break;
-#endif
-#ifdef Z8KMAGIC
- case Z8KMAGIC:
- arch = bfd_arch_z8k;
- switch (internal_f->f_flags & F_MACHMASK)
- {
- case F_Z8001:
- machine = bfd_mach_z8001;
- break;
- case F_Z8002:
- machine = bfd_mach_z8002;
- break;
- default:
- return false;
- }
- break;
-#endif
-#ifdef I860
- case I860MAGIC:
- arch = bfd_arch_i860;
- break;
-#endif
-#ifdef I960
-#ifdef I960ROMAGIC
- case I960ROMAGIC:
- case I960RWMAGIC:
- arch = bfd_arch_i960;
- switch (F_I960TYPE & internal_f->f_flags)
- {
- default:
- case F_I960CORE:
- machine = bfd_mach_i960_core;
- break;
- case F_I960KB:
- machine = bfd_mach_i960_kb_sb;
- break;
- case F_I960MC:
- machine = bfd_mach_i960_mc;
- break;
- case F_I960XA:
- machine = bfd_mach_i960_xa;
- break;
- case F_I960CA:
- machine = bfd_mach_i960_ca;
- break;
- case F_I960KA:
- machine = bfd_mach_i960_ka_sa;
- break;
- case F_I960JX:
- machine = bfd_mach_i960_jx;
- break;
- case F_I960HX:
- machine = bfd_mach_i960_hx;
- break;
- }
- break;
-#endif
-#endif
-
-#ifdef RS6000COFF_C
- case U802ROMAGIC:
- case U802WRMAGIC:
- case U802TOCMAGIC:
- {
- int cputype;
-
- if (xcoff_data (abfd)->cputype != -1)
- cputype = xcoff_data (abfd)->cputype & 0xff;
- else
- {
- /* We did not get a value from the a.out header. If the
- file has not been stripped, we may be able to get the
- architecture information from the first symbol, if it
- is a .file symbol. */
- if (obj_raw_syment_count (abfd) == 0)
- cputype = 0;
- else
- {
- bfd_byte buf[SYMESZ];
- struct internal_syment sym;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read (buf, 1, SYMESZ, abfd) != SYMESZ)
- return false;
- coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
- if (sym.n_sclass == C_FILE)
- cputype = sym.n_type & 0xff;
- else
- cputype = 0;
- }
- }
-
- /* FIXME: We don't handle all cases here. */
- switch (cputype)
- {
- default:
- case 0:
-#ifdef POWERMAC
- /* PowerPC Macs use the same magic numbers as RS/6000
- (because that's how they were bootstrapped originally),
- but they are always PowerPC architecture. */
- arch = bfd_arch_powerpc;
- machine = 0;
-#else
- arch = bfd_arch_rs6000;
- machine = 6000;
-#endif /* POWERMAC */
- break;
-
- case 1:
- arch = bfd_arch_powerpc;
- machine = 601;
- break;
- case 2: /* 64 bit PowerPC */
- arch = bfd_arch_powerpc;
- machine = 620;
- break;
- case 3:
- arch = bfd_arch_powerpc;
- machine = 0;
- break;
- case 4:
- arch = bfd_arch_rs6000;
- machine = 6000;
- break;
- }
- }
- break;
-#endif
-
-#ifdef WE32KMAGIC
- case WE32KMAGIC:
- arch = bfd_arch_we32k;
- machine = 0;
- break;
-#endif
-
-#ifdef H8300MAGIC
- case H8300MAGIC:
- arch = bfd_arch_h8300;
- machine = bfd_mach_h8300;
- /* !! FIXME this probably isn't the right place for this */
- abfd->flags |= BFD_IS_RELAXABLE;
- break;
-#endif
-
-#ifdef H8300HMAGIC
- case H8300HMAGIC:
- arch = bfd_arch_h8300;
- machine = bfd_mach_h8300h;
- /* !! FIXME this probably isn't the right place for this */
- abfd->flags |= BFD_IS_RELAXABLE;
- break;
-#endif
-
-#ifdef SH_ARCH_MAGIC_BIG
- case SH_ARCH_MAGIC_BIG:
- case SH_ARCH_MAGIC_LITTLE:
- arch = bfd_arch_sh;
- machine = 0;
- break;
-#endif
-
-#ifdef H8500MAGIC
- case H8500MAGIC:
- arch = bfd_arch_h8500;
- machine = 0;
- break;
-#endif
-
-#ifdef SPARCMAGIC
- case SPARCMAGIC:
-#ifdef LYNXCOFFMAGIC
- case LYNXCOFFMAGIC:
-#endif
- arch = bfd_arch_sparc;
- machine = 0;
- break;
-#endif
-
- default: /* Unreadable input file type */
- arch = bfd_arch_obscure;
- break;
- }
-
- bfd_default_set_arch_mach (abfd, arch, machine);
- return true;
-}
-
-#ifdef SYMNAME_IN_DEBUG
-
-static boolean
-symname_in_debug_hook (abfd, sym)
- bfd * abfd;
- struct internal_syment *sym;
-{
- return SYMNAME_IN_DEBUG (sym) ? true : false;
-}
-
-#else
-
-#define symname_in_debug_hook \
- (boolean (*) PARAMS ((bfd *, struct internal_syment *))) bfd_false
-
-#endif
-
-#ifdef RS6000COFF_C
-
-/* Handle the csect auxent of a C_EXT or C_HIDEXT symbol. */
-
-static boolean coff_pointerize_aux_hook
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
-static boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *aux;
-{
- int class = symbol->u.syment.n_sclass;
-
- if ((class == C_EXT || class == C_HIDEXT)
- && indaux + 1 == symbol->u.syment.n_numaux)
- {
- if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD)
- {
- aux->u.auxent.x_csect.x_scnlen.p =
- table_base + aux->u.auxent.x_csect.x_scnlen.l;
- aux->fix_scnlen = 1;
- }
-
- /* Return true to indicate that the caller should not do any
- further work on this auxent. */
- return true;
- }
-
- /* Return false to indicate that this auxent should be handled by
- the caller. */
- return false;
-}
-
-#else
-#ifdef I960
-
-/* We don't want to pointerize bal entries. */
-
-static boolean coff_pointerize_aux_hook
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
-static boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *aux;
-{
- /* Return true if we don't want to pointerize this aux entry, which
- is the case for the lastfirst aux entry for a C_LEAFPROC symbol. */
- return (indaux == 1
- && (symbol->u.syment.n_sclass == C_LEAFPROC
- || symbol->u.syment.n_sclass == C_LEAFSTAT
- || symbol->u.syment.n_sclass == C_LEAFEXT));
-}
-
-#else /* ! I960 */
-
-#define coff_pointerize_aux_hook 0
-
-#endif /* ! I960 */
-#endif /* ! RS6000COFF_C */
-
-/* Print an aux entry. This returns true if it has printed it. */
-
-static boolean coff_print_aux
- PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
- combined_entry_type *, unsigned int));
-
-static boolean
-coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
- bfd *abfd;
- FILE *file;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- combined_entry_type *aux;
- unsigned int indaux;
-{
-#ifdef RS6000COFF_C
- if ((symbol->u.syment.n_sclass == C_EXT
- || symbol->u.syment.n_sclass == C_HIDEXT)
- && indaux + 1 == symbol->u.syment.n_numaux)
- {
- /* This is a csect entry. */
- fprintf (file, "AUX ");
- if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
- {
- BFD_ASSERT (! aux->fix_scnlen);
- fprintf (file, "val %5ld", aux->u.auxent.x_csect.x_scnlen.l);
- }
- else
- {
- fprintf (file, "indx ");
- if (! aux->fix_scnlen)
- fprintf (file, "%4ld", aux->u.auxent.x_csect.x_scnlen.l);
- else
- fprintf (file, "%4ld",
- (long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
- }
- fprintf (file,
- " prmhsh %ld snhsh %u typ %d algn %d clss %u stb %ld snstb %u",
- aux->u.auxent.x_csect.x_parmhash,
- (unsigned int) aux->u.auxent.x_csect.x_snhash,
- SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp),
- SMTYP_ALIGN (aux->u.auxent.x_csect.x_smtyp),
- (unsigned int) aux->u.auxent.x_csect.x_smclas,
- aux->u.auxent.x_csect.x_stab,
- (unsigned int) aux->u.auxent.x_csect.x_snstab);
- return true;
- }
-#endif
-
- /* Return false to indicate that no special action was taken. */
- return false;
-}
-
-/*
-SUBSUBSECTION
- Writing relocations
-
- To write relocations, the back end steps though the
- canonical relocation table and create an
- @code{internal_reloc}. The symbol index to use is removed from
- the @code{offset} field in the symbol table supplied. The
- address comes directly from the sum of the section base
- address and the relocation offset; the type is dug directly
- from the howto field. Then the @code{internal_reloc} is
- swapped into the shape of an @code{external_reloc} and written
- out to disk.
-
-*/
-
-#ifdef TARG_AUX
-
-static int compare_arelent_ptr PARAMS ((const PTR, const PTR));
-
-/* AUX's ld wants relocations to be sorted */
-static int
-compare_arelent_ptr (x, y)
- const PTR x;
- const PTR y;
-{
- const arelent **a = (const arelent **) x;
- const arelent **b = (const arelent **) y;
- bfd_size_type aadr = (*a)->address;
- bfd_size_type badr = (*b)->address;
-
- return (aadr < badr ? -1 : badr < aadr ? 1 : 0);
-}
-
-#endif /* TARG_AUX */
-
-static boolean
-coff_write_relocs (abfd, first_undef)
- bfd * abfd;
- int first_undef;
-{
- asection *s;
-
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- unsigned int i;
- struct external_reloc dst;
- arelent **p;
-
-#ifndef TARG_AUX
- p = s->orelocation;
-#else
- /* sort relocations before we write them out */
- p = (arelent **) bfd_malloc (s->reloc_count * sizeof (arelent *));
- if (p == NULL && s->reloc_count > 0)
- return false;
- memcpy (p, s->orelocation, s->reloc_count * sizeof (arelent *));
- qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
-#endif
-
- if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
- return false;
- for (i = 0; i < s->reloc_count; i++)
- {
- struct internal_reloc n;
- arelent *q = p[i];
- memset ((PTR) & n, 0, sizeof (n));
-
- /* Now we've renumbered the symbols we know where the
- undefined symbols live in the table. Check the reloc
- entries for symbols who's output bfd isn't the right one.
- This is because the symbol was undefined (which means
- that all the pointers are never made to point to the same
- place). This is a bad thing,'cause the symbols attached
- to the output bfd are indexed, so that the relocation
- entries know which symbol index they point to. So we
- have to look up the output symbol here. */
-
- if (q->sym_ptr_ptr[0]->the_bfd != abfd)
- {
- int i;
- const char *sname = q->sym_ptr_ptr[0]->name;
- asymbol **outsyms = abfd->outsymbols;
- for (i = first_undef; outsyms[i]; i++)
- {
- const char *intable = outsyms[i]->name;
- if (strcmp (intable, sname) == 0) {
- /* got a hit, so repoint the reloc */
- q->sym_ptr_ptr = outsyms + i;
- break;
- }
- }
- }
-
- n.r_vaddr = q->address + s->vma;
-
-#ifdef R_IHCONST
- /* The 29k const/consth reloc pair is a real kludge. The consth
- part doesn't have a symbol; it has an offset. So rebuilt
- that here. */
- if (q->howto->type == R_IHCONST)
- n.r_symndx = q->addend;
- else
-#endif
- if (q->sym_ptr_ptr)
- {
- if (q->sym_ptr_ptr == bfd_abs_section_ptr->symbol_ptr_ptr)
- /* This is a relocation relative to the absolute symbol. */
- n.r_symndx = -1;
- else
- {
- n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
- /* Take notice if the symbol reloc points to a symbol
- we don't have in our symbol table. What should we
- do for this?? */
- if (n.r_symndx > obj_conv_table_size (abfd))
- abort ();
- }
- }
-
-#ifdef SWAP_OUT_RELOC_OFFSET
- n.r_offset = q->addend;
-#endif
-
-#ifdef SELECT_RELOC
- /* Work out reloc type from what is required */
- SELECT_RELOC (n, q->howto);
-#else
- n.r_type = q->howto->type;
-#endif
- coff_swap_reloc_out (abfd, &n, &dst);
- if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ)
- return false;
- }
-
-#ifdef TARG_AUX
- if (p != NULL)
- free (p);
-#endif
- }
-
- return true;
-}
-
-/* Set flags and magic number of a coff file from architecture and machine
- type. Result is true if we can represent the arch&type, false if not. */
-
-static boolean
-coff_set_flags (abfd, magicp, flagsp)
- bfd * abfd;
- unsigned *magicp;
- unsigned short *flagsp;
-{
- switch (bfd_get_arch (abfd))
- {
-#ifdef Z8KMAGIC
- case bfd_arch_z8k:
- *magicp = Z8KMAGIC;
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_z8001:
- *flagsp = F_Z8001;
- break;
- case bfd_mach_z8002:
- *flagsp = F_Z8002;
- break;
- default:
- return false;
- }
- return true;
-#endif
-#ifdef I960ROMAGIC
-
- case bfd_arch_i960:
-
- {
- unsigned flags;
- *magicp = I960ROMAGIC;
- /*
- ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC :
- I960RWMAGIC); FIXME???
- */
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_i960_core:
- flags = F_I960CORE;
- break;
- case bfd_mach_i960_kb_sb:
- flags = F_I960KB;
- break;
- case bfd_mach_i960_mc:
- flags = F_I960MC;
- break;
- case bfd_mach_i960_xa:
- flags = F_I960XA;
- break;
- case bfd_mach_i960_ca:
- flags = F_I960CA;
- break;
- case bfd_mach_i960_ka_sa:
- flags = F_I960KA;
- break;
- case bfd_mach_i960_jx:
- flags = F_I960JX;
- break;
- case bfd_mach_i960_hx:
- flags = F_I960HX;
- break;
- default:
- return false;
- }
- *flagsp = flags;
- return true;
- }
- break;
-#endif
-#ifdef ARMMAGIC
- case bfd_arch_arm:
- *magicp = ARMMAGIC;
- return true;
-#endif
-#ifdef PPCMAGIC
- case bfd_arch_powerpc:
- *magicp = PPCMAGIC;
- return true;
- break;
-#endif
-#ifdef I386MAGIC
- case bfd_arch_i386:
- *magicp = I386MAGIC;
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-#ifdef I860MAGIC
- case bfd_arch_i860:
- *magicp = I860MAGIC;
- return true;
- break;
-#endif
-#ifdef MC68MAGIC
- case bfd_arch_m68k:
-#ifdef APOLLOM68KMAGIC
- *magicp = APOLLO_COFF_VERSION_NUMBER;
-#else
- *magicp = MC68MAGIC;
-#endif
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-
-#ifdef MC88MAGIC
- case bfd_arch_m88k:
- *magicp = MC88OMAGIC;
- return true;
- break;
-#endif
-#ifdef H8300MAGIC
- case bfd_arch_h8300:
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_h8300:
- *magicp = H8300MAGIC;
- return true;
- case bfd_mach_h8300h:
- *magicp = H8300HMAGIC;
- return true;
- }
- break;
-#endif
-
-#ifdef SH_ARCH_MAGIC_BIG
- case bfd_arch_sh:
- if (bfd_big_endian (abfd))
- *magicp = SH_ARCH_MAGIC_BIG;
- else
- *magicp = SH_ARCH_MAGIC_LITTLE;
- return true;
- break;
-#endif
-
-#ifdef SPARCMAGIC
- case bfd_arch_sparc:
- *magicp = SPARCMAGIC;
-#ifdef LYNXOS
- /* Just overwrite the usual value if we're doing Lynx. */
- *magicp = LYNXCOFFMAGIC;
-#endif
- return true;
- break;
-#endif
-
-#ifdef H8500MAGIC
- case bfd_arch_h8500:
- *magicp = H8500MAGIC;
- return true;
- break;
-#endif
-#ifdef A29K_MAGIC_BIG
- case bfd_arch_a29k:
- if (bfd_big_endian (abfd))
- *magicp = A29K_MAGIC_BIG;
- else
- *magicp = A29K_MAGIC_LITTLE;
- return true;
- break;
-#endif
-
-#ifdef WE32KMAGIC
- case bfd_arch_we32k:
- *magicp = WE32KMAGIC;
- return true;
- break;
-#endif
-
-#ifdef U802TOCMAGIC
- case bfd_arch_rs6000:
-#ifndef PPCMAGIC
- case bfd_arch_powerpc:
-#endif
- *magicp = U802TOCMAGIC;
- return true;
- break;
-#endif
-
- default: /* Unknown architecture */
- /* return false; -- fall through to "return false" below, to avoid
- "statement never reached" errors on the one below. */
- break;
- }
-
- return false;
-}
-
-
-static boolean
-coff_set_arch_mach (abfd, arch, machine)
- bfd * abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- unsigned dummy1;
- unsigned short dummy2;
-
- if (! bfd_default_set_arch_mach (abfd, arch, machine))
- return false;
-
- if (arch != bfd_arch_unknown &&
- coff_set_flags (abfd, &dummy1, &dummy2) != true)
- return false; /* We can't represent this type */
-
- return true; /* We're easy ... */
-}
-
-
-/* Calculate the file position for each section. */
-
-static void
-coff_compute_section_file_positions (abfd)
- bfd * abfd;
-{
- asection *current;
- asection *previous = (asection *) NULL;
- file_ptr sofar = FILHSZ;
-
-#ifndef I960
- file_ptr old_sofar;
-#endif
- unsigned int count;
-
-#ifdef RS6000COFF_C
- /* On XCOFF, if we have symbols, set up the .debug section. */
- if (bfd_get_symcount (abfd) > 0)
- {
- bfd_size_type sz;
- bfd_size_type i, symcount;
- asymbol **symp;
-
- sz = 0;
- symcount = bfd_get_symcount (abfd);
- for (symp = abfd->outsymbols, i = 0; i < symcount; symp++, i++)
- {
- coff_symbol_type *cf;
-
- cf = coff_symbol_from (abfd, *symp);
- if (cf != NULL
- && cf->native != NULL
- && SYMNAME_IN_DEBUG (&cf->native->u.syment))
- {
- size_t len;
-
- len = strlen (bfd_asymbol_name (*symp));
- if (len > SYMNMLEN)
- sz += len + 3;
- }
- }
- if (sz > 0)
- {
- asection *dsec;
-
- dsec = bfd_make_section_old_way (abfd, ".debug");
- if (dsec == NULL)
- abort ();
- dsec->_raw_size = sz;
- dsec->flags |= SEC_HAS_CONTENTS;
- }
- }
-#endif
-
-#ifdef COFF_IMAGE_WITH_PE
- int page_size;
- if (coff_data (abfd)->link_info)
- {
- page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
- }
- else
- page_size = PE_DEF_FILE_ALIGNMENT;
-#else
-#ifdef COFF_PAGE_SIZE
- int page_size = COFF_PAGE_SIZE;
-#endif
-#endif
-
- if (bfd_get_start_address (abfd))
- {
- /* A start address may have been added to the original file. In this
- case it will need an optional header to record it. */
- abfd->flags |= EXEC_P;
- }
-
- if (abfd->flags & EXEC_P)
- sofar += AOUTSZ;
-#ifdef RS6000COFF_C
- else if (xcoff_data (abfd)->full_aouthdr)
- sofar += AOUTSZ;
- else
- sofar += SMALL_AOUTSZ;
-#endif
-
- sofar += abfd->section_count * SCNHSZ;
-
-#ifdef RS6000COFF_C
- /* XCOFF handles overflows in the reloc and line number count fields
- by allocating a new section header to hold the correct counts. */
- for (current = abfd->sections; current != NULL; current = current->next)
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- sofar += SCNHSZ;
-#endif
-
- for (current = abfd->sections, count = 1;
- current != (asection *) NULL;
- current = current->next, ++count)
- {
- current->target_index = count;
-
- /* Only deal with sections which have contents */
- if (!(current->flags & SEC_HAS_CONTENTS))
- continue;
-
-#ifdef COFF_WITH_PE
- /* Do not include the .junk section. This is where we collect section
- data which we don't need. This is mainly the MS .debug$ data which
- stores codeview debug data. */
- if (strcmp (current->name, ".junk") == 0)
- {
- continue;
- }
-#endif
-
- /* Align the sections in the file to the same boundary on
- which they are aligned in virtual memory. I960 doesn't
- do this (FIXME) so we can stay in sync with Intel. 960
- doesn't yet page from files... */
-#ifndef I960
- if ((abfd->flags & EXEC_P) != 0)
- {
- /* make sure this section is aligned on the right boundary - by
- padding the previous section up if necessary */
-
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
- if (previous != (asection *) NULL)
- {
- previous->_raw_size += sofar - old_sofar;
- }
- }
-
-#endif
-
- /* In demand paged files the low order bits of the file offset
- must match the low order bits of the virtual address. */
-#ifdef COFF_PAGE_SIZE
- if ((abfd->flags & D_PAGED) != 0
- && (current->flags & SEC_ALLOC) != 0)
- sofar += (current->vma - sofar) % page_size;
-#endif
- current->filepos = sofar;
-
-#ifdef COFF_IMAGE_WITH_PE
- /* With PE we have to pad each section to be a multiple of its page size
- too, and remember both sizes. Cooked_size becomes very useful. */
- current->_cooked_size = current->_raw_size;
- current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
-#endif
-
- sofar += current->_raw_size;
-
-#ifndef I960
- /* make sure that this section is of the right size too */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
- current->_raw_size += sofar - old_sofar;
-#endif
-
-#ifdef _LIB
- /* Force .lib sections to start at zero. The vma is then
- incremented in coff_set_section_contents. This is right for
- SVR3.2. */
- if (strcmp (current->name, _LIB) == 0)
- bfd_set_section_vma (abfd, current, 0);
-#endif
-
- previous = current;
- }
-
- obj_relocbase (abfd) = sofar;
- abfd->output_has_begun = true;
-
-}
-
-#if 0
-
-/* This can never work, because it is called too late--after the
- section positions have been set. I can't figure out what it is
- for, so I am going to disable it--Ian Taylor 20 March 1996. */
-
-/* If .file, .text, .data, .bss symbols are missing, add them. */
-/* @@ Should we only be adding missing symbols, or overriding the aux
- values for existing section symbols? */
-static boolean
-coff_add_missing_symbols (abfd)
- bfd *abfd;
-{
- unsigned int nsyms = bfd_get_symcount (abfd);
- asymbol **sympp = abfd->outsymbols;
- asymbol **sympp2;
- unsigned int i;
- int need_text = 1, need_data = 1, need_bss = 1, need_file = 1;
-
- for (i = 0; i < nsyms; i++)
- {
- coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
- CONST char *name;
- if (csym)
- {
- /* only do this if there is a coff representation of the input
- symbol */
- if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
- {
- need_file = 0;
- continue;
- }
- name = csym->symbol.name;
- if (!name)
- continue;
- if (!strcmp (name, _TEXT))
- need_text = 0;
-#ifdef APOLLO_M68
- else if (!strcmp (name, ".wtext"))
- need_text = 0;
-#endif
- else if (!strcmp (name, _DATA))
- need_data = 0;
- else if (!strcmp (name, _BSS))
- need_bss = 0;
- }
- }
- /* Now i == bfd_get_symcount (abfd). */
- /* @@ For now, don't deal with .file symbol. */
- need_file = 0;
-
- if (!need_text && !need_data && !need_bss && !need_file)
- return true;
- nsyms += need_text + need_data + need_bss + need_file;
- sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *));
- if (!sympp2)
- return false;
- memcpy (sympp2, sympp, i * sizeof (asymbol *));
- if (need_file)
- {
- /* @@ Generate fake .file symbol, in sympp2[i], and increment i. */
- abort ();
- }
- if (need_text)
- sympp2[i++] = coff_section_symbol (abfd, _TEXT);
- if (need_data)
- sympp2[i++] = coff_section_symbol (abfd, _DATA);
- if (need_bss)
- sympp2[i++] = coff_section_symbol (abfd, _BSS);
- BFD_ASSERT (i == nsyms);
- bfd_set_symtab (abfd, sympp2, nsyms);
- return true;
-}
-
-#endif /* 0 */
-
-/* SUPPRESS 558 */
-/* SUPPRESS 529 */
-static boolean
-coff_write_object_contents (abfd)
- bfd * abfd;
-{
- asection *current;
- boolean hasrelocs = false;
- boolean haslinno = false;
- file_ptr scn_base;
- file_ptr reloc_base;
- file_ptr lineno_base;
- file_ptr sym_base;
- unsigned long reloc_size = 0;
- unsigned long lnno_size = 0;
- asection *text_sec = NULL;
- asection *data_sec = NULL;
- asection *bss_sec = NULL;
-
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
-
- bfd_set_error (bfd_error_system_call);
-
- /* Make a pass through the symbol table to count line number entries and
- put them into the correct asections */
-
- lnno_size = coff_count_linenumbers (abfd) * LINESZ;
-
- if (abfd->output_has_begun == false)
- coff_compute_section_file_positions (abfd);
-
- reloc_base = obj_relocbase (abfd);
-
- /* Work out the size of the reloc and linno areas */
-
- for (current = abfd->sections; current != NULL; current =
- current->next)
- reloc_size += current->reloc_count * RELSZ;
-
- lineno_base = reloc_base + reloc_size;
- sym_base = lineno_base + lnno_size;
-
- /* Indicate in each section->line_filepos its actual file address */
- for (current = abfd->sections; current != NULL; current =
- current->next)
- {
- if (current->lineno_count)
- {
- current->line_filepos = lineno_base;
- current->moving_line_filepos = lineno_base;
- lineno_base += current->lineno_count * LINESZ;
- }
- else
- {
- current->line_filepos = 0;
- }
- if (current->reloc_count)
- {
- current->rel_filepos = reloc_base;
- reloc_base += current->reloc_count * RELSZ;
- }
- else
- {
- current->rel_filepos = 0;
- }
- }
-
- /* Write section headers to the file. */
- internal_f.f_nscns = 0;
-
- if ((abfd->flags & EXEC_P) != 0)
- scn_base = FILHSZ + AOUTSZ;
- else
- {
- scn_base = FILHSZ;
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- scn_base += AOUTSZ;
- else
- scn_base += SMALL_AOUTSZ;
-#endif
- }
-
- if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
- return false;
-
- for (current = abfd->sections;
- current != NULL;
- current = current->next)
- {
- struct internal_scnhdr section;
-
-#ifdef COFF_WITH_PE
- /* Do not include the .junk section. This is where we collect section
- data which we don't need. This is mainly the MS .debug$ data which
- stores codeview debug data. */
- if (strcmp (current->name, ".junk") == 0)
- {
- continue;
- }
-
- /* If we've got a .reloc section, remember. */
-
-#ifdef COFF_IMAGE_WITH_PE
- if (strcmp (current->name, ".reloc") == 0)
- {
- pe_data (abfd)->has_reloc_section = 1;
- }
-#endif
-
-#endif
- internal_f.f_nscns++;
- strncpy (&(section.s_name[0]), current->name, 8);
-#ifdef _LIB
- /* Always set s_vaddr of .lib to 0. This is right for SVR3.2
- Ian Taylor <ian@cygnus.com>. */
- if (strcmp (current->name, _LIB) == 0)
- section.s_vaddr = 0;
- else
-#endif
- section.s_vaddr = current->vma;
- section.s_paddr = current->lma;
- section.s_size = current->_raw_size;
-
-#ifdef COFF_WITH_PE
- section.s_paddr = current->_cooked_size;
-#endif
-
- /*
- If this section has no size or is unloadable then the scnptr
- will be 0 too
- */
- if (current->_raw_size == 0 ||
- (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- {
- section.s_scnptr = 0;
- }
- else
- {
- section.s_scnptr = current->filepos;
- }
- section.s_relptr = current->rel_filepos;
- section.s_lnnoptr = current->line_filepos;
- section.s_nreloc = current->reloc_count;
- section.s_nlnno = current->lineno_count;
- if (current->reloc_count != 0)
- hasrelocs = true;
- if (current->lineno_count != 0)
- haslinno = true;
-
-#ifdef RS6000COFF_C
- /* Indicate the use of an XCOFF overflow section header. */
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- {
- section.s_nreloc = 0xffff;
- section.s_nlnno = 0xffff;
- }
-#endif
-
- section.s_flags = sec_to_styp_flags (current->name, current->flags);
-
- if (!strcmp (current->name, _TEXT))
- {
- text_sec = current;
- }
- else if (!strcmp (current->name, _DATA))
- {
- data_sec = current;
- }
- else if (!strcmp (current->name, _BSS))
- {
- bss_sec = current;
- }
-
-#ifdef I960
- section.s_align = (current->alignment_power
- ? 1 << current->alignment_power
- : 0);
-
-#endif
-
-#ifdef COFF_IMAGE_WITH_PE
- /* suppress output of the sections if they are null. ld includes
- the bss and data sections even if there is no size assigned
- to them. NT loader doesn't like it if these section headers are
- included if the sections themselves are not needed */
- if (section.s_size == 0)
- internal_f.f_nscns--;
- else
-#endif
- {
- SCNHDR buff;
- if (coff_swap_scnhdr_out (abfd, &section, &buff) == 0
- || bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ)
- return false;
- }
- }
-
-#ifdef RS6000COFF_C
- /* XCOFF handles overflows in the reloc and line number count fields
- by creating a new section header to hold the correct values. */
- for (current = abfd->sections; current != NULL; current = current->next)
- {
- if (current->reloc_count >= 0xffff || current->lineno_count >= 0xffff)
- {
- struct internal_scnhdr scnhdr;
- SCNHDR buff;
-
- internal_f.f_nscns++;
- strncpy (&(scnhdr.s_name[0]), current->name, 8);
- scnhdr.s_paddr = current->reloc_count;
- scnhdr.s_vaddr = current->lineno_count;
- scnhdr.s_size = 0;
- scnhdr.s_scnptr = 0;
- scnhdr.s_relptr = current->rel_filepos;
- scnhdr.s_lnnoptr = current->line_filepos;
- scnhdr.s_nreloc = current->target_index;
- scnhdr.s_nlnno = current->target_index;
- scnhdr.s_flags = STYP_OVRFLO;
- if (coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
- || bfd_write ((PTR) &buff, 1, SCNHSZ, abfd) != SCNHSZ)
- return false;
- }
- }
-#endif
-
- /* OK, now set up the filehdr... */
-
- /* Don't include the internal abs section in the section count */
-
- /*
- We will NOT put a fucking timestamp in the header here. Every time you
- put it back, I will come in and take it out again. I'm sorry. This
- field does not belong here. We fill it with a 0 so it compares the
- same but is not a reasonable time. -- gnu@cygnus.com
- */
- internal_f.f_timdat = 0;
-
- internal_f.f_flags = 0;
-
- if (abfd->flags & EXEC_P)
- internal_f.f_opthdr = AOUTSZ;
- else
- {
- internal_f.f_opthdr = 0;
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- internal_f.f_opthdr = AOUTSZ;
- else
- internal_f.f_opthdr = SMALL_AOUTSZ;
-#endif
- }
-
- if (!hasrelocs)
- internal_f.f_flags |= F_RELFLG;
- if (!haslinno)
- internal_f.f_flags |= F_LNNO;
- if (abfd->flags & EXEC_P)
- internal_f.f_flags |= F_EXEC;
-
- /* FIXME: this is wrong for PPC_PE! */
- if (bfd_little_endian (abfd))
- internal_f.f_flags |= F_AR32WR;
- else
- internal_f.f_flags |= F_AR32W;
-
- /*
- FIXME, should do something about the other byte orders and
- architectures.
- */
-
-#ifdef RS6000COFF_C
- if ((abfd->flags & DYNAMIC) != 0)
- internal_f.f_flags |= F_SHROBJ;
- if (bfd_get_section_by_name (abfd, _LOADER) != NULL)
- internal_f.f_flags |= F_DYNLOAD;
-#endif
-
- memset (&internal_a, 0, sizeof internal_a);
-
- /* Set up architecture-dependent stuff */
-
- {
- unsigned int magic = 0;
- unsigned short flags = 0;
- coff_set_flags (abfd, &magic, &flags);
- internal_f.f_magic = magic;
- internal_f.f_flags |= flags;
- /* ...and the "opt"hdr... */
-
-#ifdef A29K
-#ifdef ULTRA3 /* NYU's machine */
- /* FIXME: This is a bogus check. I really want to see if there
- * is a .shbss or a .shdata section, if so then set the magic
- * number to indicate a shared data executable.
- */
- if (internal_f.f_nscns >= 7)
- internal_a.magic = SHMAGIC; /* Shared magic */
- else
-#endif /* ULTRA3 */
- internal_a.magic = NMAGIC; /* Assume separate i/d */
-#define __A_MAGIC_SET__
-#endif /* A29K */
-#ifdef I860
- /* FIXME: What are the a.out magic numbers for the i860? */
- internal_a.magic = 0;
-#define __A_MAGIC_SET__
-#endif /* I860 */
-#ifdef I960
- internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC);
-#define __A_MAGIC_SET__
-#endif /* I960 */
-#if M88
-#define __A_MAGIC_SET__
- internal_a.magic = PAGEMAGICBCS;
-#endif /* M88 */
-
-#if APOLLO_M68
-#define __A_MAGIC_SET__
- internal_a.magic = APOLLO_COFF_VERSION_NUMBER;
-#endif
-
-#if defined(M68) || defined(WE32K) || defined(M68K)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#else
-#if defined(TARG_AUX)
- internal_a.magic = (abfd->flags & D_PAGED ? PAGEMAGICPEXECPAGED :
- abfd->flags & WP_TEXT ? PAGEMAGICPEXECSWAPPED :
- PAGEMAGICEXECSWAPPED);
-#else
-#if defined (PAGEMAGICPEXECPAGED)
- internal_a.magic = PAGEMAGICPEXECPAGED;
-#endif
-#endif /* TARG_AUX */
-#endif /* LYNXOS */
-#endif /* M68 || WE32K || M68K */
-
-#if defined(ARM)
-#define __A_MAGIC_SET__
- internal_a.magic = ZMAGIC;
-#endif
-#if defined(PPC)
-#define __A_MAGIC_SET__
- internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
-#endif
-#if defined(I386)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#else /* LYNXOS */
- internal_a.magic = ZMAGIC;
-#endif /* LYNXOS */
-#endif /* I386 */
-
-#if defined(SPARC)
-#define __A_MAGIC_SET__
-#if defined(LYNXOS)
- internal_a.magic = LYNXCOFFMAGIC;
-#endif /* LYNXOS */
-#endif /* SPARC */
-
-#if RS6000COFF_C
-#define __A_MAGIC_SET__
- internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
- (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
- RS6K_AOUTHDR_OMAGIC;
-#endif
-
-#ifndef __A_MAGIC_SET__
-#include "Your aouthdr magic number is not being set!"
-#else
-#undef __A_MAGIC_SET__
-#endif
- }
-
- /* FIXME: Does anybody ever set this to another value? */
- internal_a.vstamp = 0;
-
- /* Now should write relocs, strings, syms */
- obj_sym_filepos (abfd) = sym_base;
-
- if (bfd_get_symcount (abfd) != 0)
- {
- int firstundef;
-#if 0
- if (!coff_add_missing_symbols (abfd))
- return false;
-#endif
- if (!coff_renumber_symbols (abfd, &firstundef))
- return false;
- coff_mangle_symbols (abfd);
- if (! coff_write_symbols (abfd))
- return false;
- if (! coff_write_linenumbers (abfd))
- return false;
- if (! coff_write_relocs (abfd, firstundef))
- return false;
- }
-#ifdef COFF_IMAGE_WITH_PE
-#ifdef PPC
- else if ((abfd->flags & EXEC_P) != 0)
- {
- bfd_byte b;
-
- /* PowerPC PE appears to require that all executable files be
- rounded up to the page size. */
- b = 0;
- if (bfd_seek (abfd,
- BFD_ALIGN (sym_base, COFF_PAGE_SIZE) - 1,
- SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
- return false;
- }
-#endif
-#endif
-
- /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
- backend linker, and obj_raw_syment_count is not valid until after
- coff_write_symbols is called. */
- if (obj_raw_syment_count (abfd) != 0)
- {
- internal_f.f_symptr = sym_base;
-#ifdef RS6000COFF_C
- /* AIX appears to require that F_RELFLG not be set if there are
- local symbols but no relocations. */
- internal_f.f_flags &=~ F_RELFLG;
-#endif
- }
- else
- {
- internal_f.f_symptr = 0;
- internal_f.f_flags |= F_LSYMS;
- }
-
- if (text_sec)
- {
- internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
- internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
- }
- if (data_sec)
- {
- internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
- internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
- }
- if (bss_sec)
- {
- internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
- if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
- internal_a.data_start = bss_sec->vma;
- }
-
- internal_a.entry = bfd_get_start_address (abfd);
- internal_f.f_nsyms = obj_raw_syment_count (abfd);
-
-#ifdef RS6000COFF_C
- if (xcoff_data (abfd)->full_aouthdr)
- {
- bfd_vma toc;
- asection *loader_sec;
-
- internal_a.vstamp = 1;
-
- internal_a.o_snentry = xcoff_data (abfd)->snentry;
- if (internal_a.o_snentry == 0)
- internal_a.entry = (bfd_vma) -1;
-
- if (text_sec != NULL)
- {
- internal_a.o_sntext = text_sec->target_index;
- internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
- }
- else
- {
- internal_a.o_sntext = 0;
- internal_a.o_algntext = 0;
- }
- if (data_sec != NULL)
- {
- internal_a.o_sndata = data_sec->target_index;
- internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
- }
- else
- {
- internal_a.o_sndata = 0;
- internal_a.o_algndata = 0;
- }
- loader_sec = bfd_get_section_by_name (abfd, ".loader");
- if (loader_sec != NULL)
- internal_a.o_snloader = loader_sec->target_index;
- else
- internal_a.o_snloader = 0;
- if (bss_sec != NULL)
- internal_a.o_snbss = bss_sec->target_index;
- else
- internal_a.o_snbss = 0;
-
- toc = xcoff_data (abfd)->toc;
- internal_a.o_toc = toc;
- internal_a.o_sntoc = xcoff_data (abfd)->sntoc;
-
- internal_a.o_modtype = xcoff_data (abfd)->modtype;
- if (xcoff_data (abfd)->cputype != -1)
- internal_a.o_cputype = xcoff_data (abfd)->cputype;
- else
- {
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_rs6000:
- internal_a.o_cputype = 4;
- break;
- case bfd_arch_powerpc:
- if (bfd_get_mach (abfd) == 0)
- internal_a.o_cputype = 3;
- else
- internal_a.o_cputype = 1;
- break;
- default:
- abort ();
- }
- }
- internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
- internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
- }
-#endif
-
- /* now write them */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- {
- FILHDR buff;
- coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) & buff);
- if (bfd_write ((PTR) & buff, 1, FILHSZ, abfd) != FILHSZ)
- return false;
- }
- if (abfd->flags & EXEC_P)
- {
- AOUTHDR buff;
- coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) & buff);
- if (bfd_write ((PTR) & buff, 1, AOUTSZ, abfd) != AOUTSZ)
- return false;
- }
-#ifdef RS6000COFF_C
- else
- {
- AOUTHDR buff;
- size_t size;
-
- /* XCOFF seems to always write at least a small a.out header. */
- coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) &buff);
- if (xcoff_data (abfd)->full_aouthdr)
- size = AOUTSZ;
- else
- size = SMALL_AOUTSZ;
- if (bfd_write ((PTR) &buff, 1, size, abfd) != size)
- return false;
- }
-#endif
-
- return true;
-}
-
-static boolean
-coff_set_section_contents (abfd, section, location, offset, count)
- bfd * abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (abfd->output_has_begun == false) /* set by bfd.c handler */
- coff_compute_section_file_positions (abfd);
-
-#ifdef _LIB
-
- /* The physical address field of a .lib section is used to hold the
- number of shared libraries in the section. This code counts the
- number of sections being written, and increments the lma field
- with the number.
-
- I have found no documentation on the contents of this section.
- Experimentation indicates that the section contains zero or more
- records, each of which has the following structure:
-
- - a (four byte) word holding the length of this record, in words,
- - a word that always seems to be set to "2",
- - the path to a shared library, null-terminated and then padded
- to a whole word boundary.
-
- bfd_assert calls have been added to alert if an attempt is made
- to write a section which doesn't follow these assumptions. The
- code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
- <robertl@arnet.com> (Thanks!).
-
- Gvran Uddeborg <gvran@uddeborg.pp.se> */
-
- if (strcmp (section->name, _LIB) == 0)
- {
- bfd_byte *rec, *recend;
-
- rec = (bfd_byte *) location;
- recend = rec + count;
- while (rec < recend)
- {
- ++section->lma;
- rec += bfd_get_32 (abfd, rec) * 4;
- }
-
- BFD_ASSERT (rec == recend);
- }
-
-#endif
-
- /* Don't write out bss sections - one way to do this is to
- see if the filepos has not been set. */
- if (section->filepos == 0)
- return true;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0)
- return false;
-
- if (count != 0)
- {
- return (bfd_write (location, 1, count, abfd) == count) ? true : false;
- }
- return true;
-}
-#if 0
-static boolean
-coff_close_and_cleanup (abfd)
- bfd *abfd;
-{
- if (!bfd_read_p (abfd))
- switch (abfd->format)
- {
- case bfd_archive:
- if (!_bfd_write_archive_contents (abfd))
- return false;
- break;
- case bfd_object:
- if (!coff_write_object_contents (abfd))
- return false;
- break;
- default:
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* We depend on bfd_close to free all the memory on the obstack. */
- /* FIXME if bfd_release is not using obstacks! */
- return true;
-}
-
-#endif
-
-static PTR
-buy_and_read (abfd, where, seek_direction, size)
- bfd *abfd;
- file_ptr where;
- int seek_direction;
- size_t size;
-{
- PTR area = (PTR) bfd_alloc (abfd, size);
- if (!area)
- return (NULL);
- if (bfd_seek (abfd, where, seek_direction) != 0
- || bfd_read (area, 1, size, abfd) != size)
- return (NULL);
- return (area);
-} /* buy_and_read() */
-
-/*
-SUBSUBSECTION
- Reading linenumbers
-
- Creating the linenumber table is done by reading in the entire
- coff linenumber table, and creating another table for internal use.
-
- A coff linenumber table is structured so that each function
- is marked as having a line number of 0. Each line within the
- function is an offset from the first line in the function. The
- base of the line number information for the table is stored in
- the symbol associated with the function.
-
- The information is copied from the external to the internal
- table, and each symbol which marks a function is marked by
- pointing its...
-
- How does this work ?
-
-*/
-
-static boolean
-coff_slurp_line_table (abfd, asect)
- bfd *abfd;
- asection *asect;
-{
- LINENO *native_lineno;
- alent *lineno_cache;
-
- BFD_ASSERT (asect->lineno == (alent *) NULL);
-
- native_lineno = (LINENO *) buy_and_read (abfd,
- asect->line_filepos,
- SEEK_SET,
- (size_t) (LINESZ *
- asect->lineno_count));
- lineno_cache =
- (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
- if (lineno_cache == NULL)
- return false;
- else
- {
- unsigned int counter = 0;
- alent *cache_ptr = lineno_cache;
- LINENO *src = native_lineno;
-
- while (counter < asect->lineno_count)
- {
- struct internal_lineno dst;
- coff_swap_lineno_in (abfd, src, &dst);
- cache_ptr->line_number = dst.l_lnno;
-
- if (cache_ptr->line_number == 0)
- {
- coff_symbol_type *sym =
- (coff_symbol_type *) (dst.l_addr.l_symndx
- + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes;
- cache_ptr->u.sym = (asymbol *) sym;
- if (sym->lineno != NULL)
- {
- (*_bfd_error_handler)
- ("%s: warning: duplicate line number information for `%s'",
- bfd_get_filename (abfd),
- bfd_asymbol_name (&sym->symbol));
- }
- sym->lineno = cache_ptr;
- }
- else
- {
- cache_ptr->u.offset = dst.l_addr.l_paddr
- - bfd_section_vma (abfd, asect);
- } /* If no linenumber expect a symbol index */
-
- cache_ptr++;
- src++;
- counter++;
- }
- cache_ptr->line_number = 0;
-
- }
- asect->lineno = lineno_cache;
- /* FIXME, free native_lineno here, or use alloca or something. */
- return true;
-}
-
-static boolean
-coff_slurp_symbol_table (abfd)
- bfd * abfd;
-{
- combined_entry_type *native_symbols;
- coff_symbol_type *cached_area;
- unsigned int *table_ptr;
-
- unsigned int number_of_symbols = 0;
-
- if (obj_symbols (abfd))
- return true;
-
- /* Read in the symbol table */
- if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
- {
- return (false);
- } /* on error */
-
- /* Allocate enough room for all the symbols in cached form */
- cached_area = ((coff_symbol_type *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (coff_symbol_type))));
-
- if (cached_area == NULL)
- return false;
- table_ptr = ((unsigned int *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (unsigned int))));
-
- if (table_ptr == NULL)
- return false;
- else
- {
- coff_symbol_type *dst = cached_area;
- unsigned int last_native_index = obj_raw_syment_count (abfd);
- unsigned int this_index = 0;
- while (this_index < last_native_index)
- {
- combined_entry_type *src = native_symbols + this_index;
- table_ptr[this_index] = number_of_symbols;
- dst->symbol.the_bfd = abfd;
-
- dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset);
- /* We use the native name field to point to the cached field. */
- src->u.syment._n._n_n._n_zeroes = (long) dst;
- dst->symbol.section = coff_section_from_bfd_index (abfd,
- src->u.syment.n_scnum);
- dst->symbol.flags = 0;
- dst->done_lineno = false;
-
- switch (src->u.syment.n_sclass)
- {
-#ifdef I960
- case C_LEAFEXT:
-#if 0
- dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma;
- dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
- dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
-#endif
- /* Fall through to next case */
-
-#endif
-
- case C_EXT:
-#ifdef RS6000COFF_C
- case C_HIDEXT:
-#endif
-#ifdef COFF_WITH_PE
- /* PE uses storage class 0x68 to denote a section symbol */
- case C_SECTION:
- /* PE uses storage class 0x67 for a weak external symbol. */
- case C_NT_WEAK:
-#endif
- if ((src->u.syment.n_scnum) == 0)
- {
- if ((src->u.syment.n_value) == 0)
- {
- dst->symbol.section = bfd_und_section_ptr;
- dst->symbol.value = 0;
- }
- else
- {
- dst->symbol.section = bfd_com_section_ptr;
- dst->symbol.value = (src->u.syment.n_value);
- }
- }
- else
- {
- /* Base the value as an index from the base of the
- section */
-
- dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
- dst->symbol.value = (src->u.syment.n_value
- - dst->symbol.section->vma);
-
- if (ISFCN ((src->u.syment.n_type)))
- {
- /* A function ext does not go at the end of a
- file. */
- dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
- }
- }
-
-#ifdef RS6000COFF_C
- /* A C_HIDEXT symbol is not global. */
- if (src->u.syment.n_sclass == C_HIDEXT)
- dst->symbol.flags = BSF_LOCAL;
- /* A symbol with a csect entry should not go at the end. */
- if (src->u.syment.n_numaux > 0)
- dst->symbol.flags |= BSF_NOT_AT_END;
-#endif
-
-#ifdef COFF_WITH_PE
- if (src->u.syment.n_sclass == C_NT_WEAK)
- dst->symbol.flags = BSF_WEAK;
-#endif
-
- break;
-
- case C_STAT: /* static */
-#ifdef I960
- case C_LEAFSTAT: /* static leaf procedure */
-#endif
- case C_LABEL: /* label */
- if (src->u.syment.n_scnum == -2)
- dst->symbol.flags = BSF_DEBUGGING;
- else
- dst->symbol.flags = BSF_LOCAL;
- /*
- Base the value as an index from the base of the section, if
- there is one
- */
- if (dst->symbol.section)
- dst->symbol.value = (src->u.syment.n_value) -
- dst->symbol.section->vma;
- else
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
- case C_MOS: /* member of structure */
- case C_EOS: /* end of structure */
-#ifdef NOTDEF /* C_AUTOARG has the same value */
-#ifdef C_GLBLREG
- case C_GLBLREG: /* A29k-specific storage class */
-#endif
-#endif
- case C_REGPARM: /* register parameter */
- case C_REG: /* register variable */
-#ifdef C_AUTOARG
- case C_AUTOARG: /* 960-specific storage class */
-#endif
- case C_TPDEF: /* type definition */
- case C_ARG:
- case C_AUTO: /* automatic variable */
- case C_FIELD: /* bit field */
- case C_ENTAG: /* enumeration tag */
- case C_MOE: /* member of enumeration */
- case C_MOU: /* member of union */
- case C_UNTAG: /* union tag */
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
- case C_FILE: /* file name */
- case C_STRTAG: /* structure tag */
-#ifdef RS6000COFF_C
- case C_GSYM:
- case C_LSYM:
- case C_PSYM:
- case C_RSYM:
- case C_RPSYM:
- case C_STSYM:
- case C_BCOMM:
- case C_ECOMM:
- case C_DECL:
- case C_ENTRY:
- case C_FUN:
- case C_ESTAT:
-#endif
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
-
-#ifdef RS6000COFF_C
- case C_BINCL: /* beginning of include file */
- case C_EINCL: /* ending of include file */
- /* The value is actually a pointer into the line numbers
- of the file. We locate the line number entry, and
- set the section to the section which contains it, and
- the value to the index in that section. */
- {
- asection *sec;
-
- dst->symbol.flags = BSF_DEBUGGING;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
- && ((file_ptr) (sec->line_filepos
- + sec->lineno_count * LINESZ)
- > (file_ptr) src->u.syment.n_value))
- break;
- if (sec == NULL)
- dst->symbol.value = 0;
- else
- {
- dst->symbol.section = sec;
- dst->symbol.value = ((src->u.syment.n_value
- - sec->line_filepos)
- / LINESZ);
- src->fix_line = 1;
- }
- }
- break;
-
- case C_BSTAT:
- dst->symbol.flags = BSF_DEBUGGING;
-
- /* The value is actually a symbol index. Save a pointer
- to the symbol instead of the index. FIXME: This
- should use a union. */
- src->u.syment.n_value =
- (long) (native_symbols + src->u.syment.n_value);
- dst->symbol.value = src->u.syment.n_value;
- src->fix_value = 1;
- break;
-#endif
-
- case C_BLOCK: /* ".bb" or ".eb" */
- case C_FCN: /* ".bf" or ".ef" */
- case C_EFCN: /* physical end of function */
- dst->symbol.flags = BSF_LOCAL;
- /*
- Base the value as an index from the base of the section
- */
- dst->symbol.value = (src->u.syment.n_value) - dst->symbol.section->vma;
- break;
-
- case C_NULL:
- case C_EXTDEF: /* external definition */
- case C_ULABEL: /* undefined label */
- case C_USTATIC: /* undefined static */
-#ifndef COFF_WITH_PE
- /* C_LINE in regular coff is 0x68. NT has taken over this storage
- class to represent a section symbol */
- case C_LINE: /* line # reformatted as symbol table entry */
- /* NT uses 0x67 for a weak symbol, not C_ALIAS. */
- case C_ALIAS: /* duplicate tag */
-#endif
- case C_HIDDEN: /* ext symbol in dmert public lib */
- default:
- (*_bfd_error_handler)
- ("%s: Unrecognized storage class %d for %s symbol `%s'",
- bfd_get_filename (abfd), src->u.syment.n_sclass,
- dst->symbol.section->name, dst->symbol.name);
- dst->symbol.flags = BSF_DEBUGGING;
- dst->symbol.value = (src->u.syment.n_value);
- break;
- }
-
-/* BFD_ASSERT(dst->symbol.flags != 0);*/
-
- dst->native = src;
-
- dst->symbol.udata.i = 0;
- dst->lineno = (alent *) NULL;
- this_index += (src->u.syment.n_numaux) + 1;
- dst++;
- number_of_symbols++;
- } /* walk the native symtab */
- } /* bfdize the native symtab */
-
- obj_symbols (abfd) = cached_area;
- obj_raw_syments (abfd) = native_symbols;
-
- bfd_get_symcount (abfd) = number_of_symbols;
- obj_convert (abfd) = table_ptr;
- /* Slurp the line tables for each section too */
- {
- asection *p;
- p = abfd->sections;
- while (p)
- {
- coff_slurp_line_table (abfd, p);
- p = p->next;
- }
- }
- return true;
-} /* coff_slurp_symbol_table() */
-
-/* Check whether a symbol is globally visible. This is used by the
- COFF backend linker code in cofflink.c, since a couple of targets
- have globally visible symbols which are not class C_EXT. This
- function need not handle the case of n_class == C_EXT. */
-
-#undef OTHER_GLOBAL_CLASS
-
-#ifdef I960
-#define OTHER_GLOBAL_CLASS C_LEAFEXT
-#endif
-
-#ifdef COFF_WITH_PE
-#define OTHER_GLOBAL_CLASS C_SECTION
-#endif
-
-#ifdef OTHER_GLOBAL_CLASS
-
-static boolean
-coff_sym_is_global (abfd, syment)
- bfd *abfd;
- struct internal_syment *syment;
-{
- if (syment->n_sclass == OTHER_GLOBAL_CLASS)
- return true;
- return false;
-}
-
-#undef OTHER_GLOBAL_CLASS
-
-#else /* ! defined (OTHER_GLOBAL_CLASS) */
-
-/* sym_is_global should not be defined if it has nothing to do. */
-
-#define coff_sym_is_global 0
-
-#endif /* ! defined (OTHER_GLOBAL_CLASS) */
-
-/*
-SUBSUBSECTION
- Reading relocations
-
- Coff relocations are easily transformed into the internal BFD form
- (@code{arelent}).
-
- Reading a coff relocation table is done in the following stages:
-
- o Read the entire coff relocation table into memory.
-
- o Process each relocation in turn; first swap it from the
- external to the internal form.
-
- o Turn the symbol referenced in the relocation's symbol index
- into a pointer into the canonical symbol table.
- This table is the same as the one returned by a call to
- @code{bfd_canonicalize_symtab}. The back end will call that
- routine and save the result if a canonicalization hasn't been done.
-
- o The reloc index is turned into a pointer to a howto
- structure, in a back end specific way. For instance, the 386
- and 960 use the @code{r_type} to directly produce an index
- into a howto table vector; the 88k subtracts a number from the
- @code{r_type} field and creates an addend field.
-
-
-*/
-
-#ifndef CALC_ADDEND
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = 0; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- }
-#endif
-
-static boolean
-coff_slurp_reloc_table (abfd, asect, symbols)
- bfd * abfd;
- sec_ptr asect;
- asymbol ** symbols;
-{
- RELOC *native_relocs;
- arelent *reloc_cache;
- arelent *cache_ptr;
-
- unsigned int idx;
-
- if (asect->relocation)
- return true;
- if (asect->reloc_count == 0)
- return true;
- if (asect->flags & SEC_CONSTRUCTOR)
- return true;
- if (!coff_slurp_symbol_table (abfd))
- return false;
- native_relocs =
- (RELOC *) buy_and_read (abfd,
- asect->rel_filepos,
- SEEK_SET,
- (size_t) (RELSZ *
- asect->reloc_count));
- reloc_cache = (arelent *)
- bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
-
- if (reloc_cache == NULL)
- return false;
-
-
- for (idx = 0; idx < asect->reloc_count; idx++)
- {
-#ifdef RELOC_PROCESSING
- struct internal_reloc dst;
- struct external_reloc *src;
-
- cache_ptr = reloc_cache + idx;
- src = native_relocs + idx;
- coff_swap_reloc_in (abfd, src, &dst);
-
- RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
-#else
- struct internal_reloc dst;
- asymbol *ptr;
- struct external_reloc *src;
-
- cache_ptr = reloc_cache + idx;
- src = native_relocs + idx;
-
- coff_swap_reloc_in (abfd, src, &dst);
-
-
- cache_ptr->address = dst.r_vaddr;
-
- if (dst.r_symndx != -1)
- {
- /* @@ Should never be greater than count of symbols! */
- if (dst.r_symndx >= obj_conv_table_size (abfd))
- abort ();
- cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx];
- ptr = *(cache_ptr->sym_ptr_ptr);
- }
- else
- {
- cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- ptr = 0;
- }
-
- /* The symbols definitions that we have read in have been
- relocated as if their sections started at 0. But the offsets
- refering to the symbols in the raw data have not been
- modified, so we have to have a negative addend to compensate.
-
- Note that symbols which used to be common must be left alone */
-
- /* Calculate any reloc addend by looking at the symbol */
- CALC_ADDEND (abfd, ptr, dst, cache_ptr);
-
- cache_ptr->address -= asect->vma;
-/* !! cache_ptr->section = (asection *) NULL;*/
-
- /* Fill in the cache_ptr->howto field from dst.r_type */
- RTYPE2HOWTO (cache_ptr, &dst);
-#endif
-
- }
-
- asect->relocation = reloc_cache;
- return true;
-}
-
-#ifndef coff_rtype_to_howto
-#ifdef RTYPE2HOWTO
-
-/* Get the howto structure for a reloc. This is only used if the file
- including this one defines coff_relocate_section to be
- _bfd_coff_generic_relocate_section, so it is OK if it does not
- always work. It is the responsibility of the including file to
- make sure it is reasonable if it is needed. */
-
-static reloc_howto_type *coff_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-
-/*ARGSUSED*/
-static reloc_howto_type *
-coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
- arelent genrel;
-
- RTYPE2HOWTO (&genrel, rel);
- return genrel.howto;
-}
-
-#else /* ! defined (RTYPE2HOWTO) */
-
-#define coff_rtype_to_howto NULL
-
-#endif /* ! defined (RTYPE2HOWTO) */
-#endif /* ! defined (coff_rtype_to_howto) */
-
-/* This is stupid. This function should be a boolean predicate. */
-static long
-coff_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd * abfd;
- sec_ptr section;
- arelent ** relptr;
- asymbol ** symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count = 0;
-
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- /* this section has relocs made up by us, they are not in the
- file, so take them out of their chain and place them into
- the data area provided */
- arelent_chain *chain = section->constructor_chain;
- for (count = 0; count < section->reloc_count; count++)
- {
- *relptr++ = &chain->relent;
- chain = chain->next;
- }
-
- }
- else
- {
- if (! coff_slurp_reloc_table (abfd, section, symbols))
- return -1;
-
- tblptr = section->relocation;
-
- for (; count++ < section->reloc_count;)
- *relptr++ = tblptr++;
-
-
- }
- *relptr = 0;
- return section->reloc_count;
-}
-
-#ifdef GNU960
-file_ptr
-coff_sym_filepos (abfd)
- bfd *abfd;
-{
- return obj_sym_filepos (abfd);
-}
-#endif
-
-#ifndef coff_reloc16_estimate
-#define coff_reloc16_estimate dummy_reloc16_estimate
-
-static int
-dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
- bfd *abfd;
- asection *input_section;
- arelent *reloc;
- unsigned int shrink;
- struct bfd_link_info *link_info;
-{
- abort ();
-}
-
-#endif
-
-#ifndef coff_reloc16_extra_cases
-#define coff_reloc16_extra_cases dummy_reloc16_extra_cases
-/* This works even if abort is not declared in any header file. */
-static void
-dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
- dst_ptr)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- arelent *reloc;
- bfd_byte *data;
- unsigned int *src_ptr;
- unsigned int *dst_ptr;
-{
- abort ();
-}
-#endif
-
-/* If coff_relocate_section is defined, we can use the optimized COFF
- backend linker. Otherwise we must continue to use the old linker. */
-#ifdef coff_relocate_section
-#ifndef coff_bfd_link_hash_table_create
-#define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
-#endif
-#ifndef coff_bfd_link_add_symbols
-#define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols
-#endif
-#ifndef coff_bfd_final_link
-#define coff_bfd_final_link _bfd_coff_final_link
-#endif
-#else /* ! defined (coff_relocate_section) */
-#define coff_relocate_section NULL
-#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#ifndef coff_bfd_link_add_symbols
-#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#endif
-#define coff_bfd_final_link _bfd_generic_final_link
-#endif /* ! defined (coff_relocate_section) */
-#define coff_bfd_link_split_section _bfd_generic_link_split_section
-
-#ifndef coff_start_final_link
-#define coff_start_final_link NULL
-#endif
-
-#ifndef coff_adjust_symndx
-#define coff_adjust_symndx NULL
-#endif
-
-#ifndef coff_link_add_one_symbol
-#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol
-#endif
-
-static CONST bfd_coff_backend_data bfd_coff_std_swap_table =
-{
- coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
- coff_swap_aux_out, coff_swap_sym_out,
- coff_swap_lineno_out, coff_swap_reloc_out,
- coff_swap_filehdr_out, coff_swap_aouthdr_out,
- coff_swap_scnhdr_out,
- FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ,
-#ifdef COFF_LONG_FILENAMES
- true,
-#else
- false,
-#endif
- coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in,
- coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
- coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
- coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
- coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
- coff_sym_is_global, coff_compute_section_file_positions,
- coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol
-};
-
-#define coff_close_and_cleanup _bfd_generic_close_and_cleanup
-#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define coff_get_section_contents _bfd_generic_get_section_contents
-
-#ifndef coff_bfd_copy_private_symbol_data
-#define coff_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
-#endif
-
-#ifndef coff_bfd_copy_private_section_data
-#define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
-#endif
-
-#ifndef coff_bfd_copy_private_bfd_data
-#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
-#endif
-
-#define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
-#define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-
-#ifndef coff_bfd_print_private_bfd_data
-#define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
-#endif
-
-#ifndef coff_bfd_is_local_label
-#define coff_bfd_is_local_label bfd_generic_is_local_label
-#endif
-#ifndef coff_read_minisymbols
-#define coff_read_minisymbols _bfd_generic_read_minisymbols
-#endif
-#ifndef coff_minisymbol_to_symbol
-#define coff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-#endif
-
-/* The reloc lookup routine must be supplied by each individual COFF
- backend. */
-#ifndef coff_bfd_reloc_type_lookup
-#define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-#endif
-
-#ifndef coff_bfd_get_relocated_section_contents
-#define coff_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#endif
-#ifndef coff_bfd_relax_section
-#define coff_bfd_relax_section bfd_generic_relax_section
-#endif
diff --git a/contrib/gdb/bfd/coffgen.c b/contrib/gdb/bfd/coffgen.c
deleted file mode 100644
index 285fe61..0000000
--- a/contrib/gdb/bfd/coffgen.c
+++ /dev/null
@@ -1,2121 +0,0 @@
-/* Support for the generic parts of COFF, for BFD.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Most of this hacked by Steve Chamberlain, sac@cygnus.com.
- Split out of coffcode.h by Ian Taylor, ian@cygnus.com. */
-
-/* This file contains COFF code that is not dependent on any
- particular COFF target. There is only one version of this file in
- libbfd.a, so no target specific code may be put in here. Or, to
- put it another way,
-
- ********** DO NOT PUT TARGET SPECIFIC CODE IN THIS FILE **********
-
- If you need to add some target specific behaviour, add a new hook
- function to bfd_coff_backend_data.
-
- Some of these functions are also called by the ECOFF routines.
- Those functions may not use any COFF specific information, such as
- coff_data (abfd). */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-static void coff_fix_symbol_name
- PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *,
- asection **, bfd_size_type *));
-static boolean coff_write_symbol
- PARAMS ((bfd *, asymbol *, combined_entry_type *, unsigned int *,
- bfd_size_type *, asection **, bfd_size_type *));
-static boolean coff_write_alien_symbol
- PARAMS ((bfd *, asymbol *, unsigned int *, bfd_size_type *,
- asection **, bfd_size_type *));
-static boolean coff_write_native_symbol
- PARAMS ((bfd *, coff_symbol_type *, unsigned int *, bfd_size_type *,
- asection **, bfd_size_type *));
-static void coff_pointerize_aux
- PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
- unsigned int, combined_entry_type *));
-
-#define STRING_SIZE_SIZE (4)
-
-/* Take a section header read from a coff file (in HOST byte order),
- and make a BFD "section" out of it. This is used by ECOFF. */
-static boolean
-make_a_section_from_file (abfd, hdr, target_index)
- bfd *abfd;
- struct internal_scnhdr *hdr;
- unsigned int target_index;
-{
- asection *return_section;
- char *name;
-
- /* Assorted wastage to null-terminate the name, thanks AT&T! */
- name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
- if (name == NULL)
- return false;
- strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
- name[sizeof (hdr->s_name)] = 0;
-
- return_section = bfd_make_section_anyway (abfd, name);
- if (return_section == NULL)
- return false;
-
- return_section->vma = hdr->s_vaddr;
- return_section->lma = hdr->s_paddr;
- return_section->_raw_size = hdr->s_size;
- return_section->filepos = hdr->s_scnptr;
- return_section->rel_filepos = hdr->s_relptr;
- return_section->reloc_count = hdr->s_nreloc;
-
- bfd_coff_set_alignment_hook (abfd, return_section, hdr);
-
- return_section->line_filepos = hdr->s_lnnoptr;
-
- return_section->lineno_count = hdr->s_nlnno;
- return_section->userdata = NULL;
- return_section->next = (asection *) NULL;
- return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name);
-
- return_section->target_index = target_index;
-
- /* At least on i386-coff, the line number count for a shared library
- section must be ignored. */
- if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
- return_section->lineno_count = 0;
-
- if (hdr->s_nreloc != 0)
- return_section->flags |= SEC_RELOC;
- /* FIXME: should this check 'hdr->s_size > 0' */
- if (hdr->s_scnptr != 0)
- return_section->flags |= SEC_HAS_CONTENTS;
- return true;
-}
-
-/* Read in a COFF object and make it into a BFD. This is used by
- ECOFF as well. */
-
-static const bfd_target *
-coff_real_object_p (abfd, nscns, internal_f, internal_a)
- bfd *abfd;
- unsigned nscns;
- struct internal_filehdr *internal_f;
- struct internal_aouthdr *internal_a;
-{
- flagword oflags = abfd->flags;
- bfd_vma ostart = bfd_get_start_address (abfd);
- PTR tdata;
- size_t readsize; /* length of file_info */
- unsigned int scnhsz;
- char *external_sections;
-
- if (!(internal_f->f_flags & F_RELFLG))
- abfd->flags |= HAS_RELOC;
- if ((internal_f->f_flags & F_EXEC))
- abfd->flags |= EXEC_P;
- if (!(internal_f->f_flags & F_LNNO))
- abfd->flags |= HAS_LINENO;
- if (!(internal_f->f_flags & F_LSYMS))
- abfd->flags |= HAS_LOCALS;
-
- /* FIXME: How can we set D_PAGED correctly? */
- if ((internal_f->f_flags & F_EXEC) != 0)
- abfd->flags |= D_PAGED;
-
- bfd_get_symcount (abfd) = internal_f->f_nsyms;
- if (internal_f->f_nsyms)
- abfd->flags |= HAS_SYMS;
-
- if (internal_a != (struct internal_aouthdr *) NULL)
- bfd_get_start_address (abfd) = internal_a->entry;
- else
- bfd_get_start_address (abfd) = 0;
-
- /* Set up the tdata area. ECOFF uses its own routine, and overrides
- abfd->flags. */
- tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a);
- if (tdata == NULL)
- return 0;
-
- scnhsz = bfd_coff_scnhsz (abfd);
- readsize = nscns * scnhsz;
- external_sections = (char *) bfd_alloc (abfd, readsize);
- if (!external_sections)
- goto fail;
-
- if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
- goto fail;
-
- /* Now copy data as required; construct all asections etc */
- if (nscns != 0)
- {
- unsigned int i;
- for (i = 0; i < nscns; i++)
- {
- struct internal_scnhdr tmp;
- bfd_coff_swap_scnhdr_in (abfd,
- (PTR) (external_sections + i * scnhsz),
- (PTR) & tmp);
- make_a_section_from_file (abfd, &tmp, i + 1);
- }
- }
-
- /* make_abs_section (abfd); */
-
- if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
- goto fail;
-
- return abfd->xvec;
-
- fail:
- bfd_release (abfd, tdata);
- abfd->flags = oflags;
- bfd_get_start_address (abfd) = ostart;
- return (const bfd_target *) NULL;
-}
-
-/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
- not a COFF file. This is also used by ECOFF. */
-
-const bfd_target *
-coff_object_p (abfd)
- bfd *abfd;
-{
- unsigned int filhsz;
- unsigned int aoutsz;
- int nscns;
- PTR filehdr;
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
-
- /* figure out how much to read */
- filhsz = bfd_coff_filhsz (abfd);
- aoutsz = bfd_coff_aoutsz (abfd);
-
- filehdr = bfd_alloc (abfd, filhsz);
- if (filehdr == NULL)
- return 0;
- if (bfd_read (filehdr, 1, filhsz, abfd) != filhsz)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
- bfd_release (abfd, filehdr);
-
- if (bfd_coff_bad_format_hook (abfd, &internal_f) == false)
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- nscns = internal_f.f_nscns;
-
- if (internal_f.f_opthdr)
- {
- PTR opthdr;
-
- opthdr = bfd_alloc (abfd, aoutsz);
- if (opthdr == NULL)
- return 0;;
- if (bfd_read (opthdr, 1, aoutsz, abfd) != aoutsz)
- {
- return 0;
- }
- bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) & internal_a);
- }
-
- /* Seek past the opt hdr stuff */
- if (bfd_seek (abfd, (file_ptr) (internal_f.f_opthdr + filhsz), SEEK_SET)
- != 0)
- return NULL;
-
- return coff_real_object_p (abfd, nscns, &internal_f,
- (internal_f.f_opthdr != 0
- ? &internal_a
- : (struct internal_aouthdr *) NULL));
-}
-
-/* Get the BFD section from a COFF symbol section number. */
-
-asection *
-coff_section_from_bfd_index (abfd, index)
- bfd *abfd;
- int index;
-{
- struct sec *answer = abfd->sections;
-
- if (index == N_ABS)
- return bfd_abs_section_ptr;
- if (index == N_UNDEF)
- return bfd_und_section_ptr;
- if (index == N_DEBUG)
- return bfd_abs_section_ptr;
-
- while (answer)
- {
- if (answer->target_index == index)
- return answer;
- answer = answer->next;
- }
-
- /* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
- has a bad symbol table in biglitpow.o. */
- return bfd_und_section_ptr;
-}
-
-/* Get the upper bound of a COFF symbol table. */
-
-long
-coff_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (!bfd_coff_slurp_symbol_table (abfd))
- return -1;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (coff_symbol_type *));
-}
-
-
-/* Canonicalize a COFF symbol table. */
-
-long
-coff_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int counter;
- coff_symbol_type *symbase;
- coff_symbol_type **location = (coff_symbol_type **) alocation;
-
- if (!bfd_coff_slurp_symbol_table (abfd))
- return -1;
-
- symbase = obj_symbols (abfd);
- counter = bfd_get_symcount (abfd);
- while (counter-- > 0)
- *location++ = symbase++;
-
- *location = NULL;
-
- return bfd_get_symcount (abfd);
-}
-
-/* Get the name of a symbol. The caller must pass in a buffer of size
- >= SYMNMLEN + 1. */
-
-const char *
-_bfd_coff_internal_syment_name (abfd, sym, buf)
- bfd *abfd;
- const struct internal_syment *sym;
- char *buf;
-{
- /* FIXME: It's not clear this will work correctly if sizeof
- (_n_zeroes) != 4. */
- if (sym->_n._n_n._n_zeroes != 0
- || sym->_n._n_n._n_offset == 0)
- {
- memcpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- return buf;
- }
- else
- {
- const char *strings;
-
- BFD_ASSERT (sym->_n._n_n._n_offset >= STRING_SIZE_SIZE);
- strings = obj_coff_strings (abfd);
- if (strings == NULL)
- {
- strings = _bfd_coff_read_string_table (abfd);
- if (strings == NULL)
- return NULL;
- }
- return strings + sym->_n._n_n._n_offset;
- }
-}
-
-/* Read in and swap the relocs. This returns a buffer holding the
- relocs for section SEC in file ABFD. If CACHE is true and
- INTERNAL_RELOCS is NULL, the relocs read in will be saved in case
- the function is called again. If EXTERNAL_RELOCS is not NULL, it
- is a buffer large enough to hold the unswapped relocs. If
- INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
- the swapped relocs. If REQUIRE_INTERNAL is true, then the return
- value must be INTERNAL_RELOCS. The function returns NULL on error. */
-
-struct internal_reloc *
-_bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
- require_internal, internal_relocs)
- bfd *abfd;
- asection *sec;
- boolean cache;
- bfd_byte *external_relocs;
- boolean require_internal;
- struct internal_reloc *internal_relocs;
-{
- bfd_size_type relsz;
- bfd_byte *free_external = NULL;
- struct internal_reloc *free_internal = NULL;
- bfd_byte *erel;
- bfd_byte *erel_end;
- struct internal_reloc *irel;
-
- if (coff_section_data (abfd, sec) != NULL
- && coff_section_data (abfd, sec)->relocs != NULL)
- {
- if (! require_internal)
- return coff_section_data (abfd, sec)->relocs;
- memcpy (internal_relocs, coff_section_data (abfd, sec)->relocs,
- sec->reloc_count * sizeof (struct internal_reloc));
- return internal_relocs;
- }
-
- relsz = bfd_coff_relsz (abfd);
-
- if (external_relocs == NULL)
- {
- free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
- if (free_external == NULL && sec->reloc_count > 0)
- goto error_return;
- external_relocs = free_external;
- }
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
- != relsz * sec->reloc_count))
- goto error_return;
-
- if (internal_relocs == NULL)
- {
- free_internal = ((struct internal_reloc *)
- bfd_malloc (sec->reloc_count
- * sizeof (struct internal_reloc)));
- if (free_internal == NULL && sec->reloc_count > 0)
- goto error_return;
- internal_relocs = free_internal;
- }
-
- /* Swap in the relocs. */
- erel = external_relocs;
- erel_end = erel + relsz * sec->reloc_count;
- irel = internal_relocs;
- for (; erel < erel_end; erel += relsz, irel++)
- bfd_coff_swap_reloc_in (abfd, (PTR) erel, (PTR) irel);
-
- if (free_external != NULL)
- {
- free (free_external);
- free_external = NULL;
- }
-
- if (cache && free_internal != NULL)
- {
- if (coff_section_data (abfd, sec) == NULL)
- {
- sec->used_by_bfd =
- (PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata));
- if (sec->used_by_bfd == NULL)
- goto error_return;
- coff_section_data (abfd, sec)->contents = NULL;
- }
- coff_section_data (abfd, sec)->relocs = free_internal;
- }
-
- return internal_relocs;
-
- error_return:
- if (free_external != NULL)
- free (free_external);
- if (free_internal != NULL)
- free (free_internal);
- return NULL;
-}
-
-/* Set lineno_count for the output sections of a COFF file. */
-
-int
-coff_count_linenumbers (abfd)
- bfd *abfd;
-{
- unsigned int limit = bfd_get_symcount (abfd);
- unsigned int i;
- int total = 0;
- asymbol **p;
- asection *s;
-
- if (limit == 0)
- {
- /* This may be from the backend linker, in which case the
- lineno_count in the sections is correct. */
- for (s = abfd->sections; s != NULL; s = s->next)
- total += s->lineno_count;
- return total;
- }
-
- for (s = abfd->sections; s != NULL; s = s->next)
- BFD_ASSERT (s->lineno_count == 0);
-
- for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
- {
- asymbol *q_maybe = *p;
-
- if (bfd_asymbol_flavour (q_maybe) == bfd_target_coff_flavour)
- {
- coff_symbol_type *q = coffsymbol (q_maybe);
-
- /* The AIX 4.1 compiler can sometimes generate line numbers
- attached to debugging symbols. We try to simply ignore
- those here. */
- if (q->lineno != NULL
- && q->symbol.section->owner != NULL)
- {
- /* This symbol has line numbers. Increment the owning
- section's linenumber count. */
- alent *l = q->lineno;
-
- ++q->symbol.section->output_section->lineno_count;
- ++total;
- ++l;
- while (l->line_number != 0)
- {
- ++total;
- ++q->symbol.section->output_section->lineno_count;
- ++l;
- }
- }
- }
- }
-
- return total;
-}
-
-/* Takes a bfd and a symbol, returns a pointer to the coff specific
- area of the symbol if there is one. */
-
-/*ARGSUSED*/
-coff_symbol_type *
-coff_symbol_from (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- if (bfd_asymbol_flavour (symbol) != bfd_target_coff_flavour)
- return (coff_symbol_type *) NULL;
-
- if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
- return (coff_symbol_type *) NULL;
-
- return (coff_symbol_type *) symbol;
-}
-
-static void
-fixup_symbol_value (coff_symbol_ptr, syment)
- coff_symbol_type *coff_symbol_ptr;
- struct internal_syment *syment;
-{
-
- /* Normalize the symbol flags */
- if (bfd_is_com_section (coff_symbol_ptr->symbol.section))
- {
- /* a common symbol is undefined with a value */
- syment->n_scnum = N_UNDEF;
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING)
- {
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- else if (bfd_is_und_section (coff_symbol_ptr->symbol.section))
- {
- syment->n_scnum = N_UNDEF;
- syment->n_value = 0;
- }
- else
- {
- if (coff_symbol_ptr->symbol.section)
- {
- syment->n_scnum =
- coff_symbol_ptr->symbol.section->output_section->target_index;
-
- syment->n_value =
- coff_symbol_ptr->symbol.value +
- coff_symbol_ptr->symbol.section->output_offset +
- coff_symbol_ptr->symbol.section->output_section->vma;
- }
- else
- {
- BFD_ASSERT (0);
- /* This can happen, but I don't know why yet (steve@cygnus.com) */
- syment->n_scnum = N_ABS;
- syment->n_value = coff_symbol_ptr->symbol.value;
- }
- }
-}
-
-/* Run through all the symbols in the symbol table and work out what
- their indexes into the symbol table will be when output.
-
- Coff requires that each C_FILE symbol points to the next one in the
- chain, and that the last one points to the first external symbol. We
- do that here too. */
-
-boolean
-coff_renumber_symbols (bfd_ptr, first_undef)
- bfd *bfd_ptr;
- int *first_undef;
-{
- unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
- asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
- unsigned int native_index = 0;
- struct internal_syment *last_file = (struct internal_syment *) NULL;
- unsigned int symbol_index;
-
- /* COFF demands that undefined symbols come after all other symbols.
- Since we don't need to impose this extra knowledge on all our
- client programs, deal with that here. Sort the symbol table;
- just move the undefined symbols to the end, leaving the rest
- alone. The O'Reilly book says that defined global symbols come
- at the end before the undefined symbols, so we do that here as
- well. */
- /* @@ Do we have some condition we could test for, so we don't always
- have to do this? I don't think relocatability is quite right, but
- I'm not certain. [raeburn:19920508.1711EST] */
- {
- asymbol **newsyms;
- unsigned int i;
-
- newsyms = (asymbol **) bfd_alloc_by_size_t (bfd_ptr,
- sizeof (asymbol *)
- * (symbol_count + 1));
- if (!newsyms)
- return false;
- bfd_ptr->outsymbols = newsyms;
- for (i = 0; i < symbol_count; i++)
- if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
- || (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
- && !bfd_is_com_section (symbol_ptr_ptr[i]->section)
- && ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_FUNCTION))
- != BSF_GLOBAL)))
- *newsyms++ = symbol_ptr_ptr[i];
-
- for (i = 0; i < symbol_count; i++)
- if (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
- && (bfd_is_com_section (symbol_ptr_ptr[i]->section)
- || ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL
- | BSF_NOT_AT_END
- | BSF_FUNCTION))
- == BSF_GLOBAL)))
- *newsyms++ = symbol_ptr_ptr[i];
-
- *first_undef = newsyms - bfd_ptr->outsymbols;
-
- for (i = 0; i < symbol_count; i++)
- if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
- && bfd_is_und_section (symbol_ptr_ptr[i]->section))
- *newsyms++ = symbol_ptr_ptr[i];
- *newsyms = (asymbol *) NULL;
- symbol_ptr_ptr = bfd_ptr->outsymbols;
- }
-
- for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
- {
- coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
- symbol_ptr_ptr[symbol_index]->udata.i = symbol_index;
- if (coff_symbol_ptr && coff_symbol_ptr->native)
- {
- combined_entry_type *s = coff_symbol_ptr->native;
- int i;
-
- if (s->u.syment.n_sclass == C_FILE)
- {
- if (last_file != (struct internal_syment *) NULL)
- last_file->n_value = native_index;
- last_file = &(s->u.syment);
- }
- else
- {
-
- /* Modify the symbol values according to their section and
- type */
-
- fixup_symbol_value (coff_symbol_ptr, &(s->u.syment));
- }
- for (i = 0; i < s->u.syment.n_numaux + 1; i++)
- s[i].offset = native_index++;
- }
- else
- {
- native_index++;
- }
- }
- obj_conv_table_size (bfd_ptr) = native_index;
-
- return true;
-}
-
-/* Run thorough the symbol table again, and fix it so that all
- pointers to entries are changed to the entries' index in the output
- symbol table. */
-
-void
-coff_mangle_symbols (bfd_ptr)
- bfd *bfd_ptr;
-{
- unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
- asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
- unsigned int symbol_index;
-
- for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
- {
- coff_symbol_type *coff_symbol_ptr =
- coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
-
- if (coff_symbol_ptr && coff_symbol_ptr->native)
- {
- int i;
- combined_entry_type *s = coff_symbol_ptr->native;
-
- if (s->fix_value)
- {
- /* FIXME: We should use a union here. */
- s->u.syment.n_value =
- ((combined_entry_type *) s->u.syment.n_value)->offset;
- s->fix_value = 0;
- }
- if (s->fix_line)
- {
- /* The value is the offset into the line number entries
- for the symbol's section. On output, the symbol's
- section should be N_DEBUG. */
- s->u.syment.n_value =
- (coff_symbol_ptr->symbol.section->output_section->line_filepos
- + s->u.syment.n_value * bfd_coff_linesz (bfd_ptr));
- coff_symbol_ptr->symbol.section =
- coff_section_from_bfd_index (bfd_ptr, N_DEBUG);
- BFD_ASSERT (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING);
- }
- for (i = 0; i < s->u.syment.n_numaux; i++)
- {
- combined_entry_type *a = s + i + 1;
- if (a->fix_tag)
- {
- a->u.auxent.x_sym.x_tagndx.l =
- a->u.auxent.x_sym.x_tagndx.p->offset;
- a->fix_tag = 0;
- }
- if (a->fix_end)
- {
- a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
- a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
- a->fix_end = 0;
- }
- if (a->fix_scnlen)
- {
- a->u.auxent.x_csect.x_scnlen.l =
- a->u.auxent.x_csect.x_scnlen.p->offset;
- a->fix_scnlen = 0;
- }
- }
- }
- }
-}
-
-static void
-coff_fix_symbol_name (abfd, symbol, native, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- combined_entry_type *native;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- unsigned int name_length;
- union internal_auxent *auxent;
- char *name = (char *) (symbol->name);
-
- if (name == (char *) NULL)
- {
- /* coff symbols always have names, so we'll make one up */
- symbol->name = "strange";
- name = (char *) symbol->name;
- }
- name_length = strlen (name);
-
- if (native->u.syment.n_sclass == C_FILE
- && native->u.syment.n_numaux > 0)
- {
- strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
- auxent = &(native + 1)->u.auxent;
-
- if (bfd_coff_long_filenames (abfd))
- {
- if (name_length <= FILNMLEN)
- {
- strncpy (auxent->x_file.x_fname, name, FILNMLEN);
- }
- else
- {
- auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
- auxent->x_file.x_n.x_zeroes = 0;
- *string_size_p += name_length + 1;
- }
- }
- else
- {
- strncpy (auxent->x_file.x_fname, name, FILNMLEN);
- if (name_length > FILNMLEN)
- {
- name[FILNMLEN] = '\0';
- }
- }
- }
- else
- {
- if (name_length <= SYMNMLEN)
- {
- /* This name will fit into the symbol neatly */
- strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN);
- }
- else if (!bfd_coff_symname_in_debug (abfd, &native->u.syment))
- {
- native->u.syment._n._n_n._n_offset = (*string_size_p
- + STRING_SIZE_SIZE);
- native->u.syment._n._n_n._n_zeroes = 0;
- *string_size_p += name_length + 1;
- }
- else
- {
- long filepos;
- bfd_byte buf[2];
-
- /* This name should be written into the .debug section. For
- some reason each name is preceded by a two byte length
- and also followed by a null byte. FIXME: We assume that
- the .debug section has already been created, and that it
- is large enough. */
- if (*debug_string_section_p == (asection *) NULL)
- *debug_string_section_p = bfd_get_section_by_name (abfd, ".debug");
- filepos = bfd_tell (abfd);
- bfd_put_16 (abfd, name_length + 1, buf);
- if (!bfd_set_section_contents (abfd,
- *debug_string_section_p,
- (PTR) buf,
- (file_ptr) *debug_string_size_p,
- (bfd_size_type) 2)
- || !bfd_set_section_contents (abfd,
- *debug_string_section_p,
- (PTR) symbol->name,
- ((file_ptr) *debug_string_size_p
- + 2),
- (bfd_size_type) name_length + 1))
- abort ();
- if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
- abort ();
- native->u.syment._n._n_n._n_offset = *debug_string_size_p + 2;
- native->u.syment._n._n_n._n_zeroes = 0;
- *debug_string_size_p += name_length + 3;
- }
- }
-}
-
-/* We need to keep track of the symbol index so that when we write out
- the relocs we can get the index for a symbol. This method is a
- hack. FIXME. */
-
-#define set_index(symbol, idx) ((symbol)->udata.i = (idx))
-
-/* Write a symbol out to a COFF file. */
-
-static boolean
-coff_write_symbol (abfd, symbol, native, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- combined_entry_type *native;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- unsigned int numaux = native->u.syment.n_numaux;
- int type = native->u.syment.n_type;
- int class = native->u.syment.n_sclass;
- PTR buf;
- bfd_size_type symesz;
-
- if (native->u.syment.n_sclass == C_FILE)
- symbol->flags |= BSF_DEBUGGING;
-
- if (symbol->flags & BSF_DEBUGGING
- && bfd_is_abs_section (symbol->section))
- {
- native->u.syment.n_scnum = N_DEBUG;
- }
- else if (bfd_is_abs_section (symbol->section))
- {
- native->u.syment.n_scnum = N_ABS;
- }
- else if (bfd_is_und_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- }
- else
- {
- native->u.syment.n_scnum =
- symbol->section->output_section->target_index;
- }
-
- coff_fix_symbol_name (abfd, symbol, native, string_size_p,
- debug_string_section_p, debug_string_size_p);
-
- symesz = bfd_coff_symesz (abfd);
- buf = bfd_alloc (abfd, symesz);
- if (!buf)
- return false;
- bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
- if (bfd_write (buf, 1, symesz, abfd) != symesz)
- return false;
- bfd_release (abfd, buf);
-
- if (native->u.syment.n_numaux > 0)
- {
- bfd_size_type auxesz;
- unsigned int j;
-
- auxesz = bfd_coff_auxesz (abfd);
- buf = bfd_alloc (abfd, auxesz);
- if (!buf)
- return false;
- for (j = 0; j < native->u.syment.n_numaux; j++)
- {
- bfd_coff_swap_aux_out (abfd,
- &((native + j + 1)->u.auxent),
- type,
- class,
- j,
- native->u.syment.n_numaux,
- buf);
- if (bfd_write (buf, 1, auxesz, abfd) != auxesz)
- return false;
- }
- bfd_release (abfd, buf);
- }
-
- /* Store the index for use when we write out the relocs. */
- set_index (symbol, *written);
-
- *written += numaux + 1;
- return true;
-}
-
-/* Write out a symbol to a COFF file that does not come from a COFF
- file originally. This symbol may have been created by the linker,
- or we may be linking a non COFF file to a COFF file. */
-
-static boolean
-coff_write_alien_symbol (abfd, symbol, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- asymbol *symbol;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- combined_entry_type *native;
- combined_entry_type dummy;
-
- native = &dummy;
- native->u.syment.n_type = T_NULL;
- native->u.syment.n_flags = 0;
- if (bfd_is_und_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- native->u.syment.n_value = symbol->value;
- }
- else if (bfd_is_com_section (symbol->section))
- {
- native->u.syment.n_scnum = N_UNDEF;
- native->u.syment.n_value = symbol->value;
- }
- else if (symbol->flags & BSF_DEBUGGING)
- {
- /* There isn't much point to writing out a debugging symbol
- unless we are prepared to convert it into COFF debugging
- format. So, we just ignore them. We must clobber the symbol
- name to keep it from being put in the string table. */
- symbol->name = "";
- return true;
- }
- else
- {
- native->u.syment.n_scnum =
- symbol->section->output_section->target_index;
- native->u.syment.n_value = (symbol->value
- + symbol->section->output_section->vma
- + symbol->section->output_offset);
-
- /* Copy the any flags from the the file header into the symbol.
- FIXME: Why? */
- {
- coff_symbol_type *c = coff_symbol_from (abfd, symbol);
- if (c != (coff_symbol_type *) NULL)
- native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags;
- }
- }
-
- native->u.syment.n_type = 0;
- if (symbol->flags & BSF_LOCAL)
- native->u.syment.n_sclass = C_STAT;
- else
- native->u.syment.n_sclass = C_EXT;
- native->u.syment.n_numaux = 0;
-
- return coff_write_symbol (abfd, symbol, native, written, string_size_p,
- debug_string_section_p, debug_string_size_p);
-}
-
-/* Write a native symbol to a COFF file. */
-
-static boolean
-coff_write_native_symbol (abfd, symbol, written, string_size_p,
- debug_string_section_p, debug_string_size_p)
- bfd *abfd;
- coff_symbol_type *symbol;
- unsigned int *written;
- bfd_size_type *string_size_p;
- asection **debug_string_section_p;
- bfd_size_type *debug_string_size_p;
-{
- combined_entry_type *native = symbol->native;
- alent *lineno = symbol->lineno;
-
- /* If this symbol has an associated line number, we must store the
- symbol index in the line number field. We also tag the auxent to
- point to the right place in the lineno table. */
- if (lineno && !symbol->done_lineno && symbol->symbol.section->owner != NULL)
- {
- unsigned int count = 0;
- lineno[count].u.offset = *written;
- if (native->u.syment.n_numaux)
- {
- union internal_auxent *a = &((native + 1)->u.auxent);
-
- a->x_sym.x_fcnary.x_fcn.x_lnnoptr =
- symbol->symbol.section->output_section->moving_line_filepos;
- }
-
- /* Count and relocate all other linenumbers. */
- count++;
- while (lineno[count].line_number != 0)
- {
-#if 0
- /* 13 april 92. sac
- I've been told this, but still need proof:
- > The second bug is also in `bfd/coffcode.h'. This bug
- > causes the linker to screw up the pc-relocations for
- > all the line numbers in COFF code. This bug isn't only
- > specific to A29K implementations, but affects all
- > systems using COFF format binaries. Note that in COFF
- > object files, the line number core offsets output by
- > the assembler are relative to the start of each
- > procedure, not to the start of the .text section. This
- > patch relocates the line numbers relative to the
- > `native->u.syment.n_value' instead of the section
- > virtual address.
- > modular!olson@cs.arizona.edu (Jon Olson)
- */
- lineno[count].u.offset += native->u.syment.n_value;
-#else
- lineno[count].u.offset +=
- (symbol->symbol.section->output_section->vma
- + symbol->symbol.section->output_offset);
-#endif
- count++;
- }
- symbol->done_lineno = true;
-
- symbol->symbol.section->output_section->moving_line_filepos +=
- count * bfd_coff_linesz (abfd);
- }
-
- return coff_write_symbol (abfd, &(symbol->symbol), native, written,
- string_size_p, debug_string_section_p,
- debug_string_size_p);
-}
-
-/* Write out the COFF symbols. */
-
-boolean
-coff_write_symbols (abfd)
- bfd *abfd;
-{
- bfd_size_type string_size;
- asection *debug_string_section;
- bfd_size_type debug_string_size;
- unsigned int i;
- unsigned int limit = bfd_get_symcount (abfd);
- unsigned int written = 0;
- asymbol **p;
-
- string_size = 0;
- debug_string_section = NULL;
- debug_string_size = 0;
-
- /* Seek to the right place */
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
- return false;
-
- /* Output all the symbols we have */
-
- written = 0;
- for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
- {
- asymbol *symbol = *p;
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol);
-
- if (c_symbol == (coff_symbol_type *) NULL
- || c_symbol->native == (combined_entry_type *) NULL)
- {
- if (!coff_write_alien_symbol (abfd, symbol, &written, &string_size,
- &debug_string_section,
- &debug_string_size))
- return false;
- }
- else
- {
- if (!coff_write_native_symbol (abfd, c_symbol, &written,
- &string_size, &debug_string_section,
- &debug_string_size))
- return false;
- }
- }
-
- obj_raw_syment_count (abfd) = written;
-
- /* Now write out strings */
-
- if (string_size != 0)
- {
- unsigned int size = string_size + STRING_SIZE_SIZE;
- bfd_byte buffer[STRING_SIZE_SIZE];
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
-#else
- #error Change bfd_h_put_32
-#endif
- if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
- return false;
- for (p = abfd->outsymbols, i = 0;
- i < limit;
- i++, p++)
- {
- asymbol *q = *p;
- size_t name_length = strlen (q->name);
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, q);
- size_t maxlen;
-
- /* Figure out whether the symbol name should go in the string
- table. Symbol names that are short enough are stored
- directly in the syment structure. File names permit a
- different, longer, length in the syment structure. On
- XCOFF, some symbol names are stored in the .debug section
- rather than in the string table. */
-
- if (c_symbol == NULL
- || c_symbol->native == NULL)
- {
- /* This is not a COFF symbol, so it certainly is not a
- file name, nor does it go in the .debug section. */
- maxlen = SYMNMLEN;
- }
- else if (bfd_coff_symname_in_debug (abfd,
- &c_symbol->native->u.syment))
- {
- /* This symbol name is in the XCOFF .debug section.
- Don't write it into the string table. */
- maxlen = name_length;
- }
- else if (c_symbol->native->u.syment.n_sclass == C_FILE
- && c_symbol->native->u.syment.n_numaux > 0)
- maxlen = FILNMLEN;
- else
- maxlen = SYMNMLEN;
-
- if (name_length > maxlen)
- {
- if (bfd_write ((PTR) (q->name), 1, name_length + 1, abfd)
- != name_length + 1)
- return false;
- }
- }
- }
- else
- {
- /* We would normally not write anything here, but we'll write
- out 4 so that any stupid coff reader which tries to read the
- string table even when there isn't one won't croak. */
- unsigned int size = STRING_SIZE_SIZE;
- bfd_byte buffer[STRING_SIZE_SIZE];
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
-#else
- #error Change bfd_h_put_32
-#endif
- if (bfd_write ((PTR) buffer, 1, STRING_SIZE_SIZE, abfd)
- != STRING_SIZE_SIZE)
- return false;
- }
-
- /* Make sure the .debug section was created to be the correct size.
- We should create it ourselves on the fly, but we don't because
- BFD won't let us write to any section until we know how large all
- the sections are. We could still do it by making another pass
- over the symbols. FIXME. */
- BFD_ASSERT (debug_string_size == 0
- || (debug_string_section != (asection *) NULL
- && (BFD_ALIGN (debug_string_size,
- 1 << debug_string_section->alignment_power)
- == bfd_section_size (abfd, debug_string_section))));
-
- return true;
-}
-
-boolean
-coff_write_linenumbers (abfd)
- bfd *abfd;
-{
- asection *s;
- bfd_size_type linesz;
- PTR buff;
-
- linesz = bfd_coff_linesz (abfd);
- buff = bfd_alloc (abfd, linesz);
- if (!buff)
- return false;
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- if (s->lineno_count)
- {
- asymbol **q = abfd->outsymbols;
- if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0)
- return false;
- /* Find all the linenumbers in this section */
- while (*q)
- {
- asymbol *p = *q;
- if (p->section->output_section == s)
- {
- alent *l =
- BFD_SEND (bfd_asymbol_bfd (p), _get_lineno,
- (bfd_asymbol_bfd (p), p));
- if (l)
- {
- /* Found a linenumber entry, output */
- struct internal_lineno out;
- memset ((PTR) & out, 0, sizeof (out));
- out.l_lnno = 0;
- out.l_addr.l_symndx = l->u.offset;
- bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
- return false;
- l++;
- while (l->line_number)
- {
- out.l_lnno = l->line_number;
- out.l_addr.l_symndx = l->u.offset;
- bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
- return false;
- l++;
- }
- }
- }
- q++;
- }
- }
- }
- bfd_release (abfd, buff);
- return true;
-}
-
-/*ARGSUSED */
-alent *
-coff_get_lineno (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- return coffsymbol (symbol)->lineno;
-}
-
-#if 0
-
-/* This is only called from coff_add_missing_symbols, which has been
- disabled. */
-
-asymbol *
-coff_section_symbol (abfd, name)
- bfd *abfd;
- char *name;
-{
- asection *sec = bfd_make_section_old_way (abfd, name);
- asymbol *sym;
- combined_entry_type *csym;
-
- sym = sec->symbol;
- csym = coff_symbol_from (abfd, sym)->native;
- /* Make sure back-end COFF stuff is there. */
- if (csym == 0)
- {
- struct foo
- {
- coff_symbol_type sym;
- /* @@FIXME This shouldn't use a fixed size!! */
- combined_entry_type e[10];
- };
- struct foo *f;
- f = (struct foo *) bfd_alloc_by_size_t (abfd, sizeof (*f));
- if (!f)
- {
- bfd_set_error (bfd_error_no_error);
- return NULL;
- }
- memset ((char *) f, 0, sizeof (*f));
- coff_symbol_from (abfd, sym)->native = csym = f->e;
- }
- csym[0].u.syment.n_sclass = C_STAT;
- csym[0].u.syment.n_numaux = 1;
-/* SF_SET_STATICS (sym); @@ ??? */
- csym[1].u.auxent.x_scn.x_scnlen = sec->_raw_size;
- csym[1].u.auxent.x_scn.x_nreloc = sec->reloc_count;
- csym[1].u.auxent.x_scn.x_nlinno = sec->lineno_count;
-
- if (sec->output_section == NULL)
- {
- sec->output_section = sec;
- sec->output_offset = 0;
- }
-
- return sym;
-}
-
-#endif /* 0 */
-
-/* This function transforms the offsets into the symbol table into
- pointers to syments. */
-
-static void
-coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent)
- bfd *abfd;
- combined_entry_type *table_base;
- combined_entry_type *symbol;
- unsigned int indaux;
- combined_entry_type *auxent;
-{
- int type = symbol->u.syment.n_type;
- int class = symbol->u.syment.n_sclass;
-
- if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
- {
- if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
- (abfd, table_base, symbol, indaux, auxent))
- return;
- }
-
- /* Don't bother if this is a file or a section */
- if (class == C_STAT && type == T_NULL)
- return;
- if (class == C_FILE)
- return;
-
- /* Otherwise patch up */
-#define N_TMASK coff_data (abfd)->local_n_tmask
-#define N_BTSHFT coff_data (abfd)->local_n_btshft
- if ((ISFCN (type) || ISTAG (class) || class == C_BLOCK)
- && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0)
- {
- auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p =
- table_base + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
- auxent->fix_end = 1;
- }
- /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
- generate one, so we must be careful to ignore it. */
- if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
- {
- auxent->u.auxent.x_sym.x_tagndx.p =
- table_base + auxent->u.auxent.x_sym.x_tagndx.l;
- auxent->fix_tag = 1;
- }
-}
-
-/* Allocate space for the ".debug" section, and read it.
- We did not read the debug section until now, because
- we didn't want to go to the trouble until someone needed it. */
-
-static char *
-build_debug_section (abfd)
- bfd *abfd;
-{
- char *debug_section;
- long position;
-
- asection *sect = bfd_get_section_by_name (abfd, ".debug");
-
- if (!sect)
- {
- bfd_set_error (bfd_error_no_debug_section);
- return NULL;
- }
-
- debug_section = (PTR) bfd_alloc (abfd,
- bfd_get_section_size_before_reloc (sect));
- if (debug_section == NULL)
- return NULL;
-
- /* Seek to the beginning of the `.debug' section and read it.
- Save the current position first; it is needed by our caller.
- Then read debug section and reset the file pointer. */
-
- position = bfd_tell (abfd);
- if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
- || (bfd_read (debug_section,
- bfd_get_section_size_before_reloc (sect), 1, abfd)
- != bfd_get_section_size_before_reloc (sect))
- || bfd_seek (abfd, position, SEEK_SET) != 0)
- return NULL;
- return debug_section;
-}
-
-
-/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
- \0-terminated, but will not exceed 'maxlen' characters. The copy *will*
- be \0-terminated. */
-static char *
-copy_name (abfd, name, maxlen)
- bfd *abfd;
- char *name;
- int maxlen;
-{
- int len;
- char *newname;
-
- for (len = 0; len < maxlen; ++len)
- {
- if (name[len] == '\0')
- {
- break;
- }
- }
-
- if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
- return (NULL);
- strncpy (newname, name, len);
- newname[len] = '\0';
- return newname;
-}
-
-/* Read in the external symbols. */
-
-boolean
-_bfd_coff_get_external_symbols (abfd)
- bfd *abfd;
-{
- bfd_size_type symesz;
- size_t size;
- PTR syms;
-
- if (obj_coff_external_syms (abfd) != NULL)
- return true;
-
- symesz = bfd_coff_symesz (abfd);
-
- size = obj_raw_syment_count (abfd) * symesz;
-
- syms = (PTR) bfd_malloc (size);
- if (syms == NULL && size != 0)
- return false;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read (syms, size, 1, abfd) != size)
- {
- if (syms != NULL)
- free (syms);
- return false;
- }
-
- obj_coff_external_syms (abfd) = syms;
-
- return true;
-}
-
-/* Read in the external strings. The strings are not loaded until
- they are needed. This is because we have no simple way of
- detecting a missing string table in an archive. */
-
-const char *
-_bfd_coff_read_string_table (abfd)
- bfd *abfd;
-{
- char extstrsize[STRING_SIZE_SIZE];
- size_t strsize;
- char *strings;
-
- if (obj_coff_strings (abfd) != NULL)
- return obj_coff_strings (abfd);
-
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd)),
- SEEK_SET) != 0)
- return NULL;
-
- if (bfd_read (extstrsize, sizeof extstrsize, 1, abfd) != sizeof extstrsize)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- return NULL;
-
- /* There is no string table. */
- strsize = STRING_SIZE_SIZE;
- }
- else
- {
-#if STRING_SIZE_SIZE == 4
- strsize = bfd_h_get_32 (abfd, (bfd_byte *) extstrsize);
-#else
- #error Change bfd_h_get_32
-#endif
- }
-
- if (strsize < STRING_SIZE_SIZE)
- {
- (*_bfd_error_handler)
- ("%s: bad string table size %lu", bfd_get_filename (abfd),
- (unsigned long) strsize);
- bfd_set_error (bfd_error_bad_value);
- return NULL;
- }
-
- strings = (char *) bfd_malloc (strsize);
- if (strings == NULL)
- return NULL;
-
- if (bfd_read (strings + STRING_SIZE_SIZE,
- strsize - STRING_SIZE_SIZE, 1, abfd)
- != strsize - STRING_SIZE_SIZE)
- {
- free (strings);
- return NULL;
- }
-
- obj_coff_strings (abfd) = strings;
-
- return strings;
-}
-
-/* Free up the external symbols and strings read from a COFF file. */
-
-boolean
-_bfd_coff_free_symbols (abfd)
- bfd *abfd;
-{
- if (obj_coff_external_syms (abfd) != NULL
- && ! obj_coff_keep_syms (abfd))
- {
- free (obj_coff_external_syms (abfd));
- obj_coff_external_syms (abfd) = NULL;
- }
- if (obj_coff_strings (abfd) != NULL
- && ! obj_coff_keep_strings (abfd))
- {
- free (obj_coff_strings (abfd));
- obj_coff_strings (abfd) = NULL;
- }
- return true;
-}
-
-/* Read a symbol table into freshly bfd_allocated memory, swap it, and
- knit the symbol names into a normalized form. By normalized here I
- mean that all symbols have an n_offset pointer that points to a null-
- terminated string. */
-
-combined_entry_type *
-coff_get_normalized_symtab (abfd)
- bfd *abfd;
-{
- combined_entry_type *internal;
- combined_entry_type *internal_ptr;
- combined_entry_type *symbol_ptr;
- combined_entry_type *internal_end;
- bfd_size_type symesz;
- char *raw_src;
- char *raw_end;
- const char *string_table = NULL;
- char *debug_section = NULL;
- unsigned long size;
-
- if (obj_raw_syments (abfd) != NULL)
- return obj_raw_syments (abfd);
-
- size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
- internal = (combined_entry_type *) bfd_zalloc (abfd, size);
- if (internal == NULL && size != 0)
- return NULL;
- internal_end = internal + obj_raw_syment_count (abfd);
-
- if (! _bfd_coff_get_external_symbols (abfd))
- return NULL;
-
- raw_src = (char *) obj_coff_external_syms (abfd);
-
- /* mark the end of the symbols */
- symesz = bfd_coff_symesz (abfd);
- raw_end = (char *) raw_src + obj_raw_syment_count (abfd) * symesz;
-
- /* FIXME SOMEDAY. A string table size of zero is very weird, but
- probably possible. If one shows up, it will probably kill us. */
-
- /* Swap all the raw entries */
- for (internal_ptr = internal;
- raw_src < raw_end;
- raw_src += symesz, internal_ptr++)
- {
-
- unsigned int i;
- bfd_coff_swap_sym_in (abfd, (PTR) raw_src,
- (PTR) & internal_ptr->u.syment);
- symbol_ptr = internal_ptr;
-
- for (i = 0;
- i < symbol_ptr->u.syment.n_numaux;
- i++)
- {
- internal_ptr++;
- raw_src += symesz;
- bfd_coff_swap_aux_in (abfd, (PTR) raw_src,
- symbol_ptr->u.syment.n_type,
- symbol_ptr->u.syment.n_sclass,
- i, symbol_ptr->u.syment.n_numaux,
- &(internal_ptr->u.auxent));
- coff_pointerize_aux (abfd, internal, symbol_ptr, i,
- internal_ptr);
- }
- }
-
- /* Free the raw symbols, but not the strings (if we have them). */
- obj_coff_keep_strings (abfd) = true;
- if (! _bfd_coff_free_symbols (abfd))
- return NULL;
-
- for (internal_ptr = internal; internal_ptr < internal_end;
- internal_ptr++)
- {
- if (internal_ptr->u.syment.n_sclass == C_FILE
- && internal_ptr->u.syment.n_numaux > 0)
- {
- /* make a file symbol point to the name in the auxent, since
- the text ".file" is redundant */
- if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0)
- {
- /* the filename is a long one, point into the string table */
- if (string_table == NULL)
- {
- string_table = _bfd_coff_read_string_table (abfd);
- if (string_table == NULL)
- return NULL;
- }
-
- internal_ptr->u.syment._n._n_n._n_offset =
- ((long)
- (string_table
- + (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset));
- }
- else
- {
- /* ordinary short filename, put into memory anyway */
- internal_ptr->u.syment._n._n_n._n_offset = (long)
- copy_name (abfd, (internal_ptr + 1)->u.auxent.x_file.x_fname,
- FILNMLEN);
- }
- }
- else
- {
- if (internal_ptr->u.syment._n._n_n._n_zeroes != 0)
- {
- /* This is a "short" name. Make it long. */
- unsigned long i = 0;
- char *newstring = NULL;
-
- /* find the length of this string without walking into memory
- that isn't ours. */
- for (i = 0; i < 8; ++i)
- {
- if (internal_ptr->u.syment._n._n_name[i] == '\0')
- {
- break;
- } /* if end of string */
- } /* possible lengths of this string. */
-
- if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
- return (NULL);
- memset (newstring, 0, i);
- strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
- internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
- internal_ptr->u.syment._n._n_n._n_zeroes = 0;
- }
- else if (internal_ptr->u.syment._n._n_n._n_offset == 0)
- internal_ptr->u.syment._n._n_n._n_offset = (long int) "";
- else if (!bfd_coff_symname_in_debug (abfd, &internal_ptr->u.syment))
- {
- /* Long name already. Point symbol at the string in the
- table. */
- if (string_table == NULL)
- {
- string_table = _bfd_coff_read_string_table (abfd);
- if (string_table == NULL)
- return NULL;
- }
- internal_ptr->u.syment._n._n_n._n_offset =
- ((long int)
- (string_table
- + internal_ptr->u.syment._n._n_n._n_offset));
- }
- else
- {
- /* Long name in debug section. Very similar. */
- if (debug_section == NULL)
- debug_section = build_debug_section (abfd);
- internal_ptr->u.syment._n._n_n._n_offset = (long int)
- (debug_section + internal_ptr->u.syment._n._n_n._n_offset);
- }
- }
- internal_ptr += internal_ptr->u.syment.n_numaux;
- }
-
- obj_raw_syments (abfd) = internal;
- BFD_ASSERT (obj_raw_syment_count (abfd)
- == (unsigned int) (internal_ptr - internal));
-
- return (internal);
-} /* coff_get_normalized_symtab() */
-
-long
-coff_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-asymbol *
-coff_make_empty_symbol (abfd)
- bfd *abfd;
-{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
- if (new == NULL)
- return (NULL);
- memset (new, 0, sizeof *new);
- new->symbol.section = 0;
- new->native = 0;
- new->lineno = (alent *) NULL;
- new->done_lineno = false;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/* Make a debugging symbol. */
-
-asymbol *
-coff_bfd_make_debug_symbol (abfd, ptr, sz)
- bfd *abfd;
- PTR ptr;
- unsigned long sz;
-{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
- if (new == NULL)
- return (NULL);
- /* @@ This shouldn't be using a constant multiplier. */
- new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
- if (!new->native)
- return (NULL);
- new->symbol.section = bfd_abs_section_ptr;
- new->symbol.flags = BSF_DEBUGGING;
- new->lineno = (alent *) NULL;
- new->done_lineno = false;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/*ARGSUSED */
-void
-coff_get_symbol_info (abfd, symbol, ret)
- bfd *abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
- if (coffsymbol (symbol)->native != NULL
- && coffsymbol (symbol)->native->fix_value)
- {
- combined_entry_type *psym;
-
- psym = ((combined_entry_type *)
- coffsymbol (symbol)->native->u.syment.n_value);
- ret->value = (bfd_vma) (psym - obj_raw_syments (abfd));
- }
-}
-
-/* Print out information about COFF symbol. */
-
-void
-coff_print_symbol (abfd, filep, symbol, how)
- bfd *abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
-
- case bfd_print_symbol_more:
- fprintf (file, "coff %s %s",
- coffsymbol (symbol)->native ? "n" : "g",
- coffsymbol (symbol)->lineno ? "l" : " ");
- break;
-
- case bfd_print_symbol_all:
- if (coffsymbol (symbol)->native)
- {
- unsigned long val;
- unsigned int aux;
- combined_entry_type *combined = coffsymbol (symbol)->native;
- combined_entry_type *root = obj_raw_syments (abfd);
- struct lineno_cache_entry *l = coffsymbol (symbol)->lineno;
-
- fprintf (file, "[%3ld]", (long) (combined - root));
-
- if (! combined->fix_value)
- val = (unsigned long) combined->u.syment.n_value;
- else
- val = ((unsigned long)
- ((combined_entry_type *) combined->u.syment.n_value
- - root));
-
- fprintf (file,
- "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
- combined->u.syment.n_scnum,
- combined->u.syment.n_flags,
- combined->u.syment.n_type,
- combined->u.syment.n_sclass,
- combined->u.syment.n_numaux,
- val,
- symbol->name);
-
- for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
- {
- combined_entry_type *auxp = combined + aux + 1;
- long tagndx;
-
- if (auxp->fix_tag)
- tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root;
- else
- tagndx = auxp->u.auxent.x_sym.x_tagndx.l;
-
- fprintf (file, "\n");
-
- if (bfd_coff_print_aux (abfd, file, root, combined, auxp, aux))
- continue;
-
- switch (combined->u.syment.n_sclass)
- {
- case C_FILE:
- fprintf (file, "File ");
- break;
-
- case C_STAT:
- if (combined->u.syment.n_type == T_NULL)
- /* probably a section symbol? */
- {
- fprintf (file, "AUX scnlen 0x%lx nreloc %d nlnno %d",
- (long) auxp->u.auxent.x_scn.x_scnlen,
- auxp->u.auxent.x_scn.x_nreloc,
- auxp->u.auxent.x_scn.x_nlinno);
- break;
- }
- /* else fall through */
-
- default:
- fprintf (file, "AUX lnno %d size 0x%x tagndx %ld",
- auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
- auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size,
- tagndx);
- if (auxp->fix_end)
- fprintf (file, " endndx %ld",
- ((long)
- (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
- - root)));
- break;
- }
- }
-
- if (l)
- {
- fprintf (file, "\n%s :", l->u.sym->name);
- l++;
- while (l->line_number)
- {
- fprintf (file, "\n%4d : 0x%lx",
- l->line_number,
- ((unsigned long)
- (l->u.offset + symbol->section->vma)));
- l++;
- }
- }
- }
- else
- {
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %-5s %s %s %s",
- symbol->section->name,
- coffsymbol (symbol)->native ? "n" : "g",
- coffsymbol (symbol)->lineno ? "l" : " ",
- symbol->name);
- }
- }
-}
-
-/* Provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location. */
-
-/*ARGSUSED*/
-boolean
-coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
- functionname_ptr, line_ptr)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *line_ptr;
-{
- boolean found;
- unsigned int i;
- unsigned int line_base;
- coff_data_type *cof = coff_data (abfd);
- /* Run through the raw syments if available */
- combined_entry_type *p;
- combined_entry_type *pend;
- alent *l;
- struct coff_section_tdata *sec_data;
-
- /* Before looking through the symbol table, try to use a .stab
- section to find the information. */
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &coff_data (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- *filename_ptr = 0;
- *functionname_ptr = 0;
- *line_ptr = 0;
-
- /* Don't try and find line numbers in a non coff file */
- if (abfd->xvec->flavour != bfd_target_coff_flavour)
- return false;
-
- if (cof == NULL)
- return false;
-
- /* Find the first C_FILE symbol. */
- p = cof->raw_syments;
- pend = p + cof->raw_syment_count;
- while (p < pend)
- {
- if (p->u.syment.n_sclass == C_FILE)
- break;
- p += 1 + p->u.syment.n_numaux;
- }
-
- if (p < pend)
- {
- bfd_vma maxdiff;
-
- /* Look through the C_FILE symbols to find the best one. */
- *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- maxdiff = (bfd_vma) 0 - (bfd_vma) 1;
- while (1)
- {
- combined_entry_type *p2;
-
- for (p2 = p + 1 + p->u.syment.n_numaux;
- p2 < pend;
- p2 += 1 + p2->u.syment.n_numaux)
- {
- if (p2->u.syment.n_scnum > 0
- && (section
- == coff_section_from_bfd_index (abfd,
- p2->u.syment.n_scnum)))
- break;
- if (p2->u.syment.n_sclass == C_FILE)
- {
- p2 = pend;
- break;
- }
- }
-
- if (p2 < pend
- && offset >= (bfd_vma) p2->u.syment.n_value
- && offset - (bfd_vma) p2->u.syment.n_value < maxdiff)
- {
- *filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
- maxdiff = offset - p2->u.syment.n_value;
- }
-
- /* Avoid endless loops on erroneous files by ensuring that
- we always move forward in the file. */
- if (p - cof->raw_syments >= p->u.syment.n_value)
- break;
-
- p = cof->raw_syments + p->u.syment.n_value;
- if (p > pend || p->u.syment.n_sclass != C_FILE)
- break;
- }
- }
-
- /* Now wander though the raw linenumbers of the section */
- /* If we have been called on this section before, and the offset we
- want is further down then we can prime the lookup loop. */
- sec_data = coff_section_data (abfd, section);
- if (sec_data != NULL
- && sec_data->i > 0
- && offset >= sec_data->offset)
- {
- i = sec_data->i;
- *functionname_ptr = sec_data->function;
- line_base = sec_data->line_base;
- }
- else
- {
- i = 0;
- line_base = 0;
- }
-
- if (section->lineno != NULL)
- {
- l = &section->lineno[i];
-
- for (; i < section->lineno_count; i++)
- {
- if (l->line_number == 0)
- {
- /* Get the symbol this line number points at */
- coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
- if (coff->symbol.value > offset)
- break;
- *functionname_ptr = coff->symbol.name;
- if (coff->native)
- {
- combined_entry_type *s = coff->native;
- s = s + 1 + s->u.syment.n_numaux;
-
- /* In XCOFF a debugging symbol can follow the
- function symbol. */
- if (s->u.syment.n_scnum == N_DEBUG)
- s = s + 1 + s->u.syment.n_numaux;
-
- /* S should now point to the .bf of the function. */
- if (s->u.syment.n_numaux)
- {
- /* The linenumber is stored in the auxent. */
- union internal_auxent *a = &((s + 1)->u.auxent);
- line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
- *line_ptr = line_base;
- }
- }
- }
- else
- {
- if (l->u.offset + bfd_get_section_vma (abfd, section) > offset)
- break;
- *line_ptr = l->line_number + line_base - 1;
- }
- l++;
- }
- }
-
- /* Cache the results for the next call. */
- if (sec_data == NULL && section->owner == abfd)
- {
- section->used_by_bfd =
- ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
- sec_data = (struct coff_section_tdata *) section->used_by_bfd;
- }
- if (sec_data != NULL)
- {
- sec_data->offset = offset;
- sec_data->i = i;
- sec_data->function = *functionname_ptr;
- sec_data->line_base = line_base;
- }
-
- return true;
-}
-
-int
-coff_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- size_t size;
-
- if (reloc == false)
- {
- size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
- }
- else
- {
- size = bfd_coff_filhsz (abfd);
- }
-
- size += abfd->section_count * bfd_coff_scnhsz (abfd);
- return size;
-}
diff --git a/contrib/gdb/bfd/coffswap.h b/contrib/gdb/bfd/coffswap.h
deleted file mode 100644
index ef1b6b3..0000000
--- a/contrib/gdb/bfd/coffswap.h
+++ /dev/null
@@ -1,807 +0,0 @@
-/* Generic COFF swapping routines, for BFD.
- Copyright 1990, 1991, 1992, 1993, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file contains routines used to swap COFF data. It is a header
- file because the details of swapping depend on the details of the
- structures used by each COFF implementation. This is included by
- coffcode.h, as well as by the ECOFF backend.
-
- Any file which uses this must first include "coff/internal.h" and
- "coff/CPU.h". The functions will then be correct for that CPU. */
-
-#ifndef IMAGE_BASE
-#define IMAGE_BASE 0
-#endif
-
-#define PUTWORD bfd_h_put_32
-#define PUTHALF bfd_h_put_16
-#define PUTBYTE bfd_h_put_8
-
-#ifndef GET_FCN_LNNOPTR
-#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#endif
-
-#ifndef GET_FCN_ENDNDX
-#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-
-#ifndef PUT_FCN_LNNOPTR
-#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
-#endif
-#ifndef PUT_FCN_ENDNDX
-#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
-#endif
-#ifndef GET_LNSZ_LNNO
-#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
-#endif
-#ifndef GET_LNSZ_SIZE
-#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
-#endif
-#ifndef PUT_LNSZ_LNNO
-#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
-#endif
-#ifndef PUT_LNSZ_SIZE
-#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
-#endif
-#ifndef GET_SCN_SCNLEN
-#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
-#endif
-#ifndef GET_SCN_NRELOC
-#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
-#endif
-#ifndef GET_SCN_NLINNO
-#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
-#endif
-#ifndef PUT_SCN_SCNLEN
-#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
-#endif
-#ifndef PUT_SCN_NRELOC
-#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
-#endif
-#ifndef PUT_SCN_NLINNO
-#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
-#endif
-#ifndef GET_LINENO_LNNO
-#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
-#endif
-#ifndef PUT_LINENO_LNNO
-#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
-#endif
-
-/* The f_symptr field in the filehdr is sometimes 64 bits. */
-#ifndef GET_FILEHDR_SYMPTR
-#define GET_FILEHDR_SYMPTR bfd_h_get_32
-#endif
-#ifndef PUT_FILEHDR_SYMPTR
-#define PUT_FILEHDR_SYMPTR bfd_h_put_32
-#endif
-
-/* Some fields in the aouthdr are sometimes 64 bits. */
-#ifndef GET_AOUTHDR_TSIZE
-#define GET_AOUTHDR_TSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_TSIZE
-#define PUT_AOUTHDR_TSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_DSIZE
-#define GET_AOUTHDR_DSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_DSIZE
-#define PUT_AOUTHDR_DSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_BSIZE
-#define GET_AOUTHDR_BSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_BSIZE
-#define PUT_AOUTHDR_BSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_ENTRY
-#define GET_AOUTHDR_ENTRY bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_ENTRY
-#define PUT_AOUTHDR_ENTRY bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_TEXT_START
-#define GET_AOUTHDR_TEXT_START bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_TEXT_START
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_DATA_START
-#define GET_AOUTHDR_DATA_START bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_DATA_START
-#define PUT_AOUTHDR_DATA_START bfd_h_put_32
-#endif
-
-/* Some fields in the scnhdr are sometimes 64 bits. */
-#ifndef GET_SCNHDR_PADDR
-#define GET_SCNHDR_PADDR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_PADDR
-#define PUT_SCNHDR_PADDR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_VADDR
-#define GET_SCNHDR_VADDR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_VADDR
-#define PUT_SCNHDR_VADDR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_SIZE
-#define GET_SCNHDR_SIZE bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_SIZE
-#define PUT_SCNHDR_SIZE bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_SCNPTR
-#define GET_SCNHDR_SCNPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_SCNPTR
-#define PUT_SCNHDR_SCNPTR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_RELPTR
-#define GET_SCNHDR_RELPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_RELPTR
-#define PUT_SCNHDR_RELPTR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_LNNOPTR
-#define GET_SCNHDR_LNNOPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_LNNOPTR
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
-#endif
-
-#ifndef NO_COFF_RELOCS
-
-static void
-coff_swap_reloc_in (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- RELOC *reloc_src = (RELOC *) src;
- struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
-
- reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
- reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
-
-#ifdef RS6000COFF_C
- reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
- reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
-#else
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
-#endif
-
-#ifdef SWAP_IN_RELOC_OFFSET
- reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
- (bfd_byte *) reloc_src->r_offset);
-#endif
-}
-
-
-static unsigned int
-coff_swap_reloc_out (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- struct internal_reloc *reloc_src = (struct internal_reloc *)src;
- struct external_reloc *reloc_dst = (struct external_reloc *)dst;
- bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
- bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
-
-#ifdef RS6000COFF_C
- bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
- bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
-#else
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
- reloc_dst->r_type);
-#endif
-
-#ifdef SWAP_OUT_RELOC_OFFSET
- SWAP_OUT_RELOC_OFFSET(abfd,
- reloc_src->r_offset,
- (bfd_byte *) reloc_dst->r_offset);
-#endif
-#ifdef SWAP_OUT_RELOC_EXTRA
- SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
-#endif
-
- return sizeof(struct external_reloc);
-}
-
-#endif /* NO_COFF_RELOCS */
-
-static void
-coff_swap_filehdr_in (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- FILHDR *filehdr_src = (FILHDR *) src;
- struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
- filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
- filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
- filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
- filehdr_dst->f_symptr =
- GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
- filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
- filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
-}
-
-static unsigned int
-coff_swap_filehdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
- FILHDR *filehdr_out = (FILHDR *)out;
-
- bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
- bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
- bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
- (bfd_byte *) filehdr_out->f_symptr);
- bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
- bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
- bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
-
- return sizeof(FILHDR);
-}
-
-
-#ifndef NO_COFF_SYMBOLS
-
-static void
-coff_swap_sym_in (abfd, ext1, in1)
- bfd *abfd;
- PTR ext1;
- PTR in1;
-{
- SYMENT *ext = (SYMENT *)ext1;
- struct internal_syment *in = (struct internal_syment *)in1;
-
- if( ext->e.e_name[0] == 0) {
- in->_n._n_n._n_zeroes = 0;
- in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
- }
- else {
-#if SYMNMLEN != E_SYMNMLEN
- -> Error, we need to cope with truncating or extending SYMNMLEN!;
-#else
- memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
-#endif
- }
- in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
- in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
- if (sizeof(ext->e_type) == 2){
- in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
- }
- else {
- in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
- }
- in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
- in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
-}
-
-static unsigned int
-coff_swap_sym_out (abfd, inp, extp)
- bfd *abfd;
- PTR inp;
- PTR extp;
-{
- struct internal_syment *in = (struct internal_syment *)inp;
- SYMENT *ext =(SYMENT *)extp;
- if(in->_n._n_name[0] == 0) {
- bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
- bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
- }
- else {
-#if SYMNMLEN != E_SYMNMLEN
- -> Error, we need to cope with truncating or extending SYMNMLEN!;
-#else
- memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
-#endif
- }
- bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
- bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
- if (sizeof(ext->e_type) == 2)
- {
- bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
- }
- else
- {
- bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
- }
- bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
- bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
- return sizeof(SYMENT);
-}
-
-static void
-coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
- bfd *abfd;
- PTR ext1;
- int type;
- int class;
- int indx;
- int numaux;
- PTR in1;
-{
- AUXENT *ext = (AUXENT *)ext1;
- union internal_auxent *in = (union internal_auxent *)in1;
-
- switch (class) {
- case C_FILE:
- if (ext->x_file.x_fname[0] == 0) {
- in->x_file.x_n.x_zeroes = 0;
- in->x_file.x_n.x_offset =
- bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
- } else {
-#if FILNMLEN != E_FILNMLEN
- -> Error, we need to cope with truncating or extending FILNMLEN!;
-#else
- memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
-#endif
- }
- return;
-
- /* RS/6000 "csect" auxents */
-#ifdef RS6000COFF_C
- case C_EXT:
- case C_HIDEXT:
- if (indx + 1 == numaux)
- {
- in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
- in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
- ext->x_csect.x_parmhash);
- in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
- /* We don't have to hack bitfields in x_smtyp because it's
- defined by shifts-and-ands, which are equivalent on all
- byte orders. */
- in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
- in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
- in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
- in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
- return;
- }
- break;
-#endif
-
- case C_STAT:
-#ifdef C_LEAFSTAT
- case C_LEAFSTAT:
-#endif
- case C_HIDDEN:
- if (type == T_NULL) {
- in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
- in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
- in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
- return;
- }
- break;
- }
-
- in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
-#ifndef NO_TVNDX
- in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
-#endif
-
- if (class == C_BLOCK || ISFCN (type) || ISTAG (class))
- {
- in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
- in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
- }
- else
- {
-#if DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
-#endif
- in->x_sym.x_fcnary.x_ary.x_dimen[0] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
- in->x_sym.x_fcnary.x_ary.x_dimen[1] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
- in->x_sym.x_fcnary.x_ary.x_dimen[2] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
- in->x_sym.x_fcnary.x_ary.x_dimen[3] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
- }
-
- if (ISFCN(type)) {
- in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
- }
- else {
- in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
- in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
- }
-}
-
-static unsigned int
-coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd;
- PTR inp;
- int type;
- int class;
- int indx;
- int numaux;
- PTR extp;
-{
- union internal_auxent *in = (union internal_auxent *)inp;
- AUXENT *ext = (AUXENT *)extp;
-
- memset((PTR)ext, 0, AUXESZ);
- switch (class) {
- case C_FILE:
- if (in->x_file.x_fname[0] == 0) {
- PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- PUTWORD(abfd,
- in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
- }
- else {
-#if FILNMLEN != E_FILNMLEN
- -> Error, we need to cope with truncating or extending FILNMLEN!;
-#else
- memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
-#endif
- }
- return sizeof (AUXENT);
-
-#ifdef RS6000COFF_C
- /* RS/6000 "csect" auxents */
- case C_EXT:
- case C_HIDEXT:
- if (indx + 1 == numaux)
- {
- PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
- PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
- PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
- /* We don't have to hack bitfields in x_smtyp because it's
- defined by shifts-and-ands, which are equivalent on all
- byte orders. */
- PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
- PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
- PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
- PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
- return sizeof (AUXENT);
- }
- break;
-#endif
-
- case C_STAT:
-#ifdef C_LEAFSTAT
- case C_LEAFSTAT:
-#endif
- case C_HIDDEN:
- if (type == T_NULL) {
- PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
- PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
- PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
- return sizeof (AUXENT);
- }
- break;
- }
-
- PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
-#ifndef NO_TVNDX
- bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
-#endif
-
- if (class == C_BLOCK || ISFCN (type) || ISTAG (class))
- {
- PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
- PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
- }
- else
- {
-#if DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
-#endif
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
- }
-
- if (ISFCN (type))
- PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_misc.x_fsize);
- else
- {
- PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
- PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
- }
-
- return sizeof(AUXENT);
-}
-
-#endif /* NO_COFF_SYMBOLS */
-
-#ifndef NO_COFF_LINENOS
-
-static void
-coff_swap_lineno_in (abfd, ext1, in1)
- bfd *abfd;
- PTR ext1;
- PTR in1;
-{
- LINENO *ext = (LINENO *)ext1;
- struct internal_lineno *in = (struct internal_lineno *)in1;
-
- in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
- in->l_lnno = GET_LINENO_LNNO(abfd, ext);
-}
-
-static unsigned int
-coff_swap_lineno_out (abfd, inp, outp)
- bfd *abfd;
- PTR inp;
- PTR outp;
-{
- struct internal_lineno *in = (struct internal_lineno *)inp;
- struct external_lineno *ext = (struct external_lineno *)outp;
- PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
- ext->l_addr.l_symndx);
-
- PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
- return sizeof(struct external_lineno);
-}
-
-#endif /* NO_COFF_LINENOS */
-
-
-static void
-coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
- bfd *abfd;
- PTR aouthdr_ext1;
- PTR aouthdr_int1;
-{
- AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
- struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
-
- aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
- aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
- aouthdr_int->tsize =
- GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
- aouthdr_int->dsize =
- GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
- aouthdr_int->bsize =
- GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
- aouthdr_int->entry =
- GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
- aouthdr_int->text_start =
- GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
- aouthdr_int->data_start =
- GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
-
-#ifdef I960
- aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
-#endif
-
-#ifdef APOLLO_M68
- bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
- bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
- bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
- bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
-#endif
-
-
-#ifdef RS6000COFF_C
- aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
- aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
- aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
- aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
- aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
- aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
- aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
- aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
- aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
- aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
- aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
- aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
- aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
-#endif
-
-#ifdef MIPSECOFF
- aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
- aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
- aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
- aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
-#endif
-
-#ifdef ALPHAECOFF
- aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
-#endif
-}
-
-static unsigned int
-coff_swap_aouthdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
- AOUTHDR *aouthdr_out = (AOUTHDR *)out;
-
- bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
- bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
- PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
- PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
- PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
- PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
- PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
- (bfd_byte *) aouthdr_out->text_start);
- PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
- (bfd_byte *) aouthdr_out->data_start);
-
-#ifdef I960
- bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
-#endif
-
-#ifdef RS6000COFF_C
- bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
- bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
- bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
- bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
- bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
- bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
- bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
- bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
- memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
-#endif
-
-#ifdef MIPSECOFF
- bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
-#endif
-
-#ifdef ALPHAECOFF
- /* FIXME: What does bldrev mean? */
- bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
- bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
- bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
-#endif
-
- return sizeof(AOUTHDR);
-}
-
-static void
-coff_swap_scnhdr_in (abfd, ext, in)
- bfd *abfd;
- PTR ext;
- PTR in;
-{
- SCNHDR *scnhdr_ext = (SCNHDR *) ext;
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
-
- memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
- scnhdr_int->s_vaddr =
- GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
- scnhdr_int->s_paddr =
- GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
- scnhdr_int->s_size =
- GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
-
- scnhdr_int->s_scnptr =
- GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
- scnhdr_int->s_relptr =
- GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
- scnhdr_int->s_lnnoptr =
- GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
- scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
-#if defined(M88)
- scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#else
- scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#endif
-#ifdef I960
- scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
-#endif
-}
-
-static unsigned int
-coff_swap_scnhdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
- SCNHDR *scnhdr_ext = (SCNHDR *)out;
- unsigned int ret = sizeof (SCNHDR);
-
- memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
-
- PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
- (bfd_byte *) scnhdr_ext->s_vaddr);
-
-
- PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
- (bfd_byte *) scnhdr_ext->s_paddr);
- PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
- (bfd_byte *) scnhdr_ext->s_size);
-
- PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
- (bfd_byte *) scnhdr_ext->s_scnptr);
- PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
- (bfd_byte *) scnhdr_ext->s_relptr);
- PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
- (bfd_byte *) scnhdr_ext->s_lnnoptr);
- PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
-#if defined(M88)
- PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
- PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
-#else
- if (scnhdr_int->s_nlnno <= 0xffff)
- PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
- else
- {
- (*_bfd_error_handler) ("%s: line number overflow: 0x%lx > 0xffff",
- bfd_get_filename (abfd),
- scnhdr_int->s_nlnno);
- bfd_set_error (bfd_error_file_truncated);
- PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
- ret = 0;
- }
- if (scnhdr_int->s_nreloc <= 0xffff)
- PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
- else
- {
- (*_bfd_error_handler) ("%s: reloc overflow: 0x%lx > 0xffff",
- bfd_get_filename (abfd),
- scnhdr_int->s_nreloc);
- bfd_set_error (bfd_error_file_truncated);
- PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
- ret = 0;
- }
-#endif
-
-#if defined(I960)
- PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
-#endif
- return ret;
-}
diff --git a/contrib/gdb/bfd/config.bfd b/contrib/gdb/bfd/config.bfd
deleted file mode 100644
index 7757d5f..0000000
--- a/contrib/gdb/bfd/config.bfd
+++ /dev/null
@@ -1,491 +0,0 @@
-# config.bfd
-# Convert a canonical host type into a BFD host type.
-# Set shell variable targ to canonical target name, and run
-# using ``. config.bfd''.
-# Sets the following shell variables:
-# targ_defvec Default vector for this target
-# targ_selvecs Vectors to build for this target
-# targ_archs Architectures for this target
-# targ_cflags $(CFLAGS) for this target (FIXME: pretty bogus)
-# targ_undercore Whether underscores are used: yes or no
-
-# The binutils c++filt program wants to know whether underscores are
-# stripped or not. That is why we set targ_underscore. c++filt uses
-# this information to choose a default. This information is
-# duplicated in the symbol_leading_char field of the BFD target
-# vector, but c++filt does not deal with object files and is not
-# linked against libbfd.a. It is not terribly important that c++filt
-# get this right; it is just convenient.
-
-targ_defvec=
-targ_selvecs=
-targ_cflags=
-targ_underscore=no
-
-targ_cpu=`echo $targ | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-case "${targ_cpu}" in
-arm*) targ_archs=bfd_arm_arch ;;
-hppa*) targ_archs=bfd_hppa_arch ;;
-i[345]86) targ_archs=bfd_i386_arch ;;
-m68*) targ_archs=bfd_m68k_arch ;;
-m88*) targ_archs=bfd_m88k_arch ;;
-mips*) targ_archs=bfd_mips_arch ;;
-powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
-rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
-sparc*) targ_archs=bfd_sparc_arch ;;
-z8k*) targ_archs=bfd_z8k_arch ;;
-*) targ_archs=bfd_${targ_cpu}_arch ;;
-esac
-
-# WHEN ADDING ENTRIES TO THIS MATRIX:
-# Make sure that the left side always has two dashes. Otherwise you
-# can get spurious matches. Even for unambiguous cases, do this as a
-# convention, else the table becomes a real mess to understand and maintain.
-
-case "${targ}" in
- alpha-*-netware*)
- targ_defvec=ecoffalpha_little_vec
- targ_selvecs=nlm32_alpha_vec
- ;;
- alpha-*-*)
- targ_defvec=ecoffalpha_little_vec
- ;;
-
-
- arm-*-riscix*)
- targ_defvec=riscix_vec
- ;;
- arm-*-pe*)
- targ_defvec=armpe_little_vec
- targ_selvecs="armpe_little_vec armpe_big_vec armpei_little_vec armpei_big_vec"
- targ_underscore=yes
- ;;
- arm-*-aout | armel-*-aout)
- targ_defvec=aout_arm_little_vec
- targ_selvecs=aout_arm_big_vec
- ;;
- armeb-*-aout)
- targ_defvec=aout_arm_big_vec
- targ_selvecs=aout_arm_little_vec
- ;;
- arm-*-coff)
- targ_defvec=armcoff_little_vec
- targ_selvecs=armcoff_big_vec
- targ_underscore=yes
- ;;
-
- a29k-*-ebmon* | a29k-*-udi* | a29k-*-coff* | a29k-*-sym1* | \
- a29k-*-vxworks* | a29k-*-sysv*)
- targ_defvec=a29kcoff_big_vec
- targ_selvecs=sunos_big_vec
- targ_underscore=yes
- ;;
- a29k-*-aout* | a29k-*-bsd* | a29k-*-vsta*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
-
- h8300*-*-*)
- targ_defvec=h8300coff_vec
- targ_underscore=yes
- ;;
-
- h8500-*-*)
- targ_defvec=h8500coff_vec
- targ_underscore=yes
- ;;
-
- sh-*-*)
- targ_defvec=shcoff_vec
- targ_selvecs="shcoff_vec shlcoff_vec"
- targ_underscore=yes
- ;;
-
- hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4*)
- targ_defvec=bfd_elf32_hppa_vec
- ;;
- hppa*-*-bsd*)
- targ_defvec=som_vec
- targ_selvecs=bfd_elf32_hppa_vec
- ;;
- hppa*-*-hpux* | hppa*-*-hiux*)
- targ_defvec=som_vec
- ;;
- hppa*-*-osf*)
- targ_defvec=som_vec
- targ_selvecs=bfd_elf32_hppa_vec
- ;;
-
- i[345]86-*-sysv4* | i[345]86-*-unixware | i[345]86-*-solaris2* | \
- i[345]86-*-elf | i[345]86-*-sco*elf*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386coff_vec
- ;;
- i[345]86-*-sysv* | i[345]86-*-isc* | i[345]86-*-sco* | i[345]86-*-coff | \
- i[345]86-*-aix* | i[345]86-*-go32*)
- targ_defvec=i386coff_vec
- ;;
- i[345]86-sequent-bsd*)
- targ_defvec=i386dynix_vec
- targ_underscore=yes
- ;;
- i[345]86-*-bsd*)
- targ_defvec=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-freebsd*)
- targ_defvec=i386freebsd_vec
- targ_selvecs=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-netbsd*)
- targ_defvec=i386netbsd_vec
- targ_selvecs=i386bsd_vec
- targ_underscore=yes
- ;;
- i[345]86-*-netware*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs="nlm32_i386_vec i386coff_vec i386aout_vec"
- ;;
- i[345]86-*-linuxaout*)
- targ_defvec=i386linux_vec
- targ_selvecs=bfd_elf32_i386_vec
- targ_underscore=yes
- ;;
- i[345]86-*-linux*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386linux_vec
- targ_underscore=yes
- ;;
- i[345]86-*-lynxos*)
- targ_defvec=i386lynx_coff_vec
- targ_selvecs=i386lynx_aout_vec
- ;;
- i[345]86-*-gnu*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs=i386mach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- targ_underscore=yes
- ;;
- i[345]86-*-mach* | i[345]86-*-osf1mk*)
- targ_defvec=i386mach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- targ_underscore=yes
- ;;
- i[345]86-*-os9k)
- targ_defvec=i386os9k_vec
- ;;
- i[345]86-*-msdos*)
- targ_defvec=i386aout_vec
- targ_selvecs=i386msdos_vec
- ;;
- i[345]86-*-moss*)
- targ_defvec=bfd_elf32_i386_vec
- targ_selvecs="i386msdos_vec i386aout_vec"
- ;;
- i[345]86-*-cygwin32 | i[345]86-*-winnt | i[345]86-*-pe)
- targ_defvec=i386pe_vec
- targ_selvecs="i386pe_vec i386pei_vec"
- ;;
- i[345]86-none-*)
- targ_defvec=i386coff_vec
- ;;
- i[345]86-*-aout* | i[345]86*-*-vsta*)
- targ_defvec=i386aout_vec
- ;;
-
- i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
- targ_defvec=i860coff_vec
- ;;
- i860-*-sysv4* | i860-*-elf*)
- targ_defvec=bfd_elf32_i860_vec
- ;;
-
- i960-*-vxworks4* | i960-*-vxworks5.0)
- targ_defvec=b_out_vec_little_host
- targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec"
- targ_underscore=yes
- ;;
- i960-*-vxworks5.* | i960-*-coff* | i960-*-sysv*)
- targ_defvec=icoff_little_vec
- targ_selvecs="icoff_big_vec b_out_vec_little_host b_out_vec_big_host"
- targ_underscore=yes
- ;;
- i960-*-vxworks* | i960-*-aout* | i960-*-bout* | i960-*-nindy*)
- targ_defvec=b_out_vec_little_host
- targ_selvecs="b_out_vec_big_host icoff_little_vec icoff_big_vec"
- targ_underscore=yes
- ;;
-
- m68*-apollo-*)
- targ_defvec=apollocoff_vec
- ;;
- m68*-bull-sysv*)
- targ_defvec=m68kcoffun_vec
- targ_underscore=yes
- ;;
- m68*-hp-bsd*)
- targ_defvec=hp300bsd_vec
- targ_underscore=yes
- ;;
- m68*-*-aout*)
- targ_defvec=aout0_big_vec
- # We include this here, rather than making a separate cisco
- # configuration, so that cisco-core.c gets routinely tested at
- # least for compilation.
- targ_selvecs=cisco_core_vec
- targ_underscore=yes
- ;;
- m68*-*-elf* | m68*-*-sysv4*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68kcoff_vec
- ;;
- m68*-*-coff* | m68*-*-sysv*)
- targ_defvec=m68kcoff_vec
- targ_selvecs="m68kcoff_vec versados_vec"
- ;;
- m68*-*-hpux*)
- targ_defvec=hp300hpux_vec
- targ_underscore=yes
- ;;
- m68*-*-linuxaout*)
- targ_defvec=m68klinux_vec
- targ_selvecs=bfd_elf32_m68k_vec
- targ_underscore=yes
- ;;
- m68*-*-linux*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68klinux_vec
- ;;
- m68*-*-lynxos*)
- targ_defvec=m68klynx_coff_vec
- targ_selvecs=m68klynx_aout_vec
- ;;
- m68*-hp*-netbsd*)
- targ_defvec=m68k4knetbsd_vec
- targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"
- targ_underscore=yes
- ;;
- m68*-*-netbsd*)
- targ_defvec=m68knetbsd_vec
- targ_selvecs="m68k4knetbsd_vec hp300bsd_vec sunos_big_vec"
- targ_underscore=yes
- ;;
- m68*-*-sunos* | m68*-*-os68k* | m68*-*-vxworks* | m68*-netx-* | \
- m68*-*-bsd* | m68*-*-vsta*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
- m68*-ericsson-*)
- targ_defvec=sunos_big_vec
- targ_selvecs="m68kcoff_vec tekhex_vec"
- targ_underscore=yes
- ;;
- m68*-cbm-*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=m68kcoff_vec
- ;;
- m68*-apple-aux*)
- targ_defvec=m68kaux_coff_vec
- ;;
- m68*-*-psos*)
- targ_defvec=bfd_elf32_m68k_vec
- targ_selvecs=ieee_vec
- targ_underscore=yes
- ;;
-
- m88*-harris-cxux* | m88*-*-dgux* | m88*-*-sysv4*)
- targ_defvec=bfd_elf32_m88k_vec
- targ_selvecs=m88kbcs_vec
- ;;
- m88*-*-mach3*)
- targ_defvec=m88kmach3_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- m88*-*-*)
- targ_defvec=m88kbcs_vec
- targ_underscore=yes
- ;;
-
- mips*-big-*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips-dec-netbsd*)
- targ_defvec=bfd_elf32_littlemips_vec
- targ_selvecs=bfd_elf32_bigmips_vec
- ;;
- mips*-dec-bsd*)
- targ_defvec=aout_mips_little_vec
- targ_underscore=yes
- ;;
- mips*-dec-mach3*)
- targ_defvec=aout_mips_little_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- mips*-dec-* | mips*el-*-ecoff*)
- targ_defvec=ecoff_little_vec
- targ_selvecs=ecoff_big_vec
- ;;
- mips*-*-ecoff*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*-*-irix5*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
- ;;
- mips*-sgi-* | mips*-*-bsd*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*-*-mach3*)
- targ_defvec=aout_mips_little_vec
- targ_cflags=-DSTAT_FOR_EXEC
- ;;
- mips*-*-sysv4*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
- ;;
- mips*-*-sysv* | mips*-*-riscos*)
- targ_defvec=ecoff_big_vec
- targ_selvecs=ecoff_little_vec
- ;;
- mips*el-*-elf*)
- targ_defvec=bfd_elf32_littlemips_vec
- targ_selvecs=bfd_elf32_bigmips_vec
- ;;
- mips*-*-elf*)
- targ_defvec=bfd_elf32_bigmips_vec
- targ_selvecs=bfd_elf32_littlemips_vec
- ;;
-
- ns32k-pc532-mach* | ns32k-pc532-ux*)
- targ_defvec=pc532machaout_vec
- targ_underscore=yes
- ;;
- ns32k-*-netbsd* | ns32k-*-lites*)
- targ_defvec=pc532netbsd_vec
- targ_underscore=yes
- ;;
-
- powerpc-*-aix*)
- targ_defvec=rs6000coff_vec
- ;;
- powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | powerpc-*-solaris2*)
- targ_defvec=bfd_elf32_powerpc_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
- powerpc-*-macos* | powerpc-*-mpw*)
- targ_defvec=pmac_xcoff_vec
- ;;
- powerpc-*-netware*)
- targ_defvec=bfd_elf32_powerpc_vec
- targ_selvecs="nlm32_powerpc_vec rs6000coff_vec"
- ;;
- powerpcle-*-elf* | powerpcle-*-sysv4* | powerpcle-*-eabi* | \
- powerpcle-*-solaris2*)
- targ_defvec=bfd_elf32_powerpcle_vec
- targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
-
- powerpcle-*-pe | powerpcle-*-winnt* | powerpcle-*-cygwin32)
- targ_defvec=bfd_powerpcle_pe_vec
- targ_selvecs="bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
- ;;
-
- rs6000-*-*)
- targ_defvec=rs6000coff_vec
- ;;
-
- sparc-*-lynxos*)
- targ_defvec=sparclynx_coff_vec
- targ_selvecs=sparclynx_aout_vec
- ;;
- sparc-*-netbsd*)
- targ_defvec=sparcnetbsd_vec
- targ_underscore=yes
- ;;
- sparc-*-elf* | sparc-*-sysv4* | sparc-*-solaris2*)
- targ_defvec=bfd_elf32_sparc_vec
- targ_selvecs=sunos_big_vec
- ;;
- sparc64-*-aout*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
- sparc64-*-elf*)
- targ_defvec=bfd_elf64_sparc_vec
- targ_selvecs=bfd_elf32_sparc_vec
- ;;
- sparc64-*-solaris2* | sparc64-*-sysv4*)
- targ_defvec=bfd_elf32_sparc_vec
- # Adding 64 bit support by default causes things like objdump to
- # print addresses as 64 bits.
- #targ_selvecs=bfd_elf64_sparc_vec
- ;;
- sparc-*-netware*)
- targ_defvec=bfd_elf32_sparc_vec
- targ_selvecs="nlm32_sparc_vec sunos_big_vec"
- ;;
- sparc*-*-coff*)
- targ_defvec=sparccoff_vec
- ;;
- sparc*-*-*)
- targ_defvec=sunos_big_vec
- targ_underscore=yes
- ;;
-
- tahoe-*-*)
- targ_defvec=host_aout_vec
- targ_underscore=yes
- ;;
-
- vax-*-vms*)
- echo 1>&2 "*** BFD does not support target ${targ}."
- echo 1>&2 "*** Look in bfd/config.bfd for supported targets."
- exit 1
- ;;
- vax-*-*)
- targ_defvec=host_aout_vec
- targ_underscore=yes
- ;;
-
- we32k-*-*)
- targ_defvec=we32kcoff_vec
- ;;
-
- w65-*-*)
- targ_defvec=w65_vec
- ;;
-
- z8k*-*-*)
- targ_defvec=z8kcoff_vec
- targ_underscore=yes
- ;;
-
- *-*-ieee*)
- targ_defvec=ieee_vec
- ;;
-
- *-adobe-*)
- targ_defvec=a_aout_adobe_vec
- targ_underscore=yes
- ;;
-
- *-sony-*)
- targ_defvec=newsos3_vec
- targ_underscore=yes
- ;;
-
- *-tandem-*)
- targ_defvec=m68kcoff_vec
- targ_selvecs=ieee_vec
- ;;
-
- *)
- echo 1>&2 "*** BFD does not support target ${targ}."
- echo 1>&2 "*** Look in bfd/config.bfd for supported targets."
- exit 1
- ;;
-esac
diff --git a/contrib/gdb/bfd/config.in b/contrib/gdb/bfd/config.in
deleted file mode 100644
index dd4f968..0000000
--- a/contrib/gdb/bfd/config.in
+++ /dev/null
@@ -1,67 +0,0 @@
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* Whether malloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_MALLOC
-
-/* Whether free must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_FREE
-
-/* Define if you have a working `mmap' system call. */
-#undef HAVE_MMAP
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Do we need to use the b modifier when opening binary files? */
-#undef USE_BINARY_FOPEN
-
-/* Name of host specific header file to include in trad-core.c. */
-#undef TRAD_HEADER
-
-/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
-#undef HAVE_SYS_PROCFS_H
-
-/* Do we really want to use mmap if it's available? */
-#undef USE_MMAP
-
-/* Define if you have the fcntl function. */
-#undef HAVE_FCNTL
-
-/* Define if you have the getpagesize function. */
-#undef HAVE_GETPAGESIZE
-
-/* Define if you have the madvise function. */
-#undef HAVE_MADVISE
-
-/* Define if you have the mprotect function. */
-#undef HAVE_MPROTECT
-
-/* Define if you have the valloc function. */
-#undef HAVE_VALLOC
-
-/* Define if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
-
-/* Define if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define if you have the <sys/file.h> header file. */
-#undef HAVE_SYS_FILE_H
-
-/* Define if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define if you have the <time.h> header file. */
-#undef HAVE_TIME_H
-
-/* Define if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
diff --git a/contrib/gdb/bfd/configure b/contrib/gdb/bfd/configure
deleted file mode 100644
index 5db14db..0000000
--- a/contrib/gdb/bfd/configure
+++ /dev/null
@@ -1,2439 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.8
-# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)"
-ac_help="$ac_help
- --enable-targets alternative target configurations"
-ac_help="$ac_help
- --enable-shared build shared BFD library"
-ac_help="$ac_help
- --enable-commonbfdlib build shared BFD/opcodes/libiberty library"
-ac_help="$ac_help
- --with-mmap try using mmap for BFD input files if available"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.8"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=libbfd.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-# Check whether --enable-64-bit-bfd or --disable-64-bit-bfd was given.
-if test "${enable_64_bit_bfd+set}" = set; then
- enableval="$enable_64_bit_bfd"
- case "${enableval}" in
- yes) want64=true ;;
- no) want64=false ;;
- *) { echo "configure: error: bad value ${enableval} for 64-bit-bfd option" 1>&2; exit 1; } ;;
-esac
-else
- want64=false
-fi
-# Check whether --enable-targets or --disable-targets was given.
-if test "${enable_targets+set}" = set; then
- enableval="$enable_targets"
- case "${enableval}" in
- yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; }
- ;;
- no) enable_targets= ;;
- *) enable_targets=$enableval ;;
-esac
-fi
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- case "${enableval}" in
- yes) shared=true ;;
- no) shared=false ;;
- *) { echo "configure: error: bad value ${enableval} for BFD shared option" 1>&2; exit 1; } ;;
-esac
-fi
-# Check whether --enable-commonbfdlib or --disable-commonbfdlib was given.
-if test "${enable_commonbfdlib+set}" = set; then
- enableval="$enable_commonbfdlib"
- case "${enableval}" in
- yes) commonbfdlib=true ;;
- no) commonbfdlib=false ;;
- *) { echo "configure: error: bad value ${enableval} for BFD commonbfdlib option" 1>&2; exit 1; } ;;
-esac
-fi
-# Check whether --with-mmap or --without-mmap was given.
-if test "${with_mmap+set}" = set; then
- withval="$with_mmap"
- case "${withval}" in
- yes) want_mmap=true ;;
- no) want_mmap=false ;;
- *) { echo "configure: error: bad value ${withval} for BFD with-mmap option" 1>&2; exit 1; } ;;
-esac
-else
- want_mmap=false
-fi
-
-
-
-ac_aux_dir=
-for ac_dir in `cd $srcdir/..;pwd` $srcdir/`cd $srcdir/..;pwd`; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in `cd $srcdir/..;pwd` $srcdir/`cd $srcdir/..;pwd`" 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-
-# Do some error checking and defaulting for the host and target type.
-# The inputs are:
-# configure --host=HOST --target=TARGET --build=BUILD NONOPT
-#
-# The rules are:
-# 1. You are not allowed to specify --host, --target, and nonopt at the
-# same time.
-# 2. Host defaults to nonopt.
-# 3. If nonopt is not specified, then host defaults to the current host,
-# as determined by config.guess.
-# 4. Target and build default to nonopt.
-# 5. If nonopt is not specified, then target and build default to host.
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-case $host---$target---$nonopt in
-NONE---*---* | *---NONE---* | *---*---NONE) ;;
-*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
-esac
-
-
-# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`$ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-
-host=`$ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-echo $ac_n "checking target system type""... $ac_c" 1>&6
-
-target_alias=$target
-case "$target_alias" in
-NONE)
- case $nonopt in
- NONE) target_alias=$host_alias ;;
- *) target_alias=$nonopt ;;
- esac ;;
-esac
-
-target=`$ac_config_sub $target_alias`
-target_cpu=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-target_vendor=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-target_os=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$target" 1>&6
-
-echo $ac_n "checking build system type""... $ac_c" 1>&6
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
-
-build=`$ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
-
-test "$host_alias" != "$target_alias" &&
- test "$program_prefix$program_suffix$program_transform_name" = \
- NONENONEs,x,x, &&
- program_prefix=${target_alias}-
-
-if test -z "$target" ; then
- { echo "configure: error: Unrecognized target system type; please check config.sub." 1>&2; exit 1; }
-fi
-if test "$program_transform_name" = s,x,x,; then
- program_transform_name=
-else
- # Double any \ or $. echo might interpret backslashes.
- cat <<\EOF_SED > conftestsed
-s,\\,\\\\,g; s,\$,$$,g
-EOF_SED
- program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
- rm -f conftestsed
-fi
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,${program_prefix},; $program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
-
-# sed with no file args requires a program.
-test "$program_transform_name" = "" && program_transform_name="s,x,x,"
-
-
-host64=false
-target64=false
-
-# host stuff:
-
-ALLLIBS='$(TARGETLIB)'
-PICFLAG=
-SHLIB=unused-shlib
-SHLINK=unused-shlink
-if test "${shared}" = "true"; then
- PICFLAG=-fpic
- if test "${commonbfdlib}" = "true"; then
- ALLLIBS='$(TARGETLIB)'
- else
- ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
- SHLIB=libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/VERSION`
- SHLINK=libbfd.so
- fi
-fi
-
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- ac_prog_rejected=no
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:814: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
- if test "${CFLAGS+set}" != set; then
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_gcc_g=yes
-else
- ac_cv_prog_gcc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
- if test $ac_cv_prog_gcc_g = yes; then
- CFLAGS="-g -O"
- else
- CFLAGS="-O"
- fi
- fi
-else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
-fi
-
-
-# Permit host specific settings.
-. ${srcdir}/configure.host
-
-
-if test $host != $build; then
- ac_tool_prefix=${host_alias}-
-else
- ac_tool_prefix=
-fi
-
-# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_AR="${ac_tool_prefix}ar"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
- echo "$ac_t""$AR" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-
-# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-if test -z "$ac_cv_prog_RANLIB"; then
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-else
- RANLIB=":"
-fi
-fi
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_ifs"
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-if test "${shared}" = "true"; then
- if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
- echo "configure: warning: BFD --enable-shared only supported when using gcc" 1>&2
- shared=false
- ALLLIBS='$(TARGETLIB)'
- PICFLAG=
- SHLIB=unused-shlib
- fi
-fi
-
-
-
-
-
-
-if test "${commonbfdlib}" = "true"; then
- COMMON_SHLIB=yes
- PICLIST=piclist
-else
- COMMON_SHLIB=
- PICLIST=
-fi
-
-
-
-
-HOST_64BIT_LONG=0
-if test "x${HOST_64BIT_TYPE}" = "xlong"; then
- HOST_64BIT_LONG=1
-fi
-
-
-# If we cannot run a trivial program, we must be cross compiling.
-echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_c_cross=yes
-else
-cat > conftest.$ac_ext <<EOF
-#line 1056 "configure"
-#include "confdefs.h"
-main(){return(0);}
-EOF
-{ (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_cross=no
-else
- ac_cv_c_cross=yes
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_c_cross" 1>&6
-cross_compiling=$ac_cv_c_cross
-
-# Put a plausible default for CC_FOR_BUILD in Makefile.
-if test -z "$CC_FOR_BUILD"; then
- if test "x$cross_compiling" = "xno"; then
- CC_FOR_BUILD='$(CC)'
- else
- CC_FOR_BUILD=gcc
- fi
-fi
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1098 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1113 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1119: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-for ac_hdr in stddef.h string.h strings.h stdlib.h time.h unistd.h
-do
-ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1147 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_hdr in fcntl.h sys/file.h sys/time.h
-do
-ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1184 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1218 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-int main() { return 0; }
-int t() {
-struct tm *tp;
-; return 0; }
-EOF
-if { (eval echo configure:1228: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_header_time=yes
-else
- rm -rf conftest*
- ac_cv_header_time=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_header_time" 1>&6
-if test $ac_cv_header_time = yes; then
- cat >> confdefs.h <<\EOF
-#define TIME_WITH_SYS_TIME 1
-EOF
-
-fi
-
-for ac_func in fcntl getpagesize
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1254 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-
-
-case "${host}" in
-i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32)
- cat >> confdefs.h <<\EOF
-#define USE_BINARY_FOPEN 1
-EOF
- ;;
-esac
-
-echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1313 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-int main() { return 0; }
-int t() {
-char *(*pfn) = (char *(*)) malloc
-; return 0; }
-EOF
-if { (eval echo configure:1328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_decl_needed_malloc=no
-else
- rm -rf conftest*
- bfd_cv_decl_needed_malloc=yes
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$bfd_cv_decl_needed_malloc" 1>&6
-if test $bfd_cv_decl_needed_malloc = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo malloc | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $bfd_tr_decl 1
-EOF
-
-fi
-
-echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1353 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-int main() { return 0; }
-int t() {
-char *(*pfn) = (char *(*)) free
-; return 0; }
-EOF
-if { (eval echo configure:1368: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_decl_needed_free=no
-else
- rm -rf conftest*
- bfd_cv_decl_needed_free=yes
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$bfd_cv_decl_needed_free" 1>&6
-if test $bfd_cv_decl_needed_free = yes; then
- bfd_tr_decl=NEED_DECLARATION_`echo free | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $bfd_tr_decl 1
-EOF
-
-fi
-
-
-# If we are configured native, pick a core file support file.
-COREFILE=
-COREFLAG=
-if test "${target}" = "${host}"; then
- case "${host}" in
- alpha*-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/alphalinux.h"
-EOF
-
- ;;
- alpha*-*-*) COREFILE=osf-core.o ;;
- arm-*-riscix) COREFILE=trad-core.o ;;
- hppa*-*-hpux*) COREFILE=hpux-core.o ;;
- hppa*-*-hiux*) COREFILE=hpux-core.o ;;
- hppa*-*-bsd*) COREFILE="hpux-core.o hppabsd-core.o"
- COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
- i[345]86-sequent-bsd*)
- COREFILE=trad-core.o;
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/symmetry.h"
-EOF
-
- ;;
- i[345]86-sequent-sysv4*) ;;
- i[345]86-sequent-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/symmetry.h"
-EOF
-
- ;;
- i[345]86-*-bsd* | i[345]86-*-freebsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386bsd.h"
-EOF
-
- ;;
- i[345]86-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- i[345]86-esix-sysv3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/esix.h"
-EOF
-
- ;;
- i[345]86-*-sco* | i[345]86-*-isc*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386sco.h"
-EOF
-
- ;;
- i[345]86-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386mach3.h"
-EOF
-
- ;;
- i[345]86-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i386linux.h"
-EOF
-
- ;;
- i[345]86-*-isc*) COREFILE=trad-core.o ;;
- i[345]86-*-aix*) COREFILE=aix386-core.o ;;
- i860-*-mach3* | i860-*-osf1*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/i860mach3.h"
-EOF
-
- ;;
- mips-dec-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsbsd.h"
-EOF
-
- ;;
- mips-dec-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsmach3.h"
-EOF
-
- ;;
- mips-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- mips-dec-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/decstation.h"
-EOF
-
- ;;
- mips-sgi-irix4*) COREFILE=irix-core.o ;;
- mips-sgi-irix5*) COREFILE=irix-core.o ;;
- mips-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/mipsmach3.h"
-EOF
-
- ;;
- mips-*-sysv4*) ;;
- mips-*-sysv* | mips-*-riscos*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/riscos.h"
-EOF
-
- ;;
- mips-sony-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/news-mips.h"
-EOF
-
- ;;
- m68*-bull*-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/dpx2.h"
-EOF
-
- ;;
- m68*-hp-hpux*) COREFILE=hpux-core.o ;;
- m68*-hp-bsd*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/hp300bsd.h"
-EOF
-
- ;;
- m68*-*-linux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m68klinux.h"
-EOF
-
- ;;
- m68*-motorola-sysv*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/delta68.h"
-EOF
-
- ;;
- m68*-sony-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/news.h"
-EOF
-
- ;;
- m68*-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- m68*-apple-aux*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m68kaux.h"
-EOF
-
- ;;
- m88*-*-sysv4*) ;;
- m88*-motorola-sysv*) COREFILE=ptrace-core.o ;;
- m88*-*-mach3*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/m88kmach3.h"
-EOF
-
- ;;
- ns32k-pc532-mach)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/pc532mach.h"
-EOF
-
- ;;
- ns32k-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- rs6000-*-lynx*) COREFILE=lynx-core.o ;;
- rs6000-*-aix4*) COREFILE=rs6000-core.o ;;
- rs6000-*-*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix4*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix*) COREFILE=rs6000-core.o ;;
- sparc-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- tahoe-*-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/tahoe.h"
-EOF
-
- ;;
- vax-*-ultrix2*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxult2.h"
-EOF
-
- ;;
- vax-*-ultrix*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxult2.h"
-EOF
-
- ;;
- vax-*-*)
- COREFILE=trad-core.o
- cat >> confdefs.h <<\EOF
-#define TRAD_HEADER "hosts/vaxbsd.h"
-EOF
-
- ;;
- esac
-
- case "$COREFILE" in
- aix386-core.o) COREFLAG=-DAIX386_CORE ;;
- hppabsd-core.o) COREFLAG=-DHPPABSD_CORE ;;
- hpux-core.o) COREFLAG=-DHPUX_CORE ;;
- irix-core.o) COREFLAG=-DIRIX_CORE ;;
- lynx-core.o) COREFLAG=-DLYNX_CORE ;;
- osf-core.o) COREFLAG=-DOSF_CORE ;;
- ptrace-core.o) COREFLAG=-DPTRACE_CORE ;;
- rs6000-core.o) COREFLAG="$COREFLAG -DAIX_CORE" ;;
- trad-core.o) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
- esac
-
- # The ELF code uses the native <sys/procfs.h> to handle core files.
- # Define HAVE_SYS_PROCFS_H if the file exists and defines
- # prstatus_t.
- echo $ac_n "checking for sys/procfs.h""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'bfd_cv_header_sys_procfs_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1640 "configure"
-#include "confdefs.h"
-#include <sys/procfs.h>
-int main() { return 0; }
-int t() {
-prstatus_t t;
-; return 0; }
-EOF
-if { (eval echo configure:1648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- bfd_cv_header_sys_procfs_h=yes
-else
- rm -rf conftest*
- bfd_cv_header_sys_procfs_h=no
-fi
-rm -f conftest*
-
-fi
-
- echo "$ac_t""$bfd_cv_header_sys_procfs_h" 1>&6
- if test $bfd_cv_header_sys_procfs_h = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_PROCFS_H 1
-EOF
-
- fi
-
-fi
-
-
-
-# target stuff:
-
-# Canonicalize the secondary target names.
-if test -n "$enable_targets" ; then
- for targ in `echo $enable_targets | sed 's/,/ /g'`
- do
- result=`$ac_config_sub $targ 2>/dev/null`
- if test -n "$result" ; then
- canon_targets="$canon_targets $result"
- else
- # Allow targets that config.sub doesn't recognize, like "all".
- canon_targets="$canon_targets $targ"
- fi
- done
-fi
-
-all_targets=false
-defvec=
-selvecs=
-selarchs=
-TDEFINES=
-for targ in $target $canon_targets
-do
- if test "x$targ" = "xall"; then
- all_targets=true
- else
- . $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
- defvec=$targ_defvec
- fi
- selvecs="$selvecs $targ_defvec $targ_selvecs"
- selarchs="$selarchs $targ_archs"
- TDEFINES="$TDEFINES $targ_cflags"
- fi
-done
-
-
-# This processing still needs to be done if we're to decide properly whether
-# 64-bit support needs to be compiled in. Currently, it will be included if
-# the default or any other explicitly requested target requires it; it
-# will not be included on a 32-bit host if no 64-bit target is requested, and
-# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
-# used.
-
-# uniq the default and selected vectors in all the configured targets.
-f=""
-for i in $selvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selvecs="$f"
-
-# uniq the architectures in all the configured targets.
-f=""
-for i in $selarchs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selarchs="$f"
-
-# Target backend .o files.
-tb=
-
-elf="elf.o elflink.o"
-
-for vec in $selvecs
-do
- case "$vec" in
- # This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
- a29kcoff_big_vec) tb="$tb coff-a29k.o cofflink.o" ;;
- a_out_adobe_vec) tb="$tb aout-adobe.o aout32.o" ;;
- armcoff_little_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armcoff_big_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armpe_little_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpe_big_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpei_little_vec) tb="$tb pei-arm.o cofflink.o " ;;
- armpei_big_vec) tb="$tb pei-arm.o cofflink.o " ;;
- aout0_big_vec) tb="$tb aout0.o aout32.o" ;;
- aout_arm_big_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_arm_little_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_mips_big_vec) tb="$tb mipsbsd.o aout32.o" ;;
- aout_mips_little_vec) tb="$tb mipsbsd.o aout32.o" ;;
- apollocoff_vec) tb="$tb coff-apollo.o" ;;
- b_out_vec_big_host) tb="$tb bout.o aout32.o" ;;
- b_out_vec_little_host) tb="$tb bout.o aout32.o" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;;
- bfd_elf32_little_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;;
- bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;;
- bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.o elf64.o $elf"
- target64=true ;;
- cisco_core_vec) tb="$tb cisco-core.o" ;;
- demo_64_vec) tb="$tb demo64.o aout64.o"
- target64=true ;;
- ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o"
- target64=true ;;
- h8300coff_vec) tb="$tb coff-h8300.o reloc16.o" ;;
- h8500coff_vec) tb="$tb coff-h8500.o reloc16.o" ;;
- host_aout_vec) tb="$tb host-aout.o aout32.o" ;;
- hp300bsd_vec) tb="$tb hp300bsd.o aout32.o" ;;
- hp300hpux_vec) tb="$tb hp300hpux.o aout32.o" ;;
- i386aout_vec) tb="$tb i386aout.o aout32.o" ;;
- i386bsd_vec) tb="$tb i386bsd.o aout32.o" ;;
- i386coff_vec) tb="$tb coff-i386.o cofflink.o" ;;
- i386dynix_vec) tb="$tb i386dynix.o aout32.o" ;;
- i386freebsd_vec) tb="$tb i386freebsd.o aout32.o" ;;
- i386msdos_vec) tb="$tb i386msdos.o" ;;
- i386pe_vec) tb="$tb pe-i386.o cofflink.o " ;;
- i386pei_vec) tb="$tb pei-i386.o cofflink.o" ;;
- i386linux_vec) tb="$tb i386linux.o aout32.o" ;;
- i386lynx_aout_vec) tb="$tb i386lynx.o lynx-core.o aout32.o" ;;
- i386lynx_coff_vec) tb="$tb cf-i386lynx.o cofflink.o lynx-core.o" ;;
- i386mach3_vec) tb="$tb i386mach3.o aout32.o" ;;
- i386netbsd_vec) tb="$tb i386netbsd.o aout32.o" ;;
- i386os9k_vec) tb="$tb i386os9k.o aout32.o" ;;
- i860coff_vec) tb="$tb coff-i860.o cofflink.o" ;;
- icoff_big_vec) tb="$tb coff-i960.o cofflink.o" ;;
- icoff_little_vec) tb="$tb coff-i960.o cofflink.o" ;;
- ieee_vec) tb="$tb ieee.o" ;;
- m68kcoff_vec) tb="$tb coff-m68k.o cofflink.o" ;;
- m68kcoffun_vec) tb="$tb coff-u68k.o coff-m68k.o cofflink.o" ;;
- m68klinux_vec) tb="$tb m68klinux.o aout32.o" ;;
- m68klynx_aout_vec) tb="$tb m68klynx.o lynx-core.o aout32.o" ;;
- m68klynx_coff_vec) tb="$tb cf-m68klynx.o coff-m68k.o cofflink.o lynx-core.o" ;;
- m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;;
- m88kbcs_vec) tb="$tb coff-m88k.o" ;;
- newsos3_vec) tb="$tb newsos3.o aout32.o" ;;
- nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.o nlm32.o nlm.o" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.o nlm32.o nlm.o"
- target64=true ;;
- riscix_vec) tb="$tb aout32.o riscix.o" ;;
- nlm32_powerpc_vec) tb="$tb nlm32-ppc.o nlm32.o nlm.o" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.o aout-ns32k.o" ;;
- pc532machaout_vec) tb="$tb pc532-mach.o aout-ns32k.o" ;;
- pmac_xcoff_vec) tb="$tb coff-pmac.o xcofflink.o" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.o xcofflink.o" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- som_vec) tb="$tb som.o" ;;
- sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;;
- sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;;
- sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;;
- sparccoff_vec) tb="$tb coff-sparc.o" ;;
- srec_vec) tb="$tb srec.o" ;;
- sunos_big_vec) tb="$tb sunos.o aout32.o" ;;
- symbolsrec_vec) tb="$tb srec.o" ;;
- tekhex_vec) tb="$tb tekhex.o" ;;
- we32kcoff_vec) tb="$tb coff-we32k.o" ;;
- z8kcoff_vec) tb="$tb coff-z8k.o reloc16.o" ;;
- w65_vec) tb="$tb coff-w65.o reloc16.o" ;;
- versados_vec) tb="$tb versados.o" ;;
-
- "") ;;
- *) { echo "configure: error: *** unknown target vector $vec" 1>&2; exit 1; } ;;
- esac
-done
-
-# Target architecture .o files.
-ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g`
-
-# Weed out duplicate .o files.
-f=""
-for i in $tb ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-tb="$f"
-
-f=""
-for i in $ta ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-ta="$f"
-
-bfd_backends="$tb"
-bfd_machines="$ta"
-
-if test x${all_targets} = xtrue ; then
- bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
- bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
- selvecs=
- selarchs=
-else # all_targets is true
- # Only set these if they will be nonempty, for the clever echo.
- test -n "$selvecs" &&
- selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
- test -n "$selarchs" &&
- selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
-fi # all_targets is true
-
-case ${host64}-${target64}-${want64} in
- *true*)
- wordsize=64
- all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
- ;;
- false-false-false)
- wordsize=32
- all_backends='$(BFD32_BACKENDS)'
- ;;
-esac
-
-
-
-
-
-
-tdefaults=""
-test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
-test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
-test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
-
-
-for ac_func in valloc getpagesize
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1928 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_mmap=no
-else
-cat > conftest.$ac_ext <<EOF
-#line 1980 "configure"
-#include "confdefs.h"
-
-/* Thanks to Mike Haertel and Jim Avera for this test. */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#ifndef HAVE_GETPAGESIZE
-# include <sys/param.h>
-# ifdef EXEC_PAGESIZE
-# define getpagesize() EXEC_PAGESIZE
-# else
-# ifdef NBPG
-# define getpagesize() NBPG * CLSIZE
-# ifndef CLSIZE
-# define CLSIZE 1
-# endif
-# else
-# ifdef NBPC
-# define getpagesize() NBPC
-# else
-# define getpagesize() PAGESIZE /* SVR4 */
-# endif
-# endif
-# endif
-#endif
-
-#ifndef HAVE_VALLOC
-# define valloc malloc
-#endif
-
-#ifdef __cplusplus
-extern "C" { void *valloc(unsigned), *malloc(unsigned); }
-#else
-char *valloc(), *malloc();
-#endif
-
-int
-main()
-{
- char *buf1, *buf2, *buf3;
- int i = getpagesize(), j;
- int i2 = i * 2;
- int fd;
-
- buf1 = (char *)valloc(i2);
- buf2 = (char *)valloc(i);
- buf3 = (char *)malloc(i2);
- for (j = 0; j < i2; ++j)
- *(buf1 + j) = rand();
- fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
- write(fd, buf1, i2);
- mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
- for (j = 0; j < i; ++j)
- if (*(buf1 + j) != *(buf2 + j))
- exit(1);
- lseek(fd, (long)i, 0);
- read(fd, buf2, i); /* read into mapped memory -- file should not change */
- /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
- lseek(fd, (long)0, 0);
- read(fd, buf3, i2);
- for (j = 0; j < i2; ++j)
- if (*(buf1 + j) != *(buf3 + j))
- exit(1);
- exit(0);
-}
-
-EOF
-{ (eval echo configure:2049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_func_mmap=yes
-else
- ac_cv_func_mmap=no
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_func_mmap" 1>&6
-if test $ac_cv_func_mmap = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_MMAP 1
-EOF
-
-fi
-
-for ac_func in madvise mprotect
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2074 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-case ${want_mmap}+${ac_cv_func_mmap} in
- true+yes ) cat >> confdefs.h <<\EOF
-#define USE_MMAP 1
-EOF
- ;;
-esac
-
-rm -f doc/config.status
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
- >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.8"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile doc/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@target@%$target%g
-s%@target_alias@%$target_alias%g
-s%@target_cpu@%$target_cpu%g
-s%@target_vendor@%$target_vendor%g
-s%@target_os@%$target_os%g
-s%@build@%$build%g
-s%@build_alias@%$build_alias%g
-s%@build_cpu@%$build_cpu%g
-s%@build_vendor@%$build_vendor%g
-s%@build_os@%$build_os%g
-s%@CC@%$CC%g
-s%@HDEFINES@%$HDEFINES%g
-s%@AR@%$AR%g
-s%@RANLIB@%$RANLIB%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@ALLLIBS@%$ALLLIBS%g
-s%@PICFLAG@%$PICFLAG%g
-s%@SHLIB@%$SHLIB%g
-s%@SHLIB_CC@%$SHLIB_CC%g
-s%@SHLIB_CFLAGS@%$SHLIB_CFLAGS%g
-s%@COMMON_SHLIB@%$COMMON_SHLIB%g
-s%@PICLIST@%$PICLIST%g
-s%@SHLINK@%$SHLINK%g
-s%@HOST_64BIT_LONG@%$HOST_64BIT_LONG%g
-s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g
-s%@CPP@%$CPP%g
-s%@COREFILE@%$COREFILE%g
-s%@COREFLAG@%$COREFLAG%g
-s%@TDEFINES@%$TDEFINES%g
-s%@wordsize@%$wordsize%g
-s%@all_backends@%$all_backends%g
-s%@bfd_backends@%$bfd_backends%g
-s%@bfd_machines@%$bfd_machines%g
-s%@tdefaults@%$tdefaults%g
-
-CEOF
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust relative srcdir, etc. for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
-fi; done
-rm -f conftest.subs
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-CONFIG_HEADERS=${CONFIG_HEADERS-"config.h:config.in"}
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-
-case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
diff --git a/contrib/gdb/bfd/configure.host b/contrib/gdb/bfd/configure.host
deleted file mode 100644
index 484e5bd..0000000
--- a/contrib/gdb/bfd/configure.host
+++ /dev/null
@@ -1,128 +0,0 @@
-# This file is a shell script that overrides some of the tools and
-# flags used on a host specific basis.
-
-# Since the "bfd/hosts" directory is shared by the bfd, opcodes, and
-# binutils directories (at least), the index to it is also shared.
-# This is that index. Each configure.in file should source this file
-# in its per-host part.
-
-# This sets the following shell variables:
-# HDEFINES host specific compiler options
-# host64 set to true if this is a 64 bit host
-# HOST_64BIT_TYPE host 64 bit type
-# SHLIB_CC compiler to use when building shared library
-# SHLIB_CFLAGS flags to use when building shared library
-# PICFLAG may be set to flag to use to compile PIC
-# SHLINK may be set to the name to link the shared library to
-# ALLLIBS may be set to libraries to build
-# HLDFLAGS LDFLAGS specific to the host
-# RPATH_ENVVAR environment variable used to find shared libraries
-
-HDEFINES=
-host64=false
-HOST_64BIT_TYPE=
-
-case "${host}" in
-
-alpha-*-*) host64=true; HOST_64BIT_TYPE=long ;;
-
-hppa*-*-hpux*) HDEFINES=-DHOST_HPPAHPUX ;;
-hppa*-*-hiux*) HDEFINES=-DHOST_HPPAHPUX ;;
-hppa*-*-bsd*) HDEFINES=-DHOST_HPPABSD ;;
-hppa*-*-osf*) HDEFINES=-DHOST_HPPAOSF ;;
-
-i[345]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;;
-i[345]86-sequent-sysv4*) ;;
-i[345]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;;
-
-mips-dec-netbsd*) ;;
-mips-dec-*) HDEFINES="-G 4" ;;
-mips-sgi-irix3*) HDEFINES="-G 4" ;;
-mips-sgi-irix4*) HDEFINES="-G 4" ;;
-mips-*-sysv4*) ;;
-mips-*-sysv*) HDEFINES="-G 4" ;;
-mips-*-riscos*) HDEFINES="-G 4" ;;
-
-m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;;
-
-esac
-
-# If we are configuring with --enable-shared, adjust the shared
-# library support based on the host. This support must work for both
-# the BFD and the opcodes libraries.
-HLDFLAGS=
-RPATH_ENVVAR=LD_LIBRARY_PATH
-SHLIB_CC='$(CC)'
-SHLIB_CFLAGS='-shared'
-if [ "${shared}" = "true" ]; then
- case "${host}" in
- hppa*-*-*) picfrag=../config/mh-papic ;;
- i[3456]86-*-*) picfrag=../config/mh-x86pic ;;
- *-*-*) picfrag=../config/mh-${host_cpu}pic ;;
- esac
- if [ -f "${picfrag}" ]; then
- pic=`sed -n -e 's/^PICFLAG[ ]*=[ ]*\(.*\)$/\1/p' ${picfrag}`
- if [ -n "${pic}" ]; then
- PICFLAG=${pic}
- fi
- fi
-
- case "${host}" in
- *-dec-osf*)
- # -fpic is not needed on the Alpha.
- PICFLAG=
- ;;
- *-*-hpux*)
- # HP/UX uses .sl for shared libraries.
- SHLINK=`echo ${SHLINK} | sed -e 's/so$/sl/'`
- SHLIB_CFLAGS='-shared $(PICFLAG)'
- HLDFLAGS='-Wl,+s,+b,$(libdir)'
- RPATH_ENVVAR=SHLIB_PATH
- ;;
- *-*-irix5*)
- # -fpic is not needed on Irix 5.
- PICFLAG=
- SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
- HLDFLAGS='-Wl,-rpath,$(libdir)'
- ;;
- *-*-linux*aout*)
- ;;
- *-*-linux*)
- SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
- case "$(libdir)" in
- /lib | /usr/lib) ;;
- *) HLDFLAGS='-Wl,-rpath,$(libdir)' ;;
- esac
- ;;
- *-*-sysv4* | *-*-solaris*)
- SHLIB_CFLAGS='-shared -h $(SONAME)'
- HLDFLAGS='-R $(libdir)'
- ;;
- *-*-sunos*)
- # Build a libTARGET-bfd.so.VERSION symlink in the object directory.
- ALLLIBS=`echo ${ALLLIBS} | sed -e 's/\$(SHLINK)/stamp-tshlink/'`
- ;;
- esac
-fi
-
-# On SunOS, if the linker supports the -rpath option, use it to
-# prevent ../bfd and ../opcodes from being included in the run time
-# search path.
-case "${host}" in
- *-*-sunos*)
- echo 'main () { }' > conftest.c
- ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
- if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
- :
- elif grep 'No such file' conftest.t >/dev/null 2>&1; then
- :
- elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
- :
- elif [ "${shared}" = "true" ]; then
- HLDFLAGS='-Wl,-rpath=$(libdir)'
- else
- HLDFLAGS='-Wl,-rpath='
- fi
- rm -f conftest.t conftest.c conftest
- ;;
-esac
diff --git a/contrib/gdb/bfd/configure.in b/contrib/gdb/bfd/configure.in
deleted file mode 100644
index c8b8de5..0000000
--- a/contrib/gdb/bfd/configure.in
+++ /dev/null
@@ -1,577 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-dnl
-AC_PREREQ(2.3)
-AC_INIT(libbfd.c)
-
-AC_ARG_ENABLE(64-bit-bfd,
-[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
-[case "${enableval}" in
- yes) want64=true ;;
- no) want64=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
-esac],[want64=false])dnl
-AC_ARG_ENABLE(targets,
-[ --enable-targets alternative target configurations],
-[case "${enableval}" in
- yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
- ;;
- no) enable_targets= ;;
- *) enable_targets=$enableval ;;
-esac])dnl
-AC_ARG_ENABLE(shared,
-[ --enable-shared build shared BFD library],
-[case "${enableval}" in
- yes) shared=true ;;
- no) shared=false ;;
- *) AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
-esac])dnl
-AC_ARG_ENABLE(commonbfdlib,
-[ --enable-commonbfdlib build shared BFD/opcodes/libiberty library],
-[case "${enableval}" in
- yes) commonbfdlib=true ;;
- no) commonbfdlib=false ;;
- *) AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
-esac])dnl
-AC_ARG_WITH(mmap,
-[ --with-mmap try using mmap for BFD input files if available],
-[case "${withval}" in
- yes) want_mmap=true ;;
- no) want_mmap=false ;;
- *) AC_MSG_ERROR(bad value ${withval} for BFD with-mmap option) ;;
-esac],[want_mmap=false])dnl
-
-AC_CONFIG_HEADER(config.h:config.in)
-
-AC_CONFIG_AUX_DIR(`cd $srcdir/..;pwd`)
-AC_CANONICAL_SYSTEM
-if test -z "$target" ; then
- AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
-fi
-AC_ARG_PROGRAM
-
-host64=false
-target64=false
-
-# host stuff:
-
-ALLLIBS='$(TARGETLIB)'
-PICFLAG=
-SHLIB=unused-shlib
-SHLINK=unused-shlink
-if test "${shared}" = "true"; then
- PICFLAG=-fpic
- if test "${commonbfdlib}" = "true"; then
- ALLLIBS='$(TARGETLIB)'
- else
- ALLLIBS='$(TARGETLIB) $(SHLIB) $(SHLINK)'
-changequote(,)dnl
- SHLIB=libbfd.so.`sed -e 's/[^0-9]*\([0-9.]*\).*/\1/' ${srcdir}/VERSION`
-changequote([,])dnl
- SHLINK=libbfd.so
- fi
-fi
-
-AC_PROG_CC
-
-# Permit host specific settings.
-. ${srcdir}/configure.host
-
-AC_SUBST(HDEFINES)
-AC_CHECK_TOOL(AR, ar)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_PROG_INSTALL
-
-if test "${shared}" = "true"; then
- if test "${GCC}" != "yes" && test "${shared_non_gcc}" != "yes"; then
- AC_MSG_WARN([BFD --enable-shared only supported when using gcc])
- shared=false
- ALLLIBS='$(TARGETLIB)'
- PICFLAG=
- SHLIB=unused-shlib
- fi
-fi
-
-AC_SUBST(ALLLIBS)
-AC_SUBST(PICFLAG)
-AC_SUBST(SHLIB)
-AC_SUBST(SHLIB_CC)
-AC_SUBST(SHLIB_CFLAGS)
-if test "${commonbfdlib}" = "true"; then
- COMMON_SHLIB=yes
- PICLIST=piclist
-else
- COMMON_SHLIB=
- PICLIST=
-fi
-AC_SUBST(COMMON_SHLIB)
-AC_SUBST(PICLIST)
-AC_SUBST(SHLINK)
-
-HOST_64BIT_LONG=0
-if test "x${HOST_64BIT_TYPE}" = "xlong"; then
- HOST_64BIT_LONG=1
-fi
-AC_SUBST(HOST_64BIT_LONG)
-
-BFD_CC_FOR_BUILD
-
-AC_CHECK_HEADERS(stddef.h string.h strings.h stdlib.h time.h unistd.h)
-AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h)
-AC_HEADER_TIME
-AC_CHECK_FUNCS(fcntl getpagesize)
-
-BFD_BINARY_FOPEN
-
-BFD_NEED_DECLARATION(malloc)
-BFD_NEED_DECLARATION(free)
-
-# If we are configured native, pick a core file support file.
-COREFILE=
-COREFLAG=
-if test "${target}" = "${host}"; then
- case "${host}" in
- alpha*-*-linux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/alphalinux.h")
- ;;
- alpha*-*-*) COREFILE=osf-core.o ;;
- arm-*-riscix) COREFILE=trad-core.o ;;
- hppa*-*-hpux*) COREFILE=hpux-core.o ;;
- hppa*-*-hiux*) COREFILE=hpux-core.o ;;
- hppa*-*-bsd*) COREFILE="hpux-core.o hppabsd-core.o"
- COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
-changequote(,)dnl
- i[345]86-sequent-bsd*)
-changequote([,])dnl
- COREFILE=trad-core.o;
- AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h")
- ;;
-changequote(,)dnl
- i[345]86-sequent-sysv4*) ;;
- i[345]86-sequent-sysv*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h")
- ;;
-changequote(,)dnl
- i[345]86-*-bsd* | i[345]86-*-freebsd*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386bsd.h")
- ;;
-changequote(,)dnl
- i[345]86-*-netbsd*)
-changequote([,])dnl
- COREFILE=netbsd-core.o
- ;;
-changequote(,)dnl
- i[345]86-esix-sysv3*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/esix.h")
- ;;
-changequote(,)dnl
- i[345]86-*-sco* | i[345]86-*-isc*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386sco.h")
- ;;
-changequote(,)dnl
- i[345]86-*-mach3*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386mach3.h")
- ;;
-changequote(,)dnl
- i[345]86-*-linux*)
-changequote([,])dnl
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i386linux.h")
- ;;
-changequote(,)dnl
- i[345]86-*-isc*) COREFILE=trad-core.o ;;
- i[345]86-*-aix*) COREFILE=aix386-core.o ;;
-changequote([,])dnl
- i860-*-mach3* | i860-*-osf1*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/i860mach3.h")
- ;;
- mips-dec-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsbsd.h")
- ;;
- mips-dec-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h")
- ;;
- mips-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- mips-dec-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/decstation.h")
- ;;
- mips-sgi-irix4*) COREFILE=irix-core.o ;;
- mips-sgi-irix5*) COREFILE=irix-core.o ;;
- mips-*-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h")
- ;;
- mips-*-sysv4*) ;;
- mips-*-sysv* | mips-*-riscos*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/riscos.h")
- ;;
- mips-sony-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/news-mips.h")
- ;;
- m68*-bull*-sysv*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/dpx2.h")
- ;;
- m68*-hp-hpux*) COREFILE=hpux-core.o ;;
- m68*-hp-bsd*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/hp300bsd.h")
- ;;
- m68*-*-linux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m68klinux.h")
- ;;
- m68*-motorola-sysv*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER, "hosts/delta68.h")
- ;;
- m68*-sony-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/news.h")
- ;;
- m68*-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- m68*-apple-aux*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m68kaux.h")
- ;;
- m88*-*-sysv4*) ;;
- m88*-motorola-sysv*) COREFILE=ptrace-core.o ;;
- m88*-*-mach3*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/m88kmach3.h")
- ;;
- ns32k-pc532-mach)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/pc532mach.h")
- ;;
- ns32k-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- rs6000-*-lynx*) COREFILE=lynx-core.o ;;
- rs6000-*-aix4*) COREFILE=rs6000-core.o ;;
- rs6000-*-*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix4*) COREFILE=rs6000-core.o ;;
- powerpc-*-aix*) COREFILE=rs6000-core.o ;;
- sparc-*-netbsd*)
- COREFILE=netbsd-core.o
- ;;
- tahoe-*-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/tahoe.h")
- ;;
- vax-*-ultrix2*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxult2.h")
- ;;
- vax-*-ultrix*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxult2.h")
- ;;
- vax-*-*)
- COREFILE=trad-core.o
- AC_DEFINE(TRAD_HEADER,"hosts/vaxbsd.h")
- ;;
- esac
-
- case "$COREFILE" in
- aix386-core.o) COREFLAG=-DAIX386_CORE ;;
- hppabsd-core.o) COREFLAG=-DHPPABSD_CORE ;;
- hpux-core.o) COREFLAG=-DHPUX_CORE ;;
- irix-core.o) COREFLAG=-DIRIX_CORE ;;
- lynx-core.o) COREFLAG=-DLYNX_CORE ;;
- osf-core.o) COREFLAG=-DOSF_CORE ;;
- ptrace-core.o) COREFLAG=-DPTRACE_CORE ;;
- rs6000-core.o) COREFLAG="$COREFLAG -DAIX_CORE" ;;
- trad-core.o) COREFLAG="$COREFLAG -DTRAD_CORE" ;;
- esac
-
- # The ELF code uses the native <sys/procfs.h> to handle core files.
- # Define HAVE_SYS_PROCFS_H if the file exists and defines
- # prstatus_t.
- AC_MSG_CHECKING([for sys/procfs.h])
- AC_CACHE_VAL(bfd_cv_header_sys_procfs_h,
- [AC_TRY_COMPILE([#include <sys/procfs.h>],
- [prstatus_t t;],
- bfd_cv_header_sys_procfs_h=yes, bfd_cv_header_sys_procfs_h=no)])
- AC_MSG_RESULT($bfd_cv_header_sys_procfs_h)
- if test $bfd_cv_header_sys_procfs_h = yes; then
- AC_DEFINE(HAVE_SYS_PROCFS_H)
- fi
-
-fi
-AC_SUBST(COREFILE)
-AC_SUBST(COREFLAG)
-
-# target stuff:
-
-# Canonicalize the secondary target names.
-if test -n "$enable_targets" ; then
- for targ in `echo $enable_targets | sed 's/,/ /g'`
- do
- result=`$ac_config_sub $targ 2>/dev/null`
- if test -n "$result" ; then
- canon_targets="$canon_targets $result"
- else
- # Allow targets that config.sub doesn't recognize, like "all".
- canon_targets="$canon_targets $targ"
- fi
- done
-fi
-
-all_targets=false
-defvec=
-selvecs=
-selarchs=
-TDEFINES=
-for targ in $target $canon_targets
-do
- if test "x$targ" = "xall"; then
- all_targets=true
- else
- . $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
- defvec=$targ_defvec
- fi
- selvecs="$selvecs $targ_defvec $targ_selvecs"
- selarchs="$selarchs $targ_archs"
- TDEFINES="$TDEFINES $targ_cflags"
- fi
-done
-AC_SUBST(TDEFINES)
-
-# This processing still needs to be done if we're to decide properly whether
-# 64-bit support needs to be compiled in. Currently, it will be included if
-# the default or any other explicitly requested target requires it; it
-# will not be included on a 32-bit host if no 64-bit target is requested, and
-# no "--with-64-bit-bfd" option is given, even if "--with-targets=all" is
-# used.
-
-# uniq the default and selected vectors in all the configured targets.
-f=""
-for i in $selvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selvecs="$f"
-
-# uniq the architectures in all the configured targets.
-f=""
-for i in $selarchs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-selarchs="$f"
-
-# Target backend .o files.
-tb=
-
-elf="elf.o elflink.o"
-
-for vec in $selvecs
-do
- case "$vec" in
- # This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
- a29kcoff_big_vec) tb="$tb coff-a29k.o cofflink.o" ;;
- a_out_adobe_vec) tb="$tb aout-adobe.o aout32.o" ;;
- armcoff_little_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armcoff_big_vec) tb="$tb coff-arm.o cofflink.o " ;;
- armpe_little_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpe_big_vec) tb="$tb pe-arm.o cofflink.o " ;;
- armpei_little_vec) tb="$tb pei-arm.o cofflink.o " ;;
- armpei_big_vec) tb="$tb pei-arm.o cofflink.o " ;;
- aout0_big_vec) tb="$tb aout0.o aout32.o" ;;
- aout_arm_big_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_arm_little_vec) tb="$tb aout-arm.o aout32.o" ;;
- aout_mips_big_vec) tb="$tb mipsbsd.o aout32.o" ;;
- aout_mips_little_vec) tb="$tb mipsbsd.o aout32.o" ;;
- apollocoff_vec) tb="$tb coff-apollo.o" ;;
- b_out_vec_big_host) tb="$tb bout.o aout32.o" ;;
- b_out_vec_little_host) tb="$tb bout.o aout32.o" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;;
- bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;;
- bfd_elf32_little_generic_vec) tb="$tb elf32-gen.o elf32.o $elf" ;;
- bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
- bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;;
- bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;;
- bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;;
- bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.o elf64.o $elf"
- target64=true ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.o elf64.o $elf"
- target64=true ;;
- cisco_core_vec) tb="$tb cisco-core.o" ;;
- demo_64_vec) tb="$tb demo64.o aout64.o"
- target64=true ;;
- ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o"
- target64=true ;;
- h8300coff_vec) tb="$tb coff-h8300.o reloc16.o" ;;
- h8500coff_vec) tb="$tb coff-h8500.o reloc16.o" ;;
- host_aout_vec) tb="$tb host-aout.o aout32.o" ;;
- hp300bsd_vec) tb="$tb hp300bsd.o aout32.o" ;;
- hp300hpux_vec) tb="$tb hp300hpux.o aout32.o" ;;
- i386aout_vec) tb="$tb i386aout.o aout32.o" ;;
- i386bsd_vec) tb="$tb i386bsd.o aout32.o" ;;
- i386coff_vec) tb="$tb coff-i386.o cofflink.o" ;;
- i386dynix_vec) tb="$tb i386dynix.o aout32.o" ;;
- i386freebsd_vec) tb="$tb i386freebsd.o aout32.o" ;;
- i386msdos_vec) tb="$tb i386msdos.o" ;;
- i386pe_vec) tb="$tb pe-i386.o cofflink.o " ;;
- i386pei_vec) tb="$tb pei-i386.o cofflink.o" ;;
- i386linux_vec) tb="$tb i386linux.o aout32.o" ;;
- i386lynx_aout_vec) tb="$tb i386lynx.o lynx-core.o aout32.o" ;;
- i386lynx_coff_vec) tb="$tb cf-i386lynx.o cofflink.o lynx-core.o" ;;
- i386mach3_vec) tb="$tb i386mach3.o aout32.o" ;;
- i386netbsd_vec) tb="$tb i386netbsd.o aout32.o" ;;
- i386os9k_vec) tb="$tb i386os9k.o aout32.o" ;;
- i860coff_vec) tb="$tb coff-i860.o cofflink.o" ;;
- icoff_big_vec) tb="$tb coff-i960.o cofflink.o" ;;
- icoff_little_vec) tb="$tb coff-i960.o cofflink.o" ;;
- ieee_vec) tb="$tb ieee.o" ;;
- m68kcoff_vec) tb="$tb coff-m68k.o cofflink.o" ;;
- m68kcoffun_vec) tb="$tb coff-u68k.o coff-m68k.o cofflink.o" ;;
- m68klinux_vec) tb="$tb m68klinux.o aout32.o" ;;
- m68klynx_aout_vec) tb="$tb m68klynx.o lynx-core.o aout32.o" ;;
- m68klynx_coff_vec) tb="$tb cf-m68klynx.o coff-m68k.o cofflink.o lynx-core.o" ;;
- m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;;
- m88kbcs_vec) tb="$tb coff-m88k.o" ;;
- newsos3_vec) tb="$tb newsos3.o aout32.o" ;;
- nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.o nlm32.o nlm.o" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.o nlm32.o nlm.o"
- target64=true ;;
- riscix_vec) tb="$tb aout32.o riscix.o" ;;
- nlm32_powerpc_vec) tb="$tb nlm32-ppc.o nlm32.o nlm.o" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.o aout-ns32k.o" ;;
- pc532machaout_vec) tb="$tb pc532-mach.o aout-ns32k.o" ;;
- pmac_xcoff_vec) tb="$tb coff-pmac.o xcofflink.o" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.o xcofflink.o" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.o cofflink.o" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;;
- shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;;
- som_vec) tb="$tb som.o" ;;
- sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;;
- sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;;
- sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;;
- sparccoff_vec) tb="$tb coff-sparc.o" ;;
- srec_vec) tb="$tb srec.o" ;;
- sunos_big_vec) tb="$tb sunos.o aout32.o" ;;
- symbolsrec_vec) tb="$tb srec.o" ;;
- tekhex_vec) tb="$tb tekhex.o" ;;
- we32kcoff_vec) tb="$tb coff-we32k.o" ;;
- z8kcoff_vec) tb="$tb coff-z8k.o reloc16.o" ;;
- w65_vec) tb="$tb coff-w65.o reloc16.o" ;;
- versados_vec) tb="$tb versados.o" ;;
-
- "") ;;
- *) AC_MSG_ERROR(*** unknown target vector $vec) ;;
- esac
-done
-
-# Target architecture .o files.
-ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g`
-
-# Weed out duplicate .o files.
-f=""
-for i in $tb ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-tb="$f"
-
-f=""
-for i in $ta ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-ta="$f"
-
-bfd_backends="$tb"
-bfd_machines="$ta"
-
-if test x${all_targets} = xtrue ; then
- bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
- bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
- selvecs=
- selarchs=
-else # all_targets is true
- # Only set these if they will be nonempty, for the clever echo.
- test -n "$selvecs" &&
- selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
- test -n "$selarchs" &&
- selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
-fi # all_targets is true
-
-case ${host64}-${target64}-${want64} in
- *true*)
- wordsize=64
- all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
- ;;
- false-false-false)
- wordsize=32
- all_backends='$(BFD32_BACKENDS)'
- ;;
-esac
-
-AC_SUBST(wordsize)
-AC_SUBST(all_backends)
-AC_SUBST(bfd_backends)
-AC_SUBST(bfd_machines)
-
-tdefaults=""
-test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
-test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
-test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
-AC_SUBST(tdefaults)
-
-dnl AC_CHECK_HEADERS(sys/mman.h)
-AC_FUNC_MMAP
-AC_CHECK_FUNCS(madvise mprotect)
-case ${want_mmap}+${ac_cv_func_mmap} in
- true+yes ) AC_DEFINE(USE_MMAP) ;;
-esac
-
-rm -f doc/config.status
-AC_OUTPUT(Makefile doc/Makefile,
-[case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])
diff --git a/contrib/gdb/bfd/corefile.c b/contrib/gdb/bfd/corefile.c
deleted file mode 100644
index 212f519..0000000
--- a/contrib/gdb/bfd/corefile.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Core file generic interface routines for BFD.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- Core files
-
-DESCRIPTION
- These are functions pertaining to core files.
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-/*
-FUNCTION
- bfd_core_file_failing_command
-
-SYNOPSIS
- CONST char *bfd_core_file_failing_command(bfd *abfd);
-
-DESCRIPTION
- Return a read-only string explaining which program was running
- when it failed and produced the core file @var{abfd}.
-
-*/
-
-CONST char *
-bfd_core_file_failing_command (abfd)
- bfd *abfd;
-{
- if (abfd->format != bfd_core) {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
- return BFD_SEND (abfd, _core_file_failing_command, (abfd));
-}
-
-/*
-FUNCTION
- bfd_core_file_failing_signal
-
-SYNOPSIS
- int bfd_core_file_failing_signal(bfd *abfd);
-
-DESCRIPTION
- Returns the signal number which caused the core dump which
- generated the file the BFD @var{abfd} is attached to.
-*/
-
-int
-bfd_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- if (abfd->format != bfd_core) {
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
- }
- return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
-}
-
-
-/*
-FUNCTION
- core_file_matches_executable_p
-
-SYNOPSIS
- boolean core_file_matches_executable_p
- (bfd *core_bfd, bfd *exec_bfd);
-
-DESCRIPTION
- Return <<true>> if the core file attached to @var{core_bfd}
- was generated by a run of the executable file attached to
- @var{exec_bfd}, <<false>> otherwise.
-*/
-boolean
-core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- return BFD_SEND (core_bfd, _core_file_matches_executable_p,
- (core_bfd, exec_bfd));
-}
diff --git a/contrib/gdb/bfd/cpu-i386.c b/contrib/gdb/bfd/cpu-i386.c
deleted file mode 100644
index 4041090..0000000
--- a/contrib/gdb/bfd/cpu-i386.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD support for the Intel 386 architecture.
- Copyright 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_i386_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_i386,
- 0, /* only 1 machine */
- "i386",
- "i386",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/dep-in.sed b/contrib/gdb/bfd/dep-in.sed
deleted file mode 100644
index 1cbd786..0000000
--- a/contrib/gdb/bfd/dep-in.sed
+++ /dev/null
@@ -1,24 +0,0 @@
-:loop
-/\\$/N
-/\\$/b loop
-
-s! @BFD_H@!!g
-s!@INCDIR@!$(INCDIR)!g
-s!@SRCDIR@/!!g
-s!hosts/[^ ]*\.h ! !g
-s/ sysdep.h//g
-s/ libbfd.h//g
-s/ config.h//g
-s! \$(INCDIR)/fopen-[^ ]*\.h!!g
-s! \$(INCDIR)/ansidecl\.h!!g
-s! \$(INCDIR)/obstack\.h!!g
-
-s/\\\n */ /g
-
-s/ *$//
-s/ */ /g
-s/ *:/:/g
-/:$/d
-
-s/\(.\{50\}[^ ]*\) /\1 \\\
- /g
diff --git a/contrib/gdb/bfd/doc/ChangeLog b/contrib/gdb/bfd/doc/ChangeLog
deleted file mode 100644
index f076e37..0000000
--- a/contrib/gdb/bfd/doc/ChangeLog
+++ /dev/null
@@ -1,268 +0,0 @@
-Tue Jan 30 14:10:46 1996 Ian Lance Taylor <ian@cygnus.com>
-
- From Ronald F. Guilmette <rfg@monkeys.com>:
- * Makefile.in (libbfd.h): Depend upon proto.str.
- (libcoff.h, bfd.h): Likewise.
-
-Fri Nov 3 14:46:48 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (SRCDOC, SRCPROT, core.texi, bfd.h): Use corefile.c,
- renamed from core.c.
-
-Wed Nov 1 14:28:23 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de>
-
- * chew.c: Include <ctype.h>.
-
-Fri Oct 6 16:23:34 1995 Ken Raeburn <raeburn@cygnus.com>
-
- Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
-
- * Makefile.in (Makefile): Only remake this Makefile.
-
-Wed Oct 4 15:51:05 1995 Ken Raeburn <raeburn@cygnus.com>
-
- * chew.c: Include <stdio.h>.
-
-Tue Sep 12 18:14:50 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (maintainer-clean): New target.
-
-Thu Aug 31 12:18:43 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (bfd.h): Add additional #endif at end of bfd.h if
- __cplusplus is defined.
-
-Tue Nov 29 16:13:34 1994 Doug Evans <dje@canuck.cygnus.com>
-
- * chew.c (write_buffer): New argument `f', all callers changed.
- (stdout, stderr, print, drop, idrop): New forth words.
- * proto.str (COMMENT): New command.
- * doc.str (COMMENT): Likewise.
-
-Mon Sep 12 11:44:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * Makefile.in (DOCFILES): Remove ctor.texi.
- (IPROTOS): Remove ctor.ip.
- (SRCIPROT): Remove $(srcdir)/../ctor.c.
- (ctor.texi): Remove target.
- (libbfd.h): Remove dependency on $(srcdir)/../ctor.c. Remove
- $(MKDOC) run on $(srcdir)/../ctor.c.
- * bfd.texinfo (Constructors): Remove section.
-
-Fri Sep 2 13:33:44 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * chew.c: Include assert.h. Added prototypes for most functions.
- Changed most uses of int to long. Do bounds checking on the
- stacks. Added comment at the beginning documenting most of the
- intrinsics. Lots of whitespace changes. Re-ordered some
- functions.
- (die, check_range, icheck_range): New functions.
- (strip_trailing_newlines, print_stack_level): New functions.
- (translatecomments): Don't insert tab before "/*".
- (iscommand): Minimum command length is now 4.
- (nextword): Handle some \-sequences.
- (push_addr): Deleted.
- (main): Add new intrinsics strip_trailing_newlines and
- print_stack_level. Complain at end if stack contains more than
- one element, or less.
- (remchar): Make sure the string is not empty before chopping off a
- character.
-
- * doc.str, proto.str: Handle new commands SENUM, ENUM, ENUMX,
- ENUMEQ, ENUMEQX, ENUMDOC.
-
-Wed Jan 12 18:37:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * bfd.texinfo: Added Linker Functions node.
- * doc/Makefile.in (DOCFILES): Added linker.texi.
- (SRCDOC): Added linker.c.
- (linker.texi): New target.
-
-Tue Jan 4 10:52:56 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * chew.c: Don't rely on a correct declaration of exit.
- (chew_exit): New function which just calls exit.
- (main): Use it.
-
-Mon Jan 3 11:40:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * bfd.texinfo: Added Hash Tables node.
- * Makefile.in (DOCFILES): Added hash.texi.
- (SRCDOC): Added hash.c.
- (hash.texi): New target.
-
-Thu Dec 30 16:57:04 1993 Ken Raeburn (raeburn@cujo.cygnus.com)
-
- * Makefile.in: Delete all references to seclet.c, since it's just
- been deleted. Don't mention hash.c, linker.c, or genlink.h yet,
- since they don't contain documentation yet (hint, hint!).
-
-Fri Nov 5 10:58:53 1993 David J. Mackenzie (djm@thepub.cygnus.com)
-
- * bfd.texinfo: Small cleanups.
-
-Fri Nov 19 03:46:11 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (archures.texi): Depends on $(MKDOC).
-
-Tue Aug 10 14:22:39 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * bfd.texinfo (BFD back end): Don't include elfcode.texi, since
- it's empty now and that triggers a makeinfo bug.
-
-Mon Aug 9 16:27:30 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * bfd.texinfo (BFD back end): New section on ELF, includes
- elf.texi and elfcode.texi.
- * Makefile.in (DOCFILES): Include elf.texi, elfcode.texi.
- (SRCDOC): Include elfcode.h, elf.c.
- (elf.texi, elfcode.texi): New intermediate targets.
-
-Thu Jun 24 13:48:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
-
- * Makefile.in (.c.o, chew.o): Put CFLAGS last.
- * bfdsumm.texi: New file, broken out of bfd.texinfo, to share
- with ld.texinfo.
-
-Mon Jun 14 12:07:07 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com)
-
- * Makefile.in (install-info): remove parentdir cruft,
-
-Wed Jun 9 16:00:32 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in (mostlyclean): Remove chew.o.
-
-Tue May 25 14:46:58 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (libbfd.h): Use elfcode.h, not elf32.c.
-
-Mon May 24 15:50:07 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * chew.c (compile): Add a couple of missing casts.
-
-Wed May 12 14:45:14 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (CC_FOR_BUILD): New variable, define to be $(CC).
- (chew.o, $(MKDOC)): Build using CC_FOR_BUILD rather than CC, since
- it must run on the build machine.
-
-Tue Apr 6 22:38:10 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (chew): Don't compile from .c to executable in a
- single step; it puts a temporary .o filename into the executable,
- which makes multi-stage comparisons fail. Compile chew.c to
- chew.o, and link that, which makes identical executables every time.
-
-Wed Mar 24 17:26:29 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
-
- * Makefile.in: fix typo (bfd.texinfo not bfd.texino)
-
-Fri Mar 19 01:13:00 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
-
- * bfd.texinfo: Since BFD version number has been bumped, do same
- to "version number" on title page, and elsewhere. Should be
- fixed to extract real version number.
-
-Tue Mar 16 12:15:13 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * Makefile.in: Add *clean rules.
-
-Mon Jan 11 18:43:56 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (libbfd.h): Removed duplicate init.c and libbfd.c.
- Added seclet.c.
- (bfd.h): Added dependency on bfd.c and seclet.c. Added seclet.c
- to build.
-
-Thu Dec 17 19:35:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: added dvi target, define and use $(TEXI2DVI)
-
-Thu Dec 3 17:42:48 1992 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * Makefile.in (TEXIDIR): New variable.
- (bfd.dvi): Look for bfd.texinfo in $(srcdir). Generate index.
-
- * bfd.texinfo: Minor doc fixes.
-
-Thu Nov 5 03:13:55 1992 John Gilmore (gnu@cygnus.com)
-
- Cleanup: Replace all uses of EXFUN in the BFD sources, with PARAMS.
-
- * doc/chew.c (exfunstuff): Eliminate.
- (paramstuff): Replace exfunstuff with function to generate PARAMS.
- * doc/proto.str: Use paramstuff rather than exfunstuff.
-
-Mon Aug 17 12:40:32 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * chew.c: various patches provided by Howard Chu.
-
-Fri Jun 19 18:59:54 1992 John Gilmore (gnu at cygnus.com)
-
- * Makefile.in (libbfd.h): Add elf.c as a source of prototypes.
-
-Mon May 11 18:55:59 1992 John Gilmore (gnu at cygnus.com)
-
- * chew.c: exit() should be declared by config files, not by
- portable source code. Its type could be int or void function.
-
-Mon May 4 13:45:57 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: another CFLAGS correction.
-
-Tue Apr 28 10:21:32 1992 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * Makefile.in: Do the CFLAGS thing.
-
-Fri Apr 10 22:34:52 1992 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (MINUS_G): Add macro and default to -g.
-
-Fri Mar 6 18:53:18 1992 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * chew.c: now has -w switch turn on warnings
-
-Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in, configure.in: removed traces of namesubdir,
- -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
- copyrights to '92, changed some from Cygnus to FSF.
-
-Tue Dec 10 22:11:05 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: build chew into the current directory. Complete
- the MKDOC macro transition.
-
-Tue Dec 10 08:26:28 1991 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * chew.c: don't core dump when can't open file
- * Makefile.in: get proto.str from the right place when built in
- odd directories
-
-Tue Dec 10 04:07:25 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: infodir belongs in datadir.
-
-Sat Dec 7 17:01:23 1991 Steve Chamberlain (sac at rtl.cygnus.com)
-
- * chew.c: Much modified
- * proto.str, doc.str: New files for extracting to product
- prototypes and documents respectively.
-
-
-Fri Dec 6 22:57:12 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: added standards.text support, host/site/target
- inclusion hooks, install using INSTALL_DATA rather than cp,
- don't echo on install.
-
-Thu Dec 5 22:46:17 1991 K. Richard Pixley (rich at rtl.cygnus.com)
-
- * Makefile.in: idestdir and ddestdir go away. Added copyrights
- and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
- and mandir now keyed off datadir by default.
-
-
-Local Variables:
-version-control: never
-End:
diff --git a/contrib/gdb/bfd/doc/Makefile.in b/contrib/gdb/bfd/doc/Makefile.in
deleted file mode 100644
index aa3a76c..0000000
--- a/contrib/gdb/bfd/doc/Makefile.in
+++ /dev/null
@@ -1,311 +0,0 @@
-#
-# Makefile
-# Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-
-prefix = @prefix@
-
-exec_prefix = @exec_prefix@
-bindir = $(exec_prefix)/bin
-libdir = $(exec_prefix)/lib
-
-datadir = $(prefix)/lib
-mandir = $(prefix)/man
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-man3dir = $(mandir)/man3
-man4dir = $(mandir)/man4
-man5dir = $(mandir)/man5
-man6dir = $(mandir)/man6
-man7dir = $(mandir)/man7
-man8dir = $(mandir)/man8
-man9dir = $(mandir)/man9
-infodir = $(prefix)/info
-includedir = $(prefix)/include
-docdir = $(datadir)/doc
-
-MKDOC=./chew
-SHELL = /bin/sh
-
-INSTALL = `cd $(srcdir)/../..;pwd`/install.sh -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL)
-
-MAKEINFO = makeinfo
-TEXI2DVI = texi2dvi
-CFLAGS = -g
-
-CC_FOR_BUILD = $(CC)
-
-#### Host, target, and site specific Makefile fragments come in here.
-###
-
-.c.o:
- $(CC) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include $(H_CFLAGS) $(CFLAGS) $<
-
-DOCFILES = aoutx.texi archive.texi archures.texi \
- bfd.texi cache.texi coffcode.texi \
- core.texi elf.texi elfcode.texi format.texi libbfd.texi \
- opncls.texi reloc.texi section.texi \
- syms.texi targets.texi init.texi hash.texi linker.texi
-
-PROTOS = archive.p archures.p bfd.p \
- core.p format.p \
- libbfd.p opncls.p reloc.p \
- section.p syms.p targets.p \
- format.p core.p init.p
-
-IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip coffcode.ip
-
-# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction
-# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes,
-# you don't need these three:
-SRCDOC = $(srcdir)/../aoutx.h $(srcdir)/../archive.c \
- $(srcdir)/../archures.c $(srcdir)/../bfd.c \
- $(srcdir)/../cache.c $(srcdir)/../coffcode.h \
- $(srcdir)/../corefile.c $(srcdir)/../elf.c \
- $(srcdir)/../elfcode.h $(srcdir)/../format.c \
- $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \
- $(srcdir)/../reloc.c $(srcdir)/../section.c \
- $(srcdir)/../syms.c $(srcdir)/../targets.c \
- $(srcdir)/../hash.c $(srcdir)/../linker.c
-
-SRCPROT = $(srcdir)/../archive.c $(srcdir)/../archures.c \
- $(srcdir)/../bfd.c $(srcdir)/../coffcode.h $(srcdir)/../corefile.c \
- $(srcdir)/../format.c $(srcdir)/../libbfd.c \
- $(srcdir)/../opncls.c $(srcdir)/../reloc.c \
- $(srcdir)/../section.c $(srcdir)/../syms.c \
- $(srcdir)/../targets.c $(srcdir)/../init.c
-
-SRCIPROT = $(srcdir)/../cache.c $(srcdir)/../libbfd.c \
- $(srcdir)/../reloc.c $(srcdir)/../cpu-h8300.c \
- $(srcdir)/../cpu-i960.c $(srcdir)/../archures.c \
- $(srcdir)/../init.c
-
-STAGESTUFF = $(DOCFILES) *.info*
-
-TEXIDIR = $(srcdir)/../../texinfo/fsf
-
-all install:
-
-info: bfd.info
-
-dvi: bfd.dvi
-
-install-info: info
- for i in *.info* ; do \
- $(INSTALL_DATA) $$i $(infodir)/$$i ; \
- done
-
-docs: $(MKDOC) protos bfd.info bfd.dvi bfd.ps
-
-$(MKDOC): chew.o
- $(CC_FOR_BUILD) -o $(MKDOC) chew.o $(LOADLIBES) $(LDFLAGS)
-
-chew.o: chew.c
- $(CC_FOR_BUILD) -c -I.. -I$(srcdir)/.. -I$(srcdir)/../../include $(H_CFLAGS) $(CFLAGS) $(srcdir)/chew.c
-
-protos: libbfd.h libcoff.h bfd.h
-
-
-# We can't replace these rules with an implicit rule, because
-# makes without VPATH support couldn't find the .h files in `..'.
-
-aoutx.texi: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.texi
-
-archive.texi: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.texi
-
-archures.texi: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.texi
-
-bfd.texi: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.texi
-
-cache.texi: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.texi
-
-coffcode.texi: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.texi
-
-core.texi: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.texi
-
-elf.texi: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.texi
-
-elfcode.texi: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.texi
-
-format.texi: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.texi
-
-libbfd.texi: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.texi
-
-opncls.texi: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.texi
-
-reloc.texi : $(MKDOC) $(srcdir)/../reloc.c
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.texi
-
-section.texi: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.texi
-
-syms.texi : $(MKDOC) $(srcdir)/../syms.c
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.texi
-
-targets.texi: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.texi
-
-init.texi: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.texi
-
-hash.texi: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.texi
-
-linker.texi: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str
- $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.texi
-
-libbfd.h: $(srcdir)/../libbfd-in.h \
- $(srcdir)/../init.c \
- $(srcdir)/../libbfd.c \
- $(srcdir)/../cache.c \
- $(srcdir)/../reloc.c \
- $(srcdir)/../cpu-h8300.c \
- $(srcdir)/../cpu-i960.c \
- $(srcdir)/../archures.c \
- $(srcdir)/../elfcode.h \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../libbfd-in.h >libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../init.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../libbfd.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cache.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../reloc.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cpu-h8300.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../cpu-i960.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../archures.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elf.c >>libbfd.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../elfcode.h >>libbfd.h
-
-libcoff.h: $(srcdir)/../libcoff-in.h \
- $(srcdir)/../coffcode.h \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../libcoff-in.h >libcoff.h
- $(MKDOC) -i -f $(srcdir)/proto.str < $(srcdir)/../coffcode.h >>libcoff.h
-
-bfd.h: $(srcdir)/../bfd-in.h \
- $(srcdir)/../init.c \
- $(srcdir)/../opncls.c \
- $(srcdir)/../libbfd.c \
- $(srcdir)/../section.c \
- $(srcdir)/../archures.c \
- $(srcdir)/../reloc.c \
- $(srcdir)/../syms.c \
- $(srcdir)/../bfd.c \
- $(srcdir)/../archive.c \
- $(srcdir)/../corefile.c \
- $(srcdir)/../targets.c \
- $(srcdir)/../format.c \
- $(srcdir)/proto.str \
- $(MKDOC)
- cat $(srcdir)/../bfd-in.h >bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../init.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../opncls.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../libbfd.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../section.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archures.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../reloc.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../syms.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../bfd.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archive.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../corefile.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../targets.c >>bfd.h
- $(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../format.c >>bfd.h
- echo "#ifdef __cplusplus" >>bfd.h
- echo "}" >>bfd.h
- echo "#endif" >>bfd.h
- echo "#endif" >>bfd.h
-
-
-clean-info: clean
-
-mostlyclean:
- rm -rf *.log *.ps *~* *.dvi *# $(MKDOC) *.o
-
-clean: mostlyclean
- rm -rf $(STAGESTUFF)
- rm -f *.p *.ip bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log
-
-distclean: clean
- rm -f Makefile config.status
-
-maintainer-clean realclean: clean
- rm -f Makefile config.status
-
-bfd.info: $(DOCFILES) bfdsumm.texi bfd.texinfo
- $(MAKEINFO) -I$(srcdir) -o bfd.info $(srcdir)/bfd.texinfo
-
-bfd.dvi: $(DOCFILES) bfdsumm.texi bfd.texinfo
- $(TEXI2DVI) $(srcdir)/bfd.texinfo
-
-bfd.ps: bfd.dvi
- dvips bfd -o
-
-quickdoc: $(DOCFILES) bfdsumm.texi bfd.texinfo
- TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo
-
-stage1: force
- - mkdir stage1
- - mv -f $(STAGESTUFF) stage1
-
-stage2: force
- - mkdir stage2
- - mv -f $(STAGESTUFF) stage2
-
-stage3: force
- - mkdir stage3
- - mv -f $(STAGESTUFF) stage3
-
-against=stage2
-
-comparison: force
- for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i || exit 1 ; done
-
-de-stage1: force
- - (cd stage1 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage1
-
-de-stage2: force
- - (cd stage2 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage2
-
-de-stage3: force
- - (cd stage3 ; mv -f $(STAGESTUFF) ..)
- - rmdir stage3
-
-force:
-
-Makefile: $(srcdir)/Makefile.in
- cd .. && CONFIG_FILES=doc/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
diff --git a/contrib/gdb/bfd/doc/bfd.texinfo b/contrib/gdb/bfd/doc/bfd.texinfo
deleted file mode 100644
index af7bc10..0000000
--- a/contrib/gdb/bfd/doc/bfd.texinfo
+++ /dev/null
@@ -1,348 +0,0 @@
-\input texinfo.tex
-@setfilename bfd.info
-@c $Id: bfd.texinfo,v 1.28 1995/11/10 20:04:12 victoria Exp $
-@tex
-% NOTE LOCAL KLUGE TO AVOID TOO MUCH WHITESPACE
-\global\long\def\example{%
-\begingroup
-\let\aboveenvbreak=\par
-\let\afterenvbreak=\par
-\parskip=0pt
-\lisp}
-\global\long\def\Eexample{%
-\Elisp
-\endgroup
-\vskip -\parskip% to cancel out effect of following \par
-}
-@end tex
-@synindex fn cp
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* Bfd: (bfd). The Binary File Descriptor library.
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
-
-@ifinfo
-This file documents the BFD library.
-
-Copyright (C) 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@ignore
-Permission is granted to process this file through Tex and print the
-results, provided the printed document carries copying permission
-notice identical to this one except for the removal of this paragraph
-(this paragraph not being relevant to the printed manual).
-
-@end ignore
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, subject to the terms
-of the GNU General Public License, which includes the provision that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end ifinfo
-@iftex
-@c@finalout
-@setchapternewpage on
-@c@setchapternewpage odd
-@settitle LIB BFD, the Binary File Descriptor Library
-@titlepage
-@title{libbfd}
-@subtitle{The Binary File Descriptor Library}
-@sp 1
-@subtitle First Edition---BFD version < 3.0
-@subtitle April 1991
-@author {Steve Chamberlain}
-@author {Cygnus Support}
-@page
-
-@tex
-\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
-\xdef\manvers{\$Revision: 1.28 $} % For use in headers, footers too
-{\parskip=0pt
-\hfill Cygnus Support\par
-\hfill sac\@cygnus.com\par
-\hfill {\it BFD}, \manvers\par
-\hfill \TeX{}info \texinfoversion\par
-}
-\global\parindent=0pt % Steve likes it this way
-@end tex
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1991 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, subject to the terms
-of the GNU General Public License, which includes the provision that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end titlepage
-@end iftex
-
-@node Top, Overview, (dir), (dir)
-@ifinfo
-This file documents the binary file descriptor library libbfd.
-@end ifinfo
-
-@menu
-* Overview:: Overview of BFD
-* BFD front end:: BFD front end
-* BFD back ends:: BFD back ends
-* Index:: Index
-@end menu
-
-@node Overview, BFD front end, Top, Top
-@chapter Introduction
-@cindex BFD
-@cindex what is it?
-BFD is a package which allows applications to use the
-same routines to operate on object files whatever the object file
-format. A new object file format can be supported simply by
-creating a new BFD back end and adding it to the library.
-
-BFD is split into two parts: the front end, and the back ends (one for
-each object file format).
-@itemize @bullet
-@item The front end of BFD provides the interface to the user. It manages
-memory and various canonical data structures. The front end also
-decides which back end to use and when to call back end routines.
-@item The back ends provide BFD its view of the real world. Each back
-end provides a set of calls which the BFD front end can use to maintain
-its canonical form. The back ends also may keep around information for
-their own use, for greater efficiency.
-@end itemize
-@menu
-* History:: History
-* How It Works:: How It Works
-* What BFD Version 2 Can Do:: What BFD Version 2 Can Do
-@end menu
-
-@node History, How It Works, Overview, Overview
-@section History
-
-One spur behind BFD was the desire, on the part of the GNU 960 team at
-Intel Oregon, for interoperability of applications on their COFF and
-b.out file formats. Cygnus was providing GNU support for the team, and
-was contracted to provide the required functionality.
-
-The name came from a conversation David Wallace was having with Richard
-Stallman about the library: RMS said that it would be quite hard---David
-said ``BFD''. Stallman was right, but the name stuck.
-
-At the same time, Ready Systems wanted much the same thing, but for
-different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k
-coff.
-
-BFD was first implemented by members of Cygnus Support; Steve
-Chamberlain (@code{sac@@cygnus.com}), John Gilmore
-(@code{gnu@@cygnus.com}), K. Richard Pixley (@code{rich@@cygnus.com})
-and David Henkel-Wallace (@code{gumby@@cygnus.com}).
-
-
-
-@node How It Works, What BFD Version 2 Can Do, History, Overview
-@section How To Use BFD
-
-To use the library, include @file{bfd.h} and link with @file{libbfd.a}.
-
-BFD provides a common interface to the parts of an object file
-for a calling application.
-
-When an application sucessfully opens a target file (object, archive, or
-whatever), a pointer to an internal structure is returned. This pointer
-points to a structure called @code{bfd}, described in
-@file{bfd.h}. Our convention is to call this pointer a BFD, and
-instances of it within code @code{abfd}. All operations on
-the target object file are applied as methods to the BFD. The mapping is
-defined within @code{bfd.h} in a set of macros, all beginning
-with @samp{bfd_} to reduce namespace pollution.
-
-For example, this sequence does what you would probably expect:
-return the number of sections in an object file attached to a BFD
-@code{abfd}.
-
-@lisp
-@c @cartouche
-#include "bfd.h"
-
-unsigned int number_of_sections(abfd)
-bfd *abfd;
-@{
- return bfd_count_sections(abfd);
-@}
-@c @end cartouche
-@end lisp
-
-The abstraction used within BFD is that an object file has:
-
-@itemize @bullet
-@item
-a header,
-@item
-a number of sections containing raw data (@pxref{Sections}),
-@item
-a set of relocations (@pxref{Relocations}), and
-@item
-some symbol information (@pxref{Symbols}).
-@end itemize
-@noindent
-Also, BFDs opened for archives have the additional attribute of an index
-and contain subordinate BFDs. This approach is fine for a.out and coff,
-but loses efficiency when applied to formats such as S-records and
-IEEE-695.
-
-@node What BFD Version 2 Can Do, , How It Works, Overview
-@section What BFD Version 2 Can Do
-@include bfdsumm.texi
-
-@node BFD front end, BFD back ends, Overview, Top
-@chapter BFD front end
-@include bfd.texi
-
-@menu
-* Memory Usage::
-* Initialization::
-* Sections::
-* Symbols::
-* Archives::
-* Formats::
-* Relocations::
-* Core Files::
-* Targets::
-* Architectures::
-* Opening and Closing::
-* Internal::
-* File Caching::
-* Linker Functions::
-* Hash Tables::
-@end menu
-
-@node Memory Usage, Initialization, BFD front end, BFD front end
-@section Memory usage
-BFD keeps all of its internal structures in obstacks. There is one obstack
-per open BFD file, into which the current state is stored. When a BFD is
-closed, the obstack is deleted, and so everything which has been
-allocated by BFD for the closing file is thrown away.
-
-BFD does not free anything created by an application, but pointers into
-@code{bfd} structures become invalid on a @code{bfd_close}; for example,
-after a @code{bfd_close} the vector passed to
-@code{bfd_canonicalize_symtab} is still around, since it has been
-allocated by the application, but the data that it pointed to are
-lost.
-
-The general rule is to not close a BFD until all operations dependent
-upon data from the BFD have been completed, or all the data from within
-the file has been copied. To help with the management of memory, there
-is a function (@code{bfd_alloc_size}) which returns the number of bytes
-in obstacks associated with the supplied BFD. This could be used to
-select the greediest open BFD, close it to reclaim the memory, perform
-some operation and reopen the BFD again, to get a fresh copy of the data
-structures.
-
-@node Initialization, Sections, Memory Usage, BFD front end
-@include init.texi
-
-@node Sections, Symbols, Initialization, BFD front end
-@include section.texi
-
-@node Symbols, Archives, Sections, BFD front end
-@include syms.texi
-
-@node Archives, Formats, Symbols, BFD front end
-@include archive.texi
-
-@node Formats, Relocations, Archives, BFD front end
-@include format.texi
-
-@node Relocations, Core Files, Formats, BFD front end
-@include reloc.texi
-
-@node Core Files, Targets, Relocations, BFD front end
-@include core.texi
-
-@node Targets, Architectures, Core Files, BFD front end
-@include targets.texi
-
-@node Architectures, Opening and Closing, Targets, BFD front end
-@include archures.texi
-
-@node Opening and Closing, Internal, Architectures, BFD front end
-@include opncls.texi
-
-@node Internal, File Caching, Opening and Closing, BFD front end
-@include libbfd.texi
-
-@node File Caching, Linker Functions, Internal, BFD front end
-@include cache.texi
-
-@node Linker Functions, Hash Tables, File Caching, BFD front end
-@include linker.texi
-
-@node Hash Tables, , Linker Functions, BFD front end
-@include hash.texi
-
-@node BFD back ends, Index, BFD front end, Top
-@chapter BFD back ends
-@menu
-* What to Put Where::
-* aout :: a.out backends
-* coff :: coff backends
-* elf :: elf backends
-@ignore
-* oasys :: oasys backends
-* ieee :: ieee backend
-* srecord :: s-record backend
-@end ignore
-@end menu
-@node What to Put Where, aout, BFD back ends, BFD back ends
-All of BFD lives in one directory.
-
-@node aout, coff, What to Put Where, BFD back ends
-@include aoutx.texi
-
-@node coff, elf, aout, BFD back ends
-@include coffcode.texi
-
-@node elf, , coff, BFD back ends
-@include elf.texi
-@c Leave this out until the file has some actual contents...
-@c @include elfcode.texi
-
-@node Index, , BFD back ends , Top
-@unnumbered Index
-@printindex cp
-
-@tex
-% I think something like @colophon should be in texinfo. In the
-% meantime:
-\long\def\colophon{\hbox to0pt{}\vfill
-\centerline{The body of this manual is set in}
-\centerline{\fontname\tenrm,}
-\centerline{with headings in {\bf\fontname\tenbf}}
-\centerline{and examples in {\tt\fontname\tentt}.}
-\centerline{{\it\fontname\tenit\/} and}
-\centerline{{\sl\fontname\tensl\/}}
-\centerline{are used for emphasis.}\vfill}
-\page\colophon
-% Blame: doc@cygnus.com, 28mar91.
-@end tex
-
-@contents
-@bye
diff --git a/contrib/gdb/bfd/doc/bfdsumm.texi b/contrib/gdb/bfd/doc/bfdsumm.texi
deleted file mode 100644
index 844531a..0000000
--- a/contrib/gdb/bfd/doc/bfdsumm.texi
+++ /dev/null
@@ -1,148 +0,0 @@
-@c This summary of BFD is shared by the BFD and LD docs.
-When an object file is opened, BFD subroutines automatically determine
-the format of the input object file. They then build a descriptor in
-memory with pointers to routines that will be used to access elements of
-the object file's data structures.
-
-As different information from the the object files is required,
-BFD reads from different sections of the file and processes them.
-For example, a very common operation for the linker is processing symbol
-tables. Each BFD back end provides a routine for converting
-between the object file's representation of symbols and an internal
-canonical format. When the linker asks for the symbol table of an object
-file, it calls through a memory pointer to the routine from the
-relevant BFD back end which reads and converts the table into a canonical
-form. The linker then operates upon the canonical form. When the link is
-finished and the linker writes the output file's symbol table,
-another BFD back end routine is called to take the newly
-created symbol table and convert it into the chosen output format.
-
-@menu
-* BFD information loss:: Information Loss
-* Canonical format:: The BFD canonical object-file format
-@end menu
-
-@node BFD information loss
-@subsection Information Loss
-
-@emph{Information can be lost during output.} The output formats
-supported by BFD do not provide identical facilities, and
-information which can be described in one form has nowhere to go in
-another format. One example of this is alignment information in
-@code{b.out}. There is nowhere in an @code{a.out} format file to store
-alignment information on the contained data, so when a file is linked
-from @code{b.out} and an @code{a.out} image is produced, alignment
-information will not propagate to the output file. (The linker will
-still use the alignment information internally, so the link is performed
-correctly).
-
-Another example is COFF section names. COFF files may contain an
-unlimited number of sections, each one with a textual section name. If
-the target of the link is a format which does not have many sections (e.g.,
-@code{a.out}) or has sections without names (e.g., the Oasys format), the
-link cannot be done simply. You can circumvent this problem by
-describing the desired input-to-output section mapping with the linker command
-language.
-
-@emph{Information can be lost during canonicalization.} The BFD
-internal canonical form of the external formats is not exhaustive; there
-are structures in input formats for which there is no direct
-representation internally. This means that the BFD back ends
-cannot maintain all possible data richness through the transformation
-between external to internal and back to external formats.
-
-This limitation is only a problem when an application reads one
-format and writes another. Each BFD back end is responsible for
-maintaining as much data as possible, and the internal BFD
-canonical form has structures which are opaque to the BFD core,
-and exported only to the back ends. When a file is read in one format,
-the canonical form is generated for BFD and the application. At the
-same time, the back end saves away any information which may otherwise
-be lost. If the data is then written back in the same format, the back
-end routine will be able to use the canonical form provided by the
-BFD core as well as the information it prepared earlier. Since
-there is a great deal of commonality between back ends,
-there is no information lost when
-linking or copying big endian COFF to little endian COFF, or @code{a.out} to
-@code{b.out}. When a mixture of formats is linked, the information is
-only lost from the files whose format differs from the destination.
-
-@node Canonical format
-@subsection The BFD canonical object-file format
-
-The greatest potential for loss of information occurs when there is the least
-overlap between the information provided by the source format, that
-stored by the canonical format, and that needed by the
-destination format. A brief description of the canonical form may help
-you understand which kinds of data you can count on preserving across
-conversions.
-@cindex BFD canonical format
-@cindex internal object-file format
-
-@table @emph
-@item files
-Information stored on a per-file basis includes target machine
-architecture, particular implementation format type, a demand pageable
-bit, and a write protected bit. Information like Unix magic numbers is
-not stored here---only the magic numbers' meaning, so a @code{ZMAGIC}
-file would have both the demand pageable bit and the write protected
-text bit set. The byte order of the target is stored on a per-file
-basis, so that big- and little-endian object files may be used with one
-another.
-
-@item sections
-Each section in the input file contains the name of the section, the
-section's original address in the object file, size and alignment
-information, various flags, and pointers into other BFD data
-structures.
-
-@item symbols
-Each symbol contains a pointer to the information for the object file
-which originally defined it, its name, its value, and various flag
-bits. When a BFD back end reads in a symbol table, it relocates all
-symbols to make them relative to the base of the section where they were
-defined. Doing this ensures that each symbol points to its containing
-section. Each symbol also has a varying amount of hidden private data
-for the BFD back end. Since the symbol points to the original file, the
-private data format for that symbol is accessible. @code{ld} can
-operate on a collection of symbols of wildly different formats without
-problems.
-
-Normal global and simple local symbols are maintained on output, so an
-output file (no matter its format) will retain symbols pointing to
-functions and to global, static, and common variables. Some symbol
-information is not worth retaining; in @code{a.out}, type information is
-stored in the symbol table as long symbol names. This information would
-be useless to most COFF debuggers; the linker has command line switches
-to allow users to throw it away.
-
-There is one word of type information within the symbol, so if the
-format supports symbol type information within symbols (for example, COFF,
-IEEE, Oasys) and the type is simple enough to fit within one word
-(nearly everything but aggregates), the information will be preserved.
-
-@item relocation level
-Each canonical BFD relocation record contains a pointer to the symbol to
-relocate to, the offset of the data to relocate, the section the data
-is in, and a pointer to a relocation type descriptor. Relocation is
-performed by passing messages through the relocation type
-descriptor and the symbol pointer. Therefore, relocations can be performed
-on output data using a relocation method that is only available in one of the
-input formats. For instance, Oasys provides a byte relocation format.
-A relocation record requesting this relocation type would point
-indirectly to a routine to perform this, so the relocation may be
-performed on a byte being written to a 68k COFF file, even though 68k COFF
-has no such relocation type.
-
-@item line numbers
-Object formats can contain, for debugging purposes, some form of mapping
-between symbols, source line numbers, and addresses in the output file.
-These addresses have to be relocated along with the symbol information.
-Each symbol with an associated list of line number records points to the
-first record of the list. The head of a line number list consists of a
-pointer to the symbol, which allows finding out the address of the
-function whose line number is being described. The rest of the list is
-made up of pairs: offsets into the section and line numbers. Any format
-which can simply derive this information can pass it successfully
-between formats (COFF, IEEE and Oasys).
-@end table
diff --git a/contrib/gdb/bfd/doc/chew.c b/contrib/gdb/bfd/doc/chew.c
deleted file mode 100644
index 5c04404..0000000
--- a/contrib/gdb/bfd/doc/chew.c
+++ /dev/null
@@ -1,1551 +0,0 @@
-/* chew
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
- Contributed by steve chamberlain @cygnus
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Yet another way of extracting documentation from source.
- No, I haven't finished it yet, but I hope you people like it better
- than the old way
-
- sac
-
- Basically, this is a sort of string forth, maybe we should call it
- struth?
-
- You define new words thus:
- : <newword> <oldwords> ;
-
-*/
-
-/* Primitives provided by the program:
-
- Two stacks are provided, a string stack and an integer stack.
-
- Internal state variables:
- internal_wanted - indicates whether `-i' was passed
- internal_mode - user-settable
-
- Commands:
- push_text
- ! - pop top of integer stack for address, pop next for value; store
- @ - treat value on integer stack as the address of an integer; push
- that integer on the integer stack after popping the "address"
- hello - print "hello\n" to stdout
- stdout - put stdout marker on TOS
- stderr - put stderr marker on TOS
- print - print TOS-1 on TOS (eg: "hello\n" stdout print)
- skip_past_newline
- catstr - fn icatstr
- copy_past_newline - append input, up to and including newline into TOS
- dup - fn other_dup
- drop - discard TOS
- idrop - ditto
- remchar - delete last character from TOS
- get_stuff_in_command
- do_fancy_stuff - translate <<foo>> to @code{foo} in TOS
- bulletize - if "o" lines found, prepend @itemize @bullet to TOS
- and @item to each "o" line; append @end itemize
- courierize - put @example around . and | lines, translate {* *} { }
- exit - fn chew_exit
- swap
- outputdots - strip out lines without leading dots
- paramstuff - convert full declaration into "PARAMS" form if not already
- maybecatstr - do catstr if internal_mode == internal_wanted, discard
- value in any case
- translatecomments - turn {* and *} into comment delimiters
- kill_bogus_lines - get rid of extra newlines
- indent
- internalmode - pop from integer stack, set `internalmode' to that value
- print_stack_level - print current stack depth to stderr
- strip_trailing_newlines - go ahead, guess...
- [quoted string] - push string onto string stack
- [word starting with digit] - push atol(str) onto integer stack
-
- A command must be all upper-case, and alone on a line.
-
- Foo. */
-
-
-#include <ansidecl.h>
-#include "sysdep.h"
-#include <assert.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define DEF_SIZE 5000
-#define STACK 50
-
-int internal_wanted;
-int internal_mode;
-
-int warning;
-
-/* Here is a string type ... */
-
-typedef struct buffer
-{
- char *ptr;
- unsigned long write_idx;
- unsigned long size;
-} string_type;
-
-
-#ifdef __STDC__
-static void init_string_with_size (string_type *, unsigned int);
-static void init_string (string_type *);
-static int find (string_type *, char *);
-static void write_buffer (string_type *, FILE *);
-static void delete_string (string_type *);
-static char *addr (string_type *, unsigned int);
-static char at (string_type *, unsigned int);
-static void catchar (string_type *, int);
-static void overwrite_string (string_type *, string_type *);
-static void catbuf (string_type *, char *, unsigned int);
-static void cattext (string_type *, char *);
-static void catstr (string_type *, string_type *);
-static unsigned int skip_white_and_starts (string_type *, unsigned int);
-#endif
-
-
-static void DEFUN(init_string_with_size,(buffer, size),
- string_type *buffer AND
- unsigned int size )
-{
- buffer->write_idx = 0;
- buffer->size = size;
- buffer->ptr = malloc(size);
-}
-
-static void DEFUN(init_string,(buffer),
- string_type *buffer)
-{
- init_string_with_size(buffer, DEF_SIZE);
-
-}
-
-static int DEFUN(find, (str, what),
- string_type *str AND
- char *what)
-{
- unsigned int i;
- char *p;
- p = what;
- for (i = 0; i < str->write_idx && *p; i++)
- {
- if (*p == str->ptr[i])
- p++;
- else
- p = what;
- }
- return (*p == 0);
-
-}
-
-static void DEFUN(write_buffer,(buffer, f),
- string_type *buffer AND
- FILE *f)
-{
- fwrite(buffer->ptr, buffer->write_idx, 1, f);
-}
-
-
-static void DEFUN(delete_string,(buffer),
- string_type *buffer)
-{
- free(buffer->ptr);
-}
-
-
-static char *DEFUN(addr, (buffer, idx),
- string_type *buffer AND
- unsigned int idx)
-{
- return buffer->ptr + idx;
-}
-
-static char DEFUN(at,(buffer, pos),
- string_type *buffer AND
- unsigned int pos)
-{
- if (pos >= buffer->write_idx)
- return 0;
- return buffer->ptr[pos];
-}
-
-static void DEFUN(catchar,(buffer, ch),
- string_type *buffer AND
- int ch)
-{
- if (buffer->write_idx == buffer->size)
- {
- buffer->size *=2;
- buffer->ptr = realloc(buffer->ptr, buffer->size);
- }
-
- buffer->ptr[buffer->write_idx ++ ] = ch;
-}
-
-
-static void DEFUN(overwrite_string,(dst, src),
- string_type *dst AND
- string_type *src)
-{
- free(dst->ptr);
- dst->size = src->size;
- dst->write_idx = src->write_idx;
- dst->ptr = src->ptr;
-}
-
-static void DEFUN(catbuf,(buffer, buf, len),
- string_type *buffer AND
- char *buf AND
- unsigned int len)
-{
- if (buffer->write_idx + len >= buffer->size)
- {
- while (buffer->write_idx + len >= buffer->size)
- buffer->size *= 2;
- buffer->ptr = realloc (buffer->ptr, buffer->size);
- }
- memcpy (buffer->ptr + buffer->write_idx, buf, len);
- buffer->write_idx += len;
-}
-
-static void DEFUN(cattext,(buffer, string),
- string_type *buffer AND
- char *string)
-{
- catbuf (buffer, string, (unsigned int) strlen (string));
-}
-
-static void DEFUN(catstr,(dst, src),
- string_type *dst AND
- string_type *src)
-{
- catbuf (dst, src->ptr, src->write_idx);
-}
-
-
-static unsigned int
-DEFUN(skip_white_and_stars,(src, idx),
- string_type *src AND
- unsigned int idx)
-{
- char c;
- while ((c = at(src,idx)),
- isspace (c)
- || (c == '*'
- /* Don't skip past end-of-comment or star as first
- character on its line. */
- && at(src,idx +1) != '/'
- && at(src,idx -1) != '\n'))
- idx++;
- return idx;
-}
-
-/***********************************************************************/
-
-
-string_type stack[STACK];
-string_type *tos;
-
-unsigned int idx = 0; /* Pos in input buffer */
-string_type *ptr; /* and the buffer */
-typedef void (*stinst_type)();
-stinst_type *pc;
-stinst_type sstack[STACK];
-stinst_type *ssp = &sstack[0];
-long istack[STACK];
-long *isp = &istack[0];
-
-typedef int *word_type;
-
-
-
-struct dict_struct
-{
- char *word;
- struct dict_struct *next;
- stinst_type *code;
- int code_length;
- int code_end;
- int var;
-
-};
-typedef struct dict_struct dict_type;
-#define WORD(x) static void x()
-
-static void
-die (msg)
- char *msg;
-{
- fprintf (stderr, "%s\n", msg);
- exit (1);
-}
-
-static void
-check_range ()
-{
- if (tos < stack)
- die ("underflow in string stack");
- if (tos >= stack + STACK)
- die ("overflow in string stack");
-}
-
-static void
-icheck_range ()
-{
- if (isp < istack)
- die ("underflow in integer stack");
- if (isp >= istack + STACK)
- die ("overflow in integer stack");
-}
-
-#ifdef __STDC__
-static void exec (dict_type *);
-static void call (void);
-static void remchar (void), strip_trailing_newlines (void), push_number (void);
-static void push_text (void);
-static void remove_noncomments (string_type *, string_type *);
-static void print_stack_level (void);
-static void paramstuff (void), translatecomments (void), manglecomments (void);
-static void outputdots (void), courierize (void), bulletize (void);
-static void do_fancy_stuff (void);
-static int iscommand (string_type *, unsigned int);
-static int copy_past_newline (string_type *, unsigned int, string_type *);
-static void icopy_past_newline (void), kill_bogus_lines (void), indent (void);
-static void get_stuff_in_command (void), swap (void), other_dup (void);
-static void drop (void), idrop (void);
-static void icatstr (void), skip_past_newline (void), internalmode (void);
-static void maybecatstr (void);
-static char *nextword (char *, char **);
-dict_type *lookup_word (char *);
-static void perform (void);
-dict_type *newentry (char *);
-unsigned int add_to_definition (dict_type *, stinst_type);
-void add_intrinsic (char *, void (*)());
-void add_var (char *);
-void compile (char *);
-static void bang (void);
-static void atsign (void);
-static void hello (void);
-static void stdout_ (void);
-static void stderr_ (void);
-static void print (void);
-static void read_in (string_type *, FILE *);
-static void usage (void);
-static void chew_exit (void);
-#endif
-
-static void DEFUN(exec,(word),
- dict_type *word)
-{
- pc = word->code;
- while (*pc)
- (*pc)();
-}
-WORD(call)
-{
- stinst_type *oldpc = pc;
- dict_type *e;
- e = (dict_type *)(pc [1]);
- exec(e);
- pc = oldpc + 2;
-
-}
-
-WORD(remchar)
-{
- if (tos->write_idx)
- tos->write_idx--;
- pc++;
-}
-
-static void
-strip_trailing_newlines ()
-{
- while ((isspace (at (tos, tos->write_idx - 1))
- || at (tos, tos->write_idx - 1) == '\n')
- && tos->write_idx > 0)
- tos->write_idx--;
- pc++;
-}
-
-WORD(push_number)
-{
- isp++;
- icheck_range ();
- pc++;
- *isp = (long)(*pc);
- pc++;
-}
-
-WORD(push_text)
-{
- tos++;
- check_range ();
- init_string(tos);
- pc++;
- cattext(tos,*((char **)pc));
- pc++;
-
-}
-
-
-/* This function removes everything not inside comments starting on
- the first char of the line from the string, also when copying
- comments, removes blank space and leading *'s.
- Blank lines are turned into one blank line. */
-
-static void
-DEFUN(remove_noncomments,(src,dst),
- string_type *src AND
- string_type *dst)
-{
- unsigned int idx = 0;
-
- while (at(src,idx))
- {
- /* Now see if we have a comment at the start of the line */
- if (at(src,idx) == '\n'
- && at(src,idx+1) == '/'
- && at(src,idx+2) == '*')
- {
- idx+=3;
-
- idx = skip_white_and_stars(src,idx);
-
- /* Remove leading dot */
- if (at(src, idx) == '.')
- idx++;
-
- /* Copy to the end of the line, or till the end of the
- comment */
- while (at(src, idx))
- {
- if (at(src, idx) == '\n')
- {
- /* end of line, echo and scrape of leading blanks */
- if (at(src,idx +1) == '\n')
- catchar(dst,'\n');
- catchar(dst,'\n');
- idx++;
- idx = skip_white_and_stars(src, idx);
- }
- else if (at(src, idx) == '*' && at(src,idx+1) == '/')
- {
- idx +=2 ;
- cattext(dst,"\nENDDD\n");
- break;
- }
- else
- {
- catchar(dst, at(src, idx));
- idx++;
- }
- }
- }
- else idx++;
- }
-}
-
-static void
-print_stack_level ()
-{
- fprintf (stderr, "current string stack depth = %d, ", tos - stack);
- fprintf (stderr, "current integer stack depth = %d\n", isp - istack);
- pc++;
-}
-
-/* turn:
- foobar name(stuff);
- into:
- foobar
- name PARAMS ((stuff));
- and a blank line.
- */
-
-static void
-DEFUN_VOID(paramstuff)
-{
- unsigned int openp;
- unsigned int fname;
- unsigned int idx;
- string_type out;
- init_string(&out);
-
-
- /* make sure that it's not already param'd or proto'd */
- if(find(tos,"PARAMS") || find(tos,"PROTO") || !find(tos,"(")) {
- catstr(&out,tos);
- }
- else
- {
- /* Find the open paren */
- for (openp = 0; at(tos, openp) != '(' && at(tos,openp); openp++)
- ;
-
- fname = openp;
- /* Step back to the fname */
- fname--;
- while (fname && isspace(at(tos, fname)))
- fname --;
- while (fname && !isspace(at(tos,fname)) && at(tos,fname) != '*')
- fname--;
-
- fname++;
-
- for (idx = 0; idx < fname; idx++) /* Output type */
- {
- catchar(&out, at(tos,idx));
- }
-
- cattext(&out, "\n"); /* Insert a newline between type and fnname */
-
- for (idx = fname; idx < openp; idx++) /* Output fnname */
- {
- catchar(&out, at(tos,idx));
- }
-
- cattext(&out," PARAMS (");
-
- while (at(tos,idx) && at(tos,idx) !=';')
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- cattext(&out,");\n\n");
- }
- overwrite_string(tos, &out);
- pc++;
-
-}
-
-
-
-/* turn {*
- and *} into comments */
-
-WORD(translatecomments)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos,idx) == '{' && at(tos,idx+1) =='*')
- {
- cattext(&out,"/*");
- idx+=2;
- }
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
-
- overwrite_string(tos, &out);
-
- pc++;
-
-}
-
-/* turn everything not starting with a . into a comment */
-
-WORD(manglecomments)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos,idx) == '\n' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (at(tos,idx) == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
-
- overwrite_string(tos, &out);
-
- pc++;
-
-}
-
-/* Mod tos so that only lines with leading dots remain */
-static void
-DEFUN_VOID(outputdots)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos, idx) == '\n' && at(tos, idx+1) == '.')
- {
- char c, c2;
- idx += 2;
-
- while ((c = at(tos, idx)) && c != '\n')
- {
- if (c == '{' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (c == '*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else
- {
- catchar(&out, c);
- idx++;
- }
- }
- catchar(&out,'\n');
- }
- else
- {
- idx++;
- }
- }
-
- overwrite_string(tos, &out);
- pc++;
-
-}
-
-/* Find lines starting with . and | and put example around them on tos */
-WORD(courierize)
-{
- string_type out;
- unsigned int idx = 0;
- int command = 0;
-
- init_string(&out);
-
- while (at(tos, idx))
- {
- if (at(tos, idx) == '\n'
- && (at(tos, idx +1 ) == '.'
- || at(tos,idx+1) == '|'))
- {
- cattext(&out,"\n@example\n");
- do
- {
- idx += 2;
-
- while (at(tos, idx) && at(tos, idx)!='\n')
- {
- if (at(tos,idx)=='{' && at(tos,idx+1) =='*')
- {
- cattext(&out," /*");
- idx+=2;
- }
- else if (at(tos,idx)=='*' && at(tos,idx+1) =='}')
- {
- cattext(&out,"*/");
- idx+=2;
- }
- else if (at(tos,idx) == '{' && !command)
- {
- cattext(&out,"@{");
- idx++;
- }
- else if (at(tos,idx) == '}' && !command)
- {
- cattext(&out,"@}");
- idx++;
- }
- else
- {
- if (at(tos,idx) == '@')
- command = 1;
- else if (isspace(at(tos,idx)) || at(tos,idx) == '}')
- command = 0;
- catchar(&out, at(tos, idx));
- idx++;
- }
-
- }
- catchar(&out,'\n');
- }
- while (at(tos, idx) == '\n'
- && (at(tos, idx+1) == '.')
- || (at(tos,idx+1) == '|'));
- cattext(&out,"@end example");
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
-
- overwrite_string(tos, &out);
- pc++;
-
-
-}
-
-/* Finds any lines starting with "o ", if there are any, then turns
- on @itemize @bullet, and @items each of them. Then ends with @end
- itemize, inplace at TOS*/
-
-
-WORD(bulletize)
-{
- unsigned int idx = 0;
- int on = 0;
- string_type out;
- init_string(&out);
-
- while (at(tos, idx)) {
- if (at(tos, idx) == '@' &&
- at(tos, idx+1) == '*')
- {
- cattext(&out,"*");
- idx+=2;
- }
-
-else
- if (at(tos, idx) == '\n' &&
- at(tos, idx+1) == 'o' &&
- isspace(at(tos, idx +2)))
- {
- if (!on)
- {
- cattext(&out,"\n@itemize @bullet\n");
- on = 1;
-
- }
- cattext(&out,"\n@item\n");
- idx+=3;
- }
- else
- {
- catchar(&out, at(tos, idx));
- if (on && at(tos, idx) == '\n' &&
- at(tos, idx+1) == '\n' &&
- at(tos, idx+2) != 'o')
- {
- cattext(&out, "@end itemize");
- on = 0;
- }
- idx++;
-
- }
- }
- if (on)
- {
- cattext(&out,"@end itemize\n");
- }
-
- delete_string(tos);
- *tos = out;
- pc++;
-
-}
-
-/* Turn <<foo>> into @code{foo} in place at TOS*/
-
-
-WORD(do_fancy_stuff)
-{
- unsigned int idx = 0;
- string_type out;
- init_string(&out);
- while (at(tos, idx))
- {
- if (at(tos, idx) == '<'
- && at(tos, idx+1) == '<'
- && !isspace(at(tos,idx + 2)))
- {
- /* This qualifies as a << startup */
- idx +=2;
- cattext(&out,"@code{");
- while(at(tos,idx) &&
- at(tos,idx) != '>' )
- {
- catchar(&out, at(tos, idx));
- idx++;
-
- }
- cattext(&out,"}");
- idx+=2;
- }
- else
- {
- catchar(&out, at(tos, idx));
- idx++;
- }
- }
- delete_string(tos);
- *tos = out;
- pc++;
-
-}
-/* A command is all upper case,and alone on a line */
-static int
-DEFUN( iscommand,(ptr, idx),
- string_type *ptr AND
- unsigned int idx)
-{
- unsigned int len = 0;
- while (at(ptr,idx)) {
- if (isupper(at(ptr,idx)) || at(ptr,idx) == ' ' ||
- at(ptr,idx) == '_')
- {
- len++;
- idx++;
- }
- else if(at(ptr,idx) == '\n')
- {
- if (len > 3) return 1;
- return 0;
- }
- else return 0;
- }
- return 0;
-
-}
-
-
-DEFUN(copy_past_newline,(ptr, idx, dst),
- string_type *ptr AND
- unsigned int idx AND
- string_type *dst)
-{
- while (at(ptr, idx) && at(ptr, idx) != '\n')
- {
- catchar(dst, at(ptr, idx));
- idx++;
-
- }
- catchar(dst, at(ptr, idx));
- idx++;
- return idx;
-
-}
-
-WORD(icopy_past_newline)
-{
- tos++;
- check_range ();
- init_string(tos);
- idx = copy_past_newline(ptr, idx, tos);
- pc++;
-}
-
-/* indent
- Take the string at the top of the stack, do some prettying */
-
-
-WORD(kill_bogus_lines)
-{
- int sl ;
-
- int nl = 0;
- int idx = 0;
- int c;
- int dot = 0 ;
-
- string_type out;
- init_string(&out);
- /* Drop leading nl */
- while (at(tos,idx) == '\n')
- {
- idx++;
- }
- c = idx;
-
- /* Find the last char */
- while (at(tos,idx))
- {
- idx++;
- }
-
- /* find the last non white before the nl */
- idx--;
-
- while (idx && isspace(at(tos,idx)))
- idx--;
- idx++;
-
- /* Copy buffer upto last char, but blank lines before and after
- dots don't count */
- sl = 1;
-
- while (c < idx)
- {
- if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && at(tos,c+2) == '.')
- {
- /* Ignore two newlines before a dot*/
- c++;
- }
- else if (at(tos,c) == '.' && sl)
- {
- /* remember that this line started with a dot */
- dot=2;
- }
- else if (at(tos,c) == '\n'
- && at(tos,c+1) == '\n'
- && dot)
- {
- c++;
- /* Ignore two newlines when last line was dot */
- }
-
- catchar(&out, at(tos,c));
- if (at(tos,c) == '\n')
- {
- sl = 1;
-
- if (dot == 2)dot=1;else dot = 0;
- }
-
- c++;
-
- }
-
- /* Append nl*/
- catchar(&out, '\n');
- pc++;
- delete_string(tos);
- *tos = out;
-
-
-}
-
-WORD(indent)
-{
- string_type out;
- int tab = 0;
- int idx = 0;
- int ol =0;
- init_string(&out);
- while (at(tos,idx)) {
- switch (at(tos,idx))
- {
- case '\n':
- cattext(&out,"\n");
- idx++;
- if (tab)
- {
- cattext(&out," ");
- }
- ol = 0;
- break;
- case '(':
- tab++;
- if (ol == 0)
- cattext(&out," ");
- idx++;
- cattext(&out,"(");
- ol = 1;
- break;
- case ')':
- tab--;
- cattext(&out,")");
- idx++;
- ol=1;
-
- break;
- default:
- catchar(&out,at(tos,idx));
- ol=1;
-
- idx++;
- break;
- }
- }
-
- pc++;
- delete_string(tos);
- *tos = out;
-
-}
-
-
-WORD(get_stuff_in_command)
-{
- tos++;
- check_range ();
- init_string(tos);
-
- while (at(ptr, idx)) {
- if (iscommand(ptr, idx)) break;
- idx = copy_past_newline(ptr, idx, tos);
- }
- pc++;
-}
-
-WORD(swap)
-{
- string_type t;
-
- t = tos[0];
- tos[0] = tos[-1];
- tos[-1] =t;
- pc++;
-
-}
-
-WORD(other_dup)
-{
- tos++;
- check_range ();
- init_string(tos);
- catstr(tos, tos-1);
- pc++;
-}
-
-WORD(drop)
-{
- tos--;
- check_range ();
- pc++;
-}
-
-WORD(idrop)
-{
- isp--;
- icheck_range ();
- pc++;
-}
-
-WORD(icatstr)
-{
- tos--;
- check_range ();
- catstr(tos, tos+1);
- delete_string(tos+1);
- pc++;
-}
-
-WORD(skip_past_newline)
-{
- while (at(ptr,idx)
- && at(ptr,idx) != '\n')
- idx++;
- idx++;
- pc++;
-}
-
-
-WORD(internalmode)
-{
- internal_mode = *(isp);
- isp--;
- icheck_range ();
- pc++;
-}
-
-WORD(maybecatstr)
-{
- if (internal_wanted == internal_mode)
- {
- catstr(tos-1, tos);
- }
- delete_string(tos);
- tos--;
- check_range ();
- pc++;
-}
-
-char *
-DEFUN(nextword,(string, word),
- char *string AND
- char **word)
-{
- char *word_start;
- int idx;
- char *dst;
- char *src;
-
- int length = 0;
-
- while (isspace(*string) || *string == '-') {
- if (*string == '-')
- {
- while (*string && *string != '\n')
- string++;
-
- }
- else {
- string++;
- }
- }
- if (!*string) return 0;
-
- word_start = string;
- if (*string == '"')
- {
- do
- {
- string++;
- length++;
- if (*string == '\\')
- {
- string += 2;
- length += 2;
- }
- }
- while (*string != '"');
- }
- else
- {
- while (!isspace(*string))
- {
- string++;
- length++;
-
- }
- }
-
- *word = malloc(length + 1);
-
- dst = *word;
- src = word_start;
-
-
- for (idx= 0; idx < length; idx++)
- {
- if (src[idx] == '\\')
- switch (src[idx+1])
- {
- case 'n':
- *dst++ = '\n';
- idx++;
- break;
- case '"':
- case '\\':
- *dst++ = src[idx+1];
- idx++;
- break;
- default:
- *dst++ = '\\';
- break;
- }
- else
- *dst++ = src[idx];
- }
- *dst++ = 0;
-
-
-
-
-
- if(*string)
- return string + 1;
- else
- return 0;
-
-}
-dict_type *root;
-dict_type *
-DEFUN(lookup_word,(word),
- char *word)
-{
- dict_type *ptr = root;
- while (ptr) {
- if (strcmp(ptr->word, word) == 0) return ptr;
- ptr = ptr->next;
-
- }
- if (warning)
- fprintf(stderr,"Can't find %s\n",word);
- return 0;
-
-
-}
-
-static void DEFUN_VOID(perform)
-{
- tos = stack;
-
- while (at(ptr, idx)) {
- /* It's worth looking through the command list */
- if (iscommand(ptr, idx))
- {
- unsigned int i;
- int found = 0;
-
- char *next;
- dict_type *word ;
-
- (void) nextword(addr(ptr, idx), &next);
-
-
- word = lookup_word(next);
-
-
-
-
- if (word)
- {
- exec(word);
- }
- else
- {
- if (warning)
- fprintf(stderr,"warning, %s is not recognised\n", next);
- skip_past_newline();
- }
-
- }
- else skip_past_newline();
-
- }
-}
-
-dict_type *
-DEFUN(newentry,(word),
- char *word)
-{
- dict_type *new = (dict_type *)malloc(sizeof(dict_type));
- new->word = word;
- new->next = root;
- root = new;
- new->code = (stinst_type *)malloc(sizeof(stinst_type ));
- new->code_length = 1;
- new->code_end = 0;
- return new;
-
-}
-
-
-unsigned int
-DEFUN(add_to_definition,(entry, word),
- dict_type *entry AND
- stinst_type word)
-{
- if (entry->code_end == entry->code_length)
- {
- entry->code_length += 2;
- entry->code =
- (stinst_type *) realloc((char *)(entry->code),
- entry->code_length *sizeof(word_type));
- }
- entry->code[entry->code_end] = word;
-
-return entry->code_end++;
-}
-
-
-
-
-
-
-
-void
-DEFUN(add_intrinsic,(name, func),
- char *name AND
- void (*func)())
-{
- dict_type *new = newentry(name);
- add_to_definition(new, func);
- add_to_definition(new, 0);
-}
-
-void
-DEFUN(add_var,(name),
- char *name)
-{
- dict_type *new = newentry(name);
- add_to_definition(new, push_number);
- add_to_definition(new, (stinst_type)(&(new->var)));
- add_to_definition(new,0);
-}
-
-
-void
-DEFUN(compile, (string),
- char *string)
-{
- int jstack[STACK];
- int *jptr = jstack;
- /* add words to the dictionary */
- char *word;
- string = nextword(string, &word);
- while (string && *string && word[0])
- {
- if (strcmp(word,"var")==0)
- {
- string=nextword(string, &word);
-
- add_var(word);
- string=nextword(string, &word);
- }
-else
-
- if (word[0] == ':')
- {
- dict_type *ptr;
- /* Compile a word and add to dictionary */
- string = nextword(string, &word);
-
- ptr = newentry(word);
- string = nextword(string, &word);
- while (word[0] != ';' )
- {
- switch (word[0])
- {
- case '"':
- /* got a string, embed magic push string
- function */
- add_to_definition(ptr, push_text);
- add_to_definition(ptr, (stinst_type)(word+1));
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* Got a number, embedd the magic push number
- function */
- add_to_definition(ptr, push_number);
- add_to_definition(ptr, (stinst_type)atol(word));
- break;
- default:
- add_to_definition(ptr, call);
- add_to_definition(ptr, (stinst_type)lookup_word(word));
- }
-
- string = nextword(string, &word);
- }
- add_to_definition(ptr,0);
- string = nextword(string, &word);
- }
- else
- {
- fprintf(stderr,"syntax error at %s\n",string-1);
- }
- }
-
-}
-
-
-static void DEFUN_VOID(bang)
-{
- *(long *)((isp[0])) = isp[-1];
- isp-=2;
- icheck_range ();
- pc++;
-}
-
-WORD(atsign)
-{
- isp[0] = *(long *)(isp[0]);
- pc++;
-}
-
-WORD(hello)
-{
- printf("hello\n");
- pc++;
-}
-
-WORD(stdout_)
-{
- isp++;
- icheck_range ();
- *isp = 1;
- pc++;
-}
-
-WORD(stderr_)
-{
- isp++;
- icheck_range ();
- *isp = 2;
- pc++;
-}
-
-WORD(print)
-{
- if (*isp == 1)
- write_buffer (tos, stdout);
- else if (*isp == 2)
- write_buffer (tos, stderr);
- else
- fprintf (stderr, "print: illegal print destination `%d'\n", *isp);
- isp--;
- tos--;
- icheck_range ();
- check_range ();
- pc++;
-}
-
-
-static void DEFUN(read_in, (str, file),
- string_type *str AND
- FILE *file)
-{
- char buff[10000];
- unsigned int r;
- do
- {
- r = fread(buff, 1, sizeof(buff), file);
- catbuf(str, buff, r);
- }
- while (r);
- buff[0] = 0;
-
- catbuf(str, buff,1);
-}
-
-
-static void DEFUN_VOID(usage)
-{
- fprintf(stderr,"usage: -[d|i|g] <file >file\n");
- exit(33);
-}
-
-/* There is no reliable way to declare exit. Sometimes it returns
- int, and sometimes it returns void. Sometimes it changes between
- OS releases. Trying to get it declared correctly in the hosts file
- is a pointless waste of time. */
-
-static void
-chew_exit ()
-{
- exit (0);
-}
-
-int DEFUN(main,(ac,av),
-int ac AND
-char *av[])
-{
- unsigned int i;
- string_type buffer;
- string_type pptr;
-
- init_string(&buffer);
- init_string(&pptr);
- init_string(stack+0);
- tos=stack+1;
- ptr = &pptr;
-
- add_intrinsic("push_text", push_text);
- add_intrinsic("!", bang);
- add_intrinsic("@", atsign);
- add_intrinsic("hello",hello);
- add_intrinsic("stdout",stdout_);
- add_intrinsic("stderr",stderr_);
- add_intrinsic("print",print);
- add_intrinsic("skip_past_newline", skip_past_newline );
- add_intrinsic("catstr", icatstr );
- add_intrinsic("copy_past_newline", icopy_past_newline );
- add_intrinsic("dup", other_dup );
- add_intrinsic("drop", drop);
- add_intrinsic("idrop", idrop);
- add_intrinsic("remchar", remchar );
- add_intrinsic("get_stuff_in_command", get_stuff_in_command );
- add_intrinsic("do_fancy_stuff", do_fancy_stuff );
- add_intrinsic("bulletize", bulletize );
- add_intrinsic("courierize", courierize );
- /* If the following line gives an error, exit() is not declared in the
- ../hosts/foo.h file for this host. Fix it there, not here! */
- /* No, don't fix it anywhere; see comment on chew_exit--Ian Taylor. */
- add_intrinsic("exit", chew_exit );
- add_intrinsic("swap", swap );
- add_intrinsic("outputdots", outputdots );
- add_intrinsic("paramstuff", paramstuff );
- add_intrinsic("maybecatstr", maybecatstr );
- add_intrinsic("translatecomments", translatecomments );
- add_intrinsic("kill_bogus_lines", kill_bogus_lines);
- add_intrinsic("indent", indent);
- add_intrinsic("internalmode", internalmode);
- add_intrinsic("print_stack_level", print_stack_level);
- add_intrinsic("strip_trailing_newlines", strip_trailing_newlines);
-
- /* Put a nl at the start */
- catchar(&buffer,'\n');
-
- read_in(&buffer, stdin);
- remove_noncomments(&buffer, ptr);
- for (i= 1; i < ac; i++)
- {
- if (av[i][0] == '-')
- {
- if (av[i][1] == 'f')
- {
- string_type b;
- FILE *f;
- init_string(&b);
-
- f = fopen(av[i+1],"r");
- if (!f)
- {
- fprintf(stderr,"Can't open the input file %s\n",av[i+1]);
- return 33;
- }
-
- read_in(&b, f);
- compile(b.ptr);
- perform();
- }
- else if (av[i][1] == 'i')
- {
- internal_wanted = 1;
- }
- else if (av[i][1] == 'w')
- {
- warning = 1;
- }
- }
- }
- write_buffer(stack+0, stdout);
- if (tos != stack)
- {
- fprintf (stderr, "finishing with current stack level %d\n", tos - stack);
- return 1;
- }
- return 0;
-}
diff --git a/contrib/gdb/bfd/doc/doc.str b/contrib/gdb/bfd/doc/doc.str
deleted file mode 100644
index 9368599..0000000
--- a/contrib/gdb/bfd/doc/doc.str
+++ /dev/null
@@ -1,158 +0,0 @@
-: DOCDD
- skip_past_newline
- get_stuff_in_command kill_bogus_lines catstr
- ;
-
-: ENDDD
- skip_past_newline
- ;
-
-: EXAMPLE
- skip_past_newline
- get_stuff_in_command kill_bogus_lines do_fancy_stuff translatecomments
- courierize catstr
-
- ;
-
-: INODE
- "@node " catstr skip_past_newline copy_past_newline catstr
- ;
-
-: CODE_FRAGMENT
- EXAMPLE
- ;
-
-: COMMENT
- skip_past_newline
- get_stuff_in_command
- drop
- ;
-
-: SYNOPSIS
- skip_past_newline
- "@strong{Synopsis}\n" catstr
- "@example\n" catstr
- get_stuff_in_command
- kill_bogus_lines
- indent
- catstr
- "@end example\n" catstr
-
- ;
-
-: func
- "@findex " - a
- skip_past_newline
- copy_past_newline
- dup - a x x
- "@subsubsection @code{" - a x x b
- swap
- remchar
- "}\n" - a x b x c
- catstr catstr catstr catstr catstr
- ;
-
-: FUNCTION
- "@findex " - a
- skip_past_newline
- copy_past_newline
- dup - a x x
- "@subsubsection @code{" - a x x b
- swap
- remchar
- "}\n" - a x b x c
- catstr catstr catstr catstr catstr
- ;
-
-: bodytext
- get_stuff_in_command
- bulletize
- kill_bogus_lines
- do_fancy_stuff
- courierize
- catstr
- "@*\n" catstr
- ;
-
-: asection
- skip_past_newline
- catstr
- copy_past_newline
- do_fancy_stuff catstr
- bodytext
- ;
-
-: SECTION
- "@section " asection ;
-
-: SUBSECTION
- "@subsection " asection ;
-
-: SUBSUBSECTION
- "@subsubsection " asection ;
-
-: subhead
- skip_past_newline
- bodytext
- ;
-
-
-
-
-: DESCRIPTION
- "@strong{Description}@*\n" catstr subhead ;
-
-: RETURNS
- "@strong{Returns}@*\n" catstr subhead ;
-
-: INTERNAL_FUNCTION
- func ;
-
-
-: INTERNAL_DEFINITION
- func ;
-
-
-: INTERNAL
- func ;
-
-: TYPEDEF
- FUNCTION ;
-
-: SENUM
- skip_past_newline
- "Here are the possible values for @code{enum "
- copy_past_newline remchar catstr
- "}:\n\n" catstr catstr
- ;
-: ENUM
- skip_past_newline
- "@deffn {} "
- copy_past_newline catstr catstr
- ;
-: ENUMX
- skip_past_newline
- "@deffnx {} "
- copy_past_newline catstr
- catstr
- ;
-: ENUMEQ
- skip_past_newline
- "@deffn {} "
- copy_past_newline catstr catstr
- skip_past_newline
- ;
-: ENUMEQX
- skip_past_newline
- "@deffnx {} "
- copy_past_newline catstr
- catstr
- skip_past_newline
- ;
-: ENUMDOC
- skip_past_newline
- get_stuff_in_command
- strip_trailing_newlines
- catstr
- "\n@end deffn\n" catstr
- ;
diff --git a/contrib/gdb/bfd/doc/proto.str b/contrib/gdb/bfd/doc/proto.str
deleted file mode 100644
index 8431c16..0000000
--- a/contrib/gdb/bfd/doc/proto.str
+++ /dev/null
@@ -1,135 +0,0 @@
-
-: SYNOPSIS
- skip_past_newline
- get_stuff_in_command
- paramstuff
- indent
- maybecatstr
-;
-
-: ignore
- skip_past_newline
- get_stuff_in_command
- outputdots
- maybecatstr
- ;
-
-: CODE_FRAGMENT
- ignore ;
-
-: external
- 0 internalmode ignore ;
-
-: internal
- 1 internalmode ignore ;
-
-- input stack { a b } output b if internal, a if external
-: ifinternal
- "" swap 1 internalmode maybecatstr
- swap
- "" swap 0 internalmode maybecatstr
- catstr
- ;
-
-- Put note in output string, regardless of internal mode.
-: COMMENT
- skip_past_newline
- get_stuff_in_command
- translatecomments
- catstr
- ;
-
-- SENUM enum-type-name
-- ENUM enum-name
-- ENUMX addl-enum-name
-- ENUMDOC doc for preceding enums
-- ENDSENUM max-enum-name
-
-: make_enum_header
- dup
- "enum " swap catstr
- " {\n" catstr
- swap " _dummy_first_" swap catstr catstr
- ",\n" catstr
- ;
-: make_string_table_header
- dup
- "#ifdef _BFD_MAKE_TABLE_" swap catstr swap
- "\n\nstatic const char *const " swap catstr catstr
- "_names[] = { \"@@uninitialized@@\",\n" catstr
- ;
-: SENUM
- skip_past_newline
- copy_past_newline
- remchar
- dup
- make_enum_header
- swap
- make_string_table_header
- ifinternal
- catstr
- get_stuff_in_command catstr
- translatecomments ;
-: ENDSENUM
- skip_past_newline
- copy_past_newline strip_trailing_newlines
- dup
- " " swap catstr " };\n" catstr swap
- " \"@@overflow: " swap catstr "@@\",\n};\n#endif\n\n" catstr
- ifinternal
- catstr
- ;
-: make_enumerator
- " " swap catstr
- ",\n" catstr
- ;
-: make_enumerator_string
- " \"" swap catstr
- "\",\n" catstr
- ;
-: ENUM
- skip_past_newline
- copy_past_newline
- remchar
- dup
- make_enumerator
- swap
- make_enumerator_string
- ifinternal
- ;
-: ENUMX ENUM catstr ;
-: ENUMEQ
- skip_past_newline
- "#define "
- copy_past_newline remchar
- catstr
- " "
- catstr
- copy_past_newline
- catstr
- "" swap 0 internalmode maybecatstr
- ;
-: ENUMEQX ENUMEQ catstr ;
-: ENUMDOC
- skip_past_newline
- get_stuff_in_command
- strip_trailing_newlines
- "\n{* " swap catstr " *}\n" catstr
- translatecomments
- - discard it if we're doing internal mode
- "" swap 0 internalmode maybecatstr
- swap
- catstr catstr
- ;
-: ENDDD external ;
-: SECTION ignore ;
-: SUBSECTION ignore ;
-: SUBSUBSECTION ignore ;
-: INTERNAL_DEFINITION internal ;
-: DESCRIPTION ignore ;
-: FUNCTION external ;
-: RETURNS ignore ;
-: TYPEDEF external ;
-: INTERNAL_FUNCTION internal ;
-: INTERNAL internal ;
-: INODE ignore ;
diff --git a/contrib/gdb/bfd/ecoff.c b/contrib/gdb/bfd/ecoff.c
deleted file mode 100644
index e219ff7..0000000
--- a/contrib/gdb/bfd/ecoff.c
+++ /dev/null
@@ -1,4740 +0,0 @@
-/* Generic ECOFF (Extended-COFF) routines.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Original version by Per Bothner.
- Full support added by Ian Lance Taylor, ian@cygnus.com.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "aout/ar.h"
-#include "aout/ranlib.h"
-#include "aout/stab_gnu.h"
-
-/* FIXME: We need the definitions of N_SET[ADTB], but aout64.h defines
- some other stuff which we don't want and which conflicts with stuff
- we do want. */
-#include "libaout.h"
-#include "aout/aout64.h"
-#undef N_ABS
-#undef exec_hdr
-#undef obj_sym_filepos
-
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-#include "libcoff.h"
-#include "libecoff.h"
-
-/* Prototypes for static functions. */
-
-static int ecoff_get_magic PARAMS ((bfd *abfd));
-static long ecoff_sec_to_styp_flags PARAMS ((const char *name,
- flagword flags));
-static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd));
-static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
- asymbol *asym, int ext, int weak));
-static void ecoff_emit_aggregate PARAMS ((bfd *abfd, FDR *fdr,
- char *string,
- RNDXR *rndx, long isym,
- const char *which));
-static char *ecoff_type_to_string PARAMS ((bfd *abfd, FDR *fdr,
- unsigned int indx));
-static boolean ecoff_slurp_reloc_table PARAMS ((bfd *abfd, asection *section,
- asymbol **symbols));
-static int ecoff_sort_hdrs PARAMS ((const PTR, const PTR));
-static boolean ecoff_compute_section_file_positions PARAMS ((bfd *abfd));
-static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *abfd));
-static boolean ecoff_get_extr PARAMS ((asymbol *, EXTR *));
-static void ecoff_set_index PARAMS ((asymbol *, bfd_size_type));
-static unsigned int ecoff_armap_hash PARAMS ((CONST char *s,
- unsigned int *rehash,
- unsigned int size,
- unsigned int hlog));
-
-/* This stuff is somewhat copied from coffcode.h. */
-
-static asection bfd_debug_section = { "*DEBUG*" };
-
-/* Create an ECOFF object. */
-
-boolean
-_bfd_ecoff_mkobject (abfd)
- bfd *abfd;
-{
- abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
- bfd_zalloc (abfd, sizeof (ecoff_data_type)));
- if (abfd->tdata.ecoff_obj_data == NULL)
- return false;
-
- return true;
-}
-
-/* This is a hook called by coff_real_object_p to create any backend
- specific information. */
-
-PTR
-_bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
- bfd *abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr;
- ecoff_data_type *ecoff;
-
- if (_bfd_ecoff_mkobject (abfd) == false)
- return NULL;
-
- ecoff = ecoff_data (abfd);
- ecoff->gp_size = 8;
- ecoff->sym_filepos = internal_f->f_symptr;
-
- if (internal_a != (struct internal_aouthdr *) NULL)
- {
- int i;
-
- ecoff->text_start = internal_a->text_start;
- ecoff->text_end = internal_a->text_start + internal_a->tsize;
- ecoff->gp = internal_a->gp_value;
- ecoff->gprmask = internal_a->gprmask;
- for (i = 0; i < 4; i++)
- ecoff->cprmask[i] = internal_a->cprmask[i];
- ecoff->fprmask = internal_a->fprmask;
- if (internal_a->magic == ECOFF_AOUT_ZMAGIC)
- abfd->flags |= D_PAGED;
- else
- abfd->flags &=~ D_PAGED;
- }
-
- /* It turns out that no special action is required by the MIPS or
- Alpha ECOFF backends. They have different information in the
- a.out header, but we just copy it all (e.g., gprmask, cprmask and
- fprmask) and let the swapping routines ensure that only relevant
- information is written out. */
-
- return (PTR) ecoff;
-}
-
-/* Initialize a new section. */
-
-boolean
-_bfd_ecoff_new_section_hook (abfd, section)
- bfd *abfd;
- asection *section;
-{
- /* For the .pdata section, which has a special meaning on the Alpha,
- we set the alignment power to 3. We correct this later in
- ecoff_compute_section_file_positions. We do this hackery because
- we need to know the exact unaligned size of the .pdata section in
- order to set the lnnoptr field correctly. For every other
- section we use an alignment power of 4; this could be made target
- dependent by adding a field to ecoff_backend_data, but 4 appears
- to be correct for both the MIPS and the Alpha. */
- if (strcmp (section->name, _PDATA) == 0)
- section->alignment_power = 3;
- else
- section->alignment_power = 4;
-
- if (strcmp (section->name, _TEXT) == 0)
- section->flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- else if (strcmp (section->name, _DATA) == 0
- || strcmp (section->name, _SDATA) == 0)
- section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- else if (strcmp (section->name, _RDATA) == 0
- || strcmp (section->name, _LIT8) == 0
- || strcmp (section->name, _LIT4) == 0
- || strcmp (section->name, _RCONST) == 0)
- section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- else if (strcmp (section->name, _BSS) == 0
- || strcmp (section->name, _SBSS) == 0)
- section->flags |= SEC_ALLOC;
- else if (strcmp (section->name, _LIB) == 0)
- {
- /* An Irix 4 shared libary. */
- section->flags |= SEC_COFF_SHARED_LIBRARY;
- }
-
- /* Probably any other section name is SEC_NEVER_LOAD, but I'm
- uncertain about .init on some systems and I don't know how shared
- libraries work. */
-
- return true;
-}
-
-/* Determine the machine architecture and type. This is called from
- the generic COFF routines. It is the inverse of ecoff_get_magic,
- below. This could be an ECOFF backend routine, with one version
- for each target, but there aren't all that many ECOFF targets. */
-
-boolean
-_bfd_ecoff_set_arch_mach_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- enum bfd_architecture arch;
- unsigned long mach;
-
- switch (internal_f->f_magic)
- {
- case MIPS_MAGIC_1:
- case MIPS_MAGIC_LITTLE:
- case MIPS_MAGIC_BIG:
- arch = bfd_arch_mips;
- mach = 3000;
- break;
-
- case MIPS_MAGIC_LITTLE2:
- case MIPS_MAGIC_BIG2:
- /* MIPS ISA level 2: the r6000 */
- arch = bfd_arch_mips;
- mach = 6000;
- break;
-
- case MIPS_MAGIC_LITTLE3:
- case MIPS_MAGIC_BIG3:
- /* MIPS ISA level 3: the r4000 */
- arch = bfd_arch_mips;
- mach = 4000;
- break;
-
- case ALPHA_MAGIC:
- arch = bfd_arch_alpha;
- mach = 0;
- break;
-
- default:
- arch = bfd_arch_obscure;
- mach = 0;
- break;
- }
-
- return bfd_default_set_arch_mach (abfd, arch, mach);
-}
-
-/* Get the magic number to use based on the architecture and machine.
- This is the inverse of _bfd_ecoff_set_arch_mach_hook, above. */
-
-static int
-ecoff_get_magic (abfd)
- bfd *abfd;
-{
- int big, little;
-
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_mips:
- switch (bfd_get_mach (abfd))
- {
- default:
- case 0:
- case 3000:
- big = MIPS_MAGIC_BIG;
- little = MIPS_MAGIC_LITTLE;
- break;
-
- case 6000:
- big = MIPS_MAGIC_BIG2;
- little = MIPS_MAGIC_LITTLE2;
- break;
-
- case 4000:
- big = MIPS_MAGIC_BIG3;
- little = MIPS_MAGIC_LITTLE3;
- break;
- }
-
- return bfd_big_endian (abfd) ? big : little;
-
- case bfd_arch_alpha:
- return ALPHA_MAGIC;
-
- default:
- abort ();
- return 0;
- }
-}
-
-/* Get the section s_flags to use for a section. */
-
-static long
-ecoff_sec_to_styp_flags (name, flags)
- const char *name;
- flagword flags;
-{
- long styp;
-
- styp = 0;
-
- if (strcmp (name, _TEXT) == 0)
- styp = STYP_TEXT;
- else if (strcmp (name, _DATA) == 0)
- styp = STYP_DATA;
- else if (strcmp (name, _SDATA) == 0)
- styp = STYP_SDATA;
- else if (strcmp (name, _RDATA) == 0)
- styp = STYP_RDATA;
- else if (strcmp (name, _LITA) == 0)
- styp = STYP_LITA;
- else if (strcmp (name, _LIT8) == 0)
- styp = STYP_LIT8;
- else if (strcmp (name, _LIT4) == 0)
- styp = STYP_LIT4;
- else if (strcmp (name, _BSS) == 0)
- styp = STYP_BSS;
- else if (strcmp (name, _SBSS) == 0)
- styp = STYP_SBSS;
- else if (strcmp (name, _INIT) == 0)
- styp = STYP_ECOFF_INIT;
- else if (strcmp (name, _FINI) == 0)
- styp = STYP_ECOFF_FINI;
- else if (strcmp (name, _PDATA) == 0)
- styp = STYP_PDATA;
- else if (strcmp (name, _XDATA) == 0)
- styp = STYP_XDATA;
- else if (strcmp (name, _LIB) == 0)
- styp = STYP_ECOFF_LIB;
- else if (strcmp (name, _GOT) == 0)
- styp = STYP_GOT;
- else if (strcmp (name, _HASH) == 0)
- styp = STYP_HASH;
- else if (strcmp (name, _DYNAMIC) == 0)
- styp = STYP_DYNAMIC;
- else if (strcmp (name, _LIBLIST) == 0)
- styp = STYP_LIBLIST;
- else if (strcmp (name, _RELDYN) == 0)
- styp = STYP_RELDYN;
- else if (strcmp (name, _CONFLIC) == 0)
- styp = STYP_CONFLIC;
- else if (strcmp (name, _DYNSTR) == 0)
- styp = STYP_DYNSTR;
- else if (strcmp (name, _DYNSYM) == 0)
- styp = STYP_DYNSYM;
- else if (strcmp (name, _COMMENT) == 0)
- {
- styp = STYP_COMMENT;
- flags &=~ SEC_NEVER_LOAD;
- }
- else if (strcmp (name, _RCONST) == 0)
- styp = STYP_RCONST;
- else if (flags & SEC_CODE)
- styp = STYP_TEXT;
- else if (flags & SEC_DATA)
- styp = STYP_DATA;
- else if (flags & SEC_READONLY)
- styp = STYP_RDATA;
- else if (flags & SEC_LOAD)
- styp = STYP_REG;
- else
- styp = STYP_BSS;
-
- if (flags & SEC_NEVER_LOAD)
- styp |= STYP_NOLOAD;
-
- return styp;
-}
-
-/* Get the BFD flags to use for a section. */
-
-/*ARGSUSED*/
-flagword
-_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name)
- bfd *abfd;
- PTR hdr;
- const char *name;
-{
- struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
- long styp_flags = internal_s->s_flags;
- flagword sec_flags=0;
-
- if (styp_flags & STYP_NOLOAD)
- sec_flags |= SEC_NEVER_LOAD;
-
- /* For 386 COFF, at least, an unloadable text or data section is
- actually a shared library section. */
- if ((styp_flags & STYP_TEXT)
- || (styp_flags & STYP_ECOFF_INIT)
- || (styp_flags & STYP_ECOFF_FINI)
- || (styp_flags & STYP_DYNAMIC)
- || (styp_flags & STYP_LIBLIST)
- || (styp_flags & STYP_RELDYN)
- || styp_flags == STYP_CONFLIC
- || (styp_flags & STYP_DYNSTR)
- || (styp_flags & STYP_DYNSYM)
- || (styp_flags & STYP_HASH))
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
- }
- else if ((styp_flags & STYP_DATA)
- || (styp_flags & STYP_RDATA)
- || (styp_flags & STYP_SDATA)
- || styp_flags == STYP_PDATA
- || styp_flags == STYP_XDATA
- || (styp_flags & STYP_GOT)
- || styp_flags == STYP_RCONST)
- {
- if (sec_flags & SEC_NEVER_LOAD)
- sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
- else
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
- if ((styp_flags & STYP_RDATA)
- || styp_flags == STYP_PDATA
- || styp_flags == STYP_RCONST)
- sec_flags |= SEC_READONLY;
- }
- else if ((styp_flags & STYP_BSS)
- || (styp_flags & STYP_SBSS))
- {
- sec_flags |= SEC_ALLOC;
- }
- else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
- {
- sec_flags |= SEC_NEVER_LOAD;
- }
- else if ((styp_flags & STYP_LITA)
- || (styp_flags & STYP_LIT8)
- || (styp_flags & STYP_LIT4))
- {
- sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
- }
- else if (styp_flags & STYP_ECOFF_LIB)
- {
- sec_flags |= SEC_COFF_SHARED_LIBRARY;
- }
- else
- {
- sec_flags |= SEC_ALLOC | SEC_LOAD;
- }
-
- return sec_flags;
-}
-
-/* Read in the symbolic header for an ECOFF object file. */
-
-static boolean
-ecoff_slurp_symbolic_header (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- bfd_size_type external_hdr_size;
- PTR raw = NULL;
- HDRR *internal_symhdr;
-
- /* See if we've already read it in. */
- if (ecoff_data (abfd)->debug_info.symbolic_header.magic ==
- backend->debug_swap.sym_magic)
- return true;
-
- /* See whether there is a symbolic header. */
- if (ecoff_data (abfd)->sym_filepos == 0)
- {
- bfd_get_symcount (abfd) = 0;
- return true;
- }
-
- /* At this point bfd_get_symcount (abfd) holds the number of symbols
- as read from the file header, but on ECOFF this is always the
- size of the symbolic information header. It would be cleaner to
- handle this when we first read the file in coffgen.c. */
- external_hdr_size = backend->debug_swap.external_hdr_size;
- if (bfd_get_symcount (abfd) != external_hdr_size)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Read the symbolic information header. */
- raw = (PTR) bfd_malloc ((size_t) external_hdr_size);
- if (raw == NULL)
- goto error_return;
-
- if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
- || (bfd_read (raw, external_hdr_size, 1, abfd)
- != external_hdr_size))
- goto error_return;
- internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
- (*backend->debug_swap.swap_hdr_in) (abfd, raw, internal_symhdr);
-
- if (internal_symhdr->magic != backend->debug_swap.sym_magic)
- {
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- /* Now we can get the correct number of symbols. */
- bfd_get_symcount (abfd) = (internal_symhdr->isymMax
- + internal_symhdr->iextMax);
-
- if (raw != NULL)
- free (raw);
- return true;
- error_return:
- if (raw != NULL)
- free (raw);
- return false;
-}
-
-/* Read in and swap the important symbolic information for an ECOFF
- object file. This is called by gdb via the read_debug_info entry
- point in the backend structure. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
- bfd *abfd;
- asection *ignore;
- struct ecoff_debug_info *debug;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- HDRR *internal_symhdr;
- bfd_size_type raw_base;
- bfd_size_type raw_size;
- PTR raw;
- bfd_size_type external_fdr_size;
- char *fraw_src;
- char *fraw_end;
- struct fdr *fdr_ptr;
- bfd_size_type raw_end;
- bfd_size_type cb_end;
-
- BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
-
- /* Check whether we've already gotten it, and whether there's any to
- get. */
- if (ecoff_data (abfd)->raw_syments != (PTR) NULL)
- return true;
- if (ecoff_data (abfd)->sym_filepos == 0)
- {
- bfd_get_symcount (abfd) = 0;
- return true;
- }
-
- if (! ecoff_slurp_symbolic_header (abfd))
- return false;
-
- internal_symhdr = &debug->symbolic_header;
-
- /* Read all the symbolic information at once. */
- raw_base = (ecoff_data (abfd)->sym_filepos
- + backend->debug_swap.external_hdr_size);
-
- /* Alpha ecoff makes the determination of raw_size difficult. It has
- an undocumented debug data section between the symhdr and the first
- documented section. And the ordering of the sections varies between
- statically and dynamically linked executables.
- If bfd supports SEEK_END someday, this code could be simplified. */
-
- raw_end = 0;
-
-#define UPDATE_RAW_END(start, count, size) \
- cb_end = internal_symhdr->start + internal_symhdr->count * (size); \
- if (cb_end > raw_end) \
- raw_end = cb_end
-
- UPDATE_RAW_END (cbLineOffset, cbLine, sizeof (unsigned char));
- UPDATE_RAW_END (cbDnOffset, idnMax, backend->debug_swap.external_dnr_size);
- UPDATE_RAW_END (cbPdOffset, ipdMax, backend->debug_swap.external_pdr_size);
- UPDATE_RAW_END (cbSymOffset, isymMax, backend->debug_swap.external_sym_size);
- UPDATE_RAW_END (cbOptOffset, ioptMax, backend->debug_swap.external_opt_size);
- UPDATE_RAW_END (cbAuxOffset, iauxMax, sizeof (union aux_ext));
- UPDATE_RAW_END (cbSsOffset, issMax, sizeof (char));
- UPDATE_RAW_END (cbSsExtOffset, issExtMax, sizeof (char));
- UPDATE_RAW_END (cbFdOffset, ifdMax, backend->debug_swap.external_fdr_size);
- UPDATE_RAW_END (cbRfdOffset, crfd, backend->debug_swap.external_rfd_size);
- UPDATE_RAW_END (cbExtOffset, iextMax, backend->debug_swap.external_ext_size);
-
-#undef UPDATE_RAW_END
-
- raw_size = raw_end - raw_base;
- if (raw_size == 0)
- {
- ecoff_data (abfd)->sym_filepos = 0;
- return true;
- }
- raw = (PTR) bfd_alloc (abfd, raw_size);
- if (raw == NULL)
- return false;
- if (bfd_seek (abfd,
- (ecoff_data (abfd)->sym_filepos
- + backend->debug_swap.external_hdr_size),
- SEEK_SET) != 0
- || bfd_read (raw, raw_size, 1, abfd) != raw_size)
- {
- bfd_release (abfd, raw);
- return false;
- }
-
- ecoff_data (abfd)->raw_syments = raw;
-
- /* Get pointers for the numeric offsets in the HDRR structure. */
-#define FIX(off1, off2, type) \
- if (internal_symhdr->off1 == 0) \
- debug->off2 = (type) NULL; \
- else \
- debug->off2 = (type) ((char *) raw \
- + (internal_symhdr->off1 \
- - raw_base))
- FIX (cbLineOffset, line, unsigned char *);
- FIX (cbDnOffset, external_dnr, PTR);
- FIX (cbPdOffset, external_pdr, PTR);
- FIX (cbSymOffset, external_sym, PTR);
- FIX (cbOptOffset, external_opt, PTR);
- FIX (cbAuxOffset, external_aux, union aux_ext *);
- FIX (cbSsOffset, ss, char *);
- FIX (cbSsExtOffset, ssext, char *);
- FIX (cbFdOffset, external_fdr, PTR);
- FIX (cbRfdOffset, external_rfd, PTR);
- FIX (cbExtOffset, external_ext, PTR);
-#undef FIX
-
- /* I don't want to always swap all the data, because it will just
- waste time and most programs will never look at it. The only
- time the linker needs most of the debugging information swapped
- is when linking big-endian and little-endian MIPS object files
- together, which is not a common occurrence.
-
- We need to look at the fdr to deal with a lot of information in
- the symbols, so we swap them here. */
- debug->fdr = (struct fdr *) bfd_alloc (abfd,
- (internal_symhdr->ifdMax *
- sizeof (struct fdr)));
- if (debug->fdr == NULL)
- return false;
- external_fdr_size = backend->debug_swap.external_fdr_size;
- fdr_ptr = debug->fdr;
- fraw_src = (char *) debug->external_fdr;
- fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size;
- for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
- (*backend->debug_swap.swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
-
- return true;
-}
-
-/* ECOFF symbol table routines. The ECOFF symbol table is described
- in gcc/mips-tfile.c. */
-
-/* ECOFF uses two common sections. One is the usual one, and the
- other is for small objects. All the small objects are kept
- together, and then referenced via the gp pointer, which yields
- faster assembler code. This is what we use for the small common
- section. */
-static asection ecoff_scom_section;
-static asymbol ecoff_scom_symbol;
-static asymbol *ecoff_scom_symbol_ptr;
-
-/* Create an empty symbol. */
-
-asymbol *
-_bfd_ecoff_make_empty_symbol (abfd)
- bfd *abfd;
-{
- ecoff_symbol_type *new;
-
- new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
- if (new == (ecoff_symbol_type *) NULL)
- return (asymbol *) NULL;
- memset ((PTR) new, 0, sizeof *new);
- new->symbol.section = (asection *) NULL;
- new->fdr = (FDR *) NULL;
- new->local = false;
- new->native = NULL;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/* Set the BFD flags and section for an ECOFF symbol. */
-
-static boolean
-ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak)
- bfd *abfd;
- SYMR *ecoff_sym;
- asymbol *asym;
- int ext;
- int weak;
-{
- asym->the_bfd = abfd;
- asym->value = ecoff_sym->value;
- asym->section = &bfd_debug_section;
- asym->udata.i = 0;
-
- /* Most symbol types are just for debugging. */
- switch (ecoff_sym->st)
- {
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- break;
- case stNil:
- if (ECOFF_IS_STAB (ecoff_sym))
- {
- asym->flags = BSF_DEBUGGING;
- return true;
- }
- break;
- default:
- asym->flags = BSF_DEBUGGING;
- return true;
- }
-
- if (weak)
- asym->flags = BSF_EXPORT | BSF_WEAK;
- else if (ext)
- asym->flags = BSF_EXPORT | BSF_GLOBAL;
- else
- {
- asym->flags = BSF_LOCAL;
- /* Normally, a local stProc symbol will have a corresponding
- external symbol. We mark the local symbol as a debugging
- symbol, in order to prevent nm from printing both out.
- Similarly, we mark stLabel and stabs symbols as debugging
- symbols. In both cases, we do want to set the value
- correctly based on the symbol class. */
- if (ecoff_sym->st == stProc
- || ecoff_sym->st == stLabel
- || ECOFF_IS_STAB (ecoff_sym))
- asym->flags |= BSF_DEBUGGING;
- }
- switch (ecoff_sym->sc)
- {
- case scNil:
- /* Used for compiler generated labels. Leave them in the
- debugging section, and mark them as local. If BSF_DEBUGGING
- is set, then nm does not display them for some reason. If no
- flags are set then the linker whines about them. */
- asym->flags = BSF_LOCAL;
- break;
- case scText:
- asym->section = bfd_make_section_old_way (abfd, ".text");
- asym->value -= asym->section->vma;
- break;
- case scData:
- asym->section = bfd_make_section_old_way (abfd, ".data");
- asym->value -= asym->section->vma;
- break;
- case scBss:
- asym->section = bfd_make_section_old_way (abfd, ".bss");
- asym->value -= asym->section->vma;
- break;
- case scRegister:
- asym->flags = BSF_DEBUGGING;
- break;
- case scAbs:
- asym->section = bfd_abs_section_ptr;
- break;
- case scUndefined:
- asym->section = bfd_und_section_ptr;
- asym->flags = 0;
- asym->value = 0;
- break;
- case scCdbLocal:
- case scBits:
- case scCdbSystem:
- case scRegImage:
- case scInfo:
- case scUserStruct:
- asym->flags = BSF_DEBUGGING;
- break;
- case scSData:
- asym->section = bfd_make_section_old_way (abfd, ".sdata");
- asym->value -= asym->section->vma;
- break;
- case scSBss:
- asym->section = bfd_make_section_old_way (abfd, ".sbss");
- asym->value -= asym->section->vma;
- break;
- case scRData:
- asym->section = bfd_make_section_old_way (abfd, ".rdata");
- asym->value -= asym->section->vma;
- break;
- case scVar:
- asym->flags = BSF_DEBUGGING;
- break;
- case scCommon:
- if (asym->value > ecoff_data (abfd)->gp_size)
- {
- asym->section = bfd_com_section_ptr;
- asym->flags = 0;
- break;
- }
- /* Fall through. */
- case scSCommon:
- if (ecoff_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
- ecoff_scom_section.output_section = &ecoff_scom_section;
- ecoff_scom_section.symbol = &ecoff_scom_symbol;
- ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
- ecoff_scom_symbol.name = SCOMMON;
- ecoff_scom_symbol.flags = BSF_SECTION_SYM;
- ecoff_scom_symbol.section = &ecoff_scom_section;
- ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
- }
- asym->section = &ecoff_scom_section;
- asym->flags = 0;
- break;
- case scVarRegister:
- case scVariant:
- asym->flags = BSF_DEBUGGING;
- break;
- case scSUndefined:
- asym->section = bfd_und_section_ptr;
- asym->flags = 0;
- asym->value = 0;
- break;
- case scInit:
- asym->section = bfd_make_section_old_way (abfd, ".init");
- asym->value -= asym->section->vma;
- break;
- case scBasedVar:
- case scXData:
- case scPData:
- asym->flags = BSF_DEBUGGING;
- break;
- case scFini:
- asym->section = bfd_make_section_old_way (abfd, ".fini");
- asym->value -= asym->section->vma;
- break;
- case scRConst:
- asym->section = bfd_make_section_old_way (abfd, ".rconst");
- asym->value -= asym->section->vma;
- break;
- default:
- break;
- }
-
- /* Look for special constructors symbols and make relocation entries
- in a special construction section. These are produced by the
- -fgnu-linker argument to g++. */
- if (ECOFF_IS_STAB (ecoff_sym))
- {
- switch (ECOFF_UNMARK_STAB (ecoff_sym->index))
- {
- default:
- break;
-
- case N_SETA:
- case N_SETT:
- case N_SETD:
- case N_SETB:
- {
- const char *name;
- asection *section;
- arelent_chain *reloc_chain;
- unsigned int bitsize;
-
- /* Get a section with the same name as the symbol (usually
- __CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
- name ___CTOR_LIST (three underscores). We need
- __CTOR_LIST (two underscores), since ECOFF doesn't use
- a leading underscore. This should be handled by gcc,
- but instead we do it here. Actually, this should all
- be done differently anyhow. */
- name = bfd_asymbol_name (asym);
- if (name[0] == '_' && name[1] == '_' && name[2] == '_')
- {
- ++name;
- asym->name = name;
- }
- section = bfd_get_section_by_name (abfd, name);
- if (section == (asection *) NULL)
- {
- char *copy;
-
- copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
- if (!copy)
- return false;
- strcpy (copy, name);
- section = bfd_make_section (abfd, copy);
- }
-
- /* Build a reloc pointing to this constructor. */
- reloc_chain =
- (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
- if (!reloc_chain)
- return false;
- reloc_chain->relent.sym_ptr_ptr =
- bfd_get_section (asym)->symbol_ptr_ptr;
- reloc_chain->relent.address = section->_raw_size;
- reloc_chain->relent.addend = asym->value;
- reloc_chain->relent.howto =
- ecoff_backend (abfd)->constructor_reloc;
-
- /* Set up the constructor section to hold the reloc. */
- section->flags = SEC_CONSTRUCTOR;
- ++section->reloc_count;
-
- /* Constructor sections must be rounded to a boundary
- based on the bitsize. These are not real sections--
- they are handled specially by the linker--so the ECOFF
- 16 byte alignment restriction does not apply. */
- bitsize = ecoff_backend (abfd)->constructor_bitsize;
- section->alignment_power = 1;
- while ((1 << section->alignment_power) < bitsize / 8)
- ++section->alignment_power;
-
- reloc_chain->next = section->constructor_chain;
- section->constructor_chain = reloc_chain;
- section->_raw_size += bitsize / 8;
-
- /* Mark the symbol as a constructor. */
- asym->flags |= BSF_CONSTRUCTOR;
- }
- break;
- }
- }
- return true;
-}
-
-/* Read an ECOFF symbol table. */
-
-boolean
-_bfd_ecoff_slurp_symbol_table (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_size_type external_ext_size
- = backend->debug_swap.external_ext_size;
- const bfd_size_type external_sym_size
- = backend->debug_swap.external_sym_size;
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
- = backend->debug_swap.swap_sym_in;
- bfd_size_type internal_size;
- ecoff_symbol_type *internal;
- ecoff_symbol_type *internal_ptr;
- char *eraw_src;
- char *eraw_end;
- FDR *fdr_ptr;
- FDR *fdr_end;
-
- /* If we've already read in the symbol table, do nothing. */
- if (ecoff_data (abfd)->canonical_symbols != NULL)
- return true;
-
- /* Get the symbolic information. */
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
- &ecoff_data (abfd)->debug_info))
- return false;
- if (bfd_get_symcount (abfd) == 0)
- return true;
-
- internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
- internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
- if (internal == NULL)
- return false;
-
- internal_ptr = internal;
- eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
- eraw_end = (eraw_src
- + (ecoff_data (abfd)->debug_info.symbolic_header.iextMax
- * external_ext_size));
- for (; eraw_src < eraw_end; eraw_src += external_ext_size, internal_ptr++)
- {
- EXTR internal_esym;
-
- (*swap_ext_in) (abfd, (PTR) eraw_src, &internal_esym);
- internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
- + internal_esym.asym.iss);
- if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
- &internal_ptr->symbol, 1,
- internal_esym.weakext))
- return false;
- /* The alpha uses a negative ifd field for section symbols. */
- if (internal_esym.ifd >= 0)
- internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
- + internal_esym.ifd);
- else
- internal_ptr->fdr = NULL;
- internal_ptr->local = false;
- internal_ptr->native = (PTR) eraw_src;
- }
-
- /* The local symbols must be accessed via the fdr's, because the
- string and aux indices are relative to the fdr information. */
- fdr_ptr = ecoff_data (abfd)->debug_info.fdr;
- fdr_end = fdr_ptr + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax;
- for (; fdr_ptr < fdr_end; fdr_ptr++)
- {
- char *lraw_src;
- char *lraw_end;
-
- lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
- + fdr_ptr->isymBase * external_sym_size);
- lraw_end = lraw_src + fdr_ptr->csym * external_sym_size;
- for (;
- lraw_src < lraw_end;
- lraw_src += external_sym_size, internal_ptr++)
- {
- SYMR internal_sym;
-
- (*swap_sym_in) (abfd, (PTR) lraw_src, &internal_sym);
- internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss
- + fdr_ptr->issBase
- + internal_sym.iss);
- if (!ecoff_set_symbol_info (abfd, &internal_sym,
- &internal_ptr->symbol, 0, 0))
- return false;
- internal_ptr->fdr = fdr_ptr;
- internal_ptr->local = true;
- internal_ptr->native = (PTR) lraw_src;
- }
- }
-
- ecoff_data (abfd)->canonical_symbols = internal;
-
- return true;
-}
-
-/* Return the amount of space needed for the canonical symbols. */
-
-long
-_bfd_ecoff_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
- &ecoff_data (abfd)->debug_info))
- return -1;
-
- if (bfd_get_symcount (abfd) == 0)
- return 0;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *));
-}
-
-/* Get the canonical symbols. */
-
-long
-_bfd_ecoff_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int counter = 0;
- ecoff_symbol_type *symbase;
- ecoff_symbol_type **location = (ecoff_symbol_type **) alocation;
-
- if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
- return -1;
- if (bfd_get_symcount (abfd) == 0)
- return 0;
-
- symbase = ecoff_data (abfd)->canonical_symbols;
- while (counter < bfd_get_symcount (abfd))
- {
- *(location++) = symbase++;
- counter++;
- }
- *location++ = (ecoff_symbol_type *) NULL;
- return bfd_get_symcount (abfd);
-}
-
-/* Turn ECOFF type information into a printable string.
- ecoff_emit_aggregate and ecoff_type_to_string are from
- gcc/mips-tdump.c, with swapping added and used_ptr removed. */
-
-/* Write aggregate information to a string. */
-
-static void
-ecoff_emit_aggregate (abfd, fdr, string, rndx, isym, which)
- bfd *abfd;
- FDR *fdr;
- char *string;
- RNDXR *rndx;
- long isym;
- const char *which;
-{
- const struct ecoff_debug_swap * const debug_swap =
- &ecoff_backend (abfd)->debug_swap;
- struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
- unsigned int ifd = rndx->rfd;
- unsigned int indx = rndx->index;
- const char *name;
-
- if (ifd == 0xfff)
- ifd = isym;
-
- /* An ifd of -1 is an opaque type. An escaped index of 0 is a
- struct return type of a procedure compiled without -g. */
- if (ifd == 0xffffffff
- || (rndx->rfd == 0xfff && indx == 0))
- name = "<undefined>";
- else if (indx == indexNil)
- name = "<no name>";
- else
- {
- SYMR sym;
-
- if (debug_info->external_rfd == NULL)
- fdr = debug_info->fdr + ifd;
- else
- {
- RFDT rfd;
-
- (*debug_swap->swap_rfd_in) (abfd,
- ((char *) debug_info->external_rfd
- + ((fdr->rfdBase + ifd)
- * debug_swap->external_rfd_size)),
- &rfd);
- fdr = debug_info->fdr + rfd;
- }
-
- indx += fdr->isymBase;
-
- (*debug_swap->swap_sym_in) (abfd,
- ((char *) debug_info->external_sym
- + indx * debug_swap->external_sym_size),
- &sym);
-
- name = debug_info->ss + fdr->issBase + sym.iss;
- }
-
- sprintf (string,
- "%s %s { ifd = %u, index = %lu }",
- which, name, ifd,
- ((long) indx
- + debug_info->symbolic_header.iextMax));
-}
-
-/* Convert the type information to string format. */
-
-static char *
-ecoff_type_to_string (abfd, fdr, indx)
- bfd *abfd;
- FDR *fdr;
- unsigned int indx;
-{
- union aux_ext *aux_ptr;
- int bigendian;
- AUXU u;
- struct qual {
- unsigned int type;
- int low_bound;
- int high_bound;
- int stride;
- } qualifiers[7];
- unsigned int basic_type;
- int i;
- char buffer1[1024];
- static char buffer2[1024];
- char *p1 = buffer1;
- char *p2 = buffer2;
- RNDXR rndx;
-
- aux_ptr = ecoff_data (abfd)->debug_info.external_aux + fdr->iauxBase;
- bigendian = fdr->fBigendian;
-
- for (i = 0; i < 7; i++)
- {
- qualifiers[i].low_bound = 0;
- qualifiers[i].high_bound = 0;
- qualifiers[i].stride = 0;
- }
-
- if (AUX_GET_ISYM (bigendian, &aux_ptr[indx]) == (bfd_vma) -1)
- return "-1 (no type)";
- _bfd_ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti);
-
- basic_type = u.ti.bt;
- qualifiers[0].type = u.ti.tq0;
- qualifiers[1].type = u.ti.tq1;
- qualifiers[2].type = u.ti.tq2;
- qualifiers[3].type = u.ti.tq3;
- qualifiers[4].type = u.ti.tq4;
- qualifiers[5].type = u.ti.tq5;
- qualifiers[6].type = tqNil;
-
- /*
- * Go get the basic type.
- */
- switch (basic_type)
- {
- case btNil: /* undefined */
- strcpy (p1, "nil");
- break;
-
- case btAdr: /* address - integer same size as pointer */
- strcpy (p1, "address");
- break;
-
- case btChar: /* character */
- strcpy (p1, "char");
- break;
-
- case btUChar: /* unsigned character */
- strcpy (p1, "unsigned char");
- break;
-
- case btShort: /* short */
- strcpy (p1, "short");
- break;
-
- case btUShort: /* unsigned short */
- strcpy (p1, "unsigned short");
- break;
-
- case btInt: /* int */
- strcpy (p1, "int");
- break;
-
- case btUInt: /* unsigned int */
- strcpy (p1, "unsigned int");
- break;
-
- case btLong: /* long */
- strcpy (p1, "long");
- break;
-
- case btULong: /* unsigned long */
- strcpy (p1, "unsigned long");
- break;
-
- case btFloat: /* float (real) */
- strcpy (p1, "float");
- break;
-
- case btDouble: /* Double (real) */
- strcpy (p1, "double");
- break;
-
- /* Structures add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btStruct: /* Structure (Record) */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "struct");
- indx++; /* skip aux words */
- break;
-
- /* Unions add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to union def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btUnion: /* Union */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "union");
- indx++; /* skip aux words */
- break;
-
- /* Enumerations add 1-2 aux words:
- 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
- 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
-
- case btEnum: /* Enumeration */
- _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
- ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
- (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
- "enum");
- indx++; /* skip aux words */
- break;
-
- case btTypedef: /* defined via a typedef, isymRef points */
- strcpy (p1, "typedef");
- break;
-
- case btRange: /* subrange of int */
- strcpy (p1, "subrange");
- break;
-
- case btSet: /* pascal sets */
- strcpy (p1, "set");
- break;
-
- case btComplex: /* fortran complex */
- strcpy (p1, "complex");
- break;
-
- case btDComplex: /* fortran double complex */
- strcpy (p1, "double complex");
- break;
-
- case btIndirect: /* forward or unnamed typedef */
- strcpy (p1, "forward/unamed typedef");
- break;
-
- case btFixedDec: /* Fixed Decimal */
- strcpy (p1, "fixed decimal");
- break;
-
- case btFloatDec: /* Float Decimal */
- strcpy (p1, "float decimal");
- break;
-
- case btString: /* Varying Length Character String */
- strcpy (p1, "string");
- break;
-
- case btBit: /* Aligned Bit String */
- strcpy (p1, "bit");
- break;
-
- case btPicture: /* Picture */
- strcpy (p1, "picture");
- break;
-
- case btVoid: /* Void */
- strcpy (p1, "void");
- break;
-
- default:
- sprintf (p1, "Unknown basic type %d", (int) basic_type);
- break;
- }
-
- p1 += strlen (buffer1);
-
- /*
- * If this is a bitfield, get the bitsize.
- */
- if (u.ti.fBitfield)
- {
- int bitsize;
-
- bitsize = AUX_GET_WIDTH (bigendian, &aux_ptr[indx++]);
- sprintf (p1, " : %d", bitsize);
- p1 += strlen (buffer1);
- }
-
-
- /*
- * Deal with any qualifiers.
- */
- if (qualifiers[0].type != tqNil)
- {
- /*
- * Snarf up any array bounds in the correct order. Arrays
- * store 5 successive words in the aux. table:
- * word 0 RNDXR to type of the bounds (ie, int)
- * word 1 Current file descriptor index
- * word 2 low bound
- * word 3 high bound (or -1 if [])
- * word 4 stride size in bits
- */
- for (i = 0; i < 7; i++)
- {
- if (qualifiers[i].type == tqArray)
- {
- qualifiers[i].low_bound =
- AUX_GET_DNLOW (bigendian, &aux_ptr[indx+2]);
- qualifiers[i].high_bound =
- AUX_GET_DNHIGH (bigendian, &aux_ptr[indx+3]);
- qualifiers[i].stride =
- AUX_GET_WIDTH (bigendian, &aux_ptr[indx+4]);
- indx += 5;
- }
- }
-
- /*
- * Now print out the qualifiers.
- */
- for (i = 0; i < 6; i++)
- {
- switch (qualifiers[i].type)
- {
- case tqNil:
- case tqMax:
- break;
-
- case tqPtr:
- strcpy (p2, "ptr to ");
- p2 += sizeof ("ptr to ")-1;
- break;
-
- case tqVol:
- strcpy (p2, "volatile ");
- p2 += sizeof ("volatile ")-1;
- break;
-
- case tqFar:
- strcpy (p2, "far ");
- p2 += sizeof ("far ")-1;
- break;
-
- case tqProc:
- strcpy (p2, "func. ret. ");
- p2 += sizeof ("func. ret. ");
- break;
-
- case tqArray:
- {
- int first_array = i;
- int j;
-
- /* Print array bounds reversed (ie, in the order the C
- programmer writes them). C is such a fun language.... */
-
- while (i < 5 && qualifiers[i+1].type == tqArray)
- i++;
-
- for (j = i; j >= first_array; j--)
- {
- strcpy (p2, "array [");
- p2 += sizeof ("array [")-1;
- if (qualifiers[j].low_bound != 0)
- sprintf (p2,
- "%ld:%ld {%ld bits}",
- (long) qualifiers[j].low_bound,
- (long) qualifiers[j].high_bound,
- (long) qualifiers[j].stride);
-
- else if (qualifiers[j].high_bound != -1)
- sprintf (p2,
- "%ld {%ld bits}",
- (long) (qualifiers[j].high_bound + 1),
- (long) (qualifiers[j].stride));
-
- else
- sprintf (p2, " {%ld bits}", (long) (qualifiers[j].stride));
-
- p2 += strlen (p2);
- strcpy (p2, "] of ");
- p2 += sizeof ("] of ")-1;
- }
- }
- break;
- }
- }
- }
-
- strcpy (p2, buffer1);
- return buffer2;
-}
-
-/* Return information about ECOFF symbol SYMBOL in RET. */
-
-/*ARGSUSED*/
-void
-_bfd_ecoff_get_symbol_info (abfd, symbol, ret)
- bfd *abfd; /* Ignored. */
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/* Return whether this is a local label. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_bfd_is_local_label (abfd, symbol)
- bfd *abfd;
- asymbol *symbol;
-{
- return symbol->name[0] == '$';
-}
-
-/* Print information about an ECOFF symbol. */
-
-void
-_bfd_ecoff_print_symbol (abfd, filep, symbol, how)
- bfd *abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- const struct ecoff_debug_swap * const debug_swap
- = &ecoff_backend (abfd)->debug_swap;
- FILE *file = (FILE *)filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- if (ecoffsymbol (symbol)->local)
- {
- SYMR ecoff_sym;
-
- (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_sym);
- fprintf (file, "ecoff local ");
- fprintf_vma (file, (bfd_vma) ecoff_sym.value);
- fprintf (file, " %x %x", (unsigned) ecoff_sym.st,
- (unsigned) ecoff_sym.sc);
- }
- else
- {
- EXTR ecoff_ext;
-
- (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext);
- fprintf (file, "ecoff extern ");
- fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
- fprintf (file, " %x %x", (unsigned) ecoff_ext.asym.st,
- (unsigned) ecoff_ext.asym.sc);
- }
- break;
- case bfd_print_symbol_all:
- /* Print out the symbols in a reasonable way */
- {
- char type;
- int pos;
- EXTR ecoff_ext;
- char jmptbl;
- char cobol_main;
- char weakext;
-
- if (ecoffsymbol (symbol)->local)
- {
- (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext.asym);
- type = 'l';
- pos = ((((char *) ecoffsymbol (symbol)->native
- - (char *) ecoff_data (abfd)->debug_info.external_sym)
- / debug_swap->external_sym_size)
- + ecoff_data (abfd)->debug_info.symbolic_header.iextMax);
- jmptbl = ' ';
- cobol_main = ' ';
- weakext = ' ';
- }
- else
- {
- (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
- &ecoff_ext);
- type = 'e';
- pos = (((char *) ecoffsymbol (symbol)->native
- - (char *) ecoff_data (abfd)->debug_info.external_ext)
- / debug_swap->external_ext_size);
- jmptbl = ecoff_ext.jmptbl ? 'j' : ' ';
- cobol_main = ecoff_ext.cobol_main ? 'c' : ' ';
- weakext = ecoff_ext.weakext ? 'w' : ' ';
- }
-
- fprintf (file, "[%3d] %c ",
- pos, type);
- fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
- fprintf (file, " st %x sc %x indx %x %c%c%c %s",
- (unsigned) ecoff_ext.asym.st,
- (unsigned) ecoff_ext.asym.sc,
- (unsigned) ecoff_ext.asym.index,
- jmptbl, cobol_main, weakext,
- symbol->name);
-
- if (ecoffsymbol (symbol)->fdr != NULL
- && ecoff_ext.asym.index != indexNil)
- {
- FDR *fdr;
- unsigned int indx;
- int bigendian;
- bfd_size_type sym_base;
- union aux_ext *aux_base;
-
- fdr = ecoffsymbol (symbol)->fdr;
- indx = ecoff_ext.asym.index;
-
- /* sym_base is used to map the fdr relative indices which
- appear in the file to the position number which we are
- using. */
- sym_base = fdr->isymBase;
- if (ecoffsymbol (symbol)->local)
- sym_base +=
- ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
-
- /* aux_base is the start of the aux entries for this file;
- asym.index is an offset from this. */
- aux_base = (ecoff_data (abfd)->debug_info.external_aux
- + fdr->iauxBase);
-
- /* The aux entries are stored in host byte order; the
- order is indicated by a bit in the fdr. */
- bigendian = fdr->fBigendian;
-
- /* This switch is basically from gcc/mips-tdump.c */
- switch (ecoff_ext.asym.st)
- {
- case stNil:
- case stLabel:
- break;
-
- case stFile:
- case stBlock:
- fprintf (file, "\n End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stEnd:
- if (ecoff_ext.asym.sc == scText
- || ecoff_ext.asym.sc == scInfo)
- fprintf (file, "\n First symbol: %ld",
- (long) (indx + sym_base));
- else
- fprintf (file, "\n First symbol: %ld",
- ((long)
- (AUX_GET_ISYM (bigendian,
- &aux_base[ecoff_ext.asym.index])
- + sym_base)));
- break;
-
- case stProc:
- case stStaticProc:
- if (ECOFF_IS_STAB (&ecoff_ext.asym))
- ;
- else if (ecoffsymbol (symbol)->local)
- fprintf (file, "\n End+1 symbol: %-7ld Type: %s",
- ((long)
- (AUX_GET_ISYM (bigendian,
- &aux_base[ecoff_ext.asym.index])
- + sym_base)),
- ecoff_type_to_string (abfd, fdr, indx + 1));
- else
- fprintf (file, "\n Local symbol: %ld",
- ((long) indx
- + (long) sym_base
- + (ecoff_data (abfd)
- ->debug_info.symbolic_header.iextMax)));
- break;
-
- case stStruct:
- fprintf (file, "\n struct; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stUnion:
- fprintf (file, "\n union; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- case stEnum:
- fprintf (file, "\n enum; End+1 symbol: %ld",
- (long) (indx + sym_base));
- break;
-
- default:
- if (! ECOFF_IS_STAB (&ecoff_ext.asym))
- fprintf (file, "\n Type: %s",
- ecoff_type_to_string (abfd, fdr, indx));
- break;
- }
- }
- }
- break;
- }
-}
-
-/* Read in the relocs for a section. */
-
-static boolean
-ecoff_slurp_reloc_table (abfd, section, symbols)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- arelent *internal_relocs;
- bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
- char *external_relocs;
- arelent *rptr;
- unsigned int i;
-
- if (section->relocation != (arelent *) NULL
- || section->reloc_count == 0
- || (section->flags & SEC_CONSTRUCTOR) != 0)
- return true;
-
- if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
- return false;
-
- internal_relocs = (arelent *) bfd_alloc (abfd,
- (sizeof (arelent)
- * section->reloc_count));
- external_reloc_size = backend->external_reloc_size;
- external_relocs_size = external_reloc_size * section->reloc_count;
- external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
- if (internal_relocs == (arelent *) NULL
- || external_relocs == (char *) NULL)
- return false;
- if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
- return false;
- if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
- != external_relocs_size)
- return false;
-
- for (i = 0, rptr = internal_relocs; i < section->reloc_count; i++, rptr++)
- {
- struct internal_reloc intern;
-
- (*backend->swap_reloc_in) (abfd,
- external_relocs + i * external_reloc_size,
- &intern);
-
- if (intern.r_extern)
- {
- /* r_symndx is an index into the external symbols. */
- BFD_ASSERT (intern.r_symndx >= 0
- && (intern.r_symndx
- < (ecoff_data (abfd)
- ->debug_info.symbolic_header.iextMax)));
- rptr->sym_ptr_ptr = symbols + intern.r_symndx;
- rptr->addend = 0;
- }
- else if (intern.r_symndx == RELOC_SECTION_NONE
- || intern.r_symndx == RELOC_SECTION_ABS)
- {
- rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rptr->addend = 0;
- }
- else
- {
- CONST char *sec_name;
- asection *sec;
-
- /* r_symndx is a section key. */
- switch (intern.r_symndx)
- {
- case RELOC_SECTION_TEXT: sec_name = ".text"; break;
- case RELOC_SECTION_RDATA: sec_name = ".rdata"; break;
- case RELOC_SECTION_DATA: sec_name = ".data"; break;
- case RELOC_SECTION_SDATA: sec_name = ".sdata"; break;
- case RELOC_SECTION_SBSS: sec_name = ".sbss"; break;
- case RELOC_SECTION_BSS: sec_name = ".bss"; break;
- case RELOC_SECTION_INIT: sec_name = ".init"; break;
- case RELOC_SECTION_LIT8: sec_name = ".lit8"; break;
- case RELOC_SECTION_LIT4: sec_name = ".lit4"; break;
- case RELOC_SECTION_XDATA: sec_name = ".xdata"; break;
- case RELOC_SECTION_PDATA: sec_name = ".pdata"; break;
- case RELOC_SECTION_FINI: sec_name = ".fini"; break;
- case RELOC_SECTION_LITA: sec_name = ".lita"; break;
- case RELOC_SECTION_RCONST: sec_name = ".rconst"; break;
- default: abort ();
- }
-
- sec = bfd_get_section_by_name (abfd, sec_name);
- if (sec == (asection *) NULL)
- abort ();
- rptr->sym_ptr_ptr = sec->symbol_ptr_ptr;
-
- rptr->addend = - bfd_get_section_vma (abfd, sec);
- }
-
- rptr->address = intern.r_vaddr - bfd_get_section_vma (abfd, section);
-
- /* Let the backend select the howto field and do any other
- required processing. */
- (*backend->adjust_reloc_in) (abfd, &intern, rptr);
- }
-
- bfd_release (abfd, external_relocs);
-
- section->relocation = internal_relocs;
-
- return true;
-}
-
-/* Get a canonical list of relocs. */
-
-long
-_bfd_ecoff_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- asection *section;
- arelent **relptr;
- asymbol **symbols;
-{
- unsigned int count;
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- arelent_chain *chain;
-
- /* This section has relocs made up by us, not the file, so take
- them out of their chain and place them into the data area
- provided. */
- for (count = 0, chain = section->constructor_chain;
- count < section->reloc_count;
- count++, chain = chain->next)
- *relptr++ = &chain->relent;
- }
- else
- {
- arelent *tblptr;
-
- if (ecoff_slurp_reloc_table (abfd, section, symbols) == false)
- return -1;
-
- tblptr = section->relocation;
-
- for (count = 0; count < section->reloc_count; count++)
- *relptr++ = tblptr++;
- }
-
- *relptr = (arelent *) NULL;
-
- return section->reloc_count;
-}
-
-/* Provided a BFD, a section and an offset into the section, calculate
- and return the name of the source file and the line nearest to the
- wanted location. */
-
-/*ARGSUSED*/
-boolean
-_bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset,
- filename_ptr, functionname_ptr, retline_ptr)
- bfd *abfd;
- asection *section;
- asymbol **ignore_symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *retline_ptr;
-{
- const struct ecoff_debug_swap * const debug_swap
- = &ecoff_backend (abfd)->debug_swap;
- struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
- struct ecoff_find_line *line_info;
-
- /* Make sure we have the FDR's. */
- if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, debug_info)
- || bfd_get_symcount (abfd) == 0)
- return false;
-
- if (ecoff_data (abfd)->find_line_info == NULL)
- {
- ecoff_data (abfd)->find_line_info =
- ((struct ecoff_find_line *)
- bfd_alloc (abfd, sizeof (struct ecoff_find_line)));
- if (ecoff_data (abfd)->find_line_info == NULL)
- return false;
- ecoff_data (abfd)->find_line_info->find_buffer = NULL;
- ecoff_data (abfd)->find_line_info->fdrtab_len = 0;
- ecoff_data (abfd)->find_line_info->fdrtab = NULL;
- }
- line_info = ecoff_data (abfd)->find_line_info;
-
- return _bfd_ecoff_locate_line (abfd, section, offset, debug_info,
- debug_swap, line_info, filename_ptr,
- functionname_ptr, retline_ptr);
-}
-
-/* Copy private BFD data. This is called by objcopy and strip. We
- use it to copy the ECOFF debugging information from one BFD to the
- other. It would be theoretically possible to represent the ECOFF
- debugging information in the symbol table. However, it would be a
- lot of work, and there would be little gain (gas, gdb, and ld
- already access the ECOFF debugging information via the
- ecoff_debug_info structure, and that structure would have to be
- retained in order to support ECOFF debugging in MIPS ELF).
-
- The debugging information for the ECOFF external symbols comes from
- the symbol table, so this function only handles the other debugging
- information. */
-
-boolean
-_bfd_ecoff_bfd_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- struct ecoff_debug_info *iinfo = &ecoff_data (ibfd)->debug_info;
- struct ecoff_debug_info *oinfo = &ecoff_data (obfd)->debug_info;
- register int i;
- asymbol **sym_ptr_ptr;
- size_t c;
- boolean local;
-
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses ECOFF
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_ecoff_flavour)
- return true;
-
- /* Copy the GP value and the register masks. */
- ecoff_data (obfd)->gp = ecoff_data (ibfd)->gp;
- ecoff_data (obfd)->gprmask = ecoff_data (ibfd)->gprmask;
- ecoff_data (obfd)->fprmask = ecoff_data (ibfd)->fprmask;
- for (i = 0; i < 3; i++)
- ecoff_data (obfd)->cprmask[i] = ecoff_data (ibfd)->cprmask[i];
-
- /* Copy the version stamp. */
- oinfo->symbolic_header.vstamp = iinfo->symbolic_header.vstamp;
-
- /* If there are no symbols, don't copy any debugging information. */
- c = bfd_get_symcount (obfd);
- sym_ptr_ptr = bfd_get_outsymbols (obfd);
- if (c == 0 || sym_ptr_ptr == (asymbol **) NULL)
- return true;
-
- /* See if there are any local symbols. */
- local = false;
- for (; c > 0; c--, sym_ptr_ptr++)
- {
- if (ecoffsymbol (*sym_ptr_ptr)->local)
- {
- local = true;
- break;
- }
- }
-
- if (local)
- {
- /* There are some local symbols. We just bring over all the
- debugging information. FIXME: This is not quite the right
- thing to do. If the user has asked us to discard all
- debugging information, then we are probably going to wind up
- keeping it because there will probably be some local symbol
- which objcopy did not discard. We should actually break
- apart the debugging information and only keep that which
- applies to the symbols we want to keep. */
- oinfo->symbolic_header.ilineMax = iinfo->symbolic_header.ilineMax;
- oinfo->symbolic_header.cbLine = iinfo->symbolic_header.cbLine;
- oinfo->line = iinfo->line;
-
- oinfo->symbolic_header.idnMax = iinfo->symbolic_header.idnMax;
- oinfo->external_dnr = iinfo->external_dnr;
-
- oinfo->symbolic_header.ipdMax = iinfo->symbolic_header.ipdMax;
- oinfo->external_pdr = iinfo->external_pdr;
-
- oinfo->symbolic_header.isymMax = iinfo->symbolic_header.isymMax;
- oinfo->external_sym = iinfo->external_sym;
-
- oinfo->symbolic_header.ioptMax = iinfo->symbolic_header.ioptMax;
- oinfo->external_opt = iinfo->external_opt;
-
- oinfo->symbolic_header.iauxMax = iinfo->symbolic_header.iauxMax;
- oinfo->external_aux = iinfo->external_aux;
-
- oinfo->symbolic_header.issMax = iinfo->symbolic_header.issMax;
- oinfo->ss = iinfo->ss;
-
- oinfo->symbolic_header.ifdMax = iinfo->symbolic_header.ifdMax;
- oinfo->external_fdr = iinfo->external_fdr;
-
- oinfo->symbolic_header.crfd = iinfo->symbolic_header.crfd;
- oinfo->external_rfd = iinfo->external_rfd;
- }
- else
- {
- /* We are discarding all the local symbol information. Look
- through the external symbols and remove all references to FDR
- or aux information. */
- c = bfd_get_symcount (obfd);
- sym_ptr_ptr = bfd_get_outsymbols (obfd);
- for (; c > 0; c--, sym_ptr_ptr++)
- {
- EXTR esym;
-
- (*(ecoff_backend (obfd)->debug_swap.swap_ext_in))
- (obfd, ecoffsymbol (*sym_ptr_ptr)->native, &esym);
- esym.ifd = ifdNil;
- esym.asym.index = indexNil;
- (*(ecoff_backend (obfd)->debug_swap.swap_ext_out))
- (obfd, &esym, ecoffsymbol (*sym_ptr_ptr)->native);
- }
- }
-
- return true;
-}
-
-/* Set the architecture. The supported architecture is stored in the
- backend pointer. We always set the architecture anyhow, since many
- callers ignore the return value. */
-
-boolean
-_bfd_ecoff_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- bfd_default_set_arch_mach (abfd, arch, machine);
- return arch == ecoff_backend (abfd)->arch;
-}
-
-/* Get the size of the section headers. */
-
-/*ARGSUSED*/
-int
-_bfd_ecoff_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- asection *current;
- int c;
- int ret;
-
- c = 0;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- ++c;
-
- ret = (bfd_coff_filhsz (abfd)
- + bfd_coff_aoutsz (abfd)
- + c * bfd_coff_scnhsz (abfd));
- return BFD_ALIGN (ret, 16);
-}
-
-/* Get the contents of a section. */
-
-boolean
-_bfd_ecoff_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- return _bfd_generic_get_section_contents (abfd, section, location,
- offset, count);
-}
-
-/* Sort sections by VMA, but put SEC_ALLOC sections first. This is
- called via qsort. */
-
-static int
-ecoff_sort_hdrs (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-{
- const asection *hdr1 = *(const asection **) arg1;
- const asection *hdr2 = *(const asection **) arg2;
-
- if ((hdr1->flags & SEC_ALLOC) != 0)
- {
- if ((hdr2->flags & SEC_ALLOC) == 0)
- return -1;
- }
- else
- {
- if ((hdr2->flags & SEC_ALLOC) != 0)
- return 1;
- }
- if (hdr1->vma < hdr2->vma)
- return -1;
- else if (hdr1->vma > hdr2->vma)
- return 1;
- else
- return 0;
-}
-
-/* Calculate the file position for each section, and set
- reloc_filepos. */
-
-static boolean
-ecoff_compute_section_file_positions (abfd)
- bfd *abfd;
-{
- file_ptr sofar;
- asection **sorted_hdrs;
- asection *current;
- unsigned int i;
- file_ptr old_sofar;
- boolean first_data, first_nonalloc;
- const bfd_vma round = ecoff_backend (abfd)->round;
-
- sofar = _bfd_ecoff_sizeof_headers (abfd, false);
-
- /* Sort the sections by VMA. */
- sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
- * sizeof (asection *));
- if (sorted_hdrs == NULL)
- return false;
- for (current = abfd->sections, i = 0;
- current != NULL;
- current = current->next, i++)
- sorted_hdrs[i] = current;
- BFD_ASSERT (i == abfd->section_count);
-
- qsort (sorted_hdrs, abfd->section_count, sizeof (asection *),
- ecoff_sort_hdrs);
-
- first_data = true;
- first_nonalloc = true;
- for (i = 0; i < abfd->section_count; i++)
- {
- unsigned int alignment_power;
-
- current = sorted_hdrs[i];
-
- /* For the Alpha ECOFF .pdata section the lnnoptr field is
- supposed to indicate the number of .pdata entries that are
- really in the section. Each entry is 8 bytes. We store this
- away in line_filepos before increasing the section size. */
- if (strcmp (current->name, _PDATA) != 0)
- alignment_power = current->alignment_power;
- else
- {
- current->line_filepos = current->_raw_size / 8;
- alignment_power = 4;
- }
-
- /* On Ultrix, the data sections in an executable file must be
- aligned to a page boundary within the file. This does not
- affect the section size, though. FIXME: Does this work for
- other platforms? It requires some modification for the
- Alpha, because .rdata on the Alpha goes with the text, not
- the data. */
- if ((abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0
- && ! first_data
- && (current->flags & SEC_CODE) == 0
- && (! ecoff_backend (abfd)->rdata_in_text
- || strcmp (current->name, _RDATA) != 0)
- && strcmp (current->name, _PDATA) != 0
- && strcmp (current->name, _RCONST) != 0)
- {
- sofar = (sofar + round - 1) &~ (round - 1);
- first_data = false;
- }
- else if (strcmp (current->name, _LIB) == 0)
- {
- /* On Irix 4, the location of contents of the .lib section
- from a shared library section is also rounded up to a
- page boundary. */
-
- sofar = (sofar + round - 1) &~ (round - 1);
- }
- else if (first_nonalloc
- && (current->flags & SEC_ALLOC) == 0
- && (abfd->flags & D_PAGED) != 0)
- {
- /* Skip up to the next page for an unallocated section, such
- as the .comment section on the Alpha. This leaves room
- for the .bss section. */
- first_nonalloc = false;
- sofar = (sofar + round - 1) &~ (round - 1);
- }
-
- /* Align the sections in the file to the same boundary on
- which they are aligned in virtual memory. */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << alignment_power);
-
- if ((abfd->flags & D_PAGED) != 0
- && (current->flags & SEC_ALLOC) != 0)
- sofar += (current->vma - sofar) % round;
-
- if ((current->flags & (SEC_HAS_CONTENTS | SEC_LOAD)) != 0)
- current->filepos = sofar;
-
- sofar += current->_raw_size;
-
- /* make sure that this section is of the right size too */
- old_sofar = sofar;
- sofar = BFD_ALIGN (sofar, 1 << alignment_power);
- current->_raw_size += sofar - old_sofar;
- }
-
- free (sorted_hdrs);
- sorted_hdrs = NULL;
-
- ecoff_data (abfd)->reloc_filepos = sofar;
-
- return true;
-}
-
-/* Determine the location of the relocs for all the sections in the
- output file, as well as the location of the symbolic debugging
- information. */
-
-static bfd_size_type
-ecoff_compute_reloc_file_positions (abfd)
- bfd *abfd;
-{
- const bfd_size_type external_reloc_size =
- ecoff_backend (abfd)->external_reloc_size;
- file_ptr reloc_base;
- bfd_size_type reloc_size;
- asection *current;
- file_ptr sym_base;
-
- if (! abfd->output_has_begun)
- {
- if (! ecoff_compute_section_file_positions (abfd))
- abort ();
- abfd->output_has_begun = true;
- }
-
- reloc_base = ecoff_data (abfd)->reloc_filepos;
-
- reloc_size = 0;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- {
- if (current->reloc_count == 0)
- current->rel_filepos = 0;
- else
- {
- bfd_size_type relsize;
-
- current->rel_filepos = reloc_base;
- relsize = current->reloc_count * external_reloc_size;
- reloc_size += relsize;
- reloc_base += relsize;
- }
- }
-
- sym_base = ecoff_data (abfd)->reloc_filepos + reloc_size;
-
- /* At least on Ultrix, the symbol table of an executable file must
- be aligned to a page boundary. FIXME: Is this true on other
- platforms? */
- if ((abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0)
- sym_base = ((sym_base + ecoff_backend (abfd)->round - 1)
- &~ (ecoff_backend (abfd)->round - 1));
-
- ecoff_data (abfd)->sym_filepos = sym_base;
-
- return reloc_size;
-}
-
-/* Set the contents of a section. */
-
-boolean
-_bfd_ecoff_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- /* This must be done first, because bfd_set_section_contents is
- going to set output_has_begun to true. */
- if (abfd->output_has_begun == false)
- {
- if (! ecoff_compute_section_file_positions (abfd))
- return false;
- }
-
- /* If this is a .lib section, bump the vma address so that it winds
- up being the number of .lib sections output. This is right for
- Irix 4. Ian Taylor <ian@cygnus.com>. */
- if (strcmp (section->name, _LIB) == 0)
- ++section->vma;
-
- if (count == 0)
- return true;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-/* Get the GP value for an ECOFF file. This is a hook used by
- nlmconv. */
-
-bfd_vma
-bfd_ecoff_get_gp_value (abfd)
- bfd *abfd;
-{
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
- }
-
- return ecoff_data (abfd)->gp;
-}
-
-/* Set the GP value for an ECOFF file. This is a hook used by the
- assembler. */
-
-boolean
-bfd_ecoff_set_gp_value (abfd, gp_value)
- bfd *abfd;
- bfd_vma gp_value;
-{
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- ecoff_data (abfd)->gp = gp_value;
-
- return true;
-}
-
-/* Set the register masks for an ECOFF file. This is a hook used by
- the assembler. */
-
-boolean
-bfd_ecoff_set_regmasks (abfd, gprmask, fprmask, cprmask)
- bfd *abfd;
- unsigned long gprmask;
- unsigned long fprmask;
- unsigned long *cprmask;
-{
- ecoff_data_type *tdata;
-
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- tdata = ecoff_data (abfd);
- tdata->gprmask = gprmask;
- tdata->fprmask = fprmask;
- if (cprmask != (unsigned long *) NULL)
- {
- register int i;
-
- for (i = 0; i < 3; i++)
- tdata->cprmask[i] = cprmask[i];
- }
-
- return true;
-}
-
-/* Get ECOFF EXTR information for an external symbol. This function
- is passed to bfd_ecoff_debug_externals. */
-
-static boolean
-ecoff_get_extr (sym, esym)
- asymbol *sym;
- EXTR *esym;
-{
- ecoff_symbol_type *ecoff_sym_ptr;
- bfd *input_bfd;
-
- if (bfd_asymbol_flavour (sym) != bfd_target_ecoff_flavour
- || ecoffsymbol (sym)->native == NULL)
- {
- /* Don't include debugging, local, or section symbols. */
- if ((sym->flags & BSF_DEBUGGING) != 0
- || (sym->flags & BSF_LOCAL) != 0
- || (sym->flags & BSF_SECTION_SYM) != 0)
- return false;
-
- esym->jmptbl = 0;
- esym->cobol_main = 0;
- esym->weakext = (sym->flags & BSF_WEAK) != 0;
- esym->reserved = 0;
- esym->ifd = ifdNil;
- /* FIXME: we can do better than this for st and sc. */
- esym->asym.st = stGlobal;
- esym->asym.sc = scAbs;
- esym->asym.reserved = 0;
- esym->asym.index = indexNil;
- return true;
- }
-
- ecoff_sym_ptr = ecoffsymbol (sym);
-
- if (ecoff_sym_ptr->local)
- return false;
-
- input_bfd = bfd_asymbol_bfd (sym);
- (*(ecoff_backend (input_bfd)->debug_swap.swap_ext_in))
- (input_bfd, ecoff_sym_ptr->native, esym);
-
- /* If the symbol was defined by the linker, then esym will be
- undefined but sym will not be. Get a better class for such a
- symbol. */
- if ((esym->asym.sc == scUndefined
- || esym->asym.sc == scSUndefined)
- && ! bfd_is_und_section (bfd_get_section (sym)))
- esym->asym.sc = scAbs;
-
- /* Adjust the FDR index for the symbol by that used for the input
- BFD. */
- if (esym->ifd != -1)
- {
- struct ecoff_debug_info *input_debug;
-
- input_debug = &ecoff_data (input_bfd)->debug_info;
- BFD_ASSERT (esym->ifd < input_debug->symbolic_header.ifdMax);
- if (input_debug->ifdmap != (RFDT *) NULL)
- esym->ifd = input_debug->ifdmap[esym->ifd];
- }
-
- return true;
-}
-
-/* Set the external symbol index. This routine is passed to
- bfd_ecoff_debug_externals. */
-
-static void
-ecoff_set_index (sym, indx)
- asymbol *sym;
- bfd_size_type indx;
-{
- ecoff_set_sym_index (sym, indx);
-}
-
-/* Write out an ECOFF file. */
-
-boolean
-_bfd_ecoff_write_object_contents (abfd)
- bfd *abfd;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_vma round = backend->round;
- const bfd_size_type filhsz = bfd_coff_filhsz (abfd);
- const bfd_size_type aoutsz = bfd_coff_aoutsz (abfd);
- const bfd_size_type scnhsz = bfd_coff_scnhsz (abfd);
- const bfd_size_type external_hdr_size
- = backend->debug_swap.external_hdr_size;
- const bfd_size_type external_reloc_size = backend->external_reloc_size;
- void (* const adjust_reloc_out) PARAMS ((bfd *,
- const arelent *,
- struct internal_reloc *))
- = backend->adjust_reloc_out;
- void (* const swap_reloc_out) PARAMS ((bfd *,
- const struct internal_reloc *,
- PTR))
- = backend->swap_reloc_out;
- struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
- HDRR * const symhdr = &debug->symbolic_header;
- asection *current;
- unsigned int count;
- bfd_size_type reloc_size;
- bfd_size_type text_size;
- bfd_vma text_start;
- boolean set_text_start;
- bfd_size_type data_size;
- bfd_vma data_start;
- boolean set_data_start;
- bfd_size_type bss_size;
- PTR buff = NULL;
- PTR reloc_buff = NULL;
- struct internal_filehdr internal_f;
- struct internal_aouthdr internal_a;
- int i;
-
- /* Determine where the sections and relocs will go in the output
- file. */
- reloc_size = ecoff_compute_reloc_file_positions (abfd);
-
- count = 1;
- for (current = abfd->sections;
- current != (asection *)NULL;
- current = current->next)
- {
- current->target_index = count;
- ++count;
- }
-
- if ((abfd->flags & D_PAGED) != 0)
- text_size = _bfd_ecoff_sizeof_headers (abfd, false);
- else
- text_size = 0;
- text_start = 0;
- set_text_start = false;
- data_size = 0;
- data_start = 0;
- set_data_start = false;
- bss_size = 0;
-
- /* Write section headers to the file. */
-
- /* Allocate buff big enough to hold a section header,
- file header, or a.out header. */
- {
- bfd_size_type siz;
- siz = scnhsz;
- if (siz < filhsz)
- siz = filhsz;
- if (siz < aoutsz)
- siz = aoutsz;
- buff = (PTR) bfd_malloc ((size_t) siz);
- if (buff == NULL)
- goto error_return;
- }
-
- internal_f.f_nscns = 0;
- if (bfd_seek (abfd, (file_ptr) (filhsz + aoutsz), SEEK_SET) != 0)
- goto error_return;
- for (current = abfd->sections;
- current != (asection *) NULL;
- current = current->next)
- {
- struct internal_scnhdr section;
- bfd_vma vma;
-
- ++internal_f.f_nscns;
-
- strncpy (section.s_name, current->name, sizeof section.s_name);
-
- /* This seems to be correct for Irix 4 shared libraries. */
- vma = bfd_get_section_vma (abfd, current);
- if (strcmp (current->name, _LIB) == 0)
- section.s_vaddr = 0;
- else
- section.s_vaddr = vma;
-
- section.s_paddr = current->lma;
- section.s_size = bfd_get_section_size_before_reloc (current);
-
- /* If this section is unloadable then the scnptr will be 0. */
- if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- section.s_scnptr = 0;
- else
- section.s_scnptr = current->filepos;
- section.s_relptr = current->rel_filepos;
-
- /* FIXME: the lnnoptr of the .sbss or .sdata section of an
- object file produced by the assembler is supposed to point to
- information about how much room is required by objects of
- various different sizes. I think this only matters if we
- want the linker to compute the best size to use, or
- something. I don't know what happens if the information is
- not present. */
- if (strcmp (current->name, _PDATA) != 0)
- section.s_lnnoptr = 0;
- else
- {
- /* The Alpha ECOFF .pdata section uses the lnnoptr field to
- hold the number of entries in the section (each entry is
- 8 bytes). We stored this in the line_filepos field in
- ecoff_compute_section_file_positions. */
- section.s_lnnoptr = current->line_filepos;
- }
-
- section.s_nreloc = current->reloc_count;
- section.s_nlnno = 0;
- section.s_flags = ecoff_sec_to_styp_flags (current->name,
- current->flags);
-
- if (bfd_coff_swap_scnhdr_out (abfd, (PTR) &section, buff) == 0
- || bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
- goto error_return;
-
- if ((section.s_flags & STYP_TEXT) != 0
- || ((section.s_flags & STYP_RDATA) != 0
- && backend->rdata_in_text)
- || section.s_flags == STYP_PDATA
- || (section.s_flags & STYP_DYNAMIC) != 0
- || (section.s_flags & STYP_LIBLIST) != 0
- || (section.s_flags & STYP_RELDYN) != 0
- || section.s_flags == STYP_CONFLIC
- || (section.s_flags & STYP_DYNSTR) != 0
- || (section.s_flags & STYP_DYNSYM) != 0
- || (section.s_flags & STYP_HASH) != 0
- || (section.s_flags & STYP_ECOFF_INIT) != 0
- || (section.s_flags & STYP_ECOFF_FINI) != 0
- || section.s_flags == STYP_RCONST)
- {
- text_size += bfd_get_section_size_before_reloc (current);
- if (! set_text_start || text_start > vma)
- {
- text_start = vma;
- set_text_start = true;
- }
- }
- else if ((section.s_flags & STYP_RDATA) != 0
- || (section.s_flags & STYP_DATA) != 0
- || (section.s_flags & STYP_LITA) != 0
- || (section.s_flags & STYP_LIT8) != 0
- || (section.s_flags & STYP_LIT4) != 0
- || (section.s_flags & STYP_SDATA) != 0
- || section.s_flags == STYP_XDATA
- || (section.s_flags & STYP_GOT) != 0)
- {
- data_size += bfd_get_section_size_before_reloc (current);
- if (! set_data_start || data_start > vma)
- {
- data_start = vma;
- set_data_start = true;
- }
- }
- else if ((section.s_flags & STYP_BSS) != 0
- || (section.s_flags & STYP_SBSS) != 0)
- bss_size += bfd_get_section_size_before_reloc (current);
- else if (section.s_flags == 0
- || (section.s_flags & STYP_ECOFF_LIB) != 0
- || section.s_flags == STYP_COMMENT)
- /* Do nothing */ ;
- else
- abort ();
- }
-
- /* Set up the file header. */
-
- internal_f.f_magic = ecoff_get_magic (abfd);
-
- /* We will NOT put a fucking timestamp in the header here. Every
- time you put it back, I will come in and take it out again. I'm
- sorry. This field does not belong here. We fill it with a 0 so
- it compares the same but is not a reasonable time. --
- gnu@cygnus.com. */
- internal_f.f_timdat = 0;
-
- if (bfd_get_symcount (abfd) != 0)
- {
- /* The ECOFF f_nsyms field is not actually the number of
- symbols, it's the size of symbolic information header. */
- internal_f.f_nsyms = external_hdr_size;
- internal_f.f_symptr = ecoff_data (abfd)->sym_filepos;
- }
- else
- {
- internal_f.f_nsyms = 0;
- internal_f.f_symptr = 0;
- }
-
- internal_f.f_opthdr = aoutsz;
-
- internal_f.f_flags = F_LNNO;
- if (reloc_size == 0)
- internal_f.f_flags |= F_RELFLG;
- if (bfd_get_symcount (abfd) == 0)
- internal_f.f_flags |= F_LSYMS;
- if (abfd->flags & EXEC_P)
- internal_f.f_flags |= F_EXEC;
-
- if (bfd_little_endian (abfd))
- internal_f.f_flags |= F_AR32WR;
- else
- internal_f.f_flags |= F_AR32W;
-
- /* Set up the ``optional'' header. */
- if ((abfd->flags & D_PAGED) != 0)
- internal_a.magic = ECOFF_AOUT_ZMAGIC;
- else
- internal_a.magic = ECOFF_AOUT_OMAGIC;
-
- /* FIXME: Is this really correct? */
- internal_a.vstamp = symhdr->vstamp;
-
- /* At least on Ultrix, these have to be rounded to page boundaries.
- FIXME: Is this true on other platforms? */
- if ((abfd->flags & D_PAGED) != 0)
- {
- internal_a.tsize = (text_size + round - 1) &~ (round - 1);
- internal_a.text_start = text_start &~ (round - 1);
- internal_a.dsize = (data_size + round - 1) &~ (round - 1);
- internal_a.data_start = data_start &~ (round - 1);
- }
- else
- {
- internal_a.tsize = text_size;
- internal_a.text_start = text_start;
- internal_a.dsize = data_size;
- internal_a.data_start = data_start;
- }
-
- /* On Ultrix, the initial portions of the .sbss and .bss segments
- are at the end of the data section. The bsize field in the
- optional header records how many bss bytes are required beyond
- those in the data section. The value is not rounded to a page
- boundary. */
- if (bss_size < internal_a.dsize - data_size)
- bss_size = 0;
- else
- bss_size -= internal_a.dsize - data_size;
- internal_a.bsize = bss_size;
- internal_a.bss_start = internal_a.data_start + internal_a.dsize;
-
- internal_a.entry = bfd_get_start_address (abfd);
-
- internal_a.gp_value = ecoff_data (abfd)->gp;
-
- internal_a.gprmask = ecoff_data (abfd)->gprmask;
- internal_a.fprmask = ecoff_data (abfd)->fprmask;
- for (i = 0; i < 4; i++)
- internal_a.cprmask[i] = ecoff_data (abfd)->cprmask[i];
-
- /* Let the backend adjust the headers if necessary. */
- if (backend->adjust_headers)
- {
- if (! (*backend->adjust_headers) (abfd, &internal_f, &internal_a))
- goto error_return;
- }
-
- /* Write out the file header and the optional header. */
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, buff);
- if (bfd_write (buff, 1, filhsz, abfd) != filhsz)
- goto error_return;
-
- bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, buff);
- if (bfd_write (buff, 1, aoutsz, abfd) != aoutsz)
- goto error_return;
-
- /* Build the external symbol information. This must be done before
- writing out the relocs so that we know the symbol indices. We
- don't do this if this BFD was created by the backend linker,
- since it will have already handled the symbols and relocs. */
- if (! ecoff_data (abfd)->linker)
- {
- symhdr->iextMax = 0;
- symhdr->issExtMax = 0;
- debug->external_ext = debug->external_ext_end = NULL;
- debug->ssext = debug->ssext_end = NULL;
- if (bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap,
- (((abfd->flags & EXEC_P) == 0)
- ? true : false),
- ecoff_get_extr, ecoff_set_index)
- == false)
- goto error_return;
-
- /* Write out the relocs. */
- for (current = abfd->sections;
- current != (asection *) NULL;
- current = current->next)
- {
- arelent **reloc_ptr_ptr;
- arelent **reloc_end;
- char *out_ptr;
-
- if (current->reloc_count == 0)
- continue;
-
- reloc_buff =
- bfd_alloc (abfd, current->reloc_count * external_reloc_size);
- if (reloc_buff == NULL)
- goto error_return;
-
- reloc_ptr_ptr = current->orelocation;
- reloc_end = reloc_ptr_ptr + current->reloc_count;
- out_ptr = (char *) reloc_buff;
- for (;
- reloc_ptr_ptr < reloc_end;
- reloc_ptr_ptr++, out_ptr += external_reloc_size)
- {
- arelent *reloc;
- asymbol *sym;
- struct internal_reloc in;
-
- memset ((PTR) &in, 0, sizeof in);
-
- reloc = *reloc_ptr_ptr;
- sym = *reloc->sym_ptr_ptr;
-
- in.r_vaddr = (reloc->address
- + bfd_get_section_vma (abfd, current));
- in.r_type = reloc->howto->type;
-
- if ((sym->flags & BSF_SECTION_SYM) == 0)
- {
- in.r_symndx = ecoff_get_sym_index (*reloc->sym_ptr_ptr);
- in.r_extern = 1;
- }
- else
- {
- CONST char *name;
-
- name = bfd_get_section_name (abfd, bfd_get_section (sym));
- if (strcmp (name, ".text") == 0)
- in.r_symndx = RELOC_SECTION_TEXT;
- else if (strcmp (name, ".rdata") == 0)
- in.r_symndx = RELOC_SECTION_RDATA;
- else if (strcmp (name, ".data") == 0)
- in.r_symndx = RELOC_SECTION_DATA;
- else if (strcmp (name, ".sdata") == 0)
- in.r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- in.r_symndx = RELOC_SECTION_SBSS;
- else if (strcmp (name, ".bss") == 0)
- in.r_symndx = RELOC_SECTION_BSS;
- else if (strcmp (name, ".init") == 0)
- in.r_symndx = RELOC_SECTION_INIT;
- else if (strcmp (name, ".lit8") == 0)
- in.r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- in.r_symndx = RELOC_SECTION_LIT4;
- else if (strcmp (name, ".xdata") == 0)
- in.r_symndx = RELOC_SECTION_XDATA;
- else if (strcmp (name, ".pdata") == 0)
- in.r_symndx = RELOC_SECTION_PDATA;
- else if (strcmp (name, ".fini") == 0)
- in.r_symndx = RELOC_SECTION_FINI;
- else if (strcmp (name, ".lita") == 0)
- in.r_symndx = RELOC_SECTION_LITA;
- else if (strcmp (name, "*ABS*") == 0)
- in.r_symndx = RELOC_SECTION_ABS;
- else if (strcmp (name, ".rconst") == 0)
- in.r_symndx = RELOC_SECTION_RCONST;
- else
- abort ();
- in.r_extern = 0;
- }
-
- (*adjust_reloc_out) (abfd, reloc, &in);
-
- (*swap_reloc_out) (abfd, &in, (PTR) out_ptr);
- }
-
- if (bfd_seek (abfd, current->rel_filepos, SEEK_SET) != 0)
- goto error_return;
- if (bfd_write (reloc_buff,
- external_reloc_size, current->reloc_count, abfd)
- != external_reloc_size * current->reloc_count)
- goto error_return;
- bfd_release (abfd, reloc_buff);
- reloc_buff = NULL;
- }
-
- /* Write out the symbolic debugging information. */
- if (bfd_get_symcount (abfd) > 0)
- {
- /* Write out the debugging information. */
- if (bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap,
- ecoff_data (abfd)->sym_filepos)
- == false)
- goto error_return;
- }
- }
-
- /* The .bss section of a demand paged executable must receive an
- entire page. If there are symbols, the symbols will start on the
- next page. If there are no symbols, we must fill out the page by
- hand. */
- if (bfd_get_symcount (abfd) == 0
- && (abfd->flags & EXEC_P) != 0
- && (abfd->flags & D_PAGED) != 0)
- {
- char c;
-
- if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
- SEEK_SET) != 0)
- goto error_return;
- if (bfd_read (&c, 1, 1, abfd) == 0)
- c = 0;
- if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
- SEEK_SET) != 0)
- goto error_return;
- if (bfd_write (&c, 1, 1, abfd) != 1)
- goto error_return;
- }
-
- if (reloc_buff != NULL)
- bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
- return true;
- error_return:
- if (reloc_buff != NULL)
- bfd_release (abfd, reloc_buff);
- if (buff != NULL)
- free (buff);
- return false;
-}
-
-/* Archive handling. ECOFF uses what appears to be a unique type of
- archive header (armap). The byte ordering of the armap and the
- contents are encoded in the name of the armap itself. At least for
- now, we only support archives with the same byte ordering in the
- armap and the contents.
-
- The first four bytes in the armap are the number of symbol
- definitions. This is always a power of two.
-
- This is followed by the symbol definitions. Each symbol definition
- occupies 8 bytes. The first four bytes are the offset from the
- start of the armap strings to the null-terminated string naming
- this symbol. The second four bytes are the file offset to the
- archive member which defines this symbol. If the second four bytes
- are 0, then this is not actually a symbol definition, and it should
- be ignored.
-
- The symbols are hashed into the armap with a closed hashing scheme.
- See the functions below for the details of the algorithm.
-
- After the symbol definitions comes four bytes holding the size of
- the string table, followed by the string table itself. */
-
-/* The name of an archive headers looks like this:
- __________E[BL]E[BL]_ (with a trailing space).
- The trailing space is changed to an X if the archive is changed to
- indicate that the armap is out of date.
-
- The Alpha seems to use ________64E[BL]E[BL]_. */
-
-#define ARMAP_BIG_ENDIAN 'B'
-#define ARMAP_LITTLE_ENDIAN 'L'
-#define ARMAP_MARKER 'E'
-#define ARMAP_START_LENGTH 10
-#define ARMAP_HEADER_MARKER_INDEX 10
-#define ARMAP_HEADER_ENDIAN_INDEX 11
-#define ARMAP_OBJECT_MARKER_INDEX 12
-#define ARMAP_OBJECT_ENDIAN_INDEX 13
-#define ARMAP_END_INDEX 14
-#define ARMAP_END "_ "
-
-/* This is a magic number used in the hashing algorithm. */
-#define ARMAP_HASH_MAGIC 0x9dd68ab5
-
-/* This returns the hash value to use for a string. It also sets
- *REHASH to the rehash adjustment if the first slot is taken. SIZE
- is the number of entries in the hash table, and HLOG is the log
- base 2 of SIZE. */
-
-static unsigned int
-ecoff_armap_hash (s, rehash, size, hlog)
- CONST char *s;
- unsigned int *rehash;
- unsigned int size;
- unsigned int hlog;
-{
- unsigned int hash;
-
- hash = *s++;
- while (*s != '\0')
- hash = ((hash >> 27) | (hash << 5)) + *s++;
- hash *= ARMAP_HASH_MAGIC;
- *rehash = (hash & (size - 1)) | 1;
- return hash >> (32 - hlog);
-}
-
-/* Read in the armap. */
-
-boolean
-_bfd_ecoff_slurp_armap (abfd)
- bfd *abfd;
-{
- char nextname[17];
- unsigned int i;
- struct areltdata *mapdata;
- bfd_size_type parsed_size;
- char *raw_armap;
- struct artdata *ardata;
- unsigned int count;
- char *raw_ptr;
- struct symdef *symdef_ptr;
- char *stringbase;
-
- /* Get the name of the first element. */
- i = bfd_read ((PTR) nextname, 1, 16, abfd);
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
- return false;
-
- /* Irix 4.0.5F apparently can use either an ECOFF armap or a
- standard COFF armap. We could move the ECOFF armap stuff into
- bfd_slurp_armap, but that seems inappropriate since no other
- target uses this format. Instead, we check directly for a COFF
- armap. */
- if (strncmp (nextname, "/ ", 16) == 0)
- return bfd_slurp_armap (abfd);
-
- /* See if the first element is an armap. */
- if (strncmp (nextname, ecoff_backend (abfd)->armap_start,
- ARMAP_START_LENGTH) != 0
- || nextname[ARMAP_HEADER_MARKER_INDEX] != ARMAP_MARKER
- || (nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
- && nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
- || nextname[ARMAP_OBJECT_MARKER_INDEX] != ARMAP_MARKER
- || (nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
- && nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
- || strncmp (nextname + ARMAP_END_INDEX,
- ARMAP_END, sizeof ARMAP_END - 1) != 0)
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- /* Make sure we have the right byte ordering. */
- if (((nextname[ARMAP_HEADER_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
- ^ (bfd_header_big_endian (abfd)))
- || ((nextname[ARMAP_OBJECT_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
- ^ (bfd_big_endian (abfd))))
- {
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- /* Read in the armap. */
- ardata = bfd_ardata (abfd);
- mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
- if (mapdata == (struct areltdata *) NULL)
- return false;
- parsed_size = mapdata->parsed_size;
- bfd_release (abfd, (PTR) mapdata);
-
- raw_armap = (char *) bfd_alloc (abfd, parsed_size);
- if (raw_armap == (char *) NULL)
- return false;
-
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- bfd_release (abfd, (PTR) raw_armap);
- return false;
- }
-
- ardata->tdata = (PTR) raw_armap;
-
- count = bfd_h_get_32 (abfd, (PTR) raw_armap);
-
- ardata->symdef_count = 0;
- ardata->cache = (struct ar_cache *) NULL;
-
- /* This code used to overlay the symdefs over the raw archive data,
- but that doesn't work on a 64 bit host. */
-
- stringbase = raw_armap + count * 8 + 8;
-
-#ifdef CHECK_ARMAP_HASH
- {
- unsigned int hlog;
-
- /* Double check that I have the hashing algorithm right by making
- sure that every symbol can be looked up successfully. */
- hlog = 0;
- for (i = 1; i < count; i <<= 1)
- hlog++;
- BFD_ASSERT (i == count);
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- {
- unsigned int name_offset, file_offset;
- unsigned int hash, rehash, srch;
-
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
- if (file_offset == 0)
- continue;
- hash = ecoff_armap_hash (stringbase + name_offset, &rehash, count,
- hlog);
- if (hash == i)
- continue;
-
- /* See if we can rehash to this location. */
- for (srch = (hash + rehash) & (count - 1);
- srch != hash && srch != i;
- srch = (srch + rehash) & (count - 1))
- BFD_ASSERT (bfd_h_get_32 (abfd, (PTR) (raw_armap + 8 + srch * 8))
- != 0);
- BFD_ASSERT (srch == i);
- }
- }
-
-#endif /* CHECK_ARMAP_HASH */
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- if (bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4)) != 0)
- ++ardata->symdef_count;
-
- symdef_ptr = ((struct symdef *)
- bfd_alloc (abfd,
- ardata->symdef_count * sizeof (struct symdef)));
- if (!symdef_ptr)
- return false;
-
- ardata->symdefs = (carsym *) symdef_ptr;
-
- raw_ptr = raw_armap + 4;
- for (i = 0; i < count; i++, raw_ptr += 8)
- {
- unsigned int name_offset, file_offset;
-
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
- if (file_offset == 0)
- continue;
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
- symdef_ptr->s.name = stringbase + name_offset;
- symdef_ptr->file_offset = file_offset;
- ++symdef_ptr;
- }
-
- ardata->first_file_filepos = bfd_tell (abfd);
- /* Pad to an even boundary. */
- ardata->first_file_filepos += ardata->first_file_filepos % 2;
-
- bfd_has_map (abfd) = true;
-
- return true;
-}
-
-/* Write out an armap. */
-
-boolean
-_bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx)
- bfd *abfd;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- unsigned int hashsize, hashlog;
- unsigned int symdefsize;
- int padit;
- unsigned int stringsize;
- unsigned int mapsize;
- file_ptr firstreal;
- struct ar_hdr hdr;
- struct stat statbuf;
- unsigned int i;
- bfd_byte temp[4];
- bfd_byte *hashtable;
- bfd *current;
- bfd *last_elt;
-
- /* Ultrix appears to use as a hash table size the least power of two
- greater than twice the number of entries. */
- for (hashlog = 0; (1 << hashlog) <= 2 * orl_count; hashlog++)
- ;
- hashsize = 1 << hashlog;
-
- symdefsize = hashsize * 8;
- padit = stridx % 2;
- stringsize = stridx + padit;
-
- /* Include 8 bytes to store symdefsize and stringsize in output. */
- mapsize = symdefsize + stringsize + 8;
-
- firstreal = SARMAG + sizeof (struct ar_hdr) + mapsize + elength;
-
- memset ((PTR) &hdr, 0, sizeof hdr);
-
- /* Work out the ECOFF armap name. */
- strcpy (hdr.ar_name, ecoff_backend (abfd)->armap_start);
- hdr.ar_name[ARMAP_HEADER_MARKER_INDEX] = ARMAP_MARKER;
- hdr.ar_name[ARMAP_HEADER_ENDIAN_INDEX] =
- (bfd_header_big_endian (abfd)
- ? ARMAP_BIG_ENDIAN
- : ARMAP_LITTLE_ENDIAN);
- hdr.ar_name[ARMAP_OBJECT_MARKER_INDEX] = ARMAP_MARKER;
- hdr.ar_name[ARMAP_OBJECT_ENDIAN_INDEX] =
- bfd_big_endian (abfd) ? ARMAP_BIG_ENDIAN : ARMAP_LITTLE_ENDIAN;
- memcpy (hdr.ar_name + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1);
-
- /* Write the timestamp of the archive header to be just a little bit
- later than the timestamp of the file, otherwise the linker will
- complain that the index is out of date. Actually, the Ultrix
- linker just checks the archive name; the GNU linker may check the
- date. */
- stat (abfd->filename, &statbuf);
- sprintf (hdr.ar_date, "%ld", (long) (statbuf.st_mtime + 60));
-
- /* The DECstation uses zeroes for the uid, gid and mode of the
- armap. */
- hdr.ar_uid[0] = '0';
- hdr.ar_gid[0] = '0';
- hdr.ar_mode[0] = '0';
-
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
-
- hdr.ar_fmag[0] = '`';
- hdr.ar_fmag[1] = '\012';
-
- /* Turn all null bytes in the header into spaces. */
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *)(&hdr))[i] == '\0')
- (((char *)(&hdr))[i]) = ' ';
-
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- return false;
-
- bfd_h_put_32 (abfd, (bfd_vma) hashsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
- return false;
-
- hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
- if (!hashtable)
- return false;
-
- current = abfd->archive_head;
- last_elt = current;
- for (i = 0; i < orl_count; i++)
- {
- unsigned int hash, rehash;
-
- /* Advance firstreal to the file position of this archive
- element. */
- if (((bfd *) map[i].pos) != last_elt)
- {
- do
- {
- firstreal += arelt_size (current) + sizeof (struct ar_hdr);
- firstreal += firstreal % 2;
- current = current->next;
- }
- while (current != (bfd *) map[i].pos);
- }
-
- last_elt = current;
-
- hash = ecoff_armap_hash (*map[i].name, &rehash, hashsize, hashlog);
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (hash * 8) + 4)) != 0)
- {
- unsigned int srch;
-
- /* The desired slot is already taken. */
- for (srch = (hash + rehash) & (hashsize - 1);
- srch != hash;
- srch = (srch + rehash) & (hashsize - 1))
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (srch * 8) + 4)) == 0)
- break;
-
- BFD_ASSERT (srch != hash);
-
- hash = srch;
- }
-
- bfd_h_put_32 (abfd, (bfd_vma) map[i].namidx,
- (PTR) (hashtable + hash * 8));
- bfd_h_put_32 (abfd, (bfd_vma) firstreal,
- (PTR) (hashtable + hash * 8 + 4));
- }
-
- if (bfd_write ((PTR) hashtable, 1, symdefsize, abfd) != symdefsize)
- return false;
-
- bfd_release (abfd, hashtable);
-
- /* Now write the strings. */
- bfd_h_put_32 (abfd, (bfd_vma) stringsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
- return false;
- for (i = 0; i < orl_count; i++)
- {
- bfd_size_type len;
-
- len = strlen (*map[i].name) + 1;
- if (bfd_write ((PTR) (*map[i].name), 1, len, abfd) != len)
- return false;
- }
-
- /* The spec sez this should be a newline. But in order to be
- bug-compatible for DECstation ar we use a null. */
- if (padit)
- {
- if (bfd_write ("", 1, 1, abfd) != 1)
- return false;
- }
-
- return true;
-}
-
-/* See whether this BFD is an archive. If it is, read in the armap
- and the extended name table. */
-
-const bfd_target *
-_bfd_ecoff_archive_p (abfd)
- bfd *abfd;
-{
- char armag[SARMAG + 1];
-
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG
- || strncmp (armag, ARMAG, SARMAG) != 0)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return (const bfd_target *) NULL;
- }
-
- /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
- involves a cast, we can't do it as the left operand of
- assignment. */
- abfd->tdata.aout_ar_data =
- (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
-
- if (bfd_ardata (abfd) == (struct artdata *) NULL)
- return (const bfd_target *) NULL;
-
- bfd_ardata (abfd)->first_file_filepos = SARMAG;
- bfd_ardata (abfd)->cache = NULL;
- bfd_ardata (abfd)->archive_head = NULL;
- bfd_ardata (abfd)->symdefs = NULL;
- bfd_ardata (abfd)->extended_names = NULL;
- bfd_ardata (abfd)->tdata = NULL;
-
- if (_bfd_ecoff_slurp_armap (abfd) == false
- || _bfd_ecoff_slurp_extended_name_table (abfd) == false)
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return (const bfd_target *) NULL;
- }
-
- return abfd->xvec;
-}
-
-/* ECOFF linker code. */
-
-static struct bfd_hash_entry *ecoff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string));
-static boolean ecoff_link_add_archive_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ecoff_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean ecoff_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ecoff_link_add_externals
- PARAMS ((bfd *, struct bfd_link_info *, PTR, char *));
-
-/* Routine to create an entry in an ECOFF link hash table. */
-
-static struct bfd_hash_entry *
-ecoff_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct ecoff_link_hash_entry *ret = (struct ecoff_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct ecoff_link_hash_entry *) NULL)
- ret = ((struct ecoff_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
- if (ret == (struct ecoff_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct ecoff_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
-
- if (ret)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->abfd = NULL;
- ret->written = 0;
- ret->small = 0;
- }
- memset ((PTR) &ret->esym, 0, sizeof ret->esym);
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create an ECOFF link hash table. */
-
-struct bfd_link_hash_table *
-_bfd_ecoff_bfd_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct ecoff_link_hash_table *ret;
-
- ret = ((struct ecoff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
- if (ret == NULL)
- return NULL;
- if (! _bfd_link_hash_table_init (&ret->root, abfd,
- ecoff_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Look up an entry in an ECOFF link hash table. */
-
-#define ecoff_link_hash_lookup(table, string, create, copy, follow) \
- ((struct ecoff_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an ECOFF link hash table. */
-
-#define ecoff_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the ECOFF link hash table from the info structure. This is
- just a cast. */
-
-#define ecoff_hash_table(p) ((struct ecoff_link_hash_table *) ((p)->hash))
-
-/* Given an ECOFF BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-_bfd_ecoff_bfd_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return ecoff_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return ecoff_link_add_archive_symbols (abfd, info);
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add the symbols from an archive file to the global hash table.
- This looks through the undefined symbols, looks each one up in the
- archive hash table, and adds any associated object file. We do not
- use _bfd_generic_link_add_archive_symbols because ECOFF archives
- already have a hash table, so there is no reason to construct
- another one. */
-
-static boolean
-ecoff_link_add_archive_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- const bfd_byte *raw_armap;
- struct bfd_link_hash_entry **pundef;
- unsigned int armap_count;
- unsigned int armap_log;
- unsigned int i;
- const bfd_byte *hashtable;
- const char *stringbase;
-
- if (! bfd_has_map (abfd))
- {
- /* An empty archive is a special case. */
- if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
- return true;
- bfd_set_error (bfd_error_no_armap);
- return false;
- }
-
- /* If we don't have any raw data for this archive, as can happen on
- Irix 4.0.5F, we call the generic routine.
- FIXME: We should be more clever about this, since someday tdata
- may get to something for a generic archive. */
- raw_armap = (const bfd_byte *) bfd_ardata (abfd)->tdata;
- if (raw_armap == (bfd_byte *) NULL)
- return (_bfd_generic_link_add_archive_symbols
- (abfd, info, ecoff_link_check_archive_element));
-
- armap_count = bfd_h_get_32 (abfd, raw_armap);
-
- armap_log = 0;
- for (i = 1; i < armap_count; i <<= 1)
- armap_log++;
- BFD_ASSERT (i == armap_count);
-
- hashtable = raw_armap + 4;
- stringbase = (const char *) raw_armap + armap_count * 8 + 8;
-
- /* Look through the list of undefined symbols. */
- pundef = &info->hash->undefs;
- while (*pundef != (struct bfd_link_hash_entry *) NULL)
- {
- struct bfd_link_hash_entry *h;
- unsigned int hash, rehash;
- unsigned int file_offset;
- const char *name;
- bfd *element;
-
- h = *pundef;
-
- /* When a symbol is defined, it is not necessarily removed from
- the list. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- {
- /* Remove this entry from the list, for general cleanliness
- and because we are going to look through the list again
- if we search any more libraries. We can't remove the
- entry if it is the tail, because that would lose any
- entries we add to the list later on. */
- if (*pundef != info->hash->undefs_tail)
- *pundef = (*pundef)->next;
- else
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Native ECOFF linkers do not pull in archive elements merely
- to satisfy common definitions, so neither do we. We leave
- them on the list, though, in case we are linking against some
- other object format. */
- if (h->type != bfd_link_hash_undefined)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look for this symbol in the archive hash table. */
- hash = ecoff_armap_hash (h->root.string, &rehash, armap_count,
- armap_log);
-
- file_offset = bfd_h_get_32 (abfd, hashtable + (hash * 8) + 4);
- if (file_offset == 0)
- {
- /* Nothing in this slot. */
- pundef = &(*pundef)->next;
- continue;
- }
-
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (hash * 8));
- if (name[0] != h->root.string[0]
- || strcmp (name, h->root.string) != 0)
- {
- unsigned int srch;
- boolean found;
-
- /* That was the wrong symbol. Try rehashing. */
- found = false;
- for (srch = (hash + rehash) & (armap_count - 1);
- srch != hash;
- srch = (srch + rehash) & (armap_count - 1))
- {
- file_offset = bfd_h_get_32 (abfd, hashtable + (srch * 8) + 4);
- if (file_offset == 0)
- break;
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (srch * 8));
- if (name[0] == h->root.string[0]
- && strcmp (name, h->root.string) == 0)
- {
- found = true;
- break;
- }
- }
-
- if (! found)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- hash = srch;
- }
-
- element = (*backend->get_elt_at_filepos) (abfd, file_offset);
- if (element == (bfd *) NULL)
- return false;
-
- if (! bfd_check_format (element, bfd_object))
- return false;
-
- /* Unlike the generic linker, we know that this element provides
- a definition for an undefined symbol and we know that we want
- to include it. We don't need to check anything. */
- if (! (*info->callbacks->add_archive_element) (info, element, name))
- return false;
- if (! ecoff_link_add_object_symbols (element, info))
- return false;
-
- pundef = &(*pundef)->next;
- }
-
- return true;
-}
-
-/* This is called if we used _bfd_generic_link_add_archive_symbols
- because we were not dealing with an ECOFF archive. */
-
-static boolean
-ecoff_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- HDRR *symhdr;
- bfd_size_type external_ext_size;
- PTR external_ext = NULL;
- size_t esize;
- char *ssext = NULL;
- char *ext_ptr;
- char *ext_end;
-
- *pneeded = false;
-
- if (! ecoff_slurp_symbolic_header (abfd))
- goto error_return;
-
- /* If there are no symbols, we don't want it. */
- if (bfd_get_symcount (abfd) == 0)
- goto successful_return;
-
- symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
-
- /* Read in the external symbols and external strings. */
- external_ext_size = backend->debug_swap.external_ext_size;
- esize = symhdr->iextMax * external_ext_size;
- external_ext = (PTR) bfd_malloc (esize);
- if (external_ext == NULL && esize != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
- goto error_return;
-
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
- if (ssext == NULL && symhdr->issExtMax != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd) !=
- (bfd_size_type) symhdr->issExtMax))
- goto error_return;
-
- /* Look through the external symbols to see if they define some
- symbol that is currently undefined. */
- ext_ptr = (char *) external_ext;
- ext_end = ext_ptr + esize;
- for (; ext_ptr < ext_end; ext_ptr += external_ext_size)
- {
- EXTR esym;
- boolean def;
- const char *name;
- struct bfd_link_hash_entry *h;
-
- (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
-
- /* See if this symbol defines something. */
- if (esym.asym.st != stGlobal
- && esym.asym.st != stLabel
- && esym.asym.st != stProc)
- continue;
-
- switch (esym.asym.sc)
- {
- case scText:
- case scData:
- case scBss:
- case scAbs:
- case scSData:
- case scSBss:
- case scRData:
- case scCommon:
- case scSCommon:
- case scInit:
- case scFini:
- case scRConst:
- def = true;
- break;
- default:
- def = false;
- break;
- }
-
- if (! def)
- continue;
-
- name = ssext + esym.asym.iss;
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* Unlike the generic linker, we do not pull in elements because
- of common symbols. */
- if (h == (struct bfd_link_hash_entry *) NULL
- || h->type != bfd_link_hash_undefined)
- continue;
-
- /* Include this element. */
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- goto error_return;
- if (! ecoff_link_add_externals (abfd, info, external_ext, ssext))
- goto error_return;
-
- *pneeded = true;
- goto successful_return;
- }
-
- successful_return:
- if (external_ext != NULL)
- free (external_ext);
- if (ssext != NULL)
- free (ssext);
- return true;
- error_return:
- if (external_ext != NULL)
- free (external_ext);
- if (ssext != NULL)
- free (ssext);
- return false;
-}
-
-/* Add symbols from an ECOFF object file to the global linker hash
- table. */
-
-static boolean
-ecoff_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- HDRR *symhdr;
- bfd_size_type external_ext_size;
- PTR external_ext = NULL;
- size_t esize;
- char *ssext = NULL;
- boolean result;
-
- if (! ecoff_slurp_symbolic_header (abfd))
- return false;
-
- /* If there are no symbols, we don't want it. */
- if (bfd_get_symcount (abfd) == 0)
- return true;
-
- symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
-
- /* Read in the external symbols and external strings. */
- external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size;
- esize = symhdr->iextMax * external_ext_size;
- external_ext = (PTR) bfd_malloc (esize);
- if (external_ext == NULL && esize != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
- goto error_return;
-
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
- if (ssext == NULL && symhdr->issExtMax != 0)
- goto error_return;
-
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd)
- != (bfd_size_type) symhdr->issExtMax))
- goto error_return;
-
- result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
-
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
- return result;
-
- error_return:
- if (ssext != NULL)
- free (ssext);
- if (external_ext != NULL)
- free (external_ext);
- return false;
-}
-
-/* Add the external symbols of an object file to the global linker
- hash table. The external symbols and strings we are passed are
- just allocated on the stack, and will be discarded. We must
- explicitly save any information we may need later on in the link.
- We do not want to read the external symbol information again. */
-
-static boolean
-ecoff_link_add_externals (abfd, info, external_ext, ssext)
- bfd *abfd;
- struct bfd_link_info *info;
- PTR external_ext;
- char *ssext;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
- = backend->debug_swap.swap_ext_in;
- bfd_size_type external_ext_size = backend->debug_swap.external_ext_size;
- unsigned long ext_count;
- struct ecoff_link_hash_entry **sym_hash;
- char *ext_ptr;
- char *ext_end;
-
- ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
-
- sym_hash = ((struct ecoff_link_hash_entry **)
- bfd_alloc (abfd,
- ext_count * sizeof (struct bfd_link_hash_entry *)));
- if (!sym_hash)
- return false;
- ecoff_data (abfd)->sym_hashes = sym_hash;
-
- ext_ptr = (char *) external_ext;
- ext_end = ext_ptr + ext_count * external_ext_size;
- for (; ext_ptr < ext_end; ext_ptr += external_ext_size, sym_hash++)
- {
- EXTR esym;
- boolean skip;
- bfd_vma value;
- asection *section;
- const char *name;
- struct ecoff_link_hash_entry *h;
-
- *sym_hash = NULL;
-
- (*swap_ext_in) (abfd, (PTR) ext_ptr, &esym);
-
- /* Skip debugging symbols. */
- skip = false;
- switch (esym.asym.st)
- {
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- break;
- default:
- skip = true;
- break;
- }
-
- if (skip)
- continue;
-
- /* Get the information for this symbol. */
- value = esym.asym.value;
- switch (esym.asym.sc)
- {
- default:
- case scNil:
- case scRegister:
- case scCdbLocal:
- case scBits:
- case scCdbSystem:
- case scRegImage:
- case scInfo:
- case scUserStruct:
- case scVar:
- case scVarRegister:
- case scVariant:
- case scBasedVar:
- case scXData:
- case scPData:
- section = NULL;
- break;
- case scText:
- section = bfd_make_section_old_way (abfd, ".text");
- value -= section->vma;
- break;
- case scData:
- section = bfd_make_section_old_way (abfd, ".data");
- value -= section->vma;
- break;
- case scBss:
- section = bfd_make_section_old_way (abfd, ".bss");
- value -= section->vma;
- break;
- case scAbs:
- section = bfd_abs_section_ptr;
- break;
- case scUndefined:
- section = bfd_und_section_ptr;
- break;
- case scSData:
- section = bfd_make_section_old_way (abfd, ".sdata");
- value -= section->vma;
- break;
- case scSBss:
- section = bfd_make_section_old_way (abfd, ".sbss");
- value -= section->vma;
- break;
- case scRData:
- section = bfd_make_section_old_way (abfd, ".rdata");
- value -= section->vma;
- break;
- case scCommon:
- if (value > ecoff_data (abfd)->gp_size)
- {
- section = bfd_com_section_ptr;
- break;
- }
- /* Fall through. */
- case scSCommon:
- if (ecoff_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- ecoff_scom_section.name = SCOMMON;
- ecoff_scom_section.flags = SEC_IS_COMMON;
- ecoff_scom_section.output_section = &ecoff_scom_section;
- ecoff_scom_section.symbol = &ecoff_scom_symbol;
- ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
- ecoff_scom_symbol.name = SCOMMON;
- ecoff_scom_symbol.flags = BSF_SECTION_SYM;
- ecoff_scom_symbol.section = &ecoff_scom_section;
- ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
- }
- section = &ecoff_scom_section;
- break;
- case scSUndefined:
- section = bfd_und_section_ptr;
- break;
- case scInit:
- section = bfd_make_section_old_way (abfd, ".init");
- value -= section->vma;
- break;
- case scFini:
- section = bfd_make_section_old_way (abfd, ".fini");
- value -= section->vma;
- break;
- case scRConst:
- section = bfd_make_section_old_way (abfd, ".rconst");
- value -= section->vma;
- break;
- }
-
- if (section == (asection *) NULL)
- continue;
-
- name = ssext + esym.asym.iss;
-
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name,
- esym.weakext ? BSF_WEAK : BSF_GLOBAL,
- section, value, (const char *) NULL, true, true,
- (struct bfd_link_hash_entry **) &h)))
- return false;
-
- *sym_hash = h;
-
- /* If we are building an ECOFF hash table, save the external
- symbol information. */
- if (info->hash->creator->flavour == bfd_get_flavour (abfd))
- {
- if (h->abfd == (bfd *) NULL
- || (! bfd_is_und_section (section)
- && (! bfd_is_com_section (section)
- || (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak))))
- {
- h->abfd = abfd;
- h->esym = esym;
- }
-
- /* Remember whether this symbol was small undefined. */
- if (esym.asym.sc == scSUndefined)
- h->small = 1;
-
- /* If this symbol was ever small undefined, it needs to wind
- up in a GP relative section. We can't control the
- section of a defined symbol, but we can control the
- section of a common symbol. This case is actually needed
- on Ultrix 4.2 to handle the symbol cred in -lckrb. */
- if (h->small
- && h->root.type == bfd_link_hash_common
- && strcmp (h->root.u.c.p->section->name, SCOMMON) != 0)
- {
- h->root.u.c.p->section = bfd_make_section_old_way (abfd,
- SCOMMON);
- h->root.u.c.p->section->flags = SEC_ALLOC;
- if (h->esym.asym.sc == scCommon)
- h->esym.asym.sc = scSCommon;
- }
- }
- }
-
- return true;
-}
-
-/* ECOFF final link routines. */
-
-static boolean ecoff_final_link_debug_accumulate
- PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
- PTR handle));
-static boolean ecoff_link_write_external
- PARAMS ((struct ecoff_link_hash_entry *, PTR));
-static boolean ecoff_indirect_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-static boolean ecoff_reloc_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Structure used to pass information to ecoff_link_write_external. */
-
-struct extsym_info
-{
- bfd *abfd;
- struct bfd_link_info *info;
-};
-
-/* ECOFF final link routine. This looks through all the input BFDs
- and gathers together all the debugging information, and then
- processes all the link order information. This may cause it to
- close and reopen some input BFDs; I'll see how bad this is. */
-
-boolean
-_bfd_ecoff_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
- struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
- HDRR *symhdr;
- PTR handle;
- register bfd *input_bfd;
- asection *o;
- struct bfd_link_order *p;
- struct extsym_info einfo;
-
- /* We accumulate the debugging information counts in the symbolic
- header. */
- symhdr = &debug->symbolic_header;
- symhdr->vstamp = 0;
- symhdr->ilineMax = 0;
- symhdr->cbLine = 0;
- symhdr->idnMax = 0;
- symhdr->ipdMax = 0;
- symhdr->isymMax = 0;
- symhdr->ioptMax = 0;
- symhdr->iauxMax = 0;
- symhdr->issMax = 0;
- symhdr->issExtMax = 0;
- symhdr->ifdMax = 0;
- symhdr->crfd = 0;
- symhdr->iextMax = 0;
-
- /* We accumulate the debugging information itself in the debug_info
- structure. */
- debug->line = NULL;
- debug->external_dnr = NULL;
- debug->external_pdr = NULL;
- debug->external_sym = NULL;
- debug->external_opt = NULL;
- debug->external_aux = NULL;
- debug->ss = NULL;
- debug->ssext = debug->ssext_end = NULL;
- debug->external_fdr = NULL;
- debug->external_rfd = NULL;
- debug->external_ext = debug->external_ext_end = NULL;
-
- handle = bfd_ecoff_debug_init (abfd, debug, &backend->debug_swap, info);
- if (handle == (PTR) NULL)
- return false;
-
- /* Accumulate the debugging symbols from each input BFD. */
- for (input_bfd = info->input_bfds;
- input_bfd != (bfd *) NULL;
- input_bfd = input_bfd->link_next)
- {
- boolean ret;
-
- if (bfd_get_flavour (input_bfd) == bfd_target_ecoff_flavour)
- {
- /* Abitrarily set the symbolic header vstamp to the vstamp
- of the first object file in the link. */
- if (symhdr->vstamp == 0)
- symhdr->vstamp
- = ecoff_data (input_bfd)->debug_info.symbolic_header.vstamp;
- ret = ecoff_final_link_debug_accumulate (abfd, input_bfd, info,
- handle);
- }
- else
- ret = bfd_ecoff_debug_accumulate_other (handle, abfd,
- debug, &backend->debug_swap,
- input_bfd, info);
- if (! ret)
- return false;
-
- /* Combine the register masks. */
- ecoff_data (abfd)->gprmask |= ecoff_data (input_bfd)->gprmask;
- ecoff_data (abfd)->fprmask |= ecoff_data (input_bfd)->fprmask;
- ecoff_data (abfd)->cprmask[0] |= ecoff_data (input_bfd)->cprmask[0];
- ecoff_data (abfd)->cprmask[1] |= ecoff_data (input_bfd)->cprmask[1];
- ecoff_data (abfd)->cprmask[2] |= ecoff_data (input_bfd)->cprmask[2];
- ecoff_data (abfd)->cprmask[3] |= ecoff_data (input_bfd)->cprmask[3];
- }
-
- /* Write out the external symbols. */
- einfo.abfd = abfd;
- einfo.info = info;
- ecoff_link_hash_traverse (ecoff_hash_table (info),
- ecoff_link_write_external,
- (PTR) &einfo);
-
- if (info->relocateable)
- {
- /* We need to make a pass over the link_orders to count up the
- number of relocations we will need to output, so that we know
- how much space they will take up. */
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- o->reloc_count = 0;
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- if (p->type == bfd_indirect_link_order)
- o->reloc_count += p->u.indirect.section->reloc_count;
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- ++o->reloc_count;
- }
- }
-
- /* Compute the reloc and symbol file positions. */
- ecoff_compute_reloc_file_positions (abfd);
-
- /* Write out the debugging information. */
- if (! bfd_ecoff_write_accumulated_debug (handle, abfd, debug,
- &backend->debug_swap, info,
- ecoff_data (abfd)->sym_filepos))
- return false;
-
- bfd_ecoff_debug_free (handle, abfd, debug, &backend->debug_swap, info);
-
- if (info->relocateable)
- {
- /* Now reset the reloc_count field of the sections in the output
- BFD to 0, so that we can use them to keep track of how many
- relocs we have output thus far. */
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- o->reloc_count = 0;
- }
-
- /* Get a value for the GP register. */
- if (ecoff_data (abfd)->gp == 0)
- {
- struct bfd_link_hash_entry *h;
-
- h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
- if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_defined)
- ecoff_data (abfd)->gp = (h->u.def.value
- + h->u.def.section->output_section->vma
- + h->u.def.section->output_offset);
- else if (info->relocateable)
- {
- bfd_vma lo;
-
- /* Make up a value. */
- lo = (bfd_vma) -1;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- if (o->vma < lo
- && (strcmp (o->name, _SBSS) == 0
- || strcmp (o->name, _SDATA) == 0
- || strcmp (o->name, _LIT4) == 0
- || strcmp (o->name, _LIT8) == 0
- || strcmp (o->name, _LITA) == 0))
- lo = o->vma;
- }
- ecoff_data (abfd)->gp = lo + 0x8000;
- }
- else
- {
- /* If the relocate_section function needs to do a reloc
- involving the GP value, it should make a reloc_dangerous
- callback to warn that GP is not defined. */
- }
- }
-
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_ecoff_flavour))
- {
- if (! ecoff_indirect_link_order (abfd, info, o, p))
- return false;
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! ecoff_reloc_link_order (abfd, info, o, p))
- return false;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- return false;
- }
- }
- }
-
- bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;
-
- ecoff_data (abfd)->linker = true;
-
- return true;
-}
-
-/* Accumulate the debugging information for an input BFD into the
- output BFD. This must read in the symbolic information of the
- input BFD. */
-
-static boolean
-ecoff_final_link_debug_accumulate (output_bfd, input_bfd, info, handle)
- bfd *output_bfd;
- bfd *input_bfd;
- struct bfd_link_info *info;
- PTR handle;
-{
- struct ecoff_debug_info * const debug = &ecoff_data (input_bfd)->debug_info;
- const struct ecoff_debug_swap * const swap =
- &ecoff_backend (input_bfd)->debug_swap;
- HDRR *symhdr = &debug->symbolic_header;
- boolean ret;
-
-#define READ(ptr, offset, count, size, type) \
- if (symhdr->count == 0) \
- debug->ptr = NULL; \
- else \
- { \
- debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
- if (debug->ptr == NULL) \
- { \
- ret = false; \
- goto return_something; \
- } \
- if ((bfd_seek (input_bfd, (file_ptr) symhdr->offset, SEEK_SET) \
- != 0) \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- input_bfd) != size * symhdr->count)) \
- { \
- ret = false; \
- goto return_something; \
- } \
- }
-
- /* If raw_syments is not NULL, then the data was already by read by
- _bfd_ecoff_slurp_symbolic_info. */
- if (ecoff_data (input_bfd)->raw_syments == NULL)
- {
- READ (line, cbLineOffset, cbLine, sizeof (unsigned char),
- unsigned char *);
- READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
- READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
- READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
- READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
- READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
- union aux_ext *);
- READ (ss, cbSsOffset, issMax, sizeof (char), char *);
- READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
- }
-#undef READ
-
- /* We do not read the external strings or the external symbols. */
-
- ret = (bfd_ecoff_debug_accumulate
- (handle, output_bfd, &ecoff_data (output_bfd)->debug_info,
- &ecoff_backend (output_bfd)->debug_swap,
- input_bfd, debug, swap, info));
-
- return_something:
- if (ecoff_data (input_bfd)->raw_syments == NULL)
- {
- if (debug->line != NULL)
- free (debug->line);
- if (debug->external_dnr != NULL)
- free (debug->external_dnr);
- if (debug->external_pdr != NULL)
- free (debug->external_pdr);
- if (debug->external_sym != NULL)
- free (debug->external_sym);
- if (debug->external_opt != NULL)
- free (debug->external_opt);
- if (debug->external_aux != NULL)
- free (debug->external_aux);
- if (debug->ss != NULL)
- free (debug->ss);
- if (debug->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
-
- /* Make sure we don't accidentally follow one of these pointers
- into freed memory. */
- debug->line = NULL;
- debug->external_dnr = NULL;
- debug->external_pdr = NULL;
- debug->external_sym = NULL;
- debug->external_opt = NULL;
- debug->external_aux = NULL;
- debug->ss = NULL;
- debug->external_fdr = NULL;
- debug->external_rfd = NULL;
- }
-
- return ret;
-}
-
-/* Put out information for an external symbol. These come only from
- the hash table. */
-
-static boolean
-ecoff_link_write_external (h, data)
- struct ecoff_link_hash_entry *h;
- PTR data;
-{
- struct extsym_info *einfo = (struct extsym_info *) data;
- bfd *output_bfd = einfo->abfd;
- boolean strip;
-
- /* We need to check if this symbol is being stripped. */
- if (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- strip = false;
- else if (einfo->info->strip == strip_all
- || (einfo->info->strip == strip_some
- && bfd_hash_lookup (einfo->info->keep_hash,
- h->root.root.string,
- false, false) == NULL))
- strip = true;
- else
- strip = false;
-
- if (strip || h->written)
- return true;
-
- if (h->abfd == (bfd *) NULL)
- {
- h->esym.jmptbl = 0;
- h->esym.cobol_main = 0;
- h->esym.weakext = 0;
- h->esym.reserved = 0;
- h->esym.ifd = ifdNil;
- h->esym.asym.value = 0;
- h->esym.asym.st = stGlobal;
-
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
- h->esym.asym.sc = scAbs;
- else
- {
- asection *output_section;
- const char *name;
-
- output_section = h->root.u.def.section->output_section;
- name = bfd_section_name (output_section->owner, output_section);
-
- if (strcmp (name, _TEXT) == 0)
- h->esym.asym.sc = scText;
- else if (strcmp (name, _DATA) == 0)
- h->esym.asym.sc = scData;
- else if (strcmp (name, _SDATA) == 0)
- h->esym.asym.sc = scSData;
- else if (strcmp (name, _RDATA) == 0)
- h->esym.asym.sc = scRData;
- else if (strcmp (name, _BSS) == 0)
- h->esym.asym.sc = scBss;
- else if (strcmp (name, _SBSS) == 0)
- h->esym.asym.sc = scSBss;
- else if (strcmp (name, _INIT) == 0)
- h->esym.asym.sc = scInit;
- else if (strcmp (name, _FINI) == 0)
- h->esym.asym.sc = scFini;
- else if (strcmp (name, _PDATA) == 0)
- h->esym.asym.sc = scPData;
- else if (strcmp (name, _XDATA) == 0)
- h->esym.asym.sc = scXData;
- else if (strcmp (name, _RCONST) == 0)
- h->esym.asym.sc = scRConst;
- else
- h->esym.asym.sc = scAbs;
- }
-
- h->esym.asym.reserved = 0;
- h->esym.asym.index = indexNil;
- }
- else if (h->esym.ifd != -1)
- {
- struct ecoff_debug_info *debug;
-
- /* Adjust the FDR index for the symbol by that used for the
- input BFD. */
- debug = &ecoff_data (h->abfd)->debug_info;
- BFD_ASSERT (h->esym.ifd >= 0
- && h->esym.ifd < debug->symbolic_header.ifdMax);
- h->esym.ifd = debug->ifdmap[h->esym.ifd];
- }
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- if (h->esym.asym.sc != scUndefined
- && h->esym.asym.sc != scSUndefined)
- h->esym.asym.sc = scUndefined;
- break;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- if (h->esym.asym.sc == scUndefined
- || h->esym.asym.sc == scSUndefined)
- h->esym.asym.sc = scAbs;
- else if (h->esym.asym.sc == scCommon)
- h->esym.asym.sc = scBss;
- else if (h->esym.asym.sc == scSCommon)
- h->esym.asym.sc = scSBss;
- h->esym.asym.value = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- break;
- case bfd_link_hash_common:
- if (h->esym.asym.sc != scCommon
- && h->esym.asym.sc != scSCommon)
- h->esym.asym.sc = scCommon;
- h->esym.asym.value = h->root.u.c.size;
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: Ignore these for now. The circumstances under which
- they should be written out are not clear to me. */
- return true;
- }
-
- /* bfd_ecoff_debug_one_external uses iextMax to keep track of the
- symbol number. */
- h->indx = ecoff_data (output_bfd)->debug_info.symbolic_header.iextMax;
- h->written = 1;
-
- return (bfd_ecoff_debug_one_external
- (output_bfd, &ecoff_data (output_bfd)->debug_info,
- &ecoff_backend (output_bfd)->debug_swap, h->root.root.string,
- &h->esym));
-}
-
-/* Relocate and write an ECOFF section into an ECOFF output file. */
-
-static boolean
-ecoff_indirect_link_order (output_bfd, info, output_section, link_order)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection *output_section;
- struct bfd_link_order *link_order;
-{
- asection *input_section;
- bfd *input_bfd;
- struct ecoff_section_tdata *section_tdata;
- bfd_size_type raw_size;
- bfd_size_type cooked_size;
- bfd_byte *contents = NULL;
- bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
- PTR external_relocs = NULL;
-
- BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
-
- if (link_order->size == 0)
- return true;
-
- input_section = link_order->u.indirect.section;
- input_bfd = input_section->owner;
- section_tdata = ecoff_section_data (input_bfd, input_section);
-
- raw_size = input_section->_raw_size;
- cooked_size = input_section->_cooked_size;
- if (cooked_size == 0)
- cooked_size = raw_size;
-
- BFD_ASSERT (input_section->output_section == output_section);
- BFD_ASSERT (input_section->output_offset == link_order->offset);
- BFD_ASSERT (cooked_size == link_order->size);
-
- /* Get the section contents. We allocate memory for the larger of
- the size before relocating and the size after relocating. */
- contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
- ? (size_t) raw_size
- : (size_t) cooked_size);
- if (contents == NULL && raw_size != 0)
- goto error_return;
-
- /* If we are relaxing, the contents may have already been read into
- memory, in which case we copy them into our new buffer. We don't
- simply reuse the old buffer in case cooked_size > raw_size. */
- if (section_tdata != (struct ecoff_section_tdata *) NULL
- && section_tdata->contents != (bfd_byte *) NULL)
- memcpy (contents, section_tdata->contents, (size_t) raw_size);
- else
- {
- if (! bfd_get_section_contents (input_bfd, input_section,
- (PTR) contents,
- (file_ptr) 0, raw_size))
- goto error_return;
- }
-
- /* Get the relocs. If we are relaxing MIPS code, they will already
- have been read in. Otherwise, we read them in now. */
- external_reloc_size = ecoff_backend (input_bfd)->external_reloc_size;
- external_relocs_size = external_reloc_size * input_section->reloc_count;
-
- if (section_tdata != (struct ecoff_section_tdata *) NULL
- && section_tdata->external_relocs != NULL)
- external_relocs = section_tdata->external_relocs;
- else
- {
- external_relocs = (PTR) bfd_malloc ((size_t) external_relocs_size);
- if (external_relocs == NULL && external_relocs_size != 0)
- goto error_return;
-
- if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
- != external_relocs_size))
- goto error_return;
- }
-
- /* Relocate the section contents. */
- if (! ((*ecoff_backend (input_bfd)->relocate_section)
- (output_bfd, info, input_bfd, input_section, contents,
- external_relocs)))
- goto error_return;
-
- /* Write out the relocated section. */
- if (! bfd_set_section_contents (output_bfd,
- output_section,
- (PTR) contents,
- input_section->output_offset,
- cooked_size))
- goto error_return;
-
- /* If we are producing relocateable output, the relocs were
- modified, and we write them out now. We use the reloc_count
- field of output_section to keep track of the number of relocs we
- have output so far. */
- if (info->relocateable)
- {
- if (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) != 0
- || (bfd_write (external_relocs, 1, external_relocs_size, output_bfd)
- != external_relocs_size))
- goto error_return;
- output_section->reloc_count += input_section->reloc_count;
- }
-
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL && section_tdata == NULL)
- free (external_relocs);
- return true;
-
- error_return:
- if (contents != NULL)
- free (contents);
- if (external_relocs != NULL && section_tdata == NULL)
- free (external_relocs);
- return false;
-}
-
-/* Generate a reloc when linking an ECOFF file. This is a reloc
- requested by the linker, and does come from any input file. This
- is used to build constructor and destructor tables when linking
- with -Ur. */
-
-static boolean
-ecoff_reloc_link_order (output_bfd, info, output_section, link_order)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection *output_section;
- struct bfd_link_order *link_order;
-{
- enum bfd_link_order_type type;
- asection *section;
- bfd_vma addend;
- arelent rel;
- struct internal_reloc in;
- bfd_size_type external_reloc_size;
- bfd_byte *rbuf;
- boolean ok;
-
- type = link_order->type;
- section = NULL;
- addend = link_order->u.reloc.p->addend;
-
- /* We set up an arelent to pass to the backend adjust_reloc_out
- routine. */
- rel.address = link_order->offset;
-
- rel.howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (rel.howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (type == bfd_section_reloc_link_order)
- {
- section = link_order->u.reloc.p->u.section;
- rel.sym_ptr_ptr = section->symbol_ptr_ptr;
- }
- else
- {
- struct bfd_link_hash_entry *h;
-
- /* Treat a reloc against a defined symbol as though it were
- actually against the section. */
- h = bfd_wrapped_link_hash_lookup (output_bfd, info,
- link_order->u.reloc.p->u.name,
- false, false, false);
- if (h != NULL
- && (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak))
- {
- type = bfd_section_reloc_link_order;
- section = h->u.def.section->output_section;
- /* It seems that we ought to add the symbol value to the
- addend here, but in practice it has already been added
- because it was passed to constructor_callback. */
- addend += section->vma + h->u.def.section->output_offset;
- }
- else
- {
- /* We can't set up a reloc against a symbol correctly,
- because we have no asymbol structure. Currently no
- adjust_reloc_out routine cares. */
- rel.sym_ptr_ptr = (asymbol **) NULL;
- }
- }
-
- /* All ECOFF relocs are in-place. Put the addend into the object
- file. */
-
- BFD_ASSERT (rel.howto->partial_inplace);
- if (addend != 0)
- {
- bfd_size_type size;
- bfd_reloc_status_type rstat;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (rel.howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- rstat = _bfd_relocate_contents (rel.howto, output_bfd, addend, buf);
- switch (rstat)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*info->callbacks->reloc_overflow)
- (info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (output_bfd, section)
- : link_order->u.reloc.p->u.name),
- rel.howto->name, addend, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
- }
-
- rel.addend = 0;
-
- /* Move the information into a internal_reloc structure. */
- in.r_vaddr = (rel.address
- + bfd_get_section_vma (output_bfd, output_section));
- in.r_type = rel.howto->type;
-
- if (type == bfd_symbol_reloc_link_order)
- {
- struct ecoff_link_hash_entry *h;
-
- h = ((struct ecoff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h != (struct ecoff_link_hash_entry *) NULL
- && h->indx != -1)
- in.r_symndx = h->indx;
- else
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- in.r_symndx = 0;
- }
- in.r_extern = 1;
- }
- else
- {
- CONST char *name;
-
- name = bfd_get_section_name (output_bfd, section);
- if (strcmp (name, ".text") == 0)
- in.r_symndx = RELOC_SECTION_TEXT;
- else if (strcmp (name, ".rdata") == 0)
- in.r_symndx = RELOC_SECTION_RDATA;
- else if (strcmp (name, ".data") == 0)
- in.r_symndx = RELOC_SECTION_DATA;
- else if (strcmp (name, ".sdata") == 0)
- in.r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- in.r_symndx = RELOC_SECTION_SBSS;
- else if (strcmp (name, ".bss") == 0)
- in.r_symndx = RELOC_SECTION_BSS;
- else if (strcmp (name, ".init") == 0)
- in.r_symndx = RELOC_SECTION_INIT;
- else if (strcmp (name, ".lit8") == 0)
- in.r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- in.r_symndx = RELOC_SECTION_LIT4;
- else if (strcmp (name, ".xdata") == 0)
- in.r_symndx = RELOC_SECTION_XDATA;
- else if (strcmp (name, ".pdata") == 0)
- in.r_symndx = RELOC_SECTION_PDATA;
- else if (strcmp (name, ".fini") == 0)
- in.r_symndx = RELOC_SECTION_FINI;
- else if (strcmp (name, ".lita") == 0)
- in.r_symndx = RELOC_SECTION_LITA;
- else if (strcmp (name, "*ABS*") == 0)
- in.r_symndx = RELOC_SECTION_ABS;
- else if (strcmp (name, ".rconst") == 0)
- in.r_symndx = RELOC_SECTION_RCONST;
- else
- abort ();
- in.r_extern = 0;
- }
-
- /* Let the BFD backend adjust the reloc. */
- (*ecoff_backend (output_bfd)->adjust_reloc_out) (output_bfd, &rel, &in);
-
- /* Get some memory and swap out the reloc. */
- external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
- rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
- if (rbuf == (bfd_byte *) NULL)
- return false;
-
- (*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf);
-
- ok = (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) == 0
- && (bfd_write ((PTR) rbuf, 1, external_reloc_size, output_bfd)
- == external_reloc_size));
-
- if (ok)
- ++output_section->reloc_count;
-
- free (rbuf);
-
- return ok;
-}
diff --git a/contrib/gdb/bfd/ecofflink.c b/contrib/gdb/bfd/ecofflink.c
deleted file mode 100644
index 03d6e00..0000000
--- a/contrib/gdb/bfd/ecofflink.c
+++ /dev/null
@@ -1,2452 +0,0 @@
-/* Routines to link ECOFF debugging information.
- Copyright 1993 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "aout/stab_gnu.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-
-static boolean ecoff_add_bytes PARAMS ((char **buf, char **bufend,
- size_t need));
-static struct bfd_hash_entry *string_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-static void ecoff_align_debug PARAMS ((bfd *abfd,
- struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap));
-static boolean ecoff_write_symhdr PARAMS ((bfd *, struct ecoff_debug_info *,
- const struct ecoff_debug_swap *,
- file_ptr where));
-static int cmp_fdrtab_entry PARAMS ((const PTR, const PTR));
-static boolean mk_fdrtab PARAMS ((bfd *,
- struct ecoff_debug_info * const,
- const struct ecoff_debug_swap * const,
- struct ecoff_find_line *));
-static long fdrtab_lookup PARAMS ((struct ecoff_find_line *, bfd_vma));
-
-/* Obstack allocation and deallocation routines. */
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-/* Routines to swap auxiliary information in and out. I am assuming
- that the auxiliary information format is always going to be target
- independent. */
-
-/* Swap in a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-_bfd_ecoff_swap_tir_in (bigend, ext_copy, intern)
- int bigend;
- const struct tir_ext *ext_copy;
- TIR *intern;
-{
- struct tir_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
- >> TIR_BITS1_BT_SH_BIG;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
- >> TIR_BITS_TQ4_SH_BIG;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
- >> TIR_BITS_TQ5_SH_BIG;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
- >> TIR_BITS_TQ0_SH_BIG;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
- >> TIR_BITS_TQ1_SH_BIG;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
- >> TIR_BITS_TQ2_SH_BIG;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
- >> TIR_BITS_TQ3_SH_BIG;
- } else {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
- >> TIR_BITS1_BT_SH_LITTLE;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
- >> TIR_BITS_TQ4_SH_LITTLE;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
- >> TIR_BITS_TQ5_SH_LITTLE;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
- >> TIR_BITS_TQ0_SH_LITTLE;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
- >> TIR_BITS_TQ1_SH_LITTLE;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
- >> TIR_BITS_TQ2_SH_LITTLE;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
- >> TIR_BITS_TQ3_SH_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-_bfd_ecoff_swap_tir_out (bigend, intern_copy, ext)
- int bigend;
- const TIR *intern_copy;
- struct tir_ext *ext;
-{
- TIR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_BIG)
- & TIR_BITS1_BT_BIG));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
- & TIR_BITS_TQ4_BIG)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
- & TIR_BITS_TQ5_BIG));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
- & TIR_BITS_TQ0_BIG)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
- & TIR_BITS_TQ1_BIG));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
- & TIR_BITS_TQ2_BIG)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
- & TIR_BITS_TQ3_BIG));
- } else {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
- & TIR_BITS1_BT_LITTLE));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
- & TIR_BITS_TQ4_LITTLE)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
- & TIR_BITS_TQ5_LITTLE));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
- & TIR_BITS_TQ0_LITTLE)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
- & TIR_BITS_TQ1_LITTLE));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
- & TIR_BITS_TQ2_LITTLE)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
- & TIR_BITS_TQ3_LITTLE));
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-_bfd_ecoff_swap_rndx_in (bigend, ext_copy, intern)
- int bigend;
- const struct rndx_ext *ext_copy;
- RNDXR *intern;
-{
- struct rndx_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
- >> RNDX_BITS1_RFD_SH_BIG);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
- << RNDX_BITS1_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
- } else {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
- << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
- >> RNDX_BITS1_INDEX_SH_LITTLE)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
- | ((unsigned int) ext->r_bits[3]
- << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-_bfd_ecoff_swap_rndx_out (bigend, intern_copy, ext)
- int bigend;
- const RNDXR *intern_copy;
- struct rndx_ext *ext;
-{
- RNDXR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
- ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
- & RNDX_BITS1_RFD_BIG)
- | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
- & RNDX_BITS1_INDEX_BIG));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
- } else {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
- ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
- & RNDX_BITS1_RFD_LITTLE)
- | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
- & RNDX_BITS1_INDEX_LITTLE));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* The minimum amount of data to allocate. */
-#define ALLOC_SIZE (4064)
-
-/* Add bytes to a buffer. Return success. */
-
-static boolean
-ecoff_add_bytes (buf, bufend, need)
- char **buf;
- char **bufend;
- size_t need;
-{
- size_t have;
- size_t want;
- char *newbuf;
-
- have = *bufend - *buf;
- if (have > need)
- want = ALLOC_SIZE;
- else
- {
- want = need - have;
- if (want < ALLOC_SIZE)
- want = ALLOC_SIZE;
- }
- newbuf = (char *) bfd_realloc (*buf, have + want);
- if (newbuf == NULL)
- return false;
- *buf = newbuf;
- *bufend = *buf + have + want;
- return true;
-}
-
-/* We keep a hash table which maps strings to numbers. We use it to
- map FDR names to indices in the output file, and to map local
- strings when combining stabs debugging information. */
-
-struct string_hash_entry
-{
- struct bfd_hash_entry root;
- /* FDR index or string table offset. */
- long val;
- /* Next entry in string table. */
- struct string_hash_entry *next;
-};
-
-struct string_hash_table
-{
- struct bfd_hash_table table;
-};
-
-/* Routine to create an entry in a string hash table. */
-
-static struct bfd_hash_entry *
-string_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct string_hash_entry *ret = (struct string_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct string_hash_entry *) NULL)
- ret = ((struct string_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
- if (ret == (struct string_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct string_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->val = -1;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Look up an entry in an string hash table. */
-
-#define string_hash_lookup(t, string, create, copy) \
- ((struct string_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* We can't afford to read in all the debugging information when we do
- a link. Instead, we build a list of these structures to show how
- different parts of the input file map to the output file. */
-
-struct shuffle
-{
- /* The next entry in this linked list. */
- struct shuffle *next;
- /* The length of the information. */
- unsigned long size;
- /* Whether this information comes from a file or not. */
- boolean filep;
- union
- {
- struct
- {
- /* The BFD the data comes from. */
- bfd *input_bfd;
- /* The offset within input_bfd. */
- file_ptr offset;
- } file;
- /* The data to be written out. */
- PTR memory;
- } u;
-};
-
-/* This structure holds information across calls to
- bfd_ecoff_debug_accumulate. */
-
-struct accumulate
-{
- /* The FDR hash table. */
- struct string_hash_table fdr_hash;
- /* The strings hash table. */
- struct string_hash_table str_hash;
- /* Linked lists describing how to shuffle the input debug
- information into the output file. We keep a pointer to both the
- head and the tail. */
- struct shuffle *line;
- struct shuffle *line_end;
- struct shuffle *pdr;
- struct shuffle *pdr_end;
- struct shuffle *sym;
- struct shuffle *sym_end;
- struct shuffle *opt;
- struct shuffle *opt_end;
- struct shuffle *aux;
- struct shuffle *aux_end;
- struct shuffle *ss;
- struct shuffle *ss_end;
- struct string_hash_entry *ss_hash;
- struct string_hash_entry *ss_hash_end;
- struct shuffle *fdr;
- struct shuffle *fdr_end;
- struct shuffle *rfd;
- struct shuffle *rfd_end;
- /* The size of the largest file shuffle. */
- unsigned long largest_file_shuffle;
- /* An obstack for debugging information. */
- struct obstack memory;
-};
-
-/* Add a file entry to a shuffle list. */
-
-static boolean add_file_shuffle PARAMS ((struct accumulate *,
- struct shuffle **,
- struct shuffle **, bfd *, file_ptr,
- unsigned long));
-
-static boolean
-add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
- struct accumulate *ainfo;
- struct shuffle **head;
- struct shuffle **tail;
- bfd *input_bfd;
- file_ptr offset;
- unsigned long size;
-{
- struct shuffle *n;
-
- if (*tail != (struct shuffle *) NULL
- && (*tail)->filep
- && (*tail)->u.file.input_bfd == input_bfd
- && (*tail)->u.file.offset + (*tail)->size == (unsigned long) offset)
- {
- /* Just merge this entry onto the existing one. */
- (*tail)->size += size;
- if ((*tail)->size > ainfo->largest_file_shuffle)
- ainfo->largest_file_shuffle = (*tail)->size;
- return true;
- }
-
- n = (struct shuffle *) obstack_alloc (&ainfo->memory,
- sizeof (struct shuffle));
- if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- n->next = NULL;
- n->size = size;
- n->filep = true;
- n->u.file.input_bfd = input_bfd;
- n->u.file.offset = offset;
- if (*head == (struct shuffle *) NULL)
- *head = n;
- if (*tail != (struct shuffle *) NULL)
- (*tail)->next = n;
- *tail = n;
- if (size > ainfo->largest_file_shuffle)
- ainfo->largest_file_shuffle = size;
- return true;
-}
-
-/* Add a memory entry to a shuffle list. */
-
-static boolean add_memory_shuffle PARAMS ((struct accumulate *,
- struct shuffle **head,
- struct shuffle **tail,
- bfd_byte *data, unsigned long size));
-
-static boolean
-add_memory_shuffle (ainfo, head, tail, data, size)
- struct accumulate *ainfo;
- struct shuffle **head;
- struct shuffle **tail;
- bfd_byte *data;
- unsigned long size;
-{
- struct shuffle *n;
-
- n = (struct shuffle *) obstack_alloc (&ainfo->memory,
- sizeof (struct shuffle));
- if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- n->next = NULL;
- n->size = size;
- n->filep = false;
- n->u.memory = (PTR) data;
- if (*head == (struct shuffle *) NULL)
- *head = n;
- if (*tail != (struct shuffle *) NULL)
- (*tail)->next = n;
- *tail = n;
- return true;
-}
-
-/* Initialize the FDR hash table. This returns a handle which is then
- passed in to bfd_ecoff_debug_accumulate, et. al. */
-
-/*ARGSUSED*/
-PTR
-bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo;
-
- ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
- if (!ainfo)
- return NULL;
- if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
- 1021))
- return NULL;
-
- ainfo->line = NULL;
- ainfo->line_end = NULL;
- ainfo->pdr = NULL;
- ainfo->pdr_end = NULL;
- ainfo->sym = NULL;
- ainfo->sym_end = NULL;
- ainfo->opt = NULL;
- ainfo->opt_end = NULL;
- ainfo->aux = NULL;
- ainfo->aux_end = NULL;
- ainfo->ss = NULL;
- ainfo->ss_end = NULL;
- ainfo->ss_hash = NULL;
- ainfo->ss_hash_end = NULL;
- ainfo->fdr = NULL;
- ainfo->fdr_end = NULL;
- ainfo->rfd = NULL;
- ainfo->rfd_end = NULL;
-
- ainfo->largest_file_shuffle = 0;
-
- if (! info->relocateable)
- {
- if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc))
- return NULL;
-
- /* The first entry in the string table is the empty string. */
- output_debug->symbolic_header.issMax = 1;
- }
-
- if (!obstack_begin (&ainfo->memory, 4050))
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
-
- return (PTR) ainfo;
-}
-
-/* Free the accumulated debugging information. */
-
-/*ARGSUSED*/
-void
-bfd_ecoff_debug_free (handle, output_bfd, output_debug, output_swap, info)
- PTR handle;
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- bfd_hash_table_free (&ainfo->fdr_hash.table);
-
- if (! info->relocateable)
- bfd_hash_table_free (&ainfo->str_hash.table);
-
- obstack_free (&ainfo->memory, (PTR) NULL);
-
- free (ainfo);
-}
-
-/* Accumulate the debugging information from INPUT_BFD into
- OUTPUT_BFD. The INPUT_DEBUG argument points to some ECOFF
- debugging information which we want to link into the information
- pointed to by the OUTPUT_DEBUG argument. OUTPUT_SWAP and
- INPUT_SWAP point to the swapping information needed. INFO is the
- linker information structure. HANDLE is returned by
- bfd_ecoff_debug_init. */
-
-/*ARGSUSED*/
-boolean
-bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
- input_bfd, input_debug, input_swap,
- info)
- PTR handle;
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- bfd *input_bfd;
- struct ecoff_debug_info *input_debug;
- const struct ecoff_debug_swap *input_swap;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
- = input_swap->swap_sym_in;
- void (* const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *))
- = input_swap->swap_rfd_in;
- void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
- = output_swap->swap_sym_out;
- void (* const swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR))
- = output_swap->swap_fdr_out;
- void (* const swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR))
- = output_swap->swap_rfd_out;
- bfd_size_type external_pdr_size = output_swap->external_pdr_size;
- bfd_size_type external_sym_size = output_swap->external_sym_size;
- bfd_size_type external_opt_size = output_swap->external_opt_size;
- bfd_size_type external_fdr_size = output_swap->external_fdr_size;
- bfd_size_type external_rfd_size = output_swap->external_rfd_size;
- HDRR * const output_symhdr = &output_debug->symbolic_header;
- HDRR * const input_symhdr = &input_debug->symbolic_header;
- bfd_vma section_adjust[scMax];
- asection *sec;
- bfd_byte *fdr_start;
- bfd_byte *fdr_ptr;
- bfd_byte *fdr_end;
- bfd_size_type fdr_add;
- unsigned int copied;
- RFDT i;
- unsigned long sz;
- bfd_byte *rfd_out;
- bfd_byte *rfd_in;
- bfd_byte *rfd_end;
- long newrfdbase = 0;
- long oldrfdbase = 0;
- bfd_byte *fdr_out;
-
- /* Use section_adjust to hold the value to add to a symbol in a
- particular section. */
- memset ((PTR) section_adjust, 0, sizeof section_adjust);
-
-#define SET(name, indx) \
- sec = bfd_get_section_by_name (input_bfd, name); \
- if (sec != NULL) \
- section_adjust[indx] = (sec->output_section->vma \
- + sec->output_offset \
- - sec->vma);
-
- SET (".text", scText);
- SET (".data", scData);
- SET (".bss", scBss);
- SET (".sdata", scSData);
- SET (".sbss", scSBss);
- /* scRdata section may be either .rdata or .rodata. */
- SET (".rdata", scRData);
- SET (".rodata", scRData);
- SET (".init", scInit);
- SET (".fini", scFini);
- SET (".rconst", scRConst);
-
-#undef SET
-
- /* Find all the debugging information based on the FDR's. We need
- to handle them whether they are swapped or not. */
- if (input_debug->fdr != (FDR *) NULL)
- {
- fdr_start = (bfd_byte *) input_debug->fdr;
- fdr_add = sizeof (FDR);
- }
- else
- {
- fdr_start = (bfd_byte *) input_debug->external_fdr;
- fdr_add = input_swap->external_fdr_size;
- }
- fdr_end = fdr_start + input_symhdr->ifdMax * fdr_add;
-
- input_debug->ifdmap = (RFDT *) bfd_alloc (input_bfd,
- (input_symhdr->ifdMax
- * sizeof (RFDT)));
-
- sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size;
- rfd_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!input_debug->ifdmap || !rfd_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->rfd, &ainfo->rfd_end, rfd_out, sz))
- return false;
-
- copied = 0;
-
- /* Look through the FDR's to see which ones we are going to include
- in the final output. We do not want duplicate FDR information
- for header files, because ECOFF debugging is often very large.
- When we find an FDR with no line information which can be merged,
- we look it up in a hash table to ensure that we only include it
- once. We keep a table mapping FDR numbers to the final number
- they get with the BFD, so that we can refer to it when we write
- out the external symbols. */
- for (fdr_ptr = fdr_start, i = 0;
- fdr_ptr < fdr_end;
- fdr_ptr += fdr_add, i++, rfd_out += external_rfd_size)
- {
- FDR fdr;
-
- if (input_debug->fdr != (FDR *) NULL)
- fdr = *(FDR *) fdr_ptr;
- else
- (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
-
- /* See if this FDR can be merged with an existing one. */
- if (fdr.cbLine == 0 && fdr.rss != -1 && fdr.fMerge)
- {
- const char *name;
- char *lookup;
- struct string_hash_entry *fh;
-
- /* We look up a string formed from the file name and the
- number of symbols. Sometimes an include file will
- conditionally define a typedef or something based on the
- order of include files. Using the number of symbols as a
- hash reduces the chance that we will merge symbol
- information that should not be merged. */
- name = input_debug->ss + fdr.issBase + fdr.rss;
-
- lookup = (char *) bfd_malloc (strlen (name) + 20);
- if (lookup == NULL)
- return false;
- sprintf (lookup, "%s %lx", name, fdr.csym);
-
- fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true);
- free (lookup);
- if (fh == (struct string_hash_entry *) NULL)
- return false;
-
- if (fh->val != -1)
- {
- input_debug->ifdmap[i] = fh->val;
- (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i,
- (PTR) rfd_out);
-
- /* Don't copy this FDR. */
- continue;
- }
-
- fh->val = output_symhdr->ifdMax + copied;
- }
-
- input_debug->ifdmap[i] = output_symhdr->ifdMax + copied;
- (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, (PTR) rfd_out);
- ++copied;
- }
-
- newrfdbase = output_symhdr->crfd;
- output_symhdr->crfd += input_symhdr->ifdMax;
-
- /* Copy over any existing RFD's. RFD's are only created by the
- linker, so this will only happen for input files which are the
- result of a partial link. */
- rfd_in = (bfd_byte *) input_debug->external_rfd;
- rfd_end = rfd_in + input_symhdr->crfd * input_swap->external_rfd_size;
- for (;
- rfd_in < rfd_end;
- rfd_in += input_swap->external_rfd_size)
- {
- RFDT rfd;
-
- (*swap_rfd_in) (input_bfd, (PTR) rfd_in, &rfd);
- BFD_ASSERT (rfd >= 0 && rfd < input_symhdr->ifdMax);
- rfd = input_debug->ifdmap[rfd];
- (*swap_rfd_out) (output_bfd, &rfd, (PTR) rfd_out);
- rfd_out += external_rfd_size;
- }
-
- oldrfdbase = output_symhdr->crfd;
- output_symhdr->crfd += input_symhdr->crfd;
-
- /* Look through the FDR's and copy over all associated debugging
- information. */
- sz = copied * external_fdr_size;
- fdr_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!fdr_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end, fdr_out, sz))
- return false;
- for (fdr_ptr = fdr_start, i = 0;
- fdr_ptr < fdr_end;
- fdr_ptr += fdr_add, i++)
- {
- FDR fdr;
- bfd_vma fdr_adr;
- bfd_byte *sym_out;
- bfd_byte *lraw_src;
- bfd_byte *lraw_end;
- boolean fgotfilename;
-
- if (input_debug->ifdmap[i] < output_symhdr->ifdMax)
- {
- /* We are not copying this FDR. */
- continue;
- }
-
- if (input_debug->fdr != (FDR *) NULL)
- fdr = *(FDR *) fdr_ptr;
- else
- (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
-
- fdr_adr = fdr.adr;
-
- /* Adjust the FDR address for any changes that may have been
- made by relaxing. */
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- struct ecoff_value_adjust *adjust;
-
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (fdr_adr >= adjust->start
- && fdr_adr < adjust->end)
- fdr.adr += adjust->adjust;
- }
-
- /* FIXME: It is conceivable that this FDR points to the .init or
- .fini section, in which case this will not do the right
- thing. */
- fdr.adr += section_adjust[scText];
-
- /* Swap in the local symbols, adjust their values, and swap them
- out again. */
- fgotfilename = false;
- sz = fdr.csym * external_sym_size;
- sym_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!sym_out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end, sym_out,
- sz))
- return false;
- lraw_src = ((bfd_byte *) input_debug->external_sym
- + fdr.isymBase * input_swap->external_sym_size);
- lraw_end = lraw_src + fdr.csym * input_swap->external_sym_size;
- for (; lraw_src < lraw_end; lraw_src += input_swap->external_sym_size)
- {
- SYMR internal_sym;
-
- (*swap_sym_in) (input_bfd, (PTR) lraw_src, &internal_sym);
-
- BFD_ASSERT (internal_sym.sc != scCommon
- && internal_sym.sc != scSCommon);
-
- /* Adjust the symbol value if appropriate. */
- switch (internal_sym.st)
- {
- case stNil:
- if (ECOFF_IS_STAB (&internal_sym))
- break;
- /* Fall through. */
- case stGlobal:
- case stStatic:
- case stLabel:
- case stProc:
- case stStaticProc:
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- bfd_vma value;
- struct ecoff_value_adjust *adjust;
-
- value = internal_sym.value;
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (value >= adjust->start
- && value < adjust->end)
- internal_sym.value += adjust->adjust;
- }
- internal_sym.value += section_adjust[internal_sym.sc];
- break;
-
- default:
- break;
- }
-
- /* If we are doing a final link, we hash all the strings in
- the local symbol table together. This reduces the amount
- of space required by debugging information. We don't do
- this when performing a relocateable link because it would
- prevent us from easily merging different FDR's. */
- if (! info->relocateable)
- {
- boolean ffilename;
- const char *name;
-
- if (! fgotfilename && internal_sym.iss == fdr.rss)
- ffilename = true;
- else
- ffilename = false;
-
- /* Hash the name into the string table. */
- name = input_debug->ss + fdr.issBase + internal_sym.iss;
- if (*name == '\0')
- internal_sym.iss = 0;
- else
- {
- struct string_hash_entry *sh;
-
- sh = string_hash_lookup (&ainfo->str_hash, name, true, true);
- if (sh == (struct string_hash_entry *) NULL)
- return false;
- if (sh->val == -1)
- {
- sh->val = output_symhdr->issMax;
- output_symhdr->issMax += strlen (name) + 1;
- if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
- ainfo->ss_hash = sh;
- if (ainfo->ss_hash_end
- != (struct string_hash_entry *) NULL)
- ainfo->ss_hash_end->next = sh;
- ainfo->ss_hash_end = sh;
- }
- internal_sym.iss = sh->val;
- }
-
- if (ffilename)
- {
- fdr.rss = internal_sym.iss;
- fgotfilename = true;
- }
- }
-
- (*swap_sym_out) (output_bfd, &internal_sym, sym_out);
- sym_out += external_sym_size;
- }
-
- fdr.isymBase = output_symhdr->isymMax;
- output_symhdr->isymMax += fdr.csym;
-
- /* Copy the information that does not need swapping. */
-
- /* FIXME: If we are relaxing, we need to adjust the line
- numbers. Frankly, forget it. Anybody using stabs debugging
- information will not use this line number information, and
- stabs are adjusted correctly. */
- if (fdr.cbLine > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
- input_bfd,
- input_symhdr->cbLineOffset + fdr.cbLineOffset,
- fdr.cbLine))
- return false;
- fdr.ilineBase = output_symhdr->ilineMax;
- fdr.cbLineOffset = output_symhdr->cbLine;
- output_symhdr->ilineMax += fdr.cline;
- output_symhdr->cbLine += fdr.cbLine;
- }
- if (fdr.caux > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
- input_bfd,
- (input_symhdr->cbAuxOffset
- + fdr.iauxBase * sizeof (union aux_ext)),
- fdr.caux * sizeof (union aux_ext)))
- return false;
- fdr.iauxBase = output_symhdr->iauxMax;
- output_symhdr->iauxMax += fdr.caux;
- }
- if (! info->relocateable)
- {
-
- /* When are are hashing strings, we lie about the number of
- strings attached to each FDR. We need to set cbSs
- because some versions of dbx apparently use it to decide
- how much of the string table to read in. */
- fdr.issBase = 0;
- fdr.cbSs = output_symhdr->issMax;
- }
- else if (fdr.cbSs > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
- input_bfd,
- input_symhdr->cbSsOffset + fdr.issBase,
- fdr.cbSs))
- return false;
- fdr.issBase = output_symhdr->issMax;
- output_symhdr->issMax += fdr.cbSs;
- }
-
- if ((output_bfd->xvec->header_byteorder
- == input_bfd->xvec->header_byteorder)
- && input_debug->adjust == (struct ecoff_value_adjust *) NULL)
- {
- /* The two BFD's have the same endianness, and we don't have
- to adjust the PDR addresses, so simply copying the
- information will suffice. */
- BFD_ASSERT (external_pdr_size == input_swap->external_pdr_size);
- if (fdr.cpd > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end,
- input_bfd,
- (input_symhdr->cbPdOffset
- + fdr.ipdFirst * external_pdr_size),
- fdr.cpd * external_pdr_size))
- return false;
- }
- BFD_ASSERT (external_opt_size == input_swap->external_opt_size);
- if (fdr.copt > 0)
- {
- if (!add_file_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end,
- input_bfd,
- (input_symhdr->cbOptOffset
- + fdr.ioptBase * external_opt_size),
- fdr.copt * external_opt_size))
- return false;
- }
- }
- else
- {
- bfd_size_type outsz, insz;
- bfd_byte *in;
- bfd_byte *end;
- bfd_byte *out;
-
- /* The two BFD's have different endianness, so we must swap
- everything in and out. This code would always work, but
- it would be unnecessarily slow in the normal case. */
- outsz = external_pdr_size;
- insz = input_swap->external_pdr_size;
- in = ((bfd_byte *) input_debug->external_pdr
- + fdr.ipdFirst * insz);
- end = in + fdr.cpd * insz;
- sz = fdr.cpd * outsz;
- out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end, out,
- sz))
- return false;
- for (; in < end; in += insz, out += outsz)
- {
- PDR pdr;
-
- (*input_swap->swap_pdr_in) (input_bfd, (PTR) in, &pdr);
-
- /* If we have been relaxing, we may have to adjust the
- address. */
- if (input_debug->adjust != (struct ecoff_value_adjust *) NULL)
- {
- bfd_vma adr;
- struct ecoff_value_adjust *adjust;
-
- adr = fdr_adr + pdr.adr;
- for (adjust = input_debug->adjust;
- adjust != (struct ecoff_value_adjust *) NULL;
- adjust = adjust->next)
- if (adr >= adjust->start
- && adr < adjust->end)
- pdr.adr += adjust->adjust;
- }
-
- (*output_swap->swap_pdr_out) (output_bfd, &pdr, (PTR) out);
- }
-
- /* Swap over the optimization information. */
- outsz = external_opt_size;
- insz = input_swap->external_opt_size;
- in = ((bfd_byte *) input_debug->external_opt
- + fdr.ioptBase * insz);
- end = in + fdr.copt * insz;
- sz = fdr.copt * outsz;
- out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
- if (!out)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (!add_memory_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end, out,
- sz))
- return false;
- for (; in < end; in += insz, out += outsz)
- {
- OPTR opt;
-
- (*input_swap->swap_opt_in) (input_bfd, (PTR) in, &opt);
- (*output_swap->swap_opt_out) (output_bfd, &opt, (PTR) out);
- }
- }
-
- fdr.ipdFirst = output_symhdr->ipdMax;
- output_symhdr->ipdMax += fdr.cpd;
- fdr.ioptBase = output_symhdr->ioptMax;
- output_symhdr->ioptMax += fdr.copt;
-
- if (fdr.crfd <= 0)
- {
- /* Point this FDR at the table of RFD's we created. */
- fdr.rfdBase = newrfdbase;
- fdr.crfd = input_symhdr->ifdMax;
- }
- else
- {
- /* Point this FDR at the remapped RFD's. */
- fdr.rfdBase += oldrfdbase;
- }
-
- (*swap_fdr_out) (output_bfd, &fdr, fdr_out);
- fdr_out += external_fdr_size;
- ++output_symhdr->ifdMax;
- }
-
- return true;
-}
-
-/* Add a string to the debugging information we are accumulating.
- Return the offset from the fdr string base. */
-
-static long ecoff_add_string PARAMS ((struct accumulate *,
- struct bfd_link_info *,
- struct ecoff_debug_info *,
- FDR *fdr, const char *string));
-
-static long
-ecoff_add_string (ainfo, info, debug, fdr, string)
- struct accumulate *ainfo;
- struct bfd_link_info *info;
- struct ecoff_debug_info *debug;
- FDR *fdr;
- const char *string;
-{
- HDRR *symhdr;
- size_t len;
- bfd_size_type ret;
-
- symhdr = &debug->symbolic_header;
- len = strlen (string);
- if (info->relocateable)
- {
- if (!add_memory_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end, (PTR) string,
- len + 1))
- return -1;
- ret = symhdr->issMax;
- symhdr->issMax += len + 1;
- fdr->cbSs += len + 1;
- }
- else
- {
- struct string_hash_entry *sh;
-
- sh = string_hash_lookup (&ainfo->str_hash, string, true, true);
- if (sh == (struct string_hash_entry *) NULL)
- return -1;
- if (sh->val == -1)
- {
- sh->val = symhdr->issMax;
- symhdr->issMax += len + 1;
- if (ainfo->ss_hash == (struct string_hash_entry *) NULL)
- ainfo->ss_hash = sh;
- if (ainfo->ss_hash_end
- != (struct string_hash_entry *) NULL)
- ainfo->ss_hash_end->next = sh;
- ainfo->ss_hash_end = sh;
- }
- ret = sh->val;
- }
-
- return ret;
-}
-
-/* Add debugging information from a non-ECOFF file. */
-
-boolean
-bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
- output_swap, input_bfd, info)
- PTR handle;
- bfd *output_bfd;
- struct ecoff_debug_info *output_debug;
- const struct ecoff_debug_swap *output_swap;
- bfd *input_bfd;
- struct bfd_link_info *info;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
- = output_swap->swap_sym_out;
- HDRR *output_symhdr = &output_debug->symbolic_header;
- FDR fdr;
- asection *sec;
- asymbol **symbols;
- asymbol **sym_ptr;
- asymbol **sym_end;
- long symsize;
- long symcount;
- PTR external_fdr;
-
- memset ((PTR) &fdr, 0, sizeof fdr);
-
- sec = bfd_get_section_by_name (input_bfd, ".text");
- if (sec != NULL)
- fdr.adr = sec->output_section->vma + sec->output_offset;
- else
- {
- /* FIXME: What about .init or .fini? */
- fdr.adr = 0;
- }
-
- fdr.issBase = output_symhdr->issMax;
- fdr.cbSs = 0;
- fdr.rss = ecoff_add_string (ainfo, info, output_debug, &fdr,
- bfd_get_filename (input_bfd));
- if (fdr.rss == -1)
- return false;
- fdr.isymBase = output_symhdr->isymMax;
-
- /* Get the local symbols from the input BFD. */
- symsize = bfd_get_symtab_upper_bound (input_bfd);
- if (symsize < 0)
- return false;
- symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
- if (symbols == (asymbol **) NULL)
- return false;
- symcount = bfd_canonicalize_symtab (input_bfd, symbols);
- if (symcount < 0)
- return false;
- sym_end = symbols + symcount;
-
- /* Handle the local symbols. Any external symbols are handled
- separately. */
- fdr.csym = 0;
- for (sym_ptr = symbols; sym_ptr != sym_end; sym_ptr++)
- {
- SYMR internal_sym;
- PTR external_sym;
-
- if (((*sym_ptr)->flags & BSF_EXPORT) != 0)
- continue;
- memset ((PTR) &internal_sym, 0, sizeof internal_sym);
- internal_sym.iss = ecoff_add_string (ainfo, info, output_debug, &fdr,
- (*sym_ptr)->name);
-
- if (internal_sym.iss == -1)
- return false;
- if (bfd_is_com_section ((*sym_ptr)->section)
- || bfd_is_und_section ((*sym_ptr)->section))
- internal_sym.value = (*sym_ptr)->value;
- else
- internal_sym.value = ((*sym_ptr)->value
- + (*sym_ptr)->section->output_offset
- + (*sym_ptr)->section->output_section->vma);
- internal_sym.st = stNil;
- internal_sym.sc = scUndefined;
- internal_sym.index = indexNil;
-
- external_sym = (PTR) obstack_alloc (&ainfo->memory,
- output_swap->external_sym_size);
- if (!external_sym)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- (*swap_sym_out) (output_bfd, &internal_sym, external_sym);
- add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end,
- external_sym, output_swap->external_sym_size);
- ++fdr.csym;
- ++output_symhdr->isymMax;
- }
-
- bfd_release (output_bfd, (PTR) symbols);
-
- /* Leave everything else in the FDR zeroed out. This will cause
- the lang field to be langC. The fBigendian field will
- indicate little endian format, but it doesn't matter because
- it only applies to aux fields and there are none. */
- external_fdr = (PTR) obstack_alloc (&ainfo->memory,
- output_swap->external_fdr_size);
- if (!external_fdr)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- (*output_swap->swap_fdr_out) (output_bfd, &fdr, external_fdr);
- add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end,
- external_fdr, output_swap->external_fdr_size);
-
- ++output_symhdr->ifdMax;
-
- return true;
-}
-
-/* Set up ECOFF debugging information for the external symbols.
- FIXME: This is done using a memory buffer, but it should be
- probably be changed to use a shuffle structure. The assembler uses
- this interface, so that must be changed to do something else. */
-
-boolean
-bfd_ecoff_debug_externals (abfd, debug, swap, relocateable, get_extr,
- set_index)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- boolean relocateable;
- boolean (*get_extr) PARAMS ((asymbol *, EXTR *));
- void (*set_index) PARAMS ((asymbol *, bfd_size_type));
-{
- HDRR * const symhdr = &debug->symbolic_header;
- asymbol **sym_ptr_ptr;
- size_t c;
-
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr == NULL)
- return true;
-
- for (c = bfd_get_symcount (abfd); c > 0; c--, sym_ptr_ptr++)
- {
- asymbol *sym_ptr;
- EXTR esym;
-
- sym_ptr = *sym_ptr_ptr;
-
- /* Get the external symbol information. */
- if ((*get_extr) (sym_ptr, &esym) == false)
- continue;
-
- /* If we're producing an executable, move common symbols into
- bss. */
- if (relocateable == false)
- {
- if (esym.asym.sc == scCommon)
- esym.asym.sc = scBss;
- else if (esym.asym.sc == scSCommon)
- esym.asym.sc = scSBss;
- }
-
- if (bfd_is_com_section (sym_ptr->section)
- || bfd_is_und_section (sym_ptr->section)
- || sym_ptr->section->output_section == (asection *) NULL)
- {
- /* FIXME: gas does not keep the value of a small undefined
- symbol in the symbol itself, because of relocation
- problems. */
- if (esym.asym.sc != scSUndefined
- || esym.asym.value == 0
- || sym_ptr->value != 0)
- esym.asym.value = sym_ptr->value;
- }
- else
- esym.asym.value = (sym_ptr->value
- + sym_ptr->section->output_offset
- + sym_ptr->section->output_section->vma);
-
- if (set_index)
- (*set_index) (sym_ptr, (bfd_size_type) symhdr->iextMax);
-
- if (! bfd_ecoff_debug_one_external (abfd, debug, swap,
- sym_ptr->name, &esym))
- return false;
- }
-
- return true;
-}
-
-/* Add a single external symbol to the debugging information. */
-
-boolean
-bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- const char *name;
- EXTR *esym;
-{
- const bfd_size_type external_ext_size = swap->external_ext_size;
- void (* const swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR))
- = swap->swap_ext_out;
- HDRR * const symhdr = &debug->symbolic_header;
- size_t namelen;
-
- namelen = strlen (name);
-
- if ((size_t) (debug->ssext_end - debug->ssext)
- < symhdr->issExtMax + namelen + 1)
- {
- if (ecoff_add_bytes ((char **) &debug->ssext,
- (char **) &debug->ssext_end,
- symhdr->issExtMax + namelen + 1)
- == false)
- return false;
- }
- if ((size_t) ((char *) debug->external_ext_end
- - (char *) debug->external_ext)
- < (symhdr->iextMax + 1) * external_ext_size)
- {
- if (ecoff_add_bytes ((char **) &debug->external_ext,
- (char **) &debug->external_ext_end,
- (symhdr->iextMax + 1) * external_ext_size)
- == false)
- return false;
- }
-
- esym->asym.iss = symhdr->issExtMax;
-
- (*swap_ext_out) (abfd, esym,
- ((char *) debug->external_ext
- + symhdr->iextMax * swap->external_ext_size));
-
- ++symhdr->iextMax;
-
- strcpy (debug->ssext + symhdr->issExtMax, name);
- symhdr->issExtMax += namelen + 1;
-
- return true;
-}
-
-/* Align the ECOFF debugging information. */
-
-/*ARGSUSED*/
-static void
-ecoff_align_debug (abfd, debug, swap)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
-{
- HDRR * const symhdr = &debug->symbolic_header;
- bfd_size_type debug_align, aux_align, rfd_align;
- size_t add;
-
- /* Adjust the counts so that structures are aligned. */
- debug_align = swap->debug_align;
- aux_align = debug_align / sizeof (union aux_ext);
- rfd_align = debug_align / swap->external_rfd_size;
-
- add = debug_align - (symhdr->cbLine & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->line != (unsigned char *) NULL)
- memset ((PTR) (debug->line + symhdr->cbLine), 0, add);
- symhdr->cbLine += add;
- }
-
- add = debug_align - (symhdr->issMax & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->ss != (char *) NULL)
- memset ((PTR) (debug->ss + symhdr->issMax), 0, add);
- symhdr->issMax += add;
- }
-
- add = debug_align - (symhdr->issExtMax & (debug_align - 1));
- if (add != debug_align)
- {
- if (debug->ssext != (char *) NULL)
- memset ((PTR) (debug->ssext + symhdr->issExtMax), 0, add);
- symhdr->issExtMax += add;
- }
-
- add = aux_align - (symhdr->iauxMax & (aux_align - 1));
- if (add != aux_align)
- {
- if (debug->external_aux != (union aux_ext *) NULL)
- memset ((PTR) (debug->external_aux + symhdr->iauxMax), 0,
- add * sizeof (union aux_ext));
- symhdr->iauxMax += add;
- }
-
- add = rfd_align - (symhdr->crfd & (rfd_align - 1));
- if (add != rfd_align)
- {
- if (debug->external_rfd != (PTR) NULL)
- memset ((PTR) ((char *) debug->external_rfd
- + symhdr->crfd * swap->external_rfd_size),
- 0, (size_t) (add * swap->external_rfd_size));
- symhdr->crfd += add;
- }
-}
-
-/* Return the size required by the ECOFF debugging information. */
-
-bfd_size_type
-bfd_ecoff_debug_size (abfd, debug, swap)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
-{
- bfd_size_type tot;
-
- ecoff_align_debug (abfd, debug, swap);
- tot = swap->external_hdr_size;
-
-#define ADD(count, size) \
- tot += debug->symbolic_header.count * size
-
- ADD (cbLine, sizeof (unsigned char));
- ADD (idnMax, swap->external_dnr_size);
- ADD (ipdMax, swap->external_pdr_size);
- ADD (isymMax, swap->external_sym_size);
- ADD (ioptMax, swap->external_opt_size);
- ADD (iauxMax, sizeof (union aux_ext));
- ADD (issMax, sizeof (char));
- ADD (issExtMax, sizeof (char));
- ADD (ifdMax, swap->external_fdr_size);
- ADD (crfd, swap->external_rfd_size);
- ADD (iextMax, swap->external_ext_size);
-
-#undef ADD
-
- return tot;
-}
-
-/* Write out the ECOFF symbolic header, given the file position it is
- going to be placed at. This assumes that the counts are set
- correctly. */
-
-static boolean
-ecoff_write_symhdr (abfd, debug, swap, where)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- file_ptr where;
-{
- HDRR * const symhdr = &debug->symbolic_header;
- char *buff = NULL;
-
- ecoff_align_debug (abfd, debug, swap);
-
- /* Go to the right location in the file. */
- if (bfd_seek (abfd, where, SEEK_SET) != 0)
- return false;
-
- where += swap->external_hdr_size;
-
- symhdr->magic = swap->sym_magic;
-
- /* Fill in the file offsets. */
-#define SET(offset, count, size) \
- if (symhdr->count == 0) \
- symhdr->offset = 0; \
- else \
- { \
- symhdr->offset = where; \
- where += symhdr->count * size; \
- }
-
- SET (cbLineOffset, cbLine, sizeof (unsigned char));
- SET (cbDnOffset, idnMax, swap->external_dnr_size);
- SET (cbPdOffset, ipdMax, swap->external_pdr_size);
- SET (cbSymOffset, isymMax, swap->external_sym_size);
- SET (cbOptOffset, ioptMax, swap->external_opt_size);
- SET (cbAuxOffset, iauxMax, sizeof (union aux_ext));
- SET (cbSsOffset, issMax, sizeof (char));
- SET (cbSsExtOffset, issExtMax, sizeof (char));
- SET (cbFdOffset, ifdMax, swap->external_fdr_size);
- SET (cbRfdOffset, crfd, swap->external_rfd_size);
- SET (cbExtOffset, iextMax, swap->external_ext_size);
-#undef SET
-
- buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size);
- if (buff == NULL && swap->external_hdr_size != 0)
- goto error_return;
-
- (*swap->swap_hdr_out) (abfd, symhdr, buff);
- if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
- != swap->external_hdr_size)
- goto error_return;
-
- if (buff != NULL)
- free (buff);
- return true;
- error_return:
- if (buff != NULL)
- free (buff);
- return false;
-}
-
-/* Write out the ECOFF debugging information. This function assumes
- that the information (the pointers and counts) in *DEBUG have been
- set correctly. WHERE is the position in the file to write the
- information to. This function fills in the file offsets in the
- symbolic header. */
-
-boolean
-bfd_ecoff_write_debug (abfd, debug, swap, where)
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- file_ptr where;
-{
- HDRR * const symhdr = &debug->symbolic_header;
-
- if (! ecoff_write_symhdr (abfd, debug, swap, where))
- return false;
-
-#define WRITE(ptr, count, size, offset) \
- BFD_ASSERT (symhdr->offset == 0 \
- || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
- if (bfd_write ((PTR) debug->ptr, size, symhdr->count, abfd) \
- != size * symhdr->count) \
- return false;
-
- WRITE (line, cbLine, sizeof (unsigned char), cbLineOffset);
- WRITE (external_dnr, idnMax, swap->external_dnr_size, cbDnOffset);
- WRITE (external_pdr, ipdMax, swap->external_pdr_size, cbPdOffset);
- WRITE (external_sym, isymMax, swap->external_sym_size, cbSymOffset);
- WRITE (external_opt, ioptMax, swap->external_opt_size, cbOptOffset);
- WRITE (external_aux, iauxMax, sizeof (union aux_ext), cbAuxOffset);
- WRITE (ss, issMax, sizeof (char), cbSsOffset);
- WRITE (ssext, issExtMax, sizeof (char), cbSsExtOffset);
- WRITE (external_fdr, ifdMax, swap->external_fdr_size, cbFdOffset);
- WRITE (external_rfd, crfd, swap->external_rfd_size, cbRfdOffset);
- WRITE (external_ext, iextMax, swap->external_ext_size, cbExtOffset);
-#undef WRITE
-
- return true;
-}
-
-/* Write out a shuffle list. */
-
-static boolean ecoff_write_shuffle PARAMS ((bfd *,
- const struct ecoff_debug_swap *,
- struct shuffle *, PTR space));
-
-static boolean
-ecoff_write_shuffle (abfd, swap, shuffle, space)
- bfd *abfd;
- const struct ecoff_debug_swap *swap;
- struct shuffle *shuffle;
- PTR space;
-{
- register struct shuffle *l;
- unsigned long total;
-
- total = 0;
- for (l = shuffle; l != (struct shuffle *) NULL; l = l->next)
- {
- if (! l->filep)
- {
- if (bfd_write (l->u.memory, 1, l->size, abfd) != l->size)
- return false;
- }
- else
- {
- if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (space, 1, l->size, l->u.file.input_bfd) != l->size
- || bfd_write (space, 1, l->size, abfd) != l->size)
- return false;
- }
- total += l->size;
- }
-
- if ((total & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- return false;
-
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- return false;
- }
- free (s);
- }
-
- return true;
-}
-
-/* Write out debugging information using accumulated linker
- information. */
-
-boolean
-bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
- PTR handle;
- bfd *abfd;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- struct bfd_link_info *info;
- file_ptr where;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- PTR space = NULL;
-
- if (! ecoff_write_symhdr (abfd, debug, swap, where))
- goto error_return;
-
- space = (PTR) bfd_malloc (ainfo->largest_file_shuffle);
- if (space == NULL && ainfo->largest_file_shuffle != 0)
- goto error_return;
-
- if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->sym, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->opt, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->aux, space))
- goto error_return;
-
- /* The string table is written out from the hash table if this is a
- final link. */
- if (info->relocateable)
- {
- BFD_ASSERT (ainfo->ss_hash == (struct string_hash_entry *) NULL);
- if (! ecoff_write_shuffle (abfd, swap, ainfo->ss, space))
- goto error_return;
- }
- else
- {
- unsigned long total;
- bfd_byte null;
- struct string_hash_entry *sh;
-
- BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
- null = 0;
- if (bfd_write ((PTR) &null, 1, 1, abfd) != 1)
- goto error_return;
- total = 1;
- BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
- for (sh = ainfo->ss_hash;
- sh != (struct string_hash_entry *) NULL;
- sh = sh->next)
- {
- size_t len;
-
- len = strlen (sh->root.string);
- if (bfd_write ((PTR) sh->root.string, 1, len + 1, abfd) != len + 1)
- goto error_return;
- total += len + 1;
- }
-
- if ((total & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- goto error_return;
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- goto error_return;
- }
- free (s);
- }
- }
-
- /* The external strings and symbol are not converted over to using
- shuffles. FIXME: They probably should be. */
- if (bfd_write (debug->ssext, 1, debug->symbolic_header.issExtMax, abfd)
- != (bfd_size_type) debug->symbolic_header.issExtMax)
- goto error_return;
- if ((debug->symbolic_header.issExtMax & (swap->debug_align - 1)) != 0)
- {
- unsigned int i;
- bfd_byte *s;
-
- i = (swap->debug_align
- - (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
- s = (bfd_byte *) bfd_malloc (i);
- if (s == NULL && i != 0)
- goto error_return;
- memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
- {
- free (s);
- goto error_return;
- }
- free (s);
- }
-
- if (! ecoff_write_shuffle (abfd, swap, ainfo->fdr, space)
- || ! ecoff_write_shuffle (abfd, swap, ainfo->rfd, space))
- goto error_return;
-
- BFD_ASSERT (debug->symbolic_header.cbExtOffset == 0
- || (debug->symbolic_header.cbExtOffset
- == (bfd_vma) bfd_tell (abfd)));
-
- if (bfd_write (debug->external_ext, swap->external_ext_size,
- debug->symbolic_header.iextMax, abfd)
- != debug->symbolic_header.iextMax * swap->external_ext_size)
- goto error_return;
-
- if (space != NULL)
- free (space);
- return true;
-
- error_return:
- if (space != NULL)
- free (space);
- return false;
-}
-
-/* Handle the find_nearest_line function for both ECOFF and MIPS ELF
- files. */
-
-/* Compare FDR entries. This is called via qsort. */
-
-static int
-cmp_fdrtab_entry (leftp, rightp)
- const PTR leftp;
- const PTR rightp;
-{
- const struct ecoff_fdrtab_entry *lp =
- (const struct ecoff_fdrtab_entry *) leftp;
- const struct ecoff_fdrtab_entry *rp =
- (const struct ecoff_fdrtab_entry *) rightp;
-
- if (lp->base_addr < rp->base_addr)
- return -1;
- if (lp->base_addr > rp->base_addr)
- return 1;
- return 0;
-}
-
-/* Each file descriptor (FDR) has a memory address, to simplify
- looking up an FDR by address, we build a table covering all FDRs
- that have a least one procedure descriptor in them. The final
- table will be sorted by address so we can look it up via binary
- search. */
-
-static boolean
-mk_fdrtab (abfd, debug_info, debug_swap, line_info)
- bfd *abfd;
- struct ecoff_debug_info * const debug_info;
- const struct ecoff_debug_swap * const debug_swap;
- struct ecoff_find_line *line_info;
-{
- struct ecoff_fdrtab_entry *tab;
- FDR *fdr_ptr;
- FDR *fdr_start;
- FDR *fdr_end;
- boolean stabs;
- long len;
-
- fdr_start = debug_info->fdr;
- fdr_end = fdr_start + debug_info->symbolic_header.ifdMax;
-
- /* First, let's see how long the table needs to be: */
- for (len = 0, fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
- {
- if (fdr_ptr->cpd == 0) /* skip FDRs that have no PDRs */
- continue;
- ++len;
- }
-
- /* Now, create and fill in the table: */
-
- line_info->fdrtab = ((struct ecoff_fdrtab_entry*)
- bfd_zalloc (abfd,
- len * sizeof (struct ecoff_fdrtab_entry)));
- if (line_info->fdrtab == NULL)
- return false;
- line_info->fdrtab_len = len;
-
- tab = line_info->fdrtab;
- for (fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
- {
- if (fdr_ptr->cpd == 0)
- continue;
-
- /* Check whether this file has stabs debugging information. In
- a file with stabs debugging information, the second local
- symbol is named @stabs. */
- stabs = false;
- if (fdr_ptr->csym >= 2)
- {
- char *sym_ptr;
- SYMR sym;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 1)*debug_swap->external_sym_size);
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
- if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
- STABS_SYMBOL) == 0)
- stabs = true;
- }
-
- if (!stabs)
- {
- bfd_size_type external_pdr_size;
- char *pdr_ptr;
- PDR pdr;
-
- external_pdr_size = debug_swap->external_pdr_size;
-
- pdr_ptr = ((char *) debug_info->external_pdr
- + fdr_ptr->ipdFirst * external_pdr_size);
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* The address of the first PDR is the offset of that
- procedure relative to the beginning of file FDR. */
- tab->base_addr = fdr_ptr->adr - pdr.adr;
- }
- else
- {
- /* XXX I don't know about stabs, so this is a guess
- (davidm@cs.arizona.edu): */
- tab->base_addr = fdr_ptr->adr;
- }
- tab->fdr = fdr_ptr;
- ++tab;
- }
-
- /* Finally, the table is sorted in increasing memory-address order.
- The table is mostly sorted already, but there are cases (e.g.,
- static functions in include files), where this does not hold.
- Use "odump -PFv" to verify... */
- qsort ((PTR) line_info->fdrtab, len,
- sizeof (struct ecoff_fdrtab_entry), cmp_fdrtab_entry);
-
- return true;
-}
-
-/* Return index of first FDR that covers to OFFSET. */
-
-static long
-fdrtab_lookup (line_info, offset)
- struct ecoff_find_line *line_info;
- bfd_vma offset;
-{
- long low, high, len;
- long mid = -1;
- struct ecoff_fdrtab_entry *tab;
-
- len = line_info->fdrtab_len;
- if (len == 0)
- return -1;
-
- tab = line_info->fdrtab;
- for (low = 0, high = len - 1 ; low != high ;)
- {
- mid = (high + low) / 2;
- if (offset >= tab[mid].base_addr && offset < tab[mid + 1].base_addr)
- goto find_min;
-
- if (tab[mid].base_addr > offset)
- high = mid;
- else
- low = mid + 1;
- }
- ++mid;
-
- /* last entry is catch-all for all higher addresses: */
- if (offset < tab[mid].base_addr)
- return -1;
-
- find_min:
-
- while (mid > 0 && tab[mid - 1].base_addr == tab[mid].base_addr)
- --mid;
-
- return mid;
-}
-
-/* Do the work of find_nearest_line. */
-
-boolean
-_bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap,
- line_info, filename_ptr, functionname_ptr, retline_ptr)
- bfd *abfd;
- asection *section;
- bfd_vma offset;
- struct ecoff_debug_info * const debug_info;
- const struct ecoff_debug_swap * const debug_swap;
- struct ecoff_find_line *line_info;
- const char **filename_ptr;
- const char **functionname_ptr;
- unsigned int *retline_ptr;
-{
- struct ecoff_fdrtab_entry *tab;
- boolean stabs;
- FDR *fdr_ptr;
- int i;
-
- offset += section->vma;
-
- /* Build FDR table (sorted by object file's base-address) if we
- don't have it already. */
- if (line_info->fdrtab == NULL
- && !mk_fdrtab (abfd, debug_info, debug_swap, line_info))
- return false;
-
- tab = line_info->fdrtab;
-
- /* find first FDR for address OFFSET */
- i = fdrtab_lookup (line_info, offset);
- if (i < 0)
- return false; /* no FDR, no fun... */
- fdr_ptr = tab[i].fdr;
-
- /* Check whether this file has stabs debugging information. In a
- file with stabs debugging information, the second local symbol is
- named @stabs. */
- stabs = false;
- if (fdr_ptr->csym >= 2)
- {
- char *sym_ptr;
- SYMR sym;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 1) * debug_swap->external_sym_size);
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
- if (strcmp (debug_info->ss + fdr_ptr->issBase + sym.iss,
- STABS_SYMBOL) == 0)
- stabs = true;
- }
-
- if (!stabs)
- {
- bfd_size_type external_pdr_size;
- char *pdr_ptr;
- char *best_pdr = NULL;
- FDR *best_fdr;
- bfd_vma best_dist = ~0;
- PDR pdr;
- unsigned char *line_ptr;
- unsigned char *line_end;
- int lineno;
- /* This file uses ECOFF debugging information. Each FDR has a
- list of procedure descriptors (PDR). The address in the FDR
- is the absolute address of the first procedure. The address
- in the first PDR gives the offset of that procedure relative
- to the object file's base-address. The addresses in
- subsequent PDRs specify each procedure's address relative to
- the object file's base-address. To make things more juicy,
- whenever the PROF bit in the PDR is set, the real entry point
- of the procedure may be 16 bytes below what would normally be
- the procedure's entry point. Instead, DEC came up with a
- wicked scheme to create profiled libraries "on the fly":
- instead of shipping a regular and a profiled version of each
- library, they insert 16 bytes of unused space in front of
- each procedure and set the "prof" bit in the PDR to indicate
- that there is a gap there (this is done automagically by "as"
- when option "-pg" is specified). Thus, normally, you link
- against such a library and, except for lots of 16 byte gaps
- between functions, things will behave as usual. However,
- when invoking "ld" with option "-pg", it will fill those gaps
- with code that calls mcount(). It then moves the function's
- entry point down by 16 bytes, and out pops a binary that has
- all functions profiled.
-
- NOTE: Neither FDRs nor PDRs are strictly sorted in memory
- order. For example, when including header-files that
- define functions, the FDRs follow behind the including
- file, even though their code may have been generated at
- a lower address. File coff-alpha.c from libbfd
- illustrates this (use "odump -PFv" to look at a file's
- FDR/PDR). Similarly, PDRs are sometimes out of order
- as well. An example of this is OSF/1 v3.0 libc's
- malloc.c. I'm not sure why this happens, but it could
- be due to optimizations that reorder a function's
- position within an object-file.
-
- Strategy:
-
- On the first call to this function, we build a table of FDRs
- that is sorted by the base-address of the object-file the FDR
- is referring to. Notice that each object-file may contain
- code from multiple source files (e.g., due to code defined in
- include files). Thus, for any given base-address, there may
- be multiple FDRs (but this case is, fortunately, uncommon).
- lookup(addr) guarantees to return the first FDR that applies
- to address ADDR. Thus, after invoking lookup(), we have a
- list of FDRs that may contain the PDR for ADDR. Next, we
- walk through the PDRs of these FDRs and locate the one that
- is closest to ADDR (i.e., for which the difference between
- ADDR and the PDR's entry point is positive and minimal).
- Once, the right FDR and PDR are located, we simply walk
- through the line-number table to lookup the line-number that
- best matches ADDR. Obviously, things could be sped up by
- keeping a sorted list of PDRs instead of a sorted list of
- FDRs. However, this would increase space requirements
- considerably, which is undesirable. */
- external_pdr_size = debug_swap->external_pdr_size;
-
- /* Make offset relative to object file's start-address: */
- offset -= tab[i].base_addr;
- /* Search FDR list starting at tab[i] for the PDR that best matches
- OFFSET. Normally, the FDR list is only one entry long. */
- best_fdr = NULL;
- do
- {
- bfd_vma dist, min_dist = 0;
- char *pdr_hold;
- char *pdr_end;
-
- fdr_ptr = tab[i].fdr;
-
- pdr_ptr = ((char *) debug_info->external_pdr
- + fdr_ptr->ipdFirst * external_pdr_size);
- pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* Find PDR that is closest to OFFSET. If pdr.prof is set,
- the procedure entry-point *may* be 0x10 below pdr.adr. We
- simply pretend that pdr.prof *implies* a lower entry-point.
- This is safe because it just means that may identify 4 NOPs
- in front of the function as belonging to the function. */
- for (pdr_hold = NULL;
- pdr_ptr < pdr_end;
- (pdr_ptr += external_pdr_size,
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr)))
- {
- if (offset >= (pdr.adr - 0x10 * pdr.prof))
- {
- dist = offset - (pdr.adr - 0x10 * pdr.prof);
- if (!pdr_hold || dist < min_dist)
- {
- min_dist = dist;
- pdr_hold = pdr_ptr;
- }
- }
- }
-
- if (!best_pdr || min_dist < best_dist)
- {
- best_dist = min_dist;
- best_fdr = fdr_ptr;
- best_pdr = pdr_hold;
- }
- /* continue looping until base_addr of next entry is different: */
- }
- while (++i < line_info->fdrtab_len
- && tab[i].base_addr == tab[i - 1].base_addr);
-
- if (!best_fdr || !best_pdr)
- return false; /* shouldn't happen... */
-
- /* phew, finally we got something that we can hold onto: */
- fdr_ptr = best_fdr;
- pdr_ptr = best_pdr;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- /* Now we can look for the actual line number. The line numbers
- are stored in a very funky format, which I won't try to
- describe. The search is bounded by the end of the FDRs line
- number entries. */
- line_end = debug_info->line + fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
-
- /* Make offset relative to procedure entry: */
- offset -= pdr.adr - 0x10 * pdr.prof;
- lineno = pdr.lnLow;
- line_ptr = debug_info->line + fdr_ptr->cbLineOffset + pdr.cbLineOffset;
- while (line_ptr < line_end)
- {
- int delta;
- unsigned int count;
-
- delta = *line_ptr >> 4;
- if (delta >= 0x8)
- delta -= 0x10;
- count = (*line_ptr & 0xf) + 1;
- ++line_ptr;
- if (delta == -8)
- {
- delta = (((line_ptr[0]) & 0xff) << 8) + ((line_ptr[1]) & 0xff);
- if (delta >= 0x8000)
- delta -= 0x10000;
- line_ptr += 2;
- }
- lineno += delta;
- if (offset < count * 4)
- break;
- offset -= count * 4;
- }
-
- /* If fdr_ptr->rss is -1, then this file does not have full
- symbols, at least according to gdb/mipsread.c. */
- if (fdr_ptr->rss == -1)
- {
- *filename_ptr = NULL;
- if (pdr.isym == -1)
- *functionname_ptr = NULL;
- else
- {
- EXTR proc_ext;
-
- (*debug_swap->swap_ext_in)
- (abfd,
- ((char *) debug_info->external_ext
- + pdr.isym * debug_swap->external_ext_size),
- &proc_ext);
- *functionname_ptr = debug_info->ssext + proc_ext.asym.iss;
- }
- }
- else
- {
- SYMR proc_sym;
-
- *filename_ptr = debug_info->ss + fdr_ptr->issBase + fdr_ptr->rss;
- (*debug_swap->swap_sym_in)
- (abfd,
- ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + pdr.isym) * debug_swap->external_sym_size),
- &proc_sym);
- *functionname_ptr = debug_info->ss + fdr_ptr->issBase + proc_sym.iss;
- }
- if (lineno == ilineNil)
- lineno = 0;
- *retline_ptr = lineno;
- }
- else
- {
- bfd_size_type external_sym_size;
- const char *directory_name;
- const char *main_file_name;
- const char *current_file_name;
- const char *function_name;
- const char *line_file_name;
- bfd_vma low_func_vma;
- bfd_vma low_line_vma;
- boolean past_line;
- boolean past_fn;
- char *sym_ptr, *sym_ptr_end;
- size_t len, funclen;
- char *buffer = NULL;
-
- /* This file uses stabs debugging information. When gcc is not
- optimizing, it will put the line number information before
- the function name stabs entry. When gcc is optimizing, it
- will put the stabs entry for all the function first, followed
- by the line number information. (This appears to happen
- because of the two output files used by the -mgpopt switch,
- which is implied by -O). This means that we must keep
- looking through the symbols until we find both a line number
- and a function name which are beyond the address we want. */
-
- *filename_ptr = NULL;
- *functionname_ptr = NULL;
- *retline_ptr = 0;
-
- directory_name = NULL;
- main_file_name = NULL;
- current_file_name = NULL;
- function_name = NULL;
- line_file_name = NULL;
- low_func_vma = 0;
- low_line_vma = 0;
- past_line = false;
- past_fn = false;
-
- external_sym_size = debug_swap->external_sym_size;
-
- sym_ptr = ((char *) debug_info->external_sym
- + (fdr_ptr->isymBase + 2) * external_sym_size);
- sym_ptr_end = sym_ptr + (fdr_ptr->csym - 2) * external_sym_size;
- for (;
- sym_ptr < sym_ptr_end && (! past_line || ! past_fn);
- sym_ptr += external_sym_size)
- {
- SYMR sym;
-
- (*debug_swap->swap_sym_in) (abfd, sym_ptr, &sym);
-
- if (ECOFF_IS_STAB (&sym))
- {
- switch (ECOFF_UNMARK_STAB (sym.index))
- {
- case N_SO:
- main_file_name = current_file_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
-
- /* Check the next symbol to see if it is also an
- N_SO symbol. */
- if (sym_ptr + external_sym_size < sym_ptr_end)
- {
- SYMR nextsym;
-
- (*debug_swap->swap_sym_in) (abfd,
- sym_ptr + external_sym_size,
- &nextsym);
- if (ECOFF_IS_STAB (&nextsym)
- && ECOFF_UNMARK_STAB (nextsym.index) == N_SO)
- {
- directory_name = current_file_name;
- main_file_name = current_file_name =
- debug_info->ss + fdr_ptr->issBase + nextsym.iss;
- sym_ptr += external_sym_size;
- }
- }
- break;
-
- case N_SOL:
- current_file_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
- break;
-
- case N_FUN:
- if (sym.value > offset)
- past_fn = true;
- else if (sym.value >= low_func_vma)
- {
- low_func_vma = sym.value;
- function_name =
- debug_info->ss + fdr_ptr->issBase + sym.iss;
- }
- break;
- }
- }
- else if (sym.st == stLabel && sym.index != indexNil)
- {
- if (sym.value > offset)
- past_line = true;
- else if (sym.value >= low_line_vma)
- {
- low_line_vma = sym.value;
- line_file_name = current_file_name;
- *retline_ptr = sym.index;
- }
- }
- }
-
- if (*retline_ptr != 0)
- main_file_name = line_file_name;
-
- /* We need to remove the stuff after the colon in the function
- name. We also need to put the directory name and the file
- name together. */
- if (function_name == NULL)
- len = funclen = 0;
- else
- len = funclen = strlen (function_name) + 1;
-
- if (main_file_name != NULL
- && directory_name != NULL
- && main_file_name[0] != '/')
- len += strlen (directory_name) + strlen (main_file_name) + 1;
-
- if (len != 0)
- {
- if (line_info->find_buffer != NULL)
- free (line_info->find_buffer);
- buffer = (char *) bfd_malloc (len);
- if (buffer == NULL)
- return false;
- line_info->find_buffer = buffer;
- }
-
- if (function_name != NULL)
- {
- char *colon;
-
- strcpy (buffer, function_name);
- colon = strchr (buffer, ':');
- if (colon != NULL)
- *colon = '\0';
- *functionname_ptr = buffer;
- }
-
- if (main_file_name != NULL)
- {
- if (directory_name == NULL || main_file_name[0] == '/')
- *filename_ptr = main_file_name;
- else
- {
- sprintf (buffer + funclen, "%s%s", directory_name,
- main_file_name);
- *filename_ptr = buffer + funclen;
- }
- }
- }
-
- return true;
-}
-
-/* These routines copy symbolic information into a memory buffer.
-
- FIXME: The whole point of the shuffle code is to avoid storing
- everything in memory, since the linker is such a memory hog. This
- code makes that effort useless. It is only called by the MIPS ELF
- code when generating a shared library, so it is not that big a
- deal, but it should be fixed eventually. */
-
-/* Collect a shuffle into a memory buffer. */
-
-static boolean ecoff_collect_shuffle PARAMS ((struct shuffle *, bfd_byte *));
-
-static boolean
-ecoff_collect_shuffle (l, buff)
- struct shuffle *l;
- bfd_byte *buff;
-{
- unsigned long total;
-
- total = 0;
- for (; l != (struct shuffle *) NULL; l = l->next)
- {
- if (! l->filep)
- memcpy (buff, l->u.memory, l->size);
- else
- {
- if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (buff, 1, l->size, l->u.file.input_bfd) != l->size)
- return false;
- }
- total += l->size;
- buff += l->size;
- }
-
- return true;
-}
-
-/* Copy PDR information into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_pdr (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- return ecoff_collect_shuffle (ainfo->pdr, buff);
-}
-
-/* Copy symbol information into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_sym (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
-
- return ecoff_collect_shuffle (ainfo->sym, buff);
-}
-
-/* Copy the string table into a memory buffer. */
-
-boolean
-_bfd_ecoff_get_accumulated_ss (handle, buff)
- PTR handle;
- bfd_byte *buff;
-{
- struct accumulate *ainfo = (struct accumulate *) handle;
- struct string_hash_entry *sh;
- unsigned long total;
-
- /* The string table is written out from the hash table if this is a
- final link. */
- BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
- *buff++ = '\0';
- total = 1;
- BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
- for (sh = ainfo->ss_hash;
- sh != (struct string_hash_entry *) NULL;
- sh = sh->next)
- {
- size_t len;
-
- len = strlen (sh->root.string);
- memcpy (buff, (PTR) sh->root.string, len + 1);
- total += len + 1;
- buff += len + 1;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/elf-bfd.h b/contrib/gdb/bfd/elf-bfd.h
deleted file mode 100644
index ee38e5b..0000000
--- a/contrib/gdb/bfd/elf-bfd.h
+++ /dev/null
@@ -1,858 +0,0 @@
-/* BFD back-end data structures for ELF files.
- Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _LIBELF_H_
-#define _LIBELF_H_ 1
-
-#include "elf/common.h"
-#include "elf/internal.h"
-#include "elf/external.h"
-#include "bfdlink.h"
-
-/* If size isn't specified as 64 or 32, NAME macro should fail. */
-#ifndef NAME
-#if ARCH_SIZE==64
-#define NAME(x,y) CAT4(x,64,_,y)
-#endif
-#if ARCH_SIZE==32
-#define NAME(x,y) CAT4(x,32,_,y)
-#endif
-#endif
-
-#ifndef NAME
-#define NAME(x,y) CAT4(x,NOSIZE,_,y)
-#endif
-
-#define ElfNAME(X) NAME(Elf,X)
-#define elfNAME(X) NAME(elf,X)
-
-/* Information held for an ELF symbol. The first field is the
- corresponding asymbol. Every symbol is an ELF file is actually a
- pointer to this structure, although it is often handled as a
- pointer to an asymbol. */
-
-typedef struct
-{
- /* The BFD symbol. */
- asymbol symbol;
- /* ELF symbol information. */
- Elf_Internal_Sym internal_elf_sym;
- /* Backend specific information. */
- union
- {
- unsigned int hppa_arg_reloc;
- PTR mips_extr;
- PTR any;
- }
- tc_data;
-} elf_symbol_type;
-
-/* ELF linker hash table entries. */
-
-struct elf_link_hash_entry
-{
- struct bfd_link_hash_entry root;
-
- /* Symbol index in output file. This is initialized to -1. It is
- set to -2 if the symbol is used by a reloc. */
- long indx;
-
- /* Symbol size. */
- bfd_size_type size;
-
- /* Symbol index as a dynamic symbol. Initialized to -1, and remains
- -1 if this is not a dynamic symbol. */
- long dynindx;
-
- /* String table index in .dynstr if this is a dynamic symbol. */
- unsigned long dynstr_index;
-
- /* If this is a weak defined symbol from a dynamic object, this
- field points to a defined symbol with the same value, if there is
- one. Otherwise it is NULL. */
- struct elf_link_hash_entry *weakdef;
-
- /* If this symbol requires an entry in the global offset table, the
- processor specific backend uses this field to hold the offset
- into the .got section. If this field is -1, then the symbol does
- not require a global offset table entry. */
- bfd_vma got_offset;
-
- /* If this symbol requires an entry in the procedure linkage table,
- the processor specific backend uses these two fields to hold the
- offset into the procedure linkage section and the offset into the
- .got section. If plt_offset is -1, then the symbol does not
- require an entry in the procedure linkage table. */
- bfd_vma plt_offset;
-
- /* If this symbol is used in the linker created sections, the processor
- specific backend uses this field to map the field into the offset
- from the beginning of the section. */
- struct elf_linker_section_pointers *linker_section_pointer;
-
- /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
- char type;
-
- /* Some flags; legal values follow. */
- unsigned char elf_link_hash_flags;
- /* Symbol is referenced by a non-shared object. */
-#define ELF_LINK_HASH_REF_REGULAR 01
- /* Symbol is defined by a non-shared object. */
-#define ELF_LINK_HASH_DEF_REGULAR 02
- /* Symbol is referenced by a shared object. */
-#define ELF_LINK_HASH_REF_DYNAMIC 04
- /* Symbol is defined by a shared object. */
-#define ELF_LINK_HASH_DEF_DYNAMIC 010
- /* Dynamic symbol has been adjustd. */
-#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 020
- /* Symbol needs a copy reloc. */
-#define ELF_LINK_HASH_NEEDS_COPY 040
- /* Symbol needs a procedure linkage table entry. */
-#define ELF_LINK_HASH_NEEDS_PLT 0100
- /* Symbol appears in a non-ELF input file. */
-#define ELF_LINK_NON_ELF 0200
- /* Note: If you add more flags, you must change the type of
- elf_link_hash_flags. */
-};
-
-/* ELF linker hash table. */
-
-struct elf_link_hash_table
-{
- struct bfd_link_hash_table root;
- /* Whether we have created the special dynamic sections required
- when linking against or generating a shared object. */
- boolean dynamic_sections_created;
- /* The BFD used to hold special sections created by the linker.
- This will be the first BFD found which requires these sections to
- be created. */
- bfd *dynobj;
- /* The number of symbols found in the link which must be put into
- the .dynsym section. */
- bfd_size_type dynsymcount;
- /* The string table of dynamic symbols, which becomes the .dynstr
- section. */
- struct bfd_strtab_hash *dynstr;
- /* The number of buckets in the hash table in the .hash section.
- This is based on the number of dynamic symbols. */
- bfd_size_type bucketcount;
- /* A linked list of DT_NEEDED names found in dynamic objects
- included in the link. */
- struct bfd_link_needed_list *needed;
-};
-
-/* Look up an entry in an ELF linker hash table. */
-
-#define elf_link_hash_lookup(table, string, create, copy, follow) \
- ((struct elf_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-/* Traverse an ELF linker hash table. */
-
-#define elf_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the ELF linker hash table from a link_info structure. */
-
-#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
-
-/* Constant information held for an ELF backend. */
-
-struct elf_size_info {
- unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
- unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
-
- unsigned char arch_size, file_align;
- unsigned char elfclass, ev_current;
- int (*write_out_phdrs) PARAMS ((bfd *, Elf_Internal_Phdr *, int));
- boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
- void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
- void (*swap_symbol_out) PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
- boolean (*slurp_reloc_table) PARAMS ((bfd *, asection *, asymbol **));
- long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
- void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-};
-
-#define elf_symbol_from(ABFD,S) \
- (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
- && (S)->the_bfd->tdata.elf_obj_data != 0) \
- ? (elf_symbol_type *) (S) \
- : 0)
-
-struct elf_backend_data
-{
- /* Whether the backend uses REL or RELA relocations. FIXME: some
- ELF backends use both. When we need to support one, this whole
- approach will need to be changed. */
- int use_rela_p;
-
- /* The architecture for this backend. */
- enum bfd_architecture arch;
-
- /* The ELF machine code (EM_xxxx) for this backend. */
- int elf_machine_code;
-
- /* The maximum page size for this backend. */
- bfd_vma maxpagesize;
-
- /* This is true if the linker should act like collect and gather
- global constructors and destructors by name. This is true for
- MIPS ELF because the Irix 5 tools can not handle the .init
- section. */
- boolean collect;
-
- /* This is true if the linker should ignore changes to the type of a
- symbol. This is true for MIPS ELF because some Irix 5 objects
- record undefined functions as STT_OBJECT although the definitions
- are STT_FUNC. */
- boolean type_change_ok;
-
- /* A function to translate an ELF RELA relocation to a BFD arelent
- structure. */
- void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
-
- /* A function to translate an ELF REL relocation to a BFD arelent
- structure. */
- void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rel *));
-
- /* A function to determine whether a symbol is global when
- partitioning the symbol table into local and global symbols.
- This should be NULL for most targets, in which case the correct
- thing will be done. MIPS ELF, at least on the Irix 5, has
- special requirements. */
- boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
-
- /* The remaining functions are hooks which are called only if they
- are not NULL. */
-
- /* A function to permit a backend specific check on whether a
- particular BFD format is relevant for an object file, and to
- permit the backend to set any global information it wishes. When
- this is called elf_elfheader is set, but anything else should be
- used with caution. If this returns false, the check_format
- routine will return a bfd_error_wrong_format error. */
- boolean (*elf_backend_object_p) PARAMS ((bfd *));
-
- /* A function to do additional symbol processing when reading the
- ELF symbol table. This is where any processor-specific special
- section indices are handled. */
- void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
-
- /* A function to do additional symbol processing after reading the
- entire ELF symbol table. */
- boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
- elf_symbol_type *,
- unsigned int));
-
- /* A function to do additional processing on the ELF section header
- just before writing it out. This is used to set the flags and
- type fields for some sections, or to actually write out data for
- unusual sections. */
- boolean (*elf_backend_section_processing) PARAMS ((bfd *,
- Elf32_Internal_Shdr *));
-
- /* A function to handle unusual section types when creating BFD
- sections from ELF sections. */
- boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
- Elf32_Internal_Shdr *,
- char *));
-
- /* A function to set up the ELF section header for a BFD section in
- preparation for writing it out. This is where the flags and type
- fields are set for unusual sections. */
- boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
- asection *));
-
- /* A function to get the ELF section index for a BFD section. If
- this returns true, the section was found. If it is a normal ELF
- section, *RETVAL should be left unchanged. If it is not a normal
- ELF section *RETVAL should be set to the SHN_xxxx index. */
- boolean (*elf_backend_section_from_bfd_section)
- PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
-
- /* If this field is not NULL, it is called by the add_symbols phase
- of a link just before adding a symbol to the global linker hash
- table. It may modify any of the fields as it wishes. If *NAME
- is set to NULL, the symbol will be skipped rather than being
- added to the hash table. This function is responsible for
- handling all processor dependent symbol bindings and section
- indices, and must set at least *FLAGS and *SEC for each processor
- dependent case; failure to do so will cause a link error. */
- boolean (*elf_add_symbol_hook)
- PARAMS ((bfd *abfd, struct bfd_link_info *info,
- const Elf_Internal_Sym *, const char **name,
- flagword *flags, asection **sec, bfd_vma *value));
-
- /* If this field is not NULL, it is called by the elf_link_output_sym
- phase of a link for each symbol which will appear in the object file. */
- boolean (*elf_backend_link_output_symbol_hook)
- PARAMS ((bfd *, struct bfd_link_info *info, const char *,
- Elf_Internal_Sym *, asection *));
-
- /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
- linker the first time it encounters a dynamic object in the link.
- This function must create any sections required for dynamic
- linking. The ABFD argument is a dynamic object. The .interp,
- .dynamic, .dynsym, .dynstr, and .hash functions have already been
- created, and this function may modify the section flags if
- desired. This function will normally create the .got and .plt
- sections, but different backends have different requirements. */
- boolean (*elf_backend_create_dynamic_sections)
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-
- /* The CHECK_RELOCS function is called by the add_symbols phase of
- the ELF backend linker. It is called once for each section with
- relocs of an object file, just after the symbols for the object
- file have been added to the global linker hash table. The
- function must look through the relocs and do any special handling
- required. This generally means allocating space in the global
- offset table, and perhaps allocating space for a reloc. The
- relocs are always passed as Rela structures; if the section
- actually uses Rel structures, the r_addend field will always be
- zero. */
- boolean (*check_relocs)
- PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
- const Elf_Internal_Rela *relocs));
-
- /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
- linker for every symbol which is defined by a dynamic object and
- referenced by a regular object. This is called after all the
- input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
- function has been called. The hash table entry should be
- bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
- defined in a section from a dynamic object. Dynamic object
- sections are not included in the final link, and this function is
- responsible for changing the value to something which the rest of
- the link can deal with. This will normally involve adding an
- entry to the .plt or .got or some such section, and setting the
- symbol to point to that. */
- boolean (*elf_backend_adjust_dynamic_symbol)
- PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
-
- /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
- linker after all the linker input files have been seen but before
- the sections sizes have been set. This is called after
- ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
- It is only called when linking against a dynamic object. It must
- set the sizes of the dynamic sections, and may fill in their
- contents as well. The generic ELF linker can handle the .dynsym,
- .dynstr and .hash sections. This function must handle the
- .interp section and any sections created by the
- CREATE_DYNAMIC_SECTIONS entry point. */
- boolean (*elf_backend_size_dynamic_sections)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
-
- /* The RELOCATE_SECTION function is called by the ELF backend linker
- to handle the relocations for a section.
-
- The relocs are always passed as Rela structures; if the section
- actually uses Rel structures, the r_addend field will always be
- zero.
-
- This function is responsible for adjust the section contents as
- necessary, and (if using Rela relocs and generating a
- relocateable output file) adjusting the reloc addend as
- necessary.
-
- This function does not have to worry about setting the reloc
- address or the reloc symbol index.
-
- LOCAL_SYMS is a pointer to the swapped in local symbols.
-
- LOCAL_SECTIONS is an array giving the section in the input file
- corresponding to the st_shndx field of each local symbol.
-
- The global hash table entry for the global symbols can be found
- via elf_sym_hashes (input_bfd).
-
- When generating relocateable output, this function must handle
- STB_LOCAL/STT_SECTION symbols specially. The output symbol is
- going to be the section symbol corresponding to the output
- section, which means that the addend must be adjusted
- accordingly. */
- boolean (*elf_backend_relocate_section)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
- bfd *input_bfd, asection *input_section, bfd_byte *contents,
- Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
- asection **local_sections));
-
- /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
- linker just before it writes a symbol out to the .dynsym section.
- The processor backend may make any required adjustment to the
- symbol. It may also take the opportunity to set contents of the
- dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
- all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
- on those symbols which are defined by a dynamic object. */
- boolean (*elf_backend_finish_dynamic_symbol)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
- struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
-
- /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
- linker just before it writes all the dynamic sections out to the
- output file. The FINISH_DYNAMIC_SYMBOL will have been called on
- all dynamic symbols. */
- boolean (*elf_backend_finish_dynamic_sections)
- PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
-
- /* A function to do any beginning processing needed for the ELF file
- before building the ELF headers and computing file positions. */
- void (*elf_backend_begin_write_processing)
- PARAMS ((bfd *, struct bfd_link_info *));
-
- /* A function to do any final processing needed for the ELF file
- before writing it out. The LINKER argument is true if this BFD
- was created by the ELF backend linker. */
- void (*elf_backend_final_write_processing)
- PARAMS ((bfd *, boolean linker));
-
- /* This function is called by get_program_header_size. It should
- return the number of additional program segments which this BFD
- will need. It should return -1 on error. */
- int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
-
- /* This function is called to modify an existing segment map in a
- backend specific fashion. */
- boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
-
- /* The swapping table to use when dealing with ECOFF information.
- Used for the MIPS ELF .mdebug section. */
- const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
-
- /* Alternate EM_xxxx machine codes for this backend. */
- int elf_machine_alt1;
- int elf_machine_alt2;
-
- const struct elf_size_info *s;
-
- unsigned want_got_plt : 1;
- unsigned plt_readonly : 1;
- unsigned want_plt_sym : 1;
-};
-
-/* Information stored for each BFD section in an ELF file. This
- structure is allocated by elf_new_section_hook. */
-
-struct bfd_elf_section_data
-{
- /* The ELF header for this section. */
- Elf_Internal_Shdr this_hdr;
- /* The ELF header for the reloc section associated with this
- section, if any. */
- Elf_Internal_Shdr rel_hdr;
- /* The ELF section number of this section. Only used for an output
- file. */
- int this_idx;
- /* The ELF section number of the reloc section associated with this
- section, if any. Only used for an output file. */
- int rel_idx;
- /* Used by the backend linker to store the symbol hash table entries
- associated with relocs against global symbols. */
- struct elf_link_hash_entry **rel_hashes;
- /* A pointer to the swapped relocs. If the section uses REL relocs,
- rather than RELA, all the r_addend fields will be zero. This
- pointer may be NULL. It is used by the backend linker. */
- Elf_Internal_Rela *relocs;
- /* Used by the backend linker when generating a shared library to
- record the dynamic symbol index for a section symbol
- corresponding to this section. */
- long dynindx;
- /* A pointer available for the processor specific ELF backend. */
- PTR tdata;
-};
-
-#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
-
-#define get_elf_backend_data(abfd) \
- ((struct elf_backend_data *) (abfd)->xvec->backend_data)
-
-/* Enumeration to specify the special section. */
-typedef enum elf_linker_section_enum
-{
- LINKER_SECTION_UNKNOWN, /* not used */
- LINKER_SECTION_GOT, /* .got section for global offset pointers */
- LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
- LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
- LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
- LINKER_SECTION_MAX /* # of linker sections */
-} elf_linker_section_enum_t;
-
-/* Sections created by the linker. */
-
-typedef struct elf_linker_section
-{
- char *name; /* name of the section */
- char *rel_name; /* name of the associated .rel{,a}. section */
- char *bss_name; /* name of a related .bss section */
- char *sym_name; /* name of symbol to reference this section */
- asection *section; /* pointer to the section */
- asection *bss_section; /* pointer to the bss section associated with this */
- asection *rel_section; /* pointer to the relocations needed for this section */
- struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
- bfd_vma initial_size; /* initial size before any linker generated allocations */
- bfd_vma sym_offset; /* offset of symbol from beginning of section */
- bfd_vma hole_size; /* size of reserved address hole in allocation */
- bfd_vma hole_offset; /* current offset for the hole */
- bfd_vma max_hole_offset; /* maximum offset for the hole */
- elf_linker_section_enum_t which; /* which section this is */
- boolean hole_written_p; /* whether the hole has been initialized */
- int alignment; /* alignment for the section */
- flagword flags; /* flags to use to create the section */
-} elf_linker_section_t;
-
-/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
- provides allows us to return different pointers, based on different addend's. */
-
-typedef struct elf_linker_section_pointers
-{
- struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
- bfd_vma offset; /* offset of pointer from beginning of section */
- bfd_signed_vma addend; /* addend used */
- elf_linker_section_enum_t which; /* which linker section this is */
- boolean written_address_p; /* whether address was written yet */
-} elf_linker_section_pointers_t;
-
-/* Some private data is stashed away for future use using the tdata pointer
- in the bfd structure. */
-
-struct elf_obj_tdata
-{
- Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
- Elf_Internal_Shdr **elf_sect_ptr;
- Elf_Internal_Phdr *phdr;
- struct elf_segment_map *segment_map;
- struct bfd_strtab_hash *strtab_ptr;
- int num_locals;
- int num_globals;
- asymbol **section_syms; /* STT_SECTION symbols for each section */
- Elf_Internal_Shdr symtab_hdr;
- Elf_Internal_Shdr shstrtab_hdr;
- Elf_Internal_Shdr strtab_hdr;
- Elf_Internal_Shdr dynsymtab_hdr;
- Elf_Internal_Shdr dynstrtab_hdr;
- unsigned int symtab_section, shstrtab_section;
- unsigned int strtab_section, dynsymtab_section;
- file_ptr next_file_pos;
- void *prstatus; /* The raw /proc prstatus structure */
- void *prpsinfo; /* The raw /proc prpsinfo structure */
- bfd_vma gp; /* The gp value (MIPS only, for now) */
- unsigned int gp_size; /* The gp size (MIPS only, for now) */
-
- /* This is set to true if the object was created by the backend
- linker. */
- boolean linker;
-
- /* A mapping from external symbols to entries in the linker hash
- table, used when linking. This is indexed by the symbol index
- minus the sh_info field of the symbol table header. */
- struct elf_link_hash_entry **sym_hashes;
-
- /* A mapping from local symbols to offsets into the global offset
- table, used when linking. This is indexed by the symbol index. */
- bfd_vma *local_got_offsets;
-
- /* A mapping from local symbols to offsets into the various linker
- sections added. This is index by the symbol index. */
- elf_linker_section_pointers_t **linker_section_pointers;
-
- /* The linker ELF emulation code needs to let the backend ELF linker
- know what filename should be used for a dynamic object if the
- dynamic object is found using a search. The emulation code then
- sometimes needs to know what name was actually used. Until the
- file has been added to the linker symbol table, this field holds
- the name the linker wants. After it has been added, it holds the
- name actually used, which will be the DT_SONAME entry if there is
- one. */
- const char *dt_name;
-
- /* Irix 5 often screws up the symbol table, sorting local symbols
- after global symbols. This flag is set if the symbol table in
- this BFD appears to be screwed up. If it is, we ignore the
- sh_info field in the symbol table header, and always read all the
- symbols. */
- boolean bad_symtab;
-
- /* Records the result of `get_program_header_size'. */
- bfd_size_type program_header_size;
-
- /* Used by find_nearest_line entry point. */
- PTR line_info;
-
- /* Used by MIPS ELF find_nearest_line entry point. The structure
- could be included directly in this one, but there's no point to
- wasting the memory just for the infrequently called
- find_nearest_line. */
- struct mips_elf_find_line *find_line_info;
-
- /* Used to determine if the e_flags field has been initialized */
- boolean flags_init;
-
- /* Linker sections that we are interested in. */
- struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
-};
-
-#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
-#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
-#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
-#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
-#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
-#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
-#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
-#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
-#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
-#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
-#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
-#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
-#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
-#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
-#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got_offsets)
-#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
-#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
-#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
-#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
-#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
-
-extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
-extern char *bfd_elf_string_from_elf_section
- PARAMS ((bfd *, unsigned, unsigned));
-extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
-
-extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
-extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
- bfd_print_symbol_type));
-#define elf_string_from_elf_strtab(abfd,strindex) \
- bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
-
-#define bfd_elf32_print_symbol bfd_elf_print_symbol
-#define bfd_elf64_print_symbol bfd_elf_print_symbol
-#define bfd_elf32_mkobject bfd_elf_mkobject
-#define bfd_elf64_mkobject bfd_elf_mkobject
-#define elf_mkobject bfd_elf_mkobject
-
-extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *));
-
-extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
- arelent *,
- asymbol *,
- PTR,
- asection *,
- bfd *,
- char **));
-extern boolean bfd_elf_mkobject PARAMS ((bfd *));
-extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
-extern boolean _bfd_elf_make_section_from_shdr
- PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
-extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_elf_link_hash_table_init
- PARAMS ((struct elf_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-extern boolean _bfd_elf_copy_private_symbol_data
- PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
-extern boolean _bfd_elf_copy_private_section_data
- PARAMS ((bfd *, asection *, bfd *, asection *));
-extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
-extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr,
- bfd_size_type));
-extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
- arelent **, asymbol **));
-extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
-extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *));
-extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
-extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
-extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
- asymbol **,
- bfd_vma, CONST char **,
- CONST char **,
- unsigned int *));
-#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
-#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
-extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
-
-/* If the target doesn't have reloc handling written yet: */
-extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
-
-asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
-boolean
-_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
- struct elf_link_hash_entry *));
-boolean
-_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
- struct bfd_link_info *));
-void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
-file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
- file_ptr,
- boolean));
-
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-boolean _bfd_elf_create_got_section PARAMS ((bfd *,
- struct bfd_link_info *));
-
-elf_linker_section_t *_bfd_elf_create_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- enum elf_linker_section_enum,
- elf_linker_section_t *defaults));
-
-elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
- PARAMS ((elf_linker_section_pointers_t *linker_pointers,
- bfd_signed_vma addend,
- elf_linker_section_enum_t which));
-
-boolean bfd_elf32_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf32_Internal_Rela *rel));
-
-bfd_vma bfd_elf32_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf32_Internal_Rela *rel,
- int relative_reloc));
-
-boolean bfd_elf64_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf64_Internal_Rela *rel));
-
-bfd_vma bfd_elf64_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf64_Internal_Rela *rel,
- int relative_reloc));
-
-boolean _bfd_elf_make_linker_section_rela
- PARAMS ((bfd *dynobj,
- elf_linker_section_t *lsect,
- int alignment));
-
-extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
-
-extern boolean bfd_elf32_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf32_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern void bfd_elf32_swap_symbol_in
- PARAMS ((bfd *, Elf32_External_Sym *, Elf_Internal_Sym *));
-extern void bfd_elf32_swap_symbol_out
- PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
-extern void bfd_elf32_swap_reloc_in
- PARAMS ((bfd *, Elf32_External_Rel *, Elf_Internal_Rel *));
-extern void bfd_elf32_swap_reloc_out
- PARAMS ((bfd *, Elf_Internal_Rel *, Elf32_External_Rel *));
-extern void bfd_elf32_swap_reloca_in
- PARAMS ((bfd *, Elf32_External_Rela *, Elf_Internal_Rela *));
-extern void bfd_elf32_swap_reloca_out
- PARAMS ((bfd *, Elf_Internal_Rela *, Elf32_External_Rela *));
-extern void bfd_elf32_swap_phdr_in
- PARAMS ((bfd *, Elf32_External_Phdr *, Elf_Internal_Phdr *));
-extern void bfd_elf32_swap_phdr_out
- PARAMS ((bfd *, Elf_Internal_Phdr *, Elf32_External_Phdr *));
-extern void bfd_elf32_swap_dyn_in
- PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-extern void bfd_elf32_swap_dyn_out
- PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf32_External_Dyn *));
-extern boolean bfd_elf32_add_dynamic_entry
- PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
-extern boolean bfd_elf32_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
-extern boolean bfd_elf64_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf64_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern void bfd_elf64_swap_symbol_in
- PARAMS ((bfd *, Elf64_External_Sym *, Elf_Internal_Sym *));
-extern void bfd_elf64_swap_symbol_out
- PARAMS ((bfd *, Elf_Internal_Sym *, PTR));
-extern void bfd_elf64_swap_reloc_in
- PARAMS ((bfd *, Elf64_External_Rel *, Elf_Internal_Rel *));
-extern void bfd_elf64_swap_reloc_out
- PARAMS ((bfd *, Elf_Internal_Rel *, Elf64_External_Rel *));
-extern void bfd_elf64_swap_reloca_in
- PARAMS ((bfd *, Elf64_External_Rela *, Elf_Internal_Rela *));
-extern void bfd_elf64_swap_reloca_out
- PARAMS ((bfd *, Elf_Internal_Rela *, Elf64_External_Rela *));
-extern void bfd_elf64_swap_phdr_in
- PARAMS ((bfd *, Elf64_External_Phdr *, Elf_Internal_Phdr *));
-extern void bfd_elf64_swap_phdr_out
- PARAMS ((bfd *, Elf_Internal_Phdr *, Elf64_External_Phdr *));
-extern void bfd_elf64_swap_dyn_in
- PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-extern void bfd_elf64_swap_dyn_out
- PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf64_External_Dyn *));
-extern boolean bfd_elf64_add_dynamic_entry
- PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
-extern boolean bfd_elf64_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-#define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-#define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-
-#endif /* _LIBELF_H_ */
diff --git a/contrib/gdb/bfd/elf.c b/contrib/gdb/bfd/elf.c
deleted file mode 100644
index 981d3ee..0000000
--- a/contrib/gdb/bfd/elf.c
+++ /dev/null
@@ -1,3318 +0,0 @@
-/* ELF executable support for BFD.
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-
-SECTION
- ELF backends
-
- BFD support for ELF formats is being worked on.
- Currently, the best supported back ends are for sparc and i386
- (running svr4 or Solaris 2).
-
- Documentation of the internals of the support code still needs
- to be written. The code is changing quickly enough that we
- haven't bothered yet.
- */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#define ARCH_SIZE 0
-#include "elf-bfd.h"
-
-static INLINE struct elf_segment_map *make_mapping
- PARAMS ((bfd *, asection **, unsigned int, unsigned int, boolean));
-static int elf_sort_sections PARAMS ((const PTR, const PTR));
-static boolean assign_file_positions_for_segments PARAMS ((bfd *));
-static boolean assign_file_positions_except_relocs PARAMS ((bfd *));
-static boolean prep_headers PARAMS ((bfd *));
-static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **));
-static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *));
-
-/* Standard ELF hash function. Do not change this function; you will
- cause invalid hash tables to be generated. (Well, you would if this
- were being used yet.) */
-unsigned long
-bfd_elf_hash (name)
- CONST unsigned char *name;
-{
- unsigned long h = 0;
- unsigned long g;
- int ch;
-
- while ((ch = *name++) != '\0')
- {
- h = (h << 4) + ch;
- if ((g = (h & 0xf0000000)) != 0)
- {
- h ^= g >> 24;
- h &= ~g;
- }
- }
- return h;
-}
-
-/* Read a specified number of bytes at a specified offset in an ELF
- file, into a newly allocated buffer, and return a pointer to the
- buffer. */
-
-static char *
-elf_read (abfd, offset, size)
- bfd * abfd;
- long offset;
- unsigned int size;
-{
- char *buf;
-
- if ((buf = bfd_alloc (abfd, size)) == NULL)
- return NULL;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
- return NULL;
- if (bfd_read ((PTR) buf, size, 1, abfd) != size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_file_truncated);
- return NULL;
- }
- return buf;
-}
-
-boolean
-elf_mkobject (abfd)
- bfd * abfd;
-{
- /* this just does initialization */
- /* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
- elf_tdata (abfd) = (struct elf_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
- if (elf_tdata (abfd) == 0)
- return false;
- /* since everything is done at close time, do we need any
- initialization? */
-
- return true;
-}
-
-char *
-bfd_elf_get_str_section (abfd, shindex)
- bfd * abfd;
- unsigned int shindex;
-{
- Elf_Internal_Shdr **i_shdrp;
- char *shstrtab = NULL;
- unsigned int offset;
- unsigned int shstrtabsize;
-
- i_shdrp = elf_elfsections (abfd);
- if (i_shdrp == 0 || i_shdrp[shindex] == 0)
- return 0;
-
- shstrtab = (char *) i_shdrp[shindex]->contents;
- if (shstrtab == NULL)
- {
- /* No cached one, attempt to read, and cache what we read. */
- offset = i_shdrp[shindex]->sh_offset;
- shstrtabsize = i_shdrp[shindex]->sh_size;
- shstrtab = elf_read (abfd, offset, shstrtabsize);
- i_shdrp[shindex]->contents = (PTR) shstrtab;
- }
- return shstrtab;
-}
-
-char *
-bfd_elf_string_from_elf_section (abfd, shindex, strindex)
- bfd * abfd;
- unsigned int shindex;
- unsigned int strindex;
-{
- Elf_Internal_Shdr *hdr;
-
- if (strindex == 0)
- return "";
-
- hdr = elf_elfsections (abfd)[shindex];
-
- if (hdr->contents == NULL
- && bfd_elf_get_str_section (abfd, shindex) == NULL)
- return NULL;
-
- return ((char *) hdr->contents) + strindex;
-}
-
-/* Make a BFD section from an ELF section. We store a pointer to the
- BFD section in the bfd_section field of the header. */
-
-boolean
-_bfd_elf_make_section_from_shdr (abfd, hdr, name)
- bfd *abfd;
- Elf_Internal_Shdr *hdr;
- const char *name;
-{
- asection *newsect;
- flagword flags;
-
- if (hdr->bfd_section != NULL)
- {
- BFD_ASSERT (strcmp (name,
- bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
- return true;
- }
-
- newsect = bfd_make_section_anyway (abfd, name);
- if (newsect == NULL)
- return false;
-
- newsect->filepos = hdr->sh_offset;
-
- if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
- || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
- || ! bfd_set_section_alignment (abfd, newsect,
- bfd_log2 (hdr->sh_addralign)))
- return false;
-
- flags = SEC_NO_FLAGS;
- if (hdr->sh_type != SHT_NOBITS)
- flags |= SEC_HAS_CONTENTS;
- if ((hdr->sh_flags & SHF_ALLOC) != 0)
- {
- flags |= SEC_ALLOC;
- if (hdr->sh_type != SHT_NOBITS)
- flags |= SEC_LOAD;
- }
- if ((hdr->sh_flags & SHF_WRITE) == 0)
- flags |= SEC_READONLY;
- if ((hdr->sh_flags & SHF_EXECINSTR) != 0)
- flags |= SEC_CODE;
- else if ((flags & SEC_LOAD) != 0)
- flags |= SEC_DATA;
-
- /* The debugging sections appear to be recognized only by name, not
- any sort of flag. */
- if (strncmp (name, ".debug", sizeof ".debug" - 1) == 0
- || strncmp (name, ".line", sizeof ".line" - 1) == 0
- || strncmp (name, ".stab", sizeof ".stab" - 1) == 0)
- flags |= SEC_DEBUGGING;
-
- if (! bfd_set_section_flags (abfd, newsect, flags))
- return false;
-
- if ((flags & SEC_ALLOC) != 0)
- {
- Elf_Internal_Phdr *phdr;
- unsigned int i;
-
- /* Look through the phdrs to see if we need to adjust the lma. */
- phdr = elf_tdata (abfd)->phdr;
- for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
- {
- if (phdr->p_type == PT_LOAD
- && phdr->p_paddr != 0
- && phdr->p_vaddr != phdr->p_paddr
- && phdr->p_vaddr <= hdr->sh_addr
- && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size)
- {
- newsect->lma += phdr->p_paddr - phdr->p_vaddr;
- break;
- }
- }
- }
-
- hdr->bfd_section = newsect;
- elf_section_data (newsect)->this_hdr = *hdr;
-
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_elf_find_section
-
-SYNOPSIS
- struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
-
-DESCRIPTION
- Helper functions for GDB to locate the string tables.
- Since BFD hides string tables from callers, GDB needs to use an
- internal hook to find them. Sun's .stabstr, in particular,
- isn't even pointed to by the .stab section, so ordinary
- mechanisms wouldn't work to find it, even if we had some.
-*/
-
-struct elf_internal_shdr *
-bfd_elf_find_section (abfd, name)
- bfd * abfd;
- char *name;
-{
- Elf_Internal_Shdr **i_shdrp;
- char *shstrtab;
- unsigned int max;
- unsigned int i;
-
- i_shdrp = elf_elfsections (abfd);
- if (i_shdrp != NULL)
- {
- shstrtab = bfd_elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
- if (shstrtab != NULL)
- {
- max = elf_elfheader (abfd)->e_shnum;
- for (i = 1; i < max; i++)
- if (!strcmp (&shstrtab[i_shdrp[i]->sh_name], name))
- return i_shdrp[i];
- }
- }
- return 0;
-}
-
-const char *const bfd_elf_section_type_names[] = {
- "SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
- "SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
- "SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
-};
-
-/* ELF relocs are against symbols. If we are producing relocateable
- output, and the reloc is against an external symbol, and nothing
- has given us any additional addend, the resulting reloc will also
- be against the same symbol. In such a case, we don't want to
- change anything about the way the reloc is handled, since it will
- all be done at final link time. Rather than put special case code
- into bfd_perform_relocation, all the reloc types use this howto
- function. It just short circuits the reloc if producing
- relocateable output against an external symbol. */
-
-/*ARGSUSED*/
-bfd_reloc_status_type
-bfd_elf_generic_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && (! reloc_entry->howto->partial_inplace
- || reloc_entry->addend == 0))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- return bfd_reloc_continue;
-}
-
-/* Print out the program headers. */
-
-boolean
-_bfd_elf_print_private_bfd_data (abfd, farg)
- bfd *abfd;
- PTR farg;
-{
- FILE *f = (FILE *) farg;
- Elf_Internal_Phdr *p;
- asection *s;
- bfd_byte *dynbuf = NULL;
-
- p = elf_tdata (abfd)->phdr;
- if (p != NULL)
- {
- unsigned int i, c;
-
- fprintf (f, "\nProgram Header:\n");
- c = elf_elfheader (abfd)->e_phnum;
- for (i = 0; i < c; i++, p++)
- {
- const char *s;
- char buf[20];
-
- switch (p->p_type)
- {
- case PT_NULL: s = "NULL"; break;
- case PT_LOAD: s = "LOAD"; break;
- case PT_DYNAMIC: s = "DYNAMIC"; break;
- case PT_INTERP: s = "INTERP"; break;
- case PT_NOTE: s = "NOTE"; break;
- case PT_SHLIB: s = "SHLIB"; break;
- case PT_PHDR: s = "PHDR"; break;
- default: sprintf (buf, "0x%lx", p->p_type); s = buf; break;
- }
- fprintf (f, "%8s off 0x", s);
- fprintf_vma (f, p->p_offset);
- fprintf (f, " vaddr 0x");
- fprintf_vma (f, p->p_vaddr);
- fprintf (f, " paddr 0x");
- fprintf_vma (f, p->p_paddr);
- fprintf (f, " align 2**%u\n", bfd_log2 (p->p_align));
- fprintf (f, " filesz 0x");
- fprintf_vma (f, p->p_filesz);
- fprintf (f, " memsz 0x");
- fprintf_vma (f, p->p_memsz);
- fprintf (f, " flags %c%c%c",
- (p->p_flags & PF_R) != 0 ? 'r' : '-',
- (p->p_flags & PF_W) != 0 ? 'w' : '-',
- (p->p_flags & PF_X) != 0 ? 'x' : '-');
- if ((p->p_flags &~ (PF_R | PF_W | PF_X)) != 0)
- fprintf (f, " %lx", p->p_flags &~ (PF_R | PF_W | PF_X));
- fprintf (f, "\n");
- }
- }
-
- s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
- {
- int elfsec;
- unsigned long link;
- bfd_byte *extdyn, *extdynend;
- size_t extdynsize;
- void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
-
- fprintf (f, "\nDynamic Section:\n");
-
- dynbuf = (bfd_byte *) bfd_malloc (s->_raw_size);
- if (dynbuf == NULL)
- goto error_return;
- if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf, (file_ptr) 0,
- s->_raw_size))
- goto error_return;
-
- elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
- if (elfsec == -1)
- goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
-
- extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
- swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
-
- extdyn = dynbuf;
- extdynend = extdyn + s->_raw_size;
- for (; extdyn < extdynend; extdyn += extdynsize)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- char ab[20];
- boolean stringp;
-
- (*swap_dyn_in) (abfd, (PTR) extdyn, &dyn);
-
- if (dyn.d_tag == DT_NULL)
- break;
-
- stringp = false;
- switch (dyn.d_tag)
- {
- default:
- sprintf (ab, "0x%lx", (unsigned long) dyn.d_tag);
- name = ab;
- break;
-
- case DT_NEEDED: name = "NEEDED"; stringp = true; break;
- case DT_PLTRELSZ: name = "PLTRELSZ"; break;
- case DT_PLTGOT: name = "PLTGOT"; break;
- case DT_HASH: name = "HASH"; break;
- case DT_STRTAB: name = "STRTAB"; break;
- case DT_SYMTAB: name = "SYMTAB"; break;
- case DT_RELA: name = "RELA"; break;
- case DT_RELASZ: name = "RELASZ"; break;
- case DT_RELAENT: name = "RELAENT"; break;
- case DT_STRSZ: name = "STRSZ"; break;
- case DT_SYMENT: name = "SYMENT"; break;
- case DT_INIT: name = "INIT"; break;
- case DT_FINI: name = "FINI"; break;
- case DT_SONAME: name = "SONAME"; stringp = true; break;
- case DT_RPATH: name = "RPATH"; stringp = true; break;
- case DT_SYMBOLIC: name = "SYMBOLIC"; break;
- case DT_REL: name = "REL"; break;
- case DT_RELSZ: name = "RELSZ"; break;
- case DT_RELENT: name = "RELENT"; break;
- case DT_PLTREL: name = "PLTREL"; break;
- case DT_DEBUG: name = "DEBUG"; break;
- case DT_TEXTREL: name = "TEXTREL"; break;
- case DT_JMPREL: name = "JMPREL"; break;
- }
-
- fprintf (f, " %-11s ", name);
- if (! stringp)
- fprintf (f, "0x%lx", (unsigned long) dyn.d_un.d_val);
- else
- {
- const char *string;
-
- string = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
- if (string == NULL)
- goto error_return;
- fprintf (f, "%s", string);
- }
- fprintf (f, "\n");
- }
-
- free (dynbuf);
- dynbuf = NULL;
- }
-
- return true;
-
- error_return:
- if (dynbuf != NULL)
- free (dynbuf);
- return false;
-}
-
-/* Display ELF-specific fields of a symbol. */
-void
-bfd_elf_print_symbol (ignore_abfd, filep, symbol, how)
- bfd *ignore_abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- fprintf (file, "elf ");
- fprintf_vma (file, symbol->value);
- fprintf (file, " %lx", (long) symbol->flags);
- break;
- case bfd_print_symbol_all:
- {
- CONST char *section_name;
- section_name = symbol->section ? symbol->section->name : "(*none*)";
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %s\t", section_name);
- /* Print the "other" value for a symbol. For common symbols,
- we've already printed the size; now print the alignment.
- For other symbols, we have no specified alignment, and
- we've printed the address; now print the size. */
- fprintf_vma (file,
- (bfd_is_com_section (symbol->section)
- ? ((elf_symbol_type *) symbol)->internal_elf_sym.st_value
- : ((elf_symbol_type *) symbol)->internal_elf_sym.st_size));
- fprintf (file, " %s", symbol->name);
- }
- break;
- }
-}
-
-/* Create an entry in an ELF linker hash table. */
-
-struct bfd_hash_entry *
-_bfd_elf_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct elf_link_hash_entry *ret = (struct elf_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct elf_link_hash_entry *) NULL)
- ret = ((struct elf_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry)));
- if (ret == (struct elf_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct elf_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != (struct elf_link_hash_entry *) NULL)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->size = 0;
- ret->dynindx = -1;
- ret->dynstr_index = 0;
- ret->weakdef = NULL;
- ret->got_offset = (bfd_vma) -1;
- ret->plt_offset = (bfd_vma) -1;
- ret->linker_section_pointer = (elf_linker_section_pointers_t *)0;
- ret->type = STT_NOTYPE;
- /* Assume that we have been called by a non-ELF symbol reader.
- This flag is then reset by the code which reads an ELF input
- file. This ensures that a symbol created by a non-ELF symbol
- reader will have the flag set correctly. */
- ret->elf_link_hash_flags = ELF_LINK_NON_ELF;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an ELF linker hash table. */
-
-boolean
-_bfd_elf_link_hash_table_init (table, abfd, newfunc)
- struct elf_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- table->dynamic_sections_created = false;
- table->dynobj = NULL;
- /* The first dynamic symbol is a dummy. */
- table->dynsymcount = 1;
- table->dynstr = NULL;
- table->bucketcount = 0;
- table->needed = NULL;
- return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
-}
-
-/* Create an ELF linker hash table. */
-
-struct bfd_link_hash_table *
-_bfd_elf_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct elf_link_hash_table *ret;
-
- ret = ((struct elf_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
- if (ret == (struct elf_link_hash_table *) NULL)
- return NULL;
-
- if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return NULL;
- }
-
- return &ret->root;
-}
-
-/* This is a hook for the ELF emulation code in the generic linker to
- tell the backend linker what file name to use for the DT_NEEDED
- entry for a dynamic object. The generic linker passes name as an
- empty string to indicate that no DT_NEEDED entry should be made. */
-
-void
-bfd_elf_set_dt_needed_name (abfd, name)
- bfd *abfd;
- const char *name;
-{
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && bfd_get_format (abfd) == bfd_object)
- elf_dt_name (abfd) = name;
-}
-
-/* Get the list of DT_NEEDED entries for a link. This is a hook for
- the ELF emulation code. */
-
-struct bfd_link_needed_list *
-bfd_elf_get_needed_list (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (info->hash->creator->flavour != bfd_target_elf_flavour)
- return NULL;
- return elf_hash_table (info)->needed;
-}
-
-/* Get the name actually used for a dynamic object for a link. This
- is the SONAME entry if there is one. Otherwise, it is the string
- passed to bfd_elf_set_dt_needed_name, or it is the filename. */
-
-const char *
-bfd_elf_get_dt_soname (abfd)
- bfd *abfd;
-{
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
- && bfd_get_format (abfd) == bfd_object)
- return elf_dt_name (abfd);
- return NULL;
-}
-
-/* Allocate an ELF string table--force the first byte to be zero. */
-
-struct bfd_strtab_hash *
-_bfd_elf_stringtab_init ()
-{
- struct bfd_strtab_hash *ret;
-
- ret = _bfd_stringtab_init ();
- if (ret != NULL)
- {
- bfd_size_type loc;
-
- loc = _bfd_stringtab_add (ret, "", true, false);
- BFD_ASSERT (loc == 0 || loc == (bfd_size_type) -1);
- if (loc == (bfd_size_type) -1)
- {
- _bfd_stringtab_free (ret);
- ret = NULL;
- }
- }
- return ret;
-}
-
-/* ELF .o/exec file reading */
-
-/* Create a new bfd section from an ELF section header. */
-
-boolean
-bfd_section_from_shdr (abfd, shindex)
- bfd *abfd;
- unsigned int shindex;
-{
- Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[shindex];
- Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- char *name;
-
- name = elf_string_from_elf_strtab (abfd, hdr->sh_name);
-
- switch (hdr->sh_type)
- {
- case SHT_NULL:
- /* Inactive section. Throw it away. */
- return true;
-
- case SHT_PROGBITS: /* Normal section with contents. */
- case SHT_DYNAMIC: /* Dynamic linking information. */
- case SHT_NOBITS: /* .bss section. */
- case SHT_HASH: /* .hash section. */
- case SHT_NOTE: /* .note section. */
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_SYMTAB: /* A symbol table */
- if (elf_onesymtab (abfd) == shindex)
- return true;
-
- BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
- BFD_ASSERT (elf_onesymtab (abfd) == 0);
- elf_onesymtab (abfd) = shindex;
- elf_tdata (abfd)->symtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr;
- abfd->flags |= HAS_SYMS;
-
- /* Sometimes a shared object will map in the symbol table. If
- SHF_ALLOC is set, and this is a shared object, then we also
- treat this section as a BFD section. We can not base the
- decision purely on SHF_ALLOC, because that flag is sometimes
- set in a relocateable object file, which would confuse the
- linker. */
- if ((hdr->sh_flags & SHF_ALLOC) != 0
- && (abfd->flags & DYNAMIC) != 0
- && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
- return false;
-
- return true;
-
- case SHT_DYNSYM: /* A dynamic symbol table */
- if (elf_dynsymtab (abfd) == shindex)
- return true;
-
- BFD_ASSERT (hdr->sh_entsize == bed->s->sizeof_sym);
- BFD_ASSERT (elf_dynsymtab (abfd) == 0);
- elf_dynsymtab (abfd) = shindex;
- elf_tdata (abfd)->dynsymtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr;
- abfd->flags |= HAS_SYMS;
-
- /* Besides being a symbol table, we also treat this as a regular
- section, so that objcopy can handle it. */
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_STRTAB: /* A string table */
- if (hdr->bfd_section != NULL)
- return true;
- if (ehdr->e_shstrndx == shindex)
- {
- elf_tdata (abfd)->shstrtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
- return true;
- }
- {
- unsigned int i;
-
- for (i = 1; i < ehdr->e_shnum; i++)
- {
- Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
- if (hdr2->sh_link == shindex)
- {
- if (! bfd_section_from_shdr (abfd, i))
- return false;
- if (elf_onesymtab (abfd) == i)
- {
- elf_tdata (abfd)->strtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] =
- &elf_tdata (abfd)->strtab_hdr;
- return true;
- }
- if (elf_dynsymtab (abfd) == i)
- {
- elf_tdata (abfd)->dynstrtab_hdr = *hdr;
- elf_elfsections (abfd)[shindex] = hdr =
- &elf_tdata (abfd)->dynstrtab_hdr;
- /* We also treat this as a regular section, so
- that objcopy can handle it. */
- break;
- }
-#if 0 /* Not handling other string tables specially right now. */
- hdr2 = elf_elfsections (abfd)[i]; /* in case it moved */
- /* We have a strtab for some random other section. */
- newsect = (asection *) hdr2->bfd_section;
- if (!newsect)
- break;
- hdr->bfd_section = newsect;
- hdr2 = &elf_section_data (newsect)->str_hdr;
- *hdr2 = *hdr;
- elf_elfsections (abfd)[shindex] = hdr2;
-#endif
- }
- }
- }
-
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- case SHT_REL:
- case SHT_RELA:
- /* *These* do a lot of work -- but build no sections! */
- {
- asection *target_sect;
- Elf_Internal_Shdr *hdr2;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
-
- /* For some incomprehensible reason Oracle distributes
- libraries for Solaris in which some of the objects have
- bogus sh_link fields. It would be nice if we could just
- reject them, but, unfortunately, some people need to use
- them. We scan through the section headers; if we find only
- one suitable symbol table, we clobber the sh_link to point
- to it. I hope this doesn't break anything. */
- if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
- && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
- {
- int scan;
- int found;
-
- found = 0;
- for (scan = 1; scan < ehdr->e_shnum; scan++)
- {
- if (elf_elfsections (abfd)[scan]->sh_type == SHT_SYMTAB
- || elf_elfsections (abfd)[scan]->sh_type == SHT_DYNSYM)
- {
- if (found != 0)
- {
- found = 0;
- break;
- }
- found = scan;
- }
- }
- if (found != 0)
- hdr->sh_link = found;
- }
-
- /* Get the symbol table. */
- if (elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
- && ! bfd_section_from_shdr (abfd, hdr->sh_link))
- return false;
-
- /* If this reloc section does not use the main symbol table we
- don't treat it as a reloc section. BFD can't adequately
- represent such a section, so at least for now, we don't
- try. We just present it as a normal section. */
- if (hdr->sh_link != elf_onesymtab (abfd))
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
-
- /* Don't allow REL relocations on a machine that uses RELA and
- vice versa. */
- /* @@ Actually, the generic ABI does suggest that both might be
- used in one file. But the four ABI Processor Supplements I
- have access to right now all specify that only one is used on
- each of those architectures. It's conceivable that, e.g., a
- bunch of absolute 32-bit relocs might be more compact in REL
- form even on a RELA machine... */
- BFD_ASSERT (use_rela_p
- ? (hdr->sh_type == SHT_RELA
- && hdr->sh_entsize == bed->s->sizeof_rela)
- : (hdr->sh_type == SHT_REL
- && hdr->sh_entsize == bed->s->sizeof_rel));
-
- if (! bfd_section_from_shdr (abfd, hdr->sh_info))
- return false;
- target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
- if (target_sect == NULL)
- return false;
-
- hdr2 = &elf_section_data (target_sect)->rel_hdr;
- *hdr2 = *hdr;
- elf_elfsections (abfd)[shindex] = hdr2;
- target_sect->reloc_count = hdr->sh_size / hdr->sh_entsize;
- target_sect->flags |= SEC_RELOC;
- target_sect->relocation = NULL;
- target_sect->rel_filepos = hdr->sh_offset;
- abfd->flags |= HAS_RELOC;
- return true;
- }
- break;
-
- case SHT_SHLIB:
- return true;
-
- default:
- /* Check for any processor-specific section types. */
- {
- if (bed->elf_backend_section_from_shdr)
- (*bed->elf_backend_section_from_shdr) (abfd, hdr, name);
- }
- break;
- }
-
- return true;
-}
-
-/* Given an ELF section number, retrieve the corresponding BFD
- section. */
-
-asection *
-bfd_section_from_elf_index (abfd, index)
- bfd *abfd;
- unsigned int index;
-{
- BFD_ASSERT (index > 0 && index < SHN_LORESERVE);
- if (index >= elf_elfheader (abfd)->e_shnum)
- return NULL;
- return elf_elfsections (abfd)[index]->bfd_section;
-}
-
-boolean
-_bfd_elf_new_section_hook (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- struct bfd_elf_section_data *sdata;
-
- sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
- if (!sdata)
- return false;
- sec->used_by_bfd = (PTR) sdata;
- memset (sdata, 0, sizeof (*sdata));
- return true;
-}
-
-/* Create a new bfd section from an ELF program header.
-
- Since program segments have no names, we generate a synthetic name
- of the form segment<NUM>, where NUM is generally the index in the
- program header table. For segments that are split (see below) we
- generate the names segment<NUM>a and segment<NUM>b.
-
- Note that some program segments may have a file size that is different than
- (less than) the memory size. All this means is that at execution the
- system must allocate the amount of memory specified by the memory size,
- but only initialize it with the first "file size" bytes read from the
- file. This would occur for example, with program segments consisting
- of combined data+bss.
-
- To handle the above situation, this routine generates TWO bfd sections
- for the single program segment. The first has the length specified by
- the file size of the segment, and the second has the length specified
- by the difference between the two sizes. In effect, the segment is split
- into it's initialized and uninitialized parts.
-
- */
-
-boolean
-bfd_section_from_phdr (abfd, hdr, index)
- bfd *abfd;
- Elf_Internal_Phdr *hdr;
- int index;
-{
- asection *newsect;
- char *name;
- char namebuf[64];
- int split;
-
- split = ((hdr->p_memsz > 0) &&
- (hdr->p_filesz > 0) &&
- (hdr->p_memsz > hdr->p_filesz));
- sprintf (namebuf, split ? "segment%da" : "segment%d", index);
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
- if (!name)
- return false;
- strcpy (name, namebuf);
- newsect = bfd_make_section (abfd, name);
- if (newsect == NULL)
- return false;
- newsect->vma = hdr->p_vaddr;
- newsect->lma = hdr->p_paddr;
- newsect->_raw_size = hdr->p_filesz;
- newsect->filepos = hdr->p_offset;
- newsect->flags |= SEC_HAS_CONTENTS;
- if (hdr->p_type == PT_LOAD)
- {
- newsect->flags |= SEC_ALLOC;
- newsect->flags |= SEC_LOAD;
- if (hdr->p_flags & PF_X)
- {
- /* FIXME: all we known is that it has execute PERMISSION,
- may be data. */
- newsect->flags |= SEC_CODE;
- }
- }
- if (!(hdr->p_flags & PF_W))
- {
- newsect->flags |= SEC_READONLY;
- }
-
- if (split)
- {
- sprintf (namebuf, "segment%db", index);
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
- if (!name)
- return false;
- strcpy (name, namebuf);
- newsect = bfd_make_section (abfd, name);
- if (newsect == NULL)
- return false;
- newsect->vma = hdr->p_vaddr + hdr->p_filesz;
- newsect->lma = hdr->p_paddr + hdr->p_filesz;
- newsect->_raw_size = hdr->p_memsz - hdr->p_filesz;
- if (hdr->p_type == PT_LOAD)
- {
- newsect->flags |= SEC_ALLOC;
- if (hdr->p_flags & PF_X)
- newsect->flags |= SEC_CODE;
- }
- if (!(hdr->p_flags & PF_W))
- newsect->flags |= SEC_READONLY;
- }
-
- return true;
-}
-
-/* Set up an ELF internal section header for a section. */
-
-/*ARGSUSED*/
-static void
-elf_fake_sections (abfd, asect, failedptrarg)
- bfd *abfd;
- asection *asect;
- PTR failedptrarg;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- boolean *failedptr = (boolean *) failedptrarg;
- Elf_Internal_Shdr *this_hdr;
-
- if (*failedptr)
- {
- /* We already failed; just get out of the bfd_map_over_sections
- loop. */
- return;
- }
-
- this_hdr = &elf_section_data (asect)->this_hdr;
-
- this_hdr->sh_name = (unsigned long) _bfd_stringtab_add (elf_shstrtab (abfd),
- asect->name,
- true, false);
- if (this_hdr->sh_name == (unsigned long) -1)
- {
- *failedptr = true;
- return;
- }
-
- this_hdr->sh_flags = 0;
-
- if ((asect->flags & SEC_ALLOC) != 0)
- this_hdr->sh_addr = asect->vma;
- else
- this_hdr->sh_addr = 0;
-
- this_hdr->sh_offset = 0;
- this_hdr->sh_size = asect->_raw_size;
- this_hdr->sh_link = 0;
- this_hdr->sh_addralign = 1 << asect->alignment_power;
- /* The sh_entsize and sh_info fields may have been set already by
- copy_private_section_data. */
-
- this_hdr->bfd_section = asect;
- this_hdr->contents = NULL;
-
- /* FIXME: This should not be based on section names. */
- if (strcmp (asect->name, ".dynstr") == 0)
- this_hdr->sh_type = SHT_STRTAB;
- else if (strcmp (asect->name, ".hash") == 0)
- {
- this_hdr->sh_type = SHT_HASH;
- this_hdr->sh_entsize = bed->s->arch_size / 8;
- }
- else if (strcmp (asect->name, ".dynsym") == 0)
- {
- this_hdr->sh_type = SHT_DYNSYM;
- this_hdr->sh_entsize = bed->s->sizeof_sym;
- }
- else if (strcmp (asect->name, ".dynamic") == 0)
- {
- this_hdr->sh_type = SHT_DYNAMIC;
- this_hdr->sh_entsize = bed->s->sizeof_dyn;
- }
- else if (strncmp (asect->name, ".rela", 5) == 0
- && get_elf_backend_data (abfd)->use_rela_p)
- {
- this_hdr->sh_type = SHT_RELA;
- this_hdr->sh_entsize = bed->s->sizeof_rela;
- }
- else if (strncmp (asect->name, ".rel", 4) == 0
- && ! get_elf_backend_data (abfd)->use_rela_p)
- {
- this_hdr->sh_type = SHT_REL;
- this_hdr->sh_entsize = bed->s->sizeof_rel;
- }
- else if (strcmp (asect->name, ".note") == 0)
- this_hdr->sh_type = SHT_NOTE;
- else if (strncmp (asect->name, ".stab", 5) == 0
- && strcmp (asect->name + strlen (asect->name) - 3, "str") == 0)
- this_hdr->sh_type = SHT_STRTAB;
- else if ((asect->flags & SEC_ALLOC) != 0
- && (asect->flags & SEC_LOAD) != 0)
- this_hdr->sh_type = SHT_PROGBITS;
- else if ((asect->flags & SEC_ALLOC) != 0
- && ((asect->flags & SEC_LOAD) == 0))
- this_hdr->sh_type = SHT_NOBITS;
- else
- {
- /* Who knows? */
- this_hdr->sh_type = SHT_PROGBITS;
- }
-
- if ((asect->flags & SEC_ALLOC) != 0)
- this_hdr->sh_flags |= SHF_ALLOC;
- if ((asect->flags & SEC_READONLY) == 0)
- this_hdr->sh_flags |= SHF_WRITE;
- if ((asect->flags & SEC_CODE) != 0)
- this_hdr->sh_flags |= SHF_EXECINSTR;
-
- /* Check for processor-specific section types. */
- {
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (bed->elf_backend_fake_sections)
- (*bed->elf_backend_fake_sections) (abfd, this_hdr, asect);
- }
-
- /* If the section has relocs, set up a section header for the
- SHT_REL[A] section. */
- if ((asect->flags & SEC_RELOC) != 0)
- {
- Elf_Internal_Shdr *rela_hdr;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
- char *name;
-
- rela_hdr = &elf_section_data (asect)->rel_hdr;
- name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
- if (name == NULL)
- {
- *failedptr = true;
- return;
- }
- sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
- rela_hdr->sh_name =
- (unsigned int) _bfd_stringtab_add (elf_shstrtab (abfd), name,
- true, false);
- if (rela_hdr->sh_name == (unsigned int) -1)
- {
- *failedptr = true;
- return;
- }
- rela_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
- rela_hdr->sh_entsize = (use_rela_p
- ? bed->s->sizeof_rela
- : bed->s->sizeof_rel);
- rela_hdr->sh_addralign = bed->s->file_align;
- rela_hdr->sh_flags = 0;
- rela_hdr->sh_addr = 0;
- rela_hdr->sh_size = 0;
- rela_hdr->sh_offset = 0;
- }
-}
-
-/* Assign all ELF section numbers. The dummy first section is handled here
- too. The link/info pointers for the standard section types are filled
- in here too, while we're at it. */
-
-static boolean
-assign_section_numbers (abfd)
- bfd *abfd;
-{
- struct elf_obj_tdata *t = elf_tdata (abfd);
- asection *sec;
- unsigned int section_number;
- Elf_Internal_Shdr **i_shdrp;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- section_number = 1;
-
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- struct bfd_elf_section_data *d = elf_section_data (sec);
-
- d->this_idx = section_number++;
- if ((sec->flags & SEC_RELOC) == 0)
- d->rel_idx = 0;
- else
- d->rel_idx = section_number++;
- }
-
- t->shstrtab_section = section_number++;
- elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
- t->shstrtab_hdr.sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
-
- if (abfd->symcount > 0)
- {
- t->symtab_section = section_number++;
- t->strtab_section = section_number++;
- }
-
- elf_elfheader (abfd)->e_shnum = section_number;
-
- /* Set up the list of section header pointers, in agreement with the
- indices. */
- i_shdrp = ((Elf_Internal_Shdr **)
- bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
- if (i_shdrp == NULL)
- return false;
-
- i_shdrp[0] = ((Elf_Internal_Shdr *)
- bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
- if (i_shdrp[0] == NULL)
- {
- bfd_release (abfd, i_shdrp);
- return false;
- }
- memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
-
- elf_elfsections (abfd) = i_shdrp;
-
- i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
- if (abfd->symcount > 0)
- {
- i_shdrp[t->symtab_section] = &t->symtab_hdr;
- i_shdrp[t->strtab_section] = &t->strtab_hdr;
- t->symtab_hdr.sh_link = t->strtab_section;
- }
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- struct bfd_elf_section_data *d = elf_section_data (sec);
- asection *s;
- const char *name;
-
- i_shdrp[d->this_idx] = &d->this_hdr;
- if (d->rel_idx != 0)
- i_shdrp[d->rel_idx] = &d->rel_hdr;
-
- /* Fill in the sh_link and sh_info fields while we're at it. */
-
- /* sh_link of a reloc section is the section index of the symbol
- table. sh_info is the section index of the section to which
- the relocation entries apply. */
- if (d->rel_idx != 0)
- {
- d->rel_hdr.sh_link = t->symtab_section;
- d->rel_hdr.sh_info = d->this_idx;
- }
-
- switch (d->this_hdr.sh_type)
- {
- case SHT_REL:
- case SHT_RELA:
- /* A reloc section which we are treating as a normal BFD
- section. sh_link is the section index of the symbol
- table. sh_info is the section index of the section to
- which the relocation entries apply. We assume that an
- allocated reloc section uses the dynamic symbol table.
- FIXME: How can we be sure? */
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
-
- /* We look up the section the relocs apply to by name. */
- name = sec->name;
- if (d->this_hdr.sh_type == SHT_REL)
- name += 4;
- else
- name += 5;
- s = bfd_get_section_by_name (abfd, name);
- if (s != NULL)
- d->this_hdr.sh_info = elf_section_data (s)->this_idx;
- break;
-
- case SHT_STRTAB:
- /* We assume that a section named .stab*str is a stabs
- string section. We look for a section with the same name
- but without the trailing ``str'', and set its sh_link
- field to point to this section. */
- if (strncmp (sec->name, ".stab", sizeof ".stab" - 1) == 0
- && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0)
- {
- size_t len;
- char *alc;
-
- len = strlen (sec->name);
- alc = (char *) bfd_malloc (len - 2);
- if (alc == NULL)
- return false;
- strncpy (alc, sec->name, len - 3);
- alc[len - 3] = '\0';
- s = bfd_get_section_by_name (abfd, alc);
- free (alc);
- if (s != NULL)
- {
- elf_section_data (s)->this_hdr.sh_link = d->this_idx;
-
- /* This is a .stab section. */
- elf_section_data (s)->this_hdr.sh_entsize =
- 4 + 2 * (bed->s->arch_size / 8);
- }
- }
- break;
-
- case SHT_DYNAMIC:
- case SHT_DYNSYM:
- /* sh_link is the section header index of the string table
- used for the dynamic entries or symbol table. */
- s = bfd_get_section_by_name (abfd, ".dynstr");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
- break;
-
- case SHT_HASH:
- /* sh_link is the section header index of the symbol table
- this hash table is for. */
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
- break;
- }
- }
-
- return true;
-}
-
-/* Map symbol from it's internal number to the external number, moving
- all local symbols to be at the head of the list. */
-
-static INLINE int
-sym_is_global (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- /* If the backend has a special mapping, use it. */
- if (get_elf_backend_data (abfd)->elf_backend_sym_is_global)
- return ((*get_elf_backend_data (abfd)->elf_backend_sym_is_global)
- (abfd, sym));
-
- return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym)));
-}
-
-static boolean
-elf_map_symbols (abfd)
- bfd *abfd;
-{
- int symcount = bfd_get_symcount (abfd);
- asymbol **syms = bfd_get_outsymbols (abfd);
- asymbol **sect_syms;
- int num_locals = 0;
- int num_globals = 0;
- int num_locals2 = 0;
- int num_globals2 = 0;
- int max_index = 0;
- int num_sections = 0;
- int idx;
- asection *asect;
- asymbol **new_syms;
-
-#ifdef DEBUG
- fprintf (stderr, "elf_map_symbols\n");
- fflush (stderr);
-#endif
-
- /* Add a section symbol for each BFD section. FIXME: Is this really
- necessary? */
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (max_index < asect->index)
- max_index = asect->index;
- }
-
- max_index++;
- sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
- if (sect_syms == NULL)
- return false;
- elf_section_syms (abfd) = sect_syms;
-
- for (idx = 0; idx < symcount; idx++)
- {
- if ((syms[idx]->flags & BSF_SECTION_SYM) != 0
- && (syms[idx]->value + syms[idx]->section->vma) == 0)
- {
- asection *sec;
-
- sec = syms[idx]->section;
- if (sec->owner != NULL)
- {
- if (sec->owner != abfd)
- {
- if (sec->output_offset != 0)
- continue;
- sec = sec->output_section;
- BFD_ASSERT (sec->owner == abfd);
- }
- sect_syms[sec->index] = syms[idx];
- }
- }
- }
-
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- asymbol *sym;
-
- if (sect_syms[asect->index] != NULL)
- continue;
-
- sym = bfd_make_empty_symbol (abfd);
- if (sym == NULL)
- return false;
- sym->the_bfd = abfd;
- sym->name = asect->name;
- sym->value = 0;
- /* Set the flags to 0 to indicate that this one was newly added. */
- sym->flags = 0;
- sym->section = asect;
- sect_syms[asect->index] = sym;
- num_sections++;
-#ifdef DEBUG
- fprintf (stderr,
- "creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = 0x%.8lx\n",
- asect->name, (long) asect->vma, asect->index, (long) asect);
-#endif
- }
-
- /* Classify all of the symbols. */
- for (idx = 0; idx < symcount; idx++)
- {
- if (!sym_is_global (abfd, syms[idx]))
- num_locals++;
- else
- num_globals++;
- }
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (sect_syms[asect->index] != NULL
- && sect_syms[asect->index]->flags == 0)
- {
- sect_syms[asect->index]->flags = BSF_SECTION_SYM;
- if (!sym_is_global (abfd, sect_syms[asect->index]))
- num_locals++;
- else
- num_globals++;
- sect_syms[asect->index]->flags = 0;
- }
- }
-
- /* Now sort the symbols so the local symbols are first. */
- new_syms = ((asymbol **)
- bfd_alloc (abfd,
- (num_locals + num_globals) * sizeof (asymbol *)));
- if (new_syms == NULL)
- return false;
-
- for (idx = 0; idx < symcount; idx++)
- {
- asymbol *sym = syms[idx];
- int i;
-
- if (!sym_is_global (abfd, sym))
- i = num_locals2++;
- else
- i = num_locals + num_globals2++;
- new_syms[i] = sym;
- sym->udata.i = i + 1;
- }
- for (asect = abfd->sections; asect; asect = asect->next)
- {
- if (sect_syms[asect->index] != NULL
- && sect_syms[asect->index]->flags == 0)
- {
- asymbol *sym = sect_syms[asect->index];
- int i;
-
- sym->flags = BSF_SECTION_SYM;
- if (!sym_is_global (abfd, sym))
- i = num_locals2++;
- else
- i = num_locals + num_globals2++;
- new_syms[i] = sym;
- sym->udata.i = i + 1;
- }
- }
-
- bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
-
- elf_num_locals (abfd) = num_locals;
- elf_num_globals (abfd) = num_globals;
- return true;
-}
-
-/* Align to the maximum file alignment that could be required for any
- ELF data structure. */
-
-static INLINE file_ptr align_file_position PARAMS ((file_ptr, int));
-static INLINE file_ptr
-align_file_position (off, align)
- file_ptr off;
- int align;
-{
- return (off + align - 1) & ~(align - 1);
-}
-
-/* Assign a file position to a section, optionally aligning to the
- required section alignment. */
-
-INLINE file_ptr
-_bfd_elf_assign_file_position_for_section (i_shdrp, offset, align)
- Elf_Internal_Shdr *i_shdrp;
- file_ptr offset;
- boolean align;
-{
- if (align)
- {
- unsigned int al;
-
- al = i_shdrp->sh_addralign;
- if (al > 1)
- offset = BFD_ALIGN (offset, al);
- }
- i_shdrp->sh_offset = offset;
- if (i_shdrp->bfd_section != NULL)
- i_shdrp->bfd_section->filepos = offset;
- if (i_shdrp->sh_type != SHT_NOBITS)
- offset += i_shdrp->sh_size;
- return offset;
-}
-
-/* Compute the file positions we are going to put the sections at, and
- otherwise prepare to begin writing out the ELF file. If LINK_INFO
- is not NULL, this is being called by the ELF backend linker. */
-
-boolean
-_bfd_elf_compute_section_file_positions (abfd, link_info)
- bfd *abfd;
- struct bfd_link_info *link_info;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- boolean failed;
- struct bfd_strtab_hash *strtab;
- Elf_Internal_Shdr *shstrtab_hdr;
-
- if (abfd->output_has_begun)
- return true;
-
- /* Do any elf backend specific processing first. */
- if (bed->elf_backend_begin_write_processing)
- (*bed->elf_backend_begin_write_processing) (abfd, link_info);
-
- if (! prep_headers (abfd))
- return false;
-
- failed = false;
- bfd_map_over_sections (abfd, elf_fake_sections, &failed);
- if (failed)
- return false;
-
- if (!assign_section_numbers (abfd))
- return false;
-
- /* The backend linker builds symbol table information itself. */
- if (link_info == NULL && abfd->symcount > 0)
- {
- if (! swap_out_syms (abfd, &strtab))
- return false;
- }
-
- shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
- /* sh_name was set in prep_headers. */
- shstrtab_hdr->sh_type = SHT_STRTAB;
- shstrtab_hdr->sh_flags = 0;
- shstrtab_hdr->sh_addr = 0;
- shstrtab_hdr->sh_size = _bfd_stringtab_size (elf_shstrtab (abfd));
- shstrtab_hdr->sh_entsize = 0;
- shstrtab_hdr->sh_link = 0;
- shstrtab_hdr->sh_info = 0;
- /* sh_offset is set in assign_file_positions_except_relocs. */
- shstrtab_hdr->sh_addralign = 1;
-
- if (!assign_file_positions_except_relocs (abfd))
- return false;
-
- if (link_info == NULL && abfd->symcount > 0)
- {
- file_ptr off;
- Elf_Internal_Shdr *hdr;
-
- off = elf_tdata (abfd)->next_file_pos;
-
- hdr = &elf_tdata (abfd)->symtab_hdr;
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
-
- hdr = &elf_tdata (abfd)->strtab_hdr;
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
-
- elf_tdata (abfd)->next_file_pos = off;
-
- /* Now that we know where the .strtab section goes, write it
- out. */
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd, strtab))
- return false;
- _bfd_stringtab_free (strtab);
- }
-
- abfd->output_has_begun = true;
-
- return true;
-}
-
-/* Create a mapping from a set of sections to a program segment. */
-
-static INLINE struct elf_segment_map *
-make_mapping (abfd, sections, from, to, phdr)
- bfd *abfd;
- asection **sections;
- unsigned int from;
- unsigned int to;
- boolean phdr;
-{
- struct elf_segment_map *m;
- unsigned int i;
- asection **hdrpp;
-
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd,
- (sizeof (struct elf_segment_map)
- + (to - from - 1) * sizeof (asection *))));
- if (m == NULL)
- return NULL;
- m->next = NULL;
- m->p_type = PT_LOAD;
- for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
- m->sections[i - from] = *hdrpp;
- m->count = to - from;
-
- if (from == 0 && phdr)
- {
- /* Include the headers in the first PT_LOAD segment. */
- m->includes_filehdr = 1;
- m->includes_phdrs = 1;
- }
-
- return m;
-}
-
-/* Set up a mapping from BFD sections to program segments. */
-
-static boolean
-map_sections_to_segments (abfd)
- bfd *abfd;
-{
- asection **sections = NULL;
- asection *s;
- unsigned int i;
- unsigned int count;
- struct elf_segment_map *mfirst;
- struct elf_segment_map **pm;
- struct elf_segment_map *m;
- asection *last_hdr;
- unsigned int phdr_index;
- bfd_vma maxpagesize;
- asection **hdrpp;
- boolean phdr_in_section = true;
- boolean writable;
- asection *dynsec;
-
- if (elf_tdata (abfd)->segment_map != NULL)
- return true;
-
- if (bfd_count_sections (abfd) == 0)
- return true;
-
- /* Select the allocated sections, and sort them. */
-
- sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
- * sizeof (asection *));
- if (sections == NULL)
- goto error_return;
-
- i = 0;
- for (s = abfd->sections; s != NULL; s = s->next)
- {
- if ((s->flags & SEC_ALLOC) != 0)
- {
- sections[i] = s;
- ++i;
- }
- }
- BFD_ASSERT (i <= bfd_count_sections (abfd));
- count = i;
-
- qsort (sections, (size_t) count, sizeof (asection *), elf_sort_sections);
-
- /* Build the mapping. */
-
- mfirst = NULL;
- pm = &mfirst;
-
- /* If we have a .interp section, then create a PT_PHDR segment for
- the program headers and a PT_INTERP segment for the .interp
- section. */
- s = bfd_get_section_by_name (abfd, ".interp");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_PHDR;
- /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
- m->p_flags = PF_R | PF_X;
- m->p_flags_valid = 1;
- m->includes_phdrs = 1;
-
- *pm = m;
- pm = &m->next;
-
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_INTERP;
- m->count = 1;
- m->sections[0] = s;
-
- *pm = m;
- pm = &m->next;
- }
-
- /* Look through the sections. We put sections in the same program
- segment when the start of the second section can be placed within
- a few bytes of the end of the first section. */
- last_hdr = NULL;
- phdr_index = 0;
- maxpagesize = get_elf_backend_data (abfd)->maxpagesize;
- writable = false;
- dynsec = bfd_get_section_by_name (abfd, ".dynamic");
- if (dynsec != NULL
- && (dynsec->flags & SEC_LOAD) == 0)
- dynsec = NULL;
-
- /* Deal with -Ttext or something similar such that the
- first section is not adjacent to the program headers. */
- if (count
- && ((sections[0]->lma % maxpagesize) <
- (elf_tdata (abfd)->program_header_size % maxpagesize)))
- phdr_in_section = false;
-
- for (i = 0, hdrpp = sections; i < count; i++, hdrpp++)
- {
- asection *hdr;
-
- hdr = *hdrpp;
-
- /* See if this section and the last one will fit in the same
- segment. Don't put a loadable section after a non-loadable
- section. If we are building a dynamic executable, don't put
- a writable section in a read only segment (we don't do this
- for a non-dynamic executable because some people prefer to
- have only one program segment; anybody can use PHDRS in their
- linker script to control what happens anyhow). */
- if (last_hdr == NULL
- || ((BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
- >= hdr->lma)
- && ((last_hdr->flags & SEC_LOAD) != 0
- || (hdr->flags & SEC_LOAD) == 0)
- && (dynsec == NULL
- || writable
- || (hdr->flags & SEC_READONLY) != 0)))
- {
- last_hdr = hdr;
- continue;
- }
-
- /* This section won't fit in the program segment. We must
- create a new program header holding all the sections from
- phdr_index until hdr. */
-
- m = make_mapping (abfd, sections, phdr_index, i, phdr_in_section);
- if (m == NULL)
- goto error_return;
-
- *pm = m;
- pm = &m->next;
-
- if ((hdr->flags & SEC_READONLY) == 0)
- writable = true;
-
- last_hdr = hdr;
- phdr_index = i;
- phdr_in_section = false;
- }
-
- /* Create a final PT_LOAD program segment. */
- if (last_hdr != NULL)
- {
- m = make_mapping (abfd, sections, phdr_index, i, phdr_in_section);
- if (m == NULL)
- goto error_return;
-
- *pm = m;
- pm = &m->next;
- }
-
- /* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
- if (dynsec != NULL)
- {
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
- if (m == NULL)
- goto error_return;
- m->next = NULL;
- m->p_type = PT_DYNAMIC;
- m->count = 1;
- m->sections[0] = dynsec;
-
- *pm = m;
- pm = &m->next;
- }
-
- free (sections);
- sections = NULL;
-
- elf_tdata (abfd)->segment_map = mfirst;
- return true;
-
- error_return:
- if (sections != NULL)
- free (sections);
- return false;
-}
-
-/* Sort sections by VMA. */
-
-static int
-elf_sort_sections (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-{
- const asection *sec1 = *(const asection **) arg1;
- const asection *sec2 = *(const asection **) arg2;
-
- if (sec1->vma < sec2->vma)
- return -1;
- else if (sec1->vma > sec2->vma)
- return 1;
-
- /* Put !SEC_LOAD sections after SEC_LOAD ones. */
-
-#define TOEND(x) (((x)->flags & SEC_LOAD) == 0)
-
- if (TOEND (sec1))
- if (TOEND (sec2))
- return sec1->target_index - sec2->target_index;
- else
- return 1;
-
- if (TOEND (sec2))
- return -1;
-
-#undef TOEND
-
- /* Sort by size, to put zero sized sections before others at the
- same address. */
-
- if (sec1->_raw_size < sec2->_raw_size)
- return -1;
- if (sec1->_raw_size > sec2->_raw_size)
- return 1;
-
- return sec1->target_index - sec2->target_index;
-}
-
-/* Assign file positions to the sections based on the mapping from
- sections to segments. This function also sets up some fields in
- the file header, and writes out the program headers. */
-
-static boolean
-assign_file_positions_for_segments (abfd)
- bfd *abfd;
-{
- const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- unsigned int count;
- struct elf_segment_map *m;
- unsigned int alloc;
- Elf_Internal_Phdr *phdrs;
- file_ptr off;
- bfd_vma filehdr_vaddr, filehdr_paddr;
- bfd_vma phdrs_vaddr, phdrs_paddr;
- Elf_Internal_Phdr *p;
-
- if (elf_tdata (abfd)->segment_map == NULL)
- {
- if (! map_sections_to_segments (abfd))
- return false;
- }
-
- if (bed->elf_backend_modify_segment_map)
- {
- if (! (*bed->elf_backend_modify_segment_map) (abfd))
- return false;
- }
-
- count = 0;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- ++count;
-
- elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
- elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
- elf_elfheader (abfd)->e_phnum = count;
-
- if (count == 0)
- return true;
-
- /* If we already counted the number of program segments, make sure
- that we allocated enough space. This happens when SIZEOF_HEADERS
- is used in a linker script. */
- alloc = elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr;
- if (alloc != 0 && count > alloc)
- {
- ((*_bfd_error_handler)
- ("%s: Not enough room for program headers (allocated %u, need %u)",
- bfd_get_filename (abfd), alloc, count));
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (alloc == 0)
- alloc = count;
-
- phdrs = ((Elf_Internal_Phdr *)
- bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
- if (phdrs == NULL)
- return false;
-
- off = bed->s->sizeof_ehdr;
- off += alloc * bed->s->sizeof_phdr;
-
- filehdr_vaddr = 0;
- filehdr_paddr = 0;
- phdrs_vaddr = 0;
- phdrs_paddr = 0;
- for (m = elf_tdata (abfd)->segment_map, p = phdrs;
- m != NULL;
- m = m->next, p++)
- {
- unsigned int i;
- asection **secpp;
-
- /* If elf_segment_map is not from map_sections_to_segments, the
- sections may not be correctly ordered. */
- if (m->count > 0)
- qsort (m->sections, (size_t) m->count, sizeof (asection *),
- elf_sort_sections);
-
- p->p_type = m->p_type;
-
- if (m->p_flags_valid)
- p->p_flags = m->p_flags;
- else
- p->p_flags = 0;
-
- if (p->p_type == PT_LOAD
- && m->count > 0
- && (m->sections[0]->flags & SEC_LOAD) != 0)
- off += (m->sections[0]->vma - off) % bed->maxpagesize;
-
- if (m->count == 0)
- p->p_vaddr = 0;
- else
- p->p_vaddr = m->sections[0]->vma;
-
- if (m->p_paddr_valid)
- p->p_paddr = m->p_paddr;
- else if (m->count == 0)
- p->p_paddr = 0;
- else
- p->p_paddr = m->sections[0]->lma;
-
- if (p->p_type == PT_LOAD)
- p->p_align = bed->maxpagesize;
- else if (m->count == 0)
- p->p_align = bed->s->file_align;
- else
- p->p_align = 0;
-
- p->p_offset = 0;
- p->p_filesz = 0;
- p->p_memsz = 0;
-
- if (m->includes_filehdr)
- {
- if (! m->p_flags_valid)
- p->p_flags |= PF_R;
- p->p_offset = 0;
- p->p_filesz = bed->s->sizeof_ehdr;
- p->p_memsz = bed->s->sizeof_ehdr;
- if (m->count > 0)
- {
- BFD_ASSERT (p->p_type == PT_LOAD);
- p->p_vaddr -= off;
- if (! m->p_paddr_valid)
- p->p_paddr -= off;
- }
- if (p->p_type == PT_LOAD)
- {
- filehdr_vaddr = p->p_vaddr;
- filehdr_paddr = p->p_paddr;
- }
- }
-
- if (m->includes_phdrs)
- {
- if (! m->p_flags_valid)
- p->p_flags |= PF_R;
- if (m->includes_filehdr)
- {
- if (p->p_type == PT_LOAD)
- {
- phdrs_vaddr = p->p_vaddr + bed->s->sizeof_ehdr;
- phdrs_paddr = p->p_paddr + bed->s->sizeof_ehdr;
- }
- }
- else
- {
- p->p_offset = bed->s->sizeof_ehdr;
- if (m->count > 0)
- {
- BFD_ASSERT (p->p_type == PT_LOAD);
- p->p_vaddr -= off - p->p_offset;
- if (! m->p_paddr_valid)
- p->p_paddr -= off - p->p_offset;
- }
- if (p->p_type == PT_LOAD)
- {
- phdrs_vaddr = p->p_vaddr;
- phdrs_paddr = p->p_paddr;
- }
- }
- p->p_filesz += alloc * bed->s->sizeof_phdr;
- p->p_memsz += alloc * bed->s->sizeof_phdr;
- }
-
- if (p->p_type == PT_LOAD)
- {
- if (! m->includes_filehdr && ! m->includes_phdrs)
- p->p_offset = off;
- else
- {
- file_ptr adjust;
-
- adjust = off - (p->p_offset + p->p_filesz);
- p->p_filesz += adjust;
- p->p_memsz += adjust;
- }
- }
-
- for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
- {
- asection *sec;
- flagword flags;
- bfd_size_type align;
-
- sec = *secpp;
- flags = sec->flags;
-
- if (p->p_type == PT_LOAD)
- {
- bfd_vma adjust;
-
- /* The section VMA must equal the file position modulo
- the page size. */
- if ((flags & SEC_ALLOC) != 0)
- {
- adjust = (sec->vma - off) % bed->maxpagesize;
- if (adjust != 0)
- {
- if (i == 0)
- abort ();
- p->p_memsz += adjust;
- off += adjust;
- if ((flags & SEC_LOAD) != 0)
- p->p_filesz += adjust;
- }
- }
-
- sec->filepos = off;
-
- if ((flags & SEC_LOAD) != 0)
- off += sec->_raw_size;
- }
-
- p->p_memsz += sec->_raw_size;
-
- if ((flags & SEC_LOAD) != 0)
- p->p_filesz += sec->_raw_size;
-
- align = 1 << bfd_get_section_alignment (abfd, sec);
- if (align > p->p_align)
- p->p_align = align;
-
- if (! m->p_flags_valid)
- {
- p->p_flags |= PF_R;
- if ((flags & SEC_CODE) != 0)
- p->p_flags |= PF_X;
- if ((flags & SEC_READONLY) == 0)
- p->p_flags |= PF_W;
- }
- }
- }
-
- /* Now that we have set the section file positions, we can set up
- the file positions for the non PT_LOAD segments. */
- for (m = elf_tdata (abfd)->segment_map, p = phdrs;
- m != NULL;
- m = m->next, p++)
- {
- if (p->p_type != PT_LOAD && m->count > 0)
- {
- BFD_ASSERT (! m->includes_filehdr && ! m->includes_phdrs);
- p->p_offset = m->sections[0]->filepos;
- }
- if (m->count == 0)
- {
- if (m->includes_filehdr)
- {
- p->p_vaddr = filehdr_vaddr;
- if (! m->p_paddr_valid)
- p->p_paddr = filehdr_paddr;
- }
- else if (m->includes_phdrs)
- {
- p->p_vaddr = phdrs_vaddr;
- if (! m->p_paddr_valid)
- p->p_paddr = phdrs_paddr;
- }
- }
- }
-
- /* Clear out any program headers we allocated but did not use. */
- for (; count < alloc; count++, p++)
- {
- memset (p, 0, sizeof *p);
- p->p_type = PT_NULL;
- }
-
- elf_tdata (abfd)->phdr = phdrs;
-
- elf_tdata (abfd)->next_file_pos = off;
-
- /* Write out the program headers. */
- if (bfd_seek (abfd, bed->s->sizeof_ehdr, SEEK_SET) != 0
- || bed->s->write_out_phdrs (abfd, phdrs, alloc) != 0)
- return false;
-
- return true;
-}
-
-/* Get the size of the program header.
-
- If this is called by the linker before any of the section VMA's are set, it
- can't calculate the correct value for a strange memory layout. This only
- happens when SIZEOF_HEADERS is used in a linker script. In this case,
- SORTED_HDRS is NULL and we assume the normal scenario of one text and one
- data segment (exclusive of .interp and .dynamic).
-
- ??? User written scripts must either not use SIZEOF_HEADERS, or assume there
- will be two segments. */
-
-static bfd_size_type
-get_program_header_size (abfd)
- bfd *abfd;
-{
- size_t segs;
- asection *s;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- /* We can't return a different result each time we're called. */
- if (elf_tdata (abfd)->program_header_size != 0)
- return elf_tdata (abfd)->program_header_size;
-
- if (elf_tdata (abfd)->segment_map != NULL)
- {
- struct elf_segment_map *m;
-
- segs = 0;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- ++segs;
- elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
- return elf_tdata (abfd)->program_header_size;
- }
-
- /* Assume we will need exactly two PT_LOAD segments: one for text
- and one for data. */
- segs = 2;
-
- s = bfd_get_section_by_name (abfd, ".interp");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- /* If we have a loadable interpreter section, we need a
- PT_INTERP segment. In this case, assume we also need a
- PT_PHDR segment, although that may not be true for all
- targets. */
- segs += 2;
- }
-
- if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
- {
- /* We need a PT_DYNAMIC segment. */
- ++segs;
- }
-
- /* Let the backend count up any program headers it might need. */
- if (bed->elf_backend_additional_program_headers)
- {
- int a;
-
- a = (*bed->elf_backend_additional_program_headers) (abfd);
- if (a == -1)
- abort ();
- segs += a;
- }
-
- elf_tdata (abfd)->program_header_size = segs * bed->s->sizeof_phdr;
- return elf_tdata (abfd)->program_header_size;
-}
-
-/* Work out the file positions of all the sections. This is called by
- _bfd_elf_compute_section_file_positions. All the section sizes and
- VMAs must be known before this is called.
-
- We do not consider reloc sections at this point, unless they form
- part of the loadable image. Reloc sections are assigned file
- positions in assign_file_positions_for_relocs, which is called by
- write_object_contents and final_link.
-
- We also don't set the positions of the .symtab and .strtab here. */
-
-static boolean
-assign_file_positions_except_relocs (abfd)
- bfd *abfd;
-{
- struct elf_obj_tdata * const tdata = elf_tdata (abfd);
- Elf_Internal_Ehdr * const i_ehdrp = elf_elfheader (abfd);
- Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
- file_ptr off;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- {
- Elf_Internal_Shdr **hdrpp;
- unsigned int i;
-
- /* Start after the ELF header. */
- off = i_ehdrp->e_ehsize;
-
- /* We are not creating an executable, which means that we are
- not creating a program header, and that the actual order of
- the sections in the file is unimportant. */
- for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
- {
- Elf_Internal_Shdr *hdr;
-
- hdr = *hdrpp;
- if (hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
- {
- hdr->sh_offset = -1;
- continue;
- }
- if (i == tdata->symtab_section
- || i == tdata->strtab_section)
- {
- hdr->sh_offset = -1;
- continue;
- }
-
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
- }
- }
- else
- {
- unsigned int i;
- Elf_Internal_Shdr **hdrpp;
-
- /* Assign file positions for the loaded sections based on the
- assignment of sections to segments. */
- if (! assign_file_positions_for_segments (abfd))
- return false;
-
- /* Assign file positions for the other sections. */
-
- off = elf_tdata (abfd)->next_file_pos;
- for (i = 1, hdrpp = i_shdrpp + 1; i < i_ehdrp->e_shnum; i++, hdrpp++)
- {
- Elf_Internal_Shdr *hdr;
-
- hdr = *hdrpp;
- if (hdr->bfd_section != NULL
- && hdr->bfd_section->filepos != 0)
- hdr->sh_offset = hdr->bfd_section->filepos;
- else if ((hdr->sh_flags & SHF_ALLOC) != 0)
- {
- ((*_bfd_error_handler)
- ("%s: warning: allocated section `%s' not in segment",
- bfd_get_filename (abfd),
- (hdr->bfd_section == NULL
- ? "*unknown*"
- : hdr->bfd_section->name)));
- off += (hdr->sh_addr - off) % bed->maxpagesize;
- off = _bfd_elf_assign_file_position_for_section (hdr, off,
- false);
- }
- else if (hdr->sh_type == SHT_REL
- || hdr->sh_type == SHT_RELA
- || hdr == i_shdrpp[tdata->symtab_section]
- || hdr == i_shdrpp[tdata->strtab_section])
- hdr->sh_offset = -1;
- else
- off = _bfd_elf_assign_file_position_for_section (hdr, off, true);
- }
- }
-
- /* Place the section headers. */
- off = align_file_position (off, bed->s->file_align);
- i_ehdrp->e_shoff = off;
- off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
-
- elf_tdata (abfd)->next_file_pos = off;
-
- return true;
-}
-
-static boolean
-prep_headers (abfd)
- bfd *abfd;
-{
- Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
- Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */
- Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
- int count;
- struct bfd_strtab_hash *shstrtab;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- i_ehdrp = elf_elfheader (abfd);
- i_shdrp = elf_elfsections (abfd);
-
- shstrtab = _bfd_elf_stringtab_init ();
- if (shstrtab == NULL)
- return false;
-
- elf_shstrtab (abfd) = shstrtab;
-
- i_ehdrp->e_ident[EI_MAG0] = ELFMAG0;
- i_ehdrp->e_ident[EI_MAG1] = ELFMAG1;
- i_ehdrp->e_ident[EI_MAG2] = ELFMAG2;
- i_ehdrp->e_ident[EI_MAG3] = ELFMAG3;
-
- i_ehdrp->e_ident[EI_CLASS] = bed->s->elfclass;
- i_ehdrp->e_ident[EI_DATA] =
- bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
- i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
-
- for (count = EI_PAD; count < EI_NIDENT; count++)
- i_ehdrp->e_ident[count] = 0;
-
- if ((abfd->flags & DYNAMIC) != 0)
- i_ehdrp->e_type = ET_DYN;
- else if ((abfd->flags & EXEC_P) != 0)
- i_ehdrp->e_type = ET_EXEC;
- else
- i_ehdrp->e_type = ET_REL;
-
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_unknown:
- i_ehdrp->e_machine = EM_NONE;
- break;
- case bfd_arch_sparc:
- if (bed->s->arch_size == 64)
- i_ehdrp->e_machine = EM_SPARC64;
- else
- i_ehdrp->e_machine = EM_SPARC;
- break;
- case bfd_arch_i386:
- i_ehdrp->e_machine = EM_386;
- break;
- case bfd_arch_m68k:
- i_ehdrp->e_machine = EM_68K;
- break;
- case bfd_arch_m88k:
- i_ehdrp->e_machine = EM_88K;
- break;
- case bfd_arch_i860:
- i_ehdrp->e_machine = EM_860;
- break;
- case bfd_arch_mips: /* MIPS Rxxxx */
- i_ehdrp->e_machine = EM_MIPS; /* only MIPS R3000 */
- break;
- case bfd_arch_hppa:
- i_ehdrp->e_machine = EM_PARISC;
- break;
- case bfd_arch_powerpc:
- i_ehdrp->e_machine = EM_PPC;
- break;
- /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
- default:
- i_ehdrp->e_machine = EM_NONE;
- }
- i_ehdrp->e_version = bed->s->ev_current;
- i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
-
- /* no program header, for now. */
- i_ehdrp->e_phoff = 0;
- i_ehdrp->e_phentsize = 0;
- i_ehdrp->e_phnum = 0;
-
- /* each bfd section is section header entry */
- i_ehdrp->e_entry = bfd_get_start_address (abfd);
- i_ehdrp->e_shentsize = bed->s->sizeof_shdr;
-
- /* if we're building an executable, we'll need a program header table */
- if (abfd->flags & EXEC_P)
- {
- /* it all happens later */
-#if 0
- i_ehdrp->e_phentsize = sizeof (Elf_External_Phdr);
-
- /* elf_build_phdrs() returns a (NULL-terminated) array of
- Elf_Internal_Phdrs */
- i_phdrp = elf_build_phdrs (abfd, i_ehdrp, i_shdrp, &i_ehdrp->e_phnum);
- i_ehdrp->e_phoff = outbase;
- outbase += i_ehdrp->e_phentsize * i_ehdrp->e_phnum;
-#endif
- }
- else
- {
- i_ehdrp->e_phentsize = 0;
- i_phdrp = 0;
- i_ehdrp->e_phoff = 0;
- }
-
- elf_tdata (abfd)->symtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".symtab", true, false);
- elf_tdata (abfd)->strtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".strtab", true, false);
- elf_tdata (abfd)->shstrtab_hdr.sh_name =
- (unsigned int) _bfd_stringtab_add (shstrtab, ".shstrtab", true, false);
- if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
- || elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
- || elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1)
- return false;
-
- return true;
-}
-
-/* Assign file positions for all the reloc sections which are not part
- of the loadable file image. */
-
-void
-_bfd_elf_assign_file_positions_for_relocs (abfd)
- bfd *abfd;
-{
- file_ptr off;
- unsigned int i;
- Elf_Internal_Shdr **shdrpp;
-
- off = elf_tdata (abfd)->next_file_pos;
-
- for (i = 1, shdrpp = elf_elfsections (abfd) + 1;
- i < elf_elfheader (abfd)->e_shnum;
- i++, shdrpp++)
- {
- Elf_Internal_Shdr *shdrp;
-
- shdrp = *shdrpp;
- if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA)
- && shdrp->sh_offset == -1)
- off = _bfd_elf_assign_file_position_for_section (shdrp, off, true);
- }
-
- elf_tdata (abfd)->next_file_pos = off;
-}
-
-boolean
-_bfd_elf_write_object_contents (abfd)
- bfd *abfd;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- Elf_Internal_Ehdr *i_ehdrp;
- Elf_Internal_Shdr **i_shdrp;
- boolean failed;
- unsigned int count;
-
- if (! abfd->output_has_begun
- && ! _bfd_elf_compute_section_file_positions (abfd,
- (struct bfd_link_info *) NULL))
- return false;
-
- i_shdrp = elf_elfsections (abfd);
- i_ehdrp = elf_elfheader (abfd);
-
- failed = false;
- bfd_map_over_sections (abfd, bed->s->write_relocs, &failed);
- if (failed)
- return false;
- _bfd_elf_assign_file_positions_for_relocs (abfd);
-
- /* After writing the headers, we need to write the sections too... */
- for (count = 1; count < i_ehdrp->e_shnum; count++)
- {
- if (bed->elf_backend_section_processing)
- (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
- if (i_shdrp[count]->contents)
- {
- if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
- || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size,
- 1, abfd)
- != i_shdrp[count]->sh_size))
- return false;
- }
- }
-
- /* Write out the section header names. */
- if (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd, elf_shstrtab (abfd)))
- return false;
-
- if (bed->elf_backend_final_write_processing)
- (*bed->elf_backend_final_write_processing) (abfd,
- elf_tdata (abfd)->linker);
-
- return bed->s->write_shdrs_and_ehdr (abfd);
-}
-
-/* given a section, search the header to find them... */
-int
-_bfd_elf_section_from_bfd_section (abfd, asect)
- bfd *abfd;
- struct sec *asect;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
- int index;
- Elf_Internal_Shdr *hdr;
- int maxindex = elf_elfheader (abfd)->e_shnum;
-
- for (index = 0; index < maxindex; index++)
- {
- hdr = i_shdrp[index];
- if (hdr->bfd_section == asect)
- return index;
- }
-
- if (bed->elf_backend_section_from_bfd_section)
- {
- for (index = 0; index < maxindex; index++)
- {
- int retval;
-
- hdr = i_shdrp[index];
- retval = index;
- if ((*bed->elf_backend_section_from_bfd_section)
- (abfd, hdr, asect, &retval))
- return retval;
- }
- }
-
- if (bfd_is_abs_section (asect))
- return SHN_ABS;
- if (bfd_is_com_section (asect))
- return SHN_COMMON;
- if (bfd_is_und_section (asect))
- return SHN_UNDEF;
-
- return -1;
-}
-
-/* Given a BFD symbol, return the index in the ELF symbol table, or -1
- on error. */
-
-int
-_bfd_elf_symbol_from_bfd_symbol (abfd, asym_ptr_ptr)
- bfd *abfd;
- struct symbol_cache_entry **asym_ptr_ptr;
-{
- struct symbol_cache_entry *asym_ptr = *asym_ptr_ptr;
- int idx;
- flagword flags = asym_ptr->flags;
-
- /* When gas creates relocations against local labels, it creates its
- own symbol for the section, but does put the symbol into the
- symbol chain, so udata is 0. When the linker is generating
- relocatable output, this section symbol may be for one of the
- input sections rather than the output section. */
- if (asym_ptr->udata.i == 0
- && (flags & BSF_SECTION_SYM)
- && asym_ptr->section)
- {
- int indx;
-
- if (asym_ptr->section->output_section != NULL)
- indx = asym_ptr->section->output_section->index;
- else
- indx = asym_ptr->section->index;
- if (elf_section_syms (abfd)[indx])
- asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
- }
-
- idx = asym_ptr->udata.i;
-
- if (idx == 0)
- {
- /* This case can occur when using --strip-symbol on a symbol
- which is used in a relocation entry. */
- (*_bfd_error_handler)
- ("%s: symbol `%s' required but not present",
- bfd_get_filename (abfd), bfd_asymbol_name (asym_ptr));
- bfd_set_error (bfd_error_no_symbols);
- return -1;
- }
-
-#if DEBUG & 4
- {
- fprintf (stderr,
- "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx%s\n",
- (long) asym_ptr, asym_ptr->name, idx, flags,
- elf_symbol_flags (flags));
- fflush (stderr);
- }
-#endif
-
- return idx;
-}
-
-/* Copy private BFD data. This copies any program header information. */
-
-static boolean
-copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- Elf_Internal_Ehdr *iehdr;
- struct elf_segment_map *mfirst;
- struct elf_segment_map **pm;
- Elf_Internal_Phdr *p;
- unsigned int i, c;
-
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- if (elf_tdata (ibfd)->phdr == NULL)
- return true;
-
- iehdr = elf_elfheader (ibfd);
-
- mfirst = NULL;
- pm = &mfirst;
-
- c = elf_elfheader (ibfd)->e_phnum;
- for (i = 0, p = elf_tdata (ibfd)->phdr; i < c; i++, p++)
- {
- unsigned int csecs;
- asection *s;
- struct elf_segment_map *m;
- unsigned int isec;
-
- csecs = 0;
-
- /* The complicated case when p_vaddr is 0 is to handle the
- Solaris linker, which generates a PT_INTERP section with
- p_vaddr and p_memsz set to 0. */
- for (s = ibfd->sections; s != NULL; s = s->next)
- if (((s->vma >= p->p_vaddr
- && (s->vma + s->_raw_size <= p->p_vaddr + p->p_memsz
- || s->vma + s->_raw_size <= p->p_vaddr + p->p_filesz))
- || (p->p_vaddr == 0
- && p->p_filesz > 0
- && (s->flags & SEC_HAS_CONTENTS) != 0
- && (bfd_vma) s->filepos >= p->p_offset
- && ((bfd_vma) s->filepos + s->_raw_size
- <= p->p_offset + p->p_filesz)))
- && (s->flags & SEC_ALLOC) != 0
- && s->output_section != NULL)
- ++csecs;
-
- m = ((struct elf_segment_map *)
- bfd_alloc (obfd,
- (sizeof (struct elf_segment_map)
- + (csecs - 1) * sizeof (asection *))));
- if (m == NULL)
- return false;
-
- m->next = NULL;
- m->p_type = p->p_type;
- m->p_flags = p->p_flags;
- m->p_flags_valid = 1;
- m->p_paddr = p->p_paddr;
- m->p_paddr_valid = 1;
-
- m->includes_filehdr = (p->p_offset == 0
- && p->p_filesz >= iehdr->e_ehsize);
-
- m->includes_phdrs = (p->p_offset <= (bfd_vma) iehdr->e_phoff
- && (p->p_offset + p->p_filesz
- >= ((bfd_vma) iehdr->e_phoff
- + iehdr->e_phnum * iehdr->e_phentsize)));
-
- isec = 0;
- for (s = ibfd->sections; s != NULL; s = s->next)
- {
- if (((s->vma >= p->p_vaddr
- && (s->vma + s->_raw_size <= p->p_vaddr + p->p_memsz
- || s->vma + s->_raw_size <= p->p_vaddr + p->p_filesz))
- || (p->p_vaddr == 0
- && p->p_filesz > 0
- && (s->flags & SEC_HAS_CONTENTS) != 0
- && (bfd_vma) s->filepos >= p->p_offset
- && ((bfd_vma) s->filepos + s->_raw_size
- <= p->p_offset + p->p_filesz)))
- && (s->flags & SEC_ALLOC) != 0
- && s->output_section != NULL)
- {
- m->sections[isec] = s->output_section;
- ++isec;
- }
- }
- BFD_ASSERT (isec == csecs);
- m->count = csecs;
-
- *pm = m;
- pm = &m->next;
- }
-
- elf_tdata (obfd)->segment_map = mfirst;
-
- return true;
-}
-
-/* Copy private section information. This copies over the entsize
- field, and sometimes the info field. */
-
-boolean
-_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)
- bfd *ibfd;
- asection *isec;
- bfd *obfd;
- asection *osec;
-{
- Elf_Internal_Shdr *ihdr, *ohdr;
-
- if (ibfd->xvec->flavour != bfd_target_elf_flavour
- || obfd->xvec->flavour != bfd_target_elf_flavour)
- return true;
-
- /* Copy over private BFD data if it has not already been copied.
- This must be done here, rather than in the copy_private_bfd_data
- entry point, because the latter is called after the section
- contents have been set, which means that the program headers have
- already been worked out. */
- if (elf_tdata (obfd)->segment_map == NULL
- && elf_tdata (ibfd)->phdr != NULL)
- {
- asection *s;
-
- /* Only set up the segments when all the sections have been set
- up. */
- for (s = ibfd->sections; s != NULL; s = s->next)
- if (s->output_section == NULL)
- break;
- if (s == NULL)
- {
- if (! copy_private_bfd_data (ibfd, obfd))
- return false;
- }
- }
-
- ihdr = &elf_section_data (isec)->this_hdr;
- ohdr = &elf_section_data (osec)->this_hdr;
-
- ohdr->sh_entsize = ihdr->sh_entsize;
-
- if (ihdr->sh_type == SHT_SYMTAB
- || ihdr->sh_type == SHT_DYNSYM)
- ohdr->sh_info = ihdr->sh_info;
-
- return true;
-}
-
-/* Copy private symbol information. If this symbol is in a section
- which we did not map into a BFD section, try to map the section
- index correctly. We use special macro definitions for the mapped
- section indices; these definitions are interpreted by the
- swap_out_syms function. */
-
-#define MAP_ONESYMTAB (SHN_LORESERVE - 1)
-#define MAP_DYNSYMTAB (SHN_LORESERVE - 2)
-#define MAP_STRTAB (SHN_LORESERVE - 3)
-#define MAP_SHSTRTAB (SHN_LORESERVE - 4)
-
-boolean
-_bfd_elf_copy_private_symbol_data (ibfd, isymarg, obfd, osymarg)
- bfd *ibfd;
- asymbol *isymarg;
- bfd *obfd;
- asymbol *osymarg;
-{
- elf_symbol_type *isym, *osym;
-
- isym = elf_symbol_from (ibfd, isymarg);
- osym = elf_symbol_from (obfd, osymarg);
-
- if (isym != NULL
- && osym != NULL
- && bfd_is_abs_section (isym->symbol.section))
- {
- unsigned int shndx;
-
- shndx = isym->internal_elf_sym.st_shndx;
- if (shndx == elf_onesymtab (ibfd))
- shndx = MAP_ONESYMTAB;
- else if (shndx == elf_dynsymtab (ibfd))
- shndx = MAP_DYNSYMTAB;
- else if (shndx == elf_tdata (ibfd)->strtab_section)
- shndx = MAP_STRTAB;
- else if (shndx == elf_tdata (ibfd)->shstrtab_section)
- shndx = MAP_SHSTRTAB;
- osym->internal_elf_sym.st_shndx = shndx;
- }
-
- return true;
-}
-
-/* Swap out the symbols. */
-
-static boolean
-swap_out_syms (abfd, sttp)
- bfd *abfd;
- struct bfd_strtab_hash **sttp;
-{
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (!elf_map_symbols (abfd))
- return false;
-
- /* Dump out the symtabs. */
- {
- int symcount = bfd_get_symcount (abfd);
- asymbol **syms = bfd_get_outsymbols (abfd);
- struct bfd_strtab_hash *stt;
- Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Shdr *symstrtab_hdr;
- char *outbound_syms;
- int idx;
-
- stt = _bfd_elf_stringtab_init ();
- if (stt == NULL)
- return false;
-
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- symtab_hdr->sh_type = SHT_SYMTAB;
- symtab_hdr->sh_entsize = bed->s->sizeof_sym;
- symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1);
- symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
- symtab_hdr->sh_addralign = bed->s->file_align;
-
- symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
- symstrtab_hdr->sh_type = SHT_STRTAB;
-
- outbound_syms = bfd_alloc (abfd,
- (1 + symcount) * bed->s->sizeof_sym);
- if (outbound_syms == NULL)
- return false;
- symtab_hdr->contents = (PTR) outbound_syms;
-
- /* now generate the data (for "contents") */
- {
- /* Fill in zeroth symbol and swap it out. */
- Elf_Internal_Sym sym;
- sym.st_name = 0;
- sym.st_value = 0;
- sym.st_size = 0;
- sym.st_info = 0;
- sym.st_other = 0;
- sym.st_shndx = SHN_UNDEF;
- bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
- outbound_syms += bed->s->sizeof_sym;
- }
- for (idx = 0; idx < symcount; idx++)
- {
- Elf_Internal_Sym sym;
- bfd_vma value = syms[idx]->value;
- elf_symbol_type *type_ptr;
- flagword flags = syms[idx]->flags;
- int type;
-
- if (flags & BSF_SECTION_SYM)
- /* Section symbols have no names. */
- sym.st_name = 0;
- else
- {
- sym.st_name = (unsigned long) _bfd_stringtab_add (stt,
- syms[idx]->name,
- true, false);
- if (sym.st_name == (unsigned long) -1)
- return false;
- }
-
- type_ptr = elf_symbol_from (abfd, syms[idx]);
-
- if (bfd_is_com_section (syms[idx]->section))
- {
- /* ELF common symbols put the alignment into the `value' field,
- and the size into the `size' field. This is backwards from
- how BFD handles it, so reverse it here. */
- sym.st_size = value;
- if (type_ptr == NULL
- || type_ptr->internal_elf_sym.st_value == 0)
- sym.st_value = value >= 16 ? 16 : (1 << bfd_log2 (value));
- else
- sym.st_value = type_ptr->internal_elf_sym.st_value;
- sym.st_shndx = _bfd_elf_section_from_bfd_section (abfd,
- syms[idx]->section);
- }
- else
- {
- asection *sec = syms[idx]->section;
- int shndx;
-
- if (sec->output_section)
- {
- value += sec->output_offset;
- sec = sec->output_section;
- }
- value += sec->vma;
- sym.st_value = value;
- sym.st_size = type_ptr ? type_ptr->internal_elf_sym.st_size : 0;
-
- if (bfd_is_abs_section (sec)
- && type_ptr != NULL
- && type_ptr->internal_elf_sym.st_shndx != 0)
- {
- /* This symbol is in a real ELF section which we did
- not create as a BFD section. Undo the mapping done
- by copy_private_symbol_data. */
- shndx = type_ptr->internal_elf_sym.st_shndx;
- switch (shndx)
- {
- case MAP_ONESYMTAB:
- shndx = elf_onesymtab (abfd);
- break;
- case MAP_DYNSYMTAB:
- shndx = elf_dynsymtab (abfd);
- break;
- case MAP_STRTAB:
- shndx = elf_tdata (abfd)->strtab_section;
- break;
- case MAP_SHSTRTAB:
- shndx = elf_tdata (abfd)->shstrtab_section;
- break;
- default:
- break;
- }
- }
- else
- {
- shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
-
- if (shndx == -1)
- {
- asection *sec2;
-
- /* Writing this would be a hell of a lot easier if
- we had some decent documentation on bfd, and
- knew what to expect of the library, and what to
- demand of applications. For example, it
- appears that `objcopy' might not set the
- section of a symbol to be a section that is
- actually in the output file. */
- sec2 = bfd_get_section_by_name (abfd, sec->name);
- BFD_ASSERT (sec2 != 0);
- shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
- BFD_ASSERT (shndx != -1);
- }
- }
-
- sym.st_shndx = shndx;
- }
-
- if ((flags & BSF_FUNCTION) != 0)
- type = STT_FUNC;
- else if ((flags & BSF_OBJECT) != 0)
- type = STT_OBJECT;
- else
- type = STT_NOTYPE;
-
- if (bfd_is_com_section (syms[idx]->section))
- sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
- else if (bfd_is_und_section (syms[idx]->section))
- sym.st_info = ELF_ST_INFO (((flags & BSF_WEAK)
- ? STB_WEAK
- : STB_GLOBAL),
- type);
- else if (flags & BSF_SECTION_SYM)
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- else if (flags & BSF_FILE)
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
- else
- {
- int bind = STB_LOCAL;
-
- if (flags & BSF_LOCAL)
- bind = STB_LOCAL;
- else if (flags & BSF_WEAK)
- bind = STB_WEAK;
- else if (flags & BSF_GLOBAL)
- bind = STB_GLOBAL;
-
- sym.st_info = ELF_ST_INFO (bind, type);
- }
-
- sym.st_other = 0;
- bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
- outbound_syms += bed->s->sizeof_sym;
- }
-
- *sttp = stt;
- symstrtab_hdr->sh_size = _bfd_stringtab_size (stt);
- symstrtab_hdr->sh_type = SHT_STRTAB;
-
- symstrtab_hdr->sh_flags = 0;
- symstrtab_hdr->sh_addr = 0;
- symstrtab_hdr->sh_entsize = 0;
- symstrtab_hdr->sh_link = 0;
- symstrtab_hdr->sh_info = 0;
- symstrtab_hdr->sh_addralign = 1;
- }
-
- return true;
-}
-
-/* Return the number of bytes required to hold the symtab vector.
-
- Note that we base it on the count plus 1, since we will null terminate
- the vector allocated based on this size. However, the ELF symbol table
- always has a dummy entry as symbol #0, so it ends up even. */
-
-long
-_bfd_elf_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- long symcount;
- long symtab_size;
- Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
-
- symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
- symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
-
- return symtab_size;
-}
-
-long
-_bfd_elf_get_dynamic_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- long symcount;
- long symtab_size;
- Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
-
- if (elf_dynsymtab (abfd) == 0)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
- symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
-
- return symtab_size;
-}
-
-long
-_bfd_elf_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-/* Canonicalize the relocs. */
-
-long
-_bfd_elf_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr;
- unsigned int i;
-
- if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, section, symbols))
- return -1;
-
- tblptr = section->relocation;
- for (i = 0; i < section->reloc_count; i++)
- *relptr++ = tblptr++;
-
- *relptr = NULL;
-
- return section->reloc_count;
-}
-
-long
-_bfd_elf_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- long symcount = get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, false);
-
- if (symcount >= 0)
- bfd_get_symcount (abfd) = symcount;
- return symcount;
-}
-
-long
-_bfd_elf_canonicalize_dynamic_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- return get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, true);
-}
-
-asymbol *
-_bfd_elf_make_empty_symbol (abfd)
- bfd *abfd;
-{
- elf_symbol_type *newsym;
-
- newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
- if (!newsym)
- return NULL;
- else
- {
- newsym->symbol.the_bfd = abfd;
- return &newsym->symbol;
- }
-}
-
-void
-_bfd_elf_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-alent *
-_bfd_elf_get_lineno (ignore_abfd, symbol)
- bfd *ignore_abfd;
- asymbol *symbol;
-{
- abort ();
- return NULL;
-}
-
-boolean
-_bfd_elf_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- /* If this isn't the right architecture for this backend, and this
- isn't the generic backend, fail. */
- if (arch != get_elf_backend_data (abfd)->arch
- && arch != bfd_arch_unknown
- && get_elf_backend_data (abfd)->arch != bfd_arch_unknown)
- return false;
-
- return bfd_default_set_arch_mach (abfd, arch, machine);
-}
-
-/* Find the nearest line to a particular section and offset, for error
- reporting. */
-
-boolean
-_bfd_elf_find_nearest_line (abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *line_ptr;
-{
- boolean found;
- const char *filename;
- asymbol *func;
- bfd_vma low_func;
- asymbol **p;
-
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &elf_tdata (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- if (symbols == NULL)
- return false;
-
- filename = NULL;
- func = NULL;
- low_func = 0;
-
- for (p = symbols; *p != NULL; p++)
- {
- elf_symbol_type *q;
-
- q = (elf_symbol_type *) *p;
-
- if (bfd_get_section (&q->symbol) != section)
- continue;
-
- switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
- {
- default:
- break;
- case STT_FILE:
- filename = bfd_asymbol_name (&q->symbol);
- break;
- case STT_FUNC:
- if (q->symbol.section == section
- && q->symbol.value >= low_func
- && q->symbol.value <= offset)
- {
- func = (asymbol *) q;
- low_func = q->symbol.value;
- }
- break;
- }
- }
-
- if (func == NULL)
- return false;
-
- *filename_ptr = filename;
- *functionname_ptr = bfd_asymbol_name (func);
- *line_ptr = 0;
- return true;
-}
-
-int
-_bfd_elf_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- int ret;
-
- ret = get_elf_backend_data (abfd)->s->sizeof_ehdr;
- if (! reloc)
- ret += get_program_header_size (abfd);
- return ret;
-}
-
-boolean
-_bfd_elf_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- Elf_Internal_Shdr *hdr;
-
- if (! abfd->output_has_begun
- && ! _bfd_elf_compute_section_file_positions (abfd,
- (struct bfd_link_info *) NULL))
- return false;
-
- hdr = &elf_section_data (section)->this_hdr;
-
- if (bfd_seek (abfd, hdr->sh_offset + offset, SEEK_SET) == -1)
- return false;
- if (bfd_write (location, 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-void
-_bfd_elf_no_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rela *dst;
-{
- abort ();
-}
-
-#if 0
-void
-_bfd_elf_no_info_to_howto_rel (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rel *dst;
-{
- abort ();
-}
-#endif
diff --git a/contrib/gdb/bfd/format.c b/contrib/gdb/bfd/format.c
deleted file mode 100644
index 7a303424..0000000
--- a/contrib/gdb/bfd/format.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* Generic BFD support for file formats.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- File formats
-
- A format is a BFD concept of high level file contents type. The
- formats supported by BFD are:
-
- o <<bfd_object>>
-
- The BFD may contain data, symbols, relocations and debug info.
-
- o <<bfd_archive>>
-
- The BFD contains other BFDs and an optional index.
-
- o <<bfd_core>>
-
- The BFD contains the result of an executable core dump.
-
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* IMPORT from targets.c. */
-extern const size_t _bfd_target_vector_entries;
-
-/*
-FUNCTION
- bfd_check_format
-
-SYNOPSIS
- boolean bfd_check_format(bfd *abfd, bfd_format format);
-
-DESCRIPTION
- Verify if the file attached to the BFD @var{abfd} is compatible
- with the format @var{format} (i.e., one of <<bfd_object>>,
- <<bfd_archive>> or <<bfd_core>>).
-
- If the BFD has been set to a specific target before the
- call, only the named target and format combination is
- checked. If the target has not been set, or has been set to
- <<default>>, then all the known target backends is
- interrogated to determine a match. If the default target
- matches, it is used. If not, exactly one target must recognize
- the file, or an error results.
-
- The function returns <<true>> on success, otherwise <<false>>
- with one of the following error codes:
-
- o <<bfd_error_invalid_operation>> -
- if <<format>> is not one of <<bfd_object>>, <<bfd_archive>> or
- <<bfd_core>>.
-
- o <<bfd_error_system_call>> -
- if an error occured during a read - even some file mismatches
- can cause bfd_error_system_calls.
-
- o <<file_not_recognised>> -
- none of the backends recognised the file format.
-
- o <<bfd_error_file_ambiguously_recognized>> -
- more than one backend recognised the file format.
-*/
-
-boolean
-bfd_check_format (abfd, format)
- bfd *abfd;
- bfd_format format;
-{
- return bfd_check_format_matches (abfd, format, NULL);
-}
-
-/*
-FUNCTION
- bfd_check_format_matches
-
-SYNOPSIS
- boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);
-
-DESCRIPTION
- Like <<bfd_check_format>>, except when it returns false with
- <<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>. In that
- case, if @var{matching} is not NULL, it will be filled in with
- a NULL-terminated list of the names of the formats that matched,
- allocated with <<malloc>>.
- Then the user may choose a format and try again.
-
- When done with the list that @var{matching} points to, the caller
- should free it.
-*/
-
-boolean
-bfd_check_format_matches (abfd, format, matching)
- bfd *abfd;
- bfd_format format;
- char ***matching;
-{
- const bfd_target * const *target, *save_targ, *right_targ;
- char **matching_vector = NULL;
- int match_count;
-
- if (!bfd_read_p (abfd) ||
- ((int)(abfd->format) < (int)bfd_unknown) ||
- ((int)(abfd->format) >= (int)bfd_type_end)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (abfd->format != bfd_unknown)
- return (abfd->format == format)? true: false;
-
-
- /* Since the target type was defaulted, check them
- all in the hope that one will be uniquely recognized. */
-
- save_targ = abfd->xvec;
- match_count = 0;
- if (matching)
- {
- matching_vector =
- (char **) bfd_malloc (sizeof (char *) *
- (_bfd_target_vector_entries + 1));
- if (!matching_vector)
- return false;
- matching_vector[0] = NULL;
- *matching = matching_vector;
- }
- right_targ = 0;
-
-
- /* presume the answer is yes */
- abfd->format = format;
-
- /* If the target type was explicitly specified, just check that target. */
-
- if (!abfd->target_defaulted) {
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0) /* rewind! */
- return false;
- right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
- if (right_targ) {
- abfd->xvec = right_targ; /* Set the target as returned */
- if (matching)
- free (matching_vector);
- return true; /* File position has moved, BTW */
- }
- }
-
- for (target = bfd_target_vector; *target != NULL; target++) {
- extern const bfd_target binary_vec;
- const bfd_target *temp;
-
- if (*target == &binary_vec)
- continue;
-
- abfd->xvec = *target; /* Change BFD's target temporarily */
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0)
- return false;
- /* If _bfd_check_format neglects to set bfd_error, assume bfd_error_wrong_format.
- We didn't used to even pay any attention to bfd_error, so I suspect
- that some _bfd_check_format might have this problem. */
- bfd_set_error (bfd_error_wrong_format);
- temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
- if (temp) { /* This format checks out as ok! */
- right_targ = temp;
- if (matching)
- {
- matching_vector[match_count] = temp->name;
- matching_vector[match_count + 1] = NULL;
- }
- match_count++;
- /* If this is the default target, accept it, even if other targets
- might match. People who want those other targets have to set
- the GNUTARGET variable. */
- if (temp == bfd_default_vector[0])
- {
- if (matching)
- {
- matching_vector[0] = temp->name;
- matching_vector[1] = NULL;
- }
- match_count = 1;
- break;
- }
-#ifdef GNU960
- /* Big- and little-endian b.out archives look the same, but it doesn't
- * matter: there is no difference in their headers, and member file byte
- * orders will (I hope) be handled appropriately by bfd. Ditto for big
- * and little coff archives. And the 4 coff/b.out object formats are
- * unambiguous. So accept the first match we find.
- */
- break;
-#endif
- } else if (bfd_get_error () != bfd_error_wrong_format) {
- abfd->xvec = save_targ;
- abfd->format = bfd_unknown;
- if (matching && bfd_get_error () != bfd_error_file_ambiguously_recognized)
- free (matching_vector);
- return false;
- }
- }
-
- if (match_count == 1) {
- abfd->xvec = right_targ; /* Change BFD's target permanently */
- if (matching)
- free (matching_vector);
- return true; /* File position has moved, BTW */
- }
-
- abfd->xvec = save_targ; /* Restore original target type */
- abfd->format = bfd_unknown; /* Restore original format */
- if (match_count == 0)
- {
- bfd_set_error (bfd_error_file_not_recognized);
- if (matching)
- free (matching_vector);
- }
- else
- bfd_set_error (bfd_error_file_ambiguously_recognized);
- return false;
-}
-
-/*
-FUNCTION
- bfd_set_format
-
-SYNOPSIS
- boolean bfd_set_format(bfd *abfd, bfd_format format);
-
-DESCRIPTION
- This function sets the file format of the BFD @var{abfd} to the
- format @var{format}. If the target set in the BFD does not
- support the format requested, the format is invalid, or the BFD
- is not open for writing, then an error occurs.
-
-*/
-
-boolean
-bfd_set_format (abfd, format)
- bfd *abfd;
- bfd_format format;
-{
-
- if (bfd_read_p (abfd) ||
- ((int)abfd->format < (int)bfd_unknown) ||
- ((int)abfd->format >= (int)bfd_type_end)) {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (abfd->format != bfd_unknown)
- return (abfd->format == format) ? true:false;
-
- /* presume the answer is yes */
- abfd->format = format;
-
- if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) {
- abfd->format = bfd_unknown;
- return false;
- }
-
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_format_string
-
-SYNOPSIS
- CONST char *bfd_format_string(bfd_format format);
-
-DESCRIPTION
- Return a pointer to a const string
- <<invalid>>, <<object>>, <<archive>>, <<core>>, or <<unknown>>,
- depending upon the value of @var{format}.
-*/
-
-CONST char *
-bfd_format_string (format)
- bfd_format format;
-{
- if (((int)format <(int) bfd_unknown)
- || ((int)format >=(int) bfd_type_end))
- return "invalid";
-
- switch (format) {
- case bfd_object:
- return "object"; /* linker/assember/compiler output */
- case bfd_archive:
- return "archive"; /* object archive file */
- case bfd_core:
- return "core"; /* core dump */
- default:
- return "unknown";
- }
-}
diff --git a/contrib/gdb/bfd/freebsd.h b/contrib/gdb/bfd/freebsd.h
deleted file mode 100644
index 43d29a9..0000000
--- a/contrib/gdb/bfd/freebsd.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* BFD back-end definitions used by all FreeBSD targets.
- Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/* FreeBSD ZMAGIC files never have the header in the text. */
-#define N_HEADER_IN_TEXT(x) 0
-
-/* A ZMAGIC file can start at almost any address if it is a kernel. */
-#define TEXT_START_ADDR dont use TEXT_START_ADDR
-
-/* The following definitions are essentially the same as the ones in
- FreeBSD's <sys/imgact_aout.h>. They override gdb's versions, which
- don't work for kernels. See ../include/aout/aout64.h. */
-#define N_TXTADDR(x) \
- (N_GETMAGIC(x) == OMAGIC || N_GETMAGIC(x) == NMAGIC \
- || N_GETMAGIC(x) == ZMAGIC \
- ? ((x).a_entry < (x).a_text ? 0 : (x).a_entry & ~TARGET_PAGE_SIZE) \
- : TARGET_PAGE_SIZE)
-#define N_TXTOFF(x) \
- (N_GETMAGIC(x) == ZMAGIC ? TARGET_PAGE_SIZE \
- : (N_GETMAGIC(x) == QMAGIC || N_GETMAGIC_NET(x) == ZMAGIC) ? 0 \
- : sizeof(struct external_exec))
-#define N_TXTSIZE(x) ((x).a_text)
-
-#define N_GETMAGIC(exec) \
- ((exec).a_info & 0xffff)
-#define N_GETMAGIC_NET(exec) \
- (ntohl ((exec).a_info) & 0xffff)
-#define N_GETMID_NET(exec) \
- ((ntohl ((exec).a_info) >> 16) & 0x3ff)
-#define N_GETFLAG_NET(ex) \
- ((ntohl ((exec).a_info) >> 26) & 0x3f)
-
-#define N_MACHTYPE(exec) \
- ((enum machine_type) \
- ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
- ((exec).a_info >> 16) & 0x3ff))
-#define N_FLAGS(exec) \
- ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
- ((exec).a_info >> 26) & 0x3f)
-
-#define N_SET_INFO(exec, magic, type, flags) \
- ((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0x3ff) << 16) \
- | (((flags) & 0x3f) << 26))
-#define N_SET_MACHTYPE(exec, machtype) \
- ((exec).a_info = \
- ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
-#define N_SET_FLAGS(exec, flags) \
- ((exec).a_info = \
- ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-/* On FreeBSD, the magic number is always in correct endian format */
-#define NO_SWAP_MAGIC
-
-
-#define MY_write_object_contents MY(write_object_contents)
-static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
-
-#include "aout-target.h"
-
-/* Write an object file.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-static boolean
-MY(write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
-#if CHOOSE_RELOC_SIZE
- CHOOSE_RELOC_SIZE(abfd);
-#else
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-#endif
-
- /* Magic number, maestro, please! */
- switch (bfd_get_arch(abfd)) {
- case bfd_arch_m68k:
- if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
- N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
- else
- N_SET_MACHTYPE(*execp, M_68K_NETBSD);
- break;
- case bfd_arch_sparc:
- N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
- break;
- case bfd_arch_i386:
- N_SET_MACHTYPE(*execp, M_386_NETBSD);
- break;
- case bfd_arch_ns32k:
- N_SET_MACHTYPE(*execp, M_532_NETBSD);
- break;
- default:
- N_SET_MACHTYPE(*execp, M_UNKNOWN);
- break;
- }
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
diff --git a/contrib/gdb/bfd/genlink.h b/contrib/gdb/bfd/genlink.h
deleted file mode 100644
index 5f08094..0000000
--- a/contrib/gdb/bfd/genlink.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* genlink.h -- interface to the BFD generic linker
- Copyright 1993, 1994 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef GENLINK_H
-#define GENLINK_H
-
-/* This header file is internal to BFD. It describes the internal
- structures and functions used by the BFD generic linker, in case
- any of the more specific linkers want to use or call them. Note
- that some functions, such as _bfd_generic_link_hash_table_create,
- are declared in libbfd.h, because they are expected to be widely
- used. The functions and structures in this file will probably only
- be used by a few files besides linker.c itself. In fact, this file
- is not particularly complete; I have only put in the interfaces I
- actually needed. */
-
-/* The generic linker uses a hash table which is a derived class of
- the standard linker hash table, just as the other backend specific
- linkers do. Do not confuse the generic linker hash table with the
- standard BFD linker hash table it is built upon. */
-
-/* Generic linker hash table entries. */
-
-struct generic_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Whether this symbol has been written out. */
- boolean written;
- /* Symbol from input BFD. */
- asymbol *sym;
-};
-
-/* Generic linker hash table. */
-
-struct generic_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in an generic link hash table. */
-
-#define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
- ((struct generic_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an generic link hash table. */
-
-#define _bfd_generic_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the generic link hash table from the info structure. This is
- just a cast. */
-
-#define _bfd_generic_hash_table(p) \
- ((struct generic_link_hash_table *) ((p)->hash))
-
-/* The generic linker reads in the asymbol structures for an input BFD
- and keeps them in the outsymbol and symcount fields. */
-
-#define _bfd_generic_link_get_symbols(abfd) ((abfd)->outsymbols)
-#define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
-
-/* Add the symbols of input_bfd to the symbols being built for
- output_bfd. */
-extern boolean _bfd_generic_link_output_symbols
- PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
- size_t *psymalloc));
-
-/* This structure is used to pass information to
- _bfd_generic_link_write_global_symbol, which may be called via
- _bfd_generic_link_hash_traverse. */
-
-struct generic_write_global_symbol_info
-{
- struct bfd_link_info *info;
- bfd *output_bfd;
- size_t *psymalloc;
-};
-
-/* Write out a single global symbol. This is expected to be called
- via _bfd_generic_link_hash_traverse. The second argument must
- actually be a struct generic_write_global_symbol_info *. */
-extern boolean _bfd_generic_link_write_global_symbol
- PARAMS ((struct generic_link_hash_entry *, PTR));
-
-#endif
diff --git a/contrib/gdb/bfd/hash.c b/contrib/gdb/bfd/hash.c
deleted file mode 100644
index 35913fc..0000000
--- a/contrib/gdb/bfd/hash.c
+++ /dev/null
@@ -1,734 +0,0 @@
-/* hash.c -- hash table routines for BFD
- Copyright (C) 1993, 94 Free Software Foundation, Inc.
- Written by Steve Chamberlain <sac@cygnus.com>
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-/*
-SECTION
- Hash Tables
-
-@cindex Hash tables
- BFD provides a simple set of hash table functions. Routines
- are provided to initialize a hash table, to free a hash table,
- to look up a string in a hash table and optionally create an
- entry for it, and to traverse a hash table. There is
- currently no routine to delete an string from a hash table.
-
- The basic hash table does not permit any data to be stored
- with a string. However, a hash table is designed to present a
- base class from which other types of hash tables may be
- derived. These derived types may store additional information
- with the string. Hash tables were implemented in this way,
- rather than simply providing a data pointer in a hash table
- entry, because they were designed for use by the linker back
- ends. The linker may create thousands of hash table entries,
- and the overhead of allocating private data and storing and
- following pointers becomes noticeable.
-
- The basic hash table code is in <<hash.c>>.
-
-@menu
-@* Creating and Freeing a Hash Table::
-@* Looking Up or Entering a String::
-@* Traversing a Hash Table::
-@* Deriving a New Hash Table Type::
-@end menu
-
-INODE
-Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables
-SUBSECTION
- Creating and freeing a hash table
-
-@findex bfd_hash_table_init
-@findex bfd_hash_table_init_n
- To create a hash table, create an instance of a <<struct
- bfd_hash_table>> (defined in <<bfd.h>>) and call
- <<bfd_hash_table_init>> (if you know approximately how many
- entries you will need, the function <<bfd_hash_table_init_n>>,
- which takes a @var{size} argument, may be used).
- <<bfd_hash_table_init>> returns <<false>> if some sort of
- error occurs.
-
-@findex bfd_hash_newfunc
- The function <<bfd_hash_table_init>> take as an argument a
- function to use to create new entries. For a basic hash
- table, use the function <<bfd_hash_newfunc>>. @xref{Deriving
- a New Hash Table Type} for why you would want to use a
- different value for this argument.
-
-@findex bfd_hash_allocate
- <<bfd_hash_table_init>> will create an obstack which will be
- used to allocate new entries. You may allocate memory on this
- obstack using <<bfd_hash_allocate>>.
-
-@findex bfd_hash_table_free
- Use <<bfd_hash_table_free>> to free up all the memory that has
- been allocated for a hash table. This will not free up the
- <<struct bfd_hash_table>> itself, which you must provide.
-
-INODE
-Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables
-SUBSECTION
- Looking up or entering a string
-
-@findex bfd_hash_lookup
- The function <<bfd_hash_lookup>> is used both to look up a
- string in the hash table and to create a new entry.
-
- If the @var{create} argument is <<false>>, <<bfd_hash_lookup>>
- will look up a string. If the string is found, it will
- returns a pointer to a <<struct bfd_hash_entry>>. If the
- string is not found in the table <<bfd_hash_lookup>> will
- return <<NULL>>. You should not modify any of the fields in
- the returns <<struct bfd_hash_entry>>.
-
- If the @var{create} argument is <<true>>, the string will be
- entered into the hash table if it is not already there.
- Either way a pointer to a <<struct bfd_hash_entry>> will be
- returned, either to the existing structure or to a newly
- created one. In this case, a <<NULL>> return means that an
- error occurred.
-
- If the @var{create} argument is <<true>>, and a new entry is
- created, the @var{copy} argument is used to decide whether to
- copy the string onto the hash table obstack or not. If
- @var{copy} is passed as <<false>>, you must be careful not to
- deallocate or modify the string as long as the hash table
- exists.
-
-INODE
-Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables
-SUBSECTION
- Traversing a hash table
-
-@findex bfd_hash_traverse
- The function <<bfd_hash_traverse>> may be used to traverse a
- hash table, calling a function on each element. The traversal
- is done in a random order.
-
- <<bfd_hash_traverse>> takes as arguments a function and a
- generic <<void *>> pointer. The function is called with a
- hash table entry (a <<struct bfd_hash_entry *>>) and the
- generic pointer passed to <<bfd_hash_traverse>>. The function
- must return a <<boolean>> value, which indicates whether to
- continue traversing the hash table. If the function returns
- <<false>>, <<bfd_hash_traverse>> will stop the traversal and
- return immediately.
-
-INODE
-Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables
-SUBSECTION
- Deriving a new hash table type
-
- Many uses of hash tables want to store additional information
- which each entry in the hash table. Some also find it
- convenient to store additional information with the hash table
- itself. This may be done using a derived hash table.
-
- Since C is not an object oriented language, creating a derived
- hash table requires sticking together some boilerplate
- routines with a few differences specific to the type of hash
- table you want to create.
-
- An example of a derived hash table is the linker hash table.
- The structures for this are defined in <<bfdlink.h>>. The
- functions are in <<linker.c>>.
-
- You may also derive a hash table from an already derived hash
- table. For example, the a.out linker backend code uses a hash
- table derived from the linker hash table.
-
-@menu
-@* Define the Derived Structures::
-@* Write the Derived Creation Routine::
-@* Write Other Derived Routines::
-@end menu
-
-INODE
-Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type
-SUBSUBSECTION
- Define the derived structures
-
- You must define a structure for an entry in the hash table,
- and a structure for the hash table itself.
-
- The first field in the structure for an entry in the hash
- table must be of the type used for an entry in the hash table
- you are deriving from. If you are deriving from a basic hash
- table this is <<struct bfd_hash_entry>>, which is defined in
- <<bfd.h>>. The first field in the structure for the hash
- table itself must be of the type of the hash table you are
- deriving from itself. If you are deriving from a basic hash
- table, this is <<struct bfd_hash_table>>.
-
- For example, the linker hash table defines <<struct
- bfd_link_hash_entry>> (in <<bfdlink.h>>). The first field,
- <<root>>, is of type <<struct bfd_hash_entry>>. Similarly,
- the first field in <<struct bfd_link_hash_table>>, <<table>>,
- is of type <<struct bfd_hash_table>>.
-
-INODE
-Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type
-SUBSUBSECTION
- Write the derived creation routine
-
- You must write a routine which will create and initialize an
- entry in the hash table. This routine is passed as the
- function argument to <<bfd_hash_table_init>>.
-
- In order to permit other hash tables to be derived from the
- hash table you are creating, this routine must be written in a
- standard way.
-
- The first argument to the creation routine is a pointer to a
- hash table entry. This may be <<NULL>>, in which case the
- routine should allocate the right amount of space. Otherwise
- the space has already been allocated by a hash table type
- derived from this one.
-
- After allocating space, the creation routine must call the
- creation routine of the hash table type it is derived from,
- passing in a pointer to the space it just allocated. This
- will initialize any fields used by the base hash table.
-
- Finally the creation routine must initialize any local fields
- for the new hash table type.
-
- Here is a boilerplate example of a creation routine.
- @var{function_name} is the name of the routine.
- @var{entry_type} is the type of an entry in the hash table you
- are creating. @var{base_newfunc} is the name of the creation
- routine of the hash table type your hash table is derived
- from.
-
-EXAMPLE
-
-.struct bfd_hash_entry *
-.@var{function_name} (entry, table, string)
-. struct bfd_hash_entry *entry;
-. struct bfd_hash_table *table;
-. const char *string;
-.{
-. struct @var{entry_type} *ret = (@var{entry_type} *) entry;
-.
-. {* Allocate the structure if it has not already been allocated by a
-. derived class. *}
-. if (ret == (@var{entry_type} *) NULL)
-. {
-. ret = ((@var{entry_type} *)
-. bfd_hash_allocate (table, sizeof (@var{entry_type})));
-. if (ret == (@var{entry_type} *) NULL)
-. return NULL;
-. }
-.
-. {* Call the allocation method of the base class. *}
-. ret = ((@var{entry_type} *)
-. @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string));
-.
-. {* Initialize the local fields here. *}
-.
-. return (struct bfd_hash_entry *) ret;
-.}
-
-DESCRIPTION
- The creation routine for the linker hash table, which is in
- <<linker.c>>, looks just like this example.
- @var{function_name} is <<_bfd_link_hash_newfunc>>.
- @var{entry_type} is <<struct bfd_link_hash_entry>>.
- @var{base_newfunc} is <<bfd_hash_newfunc>>, the creation
- routine for a basic hash table.
-
- <<_bfd_link_hash_newfunc>> also initializes the local fields
- in a linker hash table entry: <<type>>, <<written>> and
- <<next>>.
-
-INODE
-Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type
-SUBSUBSECTION
- Write other derived routines
-
- You will want to write other routines for your new hash table,
- as well.
-
- You will want an initialization routine which calls the
- initialization routine of the hash table you are deriving from
- and initializes any other local fields. For the linker hash
- table, this is <<_bfd_link_hash_table_init>> in <<linker.c>>.
-
- You will want a lookup routine which calls the lookup routine
- of the hash table you are deriving from and casts the result.
- The linker hash table uses <<bfd_link_hash_lookup>> in
- <<linker.c>> (this actually takes an additional argument which
- it uses to decide how to return the looked up value).
-
- You may want a traversal routine. This should just call the
- traversal routine of the hash table you are deriving from with
- appropriate casts. The linker hash table uses
- <<bfd_link_hash_traverse>> in <<linker.c>>.
-
- These routines may simply be defined as macros. For example,
- the a.out backend linker hash table, which is derived from the
- linker hash table, uses macros for the lookup and traversal
- routines. These are <<aout_link_hash_lookup>> and
- <<aout_link_hash_traverse>> in aoutx.h.
-*/
-
-/* Obstack allocation and deallocation routines. */
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-/* The default number of entries to use when creating a hash table. */
-#define DEFAULT_SIZE (4051)
-
-/* Create a new hash table, given a number of entries. */
-
-boolean
-bfd_hash_table_init_n (table, newfunc, size)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
- unsigned int size;
-{
- unsigned int alloc;
-
- alloc = size * sizeof (struct bfd_hash_entry *);
- if (!obstack_begin (&table->memory, alloc))
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- table->table = ((struct bfd_hash_entry **)
- obstack_alloc (&table->memory, alloc));
- if (!table->table)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- memset ((PTR) table->table, 0, alloc);
- table->size = size;
- table->newfunc = newfunc;
- return true;
-}
-
-/* Create a new hash table with the default number of entries. */
-
-boolean
-bfd_hash_table_init (table, newfunc)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return bfd_hash_table_init_n (table, newfunc, DEFAULT_SIZE);
-}
-
-/* Free a hash table. */
-
-void
-bfd_hash_table_free (table)
- struct bfd_hash_table *table;
-{
- obstack_free (&table->memory, (PTR) NULL);
-}
-
-/* Look up a string in a hash table. */
-
-struct bfd_hash_entry *
-bfd_hash_lookup (table, string, create, copy)
- struct bfd_hash_table *table;
- const char *string;
- boolean create;
- boolean copy;
-{
- register const unsigned char *s;
- register unsigned long hash;
- register unsigned int c;
- struct bfd_hash_entry *hashp;
- unsigned int len;
- unsigned int index;
-
- hash = 0;
- len = 0;
- s = (const unsigned char *) string;
- while ((c = *s++) != '\0')
- {
- hash += c + (c << 17);
- hash ^= hash >> 2;
- ++len;
- }
- hash += len + (len << 17);
- hash ^= hash >> 2;
-
- index = hash % table->size;
- for (hashp = table->table[index];
- hashp != (struct bfd_hash_entry *) NULL;
- hashp = hashp->next)
- {
- if (hashp->hash == hash
- && strcmp (hashp->string, string) == 0)
- return hashp;
- }
-
- if (! create)
- return (struct bfd_hash_entry *) NULL;
-
- hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string);
- if (hashp == (struct bfd_hash_entry *) NULL)
- return (struct bfd_hash_entry *) NULL;
- if (copy)
- {
- char *new;
-
- new = (char *) obstack_alloc (&table->memory, len + 1);
- if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) NULL;
- }
- strcpy (new, string);
- string = new;
- }
- hashp->string = string;
- hashp->hash = hash;
- hashp->next = table->table[index];
- table->table[index] = hashp;
-
- return hashp;
-}
-
-/* Replace an entry in a hash table. */
-
-void
-bfd_hash_replace (table, old, nw)
- struct bfd_hash_table *table;
- struct bfd_hash_entry *old;
- struct bfd_hash_entry *nw;
-{
- unsigned int index;
- struct bfd_hash_entry **pph;
-
- index = old->hash % table->size;
- for (pph = &table->table[index];
- (*pph) != (struct bfd_hash_entry *) NULL;
- pph = &(*pph)->next)
- {
- if (*pph == old)
- {
- *pph = nw;
- return;
- }
- }
-
- abort ();
-}
-
-/* Base method for creating a new hash table entry. */
-
-/*ARGSUSED*/
-struct bfd_hash_entry *
-bfd_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- if (entry == (struct bfd_hash_entry *) NULL)
- entry = ((struct bfd_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct bfd_hash_entry)));
- return entry;
-}
-
-/* Allocate space in a hash table. */
-
-PTR
-bfd_hash_allocate (table, size)
- struct bfd_hash_table *table;
- unsigned int size;
-{
- PTR ret;
-
- ret = obstack_alloc (&table->memory, size);
- if (ret == NULL && size != 0)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-/* Traverse a hash table. */
-
-void
-bfd_hash_traverse (table, func, info)
- struct bfd_hash_table *table;
- boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
- PTR info;
-{
- unsigned int i;
-
- for (i = 0; i < table->size; i++)
- {
- struct bfd_hash_entry *p;
-
- for (p = table->table[i]; p != NULL; p = p->next)
- {
- if (! (*func) (p, info))
- return;
- }
- }
-}
-
-/* A few different object file formats (a.out, COFF, ELF) use a string
- table. These functions support adding strings to a string table,
- returning the byte offset, and writing out the table.
-
- Possible improvements:
- + look for strings matching trailing substrings of other strings
- + better data structures? balanced trees?
- + look at reducing memory use elsewhere -- maybe if we didn't have
- to construct the entire symbol table at once, we could get by
- with smaller amounts of VM? (What effect does that have on the
- string table reductions?) */
-
-/* An entry in the strtab hash table. */
-
-struct strtab_hash_entry
-{
- struct bfd_hash_entry root;
- /* Index in string table. */
- bfd_size_type index;
- /* Next string in strtab. */
- struct strtab_hash_entry *next;
-};
-
-/* The strtab hash table. */
-
-struct bfd_strtab_hash
-{
- struct bfd_hash_table table;
- /* Size of strtab--also next available index. */
- bfd_size_type size;
- /* First string in strtab. */
- struct strtab_hash_entry *first;
- /* Last string in strtab. */
- struct strtab_hash_entry *last;
- /* Whether to precede strings with a two byte length, as in the
- XCOFF .debug section. */
- boolean xcoff;
-};
-
-static struct bfd_hash_entry *strtab_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-/* Routine to create an entry in a strtab. */
-
-static struct bfd_hash_entry *
-strtab_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct strtab_hash_entry *) NULL)
- ret = ((struct strtab_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
- if (ret == (struct strtab_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct strtab_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->index = (bfd_size_type) -1;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Look up an entry in an strtab. */
-
-#define strtab_hash_lookup(t, string, create, copy) \
- ((struct strtab_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* Create a new strtab. */
-
-struct bfd_strtab_hash *
-_bfd_stringtab_init ()
-{
- struct bfd_strtab_hash *table;
-
- table = ((struct bfd_strtab_hash *)
- bfd_malloc (sizeof (struct bfd_strtab_hash)));
- if (table == NULL)
- return NULL;
-
- if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
- {
- free (table);
- return NULL;
- }
-
- table->size = 0;
- table->first = NULL;
- table->last = NULL;
- table->xcoff = false;
-
- return table;
-}
-
-/* Create a new strtab in which the strings are output in the format
- used in the XCOFF .debug section: a two byte length precedes each
- string. */
-
-struct bfd_strtab_hash *
-_bfd_xcoff_stringtab_init ()
-{
- struct bfd_strtab_hash *ret;
-
- ret = _bfd_stringtab_init ();
- if (ret != NULL)
- ret->xcoff = true;
- return ret;
-}
-
-/* Free a strtab. */
-
-void
-_bfd_stringtab_free (table)
- struct bfd_strtab_hash *table;
-{
- bfd_hash_table_free (&table->table);
- free (table);
-}
-
-/* Get the index of a string in a strtab, adding it if it is not
- already present. If HASH is false, we don't really use the hash
- table, and we don't eliminate duplicate strings. */
-
-bfd_size_type
-_bfd_stringtab_add (tab, str, hash, copy)
- struct bfd_strtab_hash *tab;
- const char *str;
- boolean hash;
- boolean copy;
-{
- register struct strtab_hash_entry *entry;
-
- if (hash)
- {
- entry = strtab_hash_lookup (tab, str, true, copy);
- if (entry == NULL)
- return (bfd_size_type) -1;
- }
- else
- {
- entry = ((struct strtab_hash_entry *)
- bfd_hash_allocate (&tab->table,
- sizeof (struct strtab_hash_entry)));
- if (entry == NULL)
- return (bfd_size_type) -1;
- if (! copy)
- entry->root.string = str;
- else
- {
- char *n;
-
- n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
- if (n == NULL)
- return (bfd_size_type) -1;
- entry->root.string = n;
- }
- entry->index = (bfd_size_type) -1;
- entry->next = NULL;
- }
-
- if (entry->index == (bfd_size_type) -1)
- {
- entry->index = tab->size;
- tab->size += strlen (str) + 1;
- if (tab->xcoff)
- {
- entry->index += 2;
- tab->size += 2;
- }
- if (tab->first == NULL)
- tab->first = entry;
- else
- tab->last->next = entry;
- tab->last = entry;
- }
-
- return entry->index;
-}
-
-/* Get the number of bytes in a strtab. */
-
-bfd_size_type
-_bfd_stringtab_size (tab)
- struct bfd_strtab_hash *tab;
-{
- return tab->size;
-}
-
-/* Write out a strtab. ABFD must already be at the right location in
- the file. */
-
-boolean
-_bfd_stringtab_emit (abfd, tab)
- register bfd *abfd;
- struct bfd_strtab_hash *tab;
-{
- register boolean xcoff;
- register struct strtab_hash_entry *entry;
-
- xcoff = tab->xcoff;
-
- for (entry = tab->first; entry != NULL; entry = entry->next)
- {
- register const char *str;
- register size_t len;
-
- str = entry->root.string;
- len = strlen (str) + 1;
-
- if (xcoff)
- {
- bfd_byte buf[2];
-
- /* The output length includes the null byte. */
- bfd_put_16 (abfd, len, buf);
- if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
- return false;
- }
-
- if (bfd_write ((PTR) str, 1, len, abfd) != len)
- return false;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/hosts/alphalinux.h b/contrib/gdb/bfd/hosts/alphalinux.h
deleted file mode 100644
index d9ba1b7..0000000
--- a/contrib/gdb/bfd/hosts/alphalinux.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Linux dumps "struct task_struct" at the end of the core-file. This
- structure is currently 920 bytes long, but we allow up to 1024
- bytes to allow for some future growth. */
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 1024
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/contrib/gdb/bfd/hosts/decstation.h b/contrib/gdb/bfd/hosts/decstation.h
deleted file mode 100644
index a80c143..0000000
--- a/contrib/gdb/bfd/hosts/decstation.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Hopefully this should include either machine/param.h (Ultrix) or
- machine/machparam.h (Mach), whichever is its name on this system. */
-#include <sys/param.h>
-
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
diff --git a/contrib/gdb/bfd/hosts/delta68.h b/contrib/gdb/bfd/hosts/delta68.h
deleted file mode 100644
index 1a6a6e6..0000000
--- a/contrib/gdb/bfd/hosts/delta68.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Definitions for a Motorola Delta 3300 box running System V R3.0.
- Contributed by manfred@lts.sel.alcatel.de. */
-
-#include <sys/param.h>
-
-/* Definitions used by trad-core.c. */
-#define NBPG NBPC
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
-#if 0
-#define HOST_STACK_END_ADDR 0x40000000
-#else
-/* User's stack, copied from sys/param.h */
-#define HOST_STACK_END_ADDR USRSTACK
-#endif
-#define UPAGES USIZE
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- abfd->tdata.trad_core_data->u.u_abort
diff --git a/contrib/gdb/bfd/hosts/dpx2.h b/contrib/gdb/bfd/hosts/dpx2.h
deleted file mode 100644
index ea6395f..0000000
--- a/contrib/gdb/bfd/hosts/dpx2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Definitions that are needed for core files. Core section sizes for
- the DPX2 are in bytes. */
-
-#include <sys/param.h>
-#define NBPG 1
-#define UPAGES (USIZE * NBPP)
-#define HOST_DATA_START_ADDR (u.u_exdata.ux_datorg)
-#define HOST_STACK_END_ADDR (USERSTACK)
diff --git a/contrib/gdb/bfd/hosts/hp300bsd.h b/contrib/gdb/bfd/hosts/hp300bsd.h
deleted file mode 100644
index 9828717..0000000
--- a/contrib/gdb/bfd/hosts/hp300bsd.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <sys/param.h>
-#ifdef BSD4_4
-#define NO_CORE_COMMAND
-#endif
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG /* Data seg start addr rounds to NBPG */
-#define HOST_MACHINE_ARCH bfd_arch_m68k
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR 0xfff00000
-#define HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/i386bsd.h b/contrib/gdb/bfd/hosts/i386bsd.h
deleted file mode 100644
index ac0d840..0000000
--- a/contrib/gdb/bfd/hosts/i386bsd.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Intel 386 running any BSD Unix */
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-
-/* Jolitz suggested defining HOST_STACK_END_ADDR to
- (u.u_kproc.kp_eproc.e_vm.vm_maxsaddr + MAXSSIZ), which should work on
- both BSDI and 386BSD, but that is believed not to work for BSD 4.4. */
-
-#ifdef __bsdi__
-/* This seems to be the right thing for BSDI. */
-#define HOST_STACK_END_ADDR USRSTACK
-#define HOST_DATA_START_ADDR ((bfd_vma)u.u_kproc.kp_eproc.e_vm.vm_daddr)
-#else
-/* This seems to be the right thing for 386BSD release 0.1. */
-#define HOST_STACK_END_ADDR (USRSTACK - MAXSSIZ)
-#endif
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_sig)
-#define u_comm u_kproc.kp_proc.p_comm
diff --git a/contrib/gdb/bfd/hosts/i386linux.h b/contrib/gdb/bfd/hosts/i386linux.h
deleted file mode 100644
index 13a51f1..0000000
--- a/contrib/gdb/bfd/hosts/i386linux.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Linux writes the task structure at the end of the core file. Currently it
- is 2912 bytes. It is possible that this should be a pickier check, but
- we should probably not be too picky (the size of the task structure might
- vary, and if it's not the length we expect it to be, it doesn't affect
- our ability to process the core file). So allow 0-4096 extra bytes at
- the end. */
-
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
diff --git a/contrib/gdb/bfd/hosts/i386mach3.h b/contrib/gdb/bfd/hosts/i386mach3.h
deleted file mode 100644
index dcc61e3..0000000
--- a/contrib/gdb/bfd/hosts/i386mach3.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-/* This is an ugly way to hack around the incorrect
- * definition of UPAGES in i386/machparam.h.
- *
- * The definition should specify the size reserved
- * for "struct user" in core files in PAGES,
- * but instead it gives it in 512-byte core-clicks
- * for i386 and i860. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-FIXME!! UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i386
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/i386sco.h b/contrib/gdb/bfd/hosts/i386sco.h
deleted file mode 100644
index ec8608c..0000000
--- a/contrib/gdb/bfd/hosts/i386sco.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Core file stuff. At least some, perhaps all, of the following
- defines work on many more systems than just SCO. */
-
-#define NBPG NBPC
-#define UPAGES USIZE
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_STACK_START_ADDR u.u_sub
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((core_upage(abfd)->u_sysabort != 0) \
- ? core_upage(abfd)->u_sysabort \
- : -1)
-
-/* According to the manpage, a version 2 SCO corefile can contain
- various additional sections (it is cleverly arranged so the u area,
- data, and stack are first where we can find them). So without
- writing lots of code to parse all their headers and stuff, we can't
- know whether a corefile is bigger than it should be. */
-
-#define TRAD_CORE_ALLOW_ANY_EXTRA_SIZE 1
diff --git a/contrib/gdb/bfd/hosts/i860mach3.h b/contrib/gdb/bfd/hosts/i860mach3.h
deleted file mode 100644
index edd2aa1..0000000
--- a/contrib/gdb/bfd/hosts/i860mach3.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* This file was hacked from i386mach3.h [dolan@ssd.intel.com] */
-
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-/* This is an ugly way to hack around the incorrect
- * definition of UPAGES in i386/machparam.h.
- *
- * The definition should specify the size reserved
- * for "struct user" in core files in PAGES,
- * but instead it gives it in 512-byte core-clicks
- * for i386 and i860. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-FIXME!! UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_i860
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/m68kaux.h b/contrib/gdb/bfd/hosts/m68kaux.h
deleted file mode 100644
index 6237755..0000000
--- a/contrib/gdb/bfd/hosts/m68kaux.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Definitions for an Apple Macintosh running A/UX 3.x. */
-
-#include <sys/param.h>
-#include <sys/page.h>
-
-/* Definitions used by trad-core.c. */
-#define NBPG NBPP
-
-#define HOST_DATA_START_ADDR u.u_exdata.ux_datorg
-#define HOST_TEXT_START_ADDR u.u_exdata.ux_txtorg
-#define HOST_STACK_END_ADDR 0x100000000
-
-#define UPAGES USIZE
-
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- (abfd->tdata.trad_core_data->u.u_arg[0])
diff --git a/contrib/gdb/bfd/hosts/m68klinux.h b/contrib/gdb/bfd/hosts/m68klinux.h
deleted file mode 100644
index 0067dfa..0000000
--- a/contrib/gdb/bfd/hosts/m68klinux.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Linux dumps "struct task_struct" at the end of the core-file. This
- structure is currently 2512 bytes long, but we allow up to 4096
- bytes to allow for some future growth. */
-#define TRAD_CORE_EXTRA_SIZE_ALLOWED 4096
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(abfd) \
- ((abfd)->tdata.trad_core_data->u.signal)
diff --git a/contrib/gdb/bfd/hosts/m88kmach3.h b/contrib/gdb/bfd/hosts/m88kmach3.h
deleted file mode 100644
index 4215538..0000000
--- a/contrib/gdb/bfd/hosts/m88kmach3.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-#undef UPAGES
-#define UPAGES 3
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_m88k
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/mipsbsd.h b/contrib/gdb/bfd/hosts/mipsbsd.h
deleted file mode 100644
index a2fad21..0000000
--- a/contrib/gdb/bfd/hosts/mipsbsd.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#undef ALIGN
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG -- we use HOST_DATA_START_ADDR */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-/* #define HOST_MACHINE_MACHINE */
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#define NO_CORE_COMMAND
diff --git a/contrib/gdb/bfd/hosts/mipsmach3.h b/contrib/gdb/bfd/hosts/mipsmach3.h
deleted file mode 100644
index c5c468d..0000000
--- a/contrib/gdb/bfd/hosts/mipsmach3.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <machine/vmparam.h>
-#include <machine/machparam.h>
-#include <sys/param.h>
-
-#define HOST_PAGE_SIZE NBPG
-/* #define HOST_SEGMENT_SIZE NBPG */
-#define HOST_MACHINE_ARCH bfd_arch_mips
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/news-mips.h b/contrib/gdb/bfd/hosts/news-mips.h
deleted file mode 100644
index 9e799be..0000000
--- a/contrib/gdb/bfd/hosts/news-mips.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Sony News running NewsOS 3.2. */
-
-#include <sys/param.h>
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-
-#define HOST_MACHINE_ARCH bfd_arch_mips
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_DATA_START_ADDR USRDATA
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/news.h b/contrib/gdb/bfd/hosts/news.h
deleted file mode 100644
index bf7946c..0000000
--- a/contrib/gdb/bfd/hosts/news.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Sony News running NewsOS 3.2. */
-
-#include <machine/vmparam.h>
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_m68k
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
diff --git a/contrib/gdb/bfd/hosts/pc532mach.h b/contrib/gdb/bfd/hosts/pc532mach.h
deleted file mode 100644
index ab96f59..0000000
--- a/contrib/gdb/bfd/hosts/pc532mach.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <machine/vmparam.h>
-#include <sys/param.h>
-
-/* This is an ugly way to hack around the incorrect
- * definition of UPAGES in ns532/machparam.h.
- *
- * The definition should specify the size reserved
- * for "struct user" in core files in PAGES,
- * but instead it gives it in 512-byte core-clicks
- * for ns532, i386 and i860. UPAGES is used only in trad-core.c.
- */
-#if UPAGES == 16
-#undef UPAGES
-#define UPAGES 2
-#endif
-
-#if UPAGES != 2
-#error UPAGES is neither 2 nor 16
-#endif
-
-#define HOST_PAGE_SIZE 1
-#define HOST_SEGMENT_SIZE NBPG
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
diff --git a/contrib/gdb/bfd/hosts/riscos.h b/contrib/gdb/bfd/hosts/riscos.h
deleted file mode 100644
index 8ffa826..0000000
--- a/contrib/gdb/bfd/hosts/riscos.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* RISC/os 4.52C, and presumably other versions. */
-
-#include <bsd43/machine/machparam.h>
-#include <bsd43/machine/vmparam.h>
-
-#define NBPG BSD43_NBPG
-#define UPAGES BSD43_UPAGES
-#define HOST_TEXT_START_ADDR BSD43_USRTEXT
-#define HOST_DATA_START_ADDR BSD43_USRDATA
-#define HOST_STACK_END_ADDR BSD43_USRSTACK
diff --git a/contrib/gdb/bfd/hosts/symmetry.h b/contrib/gdb/bfd/hosts/symmetry.h
deleted file mode 100644
index 75717b3..0000000
--- a/contrib/gdb/bfd/hosts/symmetry.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Symmetry running either dynix 3.1 (bsd) or ptx (sysv). */
-
-#define NBPG 4096
-#define UPAGES 1
-
-#ifdef _SEQUENT_
-/* ptx */
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR 0x3fffe000
-#define TRAD_CORE_USER_OFFSET ((UPAGES * NBPG) - sizeof (struct user))
-#else
-/* dynix */
-#define HOST_TEXT_START_ADDR 0x1000
-#define HOST_DATA_START_ADDR (NBPG * u.u_tsize)
-#define HOST_STACK_END_ADDR 0x3ffff000
-#define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
- ((core_bfd)->tdata.trad_core_data->u.u_arg[0])
-#endif
-
-#define TRAD_CORE_DSIZE_INCLUDES_TSIZE
diff --git a/contrib/gdb/bfd/hosts/tahoe.h b/contrib/gdb/bfd/hosts/tahoe.h
deleted file mode 100644
index 716cee2..0000000
--- a/contrib/gdb/bfd/hosts/tahoe.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#define NO_CORE_COMMAND
-
-#undef ALIGN /* They use it, we use it too */
-#include <machine/param.h>
-#undef ALIGN /* They use it, we use it too */
-
-#define HOST_PAGE_SIZE NBPG
-#define HOST_MACHINE_ARCH bfd_arch_tahoe
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (KERNBASE - (UPAGES * NBPG))
-#define HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxbsd.h b/contrib/gdb/bfd/hosts/vaxbsd.h
deleted file mode 100644
index ceb9cce..0000000
--- a/contrib/gdb/bfd/hosts/vaxbsd.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#define NO_CORE_COMMAND /* No command name in core file */
-
-#if 0
-#undef ALIGN /* They use it, we use it too */
-/* Does not exist on BSD 4.3, it uses machine/machparam.h.
- Whatever it is, it's included by <sys/param.h>, which trad-core.c,
- the only place that uses this (I think), already includes. */
-#include <machine/param.h>
-#endif
-#undef ALIGN /* They use it, we use it too */
-
-/* Note that HOST_PAGE_SIZE -- the page size as far as executable files
- are concerned -- is not the same as NBPG, because of page clustering. */
-#define HOST_PAGE_SIZE 1024
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR 0
-#define HOST_STACK_END_ADDR (0x80000000 - (UPAGES * NBPG))
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxult.h b/contrib/gdb/bfd/hosts/vaxult.h
deleted file mode 100644
index 13731b7..0000000
--- a/contrib/gdb/bfd/hosts/vaxult.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#define HOST_PAGE_SIZE (NBPG*CLSIZE)
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/hosts/vaxult2.h b/contrib/gdb/bfd/hosts/vaxult2.h
deleted file mode 100644
index 13731b7..0000000
--- a/contrib/gdb/bfd/hosts/vaxult2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#define HOST_PAGE_SIZE (NBPG*CLSIZE)
-#define HOST_MACHINE_ARCH bfd_arch_vax
-
-#define HOST_TEXT_START_ADDR USRTEXT
-#define HOST_STACK_END_ADDR USRSTACK
-#undef HOST_BIG_ENDIAN_P
diff --git a/contrib/gdb/bfd/i386aout.c b/contrib/gdb/bfd/i386aout.c
deleted file mode 100644
index 0801832..0000000
--- a/contrib/gdb/bfd/i386aout.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* BFD back-end for i386 a.out binaries.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* The only 386 aout system we have here is GO32 from DJ.
- These numbers make BFD work with that. If your aout 386 system
- doesn't work with these, we'll have to split them into different
- files. Send me (sac@cygnus.com) the runes to make it work on your
- system, and I'll stick it in for the next release. */
-
-#define N_HEADER_IN_TEXT(x) 0
-#define BYTES_IN_WORD 4
-
-#define N_TXTOFF(x) 0x20
-#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
-
-#define N_TXTSIZE(x) ((x).a_text)
-#if 0
-#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
-#define NOSUBEXECB
-
-#endif
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE 0x400000
-#define DEFAULT_ARCH bfd_arch_i386
-
-#define MY(OP) CAT(i386aout_,OP)
-#define TARGETNAME "a.out-i386"
-#define NO_WRITE_HEADER_KLUDGE 1
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-static boolean MY(set_sizes)();
-#define MY_backend_data &MY(backend_data)
-static CONST struct aout_backend_data MY(backend_data) = {
- 0, /* zmagic contiguous */
- 1, /* text incl header */
- 0, /* exec_hdr_flags */
- 0, /* text vma? */
- MY(set_sizes),
- 1, /* exec header not counted */
- 0, /* add_dynamic_symbols */
- 0, /* add_one_symbol */
- 0, /* link_dynamic_object */
- 0, /* write_dynamic_symbol */
- 0, /* check_dynamic_reloc */
- 0 /* finish_dynamic_link */
-};
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386bsd.c b/contrib/gdb/bfd/i386bsd.c
deleted file mode 100644
index 2328fe3..0000000
--- a/contrib/gdb/bfd/i386bsd.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* BFD back-end for i386 a.out binaries under BSD.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This data should be correct for the format used under all the various
- BSD ports for 386 machines. */
-
-#define BYTES_IN_WORD 4
-
-/* ZMAGIC files never have the header in the text. */
-#define N_HEADER_IN_TEXT(x) 0
-
-/* ZMAGIC files start at address 0. This does not apply to QMAGIC. */
-#define TEXT_START_ADDR 0
-#define N_SHARED_LIB(x) 0
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(i386bsd_,OP)
-#define TARGETNAME "a.out-i386-bsd"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386freebsd.c b/contrib/gdb/bfd/i386freebsd.c
deleted file mode 100644
index 7a6371b..0000000
--- a/contrib/gdb/bfd/i386freebsd.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for FreeBSD/386 a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#undef TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MACHTYPE_OK(mtype) ((mtype) == M_386_NETBSD || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(i386freebsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-i386-freebsd"
-
-#include "freebsd.h"
diff --git a/contrib/gdb/bfd/ihex.c b/contrib/gdb/bfd/ihex.c
deleted file mode 100644
index 80140da..0000000
--- a/contrib/gdb/bfd/ihex.c
+++ /dev/null
@@ -1,1005 +0,0 @@
-/* BFD back-end for Intel Hex objects.
- Copyright 1995 Free Software Foundation, Inc.
- Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is what Intel Hex files look like:
-
-1. INTEL FORMATS
-
-A. Intel 1
-
- 16-bit address-field format, for files 64k bytes in length or less.
-
- DATA RECORD
- Byte 1 Header = colon(:)
- 2..3 The number of data bytes in hex notation
- 4..5 High byte of the record load address
- 6..7 Low byte of the record load address
- 8..9 Record type, must be "00"
- 10..x Data bytes in hex notation:
- x = (number of bytes - 1) * 2 + 11
- x+1..x+2 Checksum in hex notation
- x+3..x+4 Carriage return, line feed
-
- END RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "00"
- 4..7 Transfer-address (usually "0000")
- the jump-to address, execution start address
- 8..9 Record type, must be "01"
- 10..11 Checksum, in hex notation
- 12..13 Carriage return, line feed
-
-B. INTEL 2
-
- MCS-86 format, using a 20-bit address for files larger than 64K bytes.
-
- DATA RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count of this record, hex notation
- 4..5 High byte of the record load address
- 6..7 Low byte of the record load address
- 8..9 Record type, must be "00"
- 10..x The data bytes in hex notation:
- x = (number of data bytes - 1) * 2 + 11
- x+1..x+2 Checksum in hex notation
- x+3..x+4 Carriage return, line feed
-
- EXTENDED ADDRESS RECORD
- Byte 1 Header = colon(:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "02"
- 10..11 High byte of the offset address
- 12..13 Low byte of the offset address
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-
- The checksums are the two's complement of the 8-bit sum
- without carry of the byte count, offset address, and the
- record type.
-
- START ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "04"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "03"
- 10..13 8086 CS value
- 14..17 8086 IP value
- 18..19 Checksum in hex notation
- 20..21 Carriage return, line feed
-
-Another document reports these additional types:
-
- EXTENDED LINEAR ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "04"
- 10..13 Upper 16 bits of address of subsequent records
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-
- START LINEAR ADDRESS RECORD
- Byte 1 Header = colon (:)
- 2..3 The byte count, must be "02"
- 4..7 Load address, must be "0000"
- 8..9 Record type, must be "05"
- 10..13 Upper 16 bits of start address
- 14..15 Checksum in hex notation
- 16..17 Carriage return, line feed
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-
-#include <ctype.h>
-
-static void ihex_init PARAMS ((void));
-static boolean ihex_mkobject PARAMS ((bfd *));
-static INLINE int ihex_get_byte PARAMS ((bfd *, boolean *));
-static void ihex_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
-static boolean ihex_scan PARAMS ((bfd *));
-static const bfd_target *ihex_object_p PARAMS ((bfd *));
-static boolean ihex_read_section PARAMS ((bfd *, asection *, bfd_byte *));
-static boolean ihex_get_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static boolean ihex_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static boolean ihex_write_record
- PARAMS ((bfd *, bfd_size_type, bfd_vma, unsigned int, bfd_byte *));
-static boolean ihex_write_object_contents PARAMS ((bfd *));
-static asymbol *ihex_make_empty_symbol PARAMS ((bfd *));
-static boolean ihex_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-
-/* The number of bytes we put on one line during output. */
-
-#define CHUNK (21)
-
-/* Macros for converting between hex and binary. */
-
-#define NIBBLE(x) (hex_value (x))
-#define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1]))
-#define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2))
-#define ISHEX(x) (hex_p (x))
-
-/* When we write out an ihex value, the values can not be output as
- they are seen. Instead, we hold them in memory in this structure. */
-
-struct ihex_data_list
-{
- struct ihex_data_list *next;
- bfd_byte *data;
- bfd_vma where;
- bfd_size_type size;
-};
-
-/* The ihex tdata information. */
-
-struct ihex_data_struct
-{
- struct ihex_data_list *head;
- struct ihex_data_list *tail;
-};
-
-/* Initialize by filling in the hex conversion array. */
-
-static void
-ihex_init ()
-{
- static boolean inited;
-
- if (! inited)
- {
- inited = true;
- hex_init ();
- }
-}
-
-/* Create an ihex object. */
-
-static boolean
-ihex_mkobject (abfd)
- bfd *abfd;
-{
- if (abfd->tdata.ihex_data == NULL)
- {
- struct ihex_data_struct *tdata;
-
- tdata = ((struct ihex_data_struct *)
- bfd_alloc (abfd, sizeof (struct ihex_data_struct)));
- if (tdata == NULL)
- return false;
- abfd->tdata.ihex_data = tdata;
- tdata->head = NULL;
- tdata->tail = NULL;
- }
-
- return true;
-}
-
-/* Read a byte from a BFD. Set *ERRORPTR if an error occurred.
- Return EOF on error or end of file. */
-
-static INLINE int
-ihex_get_byte (abfd, errorptr)
- bfd *abfd;
- boolean *errorptr;
-{
- bfd_byte c;
-
- if (bfd_read (&c, 1, 1, abfd) != 1)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- *errorptr = true;
- return EOF;
- }
-
- return (int) (c & 0xff);
-}
-
-/* Report a problem in an Intel Hex file. */
-
-static void
-ihex_bad_byte (abfd, lineno, c, error)
- bfd *abfd;
- unsigned int lineno;
- int c;
- boolean error;
-{
- if (c == EOF)
- {
- if (! error)
- bfd_set_error (bfd_error_file_truncated);
- }
- else
- {
- char buf[10];
-
- if (! isprint (c))
- sprintf (buf, "\\%03o", (unsigned int) c);
- else
- {
- buf[0] = c;
- buf[1] = '\0';
- }
- (*_bfd_error_handler)
- ("%s:%d: unexpected character `%s' in Intel Hex file\n",
- bfd_get_filename (abfd), lineno, buf);
- bfd_set_error (bfd_error_bad_value);
- }
-}
-
-/* Read an Intel hex file and turn it into sections. We create a new
- section for each contiguous set of bytes. */
-
-static boolean
-ihex_scan (abfd)
- bfd *abfd;
-{
- bfd_vma segbase;
- bfd_vma extbase;
- asection *sec;
- int lineno;
- boolean error;
- bfd_byte *buf;
- size_t bufsize;
- int c;
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- abfd->start_address = 0;
-
- extbase = 0;
- segbase = 0;
- sec = NULL;
- lineno = 1;
- error = false;
- buf = NULL;
- bufsize = 0;
- while ((c = ihex_get_byte (abfd, &error)) != EOF)
- {
- if (c == '\r')
- continue;
- else if (c == '\n')
- {
- ++lineno;
- continue;
- }
- else if (c != ':')
- {
- ihex_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
- else
- {
- file_ptr pos;
- char hdr[8];
- unsigned int i;
- unsigned int len;
- bfd_vma addr;
- unsigned int type;
- unsigned int chars;
- unsigned int chksum;
-
- /* This is a data record. */
-
- pos = bfd_tell (abfd) - 1;
-
- /* Read the header bytes. */
-
- if (bfd_read (hdr, 1, 8, abfd) != 8)
- goto error_return;
-
- for (i = 0; i < 8; i++)
- {
- if (! ISHEX (hdr[i]))
- {
- ihex_bad_byte (abfd, lineno, hdr[i], error);
- goto error_return;
- }
- }
-
- len = HEX2 (hdr);
- addr = HEX4 (hdr + 2);
- type = HEX2 (hdr + 6);
-
- /* Read the data bytes. */
-
- chars = len * 2 + 2;
- if (chars >= bufsize)
- {
- buf = (bfd_byte *) bfd_realloc (buf, chars);
- if (buf == NULL)
- goto error_return;
- bufsize = chars;
- }
-
- if (bfd_read (buf, 1, chars, abfd) != chars)
- goto error_return;
-
- for (i = 0; i < chars; i++)
- {
- if (! ISHEX (buf[i]))
- {
- ihex_bad_byte (abfd, lineno, hdr[i], error);
- goto error_return;
- }
- }
-
- /* Check the checksum. */
- chksum = len + addr + (addr >> 8) + type;
- for (i = 0; i < len; i++)
- chksum += HEX2 (buf + 2 * i);
- if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i))
- {
- (*_bfd_error_handler)
- ("%s:%d: bad checksum in Intel Hex file (expected %u, found %u)",
- bfd_get_filename (abfd), lineno,
- (- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- switch (type)
- {
- case 0:
- /* This is a data record. */
- if (sec != NULL
- && sec->vma + sec->_raw_size == extbase + segbase + addr)
- {
- /* This data goes at the end of the section we are
- currently building. */
- sec->_raw_size += len;
- }
- else if (len > 0)
- {
- char secbuf[20];
- char *secname;
-
- sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
- if (secname == NULL)
- goto error_return;
- strcpy (secname, secbuf);
- sec = bfd_make_section (abfd, secname);
- if (sec == NULL)
- goto error_return;
- sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- sec->vma = extbase + segbase + addr;
- sec->lma = extbase + segbase + addr;
- sec->_raw_size = len;
- sec->filepos = pos;
- }
- break;
-
- case 1:
- /* An end record. */
- if (abfd->start_address == 0)
- abfd->start_address = addr;
- if (buf != NULL)
- free (buf);
- return true;
-
- case 2:
- /* An extended address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended address record length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- segbase = HEX4 (buf) << 4;
-
- sec = NULL;
-
- break;
-
- case 3:
- /* An extended start address record. */
- if (len != 4)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended start address length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- abfd->start_address += (HEX4 (buf) << 4) + HEX4 (buf + 4);
-
- sec = NULL;
-
- break;
-
- case 4:
- /* An extended linear address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended linear address record length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- segbase = HEX4 (buf) << 16;
-
- sec = NULL;
-
- break;
-
- case 5:
- /* An extended linear start address record. */
- if (len != 2)
- {
- (*_bfd_error_handler)
- ("%s:%d: bad extended linear start address length in Intel Hex file",
- bfd_get_filename (abfd), lineno);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- abfd->start_address += HEX4 (buf) << 16;
-
- sec = NULL;
-
- break;
-
- default:
- (*_bfd_error_handler)
- ("%s:%d: unrecognized ihex type %u in Intel Hex file\n",
- bfd_get_filename (abfd), lineno, type);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- }
- }
-
- if (error)
- goto error_return;
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Try to recognize an Intel Hex file. */
-
-static const bfd_target *
-ihex_object_p (abfd)
- bfd *abfd;
-{
- bfd_byte b[9];
- unsigned int i;
- unsigned int type;
-
- ihex_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return NULL;
- if (bfd_read (b, 1, 9, abfd) != 9)
- {
- if (bfd_get_error () == bfd_error_file_truncated)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (b[0] != ':')
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- for (i = 1; i < 9; i++)
- {
- if (! ISHEX (b[i]))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- }
-
- type = HEX2 (b + 7);
- if (type > 5)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* OK, it looks like it really is an Intel Hex file. */
-
- if (! ihex_mkobject (abfd)
- || ! ihex_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Read the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_read_section (abfd, section, contents)
- bfd *abfd;
- asection *section;
- bfd_byte *contents;
-{
- int c;
- bfd_byte *p;
- bfd_byte *buf;
- size_t bufsize;
- boolean error;
-
- if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
- goto error_return;
-
- p = contents;
- buf = NULL;
- bufsize = 0;
- error = false;
- while ((c = ihex_get_byte (abfd, &error)) != EOF)
- {
- char hdr[8];
- unsigned int len;
- bfd_vma addr;
- unsigned int type;
- unsigned int i;
-
- if (c == '\r' || c == '\n')
- continue;
-
- /* This is called after ihex_scan has succeeded, so we ought to
- know the exact format. */
- BFD_ASSERT (c == ':');
-
- if (bfd_read (hdr, 1, 8, abfd) != 8)
- goto error_return;
-
- len = HEX2 (hdr);
- addr = HEX4 (hdr + 2);
- type = HEX2 (hdr + 6);
-
- /* We should only see type 0 records here. */
- if (type != 0)
- {
- (*_bfd_error_handler)
- ("%s: internal error in ihex_read_section",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- if (len * 2 > bufsize)
- {
- buf = (bfd_byte *) bfd_realloc (buf, len * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = len * 2;
- }
-
- if (bfd_read (buf, 1, len * 2, abfd) != len * 2)
- goto error_return;
-
- for (i = 0; i < len; i++)
- *p++ = HEX2 (buf + 2 * i);
- if ((bfd_size_type) (p - contents) >= section->_raw_size)
- {
- /* We've read everything in the section. */
- if (buf != NULL)
- free (buf);
- return true;
- }
-
- /* Skip the checksum. */
- if (bfd_read (buf, 1, 2, abfd) != 2)
- goto error_return;
- }
-
- if ((bfd_size_type) (p - contents) < section->_raw_size)
- {
- (*_bfd_error_handler)
- ("%s: bad section length in ihex_read_section",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Get the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->used_by_bfd == NULL)
- {
- section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
- if (section->used_by_bfd == NULL)
- return false;
- if (! ihex_read_section (abfd, section, section->used_by_bfd))
- return false;
- }
-
- memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
- (size_t) count);
-
- return true;
-}
-
-/* Set the contents of a section in an Intel Hex file. */
-
-static boolean
-ihex_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- struct ihex_data_list *n;
- bfd_byte *data;
- struct ihex_data_struct *tdata;
-
- if (count == 0
- || (section->flags & SEC_ALLOC) == 0
- || (section->flags & SEC_LOAD) == 0)
- return true;
-
- n = ((struct ihex_data_list *)
- bfd_alloc (abfd, sizeof (struct ihex_data_list)));
- if (n == NULL)
- return false;
-
- data = (bfd_byte *) bfd_alloc (abfd, count);
- if (data == NULL)
- return false;
- memcpy (data, location, (size_t) count);
-
- n->data = data;
- n->where = section->lma + offset;
- n->size = count;
-
- /* Sort the records by address. Optimize for the common case of
- adding a record to the end of the list. */
- tdata = abfd->tdata.ihex_data;
- if (tdata->tail != NULL
- && n->where >= tdata->tail->where)
- {
- tdata->tail->next = n;
- n->next = NULL;
- tdata->tail = n;
- }
- else
- {
- register struct ihex_data_list **pp;
-
- for (pp = &tdata->head;
- *pp != NULL && (*pp)->where < n->where;
- pp = &(*pp)->next)
- ;
- n->next = *pp;
- *pp = n;
- if (n->next == NULL)
- tdata->tail = n;
- }
-
- return true;
-}
-
-/* Write a record out to an Intel Hex file. */
-
-static boolean
-ihex_write_record (abfd, count, addr, type, data)
- bfd *abfd;
- bfd_size_type count;
- bfd_vma addr;
- unsigned int type;
- bfd_byte *data;
-{
- static const char digs[] = "0123456789ABCDEF";
- char buf[9 + CHUNK * 2 + 4];
- char *p;
- unsigned int chksum;
- unsigned int i;
-
-#define TOHEX(buf, v) \
- ((buf)[0] = digs[((v) >> 4) & 0xf], (buf)[1] = digs[(v) & 0xf])
-
- buf[0] = ':';
- TOHEX (buf + 1, count);
- TOHEX (buf + 3, (addr >> 8) & 0xff);
- TOHEX (buf + 5, addr & 0xff);
- TOHEX (buf + 7, type);
-
- chksum = count + addr + (addr >> 8) + type;
-
- for (i = 0, p = buf + 9; i < count; i++, p += 2, data++)
- {
- TOHEX (p, *data);
- chksum += *data;
- }
-
- TOHEX (p, (- chksum) & 0xff);
- p[2] = '\r';
- p[3] = '\n';
-
- if (bfd_write (buf, 1, 9 + count * 2 + 4, abfd) != 9 + count * 2 + 4)
- return false;
-
- return true;
-}
-
-/* Write out an Intel Hex file. */
-
-static boolean
-ihex_write_object_contents (abfd)
- bfd *abfd;
-{
- bfd_vma extbase;
- bfd_vma segbase;
- struct ihex_data_list *l;
-
- extbase = 0;
- segbase = 0;
- for (l = abfd->tdata.ihex_data->head; l != NULL; l = l->next)
- {
- bfd_vma where;
- bfd_byte *p;
- bfd_size_type count;
-
- where = l->where;
- p = l->data;
- count = l->size;
- while (count > 0)
- {
- bfd_size_type now;
-
- now = count;
- if (now > CHUNK)
- now = CHUNK;
-
- if (where > extbase + segbase + 0xffff)
- {
- bfd_byte addr[2];
-
- /* We need a new base address. */
- if (where <= 0xfffff)
- {
- segbase = where & 0xf0000;
- addr[0] = (segbase >> 12) & 0xff;
- addr[1] = (segbase >> 4) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 2, addr))
- return false;
- }
- else
- {
- extbase = where & 0xffff0000;
- if (where > extbase + 0xffff)
- {
- char buf[20];
-
- sprintf_vma (buf, where);
- (*_bfd_error_handler)
- ("%s: address 0x%s out of range for Intex Hex file",
- bfd_get_filename (abfd), buf);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- addr[0] = (extbase >> 24) & 0xff;
- addr[1] = (extbase >> 16) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 4, addr))
- return false;
- }
- }
-
- if (! ihex_write_record (abfd, now, where - (extbase + segbase),
- 0, p))
- return false;
-
- where += now;
- p += now;
- count -= now;
- }
- }
-
- if (abfd->start_address != 0)
- {
- bfd_vma start;
- bfd_byte startbuf[4];
-
- start = abfd->start_address;
-
- if (start > 0xfffff)
- {
- startbuf[0] = (start >> 24) & 0xff;
- startbuf[1] = (start >> 16) & 0xff;
- if (! ihex_write_record (abfd, 2, 0, 5, startbuf))
- return false;
- start &= 0xffff;
- }
-
- startbuf[0] = ((start & 0xf0000) >> 12) & 0xff;
- startbuf[1] = 0;
- startbuf[2] = (start >> 8) & 0xff;
- startbuf[3] = start & 0xff;
- if (! ihex_write_record (abfd, 4, 0, 3, startbuf))
- return false;
- }
-
- if (! ihex_write_record (abfd, 0, 0, 1, NULL))
- return false;
-
- return true;
-}
-
-/* Make an empty symbol. This is required only because
- bfd_make_section_anyway wants to create a symbol for the section. */
-
-static asymbol *
-ihex_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new;
-
- new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new != NULL)
- new->the_bfd = abfd;
- return new;
-}
-
-/* Set the architecture for the output file. The architecture is
- irrelevant, so we ignore errors about unknown architectures. */
-
-static boolean
-ihex_set_arch_mach (abfd, arch, mach)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long mach;
-{
- if (! bfd_default_set_arch_mach (abfd, arch, mach))
- {
- if (arch != bfd_arch_unknown)
- return false;
- }
- return true;
-}
-
-/* Get the size of the headers, for the linker. */
-
-/*ARGSUSED*/
-static int
-ihex_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-/* Some random definitions for the target vector. */
-
-#define ihex_close_and_cleanup _bfd_generic_close_and_cleanup
-#define ihex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define ihex_new_section_hook _bfd_generic_new_section_hook
-#define ihex_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define ihex_get_symtab_upper_bound bfd_0l
-#define ihex_get_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) bfd_0l)
-#define ihex_print_symbol _bfd_nosymbols_print_symbol
-#define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define ihex_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define ihex_get_lineno _bfd_nosymbols_get_lineno
-#define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define ihex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define ihex_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define ihex_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-#define ihex_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define ihex_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define ihex_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define ihex_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define ihex_bfd_relax_section bfd_generic_relax_section
-#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define ihex_bfd_final_link _bfd_generic_final_link
-#define ihex_bfd_link_split_section _bfd_generic_link_split_section
-
-/* The Intel Hex target vector. */
-
-const bfd_target ihex_vec =
-{
- "ihex", /* name */
- bfd_target_ihex_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- 0, /* object flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {
- _bfd_dummy_target,
- ihex_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- ihex_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- ihex_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (ihex),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (ihex),
- BFD_JUMP_TABLE_RELOCS (ihex),
- BFD_JUMP_TABLE_WRITE (ihex),
- BFD_JUMP_TABLE_LINK (ihex),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/init.c b/contrib/gdb/bfd/init.c
deleted file mode 100644
index 1fa1d50..0000000
--- a/contrib/gdb/bfd/init.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* bfd initialization stuff
- Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/*
-SECTION
- Initialization
-
- These are the functions that handle initializing a BFD.
-*/
-
-/*
-FUNCTION
- bfd_init
-
-SYNOPSIS
- void bfd_init(void);
-
-DESCRIPTION
- This routine must be called before any other BFD function to
- initialize magical internal data structures.
-*/
-
-/* Actually, there is currently nothing for this function to do.
- However, someday it may be needed, so keep it around. */
-
-void
-bfd_init ()
-{
-}
diff --git a/contrib/gdb/bfd/libaout.h b/contrib/gdb/bfd/libaout.h
deleted file mode 100644
index 76c1dff..0000000
--- a/contrib/gdb/bfd/libaout.h
+++ /dev/null
@@ -1,608 +0,0 @@
-/* BFD back-end data structures for a.out (and similar) files.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef LIBAOUT_H
-#define LIBAOUT_H
-
-/* We try to encapsulate the differences in the various a.out file
- variants in a few routines, and otherwise share large masses of code.
- This means we only have to fix bugs in one place, most of the time. */
-
-#include "bfdlink.h"
-
-/* Parameterize the a.out code based on whether it is being built
- for a 32-bit architecture or a 64-bit architecture. */
-#if ARCH_SIZE==64
-#define GET_WORD bfd_h_get_64
-#define GET_SWORD bfd_h_get_signed_64
-#define PUT_WORD bfd_h_put_64
-#ifndef NAME
-#define NAME(x,y) CAT3(x,_64_,y)
-#endif
-#define JNAME(x) CAT(x,_64)
-#define BYTES_IN_WORD 8
-#else /* ARCH_SIZE == 32 */
-#define GET_WORD bfd_h_get_32
-#define GET_SWORD bfd_h_get_signed_32
-#define PUT_WORD bfd_h_put_32
-#ifndef NAME
-#define NAME(x,y) CAT3(x,_32_,y)
-#endif
-#define JNAME(x) CAT(x,_32)
-#define BYTES_IN_WORD 4
-#endif /* ARCH_SIZE==32 */
-
-/* Declare at file level, since used in parameter lists, which have
- weird scope. */
-struct external_exec;
-struct external_nlist;
-struct reloc_ext_external;
-struct reloc_std_external;
-
-/* a.out backend linker hash table entries. */
-
-struct aout_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Whether this symbol has been written out. */
- boolean written;
- /* Symbol index in output file. */
- int indx;
-};
-
-/* a.out backend linker hash table. */
-
-struct aout_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in an a.out link hash table. */
-
-#define aout_link_hash_lookup(table, string, create, copy, follow) \
- ((struct aout_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
-
-/* Traverse an a.out link hash table. */
-
-#define aout_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the a.out link hash table from the info structure. This is
- just a cast. */
-
-#define aout_hash_table(p) ((struct aout_link_hash_table *) ((p)->hash))
-
-/* Back-end information for various a.out targets. */
-struct aout_backend_data
-{
- /* Are ZMAGIC files mapped contiguously? If so, the text section may
- need more padding, if the segment size (granularity for memory access
- control) is larger than the page size. */
- unsigned char zmagic_mapped_contiguous;
- /* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
- text section, which starts immediately after the file header.
- If not, the text section starts on the next page. */
- unsigned char text_includes_header;
-
- /* The value to pass to N_SET_FLAGS. */
- unsigned char exec_hdr_flags;
-
- /* If the text section VMA isn't specified, and we need an absolute
- address, use this as the default. If we're producing a relocatable
- file, zero is always used. */
- /* ?? Perhaps a callback would be a better choice? Will this do anything
- reasonable for a format that handles multiple CPUs with different
- load addresses for each? */
- bfd_vma default_text_vma;
-
- /* Callback for setting the page and segment sizes, if they can't be
- trivially determined from the architecture. */
- boolean (*set_sizes) PARAMS ((bfd *));
-
- /* zmagic files only. For go32, the length of the exec header contributes
- to the size of the text section in the file for alignment purposes but
- does *not* get counted in the length of the text section. */
- unsigned char exec_header_not_counted;
-
- /* Callback from the add symbols phase of the linker code to handle
- a dynamic object. */
- boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *,
- struct external_nlist **,
- bfd_size_type *, char **));
-
- /* Callback from the add symbols phase of the linker code to handle
- adding a single symbol to the global linker hash table. */
- boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
- const char *, flagword, asection *,
- bfd_vma, const char *, boolean,
- boolean,
- struct bfd_link_hash_entry **));
-
- /* Called to handle linking a dynamic object. */
- boolean (*link_dynamic_object) PARAMS ((struct bfd_link_info *, bfd *));
-
- /* Called for each global symbol being written out by the linker.
- This should write out the dynamic symbol information. */
- boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *,
- struct aout_link_hash_entry *));
-
- /* If this callback is not NULL, the linker calls it for each reloc.
- RELOC is a pointer to the unswapped reloc. If *SKIP is set to
- true, the reloc will be skipped. *RELOCATION may be changed to
- change the effects of the relocation. */
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- struct aout_link_hash_entry *h,
- PTR reloc, bfd_byte *contents,
- boolean *skip,
- bfd_vma *relocation));
-
- /* Called at the end of a link to finish up any dynamic linking
- information. */
- boolean (*finish_dynamic_link) PARAMS ((bfd *, struct bfd_link_info *));
-};
-#define aout_backend_info(abfd) \
- ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
-
-/* This is the layout in memory of a "struct exec" while we process it.
- All 'lengths' are given as a number of bytes.
- All 'alignments' are for relinkable files only; an alignment of
- 'n' indicates the corresponding segment must begin at an
- address that is a multiple of (2**n). */
-
-struct internal_exec
-{
- long a_info; /* Magic number and flags, packed */
- bfd_vma a_text; /* length of text, in bytes */
- bfd_vma a_data; /* length of data, in bytes */
- bfd_vma a_bss; /* length of uninitialized data area in mem */
- bfd_vma a_syms; /* length of symbol table data in file */
- bfd_vma a_entry; /* start address */
- bfd_vma a_trsize; /* length of text's relocation info, in bytes */
- bfd_vma a_drsize; /* length of data's relocation info, in bytes */
- /* Added for i960 */
- bfd_vma a_tload; /* Text runtime load address */
- bfd_vma a_dload; /* Data runtime load address */
- unsigned char a_talign; /* Alignment of text segment */
- unsigned char a_dalign; /* Alignment of data segment */
- unsigned char a_balign; /* Alignment of bss segment */
- char a_relaxable; /* Enough info for linker relax */
-};
-
-/* Magic number is written
-< MSB >
-3130292827262524232221201918171615141312111009080706050403020100
-< FLAGS >< MACHINE TYPE >< MAGIC NUMBER >
-*/
-/* Magic number for NetBSD is
-<MSB >
-3130292827262524232221201918171615141312111009080706050403020100
-< FLAGS >< >< MAGIC NUMBER >
-*/
-
-enum machine_type {
- M_UNKNOWN = 0,
- M_68010 = 1,
- M_68020 = 2,
- M_SPARC = 3,
- /* skip a bunch so we don't run into any of suns numbers */
- /* make these up for the ns32k*/
- M_NS32032 = (64), /* ns32032 running ? */
- M_NS32532 = (64 + 5), /* ns32532 running mach */
-
- M_386 = 100,
- M_29K = 101, /* AMD 29000 */
- M_386_DYNIX = 102, /* Sequent running dynix */
- M_ARM = 103, /* Advanced Risc Machines ARM */
- M_386_NETBSD = 134, /* NetBSD/i386 binary */
- M_68K_NETBSD = 135, /* NetBSD/m68k binary */
- M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary */
- M_532_NETBSD = 137, /* NetBSD/ns32k binary */
- M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */
- M_MIPS1 = 151, /* MIPS R2000/R3000 binary */
- M_MIPS2 = 152, /* MIPS R4000/R6000 binary */
- M_HP200 = 200, /* HP 200 (68010) BSD binary */
- M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */
- M_HPUX = (0x20c % 256)/* HP 200/300 HPUX binary */
-};
-
-#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000)
-
-#ifndef N_MAGIC
-# define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#endif
-
-#ifndef N_MACHTYPE
-# define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
-#endif
-
-#ifndef N_FLAGS
-# define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
-#endif
-
-#ifndef N_SET_INFO
-# define N_SET_INFO(exec, magic, type, flags) \
-((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0xff) << 16) \
- | (((flags) & 0xff) << 24))
-#endif
-
-#ifndef N_SET_DYNAMIC
-# define N_SET_DYNAMIC(exec, dynamic) \
-((exec).a_info = (dynamic) ? ((exec).a_info | 0x80000000) : \
-((exec).a_info & 0x7fffffff))
-#endif
-
-#ifndef N_SET_MAGIC
-# define N_SET_MAGIC(exec, magic) \
-((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
-#endif
-
-#ifndef N_SET_MACHTYPE
-# define N_SET_MACHTYPE(exec, machtype) \
-((exec).a_info = \
- ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
-#endif
-
-#ifndef N_SET_FLAGS
-# define N_SET_FLAGS(exec, flags) \
-((exec).a_info = \
- ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
-#endif
-
-typedef struct aout_symbol {
- asymbol symbol;
- short desc;
- char other;
- unsigned char type;
-} aout_symbol_type;
-
-/* The `tdata' struct for all a.out-like object file formats.
- Various things depend on this struct being around any time an a.out
- file is being handled. An example is dbxread.c in GDB. */
-
-struct aoutdata {
- struct internal_exec *hdr; /* exec file header */
- aout_symbol_type *symbols; /* symtab for input bfd */
-
- /* For ease, we do this */
- asection *textsec;
- asection *datasec;
- asection *bsssec;
-
- /* We remember these offsets so that after check_file_format, we have
- no dependencies on the particular format of the exec_hdr. */
- file_ptr sym_filepos;
- file_ptr str_filepos;
-
- /* Size of a relocation entry in external form */
- unsigned reloc_entry_size;
-
- /* Size of a symbol table entry in external form */
- unsigned symbol_entry_size;
-
- /* Page size - needed for alignment of demand paged files. */
- unsigned long page_size;
-
- /* Segment size - needed for alignment of demand paged files. */
- unsigned long segment_size;
-
- /* Zmagic disk block size - need to align the start of the text
- section in ZMAGIC binaries. Normally the same as page_size. */
- unsigned long zmagic_disk_block_size;
-
- unsigned exec_bytes_size;
- unsigned vma_adjusted : 1;
-
- /* used when a bfd supports several highly similar formats */
- enum
- {
- default_format = 0,
- /* Used on HP 9000/300 running HP/UX. See hp300hpux.c. */
- gnu_encap_format,
- /* Used on Linux, 386BSD, etc. See include/aout/aout64.h. */
- q_magic_format
- } subformat;
-
- enum
- {
- undecided_magic = 0,
- z_magic,
- o_magic,
- n_magic
- } magic;
-
- /* A buffer for find_nearest_line. */
- char *line_buf;
-
- /* The external symbol information. */
- struct external_nlist *external_syms;
- bfd_size_type external_sym_count;
- bfd_window sym_window;
- char *external_strings;
- bfd_size_type external_string_size;
- bfd_window string_window;
- struct aout_link_hash_entry **sym_hashes;
-
- /* A pointer for shared library information. */
- PTR dynamic_info;
-
- /* A mapping from local symbols to offsets into the global offset
- table, used when linking on SunOS. This is indexed by the symbol
- index. */
- bfd_vma *local_got_offsets;
-};
-
-struct aout_data_struct {
- struct aoutdata a;
- struct internal_exec e;
-};
-
-#define adata(bfd) ((bfd)->tdata.aout_data->a)
-#define exec_hdr(bfd) (adata(bfd).hdr)
-#define obj_aout_symbols(bfd) (adata(bfd).symbols)
-#define obj_textsec(bfd) (adata(bfd).textsec)
-#define obj_datasec(bfd) (adata(bfd).datasec)
-#define obj_bsssec(bfd) (adata(bfd).bsssec)
-#define obj_sym_filepos(bfd) (adata(bfd).sym_filepos)
-#define obj_str_filepos(bfd) (adata(bfd).str_filepos)
-#define obj_reloc_entry_size(bfd) (adata(bfd).reloc_entry_size)
-#define obj_symbol_entry_size(bfd) (adata(bfd).symbol_entry_size)
-#define obj_aout_subformat(bfd) (adata(bfd).subformat)
-#define obj_aout_external_syms(bfd) (adata(bfd).external_syms)
-#define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count)
-#define obj_aout_sym_window(bfd) (adata(bfd).sym_window)
-#define obj_aout_external_strings(bfd) (adata(bfd).external_strings)
-#define obj_aout_external_string_size(bfd) (adata(bfd).external_string_size)
-#define obj_aout_string_window(bfd) (adata(bfd).string_window)
-#define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes)
-#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info)
-
-/* We take the address of the first element of an asymbol to ensure that the
- macro is only ever applied to an asymbol */
-#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
-
-/* Information we keep for each a.out section. This is currently only
- used by the a.out backend linker. */
-
-struct aout_section_data_struct
-{
- /* The unswapped relocation entries for this section. */
- PTR relocs;
-};
-
-#define aout_section_data(s) \
- ((struct aout_section_data_struct *) (s)->used_by_bfd)
-
-#define set_aout_section_data(s,v) \
- ((s)->used_by_bfd = (PTR)&(v)->relocs)
-
-/* Prototype declarations for functions defined in aoutx.h */
-
-boolean
-NAME(aout,squirt_out_relocs) PARAMS ((bfd *abfd, asection *section));
-
-boolean
-NAME(aout,make_sections) PARAMS ((bfd *));
-
-const bfd_target *
-NAME(aout,some_aout_object_p) PARAMS ((bfd *abfd,
- struct internal_exec *execp,
- const bfd_target *(*callback)(bfd *)));
-
-boolean
-NAME(aout,mkobject) PARAMS ((bfd *abfd));
-
-enum machine_type
-NAME(aout,machine_type) PARAMS ((enum bfd_architecture arch,
- unsigned long machine,
- boolean *unknown));
-
-boolean
-NAME(aout,set_arch_mach) PARAMS ((bfd *abfd, enum bfd_architecture arch,
- unsigned long machine));
-
-boolean
-NAME(aout,new_section_hook) PARAMS ((bfd *abfd, asection *newsect));
-
-boolean
-NAME(aout,set_section_contents) PARAMS ((bfd *abfd, sec_ptr section,
- PTR location, file_ptr offset, bfd_size_type count));
-
-asymbol *
-NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
-
-boolean
-NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
- struct external_nlist *,
- bfd_size_type, char *,
- bfd_size_type,
- boolean dynamic));
-
-boolean
-NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
-
-boolean
-NAME(aout,write_syms) PARAMS ((bfd *abfd));
-
-void
-NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd));
-
-long
-NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd));
-
-long
-NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
-
-void
-NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
- arelent *, asymbol **, bfd_size_type));
-void
-NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
- arelent *, asymbol **, bfd_size_type));
-
-reloc_howto_type *
-NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
-
-boolean
-NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
- asymbol **symbols));
-
-long
-NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section,
- arelent **relptr, asymbol **symbols));
-
-long
-NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect));
-
-void
-NAME(aout,reclaim_reloc) PARAMS ((bfd *ignore_abfd, sec_ptr ignore));
-
-alent *
-NAME(aout,get_lineno) PARAMS ((bfd *ignore_abfd, asymbol *ignore_symbol));
-
-void
-NAME(aout,print_symbol) PARAMS ((bfd *ignore_abfd, PTR file,
- asymbol *symbol, bfd_print_symbol_type how));
-
-void
-NAME(aout,get_symbol_info) PARAMS ((bfd *ignore_abfd,
- asymbol *symbol, symbol_info *ret));
-
-boolean
-NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section,
- asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
- CONST char **functionname_ptr, unsigned int *line_ptr));
-
-long
-NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *));
-
-asymbol *
-NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
- asymbol *));
-
-int
-NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec));
-
-boolean
-NAME(aout,adjust_sizes_and_vmas) PARAMS ((bfd *abfd,
- bfd_size_type *text_size, file_ptr *text_end));
-
-void
-NAME(aout,swap_exec_header_in) PARAMS ((bfd *abfd,
- struct external_exec *raw_bytes, struct internal_exec *execp));
-
-void
-NAME(aout,swap_exec_header_out) PARAMS ((bfd *abfd,
- struct internal_exec *execp, struct external_exec *raw_bytes));
-
-struct bfd_hash_entry *
-NAME(aout,link_hash_newfunc)
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-boolean
-NAME(aout,link_hash_table_init)
- PARAMS ((struct aout_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-struct bfd_link_hash_table *
-NAME(aout,link_hash_table_create) PARAMS ((bfd *));
-
-boolean
-NAME(aout,link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
-
-boolean
-NAME(aout,final_link) PARAMS ((bfd *, struct bfd_link_info *,
- void (*) (bfd *, file_ptr *, file_ptr *,
- file_ptr *)));
-
-boolean
-NAME(aout,bfd_free_cached_info) PARAMS ((bfd *));
-
-/* A.out uses the generic versions of these routines... */
-
-#define aout_32_get_section_contents _bfd_generic_get_section_contents
-
-#define aout_64_get_section_contents _bfd_generic_get_section_contents
-#ifndef NO_WRITE_HEADER_KLUDGE
-#define NO_WRITE_HEADER_KLUDGE 0
-#endif
-
-#ifndef aout_32_bfd_is_local_label
-#define aout_32_bfd_is_local_label bfd_generic_is_local_label
-#endif
-
-#ifndef WRITE_HEADERS
-#define WRITE_HEADERS(abfd, execp) \
- { \
- bfd_size_type text_size; /* dummy vars */ \
- file_ptr text_end; \
- if (adata(abfd).magic == undecided_magic) \
- NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
- \
- execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
- execp->a_entry = bfd_get_start_address (abfd); \
- \
- execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
- obj_reloc_entry_size (abfd)); \
- execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
- obj_reloc_entry_size (abfd)); \
- NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
- \
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
- return false; \
- /* Now write out reloc info, followed by syms and strings */ \
- \
- if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
- && bfd_get_symcount (abfd) != 0) \
- { \
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
- != 0) \
- return false; \
- \
- if (! NAME(aout,write_syms)(abfd)) return false; \
- \
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
- != 0) \
- return false; \
- \
- if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
- return false; \
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
- != 0) \
- return false; \
- \
- if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
- return false; \
- } \
- }
-#endif
-
-#endif /* ! defined (LIBAOUT_H) */
diff --git a/contrib/gdb/bfd/libbfd.c b/contrib/gdb/bfd/libbfd.c
deleted file mode 100644
index 1052a3a1..0000000
--- a/contrib/gdb/bfd/libbfd.c
+++ /dev/null
@@ -1,1197 +0,0 @@
-/* Assorted BFD support routines, only used internally.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-static int real_read PARAMS ((PTR, size_t, size_t, FILE *));
-
-/*
-SECTION
- Internal functions
-
-DESCRIPTION
- These routines are used within BFD.
- They are not intended for export, but are documented here for
- completeness.
-*/
-
-/* A routine which is used in target vectors for unsupported
- operations. */
-
-/*ARGSUSED*/
-boolean
-bfd_false (ignore)
- bfd *ignore;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-}
-
-/* A routine which is used in target vectors for supported operations
- which do not actually do anything. */
-
-/*ARGSUSED*/
-boolean
-bfd_true (ignore)
- bfd *ignore;
-{
- return true;
-}
-
-/* A routine which is used in target vectors for unsupported
- operations which return a pointer value. */
-
-/*ARGSUSED*/
-PTR
-bfd_nullvoidptr (ignore)
- bfd *ignore;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
-}
-
-/*ARGSUSED*/
-int
-bfd_0 (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/*ARGSUSED*/
-unsigned int
-bfd_0u (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/*ARGUSED*/
-long
-bfd_0l (ignore)
- bfd *ignore;
-{
- return 0;
-}
-
-/* A routine which is used in target vectors for unsupported
- operations which return -1 on error. */
-
-/*ARGSUSED*/
-long
-_bfd_n1 (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
-}
-
-/*ARGSUSED*/
-void
-bfd_void (ignore)
- bfd *ignore;
-{
-}
-
-/*ARGSUSED*/
-boolean
-_bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd)
- bfd *ignore_core_bfd;
- bfd *ignore_exec_bfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-}
-
-/* Routine to handle core_file_failing_command entry point for targets
- without core file support. */
-
-/*ARGSUSED*/
-char *
-_bfd_nocore_core_file_failing_command (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return (char *)NULL;
-}
-
-/* Routine to handle core_file_failing_signal entry point for targets
- without core file support. */
-
-/*ARGSUSED*/
-int
-_bfd_nocore_core_file_failing_signal (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
-}
-
-/*ARGSUSED*/
-const bfd_target *
-_bfd_dummy_target (ignore_abfd)
- bfd *ignore_abfd;
-{
- bfd_set_error (bfd_error_wrong_format);
- return 0;
-}
-
-/* Allocate memory using malloc. */
-
-PTR
-bfd_malloc (size)
- size_t size;
-{
- PTR ptr;
-
- ptr = (PTR) malloc (size);
- if (ptr == NULL && size != 0)
- bfd_set_error (bfd_error_no_memory);
- return ptr;
-}
-
-/* Reallocate memory using realloc. */
-
-PTR
-bfd_realloc (ptr, size)
- PTR ptr;
- size_t size;
-{
- PTR ret;
-
- if (ptr == NULL)
- ret = malloc (size);
- else
- ret = realloc (ptr, size);
-
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
-
- return ret;
-}
-
-/* Allocate memory using malloc and clear it. */
-
-PTR
-bfd_zmalloc (size)
- size_t size;
-{
- PTR ptr;
-
- ptr = (PTR) malloc (size);
-
- if (size != 0)
- {
- if (ptr == NULL)
- bfd_set_error (bfd_error_no_memory);
- else
- memset (ptr, 0, size);
- }
-
- return ptr;
-}
-
-/* Some IO code */
-
-
-/* Note that archive entries don't have streams; they share their parent's.
- This allows someone to play with the iostream behind BFD's back.
-
- Also, note that the origin pointer points to the beginning of a file's
- contents (0 for non-archive elements). For archive entries this is the
- first octet in the file, NOT the beginning of the archive header. */
-
-static int
-real_read (where, a,b, file)
- PTR where;
- size_t a;
- size_t b;
- FILE *file;
-{
- return fread (where, a, b, file);
-}
-
-/* Return value is amount read (FIXME: how are errors and end of file dealt
- with? We never call bfd_set_error, which is probably a mistake). */
-
-bfd_size_type
-bfd_read (ptr, size, nitems, abfd)
- PTR ptr;
- bfd_size_type size;
- bfd_size_type nitems;
- bfd *abfd;
-{
- int nread;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- {
- struct bfd_in_memory *bim;
- bfd_size_type get;
-
- bim = (struct bfd_in_memory *) abfd->iostream;
- get = size * nitems;
- if (abfd->where + get > bim->size)
- {
- get = bim->size - abfd->where;
- bfd_set_error (bfd_error_file_truncated);
- }
- memcpy (ptr, bim->buffer + abfd->where, get);
- abfd->where += get;
- return get;
- }
-
- nread = real_read (ptr, 1, (size_t)(size*nitems), bfd_cache_lookup(abfd));
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (nread > 0)
- abfd->where += nread;
-#endif
-
- /* Set bfd_error if we did not read as much data as we expected.
-
- If the read failed due to an error set the bfd_error_system_call,
- else set bfd_error_file_truncated.
-
- A BFD backend may wish to override bfd_error_file_truncated to
- provide something more useful (eg. no_symbols or wrong_format). */
- if (nread < (int)(size * nitems))
- {
- if (ferror (bfd_cache_lookup (abfd)))
- bfd_set_error (bfd_error_system_call);
- else
- bfd_set_error (bfd_error_file_truncated);
- }
-
- return nread;
-}
-
-/* The window support stuff should probably be broken out into
- another file.... */
-/* The idea behind the next and refcount fields is that one mapped
- region can suffice for multiple read-only windows or multiple
- non-overlapping read-write windows. It's not implemented yet
- though. */
-struct _bfd_window_internal {
- struct _bfd_window_internal *next;
- PTR data;
- bfd_size_type size;
- int refcount : 31; /* should be enough... */
- unsigned mapped : 1; /* 1 = mmap, 0 = malloc */
-};
-
-void
-bfd_init_window (windowp)
- bfd_window *windowp;
-{
- windowp->data = 0;
- windowp->i = 0;
- windowp->size = 0;
-}
-
-#undef HAVE_MPROTECT /* code's not tested yet */
-
-#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
-#include <sys/types.h>
-#include <sys/mman.h>
-#endif
-
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
-static int debug_windows;
-
-/* Currently, if USE_MMAP is undefined, none if the window stuff is
- used. Okay, so it's mis-named. At least the command-line option
- "--without-mmap" is more obvious than "--without-windows" or some
- such. */
-#ifdef USE_MMAP
-
-void
-bfd_free_window (windowp)
- bfd_window *windowp;
-{
- bfd_window_internal *i = windowp->i;
- windowp->i = 0;
- windowp->data = 0;
- if (i == 0)
- return;
- i->refcount--;
- if (debug_windows)
- fprintf (stderr, "freeing window @%p<%p,%lx,%p>\n",
- windowp, windowp->data, windowp->size, windowp->i);
- if (i->refcount != 0)
- return;
-
- if (i->mapped)
- {
-#ifdef HAVE_MMAP
- munmap (i->data, i->size);
- goto no_free;
-#else
- abort ();
-#endif
- }
-#ifdef HAVE_MPROTECT
- mprotect (i->data, i->size, PROT_READ | PROT_WRITE);
-#endif
- free (i->data);
-#ifdef HAVE_MMAP
- no_free:
-#endif
- i->data = 0;
- /* There should be no more references to i at this point. */
- free (i);
-}
-#endif
-
-static int ok_to_map = 1;
-
-boolean
-bfd_get_file_window (abfd, offset, size, windowp, writable)
- bfd *abfd;
- file_ptr offset;
- bfd_size_type size;
- bfd_window *windowp;
- boolean writable;
-{
- static size_t pagesize;
- bfd_window_internal *i = windowp->i;
- size_t size_to_alloc = size;
-
-#ifndef USE_MMAP
- abort ();
-#endif
-
- if (debug_windows)
- fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
- abfd, (long) offset, (long) size,
- windowp, windowp->data, windowp->size, windowp->i,
- writable);
-
- /* Make sure we know the page size, so we can be friendly to mmap. */
- if (pagesize == 0)
- pagesize = getpagesize ();
- if (pagesize == 0)
- abort ();
-
- if (i == 0)
- {
- windowp->i = i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
- if (i == 0)
- return false;
- i->data = 0;
- }
-#ifdef HAVE_MMAP
- if (ok_to_map
- && (i->data == 0 || i->mapped == 1)
- && (abfd->flags & BFD_IN_MEMORY) == 0)
- {
- file_ptr file_offset, offset2;
- size_t real_size;
- int fd;
- FILE *f;
-
- /* Find the real file and the real offset into it. */
- while (abfd->my_archive != NULL)
- {
- offset += abfd->origin;
- abfd = abfd->my_archive;
- }
- f = bfd_cache_lookup (abfd);
- fd = fileno (f);
-
- /* Compute offsets and size for mmap and for the user's data. */
- offset2 = offset % pagesize;
- if (offset2 < 0)
- abort ();
- file_offset = offset - offset2;
- real_size = offset + size - file_offset;
- real_size = real_size + pagesize - 1;
- real_size -= real_size % pagesize;
-
- /* If we're re-using a memory region, make sure it's big enough. */
- if (i->data && i->size < size)
- {
- munmap (i->data, i->size);
- i->data = 0;
- }
- i->data = mmap (i->data, real_size,
- writable ? PROT_WRITE | PROT_READ : PROT_READ,
- (writable
- ? MAP_FILE | MAP_PRIVATE
- : MAP_FILE | MAP_SHARED),
- fd, file_offset);
- if (i->data == (PTR) -1)
- {
- /* An error happened. Report it, or try using malloc, or
- something. */
- bfd_set_error (bfd_error_system_call);
- i->data = 0;
- windowp->data = 0;
- if (debug_windows)
- fprintf (stderr, "\t\tmmap failed!\n");
- return false;
- }
- if (debug_windows)
- fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
- (long) real_size, i->data, (long) offset2);
- i->size = real_size;
- windowp->data = (PTR) ((bfd_byte *) i->data + offset2);
- windowp->size = size;
- i->mapped = 1;
- return true;
- }
- else if (debug_windows)
- {
- if (ok_to_map)
- fprintf (stderr, "not mapping: data=%lx mapped=%d\n",
- (unsigned long) i->data, (int) i->mapped);
- else
- fprintf (stderr, "not mapping: env var not set\n");
- }
-#else
- ok_to_map = 0;
-#endif
-
-#ifdef HAVE_MPROTECT
- if (!writable)
- {
- size_to_alloc += pagesize - 1;
- size_to_alloc -= size_to_alloc % pagesize;
- }
-#endif
- if (debug_windows)
- fprintf (stderr, "\n\t%s(%6ld)",
- i->data ? "realloc" : " malloc", (long) size_to_alloc);
- i->data = (PTR) bfd_realloc (i->data, size_to_alloc);
- if (debug_windows)
- fprintf (stderr, "\t-> %p\n", i->data);
- i->refcount = 1;
- if (i->data == NULL)
- {
- if (size_to_alloc == 0)
- return true;
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (bfd_seek (abfd, offset, SEEK_SET) != 0)
- return false;
- i->size = bfd_read (i->data, size, 1, abfd);
- if (i->size != size)
- return false;
- i->mapped = 0;
-#ifdef HAVE_MPROTECT
- if (!writable)
- {
- if (debug_windows)
- fprintf (stderr, "\tmprotect (%p, %ld, PROT_READ)\n", i->data,
- (long) i->size);
- mprotect (i->data, i->size, PROT_READ);
- }
-#endif
- windowp->data = i->data;
- windowp->size = i->size;
- return true;
-}
-
-bfd_size_type
-bfd_write (ptr, size, nitems, abfd)
- CONST PTR ptr;
- bfd_size_type size;
- bfd_size_type nitems;
- bfd *abfd;
-{
- long nwrote;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- nwrote = fwrite (ptr, 1, (size_t) (size * nitems),
- bfd_cache_lookup (abfd));
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (nwrote > 0)
- abfd->where += nwrote;
-#endif
- if ((bfd_size_type) nwrote != size * nitems)
- {
-#ifdef ENOSPC
- if (nwrote >= 0)
- errno = ENOSPC;
-#endif
- bfd_set_error (bfd_error_system_call);
- }
- return nwrote;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_write_bigendian_4byte_int
-
-SYNOPSIS
- void bfd_write_bigendian_4byte_int(bfd *abfd, int i);
-
-DESCRIPTION
- Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
- endian order regardless of what else is going on. This is useful in
- archives.
-
-*/
-void
-bfd_write_bigendian_4byte_int (abfd, i)
- bfd *abfd;
- int i;
-{
- bfd_byte buffer[4];
- bfd_putb32(i, buffer);
- if (bfd_write((PTR)buffer, 4, 1, abfd) != 4)
- abort ();
-}
-
-long
-bfd_tell (abfd)
- bfd *abfd;
-{
- file_ptr ptr;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return abfd->where;
-
- ptr = ftell (bfd_cache_lookup(abfd));
-
- if (abfd->my_archive)
- ptr -= abfd->origin;
- abfd->where = ptr;
- return ptr;
-}
-
-int
-bfd_flush (abfd)
- bfd *abfd;
-{
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- return 0;
- return fflush (bfd_cache_lookup(abfd));
-}
-
-/* Returns 0 for success, negative value for failure (in which case
- bfd_get_error can retrieve the error code). */
-int
-bfd_stat (abfd, statbuf)
- bfd *abfd;
- struct stat *statbuf;
-{
- FILE *f;
- int result;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- abort ();
-
- f = bfd_cache_lookup (abfd);
- if (f == NULL)
- {
- bfd_set_error (bfd_error_system_call);
- return -1;
- }
- result = fstat (fileno (f), statbuf);
- if (result < 0)
- bfd_set_error (bfd_error_system_call);
- return result;
-}
-
-/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
- can retrieve the error code). */
-
-int
-bfd_seek (abfd, position, direction)
- bfd *abfd;
- file_ptr position;
- int direction;
-{
- int result;
- FILE *f;
- file_ptr file_position;
- /* For the time being, a BFD may not seek to it's end. The problem
- is that we don't easily have a way to recognize the end of an
- element in an archive. */
-
- BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
-
- if (direction == SEEK_CUR && position == 0)
- return 0;
-
- if ((abfd->flags & BFD_IN_MEMORY) != 0)
- {
- if (direction == SEEK_SET)
- abfd->where = position;
- else
- abfd->where += position;
- return 0;
- }
-
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- if (abfd->format != bfd_archive && abfd->my_archive == 0)
- {
-#if 0
- /* Explanation for this code: I'm only about 95+% sure that the above
- conditions are sufficient and that all i/o calls are properly
- adjusting the `where' field. So this is sort of an `assert'
- that the `where' field is correct. If we can go a while without
- tripping the abort, we can probably safely disable this code,
- so that the real optimizations happen. */
- file_ptr where_am_i_now;
- where_am_i_now = ftell (bfd_cache_lookup (abfd));
- if (abfd->my_archive)
- where_am_i_now -= abfd->origin;
- if (where_am_i_now != abfd->where)
- abort ();
-#endif
- if (direction == SEEK_SET && position == abfd->where)
- return 0;
- }
- else
- {
- /* We need something smarter to optimize access to archives.
- Currently, anything inside an archive is read via the file
- handle for the archive. Which means that a bfd_seek on one
- component affects the `current position' in the archive, as
- well as in any other component.
-
- It might be sufficient to put a spike through the cache
- abstraction, and look to the archive for the file position,
- but I think we should try for something cleaner.
-
- In the meantime, no optimization for archives. */
- }
-#endif
-
- f = bfd_cache_lookup (abfd);
- file_position = position;
- if (direction == SEEK_SET && abfd->my_archive != NULL)
- file_position += abfd->origin;
-
- result = fseek (f, file_position, direction);
-
- if (result != 0)
- {
- /* Force redetermination of `where' field. */
- bfd_tell (abfd);
- bfd_set_error (bfd_error_system_call);
- }
- else
- {
-#ifdef FILE_OFFSET_IS_CHAR_INDEX
- /* Adjust `where' field. */
- if (direction == SEEK_SET)
- abfd->where = position;
- else
- abfd->where += position;
-#endif
- }
- return result;
-}
-
-/** The do-it-yourself (byte) sex-change kit */
-
-/* The middle letter e.g. get<b>short indicates Big or Little endian
- target machine. It doesn't matter what the byte order of the host
- machine is; these routines work for either. */
-
-/* FIXME: Should these take a count argument?
- Answer (gnu@cygnus.com): No, but perhaps they should be inline
- functions in swap.h #ifdef __GNUC__.
- Gprof them later and find out. */
-
-/*
-FUNCTION
- bfd_put_size
-FUNCTION
- bfd_get_size
-
-DESCRIPTION
- These macros as used for reading and writing raw data in
- sections; each access (except for bytes) is vectored through
- the target format of the BFD and mangled accordingly. The
- mangling performs any necessary endian translations and
- removes alignment restrictions. Note that types accepted and
- returned by these macros are identical so they can be swapped
- around in macros---for example, @file{libaout.h} defines <<GET_WORD>>
- to either <<bfd_get_32>> or <<bfd_get_64>>.
-
- In the put routines, @var{val} must be a <<bfd_vma>>. If we are on a
- system without prototypes, the caller is responsible for making
- sure that is true, with a cast if necessary. We don't cast
- them in the macro definitions because that would prevent <<lint>>
- or <<gcc -Wall>> from detecting sins such as passing a pointer.
- To detect calling these with less than a <<bfd_vma>>, use
- <<gcc -Wconversion>> on a host with 64 bit <<bfd_vma>>'s.
-
-.
-.{* Byte swapping macros for user section data. *}
-.
-.#define bfd_put_8(abfd, val, ptr) \
-. (*((unsigned char *)(ptr)) = (unsigned char)(val))
-.#define bfd_put_signed_8 \
-. bfd_put_8
-.#define bfd_get_8(abfd, ptr) \
-. (*(unsigned char *)(ptr))
-.#define bfd_get_signed_8(abfd, ptr) \
-. ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
-.
-.#define bfd_put_16(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
-.#define bfd_put_signed_16 \
-. bfd_put_16
-.#define bfd_get_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx16, (ptr))
-.#define bfd_get_signed_16(abfd, ptr) \
-. BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
-.
-.#define bfd_put_32(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
-.#define bfd_put_signed_32 \
-. bfd_put_32
-.#define bfd_get_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx32, (ptr))
-.#define bfd_get_signed_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
-.
-.#define bfd_put_64(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
-.#define bfd_put_signed_64 \
-. bfd_put_64
-.#define bfd_get_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx64, (ptr))
-.#define bfd_get_signed_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
-.
-*/
-
-/*
-FUNCTION
- bfd_h_put_size
- bfd_h_get_size
-
-DESCRIPTION
- These macros have the same function as their <<bfd_get_x>>
- bretheren, except that they are used for removing information
- for the header records of object files. Believe it or not,
- some object files keep their header records in big endian
- order and their data in little endian order.
-.
-.{* Byte swapping macros for file header data. *}
-.
-.#define bfd_h_put_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
-.#define bfd_h_put_signed_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
-.#define bfd_h_get_8(abfd, ptr) \
-. bfd_get_8 (abfd, ptr)
-.#define bfd_h_get_signed_8(abfd, ptr) \
-. bfd_get_signed_8 (abfd, ptr)
-.
-.#define bfd_h_put_16(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
-.#define bfd_h_put_signed_16 \
-. bfd_h_put_16
-.#define bfd_h_get_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx16,(ptr))
-.#define bfd_h_get_signed_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
-.
-.#define bfd_h_put_32(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
-.#define bfd_h_put_signed_32 \
-. bfd_h_put_32
-.#define bfd_h_get_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx32,(ptr))
-.#define bfd_h_get_signed_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
-.
-.#define bfd_h_put_64(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
-.#define bfd_h_put_signed_64 \
-. bfd_h_put_64
-.#define bfd_h_get_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx64,(ptr))
-.#define bfd_h_get_signed_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
-.
-*/
-
-/* Sign extension to bfd_signed_vma. */
-#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000)
-#define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000)
-#define EIGHT_GAZILLION (((BFD_HOST_64_BIT)0x80000000) << 32)
-#define COERCE64(x) \
- (((bfd_signed_vma) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION)
-
-bfd_vma
-bfd_getb16 (addr)
- register const bfd_byte *addr;
-{
- return (addr[0] << 8) | addr[1];
-}
-
-bfd_vma
-bfd_getl16 (addr)
- register const bfd_byte *addr;
-{
- return (addr[1] << 8) | addr[0];
-}
-
-bfd_signed_vma
-bfd_getb_signed_16 (addr)
- register const bfd_byte *addr;
-{
- return COERCE16((addr[0] << 8) | addr[1]);
-}
-
-bfd_signed_vma
-bfd_getl_signed_16 (addr)
- register const bfd_byte *addr;
-{
- return COERCE16((addr[1] << 8) | addr[0]);
-}
-
-void
-bfd_putb16 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)(data >> 8);
- addr[1] = (bfd_byte )data;
-}
-
-void
-bfd_putl16 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte )data;
- addr[1] = (bfd_byte)(data >> 8);
-}
-
-bfd_vma
-bfd_getb32 (addr)
- register const bfd_byte *addr;
-{
- return (((((bfd_vma)addr[0] << 8) | addr[1]) << 8)
- | addr[2]) << 8 | addr[3];
-}
-
-bfd_vma
-bfd_getl32 (addr)
- register const bfd_byte *addr;
-{
- return (((((bfd_vma)addr[3] << 8) | addr[2]) << 8)
- | addr[1]) << 8 | addr[0];
-}
-
-bfd_signed_vma
-bfd_getb_signed_32 (addr)
- register const bfd_byte *addr;
-{
- return COERCE32((((((bfd_vma)addr[0] << 8) | addr[1]) << 8)
- | addr[2]) << 8 | addr[3]);
-}
-
-bfd_signed_vma
-bfd_getl_signed_32 (addr)
- register const bfd_byte *addr;
-{
- return COERCE32((((((bfd_vma)addr[3] << 8) | addr[2]) << 8)
- | addr[1]) << 8 | addr[0]);
-}
-
-bfd_vma
-bfd_getb64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
-
- high= ((((((((addr[0]) << 8) |
- addr[1]) << 8) |
- addr[2]) << 8) |
- addr[3]) );
-
- low = (((((((((bfd_vma)addr[4]) << 8) |
- addr[5]) << 8) |
- addr[6]) << 8) |
- addr[7]));
-
- return high << 32 | low;
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-bfd_vma
-bfd_getl64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
- high= (((((((addr[7] << 8) |
- addr[6]) << 8) |
- addr[5]) << 8) |
- addr[4]));
-
- low = ((((((((bfd_vma)addr[3] << 8) |
- addr[2]) << 8) |
- addr[1]) << 8) |
- addr[0]) );
-
- return high << 32 | low;
-#else
- BFD_FAIL();
- return 0;
-#endif
-
-}
-
-bfd_signed_vma
-bfd_getb_signed_64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
-
- high= ((((((((addr[0]) << 8) |
- addr[1]) << 8) |
- addr[2]) << 8) |
- addr[3]) );
-
- low = (((((((((bfd_vma)addr[4]) << 8) |
- addr[5]) << 8) |
- addr[6]) << 8) |
- addr[7]));
-
- return COERCE64(high << 32 | low);
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-bfd_signed_vma
-bfd_getl_signed_64 (addr)
- register const bfd_byte *addr;
-{
-#ifdef BFD64
- bfd_vma low, high;
- high= (((((((addr[7] << 8) |
- addr[6]) << 8) |
- addr[5]) << 8) |
- addr[4]));
-
- low = ((((((((bfd_vma)addr[3] << 8) |
- addr[2]) << 8) |
- addr[1]) << 8) |
- addr[0]) );
-
- return COERCE64(high << 32 | low);
-#else
- BFD_FAIL();
- return 0;
-#endif
-}
-
-void
-bfd_putb32 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)(data >> 24);
- addr[1] = (bfd_byte)(data >> 16);
- addr[2] = (bfd_byte)(data >> 8);
- addr[3] = (bfd_byte)data;
-}
-
-void
-bfd_putl32 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
- addr[0] = (bfd_byte)data;
- addr[1] = (bfd_byte)(data >> 8);
- addr[2] = (bfd_byte)(data >> 16);
- addr[3] = (bfd_byte)(data >> 24);
-}
-
-void
-bfd_putb64 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
-#ifdef BFD64
- addr[0] = (bfd_byte)(data >> (7*8));
- addr[1] = (bfd_byte)(data >> (6*8));
- addr[2] = (bfd_byte)(data >> (5*8));
- addr[3] = (bfd_byte)(data >> (4*8));
- addr[4] = (bfd_byte)(data >> (3*8));
- addr[5] = (bfd_byte)(data >> (2*8));
- addr[6] = (bfd_byte)(data >> (1*8));
- addr[7] = (bfd_byte)(data >> (0*8));
-#else
- BFD_FAIL();
-#endif
-}
-
-void
-bfd_putl64 (data, addr)
- bfd_vma data;
- register bfd_byte *addr;
-{
-#ifdef BFD64
- addr[7] = (bfd_byte)(data >> (7*8));
- addr[6] = (bfd_byte)(data >> (6*8));
- addr[5] = (bfd_byte)(data >> (5*8));
- addr[4] = (bfd_byte)(data >> (4*8));
- addr[3] = (bfd_byte)(data >> (3*8));
- addr[2] = (bfd_byte)(data >> (2*8));
- addr[1] = (bfd_byte)(data >> (1*8));
- addr[0] = (bfd_byte)(data >> (0*8));
-#else
- BFD_FAIL();
-#endif
-}
-
-/* Default implementation */
-
-boolean
-_bfd_generic_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (count == 0)
- return true;
- if ((bfd_size_type)(offset+count) > section->_raw_size
- || bfd_seek(abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1
- || bfd_read(location, (bfd_size_type)1, count, abfd) != count)
- return (false); /* on error */
- return (true);
-}
-
-boolean
-_bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
- bfd *abfd;
- sec_ptr section;
- bfd_window *w;
- file_ptr offset;
- bfd_size_type count;
-{
-#ifdef USE_MMAP
- if (count == 0)
- return true;
- if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
- {
- /* We don't know what changes the bfd's get_section_contents
- method may have to make. So punt trying to map the file
- window, and let get_section_contents do its thing. */
- /* @@ FIXME : If the internal window has a refcount of 1 and was
- allocated with malloc instead of mmap, just reuse it. */
- bfd_free_window (w);
- w->i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
- if (w->i == NULL)
- return false;
- w->i->data = (PTR) bfd_malloc ((size_t) count);
- if (w->i->data == NULL)
- {
- free (w->i);
- w->i = NULL;
- return false;
- }
- w->i->mapped = 0;
- w->i->refcount = 1;
- w->size = w->i->size = count;
- w->data = w->i->data;
- return bfd_get_section_contents (abfd, section, w->data, offset, count);
- }
- if ((bfd_size_type) (offset+count) > section->_raw_size
- || (bfd_get_file_window (abfd, section->filepos + offset, count, w, true)
- == false))
- return false;
- return true;
-#else
- abort ();
-#endif
-}
-
-/* This generic function can only be used in implementations where creating
- NEW sections is disallowed. It is useful in patching existing sections
- in read-write files, though. See other set_section_contents functions
- to see why it doesn't work for new sections. */
-boolean
-_bfd_generic_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (count == 0)
- return true;
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
- || bfd_write (location, (bfd_size_type) 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_log2
-
-SYNOPSIS
- unsigned int bfd_log2(bfd_vma x);
-
-DESCRIPTION
- Return the log base 2 of the value supplied, rounded up. E.g., an
- @var{x} of 1025 returns 11.
-*/
-
-unsigned
-bfd_log2(x)
- bfd_vma x;
-{
- unsigned result = 0;
- while ( (bfd_vma)(1<< result) < x)
- result++;
- return result;
-}
-
-boolean
-bfd_generic_is_local_label (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- char locals_prefix = (bfd_get_symbol_leading_char (abfd) == '_') ? 'L' : '.';
-
- return (sym->name[0] == locals_prefix);
-}
-
diff --git a/contrib/gdb/bfd/libbfd.h b/contrib/gdb/bfd/libbfd.h
deleted file mode 100644
index 5cf504c..0000000
--- a/contrib/gdb/bfd/libbfd.h
+++ /dev/null
@@ -1,735 +0,0 @@
-/* libbfd.h -- Declarations used by bfd library *implementation*.
- (This include file is not for users of the library.)
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
-** change libbfd-in.h or the other BFD source files processed to
-** generate this file.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Align an address upward to a boundary, expressed as a number of bytes.
- E.g. align to an 8-byte boundary with argument of 8. */
-#define BFD_ALIGN(this, boundary) \
- ((( (this) + ((boundary) -1)) & (~((boundary)-1))))
-
-/* If you want to read and write large blocks, you might want to do it
- in quanta of this amount */
-#define DEFAULT_BUFFERSIZE 8192
-
-/* Set a tdata field. Can't use the other macros for this, since they
- do casts, and casting to the left of assignment isn't portable. */
-#define set_tdata(bfd, v) ((bfd)->tdata.any = (PTR) (v))
-
-/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
- to an instance of this structure. */
-
-struct bfd_in_memory
-{
- /* Size of buffer. */
- bfd_size_type size;
- /* Buffer holding contents of BFD. */
- bfd_byte *buffer;
-};
-
-/* tdata for an archive. For an input archive, cache
- needs to be free()'d. For an output archive, symdefs do. */
-
-struct artdata {
- file_ptr first_file_filepos;
- /* Speed up searching the armap */
- struct ar_cache *cache;
- bfd *archive_head; /* Only interesting in output routines */
- carsym *symdefs; /* the symdef entries */
- symindex symdef_count; /* how many there are */
- char *extended_names; /* clever intel extension */
- /* when more compilers are standard C, this can be a time_t */
- long armap_timestamp; /* Timestamp value written into armap.
- This is used for BSD archives to check
- that the timestamp is recent enough
- for the BSD linker to not complain,
- just before we finish writing an
- archive. */
- file_ptr armap_datepos; /* Position within archive to seek to
- rewrite the date field. */
- PTR tdata; /* Backend specific information. */
-};
-
-#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
-
-/* Goes in bfd's arelt_data slot */
-struct areltdata {
- char * arch_header; /* it's actually a string */
- unsigned int parsed_size; /* octets of filesize not including ar_hdr */
- char *filename; /* null-terminated */
-};
-
-#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
-
-extern PTR bfd_malloc PARAMS ((size_t));
-extern PTR bfd_realloc PARAMS ((PTR, size_t));
-extern PTR bfd_zmalloc PARAMS ((size_t));
-
-extern bfd_error_handler_type _bfd_error_handler;
-
-/* These routines allocate and free things on the BFD's obstack. */
-
-PTR bfd_alloc PARAMS ((bfd *abfd, size_t size));
-PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size));
-void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size));
-PTR bfd_alloc_finish PARAMS ((bfd *abfd));
-PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t wanted));
-
-#define bfd_release(x,y) (void) obstack_free(&(x->memory),y)
-
-bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
-bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
-boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
-boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
-const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
-boolean bfd_slurp_armap PARAMS ((bfd *abfd));
-boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
-#define bfd_slurp_bsd_armap bfd_slurp_armap
-#define bfd_slurp_coff_armap bfd_slurp_armap
-boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
-extern boolean _bfd_construct_extended_name_table
- PARAMS ((bfd *, boolean, char **, bfd_size_type *));
-boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
-boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
-bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
-extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
-bfd * _bfd_new_bfd PARAMS ((void));
-
-boolean bfd_false PARAMS ((bfd *ignore));
-boolean bfd_true PARAMS ((bfd *ignore));
-PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
-int bfd_0 PARAMS ((bfd *ignore));
-unsigned int bfd_0u PARAMS ((bfd *ignore));
-long bfd_0l PARAMS ((bfd *ignore));
-long _bfd_n1 PARAMS ((bfd *ignore));
-void bfd_void PARAMS ((bfd *ignore));
-
-bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
-const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
-
-void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-
-boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
- struct orl *map, unsigned int orl_count, int stridx));
-
-boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
- struct orl *map, unsigned int orl_count, int stridx));
-
-extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
-
-extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
-
-bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
- bfd *last_file));
-
-int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
-
-#define _bfd_read_ar_hdr(abfd) \
- BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
-
-/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
- BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
-
-#define _bfd_generic_close_and_cleanup bfd_true
-#define _bfd_generic_bfd_free_cached_info bfd_true
-#define _bfd_generic_new_section_hook \
- ((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
-extern boolean _bfd_generic_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
- bfd_size_type count));
-extern boolean _bfd_generic_get_section_contents_in_window
- PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
-
-/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
- BFD_JUMP_TABLE_COPY (_bfd_generic). */
-
-#define _bfd_generic_bfd_copy_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#define _bfd_generic_bfd_merge_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#define _bfd_generic_bfd_set_private_flags \
- ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
-#define _bfd_generic_bfd_copy_private_section_data \
- ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
-#define _bfd_generic_bfd_copy_private_symbol_data \
- ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
-#define _bfd_generic_bfd_print_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
-
-/* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
- support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
-
-extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
-extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
-extern boolean _bfd_nocore_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
- file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
-
-#define _bfd_noarchive_slurp_armap bfd_false
-#define _bfd_noarchive_slurp_extended_name_table bfd_false
-#define _bfd_noarchive_construct_extended_name_table \
- ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
- bfd_false)
-#define _bfd_noarchive_truncate_arname \
- ((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
-#define _bfd_noarchive_write_armap \
- ((boolean (*) \
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
- bfd_false)
-#define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
-#define _bfd_noarchive_openr_next_archived_file \
- ((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
-#define _bfd_noarchive_get_elt_at_index \
- ((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
-#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define _bfd_noarchive_update_armap_timestamp bfd_false
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
- archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
-
-#define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
-#define _bfd_archive_bsd_slurp_extended_name_table \
- _bfd_slurp_extended_name_table
-extern boolean _bfd_archive_bsd_construct_extended_name_table
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd_write_armap bsd_write_armap
-#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_archive_bsd_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_archive_bsd_generic_stat_arch_elt \
- bfd_generic_stat_arch_elt
-extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
- archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
-
-#define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
-#define _bfd_archive_coff_slurp_extended_name_table \
- _bfd_slurp_extended_name_table
-extern boolean _bfd_archive_coff_construct_extended_name_table
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
-#define _bfd_archive_coff_write_armap coff_write_armap
-#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_archive_coff_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_archive_coff_generic_stat_arch_elt \
- bfd_generic_stat_arch_elt
-#define _bfd_archive_coff_update_armap_timestamp bfd_true
-
-/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
- support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
-
-#define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
-#define _bfd_nosymbols_get_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
-#define _bfd_nosymbols_make_empty_symbol \
- ((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
-#define _bfd_nosymbols_print_symbol \
- ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
-#define _bfd_nosymbols_get_symbol_info \
- ((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
-#define _bfd_nosymbols_bfd_is_local_label \
- ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false)
-#define _bfd_nosymbols_get_lineno \
- ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
-#define _bfd_nosymbols_find_nearest_line \
- ((boolean (*) \
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
- const char **, unsigned int *))) \
- bfd_false)
-#define _bfd_nosymbols_bfd_make_debug_symbol \
- ((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
-#define _bfd_nosymbols_read_minisymbols \
- ((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
-#define _bfd_nosymbols_minisymbol_to_symbol \
- ((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
- bfd_nullvoidptr)
-
-/* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
- support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
-
-#define _bfd_norelocs_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
-#define _bfd_norelocs_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
-#define _bfd_norelocs_bfd_reloc_type_lookup \
- ((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
- bfd_nullvoidptr)
-
-/* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
- be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
-
-#define _bfd_nowrite_set_arch_mach \
- ((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
- bfd_false)
-#define _bfd_nowrite_set_section_contents \
- ((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
- bfd_false)
-
-/* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
- BFD_JUMP_TABLE_WRITE (_bfd_generic). */
-
-#define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
-extern boolean _bfd_generic_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-
-/* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
- support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
-
-#define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
-#define _bfd_nolink_bfd_get_relocated_section_contents \
- ((bfd_byte *(*) \
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
- bfd_byte *, boolean, asymbol **))) \
- bfd_nullvoidptr)
-#define _bfd_nolink_bfd_relax_section \
- ((boolean (*) \
- PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
- bfd_false)
-#define _bfd_nolink_bfd_link_hash_table_create \
- ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
-#define _bfd_nolink_bfd_link_add_symbols \
- ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
-#define _bfd_nolink_bfd_final_link \
- ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
-#define _bfd_nolink_bfd_link_split_section \
- ((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
-
-/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
- have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
- (_bfd_nodynamic). */
-
-#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
-#define _bfd_nodynamic_canonicalize_dynamic_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
-#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
-#define _bfd_nodynamic_canonicalize_dynamic_reloc \
- ((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
-
-/* Generic routine to determine of the given symbol is a local
- label. */
-extern boolean bfd_generic_is_local_label PARAMS ((bfd *, asymbol *));
-
-/* Generic minisymbol routines. */
-extern long _bfd_generic_read_minisymbols
- PARAMS ((bfd *, boolean, PTR *, unsigned int *));
-extern asymbol *_bfd_generic_minisymbol_to_symbol
- PARAMS ((bfd *, boolean, const PTR, asymbol *));
-
-/* Find the nearest line using .stab/.stabstr sections. */
-extern boolean _bfd_stab_section_find_nearest_line
- PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
- const char **, unsigned int *, PTR *));
-
-/* A routine to create entries for a bfd_link_hash_table. */
-extern struct bfd_hash_entry *_bfd_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string));
-
-/* Initialize a bfd_link_hash_table. */
-extern boolean _bfd_link_hash_table_init
- PARAMS ((struct bfd_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Generic link hash table creation routine. */
-extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
- PARAMS ((bfd *));
-
-/* Generic add symbol routine. */
-extern boolean _bfd_generic_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Generic add symbol routine. This version is used by targets for
- which the linker must collect constructors and destructors by name,
- as the collect2 program does. */
-extern boolean _bfd_generic_link_add_symbols_collect
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Generic archive add symbol routine. */
-extern boolean _bfd_generic_link_add_archive_symbols
- PARAMS ((bfd *, struct bfd_link_info *,
- boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
-
-/* Forward declaration to avoid prototype errors. */
-typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-
-/* Generic routine to add a single symbol. */
-extern boolean _bfd_generic_link_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
- asection *, bfd_vma, const char *, boolean copy,
- boolean constructor, struct bfd_link_hash_entry **));
-
-/* Generic link routine. */
-extern boolean _bfd_generic_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern boolean _bfd_generic_link_split_section
- PARAMS ((bfd *, struct sec *));
-
-/* Generic reloc_link_order processing routine. */
-extern boolean _bfd_generic_reloc_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Default link order processing routine. */
-extern boolean _bfd_default_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Count the number of reloc entries in a link order list. */
-extern unsigned int _bfd_count_link_order_relocs
- PARAMS ((struct bfd_link_order *));
-
-/* Final link relocation routine. */
-extern bfd_reloc_status_type _bfd_final_link_relocate
- PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
- bfd_vma address, bfd_vma value, bfd_vma addend));
-
-/* Relocate a particular location by a howto and a value. */
-extern bfd_reloc_status_type _bfd_relocate_contents
- PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
-
-/* Create a string table. */
-extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
-
-/* Create an XCOFF .debug section style string table. */
-extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
-
-/* Free a string table. */
-extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
-
-/* Get the size of a string table. */
-extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
-
-/* Add a string to a string table. */
-extern bfd_size_type _bfd_stringtab_add
- PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
- boolean copy));
-
-/* Write out a string table. */
-extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
-
-/* Macros to tell if bfds are read or write enabled.
-
- Note that bfds open for read may be scribbled into if the fd passed
- to bfd_fdopenr is actually open both for read and write
- simultaneously. However an output bfd will never be open for
- read. Therefore sometimes you want to check bfd_read_p or
- !bfd_read_p, and only sometimes bfd_write_p.
-*/
-
-#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
-#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
-
-void bfd_assert PARAMS ((const char*,int));
-
-#define BFD_ASSERT(x) \
-{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
-
-#define BFD_FAIL() \
-{ bfd_assert(__FILE__,__LINE__); }
-
-FILE * bfd_cache_lookup_worker PARAMS ((bfd *));
-
-extern bfd *bfd_last_cache;
-
-/* Now Steve, what's the story here? */
-#ifdef lint
-#define itos(x) "l"
-#define stoi(x) 1
-#else
-#define itos(x) ((char*)(x))
-#define stoi(x) ((int)(x))
-#endif
-
-/* List of supported target vectors, and the default vector (if
- bfd_default_vector[0] is NULL, there is no default). */
-extern const bfd_target * const bfd_target_vector[];
-extern const bfd_target * const bfd_default_vector[];
-
-/* Functions shared by the ECOFF and MIPS ELF backends, which have no
- other common header files. */
-
-#if defined(__STDC__) || defined(ALMOST_STDC)
-struct ecoff_find_line;
-#endif
-
-extern boolean _bfd_ecoff_locate_line
- PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
- const struct ecoff_debug_swap * const, struct ecoff_find_line *,
- const char **, const char **, unsigned int *));
-extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
-extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
-extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
-
-extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
-extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
-
-/* And more follows */
-
-void
-bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i));
-
-unsigned int
-bfd_log2 PARAMS ((bfd_vma x));
-
-#define BFD_CACHE_MAX_OPEN 10
-extern bfd *bfd_last_cache;
-
-#define bfd_cache_lookup(x) \
- ((x)==bfd_last_cache? \
- (FILE*)(bfd_last_cache->iostream): \
- bfd_cache_lookup_worker(x))
-boolean
-bfd_cache_init PARAMS ((bfd *abfd));
-
-boolean
-bfd_cache_close PARAMS ((bfd *abfd));
-
-FILE*
-bfd_open_file PARAMS ((bfd *abfd));
-
-FILE *
-bfd_cache_lookup_worker PARAMS ((bfd *abfd));
-
-#ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
-
-static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
-
- "BFD_RELOC_64",
- "BFD_RELOC_32",
- "BFD_RELOC_26",
- "BFD_RELOC_16",
- "BFD_RELOC_14",
- "BFD_RELOC_8",
- "BFD_RELOC_64_PCREL",
- "BFD_RELOC_32_PCREL",
- "BFD_RELOC_24_PCREL",
- "BFD_RELOC_16_PCREL",
- "BFD_RELOC_12_PCREL",
- "BFD_RELOC_8_PCREL",
- "BFD_RELOC_32_GOT_PCREL",
- "BFD_RELOC_16_GOT_PCREL",
- "BFD_RELOC_8_GOT_PCREL",
- "BFD_RELOC_32_GOTOFF",
- "BFD_RELOC_16_GOTOFF",
- "BFD_RELOC_LO16_GOTOFF",
- "BFD_RELOC_HI16_GOTOFF",
- "BFD_RELOC_HI16_S_GOTOFF",
- "BFD_RELOC_8_GOTOFF",
- "BFD_RELOC_32_PLT_PCREL",
- "BFD_RELOC_24_PLT_PCREL",
- "BFD_RELOC_16_PLT_PCREL",
- "BFD_RELOC_8_PLT_PCREL",
- "BFD_RELOC_32_PLTOFF",
- "BFD_RELOC_16_PLTOFF",
- "BFD_RELOC_LO16_PLTOFF",
- "BFD_RELOC_HI16_PLTOFF",
- "BFD_RELOC_HI16_S_PLTOFF",
- "BFD_RELOC_8_PLTOFF",
- "BFD_RELOC_68K_GLOB_DAT",
- "BFD_RELOC_68K_JMP_SLOT",
- "BFD_RELOC_68K_RELATIVE",
- "BFD_RELOC_32_BASEREL",
- "BFD_RELOC_16_BASEREL",
- "BFD_RELOC_LO16_BASEREL",
- "BFD_RELOC_HI16_BASEREL",
- "BFD_RELOC_HI16_S_BASEREL",
- "BFD_RELOC_8_BASEREL",
- "BFD_RELOC_RVA",
- "BFD_RELOC_8_FFnn",
- "BFD_RELOC_32_PCREL_S2",
- "BFD_RELOC_16_PCREL_S2",
- "BFD_RELOC_23_PCREL_S2",
- "BFD_RELOC_HI22",
- "BFD_RELOC_LO10",
- "BFD_RELOC_GPREL16",
- "BFD_RELOC_GPREL32",
- "BFD_RELOC_I960_CALLJ",
- "BFD_RELOC_NONE",
- "BFD_RELOC_SPARC_WDISP22",
- "BFD_RELOC_SPARC22",
- "BFD_RELOC_SPARC13",
- "BFD_RELOC_SPARC_GOT10",
- "BFD_RELOC_SPARC_GOT13",
- "BFD_RELOC_SPARC_GOT22",
- "BFD_RELOC_SPARC_PC10",
- "BFD_RELOC_SPARC_PC22",
- "BFD_RELOC_SPARC_WPLT30",
- "BFD_RELOC_SPARC_COPY",
- "BFD_RELOC_SPARC_GLOB_DAT",
- "BFD_RELOC_SPARC_JMP_SLOT",
- "BFD_RELOC_SPARC_RELATIVE",
- "BFD_RELOC_SPARC_UA32",
- "BFD_RELOC_SPARC_BASE13",
- "BFD_RELOC_SPARC_BASE22",
- "BFD_RELOC_SPARC_10",
- "BFD_RELOC_SPARC_11",
- "BFD_RELOC_SPARC_OLO10",
- "BFD_RELOC_SPARC_HH22",
- "BFD_RELOC_SPARC_HM10",
- "BFD_RELOC_SPARC_LM22",
- "BFD_RELOC_SPARC_PC_HH22",
- "BFD_RELOC_SPARC_PC_HM10",
- "BFD_RELOC_SPARC_PC_LM22",
- "BFD_RELOC_SPARC_WDISP16",
- "BFD_RELOC_SPARC_WDISP19",
- "BFD_RELOC_SPARC_GLOB_JMP",
- "BFD_RELOC_SPARC_7",
- "BFD_RELOC_SPARC_6",
- "BFD_RELOC_SPARC_5",
- "BFD_RELOC_ALPHA_GPDISP_HI16",
- "BFD_RELOC_ALPHA_GPDISP_LO16",
- "BFD_RELOC_ALPHA_LITERAL",
- "BFD_RELOC_ALPHA_LITUSE",
- "BFD_RELOC_ALPHA_HINT",
- "BFD_RELOC_MIPS_JMP",
- "BFD_RELOC_HI16",
- "BFD_RELOC_HI16_S",
- "BFD_RELOC_LO16",
- "BFD_RELOC_PCREL_HI16_S",
- "BFD_RELOC_PCREL_LO16",
- "BFD_RELOC_MIPS_LITERAL",
- "BFD_RELOC_MIPS_GOT16",
- "BFD_RELOC_MIPS_CALL16",
- "BFD_RELOC_MIPS_GOT_HI16",
- "BFD_RELOC_MIPS_GOT_LO16",
- "BFD_RELOC_MIPS_CALL_HI16",
- "BFD_RELOC_MIPS_CALL_LO16",
- "BFD_RELOC_386_GOT32",
- "BFD_RELOC_386_PLT32",
- "BFD_RELOC_386_COPY",
- "BFD_RELOC_386_GLOB_DAT",
- "BFD_RELOC_386_JUMP_SLOT",
- "BFD_RELOC_386_RELATIVE",
- "BFD_RELOC_386_GOTOFF",
- "BFD_RELOC_386_GOTPC",
- "BFD_RELOC_NS32K_IMM_8",
- "BFD_RELOC_NS32K_IMM_16",
- "BFD_RELOC_NS32K_IMM_32",
- "BFD_RELOC_NS32K_IMM_8_PCREL",
- "BFD_RELOC_NS32K_IMM_16_PCREL",
- "BFD_RELOC_NS32K_IMM_32_PCREL",
- "BFD_RELOC_NS32K_DISP_8",
- "BFD_RELOC_NS32K_DISP_16",
- "BFD_RELOC_NS32K_DISP_32",
- "BFD_RELOC_NS32K_DISP_8_PCREL",
- "BFD_RELOC_NS32K_DISP_16_PCREL",
- "BFD_RELOC_NS32K_DISP_32_PCREL",
- "BFD_RELOC_PPC_B26",
- "BFD_RELOC_PPC_BA26",
- "BFD_RELOC_PPC_TOC16",
- "BFD_RELOC_PPC_B16",
- "BFD_RELOC_PPC_B16_BRTAKEN",
- "BFD_RELOC_PPC_B16_BRNTAKEN",
- "BFD_RELOC_PPC_BA16",
- "BFD_RELOC_PPC_BA16_BRTAKEN",
- "BFD_RELOC_PPC_BA16_BRNTAKEN",
- "BFD_RELOC_PPC_COPY",
- "BFD_RELOC_PPC_GLOB_DAT",
- "BFD_RELOC_PPC_JMP_SLOT",
- "BFD_RELOC_PPC_RELATIVE",
- "BFD_RELOC_PPC_LOCAL24PC",
- "BFD_RELOC_PPC_EMB_NADDR32",
- "BFD_RELOC_PPC_EMB_NADDR16",
- "BFD_RELOC_PPC_EMB_NADDR16_LO",
- "BFD_RELOC_PPC_EMB_NADDR16_HI",
- "BFD_RELOC_PPC_EMB_NADDR16_HA",
- "BFD_RELOC_PPC_EMB_SDAI16",
- "BFD_RELOC_PPC_EMB_SDA2I16",
- "BFD_RELOC_PPC_EMB_SDA2REL",
- "BFD_RELOC_PPC_EMB_SDA21",
- "BFD_RELOC_PPC_EMB_MRKREF",
- "BFD_RELOC_PPC_EMB_RELSEC16",
- "BFD_RELOC_PPC_EMB_RELST_LO",
- "BFD_RELOC_PPC_EMB_RELST_HI",
- "BFD_RELOC_PPC_EMB_RELST_HA",
- "BFD_RELOC_PPC_EMB_BIT_FLD",
- "BFD_RELOC_PPC_EMB_RELSDA",
- "BFD_RELOC_CTOR",
- "BFD_RELOC_ARM_PCREL_BRANCH",
- "BFD_RELOC_ARM_IMMEDIATE",
- "BFD_RELOC_ARM_OFFSET_IMM",
- "BFD_RELOC_ARM_SHIFT_IMM",
- "BFD_RELOC_ARM_SWI",
- "BFD_RELOC_ARM_MULTI",
- "BFD_RELOC_ARM_CP_OFF_IMM",
- "BFD_RELOC_ARM_ADR_IMM",
- "BFD_RELOC_ARM_LDR_IMM",
- "BFD_RELOC_ARM_LITERAL",
- "BFD_RELOC_ARM_IN_POOL",
- "@@overflow: BFD_RELOC_UNUSED@@",
-};
-#endif
-
-reloc_howto_type *
-bfd_default_reloc_type_lookup
- PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-boolean
-bfd_generic_relax_section
- PARAMS ((bfd *abfd,
- asection *section,
- struct bfd_link_info *,
- boolean *));
-
-bfd_byte *
-
-bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- bfd_byte *data,
- boolean relocateable,
- asymbol **symbols));
-
-extern const bfd_arch_info_type bfd_default_arch_struct;
-boolean
-bfd_default_set_arch_mach PARAMS ((bfd *abfd,
- enum bfd_architecture arch,
- unsigned long mach));
-
-const bfd_arch_info_type *
-bfd_default_compatible
- PARAMS ((const bfd_arch_info_type *a,
- const bfd_arch_info_type *b));
-
-boolean
-bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string));
-
-struct elf_internal_shdr *
-bfd_elf_find_section PARAMS ((bfd *abfd, char *name));
-
diff --git a/contrib/gdb/bfd/libcoff.h b/contrib/gdb/bfd/libcoff.h
deleted file mode 100644
index daa39b5..0000000
--- a/contrib/gdb/bfd/libcoff.h
+++ /dev/null
@@ -1,823 +0,0 @@
-/* BFD COFF object file private structure.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-** NOTE: libcoff.h is a GENERATED file. Don't change it; instead,
-** change libcoff-in.h or coffcode.h.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfdlink.h"
-
-/* Object file tdata; access macros */
-
-#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
-#define exec_hdr(bfd) (coff_data(bfd)->hdr)
-#define obj_pe(bfd) (coff_data(bfd)->pe)
-#define obj_symbols(bfd) (coff_data(bfd)->symbols)
-#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
-
-#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
-#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
-#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
-#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
-#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
-
-#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
-#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
-#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
-#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
-#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
-
-#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
-
-/* `Tdata' information kept for COFF files. */
-
-typedef struct coff_tdata
-{
- struct coff_symbol_struct *symbols; /* symtab for input bfd */
- unsigned int *conversion_table;
- int conv_table_size;
- file_ptr sym_filepos;
-
- struct coff_ptr_struct *raw_syments;
- unsigned int raw_syment_count;
-
- /* These are only valid once writing has begun */
- long int relocbase;
-
- /* These members communicate important constants about the symbol table
- to GDB's symbol-reading code. These `constants' unfortunately vary
- from coff implementation to implementation... */
- unsigned local_n_btmask;
- unsigned local_n_btshft;
- unsigned local_n_tmask;
- unsigned local_n_tshift;
- unsigned local_symesz;
- unsigned local_auxesz;
- unsigned local_linesz;
-
- /* The unswapped external symbols. May be NULL. Read by
- _bfd_coff_get_external_symbols. */
- PTR external_syms;
- /* If this is true, the external_syms may not be freed. */
- boolean keep_syms;
-
- /* The string table. May be NULL. Read by
- _bfd_coff_read_string_table. */
- char *strings;
- /* If this is true, the strings may not be freed. */
- boolean keep_strings;
-
- /* is this a PE format coff file */
- int pe;
- /* Used by the COFF backend linker. */
- struct coff_link_hash_entry **sym_hashes;
-
- /* used by the pe linker for PowerPC */
- int *local_toc_sym_map;
-
- struct bfd_link_info *link_info;
-
- /* Used by coff_find_nearest_line. */
- PTR line_info;
-} coff_data_type;
-
-/* Tdata for pe image files. */
-typedef struct pe_tdata
-{
- coff_data_type coff;
- struct internal_extra_pe_aouthdr pe_opthdr;
- int dll;
- int has_reloc_section;
- boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
- flagword real_flags;
-} pe_data_type;
-
-#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
-
-/* Tdata for XCOFF files. */
-
-struct xcoff_tdata
-{
- /* Basic COFF information. */
- coff_data_type coff;
-
- /* True if a large a.out header should be generated. */
- boolean full_aouthdr;
-
- /* TOC value. */
- bfd_vma toc;
-
- /* Index of section holding TOC. */
- int sntoc;
-
- /* Index of section holding entry point. */
- int snentry;
-
- /* .text alignment from optional header. */
- int text_align_power;
-
- /* .data alignment from optional header. */
- int data_align_power;
-
- /* modtype from optional header. */
- short modtype;
-
- /* cputype from optional header. */
- short cputype;
-
- /* maxdata from optional header. */
- bfd_size_type maxdata;
-
- /* maxstack from optional header. */
- bfd_size_type maxstack;
-
- /* Used by the XCOFF backend linker. */
- asection **csects;
- unsigned long *debug_indices;
- unsigned int import_file_id;
-};
-
-#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
-
-/* We take the address of the first element of a asymbol to ensure that the
- * macro is only ever applied to an asymbol. */
-#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
-
-/* The used_by_bfd field of a section may be set to a pointer to this
- structure. */
-
-struct coff_section_tdata
-{
- /* The relocs, swapped into COFF internal form. This may be NULL. */
- struct internal_reloc *relocs;
- /* If this is true, the relocs entry may not be freed. */
- boolean keep_relocs;
- /* The section contents. This may be NULL. */
- bfd_byte *contents;
- /* If this is true, the contents entry may not be freed. */
- boolean keep_contents;
- /* Information cached by coff_find_nearest_line. */
- bfd_vma offset;
- unsigned int i;
- const char *function;
- int line_base;
- /* Available for individual backends. */
- PTR tdata;
-};
-
-/* An accessor macro for the coff_section_tdata structure. */
-#define coff_section_data(abfd, sec) \
- ((struct coff_section_tdata *) (sec)->used_by_bfd)
-
-/* Tdata for sections in XCOFF files. This is used by the linker. */
-
-struct xcoff_section_tdata
-{
- /* Used for XCOFF csects created by the linker; points to the real
- XCOFF section which contains this csect. */
- asection *enclosing;
- /* The lineno_count field for the enclosing section, because we are
- going to clobber it there. */
- unsigned int lineno_count;
- /* The first and one past the last symbol indices for symbols used
- by this csect. */
- unsigned long first_symndx;
- unsigned long last_symndx;
-};
-
-/* An accessor macro the xcoff_section_tdata structure. */
-#define xcoff_section_data(abfd, sec) \
- ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
-
-/* COFF linker hash table entries. */
-
-struct coff_link_hash_entry
-{
- struct bfd_link_hash_entry root;
-
- /* Symbol index in output file. Set to -1 initially. Set to -2 if
- there is a reloc against this symbol. */
- long indx;
-
- /* Symbol type. */
- unsigned short type;
-
- /* Symbol class. */
- unsigned char class;
-
- /* Number of auxiliary entries. */
- char numaux;
-
- /* BFD to take auxiliary entries from. */
- bfd *auxbfd;
-
- /* Pointer to array of auxiliary entries, if any. */
- union internal_auxent *aux;
-};
-
-/* COFF linker hash table. */
-
-struct coff_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in a COFF linker hash table. */
-
-#define coff_link_hash_lookup(table, string, create, copy, follow) \
- ((struct coff_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-/* Traverse a COFF linker hash table. */
-
-#define coff_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the COFF linker hash table from a link_info structure. */
-
-#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
-
-/* Functions in coffgen.c. */
-extern const bfd_target *coff_object_p PARAMS ((bfd *));
-extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
-extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
-extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
-extern int coff_count_linenumbers PARAMS ((bfd *));
-extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
-extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
-extern void coff_mangle_symbols PARAMS ((bfd *));
-extern boolean coff_write_symbols PARAMS ((bfd *));
-extern boolean coff_write_linenumbers PARAMS ((bfd *));
-extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
-extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
-extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
-extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
-extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
-extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
-extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
-extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
- bfd_print_symbol_type how));
-extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *ret));
-extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
- unsigned long));
-extern boolean coff_find_nearest_line PARAMS ((bfd *,
- asection *,
- asymbol **,
- bfd_vma offset,
- CONST char **filename_ptr,
- CONST char **functionname_ptr,
- unsigned int *line_ptr));
-extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
-extern boolean bfd_coff_reloc16_relax_section
- PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
-extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean relocateable, asymbol **));
-extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
- struct bfd_link_info *,
- asection *));
-extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
- asection *input_section,
- bfd_vma val));
-
-/* Functions and types in cofflink.c. */
-
-#define STRING_SIZE_SIZE (4)
-
-/* We use a hash table to merge identical enum, struct, and union
- definitions in the linker. */
-
-/* Information we keep for a single element (an enum value, a
- structure or union field) in the debug merge hash table. */
-
-struct coff_debug_merge_element
-{
- /* Next element. */
- struct coff_debug_merge_element *next;
-
- /* Name. */
- const char *name;
-
- /* Type. */
- unsigned int type;
-
- /* Symbol index for complex type. */
- long tagndx;
-};
-
-/* A linked list of debug merge entries for a given name. */
-
-struct coff_debug_merge_type
-{
- /* Next type with the same name. */
- struct coff_debug_merge_type *next;
-
- /* Class of type. */
- int class;
-
- /* Symbol index where this type is defined. */
- long indx;
-
- /* List of elements. */
- struct coff_debug_merge_element *elements;
-};
-
-/* Information we store in the debug merge hash table. */
-
-struct coff_debug_merge_hash_entry
-{
- struct bfd_hash_entry root;
-
- /* A list of types with this name. */
- struct coff_debug_merge_type *types;
-};
-
-/* The debug merge hash table. */
-
-struct coff_debug_merge_hash_table
-{
- struct bfd_hash_table root;
-};
-
-/* Initialize a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_table_init(table) \
- (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
-
-/* Free a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_table_free(table) \
- (bfd_hash_table_free (&(table)->root))
-
-/* Look up an entry in a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_lookup(table, string, create, copy) \
- ((struct coff_debug_merge_hash_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-/* Information we keep for each section in the output file when doing
- a relocateable link. */
-
-struct coff_link_section_info
-{
- /* The relocs to be output. */
- struct internal_reloc *relocs;
- /* For each reloc against a global symbol whose index was not known
- when the reloc was handled, the global hash table entry. */
- struct coff_link_hash_entry **rel_hashes;
-};
-
-/* Information that we pass around while doing the final link step. */
-
-struct coff_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output BFD. */
- bfd *output_bfd;
- /* Used to indicate failure in traversal routine. */
- boolean failed;
- /* Hash table for long symbol names. */
- struct bfd_strtab_hash *strtab;
- /* When doing a relocateable link, an array of information kept for
- each output section, indexed by the target_index field. */
- struct coff_link_section_info *section_info;
- /* Symbol index of last C_FILE symbol (-1 if none). */
- long last_file_index;
- /* Contents of last C_FILE symbol. */
- struct internal_syment last_file;
- /* Hash table used to merge debug information. */
- struct coff_debug_merge_hash_table debug_merge;
- /* Buffer large enough to hold swapped symbols of any input file. */
- struct internal_syment *internal_syms;
- /* Buffer large enough to hold sections of symbols of any input file. */
- asection **sec_ptrs;
- /* Buffer large enough to hold output indices of symbols of any
- input file. */
- long *sym_indices;
- /* Buffer large enough to hold output symbols for any input file. */
- bfd_byte *outsyms;
- /* Buffer large enough to hold external line numbers for any input
- section. */
- bfd_byte *linenos;
- /* Buffer large enough to hold any input section. */
- bfd_byte *contents;
- /* Buffer large enough to hold external relocs of any input section. */
- bfd_byte *external_relocs;
- /* Buffer large enough to hold swapped relocs of any input section. */
- struct internal_reloc *internal_relocs;
-};
-
-extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern boolean _bfd_coff_link_hash_table_init
- PARAMS ((struct coff_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
- PARAMS ((bfd *));
-extern const char *_bfd_coff_internal_syment_name
- PARAMS ((bfd *, const struct internal_syment *, char *));
-extern boolean _bfd_coff_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_coff_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-extern struct internal_reloc *_bfd_coff_read_internal_relocs
- PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
- struct internal_reloc *));
-extern boolean _bfd_coff_generic_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-
-extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern boolean _bfd_coff_write_global_sym
- PARAMS ((struct coff_link_hash_entry *, PTR));
-extern boolean _bfd_coff_link_input_bfd
- PARAMS ((struct coff_final_link_info *, bfd *));
-extern boolean _bfd_coff_reloc_link_order
- PARAMS ((bfd *, struct coff_final_link_info *, asection *,
- struct bfd_link_order *));
-
-
-#define coff_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-/* Functions in xcofflink.c. */
-
-extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_xcoff_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_xcoff_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_ppc_xcoff_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-
-/* And more taken from the source .. */
-
-typedef struct coff_ptr_struct
-{
-
- /* Remembers the offset from the first symbol in the file for
- this symbol. Generated by coff_renumber_symbols. */
-unsigned int offset;
-
- /* Should the value of this symbol be renumbered. Used for
- XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
-unsigned int fix_value : 1;
-
- /* Should the tag field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_tag : 1;
-
- /* Should the endidx field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_end : 1;
-
- /* Should the x_csect.x_scnlen field be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_scnlen : 1;
-
- /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
- index into the line number entries. Set by
- coff_slurp_symbol_table. */
-unsigned int fix_line : 1;
-
- /* The container for the symbol structure as read and translated
- from the file. */
-
-union {
- union internal_auxent auxent;
- struct internal_syment syment;
- } u;
-} combined_entry_type;
-
-
- /* Each canonical asymbol really looks like this: */
-
-typedef struct coff_symbol_struct
-{
- /* The actual symbol which the rest of BFD works with */
-asymbol symbol;
-
- /* A pointer to the hidden information for this symbol */
-combined_entry_type *native;
-
- /* A pointer to the linenumber information for this symbol */
-struct lineno_cache_entry *lineno;
-
- /* Have the line numbers been relocated yet ? */
-boolean done_lineno;
-} coff_symbol_type;
-typedef struct
-{
- void (*_bfd_coff_swap_aux_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR in));
-
- void (*_bfd_coff_swap_sym_in) PARAMS ((
- bfd *abfd ,
- PTR ext,
- PTR in));
-
- void (*_bfd_coff_swap_lineno_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
-
- unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
- bfd *abfd,
- PTR in,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
- bfd *abfd,
- PTR src,
- PTR dst));
-
- unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int _bfd_filhsz;
- unsigned int _bfd_aoutsz;
- unsigned int _bfd_scnhsz;
- unsigned int _bfd_symesz;
- unsigned int _bfd_auxesz;
- unsigned int _bfd_relsz;
- unsigned int _bfd_linesz;
- boolean _bfd_coff_long_filenames;
- void (*_bfd_coff_swap_filehdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_reloc_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- boolean (*_bfd_coff_bad_format_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- PTR (*_bfd_coff_mkobject_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr,
- PTR internal_aouthdr));
- flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
- bfd *abfd,
- PTR internal_scnhdr,
- const char *name));
- void (*_bfd_set_alignment_hook) PARAMS ((
- bfd *abfd,
- asection *sec,
- PTR internal_scnhdr));
- boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_symname_in_debug) PARAMS ((
- bfd *abfd,
- struct internal_syment *sym));
- boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
- bfd *abfd,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- unsigned int indaux,
- combined_entry_type *aux));
- boolean (*_bfd_coff_print_aux) PARAMS ((
- bfd *abfd,
- FILE *file,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- combined_entry_type *aux,
- unsigned int indaux));
- void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
- bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- arelent *reloc,
- bfd_byte *data,
- unsigned int *src_ptr,
- unsigned int *dst_ptr));
- int (*_bfd_coff_reloc16_estimate) PARAMS ((
- bfd *abfd,
- asection *input_section,
- arelent *r,
- unsigned int shrink,
- struct bfd_link_info *link_info));
- boolean (*_bfd_coff_sym_is_global) PARAMS ((
- bfd *abfd,
- struct internal_syment *));
- void (*_bfd_coff_compute_section_file_positions) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_start_final_link) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info));
- boolean (*_bfd_coff_relocate_section) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- struct internal_reloc *relocs,
- struct internal_syment *syms,
- asection **sections));
- reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
- bfd *abfd,
- asection *sec,
- struct internal_reloc *rel,
- struct coff_link_hash_entry *h,
- struct internal_syment *sym,
- bfd_vma *addendp));
- boolean (*_bfd_coff_adjust_symndx) PARAMS ((
- bfd *obfd,
- struct bfd_link_info *info,
- bfd *ibfd,
- asection *sec,
- struct internal_reloc *reloc,
- boolean *adjustedp));
- boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
- struct bfd_link_info *info,
- bfd *abfd,
- const char *name,
- flagword flags,
- asection *section,
- bfd_vma value,
- const char *string,
- boolean copy,
- boolean collect,
- struct bfd_link_hash_entry **hashp));
-
-} bfd_coff_backend_data;
-
-#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
-
-#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
-
-#define bfd_coff_swap_sym_in(a,e,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
-
-#define bfd_coff_swap_lineno_in(a,e,i) \
- ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
-
-#define bfd_coff_swap_reloc_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
-
-#define bfd_coff_swap_lineno_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
-
-#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
-
-#define bfd_coff_swap_sym_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
-
-#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
-
-#define bfd_coff_swap_filehdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
-
-#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
-
-#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
-#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
-#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
-#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
-#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
-#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
-#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
-#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
-#define bfd_coff_swap_filehdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
-
-#define bfd_coff_swap_reloc_in(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
-
-#define bfd_coff_bad_format_hook(abfd, filehdr) \
- ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
-
-#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
- ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
-#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
- ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
-
-#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
- ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
-
-#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
- ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
-
-#define bfd_coff_slurp_symbol_table(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
-
-#define bfd_coff_symname_in_debug(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
-
-#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
- ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
- (abfd, file, base, symbol, aux, indaux))
-
-#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
- (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
-
-#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
- (abfd, section, reloc, shrink, link_info))
-
-#define bfd_coff_sym_is_global(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
- (abfd, sym))
-
-#define bfd_coff_compute_section_file_positions(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
- (abfd))
-
-#define bfd_coff_start_final_link(obfd, info)\
- ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
- (obfd, info))
-#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
- ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
- (obfd, info, ibfd, o, con, rel, isyms, secs))
-#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
- ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
- (abfd, sec, rel, h, sym, addendp))
-#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
- ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
- (obfd, info, ibfd, sec, rel, adjustedp))
-#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
- ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
- (info, abfd, name, flags, section, value, string, cp, coll, hashp))
-
diff --git a/contrib/gdb/bfd/libecoff.h b/contrib/gdb/bfd/libecoff.h
deleted file mode 100644
index 169610d..0000000
--- a/contrib/gdb/bfd/libecoff.h
+++ /dev/null
@@ -1,352 +0,0 @@
-/* BFD ECOFF object file private structure.
- Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfdlink.h"
-
-#ifndef ECOFF_H
-#include "coff/ecoff.h"
-#endif
-
-/* This is the backend information kept for ECOFF files. This
- structure is constant for a particular backend. The first element
- is the COFF backend data structure, so that ECOFF targets can use
- the generic COFF code. */
-
-#define ecoff_backend(abfd) \
- ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
-
-struct ecoff_backend_data
-{
- /* COFF backend information. This must be the first field. */
- bfd_coff_backend_data coff;
- /* Supported architecture. */
- enum bfd_architecture arch;
- /* Initial portion of armap string. */
- const char *armap_start;
- /* The page boundary used to align sections in a demand-paged
- executable file. E.g., 0x1000. */
- bfd_vma round;
- /* True if the .rdata section is part of the text segment, as on the
- Alpha. False if .rdata is part of the data segment, as on the
- MIPS. */
- boolean rdata_in_text;
- /* Bitsize of constructor entries. */
- unsigned int constructor_bitsize;
- /* Reloc to use for constructor entries. */
- reloc_howto_type *constructor_reloc;
- /* How to swap debugging information. */
- struct ecoff_debug_swap debug_swap;
- /* External reloc size. */
- bfd_size_type external_reloc_size;
- /* Reloc swapping functions. */
- void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
- void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
- /* Backend reloc tweaking. */
- void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
- arelent *));
- void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
- struct internal_reloc *));
- /* Relocate section contents while linking. */
- boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
- bfd *input_bfd, asection *input_section,
- bfd_byte *contents,
- PTR external_relocs));
- /* Do final adjustments to filehdr and aouthdr. */
- boolean (*adjust_headers) PARAMS ((bfd *, struct internal_filehdr *,
- struct internal_aouthdr *));
- /* Read an element from an archive at a given file position. This
- is needed because OSF/1 3.2 uses a weird archive format. */
- bfd *(*get_elt_at_filepos) PARAMS ((bfd *, file_ptr));
-};
-
-/* This is the target specific information kept for ECOFF files. */
-
-#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
-
-typedef struct ecoff_tdata
-{
- /* The reloc file position, set by
- ecoff_compute_section_file_positions. */
- file_ptr reloc_filepos;
-
- /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */
- file_ptr sym_filepos;
-
- /* The start and end of the text segment. Only valid for an
- existing file, not for one we are creating. */
- unsigned long text_start;
- unsigned long text_end;
-
- /* The cached gp value. This is used when relocating. */
- bfd_vma gp;
-
- /* The maximum size of objects to optimize using gp. This is
- typically set by the -G option to the compiler, assembler or
- linker. */
- unsigned int gp_size;
-
- /* The register masks. When linking, all the masks found in the
- input files are combined into the masks of the output file.
- These are not all used for all targets, but that's OK, because
- the relevant ones are the only ones swapped in and out. */
- unsigned long gprmask;
- unsigned long fprmask;
- unsigned long cprmask[4];
-
- /* The ECOFF symbolic debugging information. */
- struct ecoff_debug_info debug_info;
-
- /* The unswapped ECOFF symbolic information. */
- PTR raw_syments;
-
- /* The canonical BFD symbols. */
- struct ecoff_symbol_struct *canonical_symbols;
-
- /* A mapping from external symbol numbers to entries in the linker
- hash table, used when linking. */
- struct ecoff_link_hash_entry **sym_hashes;
-
- /* A mapping from reloc symbol indices to sections, used when
- linking. */
- asection **symndx_to_section;
-
- /* True if this BFD was written by the backend linker. */
- boolean linker;
-
- /* True if a warning that multiple global pointer values are
- needed in the output binary was issued already. */
- boolean issued_multiple_gp_warning;
-
- /* Used by find_nearest_line entry point. The structure could be
- included directly in this one, but there's no point to wasting
- the memory just for the infrequently called find_nearest_line. */
- struct ecoff_find_line *find_line_info;
-
-} ecoff_data_type;
-
-/* Each canonical asymbol really looks like this. */
-
-typedef struct ecoff_symbol_struct
-{
- /* The actual symbol which the rest of BFD works with */
- asymbol symbol;
-
- /* The fdr for this symbol. */
- FDR *fdr;
-
- /* true if this is a local symbol rather than an external one. */
- boolean local;
-
- /* A pointer to the unswapped hidden information for this symbol.
- This is either a struct sym_ext or a struct ext_ext, depending on
- the value of the local field above. */
- PTR native;
-} ecoff_symbol_type;
-
-/* We take the address of the first element of a asymbol to ensure that the
- macro is only ever applied to an asymbol. */
-#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
-
-/* We need to save the index of an external symbol when we write it
- out so that can set the symbol index correctly when we write out
- the relocs. */
-#define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
-#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
-
-/* When generating MIPS embedded PIC code, the linker relaxes the code
- to turn PC relative branches into longer code sequences when the PC
- relative branch is out of range. This involves reading the relocs
- in bfd_relax_section as well as in bfd_final_link, and requires the
- code to keep track of which relocs have been expanded. A pointer
- to this structure is put in the used_by_bfd pointer of a section to
- keep track of this information. The user_by_bfd pointer will be
- NULL if the information was not needed. */
-
-struct ecoff_section_tdata
-{
- /* The unswapped relocs for this section. These are stored in
- memory so the input file does not have to be read twice. */
- PTR external_relocs;
-
- /* The contents of the section. These bytes may or may not be saved
- in memory, but if it is this is a pointer to them. */
- bfd_byte *contents;
-
- /* Offset adjustments for PC relative branches. A number other than
- 1 is an addend for a PC relative branch, or a switch table entry
- which is the difference of two .text locations; this addend
- arises because the branch or difference crosses one or more
- branches which were expanded into a larger code sequence. A 1
- means that this branch was itself expanded into a larger code
- sequence. 1 is not a possible offset, since all offsets must be
- multiples of the instruction size, which is 4; also, the only
- relocs with non-zero offsets will be PC relative branches or
- switch table entries within the same object file. If this field
- is NULL, no branches were expanded and no offsets are required.
- Otherwise there are as many entries as there are relocs in the
- section, and the entry for any reloc that is not PC relative is
- zero. */
- long *offsets;
-
- /* When producing an executable (i.e., final, non-relocatable link)
- on the Alpha, we may need to use multiple global pointer values
- to span the entire .lita section. In essence, we allow each
- input .lita section to have its own gp value. To support this,
- we need to keep track of the gp values that we picked for each
- input .lita section . */
- bfd_vma gp;
-};
-
-/* An accessor macro for the ecoff_section_tdata structure. */
-#define ecoff_section_data(abfd, sec) \
- ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
-
-/* ECOFF linker hash table entries. */
-
-struct ecoff_link_hash_entry
-{
- struct bfd_link_hash_entry root;
- /* Symbol index in output file. */
- long indx;
- /* BFD that ext field value came from. */
- bfd *abfd;
- /* ECOFF external symbol information. */
- EXTR esym;
- /* Nonzero if this symbol has been written out. */
- char written;
- /* Nonzero if this symbol was referred to as small undefined. */
- char small;
-};
-
-/* ECOFF linker hash table. */
-
-struct ecoff_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Make an ECOFF object. */
-extern boolean _bfd_ecoff_mkobject PARAMS ((bfd *));
-
-/* Read in the ECOFF symbolic debugging information. */
-extern boolean _bfd_ecoff_slurp_symbolic_info
- PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
-
-/* Generic ECOFF BFD backend vectors. */
-
-extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
-extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
-
-#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
-#define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-extern boolean _bfd_ecoff_new_section_hook
- PARAMS ((bfd *, asection *));
-extern boolean _bfd_ecoff_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
-
-#define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
-
-extern boolean _bfd_ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-#define _bfd_ecoff_bfd_copy_private_section_data \
- _bfd_generic_bfd_copy_private_section_data
-
-#define _bfd_ecoff_bfd_copy_private_symbol_data \
- _bfd_generic_bfd_copy_private_symbol_data
-
-#define _bfd_ecoff_bfd_print_private_bfd_data \
- _bfd_generic_bfd_print_private_bfd_data
-
-#define _bfd_ecoff_bfd_merge_private_bfd_data \
- _bfd_generic_bfd_merge_private_bfd_data
-
-#define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-extern boolean _bfd_ecoff_slurp_armap PARAMS ((bfd *abfd));
-#define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
-#define _bfd_ecoff_construct_extended_name_table \
- _bfd_archive_bsd_construct_extended_name_table
-#define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
-extern boolean _bfd_ecoff_write_armap
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
-#define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_ecoff_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define _bfd_ecoff_update_armap_timestamp bfd_true
-
-extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
-extern long _bfd_ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
-extern asymbol *_bfd_ecoff_make_empty_symbol PARAMS ((bfd *abfd));
-extern void _bfd_ecoff_print_symbol
- PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
-extern void _bfd_ecoff_get_symbol_info
- PARAMS ((bfd *, asymbol *, symbol_info *));
-extern boolean _bfd_ecoff_bfd_is_local_label
- PARAMS ((bfd *, asymbol *));
-#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
-extern boolean _bfd_ecoff_find_nearest_line
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma offset,
- const char **filename_ptr, const char **fnname_ptr,
- unsigned int *retline_ptr));
-#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
-#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
-extern long _bfd_ecoff_canonicalize_reloc
- PARAMS ((bfd *, asection *, arelent **, asymbol **symbols));
-/* ecoff_bfd_reloc_type_lookup defined by backend. */
-
-extern boolean _bfd_ecoff_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long machine));
-extern boolean _bfd_ecoff_set_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
-
-extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
-/* ecoff_bfd_get_relocated_section_contents defined by backend. */
-/* ecoff_bfd_relax_section defined by backend. */
-extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_ecoff_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_ecoff_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Hook functions for the generic COFF section reading code. */
-
-extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
-#define _bfd_ecoff_set_alignment_hook \
- ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
-extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
-extern flagword _bfd_ecoff_styp_to_sec_flags
- PARAMS ((bfd *abfd, PTR hdr, const char *name));
-extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
-
-/* ECOFF auxiliary information swapping routines. These are the same
- for all ECOFF targets, so they are defined in ecofflink.c. */
-
-extern void _bfd_ecoff_swap_tir_in
- PARAMS ((int, const struct tir_ext *, TIR *));
-extern void _bfd_ecoff_swap_tir_out
- PARAMS ((int, const TIR *, struct tir_ext *));
-extern void _bfd_ecoff_swap_rndx_in
- PARAMS ((int, const struct rndx_ext *, RNDXR *));
-extern void _bfd_ecoff_swap_rndx_out
- PARAMS ((int, const RNDXR *, struct rndx_ext *));
diff --git a/contrib/gdb/bfd/linker.c b/contrib/gdb/bfd/linker.c
deleted file mode 100644
index 4decc88..0000000
--- a/contrib/gdb/bfd/linker.c
+++ /dev/null
@@ -1,2781 +0,0 @@
-/* linker.c -- BFD linker routines
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
-
-/*
-SECTION
- Linker Functions
-
-@cindex Linker
- The linker uses three special entry points in the BFD target
- vector. It is not necessary to write special routines for
- these entry points when creating a new BFD back end, since
- generic versions are provided. However, writing them can
- speed up linking and make it use significantly less runtime
- memory.
-
- The first routine creates a hash table used by the other
- routines. The second routine adds the symbols from an object
- file to the hash table. The third routine takes all the
- object files and links them together to create the output
- file. These routines are designed so that the linker proper
- does not need to know anything about the symbols in the object
- files that it is linking. The linker merely arranges the
- sections as directed by the linker script and lets BFD handle
- the details of symbols and relocs.
-
- The second routine and third routines are passed a pointer to
- a <<struct bfd_link_info>> structure (defined in
- <<bfdlink.h>>) which holds information relevant to the link,
- including the linker hash table (which was created by the
- first routine) and a set of callback functions to the linker
- proper.
-
- The generic linker routines are in <<linker.c>>, and use the
- header file <<genlink.h>>. As of this writing, the only back
- ends which have implemented versions of these routines are
- a.out (in <<aoutx.h>>) and ECOFF (in <<ecoff.c>>). The a.out
- routines are used as examples throughout this section.
-
-@menu
-@* Creating a Linker Hash Table::
-@* Adding Symbols to the Hash Table::
-@* Performing the Final Link::
-@end menu
-
-INODE
-Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions
-SUBSECTION
- Creating a linker hash table
-
-@cindex _bfd_link_hash_table_create in target vector
-@cindex target vector (_bfd_link_hash_table_create)
- The linker routines must create a hash table, which must be
- derived from <<struct bfd_link_hash_table>> described in
- <<bfdlink.c>>. @xref{Hash Tables} for information on how to
- create a derived hash table. This entry point is called using
- the target vector of the linker output file.
-
- The <<_bfd_link_hash_table_create>> entry point must allocate
- and initialize an instance of the desired hash table. If the
- back end does not require any additional information to be
- stored with the entries in the hash table, the entry point may
- simply create a <<struct bfd_link_hash_table>>. Most likely,
- however, some additional information will be needed.
-
- For example, with each entry in the hash table the a.out
- linker keeps the index the symbol has in the final output file
- (this index number is used so that when doing a relocateable
- link the symbol index used in the output file can be quickly
- filled in when copying over a reloc). The a.out linker code
- defines the required structures and functions for a hash table
- derived from <<struct bfd_link_hash_table>>. The a.out linker
- hash table is created by the function
- <<NAME(aout,link_hash_table_create)>>; it simply allocates
- space for the hash table, initializes it, and returns a
- pointer to it.
-
- When writing the linker routines for a new back end, you will
- generally not know exactly which fields will be required until
- you have finished. You should simply create a new hash table
- which defines no additional fields, and then simply add fields
- as they become necessary.
-
-INODE
-Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions
-SUBSECTION
- Adding symbols to the hash table
-
-@cindex _bfd_link_add_symbols in target vector
-@cindex target vector (_bfd_link_add_symbols)
- The linker proper will call the <<_bfd_link_add_symbols>>
- entry point for each object file or archive which is to be
- linked (typically these are the files named on the command
- line, but some may also come from the linker script). The
- entry point is responsible for examining the file. For an
- object file, BFD must add any relevant symbol information to
- the hash table. For an archive, BFD must determine which
- elements of the archive should be used and adding them to the
- link.
-
- The a.out version of this entry point is
- <<NAME(aout,link_add_symbols)>>.
-
-@menu
-@* Differing file formats::
-@* Adding symbols from an object file::
-@* Adding symbols from an archive::
-@end menu
-
-INODE
-Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Differing file formats
-
- Normally all the files involved in a link will be of the same
- format, but it is also possible to link together different
- format object files, and the back end must support that. The
- <<_bfd_link_add_symbols>> entry point is called via the target
- vector of the file to be added. This has an important
- consequence: the function may not assume that the hash table
- is the type created by the corresponding
- <<_bfd_link_hash_table_create>> vector. All the
- <<_bfd_link_add_symbols>> function can assume about the hash
- table is that it is derived from <<struct
- bfd_link_hash_table>>.
-
- Sometimes the <<_bfd_link_add_symbols>> function must store
- some information in the hash table entry to be used by the
- <<_bfd_final_link>> function. In such a case the <<creator>>
- field of the hash table must be checked to make sure that the
- hash table was created by an object file of the same format.
-
- The <<_bfd_final_link>> routine must be prepared to handle a
- hash entry without any extra information added by the
- <<_bfd_link_add_symbols>> function. A hash entry without
- extra information will also occur when the linker script
- directs the linker to create a symbol. Note that, regardless
- of how a hash table entry is added, all the fields will be
- initialized to some sort of null value by the hash table entry
- initialization function.
-
- See <<ecoff_link_add_externals>> for an example of how to
- check the <<creator>> field before saving information (in this
- case, the ECOFF external symbol debugging information) in a
- hash table entry.
-
-INODE
-Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Adding symbols from an object file
-
- When the <<_bfd_link_add_symbols>> routine is passed an object
- file, it must add all externally visible symbols in that
- object file to the hash table. The actual work of adding the
- symbol to the hash table is normally handled by the function
- <<_bfd_generic_link_add_one_symbol>>. The
- <<_bfd_link_add_symbols>> routine is responsible for reading
- all the symbols from the object file and passing the correct
- information to <<_bfd_generic_link_add_one_symbol>>.
-
- The <<_bfd_link_add_symbols>> routine should not use
- <<bfd_canonicalize_symtab>> to read the symbols. The point of
- providing this routine is to avoid the overhead of converting
- the symbols into generic <<asymbol>> structures.
-
-@findex _bfd_generic_link_add_one_symbol
- <<_bfd_generic_link_add_one_symbol>> handles the details of
- combining common symbols, warning about multiple definitions,
- and so forth. It takes arguments which describe the symbol to
- add, notably symbol flags, a section, and an offset. The
- symbol flags include such things as <<BSF_WEAK>> or
- <<BSF_INDIRECT>>. The section is a section in the object
- file, or something like <<bfd_und_section_ptr>> for an undefined
- symbol or <<bfd_com_section_ptr>> for a common symbol.
-
- If the <<_bfd_final_link>> routine is also going to need to
- read the symbol information, the <<_bfd_link_add_symbols>>
- routine should save it somewhere attached to the object file
- BFD. However, the information should only be saved if the
- <<keep_memory>> field of the <<info>> argument is true, so
- that the <<-no-keep-memory>> linker switch is effective.
-
- The a.out function which adds symbols from an object file is
- <<aout_link_add_object_symbols>>, and most of the interesting
- work is in <<aout_link_add_symbols>>. The latter saves
- pointers to the hash tables entries created by
- <<_bfd_generic_link_add_one_symbol>> indexed by symbol number,
- so that the <<_bfd_final_link>> routine does not have to call
- the hash table lookup routine to locate the entry.
-
-INODE
-Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table
-SUBSUBSECTION
- Adding symbols from an archive
-
- When the <<_bfd_link_add_symbols>> routine is passed an
- archive, it must look through the symbols defined by the
- archive and decide which elements of the archive should be
- included in the link. For each such element it must call the
- <<add_archive_element>> linker callback, and it must add the
- symbols from the object file to the linker hash table.
-
-@findex _bfd_generic_link_add_archive_symbols
- In most cases the work of looking through the symbols in the
- archive should be done by the
- <<_bfd_generic_link_add_archive_symbols>> function. This
- function builds a hash table from the archive symbol table and
- looks through the list of undefined symbols to see which
- elements should be included.
- <<_bfd_generic_link_add_archive_symbols>> is passed a function
- to call to make the final decision about adding an archive
- element to the link and to do the actual work of adding the
- symbols to the linker hash table.
-
- The function passed to
- <<_bfd_generic_link_add_archive_symbols>> must read the
- symbols of the archive element and decide whether the archive
- element should be included in the link. If the element is to
- be included, the <<add_archive_element>> linker callback
- routine must be called with the element as an argument, and
- the elements symbols must be added to the linker hash table
- just as though the element had itself been passed to the
- <<_bfd_link_add_symbols>> function.
-
- When the a.out <<_bfd_link_add_symbols>> function receives an
- archive, it calls <<_bfd_generic_link_add_archive_symbols>>
- passing <<aout_link_check_archive_element>> as the function
- argument. <<aout_link_check_archive_element>> calls
- <<aout_link_check_ar_symbols>>. If the latter decides to add
- the element (an element is only added if it provides a real,
- non-common, definition for a previously undefined or common
- symbol) it calls the <<add_archive_element>> callback and then
- <<aout_link_check_archive_element>> calls
- <<aout_link_add_symbols>> to actually add the symbols to the
- linker hash table.
-
- The ECOFF back end is unusual in that it does not normally
- call <<_bfd_generic_link_add_archive_symbols>>, because ECOFF
- archives already contain a hash table of symbols. The ECOFF
- back end searches the archive itself to avoid the overhead of
- creating a new hash table.
-
-INODE
-Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions
-SUBSECTION
- Performing the final link
-
-@cindex _bfd_link_final_link in target vector
-@cindex target vector (_bfd_final_link)
- When all the input files have been processed, the linker calls
- the <<_bfd_final_link>> entry point of the output BFD. This
- routine is responsible for producing the final output file,
- which has several aspects. It must relocate the contents of
- the input sections and copy the data into the output sections.
- It must build an output symbol table including any local
- symbols from the input files and the global symbols from the
- hash table. When producing relocateable output, it must
- modify the input relocs and write them into the output file.
- There may also be object format dependent work to be done.
-
- The linker will also call the <<write_object_contents>> entry
- point when the BFD is closed. The two entry points must work
- together in order to produce the correct output file.
-
- The details of how this works are inevitably dependent upon
- the specific object file format. The a.out
- <<_bfd_final_link>> routine is <<NAME(aout,final_link)>>.
-
-@menu
-@* Information provided by the linker::
-@* Relocating the section contents::
-@* Writing the symbol table::
-@end menu
-
-INODE
-Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link
-SUBSUBSECTION
- Information provided by the linker
-
- Before the linker calls the <<_bfd_final_link>> entry point,
- it sets up some data structures for the function to use.
-
- The <<input_bfds>> field of the <<bfd_link_info>> structure
- will point to a list of all the input files included in the
- link. These files are linked through the <<link_next>> field
- of the <<bfd>> structure.
-
- Each section in the output file will have a list of
- <<link_order>> structures attached to the <<link_order_head>>
- field (the <<link_order>> structure is defined in
- <<bfdlink.h>>). These structures describe how to create the
- contents of the output section in terms of the contents of
- various input sections, fill constants, and, eventually, other
- types of information. They also describe relocs that must be
- created by the BFD backend, but do not correspond to any input
- file; this is used to support -Ur, which builds constructors
- while generating a relocateable object file.
-
-INODE
-Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link
-SUBSUBSECTION
- Relocating the section contents
-
- The <<_bfd_final_link>> function should look through the
- <<link_order>> structures attached to each section of the
- output file. Each <<link_order>> structure should either be
- handled specially, or it should be passed to the function
- <<_bfd_default_link_order>> which will do the right thing
- (<<_bfd_default_link_order>> is defined in <<linker.c>>).
-
- For efficiency, a <<link_order>> of type
- <<bfd_indirect_link_order>> whose associated section belongs
- to a BFD of the same format as the output BFD must be handled
- specially. This type of <<link_order>> describes part of an
- output section in terms of a section belonging to one of the
- input files. The <<_bfd_final_link>> function should read the
- contents of the section and any associated relocs, apply the
- relocs to the section contents, and write out the modified
- section contents. If performing a relocateable link, the
- relocs themselves must also be modified and written out.
-
-@findex _bfd_relocate_contents
-@findex _bfd_final_link_relocate
- The functions <<_bfd_relocate_contents>> and
- <<_bfd_final_link_relocate>> provide some general support for
- performing the actual relocations, notably overflow checking.
- Their arguments include information about the symbol the
- relocation is against and a <<reloc_howto_type>> argument
- which describes the relocation to perform. These functions
- are defined in <<reloc.c>>.
-
- The a.out function which handles reading, relocating, and
- writing section contents is <<aout_link_input_section>>. The
- actual relocation is done in <<aout_link_input_section_std>>
- and <<aout_link_input_section_ext>>.
-
-INODE
-Writing the symbol table, , Relocating the section contents, Performing the Final Link
-SUBSUBSECTION
- Writing the symbol table
-
- The <<_bfd_final_link>> function must gather all the symbols
- in the input files and write them out. It must also write out
- all the symbols in the global hash table. This must be
- controlled by the <<strip>> and <<discard>> fields of the
- <<bfd_link_info>> structure.
-
- The local symbols of the input files will not have been
- entered into the linker hash table. The <<_bfd_final_link>>
- routine must consider each input file and include the symbols
- in the output file. It may be convenient to do this when
- looking through the <<link_order>> structures, or it may be
- done by stepping through the <<input_bfds>> list.
-
- The <<_bfd_final_link>> routine must also traverse the global
- hash table to gather all the externally visible symbols. It
- is possible that most of the externally visible symbols may be
- written out when considering the symbols of each input file,
- but it is still necessary to traverse the hash table since the
- linker script may have defined some symbols that are not in
- any of the input files.
-
- The <<strip>> field of the <<bfd_link_info>> structure
- controls which symbols are written out. The possible values
- are listed in <<bfdlink.h>>. If the value is <<strip_some>>,
- then the <<keep_hash>> field of the <<bfd_link_info>>
- structure is a hash table of symbols to keep; each symbol
- should be looked up in this hash table, and only symbols which
- are present should be included in the output file.
-
- If the <<strip>> field of the <<bfd_link_info>> structure
- permits local symbols to be written out, the <<discard>> field
- is used to further controls which local symbols are included
- in the output file. If the value is <<discard_l>>, then all
- local symbols which begin with a certain prefix are discarded;
- this prefix is described by the <<lprefix>> and
- <<lprefix_len>> fields of the <<bfd_link_info>> structure.
-
- The a.out backend handles symbols by calling
- <<aout_link_write_symbols>> on each input BFD and then
- traversing the global hash table with the function
- <<aout_link_write_other_symbol>>. It builds a string table
- while writing out the symbols, which is written to the output
- file at the end of <<NAME(aout,final_link)>>.
-*/
-
-static struct bfd_hash_entry *generic_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-static boolean generic_link_read_symbols
- PARAMS ((bfd *));
-static boolean generic_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
-static boolean generic_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean collect));
-static boolean generic_link_check_archive_element_no_collect
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean generic_link_check_archive_element_collect
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
-static boolean generic_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded, boolean collect));
-static boolean generic_link_add_symbol_list
- PARAMS ((bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **,
- boolean collect));
-static bfd *hash_entry_bfd PARAMS ((struct bfd_link_hash_entry *));
-static void set_symbol_from_hash
- PARAMS ((asymbol *, struct bfd_link_hash_entry *));
-static boolean generic_add_output_symbol
- PARAMS ((bfd *, size_t *psymalloc, asymbol *));
-static boolean default_fill_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-static boolean default_indirect_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *, boolean));
-
-/* The link hash table structure is defined in bfdlink.h. It provides
- a base hash table which the backend specific hash tables are built
- upon. */
-
-/* Routine to create an entry in the link hash table. */
-
-struct bfd_hash_entry *
-_bfd_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct bfd_link_hash_entry *ret = (struct bfd_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct bfd_link_hash_entry *) NULL)
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)));
- if (ret == (struct bfd_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->type = bfd_link_hash_new;
- ret->next = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize a link hash table. The BFD argument is the one
- responsible for creating this table. */
-
-boolean
-_bfd_link_hash_table_init (table, abfd, newfunc)
- struct bfd_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- table->creator = abfd->xvec;
- table->undefs = NULL;
- table->undefs_tail = NULL;
- return bfd_hash_table_init (&table->table, newfunc);
-}
-
-/* Look up a symbol in a link hash table. If follow is true, we
- follow bfd_link_hash_indirect and bfd_link_hash_warning links to
- the real symbol. */
-
-struct bfd_link_hash_entry *
-bfd_link_hash_lookup (table, string, create, copy, follow)
- struct bfd_link_hash_table *table;
- const char *string;
- boolean create;
- boolean copy;
- boolean follow;
-{
- struct bfd_link_hash_entry *ret;
-
- ret = ((struct bfd_link_hash_entry *)
- bfd_hash_lookup (&table->table, string, create, copy));
-
- if (follow && ret != (struct bfd_link_hash_entry *) NULL)
- {
- while (ret->type == bfd_link_hash_indirect
- || ret->type == bfd_link_hash_warning)
- ret = ret->u.i.link;
- }
-
- return ret;
-}
-
-/* Look up a symbol in the main linker hash table if the symbol might
- be wrapped. This should only be used for references to an
- undefined symbol, not for definitions of a symbol. */
-
-struct bfd_link_hash_entry *
-bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow)
- bfd *abfd;
- struct bfd_link_info *info;
- const char *string;
- boolean create;
- boolean copy;
- boolean follow;
-{
- if (info->wrap_hash != NULL)
- {
- const char *l;
-
- l = string;
- if (*l == bfd_get_symbol_leading_char (abfd))
- ++l;
-
-#undef WRAP
-#define WRAP "__wrap_"
-
- if (bfd_hash_lookup (info->wrap_hash, l, false, false) != NULL)
- {
- char *n;
- struct bfd_link_hash_entry *h;
-
- /* This symbol is being wrapped. We want to replace all
- references to SYM with references to __wrap_SYM. */
-
- n = (char *) bfd_malloc (strlen (l) + sizeof WRAP + 1);
- if (n == NULL)
- return NULL;
-
- /* Note that symbol_leading_char may be '\0'. */
- n[0] = bfd_get_symbol_leading_char (abfd);
- n[1] = '\0';
- strcat (n, WRAP);
- strcat (n, l);
- h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
- free (n);
- return h;
- }
-
-#undef WRAP
-
-#undef REAL
-#define REAL "__real_"
-
- if (*l == '_'
- && strncmp (l, REAL, sizeof REAL - 1) == 0
- && bfd_hash_lookup (info->wrap_hash, l + sizeof REAL - 1,
- false, false) != NULL)
- {
- char *n;
- struct bfd_link_hash_entry *h;
-
- /* This is a reference to __real_SYM, where SYM is being
- wrapped. We want to replace all references to __real_SYM
- with references to SYM. */
-
- n = (char *) bfd_malloc (strlen (l + sizeof REAL - 1) + 2);
- if (n == NULL)
- return NULL;
-
- /* Note that symbol_leading_char may be '\0'. */
- n[0] = bfd_get_symbol_leading_char (abfd);
- n[1] = '\0';
- strcat (n, l + sizeof REAL - 1);
- h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
- free (n);
- return h;
- }
-
-#undef REAL
- }
-
- return bfd_link_hash_lookup (info->hash, string, create, copy, follow);
-}
-
-/* Traverse a generic link hash table. The only reason this is not a
- macro is to do better type checking. This code presumes that an
- argument passed as a struct bfd_hash_entry * may be caught as a
- struct bfd_link_hash_entry * with no explicit cast required on the
- call. */
-
-void
-bfd_link_hash_traverse (table, func, info)
- struct bfd_link_hash_table *table;
- boolean (*func) PARAMS ((struct bfd_link_hash_entry *, PTR));
- PTR info;
-{
- bfd_hash_traverse (&table->table,
- ((boolean (*) PARAMS ((struct bfd_hash_entry *, PTR)))
- func),
- info);
-}
-
-/* Add a symbol to the linker hash table undefs list. */
-
-INLINE void
-bfd_link_add_undef (table, h)
- struct bfd_link_hash_table *table;
- struct bfd_link_hash_entry *h;
-{
- BFD_ASSERT (h->next == NULL);
- if (table->undefs_tail != (struct bfd_link_hash_entry *) NULL)
- table->undefs_tail->next = h;
- if (table->undefs == (struct bfd_link_hash_entry *) NULL)
- table->undefs = h;
- table->undefs_tail = h;
-}
-
-/* Routine to create an entry in an generic link hash table. */
-
-static struct bfd_hash_entry *
-generic_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct generic_link_hash_entry *ret =
- (struct generic_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct generic_link_hash_entry *) NULL)
- ret = ((struct generic_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry)));
- if (ret == (struct generic_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct generic_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
-
- if (ret)
- {
- /* Set local fields. */
- ret->written = false;
- ret->sym = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create an generic link hash table. */
-
-struct bfd_link_hash_table *
-_bfd_generic_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct generic_link_hash_table *ret;
-
- ret = ((struct generic_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
- if (ret == NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! _bfd_link_hash_table_init (&ret->root, abfd,
- generic_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Grab the symbols for an object file when doing a generic link. We
- store the symbols in the outsymbols field. We need to keep them
- around for the entire link to ensure that we only read them once.
- If we read them multiple times, we might wind up with relocs and
- the hash table pointing to different instances of the symbol
- structure. */
-
-static boolean
-generic_link_read_symbols (abfd)
- bfd *abfd;
-{
- if (abfd->outsymbols == (asymbol **) NULL)
- {
- long symsize;
- long symcount;
-
- symsize = bfd_get_symtab_upper_bound (abfd);
- if (symsize < 0)
- return false;
- abfd->outsymbols = (asymbol **) bfd_alloc (abfd, symsize);
- if (abfd->outsymbols == NULL && symsize != 0)
- return false;
- symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols);
- if (symcount < 0)
- return false;
- abfd->symcount = symcount;
- }
-
- return true;
-}
-
-/* Generic function to add symbols to from an object file to the
- global hash table. This version does not automatically collect
- constructors by name. */
-
-boolean
-_bfd_generic_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return generic_link_add_symbols (abfd, info, false);
-}
-
-/* Generic function to add symbols from an object file to the global
- hash table. This version automatically collects constructors by
- name, as the collect2 program does. It should be used for any
- target which does not provide some other mechanism for setting up
- constructors and destructors; these are approximately those targets
- for which gcc uses collect2 and do not support stabs. */
-
-boolean
-_bfd_generic_link_add_symbols_collect (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- return generic_link_add_symbols (abfd, info, true);
-}
-
-/* Add symbols from an object file to the global hash table. */
-
-static boolean
-generic_link_add_symbols (abfd, info, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean collect;
-{
- boolean ret;
-
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- ret = generic_link_add_object_symbols (abfd, info, collect);
- break;
- case bfd_archive:
- ret = (_bfd_generic_link_add_archive_symbols
- (abfd, info,
- (collect
- ? generic_link_check_archive_element_collect
- : generic_link_check_archive_element_no_collect)));
- break;
- default:
- bfd_set_error (bfd_error_wrong_format);
- ret = false;
- }
-
- return ret;
-}
-
-/* Add symbols from an object file to the global hash table. */
-
-static boolean
-generic_link_add_object_symbols (abfd, info, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean collect;
-{
- if (! generic_link_read_symbols (abfd))
- return false;
- return generic_link_add_symbol_list (abfd, info,
- _bfd_generic_link_get_symcount (abfd),
- _bfd_generic_link_get_symbols (abfd),
- collect);
-}
-
-/* We build a hash table of all symbols defined in an archive. */
-
-/* An archive symbol may be defined by multiple archive elements.
- This linked list is used to hold the elements. */
-
-struct archive_list
-{
- struct archive_list *next;
- int indx;
-};
-
-/* An entry in an archive hash table. */
-
-struct archive_hash_entry
-{
- struct bfd_hash_entry root;
- /* Where the symbol is defined. */
- struct archive_list *defs;
-};
-
-/* An archive hash table itself. */
-
-struct archive_hash_table
-{
- struct bfd_hash_table table;
-};
-
-static struct bfd_hash_entry *archive_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static boolean archive_hash_table_init
- PARAMS ((struct archive_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Create a new entry for an archive hash table. */
-
-static struct bfd_hash_entry *
-archive_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct archive_hash_entry *ret = (struct archive_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct archive_hash_entry *) NULL)
- ret = ((struct archive_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct archive_hash_entry)));
- if (ret == (struct archive_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct archive_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->defs = (struct archive_list *) NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize an archive hash table. */
-
-static boolean
-archive_hash_table_init (table, newfunc)
- struct archive_hash_table *table;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return bfd_hash_table_init (&table->table, newfunc);
-}
-
-/* Look up an entry in an archive hash table. */
-
-#define archive_hash_lookup(t, string, create, copy) \
- ((struct archive_hash_entry *) \
- bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-
-/* Allocate space in an archive hash table. */
-
-#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size))
-
-/* Free an archive hash table. */
-
-#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
-
-/* Generic function to add symbols from an archive file to the global
- hash file. This function presumes that the archive symbol table
- has already been read in (this is normally done by the
- bfd_check_format entry point). It looks through the undefined and
- common symbols and searches the archive symbol table for them. If
- it finds an entry, it includes the associated object file in the
- link.
-
- The old linker looked through the archive symbol table for
- undefined symbols. We do it the other way around, looking through
- undefined symbols for symbols defined in the archive. The
- advantage of the newer scheme is that we only have to look through
- the list of undefined symbols once, whereas the old method had to
- re-search the symbol table each time a new object file was added.
-
- The CHECKFN argument is used to see if an object file should be
- included. CHECKFN should set *PNEEDED to true if the object file
- should be included, and must also call the bfd_link_info
- add_archive_element callback function and handle adding the symbols
- to the global hash table. CHECKFN should only return false if some
- sort of error occurs.
-
- For some formats, such as a.out, it is possible to look through an
- object file but not actually include it in the link. The
- archive_pass field in a BFD is used to avoid checking the symbols
- of an object files too many times. When an object is included in
- the link, archive_pass is set to -1. If an object is scanned but
- not included, archive_pass is set to the pass number. The pass
- number is incremented each time a new object file is included. The
- pass number is used because when a new object file is included it
- may create new undefined symbols which cause a previously examined
- object file to be included. */
-
-boolean
-_bfd_generic_link_add_archive_symbols (abfd, info, checkfn)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean (*checkfn) PARAMS ((bfd *, struct bfd_link_info *,
- boolean *pneeded));
-{
- carsym *arsyms;
- carsym *arsym_end;
- register carsym *arsym;
- int pass;
- struct archive_hash_table arsym_hash;
- int indx;
- struct bfd_link_hash_entry **pundef;
-
- if (! bfd_has_map (abfd))
- {
- /* An empty archive is a special case. */
- if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
- return true;
- bfd_set_error (bfd_error_no_armap);
- return false;
- }
-
- arsyms = bfd_ardata (abfd)->symdefs;
- arsym_end = arsyms + bfd_ardata (abfd)->symdef_count;
-
- /* In order to quickly determine whether an symbol is defined in
- this archive, we build a hash table of the symbols. */
- if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc))
- return false;
- for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
- {
- struct archive_hash_entry *arh;
- struct archive_list *l, **pp;
-
- arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);
- if (arh == (struct archive_hash_entry *) NULL)
- goto error_return;
- l = ((struct archive_list *)
- archive_hash_allocate (&arsym_hash, sizeof (struct archive_list)));
- if (l == NULL)
- goto error_return;
- l->indx = indx;
- for (pp = &arh->defs;
- *pp != (struct archive_list *) NULL;
- pp = &(*pp)->next)
- ;
- *pp = l;
- l->next = NULL;
- }
-
- /* The archive_pass field in the archive itself is used to
- initialize PASS, sine we may search the same archive multiple
- times. */
- pass = abfd->archive_pass + 1;
-
- /* New undefined symbols are added to the end of the list, so we
- only need to look through it once. */
- pundef = &info->hash->undefs;
- while (*pundef != (struct bfd_link_hash_entry *) NULL)
- {
- struct bfd_link_hash_entry *h;
- struct archive_hash_entry *arh;
- struct archive_list *l;
-
- h = *pundef;
-
- /* When a symbol is defined, it is not necessarily removed from
- the list. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- {
- /* Remove this entry from the list, for general cleanliness
- and because we are going to look through the list again
- if we search any more libraries. We can't remove the
- entry if it is the tail, because that would lose any
- entries we add to the list later on (it would also cause
- us to lose track of whether the symbol has been
- referenced). */
- if (*pundef != info->hash->undefs_tail)
- *pundef = (*pundef)->next;
- else
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look for this symbol in the archive symbol map. */
- arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);
- if (arh == (struct archive_hash_entry *) NULL)
- {
- pundef = &(*pundef)->next;
- continue;
- }
-
- /* Look at all the objects which define this symbol. */
- for (l = arh->defs; l != (struct archive_list *) NULL; l = l->next)
- {
- bfd *element;
- boolean needed;
-
- /* If the symbol has gotten defined along the way, quit. */
- if (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common)
- break;
-
- element = bfd_get_elt_at_index (abfd, l->indx);
- if (element == (bfd *) NULL)
- goto error_return;
-
- /* If we've already included this element, or if we've
- already checked it on this pass, continue. */
- if (element->archive_pass == -1
- || element->archive_pass == pass)
- continue;
-
- /* If we can't figure this element out, just ignore it. */
- if (! bfd_check_format (element, bfd_object))
- {
- element->archive_pass = -1;
- continue;
- }
-
- /* CHECKFN will see if this element should be included, and
- go ahead and include it if appropriate. */
- if (! (*checkfn) (element, info, &needed))
- goto error_return;
-
- if (! needed)
- element->archive_pass = pass;
- else
- {
- element->archive_pass = -1;
-
- /* Increment the pass count to show that we may need to
- recheck object files which were already checked. */
- ++pass;
- }
- }
-
- pundef = &(*pundef)->next;
- }
-
- archive_hash_table_free (&arsym_hash);
-
- /* Save PASS in case we are called again. */
- abfd->archive_pass = pass;
-
- return true;
-
- error_return:
- archive_hash_table_free (&arsym_hash);
- return false;
-}
-
-/* See if we should include an archive element. This version is used
- when we do not want to automatically collect constructors based on
- the symbol name, presumably because we have some other mechanism
- for finding them. */
-
-static boolean
-generic_link_check_archive_element_no_collect (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- return generic_link_check_archive_element (abfd, info, pneeded, false);
-}
-
-/* See if we should include an archive element. This version is used
- when we want to automatically collect constructors based on the
- symbol name, as collect2 does. */
-
-static boolean
-generic_link_check_archive_element_collect (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- return generic_link_check_archive_element (abfd, info, pneeded, true);
-}
-
-/* See if we should include an archive element. Optionally collect
- constructors. */
-
-static boolean
-generic_link_check_archive_element (abfd, info, pneeded, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
- boolean collect;
-{
- asymbol **pp, **ppend;
-
- *pneeded = false;
-
- if (! generic_link_read_symbols (abfd))
- return false;
-
- pp = _bfd_generic_link_get_symbols (abfd);
- ppend = pp + _bfd_generic_link_get_symcount (abfd);
- for (; pp < ppend; pp++)
- {
- asymbol *p;
- struct bfd_link_hash_entry *h;
-
- p = *pp;
-
- /* We are only interested in globally visible symbols. */
- if (! bfd_is_com_section (p->section)
- && (p->flags & (BSF_GLOBAL | BSF_INDIRECT | BSF_WEAK)) == 0)
- continue;
-
- /* We are only interested if we know something about this
- symbol, and it is undefined or common. An undefined weak
- symbol (type bfd_link_hash_undefweak) is not considered to be
- a reference when pulling files out of an archive. See the
- SVR4 ABI, p. 4-27. */
- h = bfd_link_hash_lookup (info->hash, bfd_asymbol_name (p), false,
- false, true);
- if (h == (struct bfd_link_hash_entry *) NULL
- || (h->type != bfd_link_hash_undefined
- && h->type != bfd_link_hash_common))
- continue;
-
- /* P is a symbol we are looking for. */
-
- if (! bfd_is_com_section (p->section))
- {
- bfd_size_type symcount;
- asymbol **symbols;
-
- /* This object file defines this symbol, so pull it in. */
- if (! (*info->callbacks->add_archive_element) (info, abfd,
- bfd_asymbol_name (p)))
- return false;
- symcount = _bfd_generic_link_get_symcount (abfd);
- symbols = _bfd_generic_link_get_symbols (abfd);
- if (! generic_link_add_symbol_list (abfd, info, symcount,
- symbols, collect))
- return false;
- *pneeded = true;
- return true;
- }
-
- /* P is a common symbol. */
-
- if (h->type == bfd_link_hash_undefined)
- {
- bfd *symbfd;
- bfd_vma size;
- unsigned int power;
-
- symbfd = h->u.undef.abfd;
- if (symbfd == (bfd *) NULL)
- {
- /* This symbol was created as undefined from outside
- BFD. We assume that we should link in the object
- file. This is for the -u option in the linker. */
- if (! (*info->callbacks->add_archive_element)
- (info, abfd, bfd_asymbol_name (p)))
- return false;
- *pneeded = true;
- return true;
- }
-
- /* Turn the symbol into a common symbol but do not link in
- the object file. This is how a.out works. Object
- formats that require different semantics must implement
- this function differently. This symbol is already on the
- undefs list. We add the section to a common section
- attached to symbfd to ensure that it is in a BFD which
- will be linked in. */
- h->type = bfd_link_hash_common;
- h->u.c.p =
- ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- size = bfd_asymbol_value (p);
- h->u.c.size = size;
-
- power = bfd_log2 (size);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
-
- if (p->section == bfd_com_section_ptr)
- h->u.c.p->section = bfd_make_section_old_way (symbfd, "COMMON");
- else
- h->u.c.p->section = bfd_make_section_old_way (symbfd,
- p->section->name);
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else
- {
- /* Adjust the size of the common symbol if necessary. This
- is how a.out works. Object formats that require
- different semantics must implement this function
- differently. */
- if (bfd_asymbol_value (p) > h->u.c.size)
- h->u.c.size = bfd_asymbol_value (p);
- }
- }
-
- /* This archive element is not needed. */
- return true;
-}
-
-/* Add the symbols from an object file to the global hash table. ABFD
- is the object file. INFO is the linker information. SYMBOL_COUNT
- is the number of symbols. SYMBOLS is the list of symbols. COLLECT
- is true if constructors should be automatically collected by name
- as is done by collect2. */
-
-static boolean
-generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
- bfd *abfd;
- struct bfd_link_info *info;
- bfd_size_type symbol_count;
- asymbol **symbols;
- boolean collect;
-{
- asymbol **pp, **ppend;
-
- pp = symbols;
- ppend = symbols + symbol_count;
- for (; pp < ppend; pp++)
- {
- asymbol *p;
-
- p = *pp;
-
- if ((p->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (p))
- || bfd_is_com_section (bfd_get_section (p))
- || bfd_is_ind_section (bfd_get_section (p)))
- {
- const char *name;
- const char *string;
- struct generic_link_hash_entry *h;
-
- name = bfd_asymbol_name (p);
- if (((p->flags & BSF_INDIRECT) != 0
- || bfd_is_ind_section (p->section))
- && pp + 1 < ppend)
- {
- pp++;
- string = bfd_asymbol_name (*pp);
- }
- else if ((p->flags & BSF_WARNING) != 0
- && pp + 1 < ppend)
- {
- /* The name of P is actually the warning string, and the
- next symbol is the one to warn about. */
- string = name;
- pp++;
- name = bfd_asymbol_name (*pp);
- }
- else
- string = NULL;
-
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name, p->flags, bfd_get_section (p),
- p->value, string, false, collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
-
- /* If this is a constructor symbol, and the linker didn't do
- anything with it, then we want to just pass the symbol
- through to the output file. This will happen when
- linking with -r. */
- if ((p->flags & BSF_CONSTRUCTOR) != 0
- && (h == NULL || h->root.type == bfd_link_hash_new))
- {
- p->udata.p = NULL;
- continue;
- }
-
- /* Save the BFD symbol so that we don't lose any backend
- specific information that may be attached to it. We only
- want this one if it gives more information than the
- existing one; we don't want to replace a defined symbol
- with an undefined one. This routine may be called with a
- hash table other than the generic hash table, so we only
- do this if we are certain that the hash table is a
- generic one. */
- if (info->hash->creator == abfd->xvec)
- {
- if (h->sym == (asymbol *) NULL
- || (! bfd_is_und_section (bfd_get_section (p))
- && (! bfd_is_com_section (bfd_get_section (p))
- || bfd_is_und_section (bfd_get_section (h->sym)))))
- {
- h->sym = p;
- /* BSF_OLD_COMMON is a hack to support COFF reloc
- reading, and it should go away when the COFF
- linker is switched to the new version. */
- if (bfd_is_com_section (bfd_get_section (p)))
- p->flags |= BSF_OLD_COMMON;
- }
-
- /* Store a back pointer from the symbol to the hash
- table entry for the benefit of relaxation code until
- it gets rewritten to not use asymbol structures.
- Setting this is also used to check whether these
- symbols were set up by the generic linker. */
- p->udata.p = (PTR) h;
- }
- }
- }
-
- return true;
-}
-
-/* We use a state table to deal with adding symbols from an object
- file. The first index into the state table describes the symbol
- from the object file. The second index into the state table is the
- type of the symbol in the hash table. */
-
-/* The symbol from the object file is turned into one of these row
- values. */
-
-enum link_row
-{
- UNDEF_ROW, /* Undefined. */
- UNDEFW_ROW, /* Weak undefined. */
- DEF_ROW, /* Defined. */
- DEFW_ROW, /* Weak defined. */
- COMMON_ROW, /* Common. */
- INDR_ROW, /* Indirect. */
- WARN_ROW, /* Warning. */
- SET_ROW /* Member of set. */
-};
-
-/* apparently needed for Hitachi 3050R(HI-UX/WE2)? */
-#undef FAIL
-
-/* The actions to take in the state table. */
-
-enum link_action
-{
- FAIL, /* Abort. */
- UND, /* Mark symbol undefined. */
- WEAK, /* Mark symbol weak undefined. */
- DEF, /* Mark symbol defined. */
- DEFW, /* Mark symbol weak defined. */
- COM, /* Mark symbol common. */
- REF, /* Mark defined symbol referenced. */
- CREF, /* Possibly warn about common reference to defined symbol. */
- CDEF, /* Define existing common symbol. */
- NOACT, /* No action. */
- BIG, /* Mark symbol common using largest size. */
- MDEF, /* Multiple definition error. */
- MIND, /* Multiple indirect symbols. */
- IND, /* Make indirect symbol. */
- CIND, /* Make indirect symbol from existing common symbol. */
- SET, /* Add value to set. */
- MWARN, /* Make warning symbol. */
- WARN, /* Issue warning. */
- CWARN, /* Warn if referenced, else MWARN. */
- CYCLE, /* Repeat with symbol pointed to. */
- REFC, /* Mark indirect symbol referenced and then CYCLE. */
- WARNC /* Issue warning and then CYCLE. */
-};
-
-/* The state table itself. The first index is a link_row and the
- second index is a bfd_link_hash_type. */
-
-static const enum link_action link_action[8][8] =
-{
- /* current\prev new undef undefw def defw com indr warn */
- /* UNDEF_ROW */ {UND, NOACT, UND, REF, REF, NOACT, REFC, WARNC },
- /* UNDEFW_ROW */ {WEAK, NOACT, NOACT, REF, REF, NOACT, REFC, WARNC },
- /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE },
- /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE },
- /* COMMON_ROW */ {COM, COM, COM, CREF, CREF, BIG, CREF, WARNC },
- /* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE },
- /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, CYCLE },
- /* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE }
-};
-
-/* Most of the entries in the LINK_ACTION table are straightforward,
- but a few are somewhat subtle.
-
- A reference to an indirect symbol (UNDEF_ROW/indr or
- UNDEFW_ROW/indr) is counted as a reference both to the indirect
- symbol and to the symbol the indirect symbol points to.
-
- A reference to a warning symbol (UNDEF_ROW/warn or UNDEFW_ROW/warn)
- causes the warning to be issued.
-
- A common definition of an indirect symbol (COMMON_ROW/indr) is
- treated as a multiple definition error. Likewise for an indirect
- definition of a common symbol (INDR_ROW/com).
-
- An indirect definition of a warning (INDR_ROW/warn) does not cause
- the warning to be issued.
-
- If a warning is created for an indirect symbol (WARN_ROW/indr) no
- warning is created for the symbol the indirect symbol points to.
-
- Adding an entry to a set does not count as a reference to a set,
- and no warning is issued (SET_ROW/warn). */
-
-/* Return the BFD in which a hash entry has been defined, if known. */
-
-static bfd *
-hash_entry_bfd (h)
- struct bfd_link_hash_entry *h;
-{
- while (h->type == bfd_link_hash_warning)
- h = h->u.i.link;
- switch (h->type)
- {
- default:
- return NULL;
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- return h->u.undef.abfd;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- return h->u.def.section->owner;
- case bfd_link_hash_common:
- return h->u.c.p->section->owner;
- }
- /*NOTREACHED*/
-}
-
-/* Add a symbol to the global hash table.
- ABFD is the BFD the symbol comes from.
- NAME is the name of the symbol.
- FLAGS is the BSF_* bits associated with the symbol.
- SECTION is the section in which the symbol is defined; this may be
- bfd_und_section_ptr or bfd_com_section_ptr.
- VALUE is the value of the symbol, relative to the section.
- STRING is used for either an indirect symbol, in which case it is
- the name of the symbol to indirect to, or a warning symbol, in
- which case it is the warning string.
- COPY is true if NAME or STRING must be copied into locally
- allocated memory if they need to be saved.
- COLLECT is true if we should automatically collect gcc constructor
- or destructor names as collect2 does.
- HASHP, if not NULL, is a place to store the created hash table
- entry; if *HASHP is not NULL, the caller has already looked up
- the hash table entry, and stored it in *HASHP. */
-
-boolean
-_bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
- string, copy, collect, hashp)
- struct bfd_link_info *info;
- bfd *abfd;
- const char *name;
- flagword flags;
- asection *section;
- bfd_vma value;
- const char *string;
- boolean copy;
- boolean collect;
- struct bfd_link_hash_entry **hashp;
-{
- enum link_row row;
- struct bfd_link_hash_entry *h;
- boolean cycle;
-
- if (bfd_is_ind_section (section)
- || (flags & BSF_INDIRECT) != 0)
- row = INDR_ROW;
- else if ((flags & BSF_WARNING) != 0)
- row = WARN_ROW;
- else if ((flags & BSF_CONSTRUCTOR) != 0)
- row = SET_ROW;
- else if (bfd_is_und_section (section))
- {
- if ((flags & BSF_WEAK) != 0)
- row = UNDEFW_ROW;
- else
- row = UNDEF_ROW;
- }
- else if ((flags & BSF_WEAK) != 0)
- row = DEFW_ROW;
- else if (bfd_is_com_section (section))
- row = COMMON_ROW;
- else
- row = DEF_ROW;
-
- if (hashp != NULL && *hashp != NULL)
- h = *hashp;
- else
- {
- if (row == UNDEF_ROW || row == UNDEFW_ROW)
- h = bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false);
- else
- h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
- if (h == NULL)
- {
- if (hashp != NULL)
- *hashp = NULL;
- return false;
- }
- }
-
- if (info->notice_hash != (struct bfd_hash_table *) NULL
- && (bfd_hash_lookup (info->notice_hash, name, false, false)
- != (struct bfd_hash_entry *) NULL))
- {
- if (! (*info->callbacks->notice) (info, name, abfd, section, value))
- return false;
- }
-
- if (hashp != (struct bfd_link_hash_entry **) NULL)
- *hashp = h;
-
- do
- {
- enum link_action action;
-
- cycle = false;
- action = link_action[(int) row][(int) h->type];
- switch (action)
- {
- case FAIL:
- abort ();
-
- case NOACT:
- /* Do nothing. */
- break;
-
- case UND:
- /* Make a new undefined symbol. */
- h->type = bfd_link_hash_undefined;
- h->u.undef.abfd = abfd;
- bfd_link_add_undef (info->hash, h);
- break;
-
- case WEAK:
- /* Make a new weak undefined symbol. */
- h->type = bfd_link_hash_undefweak;
- h->u.undef.abfd = abfd;
- break;
-
- case CDEF:
- /* We have found a definition for a symbol which was
- previously common. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_defined, (bfd_vma) 0)))
- return false;
- /* Fall through. */
- case DEF:
- case DEFW:
- {
- enum bfd_link_hash_type oldtype;
-
- /* Define a symbol. */
- oldtype = h->type;
- if (action == DEFW)
- h->type = bfd_link_hash_defweak;
- else
- h->type = bfd_link_hash_defined;
- h->u.def.section = section;
- h->u.def.value = value;
-
- /* If we have been asked to, we act like collect2 and
- identify all functions that might be global
- constructors and destructors and pass them up in a
- callback. We only do this for certain object file
- types, since many object file types can handle this
- automatically. */
- if (collect && name[0] == '_')
- {
- const char *s;
-
- /* A constructor or destructor name starts like this:
- _+GLOBAL_[_.$][ID][_.$] where the first [_.$] and
- the second are the same character (we accept any
- character there, in case a new object file format
- comes along with even worse naming restrictions). */
-
-#define CONS_PREFIX "GLOBAL_"
-#define CONS_PREFIX_LEN (sizeof CONS_PREFIX - 1)
-
- s = name + 1;
- while (*s == '_')
- ++s;
- if (s[0] == 'G'
- && strncmp (s, CONS_PREFIX, CONS_PREFIX_LEN - 1) == 0)
- {
- char c;
-
- c = s[CONS_PREFIX_LEN + 1];
- if ((c == 'I' || c == 'D')
- && s[CONS_PREFIX_LEN] == s[CONS_PREFIX_LEN + 2])
- {
- /* If this is a definition of a symbol which
- was previously weakly defined, we are in
- trouble. We have already added a
- constructor entry for the weak defined
- symbol, and now we are trying to add one
- for the new symbol. Fortunately, this case
- should never arise in practice. */
- if (oldtype == bfd_link_hash_defweak)
- abort ();
-
- if (! ((*info->callbacks->constructor)
- (info,
- c == 'I' ? true : false,
- name, abfd, section, value)))
- return false;
- }
- }
- }
- }
-
- break;
-
- case COM:
- /* We have found a common definition for a symbol. */
- if (h->type == bfd_link_hash_new)
- bfd_link_add_undef (info->hash, h);
- h->type = bfd_link_hash_common;
- h->u.c.p =
- ((struct bfd_link_hash_common_entry *)
- bfd_hash_allocate (&info->hash->table,
- sizeof (struct bfd_link_hash_common_entry)));
- if (h->u.c.p == NULL)
- return false;
-
- h->u.c.size = value;
-
- /* Select a default alignment based on the size. This may
- be overridden by the caller. */
- {
- unsigned int power;
-
- power = bfd_log2 (value);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
- }
-
- /* The section of a common symbol is only used if the common
- symbol is actually allocated. It basically provides a
- hook for the linker script to decide which output section
- the common symbols should be put in. In most cases, the
- section of a common symbol will be bfd_com_section_ptr,
- the code here will choose a common symbol section named
- "COMMON", and the linker script will contain *(COMMON) in
- the appropriate place. A few targets use separate common
- sections for small symbols, and they require special
- handling. */
- if (section == bfd_com_section_ptr)
- {
- h->u.c.p->section = bfd_make_section_old_way (abfd, "COMMON");
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else if (section->owner != abfd)
- {
- h->u.c.p->section = bfd_make_section_old_way (abfd,
- section->name);
- h->u.c.p->section->flags = SEC_ALLOC;
- }
- else
- h->u.c.p->section = section;
- break;
-
- case REF:
- /* A reference to a defined symbol. */
- if (h->next == NULL && info->hash->undefs_tail != h)
- h->next = h;
- break;
-
- case BIG:
- /* We have found a common definition for a symbol which
- already had a common definition. Use the maximum of the
- two sizes. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_common, value)))
- return false;
- if (value > h->u.c.size)
- {
- unsigned int power;
-
- h->u.c.size = value;
-
- /* Select a default alignment based on the size. This may
- be overridden by the caller. */
- power = bfd_log2 (value);
- if (power > 4)
- power = 4;
- h->u.c.p->alignment_power = power;
- }
- break;
-
- case CREF:
- {
- bfd *obfd;
-
- /* We have found a common definition for a symbol which
- was already defined. FIXME: It would nice if we could
- report the BFD which defined an indirect symbol, but we
- don't have anywhere to store the information. */
- if (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak)
- obfd = h->u.def.section->owner;
- else
- obfd = NULL;
- if (! ((*info->callbacks->multiple_common)
- (info, name, obfd, h->type, (bfd_vma) 0,
- abfd, bfd_link_hash_common, value)))
- return false;
- }
- break;
-
- case MIND:
- /* Multiple indirect symbols. This is OK if they both point
- to the same symbol. */
- if (strcmp (h->u.i.link->root.string, string) == 0)
- break;
- /* Fall through. */
- case MDEF:
- /* Handle a multiple definition. */
- {
- asection *msec;
- bfd_vma mval;
-
- switch (h->type)
- {
- case bfd_link_hash_defined:
- msec = h->u.def.section;
- mval = h->u.def.value;
- break;
- case bfd_link_hash_indirect:
- msec = bfd_ind_section_ptr;
- mval = 0;
- break;
- default:
- abort ();
- }
-
- /* Ignore a redefinition of an absolute symbol to the same
- value; it's harmless. */
- if (h->type == bfd_link_hash_defined
- && bfd_is_abs_section (msec)
- && bfd_is_abs_section (section)
- && value == mval)
- break;
-
- if (! ((*info->callbacks->multiple_definition)
- (info, name, msec->owner, msec, mval, abfd, section,
- value)))
- return false;
- }
- break;
-
- case CIND:
- /* Create an indirect symbol from an existing common symbol. */
- BFD_ASSERT (h->type == bfd_link_hash_common);
- if (! ((*info->callbacks->multiple_common)
- (info, name,
- h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
- abfd, bfd_link_hash_indirect, (bfd_vma) 0)))
- return false;
- /* Fall through. */
- case IND:
- /* Create an indirect symbol. */
- {
- struct bfd_link_hash_entry *inh;
-
- /* STRING is the name of the symbol we want to indirect
- to. */
- inh = bfd_wrapped_link_hash_lookup (abfd, info, string, true,
- copy, false);
- if (inh == (struct bfd_link_hash_entry *) NULL)
- return false;
- if (inh->type == bfd_link_hash_new)
- {
- inh->type = bfd_link_hash_undefined;
- inh->u.undef.abfd = abfd;
- bfd_link_add_undef (info->hash, inh);
- }
-
- /* If the indirect symbol has been referenced, we need to
- push the reference down to the symbol we are
- referencing. */
- if (h->type != bfd_link_hash_new)
- {
- row = UNDEF_ROW;
- cycle = true;
- }
-
- h->type = bfd_link_hash_indirect;
- h->u.i.link = inh;
- }
- break;
-
- case SET:
- /* Add an entry to a set. */
- if (! (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR,
- abfd, section, value))
- return false;
- break;
-
- case WARNC:
- /* Issue a warning and cycle. */
- if (h->u.i.warning != NULL)
- {
- if (! (*info->callbacks->warning) (info, h->u.i.warning, name,
- abfd, (asection *) NULL,
- (bfd_vma) 0))
- return false;
- /* Only issue a warning once. */
- h->u.i.warning = NULL;
- }
- /* Fall through. */
- case CYCLE:
- /* Try again with the referenced symbol. */
- h = h->u.i.link;
- cycle = true;
- break;
-
- case REFC:
- /* A reference to an indirect symbol. */
- if (h->next == NULL && info->hash->undefs_tail != h)
- h->next = h;
- h = h->u.i.link;
- cycle = true;
- break;
-
- case WARN:
- /* Issue a warning. */
- if (! (*info->callbacks->warning) (info, string, name,
- hash_entry_bfd (h),
- (asection *) NULL, (bfd_vma) 0))
- return false;
- break;
-
- case CWARN:
- /* Warn if this symbol has been referenced already,
- otherwise add a warning. A symbol has been referenced if
- the next field is not NULL, or it is the tail of the
- undefined symbol list. The REF case above helps to
- ensure this. */
- if (h->next != NULL || info->hash->undefs_tail == h)
- {
- if (! (*info->callbacks->warning) (info, string, name,
- hash_entry_bfd (h),
- (asection *) NULL,
- (bfd_vma) 0))
- return false;
- break;
- }
- /* Fall through. */
- case MWARN:
- /* Make a warning symbol. */
- {
- struct bfd_link_hash_entry *sub;
-
- /* STRING is the warning to give. */
- sub = ((struct bfd_link_hash_entry *)
- ((*info->hash->table.newfunc)
- ((struct bfd_hash_entry *) NULL, &info->hash->table,
- h->root.string)));
- if (sub == NULL)
- return false;
- *sub = *h;
- sub->type = bfd_link_hash_warning;
- sub->u.i.link = h;
- if (! copy)
- sub->u.i.warning = string;
- else
- {
- char *w;
-
- w = bfd_hash_allocate (&info->hash->table,
- strlen (string) + 1);
- if (w == NULL)
- return false;
- strcpy (w, string);
- sub->u.i.warning = w;
- }
-
- bfd_hash_replace (&info->hash->table,
- (struct bfd_hash_entry *) h,
- (struct bfd_hash_entry *) sub);
- if (hashp != NULL)
- *hashp = sub;
- }
- break;
- }
- }
- while (cycle);
-
- return true;
-}
-
-/* Generic final link routine. */
-
-boolean
-_bfd_generic_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd *sub;
- asection *o;
- struct bfd_link_order *p;
- size_t outsymalloc;
- struct generic_write_global_symbol_info wginfo;
-
- abfd->outsymbols = (asymbol **) NULL;
- abfd->symcount = 0;
- outsymalloc = 0;
-
- /* Build the output symbol table. */
- for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
- if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
- return false;
-
- /* Accumulate the global symbols. */
- wginfo.info = info;
- wginfo.output_bfd = abfd;
- wginfo.psymalloc = &outsymalloc;
- _bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
- _bfd_generic_link_write_global_symbol,
- (PTR) &wginfo);
-
- if (info->relocateable)
- {
- /* Allocate space for the output relocs for each section. */
- for (o = abfd->sections;
- o != (asection *) NULL;
- o = o->next)
- {
- o->reloc_count = 0;
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- ++o->reloc_count;
- else if (p->type == bfd_indirect_link_order)
- {
- asection *input_section;
- bfd *input_bfd;
- long relsize;
- arelent **relocs;
- asymbol **symbols;
- long reloc_count;
-
- input_section = p->u.indirect.section;
- input_bfd = input_section->owner;
- relsize = bfd_get_reloc_upper_bound (input_bfd,
- input_section);
- if (relsize < 0)
- return false;
- relocs = (arelent **) bfd_malloc ((size_t) relsize);
- if (!relocs && relsize != 0)
- return false;
- symbols = _bfd_generic_link_get_symbols (input_bfd);
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- relocs,
- symbols);
- if (reloc_count < 0)
- return false;
- BFD_ASSERT ((unsigned long) reloc_count
- == input_section->reloc_count);
- o->reloc_count += reloc_count;
- free (relocs);
- }
- }
- if (o->reloc_count > 0)
- {
- o->orelocation = ((arelent **)
- bfd_alloc (abfd,
- (o->reloc_count
- * sizeof (arelent *))));
- if (!o->orelocation)
- return false;
- o->flags |= SEC_RELOC;
- /* Reset the count so that it can be used as an index
- when putting in the output relocs. */
- o->reloc_count = 0;
- }
- }
- }
-
- /* Handle all the link order information for the sections. */
- for (o = abfd->sections;
- o != (asection *) NULL;
- o = o->next)
- {
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- switch (p->type)
- {
- case bfd_section_reloc_link_order:
- case bfd_symbol_reloc_link_order:
- if (! _bfd_generic_reloc_link_order (abfd, info, o, p))
- return false;
- break;
- case bfd_indirect_link_order:
- if (! default_indirect_link_order (abfd, info, o, p, true))
- return false;
- break;
- default:
- if (! _bfd_default_link_order (abfd, info, o, p))
- return false;
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Add an output symbol to the output BFD. */
-
-static boolean
-generic_add_output_symbol (output_bfd, psymalloc, sym)
- bfd *output_bfd;
- size_t *psymalloc;
- asymbol *sym;
-{
- if (output_bfd->symcount >= *psymalloc)
- {
- asymbol **newsyms;
-
- if (*psymalloc == 0)
- *psymalloc = 124;
- else
- *psymalloc *= 2;
- newsyms = (asymbol **) bfd_realloc (output_bfd->outsymbols,
- *psymalloc * sizeof (asymbol *));
- if (newsyms == (asymbol **) NULL)
- return false;
- output_bfd->outsymbols = newsyms;
- }
-
- output_bfd->outsymbols[output_bfd->symcount] = sym;
- ++output_bfd->symcount;
-
- return true;
-}
-
-/* Handle the symbols for an input BFD. */
-
-boolean
-_bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
- bfd *output_bfd;
- bfd *input_bfd;
- struct bfd_link_info *info;
- size_t *psymalloc;
-{
- asymbol **sym_ptr;
- asymbol **sym_end;
-
- if (! generic_link_read_symbols (input_bfd))
- return false;
-
- /* Create a filename symbol if we are supposed to. */
- if (info->create_object_symbols_section != (asection *) NULL)
- {
- asection *sec;
-
- for (sec = input_bfd->sections;
- sec != (asection *) NULL;
- sec = sec->next)
- {
- if (sec->output_section == info->create_object_symbols_section)
- {
- asymbol *newsym;
-
- newsym = bfd_make_empty_symbol (input_bfd);
- if (!newsym)
- return false;
- newsym->name = input_bfd->filename;
- newsym->value = 0;
- newsym->flags = BSF_LOCAL | BSF_FILE;
- newsym->section = sec;
-
- if (! generic_add_output_symbol (output_bfd, psymalloc,
- newsym))
- return false;
-
- break;
- }
- }
- }
-
- /* Adjust the values of the globally visible symbols, and write out
- local symbols. */
- sym_ptr = _bfd_generic_link_get_symbols (input_bfd);
- sym_end = sym_ptr + _bfd_generic_link_get_symcount (input_bfd);
- for (; sym_ptr < sym_end; sym_ptr++)
- {
- asymbol *sym;
- struct generic_link_hash_entry *h;
- boolean output;
-
- h = (struct generic_link_hash_entry *) NULL;
- sym = *sym_ptr;
- if ((sym->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym))
- || bfd_is_ind_section (bfd_get_section (sym)))
- {
- if (sym->udata.p != NULL)
- h = (struct generic_link_hash_entry *) sym->udata.p;
- else if ((sym->flags & BSF_CONSTRUCTOR) != 0)
- {
- /* This case normally means that the main linker code
- deliberately ignored this constructor symbol. We
- should just pass it through. This will screw up if
- the constructor symbol is from a different,
- non-generic, object file format, but the case will
- only arise when linking with -r, which will probably
- fail anyhow, since there will be no way to represent
- the relocs in the output format being used. */
- h = NULL;
- }
- else if (bfd_is_und_section (bfd_get_section (sym)))
- h = ((struct generic_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info,
- bfd_asymbol_name (sym),
- false, false, true));
- else
- h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info),
- bfd_asymbol_name (sym),
- false, false, true);
-
- if (h != (struct generic_link_hash_entry *) NULL)
- {
- /* Force all references to this symbol to point to
- the same area in memory. It is possible that
- this routine will be called with a hash table
- other than a generic hash table, so we double
- check that. */
- if (info->hash->creator == input_bfd->xvec)
- {
- if (h->sym != (asymbol *) NULL)
- *sym_ptr = sym = h->sym;
- }
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- case bfd_link_hash_undefined:
- break;
- case bfd_link_hash_undefweak:
- sym->flags |= BSF_WEAK;
- break;
- case bfd_link_hash_indirect:
- h = (struct generic_link_hash_entry *) h->root.u.i.link;
- /* fall through */
- case bfd_link_hash_defined:
- sym->flags |= BSF_GLOBAL;
- sym->flags &=~ BSF_CONSTRUCTOR;
- sym->value = h->root.u.def.value;
- sym->section = h->root.u.def.section;
- break;
- case bfd_link_hash_defweak:
- sym->flags |= BSF_WEAK;
- sym->flags &=~ BSF_CONSTRUCTOR;
- sym->value = h->root.u.def.value;
- sym->section = h->root.u.def.section;
- break;
- case bfd_link_hash_common:
- sym->value = h->root.u.c.size;
- sym->flags |= BSF_GLOBAL;
- if (! bfd_is_com_section (sym->section))
- {
- BFD_ASSERT (bfd_is_und_section (sym->section));
- sym->section = bfd_com_section_ptr;
- }
- /* We do not set the section of the symbol to
- h->root.u.c.p->section. That value was saved so
- that we would know where to allocate the symbol
- if it was defined. In this case the type is
- still bfd_link_hash_common, so we did not define
- it, so we do not want to use that section. */
- break;
- }
- }
- }
-
- /* This switch is straight from the old code in
- write_file_locals in ldsym.c. */
- if (info->strip == strip_some
- && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
- false, false)
- == (struct bfd_hash_entry *) NULL))
- output = false;
- else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
- {
- /* If this symbol is marked as occurring now, rather
- than at the end, output it now. This is used for
- COFF C_EXT FCN symbols. FIXME: There must be a
- better way. */
- if (bfd_asymbol_bfd (sym) == input_bfd
- && (sym->flags & BSF_NOT_AT_END) != 0)
- output = true;
- else
- output = false;
- }
- else if (bfd_is_ind_section (sym->section))
- output = false;
- else if ((sym->flags & BSF_DEBUGGING) != 0)
- {
- if (info->strip == strip_none)
- output = true;
- else
- output = false;
- }
- else if (bfd_is_und_section (sym->section)
- || bfd_is_com_section (sym->section))
- output = false;
- else if ((sym->flags & BSF_LOCAL) != 0)
- {
- if ((sym->flags & BSF_WARNING) != 0)
- output = false;
- else
- {
- switch (info->discard)
- {
- default:
- case discard_all:
- output = false;
- break;
- case discard_l:
- if (bfd_asymbol_name (sym)[0] == info->lprefix[0]
- && (info->lprefix_len == 1
- || strncmp (bfd_asymbol_name (sym), info->lprefix,
- info->lprefix_len) == 0))
- output = false;
- else
- output = true;
- break;
- case discard_none:
- output = true;
- break;
- }
- }
- }
- else if ((sym->flags & BSF_CONSTRUCTOR))
- {
- if (info->strip != strip_all)
- output = true;
- else
- output = false;
- }
- else
- abort ();
-
- if (output)
- {
- if (! generic_add_output_symbol (output_bfd, psymalloc, sym))
- return false;
- if (h != (struct generic_link_hash_entry *) NULL)
- h->written = true;
- }
- }
-
- return true;
-}
-
-/* Set the section and value of a generic BFD symbol based on a linker
- hash table entry. */
-
-static void
-set_symbol_from_hash (sym, h)
- asymbol *sym;
- struct bfd_link_hash_entry *h;
-{
- switch (h->type)
- {
- default:
- abort ();
- break;
- case bfd_link_hash_new:
- /* This can happen when a constructor symbol is seen but we are
- not building constructors. */
- if (sym->section != NULL)
- {
- BFD_ASSERT ((sym->flags & BSF_CONSTRUCTOR) != 0);
- }
- else
- {
- sym->flags |= BSF_CONSTRUCTOR;
- sym->section = bfd_abs_section_ptr;
- sym->value = 0;
- }
- break;
- case bfd_link_hash_undefined:
- sym->section = bfd_und_section_ptr;
- sym->value = 0;
- break;
- case bfd_link_hash_undefweak:
- sym->section = bfd_und_section_ptr;
- sym->value = 0;
- sym->flags |= BSF_WEAK;
- break;
- case bfd_link_hash_defined:
- sym->section = h->u.def.section;
- sym->value = h->u.def.value;
- break;
- case bfd_link_hash_defweak:
- sym->flags |= BSF_WEAK;
- sym->section = h->u.def.section;
- sym->value = h->u.def.value;
- break;
- case bfd_link_hash_common:
- sym->value = h->u.c.size;
- if (sym->section == NULL)
- sym->section = bfd_com_section_ptr;
- else if (! bfd_is_com_section (sym->section))
- {
- BFD_ASSERT (bfd_is_und_section (sym->section));
- sym->section = bfd_com_section_ptr;
- }
- /* Do not set the section; see _bfd_generic_link_output_symbols. */
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: What should we do here? */
- break;
- }
-}
-
-/* Write out a global symbol, if it hasn't already been written out.
- This is called for each symbol in the hash table. */
-
-boolean
-_bfd_generic_link_write_global_symbol (h, data)
- struct generic_link_hash_entry *h;
- PTR data;
-{
- struct generic_write_global_symbol_info *wginfo =
- (struct generic_write_global_symbol_info *) data;
- asymbol *sym;
-
- if (h->written)
- return true;
-
- h->written = true;
-
- if (wginfo->info->strip == strip_all
- || (wginfo->info->strip == strip_some
- && bfd_hash_lookup (wginfo->info->keep_hash, h->root.root.string,
- false, false) == NULL))
- return true;
-
- if (h->sym != (asymbol *) NULL)
- sym = h->sym;
- else
- {
- sym = bfd_make_empty_symbol (wginfo->output_bfd);
- if (!sym)
- return false;
- sym->name = h->root.root.string;
- sym->flags = 0;
- }
-
- set_symbol_from_hash (sym, &h->root);
-
- sym->flags |= BSF_GLOBAL;
-
- if (! generic_add_output_symbol (wginfo->output_bfd, wginfo->psymalloc,
- sym))
- {
- /* FIXME: No way to return failure. */
- abort ();
- }
-
- return true;
-}
-
-/* Create a relocation. */
-
-boolean
-_bfd_generic_reloc_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- arelent *r;
-
- if (! info->relocateable)
- abort ();
- if (sec->orelocation == (arelent **) NULL)
- abort ();
-
- r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
- if (r == (arelent *) NULL)
- return false;
-
- r->address = link_order->offset;
- r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc);
- if (r->howto == 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Get the symbol to use for the relocation. */
- if (link_order->type == bfd_section_reloc_link_order)
- r->sym_ptr_ptr = link_order->u.reloc.p->u.section->symbol_ptr_ptr;
- else
- {
- struct generic_link_hash_entry *h;
-
- h = ((struct generic_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (abfd, info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h == (struct generic_link_hash_entry *) NULL
- || ! h->written)
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, link_order->u.reloc.p->u.name,
- (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
- return false;
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- r->sym_ptr_ptr = &h->sym;
- }
-
- /* If this is an inplace reloc, write the addend to the object file.
- Otherwise, store it in the reloc addend. */
- if (! r->howto->partial_inplace)
- r->addend = link_order->u.reloc.p->addend;
- else
- {
- bfd_size_type size;
- bfd_reloc_status_type rstat;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (r->howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- rstat = _bfd_relocate_contents (r->howto, abfd,
- link_order->u.reloc.p->addend, buf);
- switch (rstat)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*info->callbacks->reloc_overflow)
- (info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (abfd, link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- r->howto->name, link_order->u.reloc.p->addend,
- (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (abfd, sec, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
-
- r->addend = 0;
- }
-
- sec->orelocation[sec->reloc_count] = r;
- ++sec->reloc_count;
-
- return true;
-}
-
-/* Allocate a new link_order for a section. */
-
-struct bfd_link_order *
-bfd_new_link_order (abfd, section)
- bfd *abfd;
- asection *section;
-{
- struct bfd_link_order *new;
-
- new = ((struct bfd_link_order *)
- bfd_alloc_by_size_t (abfd, sizeof (struct bfd_link_order)));
- if (!new)
- return NULL;
-
- new->type = bfd_undefined_link_order;
- new->offset = 0;
- new->size = 0;
- new->next = (struct bfd_link_order *) NULL;
-
- if (section->link_order_tail != (struct bfd_link_order *) NULL)
- section->link_order_tail->next = new;
- else
- section->link_order_head = new;
- section->link_order_tail = new;
-
- return new;
-}
-
-/* Default link order processing routine. Note that we can not handle
- the reloc_link_order types here, since they depend upon the details
- of how the particular backends generates relocs. */
-
-boolean
-_bfd_default_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- switch (link_order->type)
- {
- case bfd_undefined_link_order:
- case bfd_section_reloc_link_order:
- case bfd_symbol_reloc_link_order:
- default:
- abort ();
- case bfd_indirect_link_order:
- return default_indirect_link_order (abfd, info, sec, link_order,
- false);
- case bfd_fill_link_order:
- return default_fill_link_order (abfd, info, sec, link_order);
- case bfd_data_link_order:
- return bfd_set_section_contents (abfd, sec,
- (PTR) link_order->u.data.contents,
- (file_ptr) link_order->offset,
- link_order->size);
- }
-}
-
-/* Default routine to handle a bfd_fill_link_order. */
-
-/*ARGSUSED*/
-static boolean
-default_fill_link_order (abfd, info, sec, link_order)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- struct bfd_link_order *link_order;
-{
- size_t size;
- char *space;
- size_t i;
- int fill;
- boolean result;
-
- BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
-
- size = (size_t) link_order->size;
- space = (char *) bfd_malloc (size);
- if (space == NULL && size != 0)
- return false;
-
- fill = link_order->u.fill.value;
- for (i = 0; i < size; i += 2)
- space[i] = fill >> 8;
- for (i = 1; i < size; i += 2)
- space[i] = fill;
- result = bfd_set_section_contents (abfd, sec, space,
- (file_ptr) link_order->offset,
- link_order->size);
- free (space);
- return result;
-}
-
-/* Default routine to handle a bfd_indirect_link_order. */
-
-static boolean
-default_indirect_link_order (output_bfd, info, output_section, link_order,
- generic_linker)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection *output_section;
- struct bfd_link_order *link_order;
- boolean generic_linker;
-{
- asection *input_section;
- bfd *input_bfd;
- bfd_byte *contents = NULL;
- bfd_byte *new_contents;
-
- BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
-
- if (link_order->size == 0)
- return true;
-
- input_section = link_order->u.indirect.section;
- input_bfd = input_section->owner;
-
- BFD_ASSERT (input_section->output_section == output_section);
- BFD_ASSERT (input_section->output_offset == link_order->offset);
- BFD_ASSERT (input_section->_cooked_size == link_order->size);
-
- if (info->relocateable
- && input_section->reloc_count > 0
- && output_section->orelocation == (arelent **) NULL)
- {
- /* Space has not been allocated for the output relocations.
- This can happen when we are called by a specific backend
- because somebody is attempting to link together different
- types of object files. Handling this case correctly is
- difficult, and sometimes impossible. */
- abort ();
- }
-
- if (! generic_linker)
- {
- asymbol **sympp;
- asymbol **symppend;
-
- /* Get the canonical symbols. The generic linker will always
- have retrieved them by this point, but we are being called by
- a specific linker, presumably because we are linking
- different types of object files together. */
- if (! generic_link_read_symbols (input_bfd))
- return false;
-
- /* Since we have been called by a specific linker, rather than
- the generic linker, the values of the symbols will not be
- right. They will be the values as seen in the input file,
- not the values of the final link. We need to fix them up
- before we can relocate the section. */
- sympp = _bfd_generic_link_get_symbols (input_bfd);
- symppend = sympp + _bfd_generic_link_get_symcount (input_bfd);
- for (; sympp < symppend; sympp++)
- {
- asymbol *sym;
- struct bfd_link_hash_entry *h;
-
- sym = *sympp;
-
- if ((sym->flags & (BSF_INDIRECT
- | BSF_WARNING
- | BSF_GLOBAL
- | BSF_CONSTRUCTOR
- | BSF_WEAK)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym))
- || bfd_is_ind_section (bfd_get_section (sym)))
- {
- /* sym->udata may have been set by
- generic_link_add_symbol_list. */
- if (sym->udata.p != NULL)
- h = (struct bfd_link_hash_entry *) sym->udata.p;
- else if (bfd_is_und_section (bfd_get_section (sym)))
- h = bfd_wrapped_link_hash_lookup (output_bfd, info,
- bfd_asymbol_name (sym),
- false, false, true);
- else
- h = bfd_link_hash_lookup (info->hash,
- bfd_asymbol_name (sym),
- false, false, true);
- if (h != NULL)
- set_symbol_from_hash (sym, h);
- }
- }
- }
-
- /* Get and relocate the section contents. */
- contents = ((bfd_byte *)
- bfd_malloc (bfd_section_size (input_bfd, input_section)));
- if (contents == NULL && bfd_section_size (input_bfd, input_section) != 0)
- goto error_return;
- new_contents = (bfd_get_relocated_section_contents
- (output_bfd, info, link_order, contents, info->relocateable,
- _bfd_generic_link_get_symbols (input_bfd)));
- if (!new_contents)
- goto error_return;
-
- /* Output the section contents. */
- if (! bfd_set_section_contents (output_bfd, output_section,
- (PTR) new_contents,
- link_order->offset, link_order->size))
- goto error_return;
-
- if (contents != NULL)
- free (contents);
- return true;
-
- error_return:
- if (contents != NULL)
- free (contents);
- return false;
-}
-
-/* A little routine to count the number of relocs in a link_order
- list. */
-
-unsigned int
-_bfd_count_link_order_relocs (link_order)
- struct bfd_link_order *link_order;
-{
- register unsigned int c;
- register struct bfd_link_order *l;
-
- c = 0;
- for (l = link_order; l != (struct bfd_link_order *) NULL; l = l->next)
- {
- if (l->type == bfd_section_reloc_link_order
- || l->type == bfd_symbol_reloc_link_order)
- ++c;
- }
-
- return c;
-}
-
-/*
-FUNCTION
- bfd_link_split_section
-
-SYNOPSIS
- boolean bfd_link_split_section(bfd *abfd, asection *sec);
-
-DESCRIPTION
- Return nonzero if @var{sec} should be split during a
- reloceatable or final link.
-
-.#define bfd_link_split_section(abfd, sec) \
-. BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
-.
-
-*/
-
-
-
-boolean
-_bfd_generic_link_split_section (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- return false;
-}
diff --git a/contrib/gdb/bfd/opncls.c b/contrib/gdb/bfd/opncls.c
deleted file mode 100644
index 54528db..0000000
--- a/contrib/gdb/bfd/opncls.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/* opncls.c -- open and close a BFD.
- Copyright (C) 1990 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-#ifndef S_IXUSR
-#define S_IXUSR 0100 /* Execute by owner. */
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0010 /* Execute by group. */
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0001 /* Execute by others. */
-#endif
-
-/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
- if we do that we can't use fcntl. */
-
-
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-
-#ifndef HAVE_GETPAGESIZE
-#define getpagesize() 2048
-#endif
-
-long _bfd_chunksize = -1;
-
-/* Return a new BFD. All BFD's are allocated through this routine. */
-
-bfd *
-_bfd_new_bfd ()
-{
- bfd *nbfd;
-
- nbfd = (bfd *)bfd_zmalloc (sizeof (bfd));
- if (!nbfd)
- return 0;
-
- if (_bfd_chunksize <= 0)
- {
- _bfd_chunksize = getpagesize ();
- if (_bfd_chunksize <= 0)
- _bfd_chunksize = 2048;
- /* Leave some slush space, since many malloc implementations
- prepend a header, and may wind up wasting another page
- because of it. */
- _bfd_chunksize -= 32;
- }
-
- if (!obstack_begin(&nbfd->memory, _bfd_chunksize))
- {
- bfd_set_error (bfd_error_no_memory);
- return 0;
- }
-
- nbfd->arch_info = &bfd_default_arch_struct;
-
- nbfd->direction = no_direction;
- nbfd->iostream = NULL;
- nbfd->where = 0;
- nbfd->sections = (asection *)NULL;
- nbfd->format = bfd_unknown;
- nbfd->my_archive = (bfd *)NULL;
- nbfd->origin = 0;
- nbfd->opened_once = false;
- nbfd->output_has_begun = false;
- nbfd->section_count = 0;
- nbfd->usrdata = (PTR)NULL;
- nbfd->cacheable = false;
- nbfd->flags = NO_FLAGS;
- nbfd->mtime_set = false;
-
- return nbfd;
-}
-
-/* Allocate a new BFD as a member of archive OBFD. */
-
-bfd *
-_bfd_new_bfd_contained_in (obfd)
- bfd *obfd;
-{
- bfd *nbfd;
-
- nbfd = _bfd_new_bfd();
- nbfd->xvec = obfd->xvec;
- nbfd->my_archive = obfd;
- nbfd->direction = read_direction;
- nbfd->target_defaulted = obfd->target_defaulted;
- return nbfd;
-}
-
-/*
-SECTION
- Opening and closing BFDs
-
-*/
-
-/*
-FUNCTION
- bfd_openr
-
-SYNOPSIS
- bfd *bfd_openr(CONST char *filename, CONST char *target);
-
-DESCRIPTION
- Open the file @var{filename} (using <<fopen>>) with the target
- @var{target}. Return a pointer to the created BFD.
-
- Calls <<bfd_find_target>>, so @var{target} is interpreted as by
- that function.
-
- If <<NULL>> is returned then an error has occured. Possible errors
- are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or <<system_call>> error.
-*/
-
-bfd *
-bfd_openr (filename, target)
- CONST char *filename;
- CONST char *target;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- nbfd = _bfd_new_bfd();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-
- nbfd->filename = filename;
- nbfd->direction = read_direction;
-
- if (bfd_open_file (nbfd) == NULL) {
- bfd_set_error (bfd_error_system_call); /* File didn't exist, or some such */
- bfd_release(nbfd,0);
- return NULL;
- }
- return nbfd;
-}
-
-
-/* Don't try to `optimize' this function:
-
- o - We lock using stack space so that interrupting the locking
- won't cause a storage leak.
- o - We open the file stream last, since we don't want to have to
- close it if anything goes wrong. Closing the stream means closing
- the file descriptor too, even though we didn't open it.
- */
-/*
-FUNCTION
- bfd_fdopenr
-
-SYNOPSIS
- bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
-
-DESCRIPTION
- <<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to <<fopen>>.
- It opens a BFD on a file already described by the @var{fd}
- supplied.
-
- When the file is later <<bfd_close>>d, the file descriptor will be closed.
-
- If the caller desires that this file descriptor be cached by BFD
- (opened as needed, closed as needed to free descriptors for
- other opens), with the supplied @var{fd} used as an initial
- file descriptor (but subject to closure at any time), call
- bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to
- assume no cacheing; the file descriptor will remain open until
- <<bfd_close>>, and will not be affected by BFD operations on other
- files.
-
- Possible errors are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
-*/
-
-bfd *
-bfd_fdopenr (filename, target, fd)
- CONST char *filename;
- CONST char *target;
- int fd;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
- int fdflags;
-
- bfd_set_error (bfd_error_system_call);
-#if ! defined(HAVE_FCNTL) || ! defined(F_GETFL)
- fdflags = O_RDWR; /* Assume full access */
-#else
- fdflags = fcntl (fd, F_GETFL, NULL);
-#endif
- if (fdflags == -1) return NULL;
-
- nbfd = _bfd_new_bfd();
-
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-#if defined(VMS) || defined(__GO32__) || defined (WINGDB)
- nbfd->iostream = (PTR)fopen(filename, FOPEN_RB);
-#else
- /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
- switch (fdflags & (O_ACCMODE)) {
- case O_RDONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RB); break;
- case O_WRONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
- case O_RDWR: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RUB); break;
- default: abort ();
- }
-#endif
- if (nbfd->iostream == NULL) {
- (void) obstack_free (&nbfd->memory, (PTR)0);
- return NULL;
- }
-
- /* OK, put everything where it belongs */
-
- nbfd->filename = filename;
-
- /* As a special case we allow a FD open for read/write to
- be written through, although doing so requires that we end
- the previous clause with a preposition. */
- /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
- switch (fdflags & (O_ACCMODE)) {
- case O_RDONLY: nbfd->direction = read_direction; break;
- case O_WRONLY: nbfd->direction = write_direction; break;
- case O_RDWR: nbfd->direction = both_direction; break;
- default: abort ();
- }
-
- if (! bfd_cache_init (nbfd))
- return NULL;
-
- return nbfd;
-}
-
-/*
-FUNCTION
- bfd_openstreamr
-
-SYNOPSIS
- bfd *bfd_openstreamr();
-
-DESCRIPTION
-
- Open a BFD for read access on an existing stdio stream. When
- the BFD is passed to <<bfd_close>>, the stream will be closed.
-*/
-
-bfd *
-bfd_openstreamr (filename, target, stream)
- const char *filename;
- const char *target;
- FILE *stream;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- nbfd = _bfd_new_bfd ();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL)
- {
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
- }
-
- nbfd->iostream = (PTR) stream;
- nbfd->filename = filename;
- nbfd->direction = read_direction;
-
- if (! bfd_cache_init (nbfd))
- return NULL;
-
- return nbfd;
-}
-
-/** bfd_openw -- open for writing.
- Returns a pointer to a freshly-allocated BFD on success, or NULL.
-
- See comment by bfd_fdopenr before you try to modify this function. */
-
-/*
-FUNCTION
- bfd_openw
-
-SYNOPSIS
- bfd *bfd_openw(CONST char *filename, CONST char *target);
-
-DESCRIPTION
- Create a BFD, associated with file @var{filename}, using the
- file format @var{target}, and return a pointer to it.
-
- Possible errors are <<bfd_error_system_call>>, <<bfd_error_no_memory>>,
- <<bfd_error_invalid_target>>.
-*/
-
-bfd *
-bfd_openw (filename, target)
- CONST char *filename;
- CONST char *target;
-{
- bfd *nbfd;
- const bfd_target *target_vec;
-
- bfd_set_error (bfd_error_system_call);
-
- /* nbfd has to point to head of malloc'ed block so that bfd_close may
- reclaim it correctly. */
-
- nbfd = _bfd_new_bfd();
- if (nbfd == NULL)
- return NULL;
-
- target_vec = bfd_find_target (target, nbfd);
- if (target_vec == NULL) return NULL;
-
- nbfd->filename = filename;
- nbfd->direction = write_direction;
-
- if (bfd_open_file (nbfd) == NULL) {
- bfd_set_error (bfd_error_system_call); /* File not writeable, etc */
- (void) obstack_free (&nbfd->memory, (PTR)0);
- return NULL;
- }
- return nbfd;
-}
-
-/*
-
-FUNCTION
- bfd_close
-
-SYNOPSIS
- boolean bfd_close(bfd *abfd);
-
-DESCRIPTION
-
- Close a BFD. If the BFD was open for writing,
- then pending operations are completed and the file written out
- and closed. If the created file is executable, then
- <<chmod>> is called to mark it as such.
-
- All memory attached to the BFD's obstacks is released.
-
- The file descriptor associated with the BFD is closed (even
- if it was passed in to BFD by <<bfd_fdopenr>>).
-
-RETURNS
- <<true>> is returned if all is ok, otherwise <<false>>.
-*/
-
-
-boolean
-bfd_close (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- if (!bfd_read_p (abfd))
- {
- if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
- return false;
- }
-
- if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
- return false;
-
- ret = bfd_cache_close (abfd);
-
- /* If the file was open for writing and is now executable,
- make it so */
- if (ret
- && abfd->direction == write_direction
- && abfd->flags & EXEC_P)
- {
- struct stat buf;
-
- if (stat (abfd->filename, &buf) == 0)
- {
- int mask = umask (0);
- umask (mask);
- chmod (abfd->filename,
- (0777
- & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
- }
- }
-
- (void) obstack_free (&abfd->memory, (PTR)0);
- (void) free (abfd);
-
- return ret;
-}
-
-/*
-FUNCTION
- bfd_close_all_done
-
-SYNOPSIS
- boolean bfd_close_all_done(bfd *);
-
-DESCRIPTION
- Close a BFD. Differs from <<bfd_close>>
- since it does not complete any pending operations. This
- routine would be used if the application had just used BFD for
- swapping and didn't want to use any of the writing code.
-
- If the created file is executable, then <<chmod>> is called
- to mark it as such.
-
- All memory attached to the BFD's obstacks is released.
-
-RETURNS
- <<true>> is returned if all is ok, otherwise <<false>>.
-
-*/
-
-boolean
-bfd_close_all_done (abfd)
- bfd *abfd;
-{
- boolean ret;
-
- ret = bfd_cache_close (abfd);
-
- /* If the file was open for writing and is now executable,
- make it so */
- if (ret
- && abfd->direction == write_direction
- && abfd->flags & EXEC_P)
- {
- struct stat buf;
-
- if (stat (abfd->filename, &buf) == 0)
- {
- int mask = umask (0);
- umask (mask);
- chmod (abfd->filename,
- (0x777
- & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
- }
- }
- (void) obstack_free (&abfd->memory, (PTR)0);
- (void) free(abfd);
- return ret;
-}
-
-
-/*
-FUNCTION
- bfd_alloc_size
-
-SYNOPSIS
- bfd_size_type bfd_alloc_size(bfd *abfd);
-
-DESCRIPTION
- Return the number of bytes in the obstacks connected to @var{abfd}.
-
-*/
-
-bfd_size_type
-bfd_alloc_size (abfd)
- bfd *abfd;
-{
- struct _obstack_chunk *chunk = abfd->memory.chunk;
- size_t size = 0;
- while (chunk) {
- size += chunk->limit - &(chunk->contents[0]);
- chunk = chunk->prev;
- }
- return size;
-}
-
-
-
-/*
-FUNCTION
- bfd_create
-
-SYNOPSIS
- bfd *bfd_create(CONST char *filename, bfd *templ);
-
-DESCRIPTION
- Create a new BFD in the manner of
- <<bfd_openw>>, but without opening a file. The new BFD
- takes the target from the target used by @var{template}. The
- format is always set to <<bfd_object>>.
-
-*/
-
-bfd *
-bfd_create (filename, templ)
- CONST char *filename;
- bfd *templ;
-{
- bfd *nbfd = _bfd_new_bfd();
- if (nbfd == (bfd *)NULL)
- return (bfd *)NULL;
- nbfd->filename = filename;
- if(templ) {
- nbfd->xvec = templ->xvec;
- }
- nbfd->direction = no_direction;
- bfd_set_format(nbfd, bfd_object);
- return nbfd;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_alloc_by_size_t
-
-SYNOPSIS
- PTR bfd_alloc_by_size_t(bfd *abfd, size_t wanted);
-
-DESCRIPTION
- Allocate a block of @var{wanted} bytes of memory in the obstack
- attatched to <<abfd>> and return a pointer to it.
-*/
-
-
-PTR
-bfd_alloc_by_size_t (abfd, size)
- bfd *abfd;
- size_t size;
-{
- PTR ret;
-
- ret = obstack_alloc (&(abfd->memory), size);
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-void
-bfd_alloc_grow (abfd, ptr, size)
- bfd *abfd;
- PTR ptr;
- size_t size;
-{
- (void) obstack_grow(&(abfd->memory), ptr, size);
-}
-
-PTR
-bfd_alloc_finish (abfd)
- bfd *abfd;
-{
- PTR ret;
-
- ret = obstack_finish (&(abfd->memory));
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
- return ret;
-}
-
-PTR
-bfd_alloc (abfd, size)
- bfd *abfd;
- size_t size;
-{
- return bfd_alloc_by_size_t(abfd, (size_t)size);
-}
-
-PTR
-bfd_zalloc (abfd, size)
- bfd *abfd;
- size_t size;
-{
- PTR res;
- res = bfd_alloc(abfd, size);
- if (res)
- memset(res, 0, (size_t)size);
- return res;
-}
diff --git a/contrib/gdb/bfd/reloc.c b/contrib/gdb/bfd/reloc.c
deleted file mode 100644
index 46ed5c2..0000000
--- a/contrib/gdb/bfd/reloc.c
+++ /dev/null
@@ -1,2391 +0,0 @@
-/* BFD support for handling relocation entries.
- Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- Relocations
-
- BFD maintains relocations in much the same way it maintains
- symbols: they are left alone until required, then read in
- en-mass and translated into an internal form. A common
- routine <<bfd_perform_relocation>> acts upon the
- canonical form to do the fixup.
-
- Relocations are maintained on a per section basis,
- while symbols are maintained on a per BFD basis.
-
- All that a back end has to do to fit the BFD interface is to create
- a <<struct reloc_cache_entry>> for each relocation
- in a particular section, and fill in the right bits of the structures.
-
-@menu
-@* typedef arelent::
-@* howto manager::
-@end menu
-
-*/
-
-/* DO compile in the reloc_code name table from libbfd.h. */
-#define _BFD_MAKE_TABLE_bfd_reloc_code_real
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-/*
-DOCDD
-INODE
- typedef arelent, howto manager, Relocations, Relocations
-
-SUBSECTION
- typedef arelent
-
- This is the structure of a relocation entry:
-
-CODE_FRAGMENT
-.
-.typedef enum bfd_reloc_status
-.{
-. {* No errors detected *}
-. bfd_reloc_ok,
-.
-. {* The relocation was performed, but there was an overflow. *}
-. bfd_reloc_overflow,
-.
-. {* The address to relocate was not within the section supplied. *}
-. bfd_reloc_outofrange,
-.
-. {* Used by special functions *}
-. bfd_reloc_continue,
-.
-. {* Unsupported relocation size requested. *}
-. bfd_reloc_notsupported,
-.
-. {* Unused *}
-. bfd_reloc_other,
-.
-. {* The symbol to relocate against was undefined. *}
-. bfd_reloc_undefined,
-.
-. {* The relocation was performed, but may not be ok - presently
-. generated only when linking i960 coff files with i960 b.out
-. symbols. If this type is returned, the error_message argument
-. to bfd_perform_relocation will be set. *}
-. bfd_reloc_dangerous
-. }
-. bfd_reloc_status_type;
-.
-.
-.typedef struct reloc_cache_entry
-.{
-. {* A pointer into the canonical table of pointers *}
-. struct symbol_cache_entry **sym_ptr_ptr;
-.
-. {* offset in section *}
-. bfd_size_type address;
-.
-. {* addend for relocation value *}
-. bfd_vma addend;
-.
-. {* Pointer to how to perform the required relocation *}
-. reloc_howto_type *howto;
-.
-.} arelent;
-
-*/
-
-/*
-DESCRIPTION
-
- Here is a description of each of the fields within an <<arelent>>:
-
- o <<sym_ptr_ptr>>
-
- The symbol table pointer points to a pointer to the symbol
- associated with the relocation request. It is
- the pointer into the table returned by the back end's
- <<get_symtab>> action. @xref{Symbols}. The symbol is referenced
- through a pointer to a pointer so that tools like the linker
- can fix up all the symbols of the same name by modifying only
- one pointer. The relocation routine looks in the symbol and
- uses the base of the section the symbol is attached to and the
- value of the symbol as the initial relocation offset. If the
- symbol pointer is zero, then the section provided is looked up.
-
- o <<address>>
-
- The <<address>> field gives the offset in bytes from the base of
- the section data which owns the relocation record to the first
- byte of relocatable information. The actual data relocated
- will be relative to this point; for example, a relocation
- type which modifies the bottom two bytes of a four byte word
- would not touch the first byte pointed to in a big endian
- world.
-
- o <<addend>>
-
- The <<addend>> is a value provided by the back end to be added (!)
- to the relocation offset. Its interpretation is dependent upon
- the howto. For example, on the 68k the code:
-
-
-| char foo[];
-| main()
-| {
-| return foo[0x12345678];
-| }
-
- Could be compiled into:
-
-| linkw fp,#-4
-| moveb @@#12345678,d0
-| extbl d0
-| unlk fp
-| rts
-
-
- This could create a reloc pointing to <<foo>>, but leave the
- offset in the data, something like:
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000006 32 _foo
-|
-|00000000 4e56 fffc ; linkw fp,#-4
-|00000004 1039 1234 5678 ; moveb @@#12345678,d0
-|0000000a 49c0 ; extbl d0
-|0000000c 4e5e ; unlk fp
-|0000000e 4e75 ; rts
-
-
- Using coff and an 88k, some instructions don't have enough
- space in them to represent the full address range, and
- pointers have to be loaded in two parts. So you'd get something like:
-
-
-| or.u r13,r0,hi16(_foo+0x12345678)
-| ld.b r2,r13,lo16(_foo+0x12345678)
-| jmp r1
-
-
- This should create two relocs, both pointing to <<_foo>>, and with
- 0x12340000 in their addend field. The data would consist of:
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000002 HVRT16 _foo+0x12340000
-|00000006 LVRT16 _foo+0x12340000
-|
-|00000000 5da05678 ; or.u r13,r0,0x5678
-|00000004 1c4d5678 ; ld.b r2,r13,0x5678
-|00000008 f400c001 ; jmp r1
-
-
- The relocation routine digs out the value from the data, adds
- it to the addend to get the original offset, and then adds the
- value of <<_foo>>. Note that all 32 bits have to be kept around
- somewhere, to cope with carry from bit 15 to bit 16.
-
- One further example is the sparc and the a.out format. The
- sparc has a similar problem to the 88k, in that some
- instructions don't have room for an entire offset, but on the
- sparc the parts are created in odd sized lumps. The designers of
- the a.out format chose to not use the data within the section
- for storing part of the offset; all the offset is kept within
- the reloc. Anything in the data should be ignored.
-
-| save %sp,-112,%sp
-| sethi %hi(_foo+0x12345678),%g2
-| ldsb [%g2+%lo(_foo+0x12345678)],%i0
-| ret
-| restore
-
- Both relocs contain a pointer to <<foo>>, and the offsets
- contain junk.
-
-
-|RELOCATION RECORDS FOR [.text]:
-|offset type value
-|00000004 HI22 _foo+0x12345678
-|00000008 LO10 _foo+0x12345678
-|
-|00000000 9de3bf90 ; save %sp,-112,%sp
-|00000004 05000000 ; sethi %hi(_foo+0),%g2
-|00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0
-|0000000c 81c7e008 ; ret
-|00000010 81e80000 ; restore
-
-
- o <<howto>>
-
- The <<howto>> field can be imagined as a
- relocation instruction. It is a pointer to a structure which
- contains information on what to do with all of the other
- information in the reloc record and data section. A back end
- would normally have a relocation instruction set and turn
- relocations into pointers to the correct structure on input -
- but it would be possible to create each howto field on demand.
-
-*/
-
-/*
-SUBSUBSECTION
- <<enum complain_overflow>>
-
- Indicates what sort of overflow checking should be done when
- performing a relocation.
-
-CODE_FRAGMENT
-.
-.enum complain_overflow
-.{
-. {* Do not complain on overflow. *}
-. complain_overflow_dont,
-.
-. {* Complain if the bitfield overflows, whether it is considered
-. as signed or unsigned. *}
-. complain_overflow_bitfield,
-.
-. {* Complain if the value overflows when considered as signed
-. number. *}
-. complain_overflow_signed,
-.
-. {* Complain if the value overflows when considered as an
-. unsigned number. *}
-. complain_overflow_unsigned
-.};
-
-*/
-
-/*
-SUBSUBSECTION
- <<reloc_howto_type>>
-
- The <<reloc_howto_type>> is a structure which contains all the
- information that libbfd needs to know to tie up a back end's data.
-
-CODE_FRAGMENT
-.struct symbol_cache_entry; {* Forward declaration *}
-.
-.struct reloc_howto_struct
-.{
-. {* The type field has mainly a documetary use - the back end can
-. do what it wants with it, though normally the back end's
-. external idea of what a reloc number is stored
-. in this field. For example, a PC relative word relocation
-. in a coff environment has the type 023 - because that's
-. what the outside world calls a R_PCRWORD reloc. *}
-. unsigned int type;
-.
-. {* The value the final relocation is shifted right by. This drops
-. unwanted data from the relocation. *}
-. unsigned int rightshift;
-.
-. {* The size of the item to be relocated. This is *not* a
-. power-of-two measure. To get the number of bytes operated
-. on by a type of relocation, use bfd_get_reloc_size. *}
-. int size;
-.
-. {* The number of bits in the item to be relocated. This is used
-. when doing overflow checking. *}
-. unsigned int bitsize;
-.
-. {* Notes that the relocation is relative to the location in the
-. data section of the addend. The relocation function will
-. subtract from the relocation value the address of the location
-. being relocated. *}
-. boolean pc_relative;
-.
-. {* The bit position of the reloc value in the destination.
-. The relocated value is left shifted by this amount. *}
-. unsigned int bitpos;
-.
-. {* What type of overflow error should be checked for when
-. relocating. *}
-. enum complain_overflow complain_on_overflow;
-.
-. {* If this field is non null, then the supplied function is
-. called rather than the normal function. This allows really
-. strange relocation methods to be accomodated (e.g., i960 callj
-. instructions). *}
-. bfd_reloc_status_type (*special_function)
-. PARAMS ((bfd *abfd,
-. arelent *reloc_entry,
-. struct symbol_cache_entry *symbol,
-. PTR data,
-. asection *input_section,
-. bfd *output_bfd,
-. char **error_message));
-.
-. {* The textual name of the relocation type. *}
-. char *name;
-.
-. {* When performing a partial link, some formats must modify the
-. relocations rather than the data - this flag signals this.*}
-. boolean partial_inplace;
-.
-. {* The src_mask selects which parts of the read in data
-. are to be used in the relocation sum. E.g., if this was an 8 bit
-. bit of data which we read and relocated, this would be
-. 0x000000ff. When we have relocs which have an addend, such as
-. sun4 extended relocs, the value in the offset part of a
-. relocating field is garbage so we never use it. In this case
-. the mask would be 0x00000000. *}
-. bfd_vma src_mask;
-.
-. {* The dst_mask selects which parts of the instruction are replaced
-. into the instruction. In most cases src_mask == dst_mask,
-. except in the above special case, where dst_mask would be
-. 0x000000ff, and src_mask would be 0x00000000. *}
-. bfd_vma dst_mask;
-.
-. {* When some formats create PC relative instructions, they leave
-. the value of the pc of the place being relocated in the offset
-. slot of the instruction, so that a PC relative relocation can
-. be made just by adding in an ordinary offset (e.g., sun3 a.out).
-. Some formats leave the displacement part of an instruction
-. empty (e.g., m88k bcs); this flag signals the fact.*}
-. boolean pcrel_offset;
-.
-.};
-
-*/
-
-/*
-FUNCTION
- The HOWTO Macro
-
-DESCRIPTION
- The HOWTO define is horrible and will go away.
-
-
-.#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
-. {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
-
-DESCRIPTION
- And will be replaced with the totally magic way. But for the
- moment, we are compatible, so do it this way.
-
-
-.#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
-.
-DESCRIPTION
- Helper routine to turn a symbol into a relocation value.
-
-.#define HOWTO_PREPARE(relocation, symbol) \
-. { \
-. if (symbol != (asymbol *)NULL) { \
-. if (bfd_is_com_section (symbol->section)) { \
-. relocation = 0; \
-. } \
-. else { \
-. relocation = symbol->value; \
-. } \
-. } \
-.}
-
-*/
-
-/*
-FUNCTION
- bfd_get_reloc_size
-
-SYNOPSIS
- int bfd_get_reloc_size (reloc_howto_type *);
-
-DESCRIPTION
- For a reloc_howto_type that operates on a fixed number of bytes,
- this returns the number of bytes operated on.
- */
-
-int
-bfd_get_reloc_size (howto)
- reloc_howto_type *howto;
-{
- switch (howto->size)
- {
- case 0: return 1;
- case 1: return 2;
- case 2: return 4;
- case 3: return 0;
- case 4: return 8;
- case -2: return 4;
- default: abort ();
- }
-}
-
-/*
-TYPEDEF
- arelent_chain
-
-DESCRIPTION
-
- How relocs are tied together in an <<asection>>:
-
-.typedef struct relent_chain {
-. arelent relent;
-. struct relent_chain *next;
-.} arelent_chain;
-
-*/
-
-
-
-/*
-FUNCTION
- bfd_perform_relocation
-
-SYNOPSIS
- bfd_reloc_status_type
- bfd_perform_relocation
- (bfd *abfd,
- arelent *reloc_entry,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message);
-
-DESCRIPTION
- If @var{output_bfd} is supplied to this function, the
- generated image will be relocatable; the relocations are
- copied to the output file after they have been changed to
- reflect the new state of the world. There are two ways of
- reflecting the results of partial linkage in an output file:
- by modifying the output data in place, and by modifying the
- relocation record. Some native formats (e.g., basic a.out and
- basic coff) have no way of specifying an addend in the
- relocation type, so the addend has to go in the output data.
- This is no big deal since in these formats the output data
- slot will always be big enough for the addend. Complex reloc
- types with addends were invented to solve just this problem.
- The @var{error_message} argument is set to an error message if
- this return @code{bfd_reloc_dangerous}.
-
-*/
-
-
-bfd_reloc_status_type
-bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_reloc_status_type flag = bfd_reloc_ok;
- bfd_size_type addr = reloc_entry->address;
- bfd_vma output_base = 0;
- reloc_howto_type *howto = reloc_entry->howto;
- asection *reloc_target_output_section;
- asymbol *symbol;
-
- symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->section)
- && output_bfd != (bfd *) NULL)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* If we are not producing relocateable output, return an error if
- the symbol is not defined. An undefined weak symbol is
- considered to have a value of zero (SVR4 ABI, p. 4-27). */
- if (bfd_is_und_section (symbol->section)
- && (symbol->flags & BSF_WEAK) == 0
- && output_bfd == (bfd *) NULL)
- flag = bfd_reloc_undefined;
-
- /* If there is a function supplied to handle this relocation type,
- call it. It'll return `bfd_reloc_continue' if further processing
- can be done. */
- if (howto->special_function)
- {
- bfd_reloc_status_type cont;
- cont = howto->special_function (abfd, reloc_entry, symbol, data,
- input_section, output_bfd,
- error_message);
- if (cont != bfd_reloc_continue)
- return cont;
- }
-
- /* Is the address of the relocation really within the section? */
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Work out which section the relocation is targetted at and the
- initial relocation command value. */
-
- /* Get symbol value. (Common symbols are special.) */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
-
- reloc_target_output_section = symbol->section->output_section;
-
- /* Convert input-section-relative symbol value to absolute. */
- if (output_bfd && howto->partial_inplace == false)
- output_base = 0;
- else
- output_base = reloc_target_output_section->vma;
-
- relocation += output_base + symbol->section->output_offset;
-
- /* Add in supplied addend. */
- relocation += reloc_entry->addend;
-
- /* Here the variable relocation holds the final address of the
- symbol we are relocating against, plus any addend. */
-
- if (howto->pc_relative == true)
- {
- /* This is a PC relative relocation. We want to set RELOCATION
- to the distance between the address of the symbol and the
- location. RELOCATION is already the address of the symbol.
-
- We start by subtracting the address of the section containing
- the location.
-
- If pcrel_offset is set, we must further subtract the position
- of the location within the section. Some targets arrange for
- the addend to be the negative of the position of the location
- within the section; for example, i386-aout does this. For
- i386-aout, pcrel_offset is false. Some other targets do not
- include the position of the location; for example, m88kbcs,
- or ELF. For those targets, pcrel_offset is true.
-
- If we are producing relocateable output, then we must ensure
- that this reloc will be correctly computed when the final
- relocation is done. If pcrel_offset is false we want to wind
- up with the negative of the location within the section,
- which means we must adjust the existing addend by the change
- in the location within the section. If pcrel_offset is true
- we do not want to adjust the existing addend at all.
-
- FIXME: This seems logical to me, but for the case of
- producing relocateable output it is not what the code
- actually does. I don't want to change it, because it seems
- far too likely that something will break. */
-
- relocation -=
- input_section->output_section->vma + input_section->output_offset;
-
- if (howto->pcrel_offset == true)
- relocation -= reloc_entry->address;
- }
-
- if (output_bfd != (bfd *) NULL)
- {
- if (howto->partial_inplace == false)
- {
- /* This is a partial relocation, and we want to apply the relocation
- to the reloc entry rather than the raw data. Modify the reloc
- inplace to reflect what we now know. */
- reloc_entry->addend = relocation;
- reloc_entry->address += input_section->output_offset;
- return flag;
- }
- else
- {
- /* This is a partial relocation, but inplace, so modify the
- reloc record a bit.
-
- If we've relocated with a symbol with a section, change
- into a ref to the section belonging to the symbol. */
-
- reloc_entry->address += input_section->output_offset;
-
- /* WTF?? */
- if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
- {
-#if 1
- /* For m68k-coff, the addend was being subtracted twice during
- relocation with -r. Removing the line below this comment
- fixes that problem; see PR 2953.
-
-However, Ian wrote the following, regarding removing the line below,
-which explains why it is still enabled: --djm
-
-If you put a patch like that into BFD you need to check all the COFF
-linkers. I am fairly certain that patch will break coff-i386 (e.g.,
-SCO); see coff_i386_reloc in coff-i386.c where I worked around the
-problem in a different way. There may very well be a reason that the
-code works as it does.
-
-Hmmm. The first obvious point is that bfd_perform_relocation should
-not have any tests that depend upon the flavour. It's seem like
-entirely the wrong place for such a thing. The second obvious point
-is that the current code ignores the reloc addend when producing
-relocateable output for COFF. That's peculiar. In fact, I really
-have no idea what the point of the line you want to remove is.
-
-A typical COFF reloc subtracts the old value of the symbol and adds in
-the new value to the location in the object file (if it's a pc
-relative reloc it adds the difference between the symbol value and the
-location). When relocating we need to preserve that property.
-
-BFD handles this by setting the addend to the negative of the old
-value of the symbol. Unfortunately it handles common symbols in a
-non-standard way (it doesn't subtract the old value) but that's a
-different story (we can't change it without losing backward
-compatibility with old object files) (coff-i386 does subtract the old
-value, to be compatible with existing coff-i386 targets, like SCO).
-
-So everything works fine when not producing relocateable output. When
-we are producing relocateable output, logically we should do exactly
-what we do when not producing relocateable output. Therefore, your
-patch is correct. In fact, it should probably always just set
-reloc_entry->addend to 0 for all cases, since it is, in fact, going to
-add the value into the object file. This won't hurt the COFF code,
-which doesn't use the addend; I'm not sure what it will do to other
-formats (the thing to check for would be whether any formats both use
-the addend and set partial_inplace).
-
-When I wanted to make coff-i386 produce relocateable output, I ran
-into the problem that you are running into: I wanted to remove that
-line. Rather than risk it, I made the coff-i386 relocs use a special
-function; it's coff_i386_reloc in coff-i386.c. The function
-specifically adds the addend field into the object file, knowing that
-bfd_perform_relocation is not going to. If you remove that line, then
-coff-i386.c will wind up adding the addend field in twice. It's
-trivial to fix; it just needs to be done.
-
-The problem with removing the line is just that it may break some
-working code. With BFD it's hard to be sure of anything. The right
-way to deal with this is simply to build and test at least all the
-supported COFF targets. It should be straightforward if time and disk
-space consuming. For each target:
- 1) build the linker
- 2) generate some executable, and link it using -r (I would
- probably use paranoia.o and link against newlib/libc.a, which
- for all the supported targets would be available in
- /usr/cygnus/progressive/H-host/target/lib/libc.a).
- 3) make the change to reloc.c
- 4) rebuild the linker
- 5) repeat step 2
- 6) if the resulting object files are the same, you have at least
- made it no worse
- 7) if they are different you have to figure out which version is
- right
-*/
- relocation -= reloc_entry->addend;
-#endif
- reloc_entry->addend = 0;
- }
- else
- {
- reloc_entry->addend = relocation;
- }
- }
- }
- else
- {
- reloc_entry->addend = 0;
- }
-
- /* FIXME: This overflow checking is incomplete, because the value
- might have overflowed before we get here. For a correct check we
- need to compute the value in a size larger than bitsize, but we
- can't reasonably do that for a reloc the same size as a host
- machine word.
- FIXME: We should also do overflow checking on the result after
- adding in the value contained in the object file. */
- if (howto->complain_on_overflow != complain_overflow_dont
- && flag == bfd_reloc_ok)
- {
- bfd_vma check;
-
- /* Get the value that will be used for the relocation, but
- starting at bit position zero. */
- check = relocation >> howto->rightshift;
- switch (howto->complain_on_overflow)
- {
- case complain_overflow_signed:
- {
- /* Assumes two's complement. */
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
- bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
-
- /* The above right shift is incorrect for a signed value.
- Fix it up by forcing on the upper bits. */
- if (howto->rightshift > 0
- && (bfd_signed_vma) relocation < 0)
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- if ((bfd_signed_vma) check > reloc_signed_max
- || (bfd_signed_vma) check < reloc_signed_min)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_unsigned:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_unsigned_max =
- (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if ((bfd_vma) check > reloc_unsigned_max)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_bitfield:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if (((bfd_vma) check & ~reloc_bits) != 0
- && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- {
- /* The above right shift is incorrect for a signed
- value. See if turning on the upper bits fixes the
- overflow. */
- if (howto->rightshift > 0
- && (bfd_signed_vma) relocation < 0)
- {
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- flag = bfd_reloc_overflow;
- }
- else
- flag = bfd_reloc_overflow;
- }
- }
- break;
- default:
- abort ();
- }
- }
-
- /*
- Either we are relocating all the way, or we don't want to apply
- the relocation to the reloc entry (probably because there isn't
- any room in the output format to describe addends to relocs)
- */
-
- /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
- (OSF version 1.3, compiler version 3.11). It miscompiles the
- following program:
-
- struct str
- {
- unsigned int i0;
- } s = { 0 };
-
- int
- main ()
- {
- unsigned long x;
-
- x = 0x100000000;
- x <<= (unsigned long) s.i0;
- if (x == 0)
- printf ("failed\n");
- else
- printf ("succeeded (%lx)\n", x);
- }
- */
-
- relocation >>= (bfd_vma) howto->rightshift;
-
- /* Shift everything up to where it's going to be used */
-
- relocation <<= (bfd_vma) howto->bitpos;
-
- /* Wait for the day when all have the mask in them */
-
- /* What we do:
- i instruction to be left alone
- o offset within instruction
- r relocation offset to apply
- S src mask
- D dst mask
- N ~dst mask
- A part 1
- B part 2
- R result
-
- Do this:
- i i i i i o o o o o from bfd_get<size>
- and S S S S S to get the size offset we want
- + r r r r r r r r r r to get the final value to place
- and D D D D D to chop to right size
- -----------------------
- A A A A A
- And this:
- ... i i i i i o o o o o from bfd_get<size>
- and N N N N N get instruction
- -----------------------
- ... B B B B B
-
- And then:
- B B B B B
- or A A A A A
- -----------------------
- R R R R R R R R R R put into bfd_put<size>
- */
-
-#define DOIT(x) \
- x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, (char *) data + addr);
- DOIT (x);
- bfd_put_8 (abfd, x, (unsigned char *) data + addr);
- }
- break;
-
- case 1:
- if (relocation)
- {
- short x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data + addr);
- }
- break;
- case 2:
- if (relocation)
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
- case -2:
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- relocation = -relocation;
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
-
- case -1:
- {
- long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
- relocation = -relocation;
- DOIT (x);
- bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
- }
- break;
-
- case 3:
- /* Do nothing */
- break;
-
- case 4:
-#ifdef BFD64
- if (relocation)
- {
- bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr);
- DOIT (x);
- bfd_put_64 (abfd, x, (bfd_byte *) data + addr);
- }
-#else
- abort ();
-#endif
- break;
- default:
- return bfd_reloc_other;
- }
-
- return flag;
-}
-
-/*
-FUNCTION
- bfd_install_relocation
-
-SYNOPSIS
- bfd_reloc_status_type
- bfd_install_relocation
- (bfd *abfd,
- arelent *reloc_entry,
- PTR data, bfd_vma data_start,
- asection *input_section,
- char **error_message);
-
-DESCRIPTION
- This looks remarkably like <<bfd_perform_relocation>>, except it
- does not expect that the section contents have been filled in.
- I.e., it's suitable for use when creating, rather than applying
- a relocation.
-
- For now, this function should be considered reserved for the
- assembler.
-
-*/
-
-
-bfd_reloc_status_type
-bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset,
- input_section, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- PTR data_start;
- bfd_vma data_start_offset;
- asection *input_section;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_reloc_status_type flag = bfd_reloc_ok;
- bfd_size_type addr = reloc_entry->address;
- bfd_vma output_base = 0;
- reloc_howto_type *howto = reloc_entry->howto;
- asection *reloc_target_output_section;
- asymbol *symbol;
- bfd_byte *data;
-
- symbol = *(reloc_entry->sym_ptr_ptr);
- if (bfd_is_abs_section (symbol->section))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* If there is a function supplied to handle this relocation type,
- call it. It'll return `bfd_reloc_continue' if further processing
- can be done. */
- if (howto->special_function)
- {
- bfd_reloc_status_type cont;
- /* XXX - The special_function calls haven't been fixed up to deal
- with creating new relocations and section contents. */
- cont = howto->special_function (abfd, reloc_entry, symbol,
- /* XXX - Non-portable! */
- ((bfd_byte *) data_start
- - data_start_offset),
- input_section, abfd, error_message);
- if (cont != bfd_reloc_continue)
- return cont;
- }
-
- /* Is the address of the relocation really within the section? */
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Work out which section the relocation is targetted at and the
- initial relocation command value. */
-
- /* Get symbol value. (Common symbols are special.) */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
-
- reloc_target_output_section = symbol->section->output_section;
-
- /* Convert input-section-relative symbol value to absolute. */
- if (howto->partial_inplace == false)
- output_base = 0;
- else
- output_base = reloc_target_output_section->vma;
-
- relocation += output_base + symbol->section->output_offset;
-
- /* Add in supplied addend. */
- relocation += reloc_entry->addend;
-
- /* Here the variable relocation holds the final address of the
- symbol we are relocating against, plus any addend. */
-
- if (howto->pc_relative == true)
- {
- /* This is a PC relative relocation. We want to set RELOCATION
- to the distance between the address of the symbol and the
- location. RELOCATION is already the address of the symbol.
-
- We start by subtracting the address of the section containing
- the location.
-
- If pcrel_offset is set, we must further subtract the position
- of the location within the section. Some targets arrange for
- the addend to be the negative of the position of the location
- within the section; for example, i386-aout does this. For
- i386-aout, pcrel_offset is false. Some other targets do not
- include the position of the location; for example, m88kbcs,
- or ELF. For those targets, pcrel_offset is true.
-
- If we are producing relocateable output, then we must ensure
- that this reloc will be correctly computed when the final
- relocation is done. If pcrel_offset is false we want to wind
- up with the negative of the location within the section,
- which means we must adjust the existing addend by the change
- in the location within the section. If pcrel_offset is true
- we do not want to adjust the existing addend at all.
-
- FIXME: This seems logical to me, but for the case of
- producing relocateable output it is not what the code
- actually does. I don't want to change it, because it seems
- far too likely that something will break. */
-
- relocation -=
- input_section->output_section->vma + input_section->output_offset;
-
- if (howto->pcrel_offset == true && howto->partial_inplace == true)
- relocation -= reloc_entry->address;
- }
-
- if (howto->partial_inplace == false)
- {
- /* This is a partial relocation, and we want to apply the relocation
- to the reloc entry rather than the raw data. Modify the reloc
- inplace to reflect what we now know. */
- reloc_entry->addend = relocation;
- reloc_entry->address += input_section->output_offset;
- return flag;
- }
- else
- {
- /* This is a partial relocation, but inplace, so modify the
- reloc record a bit.
-
- If we've relocated with a symbol with a section, change
- into a ref to the section belonging to the symbol. */
-
- reloc_entry->address += input_section->output_offset;
-
- /* WTF?? */
- if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-little") != 0
- && strcmp (abfd->xvec->name, "coff-Intel-big") != 0)
- {
-#if 1
-/* For m68k-coff, the addend was being subtracted twice during
- relocation with -r. Removing the line below this comment
- fixes that problem; see PR 2953.
-
-However, Ian wrote the following, regarding removing the line below,
-which explains why it is still enabled: --djm
-
-If you put a patch like that into BFD you need to check all the COFF
-linkers. I am fairly certain that patch will break coff-i386 (e.g.,
-SCO); see coff_i386_reloc in coff-i386.c where I worked around the
-problem in a different way. There may very well be a reason that the
-code works as it does.
-
-Hmmm. The first obvious point is that bfd_install_relocation should
-not have any tests that depend upon the flavour. It's seem like
-entirely the wrong place for such a thing. The second obvious point
-is that the current code ignores the reloc addend when producing
-relocateable output for COFF. That's peculiar. In fact, I really
-have no idea what the point of the line you want to remove is.
-
-A typical COFF reloc subtracts the old value of the symbol and adds in
-the new value to the location in the object file (if it's a pc
-relative reloc it adds the difference between the symbol value and the
-location). When relocating we need to preserve that property.
-
-BFD handles this by setting the addend to the negative of the old
-value of the symbol. Unfortunately it handles common symbols in a
-non-standard way (it doesn't subtract the old value) but that's a
-different story (we can't change it without losing backward
-compatibility with old object files) (coff-i386 does subtract the old
-value, to be compatible with existing coff-i386 targets, like SCO).
-
-So everything works fine when not producing relocateable output. When
-we are producing relocateable output, logically we should do exactly
-what we do when not producing relocateable output. Therefore, your
-patch is correct. In fact, it should probably always just set
-reloc_entry->addend to 0 for all cases, since it is, in fact, going to
-add the value into the object file. This won't hurt the COFF code,
-which doesn't use the addend; I'm not sure what it will do to other
-formats (the thing to check for would be whether any formats both use
-the addend and set partial_inplace).
-
-When I wanted to make coff-i386 produce relocateable output, I ran
-into the problem that you are running into: I wanted to remove that
-line. Rather than risk it, I made the coff-i386 relocs use a special
-function; it's coff_i386_reloc in coff-i386.c. The function
-specifically adds the addend field into the object file, knowing that
-bfd_install_relocation is not going to. If you remove that line, then
-coff-i386.c will wind up adding the addend field in twice. It's
-trivial to fix; it just needs to be done.
-
-The problem with removing the line is just that it may break some
-working code. With BFD it's hard to be sure of anything. The right
-way to deal with this is simply to build and test at least all the
-supported COFF targets. It should be straightforward if time and disk
-space consuming. For each target:
- 1) build the linker
- 2) generate some executable, and link it using -r (I would
- probably use paranoia.o and link against newlib/libc.a, which
- for all the supported targets would be available in
- /usr/cygnus/progressive/H-host/target/lib/libc.a).
- 3) make the change to reloc.c
- 4) rebuild the linker
- 5) repeat step 2
- 6) if the resulting object files are the same, you have at least
- made it no worse
- 7) if they are different you have to figure out which version is
- right
-*/
- relocation -= reloc_entry->addend;
-#endif
- reloc_entry->addend = 0;
- }
- else
- {
- reloc_entry->addend = relocation;
- }
- }
-
- /* FIXME: This overflow checking is incomplete, because the value
- might have overflowed before we get here. For a correct check we
- need to compute the value in a size larger than bitsize, but we
- can't reasonably do that for a reloc the same size as a host
- machine word.
-
- FIXME: We should also do overflow checking on the result after
- adding in the value contained in the object file. */
- if (howto->complain_on_overflow != complain_overflow_dont)
- {
- bfd_vma check;
-
- /* Get the value that will be used for the relocation, but
- starting at bit position zero. */
- check = relocation >> howto->rightshift;
- switch (howto->complain_on_overflow)
- {
- case complain_overflow_signed:
- {
- /* Assumes two's complement. */
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
- bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
-
- /* The above right shift is incorrect for a signed value.
- Fix it up by forcing on the upper bits. */
- if (howto->rightshift > 0
- && (bfd_signed_vma) relocation < 0)
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- if ((bfd_signed_vma) check > reloc_signed_max
- || (bfd_signed_vma) check < reloc_signed_min)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_unsigned:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_unsigned_max =
- (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if ((bfd_vma) check > reloc_unsigned_max)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_bitfield:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if (((bfd_vma) check & ~reloc_bits) != 0
- && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- {
- /* The above right shift is incorrect for a signed
- value. See if turning on the upper bits fixes the
- overflow. */
- if (howto->rightshift > 0
- && (bfd_signed_vma) relocation < 0)
- {
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> howto->rightshift));
- if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- flag = bfd_reloc_overflow;
- }
- else
- flag = bfd_reloc_overflow;
- }
- }
- break;
- default:
- abort ();
- }
- }
-
- /*
- Either we are relocating all the way, or we don't want to apply
- the relocation to the reloc entry (probably because there isn't
- any room in the output format to describe addends to relocs)
- */
-
- /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
- (OSF version 1.3, compiler version 3.11). It miscompiles the
- following program:
-
- struct str
- {
- unsigned int i0;
- } s = { 0 };
-
- int
- main ()
- {
- unsigned long x;
-
- x = 0x100000000;
- x <<= (unsigned long) s.i0;
- if (x == 0)
- printf ("failed\n");
- else
- printf ("succeeded (%lx)\n", x);
- }
- */
-
- relocation >>= (bfd_vma) howto->rightshift;
-
- /* Shift everything up to where it's going to be used */
-
- relocation <<= (bfd_vma) howto->bitpos;
-
- /* Wait for the day when all have the mask in them */
-
- /* What we do:
- i instruction to be left alone
- o offset within instruction
- r relocation offset to apply
- S src mask
- D dst mask
- N ~dst mask
- A part 1
- B part 2
- R result
-
- Do this:
- i i i i i o o o o o from bfd_get<size>
- and S S S S S to get the size offset we want
- + r r r r r r r r r r to get the final value to place
- and D D D D D to chop to right size
- -----------------------
- A A A A A
- And this:
- ... i i i i i o o o o o from bfd_get<size>
- and N N N N N get instruction
- -----------------------
- ... B B B B B
-
- And then:
- B B B B B
- or A A A A A
- -----------------------
- R R R R R R R R R R put into bfd_put<size>
- */
-
-#define DOIT(x) \
- x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
-
- data = (bfd_byte *) data_start + (addr - data_start_offset);
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, (char *) data);
- DOIT (x);
- bfd_put_8 (abfd, x, (unsigned char *) data);
- }
- break;
-
- case 1:
- if (relocation)
- {
- short x = bfd_get_16 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data);
- }
- break;
- case 2:
- if (relocation)
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
- }
- break;
- case -2:
- {
- long x = bfd_get_32 (abfd, (bfd_byte *) data);
- relocation = -relocation;
- DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
- }
- break;
-
- case 3:
- /* Do nothing */
- break;
-
- case 4:
- if (relocation)
- {
- bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data);
- DOIT (x);
- bfd_put_64 (abfd, x, (bfd_byte *) data);
- }
- break;
- default:
- return bfd_reloc_other;
- }
-
- return flag;
-}
-
-/* This relocation routine is used by some of the backend linkers.
- They do not construct asymbol or arelent structures, so there is no
- reason for them to use bfd_perform_relocation. Also,
- bfd_perform_relocation is so hacked up it is easier to write a new
- function than to try to deal with it.
-
- This routine does a final relocation. It should not be used when
- generating relocateable output.
-
- FIXME: This routine ignores any special_function in the HOWTO,
- since the existing special_function values have been written for
- bfd_perform_relocation.
-
- HOWTO is the reloc howto information.
- INPUT_BFD is the BFD which the reloc applies to.
- INPUT_SECTION is the section which the reloc applies to.
- CONTENTS is the contents of the section.
- ADDRESS is the address of the reloc within INPUT_SECTION.
- VALUE is the value of the symbol the reloc refers to.
- ADDEND is the addend of the reloc. */
-
-bfd_reloc_status_type
-_bfd_final_link_relocate (howto, input_bfd, input_section, contents, address,
- value, addend)
- reloc_howto_type *howto;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- bfd_vma address;
- bfd_vma value;
- bfd_vma addend;
-{
- bfd_vma relocation;
-
- /* Sanity check the address. */
- if (address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* This function assumes that we are dealing with a basic relocation
- against a symbol. We want to compute the value of the symbol to
- relocate to. This is just VALUE, the value of the symbol, plus
- ADDEND, any addend associated with the reloc. */
- relocation = value + addend;
-
- /* If the relocation is PC relative, we want to set RELOCATION to
- the distance between the symbol (currently in RELOCATION) and the
- location we are relocating. Some targets (e.g., i386-aout)
- arrange for the contents of the section to be the negative of the
- offset of the location within the section; for such targets
- pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
- simply leave the contents of the section as zero; for such
- targets pcrel_offset is true. If pcrel_offset is false we do not
- need to subtract out the offset of the location within the
- section (which is just ADDRESS). */
- if (howto->pc_relative)
- {
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- if (howto->pcrel_offset)
- relocation -= address;
- }
-
- return _bfd_relocate_contents (howto, input_bfd, relocation,
- contents + address);
-}
-
-/* Relocate a given location using a given value and howto. */
-
-bfd_reloc_status_type
-_bfd_relocate_contents (howto, input_bfd, relocation, location)
- reloc_howto_type *howto;
- bfd *input_bfd;
- bfd_vma relocation;
- bfd_byte *location;
-{
- int size;
- bfd_vma x;
- boolean overflow;
-
- /* If the size is negative, negate RELOCATION. This isn't very
- general. */
- if (howto->size < 0)
- relocation = -relocation;
-
- /* Get the value we are going to relocate. */
- size = bfd_get_reloc_size (howto);
- switch (size)
- {
- default:
- case 0:
- abort ();
- case 1:
- x = bfd_get_8 (input_bfd, location);
- break;
- case 2:
- x = bfd_get_16 (input_bfd, location);
- break;
- case 4:
- x = bfd_get_32 (input_bfd, location);
- break;
- case 8:
-#ifdef BFD64
- x = bfd_get_64 (input_bfd, location);
-#else
- abort ();
-#endif
- break;
- }
-
- /* Check for overflow. FIXME: We may drop bits during the addition
- which we don't check for. We must either check at every single
- operation, which would be tedious, or we must do the computations
- in a type larger than bfd_vma, which would be inefficient. */
- overflow = false;
- if (howto->complain_on_overflow != complain_overflow_dont)
- {
- bfd_vma check;
- bfd_signed_vma signed_check;
- bfd_vma add;
- bfd_signed_vma signed_add;
-
- if (howto->rightshift == 0)
- {
- check = relocation;
- signed_check = (bfd_signed_vma) relocation;
- }
- else
- {
- /* Drop unwanted bits from the value we are relocating to. */
- check = relocation >> howto->rightshift;
-
- /* If this is a signed value, the rightshift just dropped
- leading 1 bits (assuming twos complement). */
- if ((bfd_signed_vma) relocation >= 0)
- signed_check = check;
- else
- signed_check = (check
- | ((bfd_vma) - 1
- & ~((bfd_vma) - 1 >> howto->rightshift)));
- }
-
- /* Get the value from the object file. */
- add = x & howto->src_mask;
-
- /* Get the value from the object file with an appropriate sign.
- The expression involving howto->src_mask isolates the upper
- bit of src_mask. If that bit is set in the value we are
- adding, it is negative, and we subtract out that number times
- two. If src_mask includes the highest possible bit, then we
- can not get the upper bit, but that does not matter since
- signed_add needs no adjustment to become negative in that
- case. */
- signed_add = add;
- if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
- signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
-
- /* Add the value from the object file, shifted so that it is a
- straight number. */
- if (howto->bitpos == 0)
- {
- check += add;
- signed_check += signed_add;
- }
- else
- {
- check += add >> howto->bitpos;
-
- /* For the signed case we use ADD, rather than SIGNED_ADD,
- to avoid warnings from SVR4 cc. This is OK since we
- explictly handle the sign bits. */
- if (signed_add >= 0)
- signed_check += add >> howto->bitpos;
- else
- signed_check += ((add >> howto->bitpos)
- | ((bfd_vma) - 1
- & ~((bfd_vma) - 1 >> howto->bitpos)));
- }
-
- switch (howto->complain_on_overflow)
- {
- case complain_overflow_signed:
- {
- /* Assumes two's complement. */
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
- bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
-
- if (signed_check > reloc_signed_max
- || signed_check < reloc_signed_min)
- overflow = true;
- }
- break;
- case complain_overflow_unsigned:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_unsigned_max =
- (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if (check > reloc_unsigned_max)
- overflow = true;
- }
- break;
- case complain_overflow_bitfield:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if ((check & ~reloc_bits) != 0
- && (((bfd_vma) signed_check & ~reloc_bits)
- != (-1 & ~reloc_bits)))
- overflow = true;
- }
- break;
- default:
- abort ();
- }
- }
-
- /* Put RELOCATION in the right bits. */
- relocation >>= (bfd_vma) howto->rightshift;
- relocation <<= (bfd_vma) howto->bitpos;
-
- /* Add RELOCATION to the right bits of X. */
- x = ((x & ~howto->dst_mask)
- | (((x & howto->src_mask) + relocation) & howto->dst_mask));
-
- /* Put the relocated value back in the object file. */
- switch (size)
- {
- default:
- case 0:
- abort ();
- case 1:
- bfd_put_8 (input_bfd, x, location);
- break;
- case 2:
- bfd_put_16 (input_bfd, x, location);
- break;
- case 4:
- bfd_put_32 (input_bfd, x, location);
- break;
- case 8:
-#ifdef BFD64
- bfd_put_64 (input_bfd, x, location);
-#else
- abort ();
-#endif
- break;
- }
-
- return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
-}
-
-/*
-DOCDD
-INODE
- howto manager, , typedef arelent, Relocations
-
-SECTION
- The howto manager
-
- When an application wants to create a relocation, but doesn't
- know what the target machine might call it, it can find out by
- using this bit of code.
-
-*/
-
-/*
-TYPEDEF
- bfd_reloc_code_type
-
-DESCRIPTION
- The insides of a reloc code. The idea is that, eventually, there
- will be one enumerator for every type of relocation we ever do.
- Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll
- return a howto pointer.
-
- This does mean that the application must determine the correct
- enumerator value; you can't get a howto pointer from a random set
- of attributes.
-
-SENUM
- bfd_reloc_code_real
-
-ENUM
- BFD_RELOC_64
-ENUMX
- BFD_RELOC_32
-ENUMX
- BFD_RELOC_26
-ENUMX
- BFD_RELOC_16
-ENUMX
- BFD_RELOC_14
-ENUMX
- BFD_RELOC_8
-ENUMDOC
- Basic absolute relocations of N bits.
-
-ENUM
- BFD_RELOC_64_PCREL
-ENUMX
- BFD_RELOC_32_PCREL
-ENUMX
- BFD_RELOC_24_PCREL
-ENUMX
- BFD_RELOC_16_PCREL
-ENUMX
- BFD_RELOC_12_PCREL
-ENUMX
- BFD_RELOC_8_PCREL
-ENUMDOC
- PC-relative relocations. Sometimes these are relative to the address
-of the relocation itself; sometimes they are relative to the start of
-the section containing the relocation. It depends on the specific target.
-
-The 24-bit relocation is used in some Intel 960 configurations.
-
-ENUM
- BFD_RELOC_32_GOT_PCREL
-ENUMX
- BFD_RELOC_16_GOT_PCREL
-ENUMX
- BFD_RELOC_8_GOT_PCREL
-ENUMX
- BFD_RELOC_32_GOTOFF
-ENUMX
- BFD_RELOC_16_GOTOFF
-ENUMX
- BFD_RELOC_LO16_GOTOFF
-ENUMX
- BFD_RELOC_HI16_GOTOFF
-ENUMX
- BFD_RELOC_HI16_S_GOTOFF
-ENUMX
- BFD_RELOC_8_GOTOFF
-ENUMX
- BFD_RELOC_32_PLT_PCREL
-ENUMX
- BFD_RELOC_24_PLT_PCREL
-ENUMX
- BFD_RELOC_16_PLT_PCREL
-ENUMX
- BFD_RELOC_8_PLT_PCREL
-ENUMX
- BFD_RELOC_32_PLTOFF
-ENUMX
- BFD_RELOC_16_PLTOFF
-ENUMX
- BFD_RELOC_LO16_PLTOFF
-ENUMX
- BFD_RELOC_HI16_PLTOFF
-ENUMX
- BFD_RELOC_HI16_S_PLTOFF
-ENUMX
- BFD_RELOC_8_PLTOFF
-ENUMDOC
- For ELF.
-
-ENUM
- BFD_RELOC_68K_GLOB_DAT
-ENUMX
- BFD_RELOC_68K_JMP_SLOT
-ENUMX
- BFD_RELOC_68K_RELATIVE
-ENUMDOC
- Relocations used by 68K ELF.
-
-ENUM
- BFD_RELOC_32_BASEREL
-ENUMX
- BFD_RELOC_16_BASEREL
-ENUMX
- BFD_RELOC_LO16_BASEREL
-ENUMX
- BFD_RELOC_HI16_BASEREL
-ENUMX
- BFD_RELOC_HI16_S_BASEREL
-ENUMX
- BFD_RELOC_8_BASEREL
-ENUMX
- BFD_RELOC_RVA
-ENUMDOC
- Linkage-table relative.
-
-ENUM
- BFD_RELOC_8_FFnn
-ENUMDOC
- Absolute 8-bit relocation, but used to form an address like 0xFFnn.
-
-ENUM
- BFD_RELOC_32_PCREL_S2
-ENUMX
- BFD_RELOC_16_PCREL_S2
-ENUMX
- BFD_RELOC_23_PCREL_S2
-ENUMDOC
- These PC-relative relocations are stored as word displacements --
-i.e., byte displacements shifted right two bits. The 30-bit word
-displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
-SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
-signed 16-bit displacement is used on the MIPS, and the 23-bit
-displacement is used on the Alpha.
-
-ENUM
- BFD_RELOC_HI22
-ENUMX
- BFD_RELOC_LO10
-ENUMDOC
- High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
-the target word. These are used on the SPARC.
-
-ENUM
- BFD_RELOC_GPREL16
-ENUMX
- BFD_RELOC_GPREL32
-ENUMDOC
- For systems that allocate a Global Pointer register, these are
-displacements off that register. These relocation types are
-handled specially, because the value the register will have is
-decided relatively late.
-
-
-ENUM
- BFD_RELOC_I960_CALLJ
-ENUMDOC
- Reloc types used for i960/b.out.
-
-ENUM
- BFD_RELOC_NONE
-ENUMX
- BFD_RELOC_SPARC_WDISP22
-ENUMX
- BFD_RELOC_SPARC22
-ENUMX
- BFD_RELOC_SPARC13
-ENUMX
- BFD_RELOC_SPARC_GOT10
-ENUMX
- BFD_RELOC_SPARC_GOT13
-ENUMX
- BFD_RELOC_SPARC_GOT22
-ENUMX
- BFD_RELOC_SPARC_PC10
-ENUMX
- BFD_RELOC_SPARC_PC22
-ENUMX
- BFD_RELOC_SPARC_WPLT30
-ENUMX
- BFD_RELOC_SPARC_COPY
-ENUMX
- BFD_RELOC_SPARC_GLOB_DAT
-ENUMX
- BFD_RELOC_SPARC_JMP_SLOT
-ENUMX
- BFD_RELOC_SPARC_RELATIVE
-ENUMX
- BFD_RELOC_SPARC_UA32
-ENUMDOC
- SPARC ELF relocations. There is probably some overlap with other
- relocation types already defined.
-
-ENUM
- BFD_RELOC_SPARC_BASE13
-ENUMX
- BFD_RELOC_SPARC_BASE22
-ENUMDOC
- I think these are specific to SPARC a.out (e.g., Sun 4).
-
-ENUMEQ
- BFD_RELOC_SPARC_64
- BFD_RELOC_64
-ENUMX
- BFD_RELOC_SPARC_10
-ENUMX
- BFD_RELOC_SPARC_11
-ENUMX
- BFD_RELOC_SPARC_OLO10
-ENUMX
- BFD_RELOC_SPARC_HH22
-ENUMX
- BFD_RELOC_SPARC_HM10
-ENUMX
- BFD_RELOC_SPARC_LM22
-ENUMX
- BFD_RELOC_SPARC_PC_HH22
-ENUMX
- BFD_RELOC_SPARC_PC_HM10
-ENUMX
- BFD_RELOC_SPARC_PC_LM22
-ENUMX
- BFD_RELOC_SPARC_WDISP16
-ENUMX
- BFD_RELOC_SPARC_WDISP19
-ENUMX
- BFD_RELOC_SPARC_GLOB_JMP
-ENUMX
- BFD_RELOC_SPARC_7
-ENUMX
- BFD_RELOC_SPARC_6
-ENUMX
- BFD_RELOC_SPARC_5
-ENUMDOC
- Some relocations we're using for SPARC V9 -- subject to change.
-
-ENUM
- BFD_RELOC_ALPHA_GPDISP_HI16
-ENUMDOC
- Alpha ECOFF relocations. Some of these treat the symbol or "addend"
- in some special way.
- For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
- writing; when reading, it will be the absolute section symbol. The
- addend is the displacement in bytes of the "lda" instruction from
- the "ldah" instruction (which is at the address of this reloc).
-ENUM
- BFD_RELOC_ALPHA_GPDISP_LO16
-ENUMDOC
- For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
- with GPDISP_HI16 relocs. The addend is ignored when writing the
- relocations out, and is filled in with the file's GP value on
- reading, for convenience.
-
-ENUM
- BFD_RELOC_ALPHA_LITERAL
-ENUMX
- BFD_RELOC_ALPHA_LITUSE
-ENUMDOC
- The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
- the assembler turns it into a LDQ instruction to load the address of
- the symbol, and then fills in a register in the real instruction.
-
- The LITERAL reloc, at the LDQ instruction, refers to the .lita
- section symbol. The addend is ignored when writing, but is filled
- in with the file's GP value on reading, for convenience, as with the
- GPDISP_LO16 reloc.
-
- The LITUSE reloc, on the instruction using the loaded address, gives
- information to the linker that it might be able to use to optimize
- away some literal section references. The symbol is ignored (read
- as the absolute section symbol), and the "addend" indicates the type
- of instruction using the register:
- 1 - "memory" fmt insn
- 2 - byte-manipulation (byte offset reg)
- 3 - jsr (target of branch)
-
- The GNU linker currently doesn't do any of this optimizing.
-
-ENUM
- BFD_RELOC_ALPHA_HINT
-ENUMDOC
- The HINT relocation indicates a value that should be filled into the
- "hint" field of a jmp/jsr/ret instruction, for possible branch-
- prediction logic which may be provided on some processors.
-
-ENUM
- BFD_RELOC_MIPS_JMP
-ENUMDOC
- Bits 27..2 of the relocation address shifted right 2 bits;
- simple reloc otherwise.
-
-ENUM
- BFD_RELOC_HI16
-ENUMDOC
- High 16 bits of 32-bit value; simple reloc.
-ENUM
- BFD_RELOC_HI16_S
-ENUMDOC
- High 16 bits of 32-bit value but the low 16 bits will be sign
- extended and added to form the final result. If the low 16
- bits form a negative number, we need to add one to the high value
- to compensate for the borrow when the low bits are added.
-ENUM
- BFD_RELOC_LO16
-ENUMDOC
- Low 16 bits.
-ENUM
- BFD_RELOC_PCREL_HI16_S
-ENUMDOC
- Like BFD_RELOC_HI16_S, but PC relative.
-ENUM
- BFD_RELOC_PCREL_LO16
-ENUMDOC
- Like BFD_RELOC_LO16, but PC relative.
-
-ENUMEQ
- BFD_RELOC_MIPS_GPREL
- BFD_RELOC_GPREL16
-ENUMDOC
- Relocation relative to the global pointer.
-
-ENUM
- BFD_RELOC_MIPS_LITERAL
-ENUMDOC
- Relocation against a MIPS literal section.
-
-ENUM
- BFD_RELOC_MIPS_GOT16
-ENUMX
- BFD_RELOC_MIPS_CALL16
-ENUMEQX
- BFD_RELOC_MIPS_GPREL32
- BFD_RELOC_GPREL32
-ENUMX
- BFD_RELOC_MIPS_GOT_HI16
-ENUMX
- BFD_RELOC_MIPS_GOT_LO16
-ENUMX
- BFD_RELOC_MIPS_CALL_HI16
-ENUMX
- BFD_RELOC_MIPS_CALL_LO16
-ENUMDOC
- MIPS ELF relocations.
-
-ENUM
- BFD_RELOC_386_GOT32
-ENUMX
- BFD_RELOC_386_PLT32
-ENUMX
- BFD_RELOC_386_COPY
-ENUMX
- BFD_RELOC_386_GLOB_DAT
-ENUMX
- BFD_RELOC_386_JUMP_SLOT
-ENUMX
- BFD_RELOC_386_RELATIVE
-ENUMX
- BFD_RELOC_386_GOTOFF
-ENUMX
- BFD_RELOC_386_GOTPC
-ENUMDOC
- i386/elf relocations
-
-ENUM
- BFD_RELOC_NS32K_IMM_8
-ENUMX
- BFD_RELOC_NS32K_IMM_16
-ENUMX
- BFD_RELOC_NS32K_IMM_32
-ENUMX
- BFD_RELOC_NS32K_IMM_8_PCREL
-ENUMX
- BFD_RELOC_NS32K_IMM_16_PCREL
-ENUMX
- BFD_RELOC_NS32K_IMM_32_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_8
-ENUMX
- BFD_RELOC_NS32K_DISP_16
-ENUMX
- BFD_RELOC_NS32K_DISP_32
-ENUMX
- BFD_RELOC_NS32K_DISP_8_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_16_PCREL
-ENUMX
- BFD_RELOC_NS32K_DISP_32_PCREL
-ENUMDOC
- ns32k relocations
-
-ENUM
- BFD_RELOC_PPC_B26
-ENUMX
- BFD_RELOC_PPC_BA26
-ENUMX
- BFD_RELOC_PPC_TOC16
-ENUMX
- BFD_RELOC_PPC_B16
-ENUMX
- BFD_RELOC_PPC_B16_BRTAKEN
-ENUMX
- BFD_RELOC_PPC_B16_BRNTAKEN
-ENUMX
- BFD_RELOC_PPC_BA16
-ENUMX
- BFD_RELOC_PPC_BA16_BRTAKEN
-ENUMX
- BFD_RELOC_PPC_BA16_BRNTAKEN
-ENUMX
- BFD_RELOC_PPC_COPY
-ENUMX
- BFD_RELOC_PPC_GLOB_DAT
-ENUMX
- BFD_RELOC_PPC_JMP_SLOT
-ENUMX
- BFD_RELOC_PPC_RELATIVE
-ENUMX
- BFD_RELOC_PPC_LOCAL24PC
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR32
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_LO
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_HI
-ENUMX
- BFD_RELOC_PPC_EMB_NADDR16_HA
-ENUMX
- BFD_RELOC_PPC_EMB_SDAI16
-ENUMX
- BFD_RELOC_PPC_EMB_SDA2I16
-ENUMX
- BFD_RELOC_PPC_EMB_SDA2REL
-ENUMX
- BFD_RELOC_PPC_EMB_SDA21
-ENUMX
- BFD_RELOC_PPC_EMB_MRKREF
-ENUMX
- BFD_RELOC_PPC_EMB_RELSEC16
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_LO
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_HI
-ENUMX
- BFD_RELOC_PPC_EMB_RELST_HA
-ENUMX
- BFD_RELOC_PPC_EMB_BIT_FLD
-ENUMX
- BFD_RELOC_PPC_EMB_RELSDA
-ENUMDOC
- Power(rs6000) and PowerPC relocations.
-
-ENUM
- BFD_RELOC_CTOR
-ENUMDOC
- The type of reloc used to build a contructor table - at the moment
- probably a 32 bit wide absolute relocation, but the target can choose.
- It generally does map to one of the other relocation types.
-
-ENUM
- BFD_RELOC_ARM_PCREL_BRANCH
-ENUMDOC
- ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
- not stored in the instruction.
-ENUM
- BFD_RELOC_ARM_IMMEDIATE
-ENUMX
- BFD_RELOC_ARM_OFFSET_IMM
-ENUMX
- BFD_RELOC_ARM_SHIFT_IMM
-ENUMX
- BFD_RELOC_ARM_SWI
-ENUMX
- BFD_RELOC_ARM_MULTI
-ENUMX
- BFD_RELOC_ARM_CP_OFF_IMM
-ENUMX
- BFD_RELOC_ARM_ADR_IMM
-ENUMX
- BFD_RELOC_ARM_LDR_IMM
-ENUMX
- BFD_RELOC_ARM_LITERAL
-ENUMX
- BFD_RELOC_ARM_IN_POOL
-ENUMDOC
- These relocs are only used within the ARM assembler. They are not
- (at present) written to any object files.
-
-COMMENT
-ENDSENUM
- BFD_RELOC_UNUSED
-CODE_FRAGMENT
-.
-.typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
-*/
-
-
-/*
-FUNCTION
- bfd_reloc_type_lookup
-
-SYNOPSIS
- reloc_howto_type *
- bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Return a pointer to a howto structure which, when
- invoked, will perform the relocation @var{code} on data from the
- architecture noted.
-
-*/
-
-
-reloc_howto_type *
-bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
-}
-
-static reloc_howto_type bfd_howto_32 =
-HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
-
-
-/*
-INTERNAL_FUNCTION
- bfd_default_reloc_type_lookup
-
-SYNOPSIS
- reloc_howto_type *bfd_default_reloc_type_lookup
- (bfd *abfd, bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Provides a default relocation lookup routine for any architecture.
-
-
-*/
-
-reloc_howto_type *
-bfd_default_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_CTOR:
- /* The type of reloc used in a ctor, which will be as wide as the
- address - so either a 64, 32, or 16 bitter. */
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 64:
- BFD_FAIL ();
- case 32:
- return &bfd_howto_32;
- case 16:
- BFD_FAIL ();
- default:
- BFD_FAIL ();
- }
- default:
- BFD_FAIL ();
- }
- return (reloc_howto_type *) NULL;
-}
-
-/*
-FUNCTION
- bfd_get_reloc_code_name
-
-SYNOPSIS
- const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
-
-DESCRIPTION
- Provides a printable name for the supplied relocation code.
- Useful mainly for printing error messages.
-*/
-
-const char *
-bfd_get_reloc_code_name (code)
- bfd_reloc_code_real_type code;
-{
- if (code > BFD_RELOC_UNUSED)
- return 0;
- return bfd_reloc_code_real_names[(int)code];
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_generic_relax_section
-
-SYNOPSIS
- boolean bfd_generic_relax_section
- (bfd *abfd,
- asection *section,
- struct bfd_link_info *,
- boolean *);
-
-DESCRIPTION
- Provides default handling for relaxing for back ends which
- don't do relaxing -- i.e., does nothing.
-*/
-
-/*ARGSUSED*/
-boolean
-bfd_generic_relax_section (abfd, section, link_info, again)
- bfd *abfd;
- asection *section;
- struct bfd_link_info *link_info;
- boolean *again;
-{
- *again = false;
- return true;
-}
-
-/*
-INTERNAL_FUNCTION
- bfd_generic_get_relocated_section_contents
-
-SYNOPSIS
- bfd_byte *
- bfd_generic_get_relocated_section_contents (bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- bfd_byte *data,
- boolean relocateable,
- asymbol **symbols);
-
-DESCRIPTION
- Provides default handling of relocation effort for back ends
- which can't be bothered to do it efficiently.
-
-*/
-
-bfd_byte *
-bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data,
- relocateable, symbols)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = link_order->u.indirect.section->owner;
- asection *input_section = link_order->u.indirect.section;
-
- long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
- arelent **reloc_vector = NULL;
- long reloc_count;
-
- if (reloc_size < 0)
- goto error_return;
-
- reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- goto error_return;
-
- /* read in the section */
- if (!bfd_get_section_contents (input_bfd,
- input_section,
- (PTR) data,
- 0,
- input_section->_raw_size))
- goto error_return;
-
- /* We're not relaxing the section, so just copy the size info */
- input_section->_cooked_size = input_section->_raw_size;
- input_section->reloc_done = true;
-
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- reloc_vector,
- symbols);
- if (reloc_count < 0)
- goto error_return;
-
- if (reloc_count > 0)
- {
- arelent **parent;
- for (parent = reloc_vector; *parent != (arelent *) NULL;
- parent++)
- {
- char *error_message = (char *) NULL;
- bfd_reloc_status_type r =
- bfd_perform_relocation (input_bfd,
- *parent,
- (PTR) data,
- input_section,
- relocateable ? abfd : (bfd *) NULL,
- &error_message);
-
- if (relocateable)
- {
- asection *os = input_section->output_section;
-
- /* A partial link, so keep the relocs */
- os->orelocation[os->reloc_count] = *parent;
- os->reloc_count++;
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- case bfd_reloc_undefined:
- if (!((*link_info->callbacks->undefined_symbol)
- (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
- input_bfd, input_section, (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_dangerous:
- BFD_ASSERT (error_message != (char *) NULL);
- if (!((*link_info->callbacks->reloc_dangerous)
- (link_info, error_message, input_bfd, input_section,
- (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_overflow:
- if (!((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
- (*parent)->howto->name, (*parent)->addend,
- input_bfd, input_section, (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_outofrange:
- default:
- abort ();
- break;
- }
-
- }
- }
- }
- if (reloc_vector != NULL)
- free (reloc_vector);
- return data;
-
-error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return NULL;
-}
diff --git a/contrib/gdb/bfd/section.c b/contrib/gdb/bfd/section.c
deleted file mode 100644
index ac9a449..0000000
--- a/contrib/gdb/bfd/section.c
+++ /dev/null
@@ -1,976 +0,0 @@
-/* Object file "section" support for the BFD library.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- Sections
-
- The raw data contained within a BFD is maintained through the
- section abstraction. A single BFD may have any number of
- sections. It keeps hold of them by pointing to the first;
- each one points to the next in the list.
-
- Sections are supported in BFD in <<section.c>>.
-
-@menu
-@* Section Input::
-@* Section Output::
-@* typedef asection::
-@* section prototypes::
-@end menu
-
-INODE
-Section Input, Section Output, Sections, Sections
-SUBSECTION
- Section input
-
- When a BFD is opened for reading, the section structures are
- created and attached to the BFD.
-
- Each section has a name which describes the section in the
- outside world---for example, <<a.out>> would contain at least
- three sections, called <<.text>>, <<.data>> and <<.bss>>.
-
- Names need not be unique; for example a COFF file may have several
- sections named <<.data>>.
-
- Sometimes a BFD will contain more than the ``natural'' number of
- sections. A back end may attach other sections containing
- constructor data, or an application may add a section (using
- <<bfd_make_section>>) to the sections attached to an already open
- BFD. For example, the linker creates an extra section
- <<COMMON>> for each input file's BFD to hold information about
- common storage.
-
- The raw data is not necessarily read in when
- the section descriptor is created. Some targets may leave the
- data in place until a <<bfd_get_section_contents>> call is
- made. Other back ends may read in all the data at once. For
- example, an S-record file has to be read once to determine the
- size of the data. An IEEE-695 file doesn't contain raw data in
- sections, but data and relocation expressions intermixed, so
- the data area has to be parsed to get out the data and
- relocations.
-
-INODE
-Section Output, typedef asection, Section Input, Sections
-
-SUBSECTION
- Section output
-
- To write a new object style BFD, the various sections to be
- written have to be created. They are attached to the BFD in
- the same way as input sections; data is written to the
- sections using <<bfd_set_section_contents>>.
-
- Any program that creates or combines sections (e.g., the assembler
- and linker) must use the <<asection>> fields <<output_section>> and
- <<output_offset>> to indicate the file sections to which each
- section must be written. (If the section is being created from
- scratch, <<output_section>> should probably point to the section
- itself and <<output_offset>> should probably be zero.)
-
- The data to be written comes from input sections attached
- (via <<output_section>> pointers) to
- the output sections. The output section structure can be
- considered a filter for the input section: the output section
- determines the vma of the output data and the name, but the
- input section determines the offset into the output section of
- the data to be written.
-
- E.g., to create a section "O", starting at 0x100, 0x123 long,
- containing two subsections, "A" at offset 0x0 (i.e., at vma
- 0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the <<asection>>
- structures would look like:
-
-| section name "A"
-| output_offset 0x00
-| size 0x20
-| output_section -----------> section name "O"
-| | vma 0x100
-| section name "B" | size 0x123
-| output_offset 0x20 |
-| size 0x103 |
-| output_section --------|
-
-
-SUBSECTION
- Link orders
-
- The data within a section is stored in a @dfn{link_order}.
- These are much like the fixups in <<gas>>. The link_order
- abstraction allows a section to grow and shrink within itself.
-
- A link_order knows how big it is, and which is the next
- link_order and where the raw data for it is; it also points to
- a list of relocations which apply to it.
-
- The link_order is used by the linker to perform relaxing on
- final code. The compiler creates code which is as big as
- necessary to make it work without relaxing, and the user can
- select whether to relax. Sometimes relaxing takes a lot of
- time. The linker runs around the relocations to see if any
- are attached to data which can be shrunk, if so it does it on
- a link_order by link_order basis.
-
-*/
-
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-/*
-DOCDD
-INODE
-typedef asection, section prototypes, Section Output, Sections
-SUBSECTION
- typedef asection
-
- Here is the section structure:
-
-CODE_FRAGMENT
-.
-.typedef struct sec
-.{
-. {* The name of the section; the name isn't a copy, the pointer is
-. the same as that passed to bfd_make_section. *}
-.
-. CONST char *name;
-.
-. {* Which section is it; 0..nth. *}
-.
-. int index;
-.
-. {* The next section in the list belonging to the BFD, or NULL. *}
-.
-. struct sec *next;
-.
-. {* The field flags contains attributes of the section. Some
-. flags are read in from the object file, and some are
-. synthesized from other information. *}
-.
-. flagword flags;
-.
-.#define SEC_NO_FLAGS 0x000
-.
-. {* Tells the OS to allocate space for this section when loading.
-. This is clear for a section containing debug information
-. only. *}
-.#define SEC_ALLOC 0x001
-.
-. {* Tells the OS to load the section from the file when loading.
-. This is clear for a .bss section. *}
-.#define SEC_LOAD 0x002
-.
-. {* The section contains data still to be relocated, so there is
-. some relocation information too. *}
-.#define SEC_RELOC 0x004
-.
-.#if 0 {* Obsolete ? *}
-.#define SEC_BALIGN 0x008
-.#endif
-.
-. {* A signal to the OS that the section contains read only
-. data. *}
-.#define SEC_READONLY 0x010
-.
-. {* The section contains code only. *}
-.#define SEC_CODE 0x020
-.
-. {* The section contains data only. *}
-.#define SEC_DATA 0x040
-.
-. {* The section will reside in ROM. *}
-.#define SEC_ROM 0x080
-.
-. {* The section contains constructor information. This section
-. type is used by the linker to create lists of constructors and
-. destructors used by <<g++>>. When a back end sees a symbol
-. which should be used in a constructor list, it creates a new
-. section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
-. the symbol to it, and builds a relocation. To build the lists
-. of constructors, all the linker has to do is catenate all the
-. sections called <<__CTOR_LIST__>> and relocate the data
-. contained within - exactly the operations it would peform on
-. standard data. *}
-.#define SEC_CONSTRUCTOR 0x100
-.
-. {* The section is a constuctor, and should be placed at the
-. end of the text, data, or bss section(?). *}
-.#define SEC_CONSTRUCTOR_TEXT 0x1100
-.#define SEC_CONSTRUCTOR_DATA 0x2100
-.#define SEC_CONSTRUCTOR_BSS 0x3100
-.
-. {* The section has contents - a data section could be
-. <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
-. <<SEC_HAS_CONTENTS>> *}
-.#define SEC_HAS_CONTENTS 0x200
-.
-. {* An instruction to the linker to not output the section
-. even if it has information which would normally be written. *}
-.#define SEC_NEVER_LOAD 0x400
-.
-. {* The section is a COFF shared library section. This flag is
-. only for the linker. If this type of section appears in
-. the input file, the linker must copy it to the output file
-. without changing the vma or size. FIXME: Although this
-. was originally intended to be general, it really is COFF
-. specific (and the flag was renamed to indicate this). It
-. might be cleaner to have some more general mechanism to
-. allow the back end to control what the linker does with
-. sections. *}
-.#define SEC_COFF_SHARED_LIBRARY 0x800
-.
-. {* The section is a common section (symbols may be defined
-. multiple times, the value of a symbol is the amount of
-. space it requires, and the largest symbol value is the one
-. used). Most targets have exactly one of these (which we
-. translate to bfd_com_section_ptr), but ECOFF has two. *}
-.#define SEC_IS_COMMON 0x8000
-.
-. {* The section contains only debugging information. For
-. example, this is set for ELF .debug and .stab sections.
-. strip tests this flag to see if a section can be
-. discarded. *}
-.#define SEC_DEBUGGING 0x10000
-.
-. {* The contents of this section are held in memory pointed to
-. by the contents field. This is checked by
-. bfd_get_section_contents, and the data is retrieved from
-. memory if appropriate. *}
-.#define SEC_IN_MEMORY 0x20000
-.
-. {* The contents of this section are to be excluded by the
-. linker for executable and shared objects unless those
-. objects are to be further relocated. *}
-.#define SEC_EXCLUDE 0x40000
-.
-. {* The contents of this section are to be sorted by the
-. based on the address specified in the associated symbol
-. table. *}
-.#define SEC_SORT_ENTRIES 0x80000
-.
-. {* End of section flags. *}
-.
-. {* The virtual memory address of the section - where it will be
-. at run time. The symbols are relocated against this. The
-. user_set_vma flag is maintained by bfd; if it's not set, the
-. backend can assign addresses (for example, in <<a.out>>, where
-. the default address for <<.data>> is dependent on the specific
-. target and various flags). *}
-.
-. bfd_vma vma;
-. boolean user_set_vma;
-.
-. {* The load address of the section - where it would be in a
-. rom image; really only used for writing section header
-. information. *}
-.
-. bfd_vma lma;
-.
-. {* The size of the section in bytes, as it will be output.
-. contains a value even if the section has no contents (e.g., the
-. size of <<.bss>>). This will be filled in after relocation *}
-.
-. bfd_size_type _cooked_size;
-.
-. {* The original size on disk of the section, in bytes. Normally this
-. value is the same as the size, but if some relaxing has
-. been done, then this value will be bigger. *}
-.
-. bfd_size_type _raw_size;
-.
-. {* If this section is going to be output, then this value is the
-. offset into the output section of the first byte in the input
-. section. E.g., if this was going to start at the 100th byte in
-. the output section, this value would be 100. *}
-.
-. bfd_vma output_offset;
-.
-. {* The output section through which to map on output. *}
-.
-. struct sec *output_section;
-.
-. {* The alignment requirement of the section, as an exponent of 2 -
-. e.g., 3 aligns to 2^3 (or 8). *}
-.
-. unsigned int alignment_power;
-.
-. {* If an input section, a pointer to a vector of relocation
-. records for the data in this section. *}
-.
-. struct reloc_cache_entry *relocation;
-.
-. {* If an output section, a pointer to a vector of pointers to
-. relocation records for the data in this section. *}
-.
-. struct reloc_cache_entry **orelocation;
-.
-. {* The number of relocation records in one of the above *}
-.
-. unsigned reloc_count;
-.
-. {* Information below is back end specific - and not always used
-. or updated. *}
-.
-. {* File position of section data *}
-.
-. file_ptr filepos;
-.
-. {* File position of relocation info *}
-.
-. file_ptr rel_filepos;
-.
-. {* File position of line data *}
-.
-. file_ptr line_filepos;
-.
-. {* Pointer to data for applications *}
-.
-. PTR userdata;
-.
-. {* If the SEC_IN_MEMORY flag is set, this points to the actual
-. contents. *}
-. unsigned char *contents;
-.
-. {* Attached line number information *}
-.
-. alent *lineno;
-.
-. {* Number of line number records *}
-.
-. unsigned int lineno_count;
-.
-. {* When a section is being output, this value changes as more
-. linenumbers are written out *}
-.
-. file_ptr moving_line_filepos;
-.
-. {* What the section number is in the target world *}
-.
-. int target_index;
-.
-. PTR used_by_bfd;
-.
-. {* If this is a constructor section then here is a list of the
-. relocations created to relocate items within it. *}
-.
-. struct relent_chain *constructor_chain;
-.
-. {* The BFD which owns the section. *}
-.
-. bfd *owner;
-.
-. boolean reloc_done;
-. {* A symbol which points at this section only *}
-. struct symbol_cache_entry *symbol;
-. struct symbol_cache_entry **symbol_ptr_ptr;
-.
-. struct bfd_link_order *link_order_head;
-. struct bfd_link_order *link_order_tail;
-.} asection ;
-.
-. {* These sections are global, and are managed by BFD. The application
-. and target back end are not permitted to change the values in
-. these sections. New code should use the section_ptr macros rather
-. than referring directly to the const sections. The const sections
-. may eventually vanish. *}
-.#define BFD_ABS_SECTION_NAME "*ABS*"
-.#define BFD_UND_SECTION_NAME "*UND*"
-.#define BFD_COM_SECTION_NAME "*COM*"
-.#define BFD_IND_SECTION_NAME "*IND*"
-.
-. {* the absolute section *}
-.extern const asection bfd_abs_section;
-.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
-.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
-. {* Pointer to the undefined section *}
-.extern const asection bfd_und_section;
-.#define bfd_und_section_ptr ((asection *) &bfd_und_section)
-.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
-. {* Pointer to the common section *}
-.extern const asection bfd_com_section;
-.#define bfd_com_section_ptr ((asection *) &bfd_com_section)
-. {* Pointer to the indirect section *}
-.extern const asection bfd_ind_section;
-.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
-.#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
-.
-.extern const struct symbol_cache_entry * const bfd_abs_symbol;
-.extern const struct symbol_cache_entry * const bfd_com_symbol;
-.extern const struct symbol_cache_entry * const bfd_und_symbol;
-.extern const struct symbol_cache_entry * const bfd_ind_symbol;
-.#define bfd_get_section_size_before_reloc(section) \
-. (section->reloc_done ? (abort(),1): (section)->_raw_size)
-.#define bfd_get_section_size_after_reloc(section) \
-. ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
-*/
-
-/* These symbols are global, not specific to any BFD. Therefore, anything
- that tries to change them is broken, and should be repaired. */
-static const asymbol global_syms[] =
-{
- /* the_bfd, name, value, attr, section [, udata] */
- {0, BFD_COM_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_com_section},
- {0, BFD_UND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_und_section},
- {0, BFD_ABS_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_abs_section},
- {0, BFD_IND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_ind_section},
-};
-
-#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
- const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
- const asection SEC = \
- { NAME, 0, 0, FLAGS, 0, false, 0, 0, 0, 0, (asection *) &SEC, \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (boolean) 0, \
- (asymbol *) &global_syms[IDX], (asymbol **) &SYM, }
-
-STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
- BFD_COM_SECTION_NAME, 0);
-STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);
-STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
-STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
-#undef STD_SECTION
-
-/*
-DOCDD
-INODE
-section prototypes, , typedef asection, Sections
-SUBSECTION
- Section prototypes
-
-These are the functions exported by the section handling part of BFD.
-*/
-
-/*
-FUNCTION
- bfd_get_section_by_name
-
-SYNOPSIS
- asection *bfd_get_section_by_name(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Run through @var{abfd} and return the one of the
- <<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
- @xref{Sections}, for more information.
-
- This should only be used in special cases; the normal way to process
- all sections of a given name is to use <<bfd_map_over_sections>> and
- <<strcmp>> on the name (or better yet, base it on the section flags
- or something else) for each section.
-*/
-
-asection *
-bfd_get_section_by_name (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sect;
-
- for (sect = abfd->sections; sect != NULL; sect = sect->next)
- if (!strcmp (sect->name, name))
- return sect;
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_make_section_old_way
-
-SYNOPSIS
- asection *bfd_make_section_old_way(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Create a new empty section called @var{name}
- and attach it to the end of the chain of sections for the
- BFD @var{abfd}. An attempt to create a section with a name which
- is already in use returns its pointer without changing the
- section chain.
-
- It has the funny name since this is the way it used to be
- before it was rewritten....
-
- Possible errors are:
- o <<bfd_error_invalid_operation>> -
- If output has already started for this BFD.
- o <<bfd_error_no_memory>> -
- If obstack alloc fails.
-
-*/
-
-
-asection *
-bfd_make_section_old_way (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sec = bfd_get_section_by_name (abfd, name);
- if (sec == (asection *) NULL)
- {
- sec = bfd_make_section (abfd, name);
- }
- return sec;
-}
-
-/*
-FUNCTION
- bfd_make_section_anyway
-
-SYNOPSIS
- asection *bfd_make_section_anyway(bfd *abfd, CONST char *name);
-
-DESCRIPTION
- Create a new empty section called @var{name} and attach it to the end of
- the chain of sections for @var{abfd}. Create a new section even if there
- is already a section with that name.
-
- Return <<NULL>> and set <<bfd_error>> on error; possible errors are:
- o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}.
- o <<bfd_error_no_memory>> - If obstack alloc fails.
-*/
-
-sec_ptr
-bfd_make_section_anyway (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *newsect;
- asection **prev = &abfd->sections;
- asection *sect = abfd->sections;
-
- if (abfd->output_has_begun)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
-
- while (sect)
- {
- prev = &sect->next;
- sect = sect->next;
- }
-
- newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (newsect == NULL)
- return NULL;
-
- newsect->name = name;
- newsect->index = abfd->section_count++;
- newsect->flags = SEC_NO_FLAGS;
-
- newsect->userdata = NULL;
- newsect->contents = NULL;
- newsect->next = (asection *) NULL;
- newsect->relocation = (arelent *) NULL;
- newsect->reloc_count = 0;
- newsect->line_filepos = 0;
- newsect->owner = abfd;
-
- /* Create a symbol whos only job is to point to this section. This is
- useful for things like relocs which are relative to the base of a
- section. */
- newsect->symbol = bfd_make_empty_symbol (abfd);
- if (newsect->symbol == NULL)
- return NULL;
- newsect->symbol->name = name;
- newsect->symbol->value = 0;
- newsect->symbol->section = newsect;
- newsect->symbol->flags = BSF_SECTION_SYM;
-
- newsect->symbol_ptr_ptr = &newsect->symbol;
-
- if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true)
- {
- free (newsect);
- return NULL;
- }
-
- *prev = newsect;
- return newsect;
-}
-
-/*
-FUNCTION
- bfd_make_section
-
-SYNOPSIS
- asection *bfd_make_section(bfd *, CONST char *name);
-
-DESCRIPTION
- Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling
- bfd_set_error ()) without changing the section chain if there is already a
- section named @var{name}. If there is an error, return <<NULL>> and set
- <<bfd_error>>.
-*/
-
-asection *
-bfd_make_section (abfd, name)
- bfd *abfd;
- CONST char *name;
-{
- asection *sect = abfd->sections;
-
- if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
- {
- return bfd_abs_section_ptr;
- }
- if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
- {
- return bfd_com_section_ptr;
- }
- if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
- {
- return bfd_und_section_ptr;
- }
-
- if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
- {
- return bfd_ind_section_ptr;
- }
-
- while (sect)
- {
- if (!strcmp (sect->name, name))
- return NULL;
- sect = sect->next;
- }
-
- /* The name is not already used; go ahead and make a new section. */
- return bfd_make_section_anyway (abfd, name);
-}
-
-
-/*
-FUNCTION
- bfd_set_section_flags
-
-SYNOPSIS
- boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
-
-DESCRIPTION
- Set the attributes of the section @var{sec} in the BFD
- @var{abfd} to the value @var{flags}. Return <<true>> on success,
- <<false>> on error. Possible error returns are:
-
- o <<bfd_error_invalid_operation>> -
- The section cannot have one or more of the attributes
- requested. For example, a .bss section in <<a.out>> may not
- have the <<SEC_HAS_CONTENTS>> field set.
-
-*/
-
-/*ARGSUSED*/
-boolean
-bfd_set_section_flags (abfd, section, flags)
- bfd *abfd;
- sec_ptr section;
- flagword flags;
-{
-#if 0
- /* If you try to copy a text section from an input file (where it
- has the SEC_CODE flag set) to an output file, this loses big if
- the bfd_applicable_section_flags (abfd) doesn't have the SEC_CODE
- set - which it doesn't, at least not for a.out. FIXME */
-
- if ((flags & bfd_applicable_section_flags (abfd)) != flags)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-#endif
-
- section->flags = flags;
- return true;
-}
-
-
-/*
-FUNCTION
- bfd_map_over_sections
-
-SYNOPSIS
- void bfd_map_over_sections(bfd *abfd,
- void (*func)(bfd *abfd,
- asection *sect,
- PTR obj),
- PTR obj);
-
-DESCRIPTION
- Call the provided function @var{func} for each section
- attached to the BFD @var{abfd}, passing @var{obj} as an
- argument. The function will be called as if by
-
-| func(abfd, the_section, obj);
-
- This is the prefered method for iterating over sections; an
- alternative would be to use a loop:
-
-| section *p;
-| for (p = abfd->sections; p != NULL; p = p->next)
-| func(abfd, p, ...)
-
-
-*/
-
-/*VARARGS2*/
-void
-bfd_map_over_sections (abfd, operation, user_storage)
- bfd *abfd;
- void (*operation) PARAMS ((bfd * abfd, asection * sect, PTR obj));
- PTR user_storage;
-{
- asection *sect;
- unsigned int i = 0;
-
- for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
- (*operation) (abfd, sect, user_storage);
-
- if (i != abfd->section_count) /* Debugging */
- abort ();
-}
-
-
-/*
-FUNCTION
- bfd_set_section_size
-
-SYNOPSIS
- boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
-
-DESCRIPTION
- Set @var{sec} to the size @var{val}. If the operation is
- ok, then <<true>> is returned, else <<false>>.
-
- Possible error returns:
- o <<bfd_error_invalid_operation>> -
- Writing has started to the BFD, so setting the size is invalid.
-
-*/
-
-boolean
-bfd_set_section_size (abfd, ptr, val)
- bfd *abfd;
- sec_ptr ptr;
- bfd_size_type val;
-{
- /* Once you've started writing to any section you cannot create or change
- the size of any others. */
-
- if (abfd->output_has_begun)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- ptr->_cooked_size = val;
- ptr->_raw_size = val;
-
- return true;
-}
-
-/*
-FUNCTION
- bfd_set_section_contents
-
-SYNOPSIS
- boolean bfd_set_section_contents
- (bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
- bfd_size_type count);
-
-
-DESCRIPTION
- Sets the contents of the section @var{section} in BFD
- @var{abfd} to the data starting in memory at @var{data}. The
- data is written to the output section starting at offset
- @var{offset} for @var{count} bytes.
-
-
-
- Normally <<true>> is returned, else <<false>>. Possible error
- returns are:
- o <<bfd_error_no_contents>> -
- The output section does not have the <<SEC_HAS_CONTENTS>>
- attribute, so nothing can be written to it.
- o and some more too
-
- This routine is front end to the back end function
- <<_bfd_set_section_contents>>.
-
-
-*/
-
-#define bfd_get_section_size_now(abfd,sec) \
-(sec->reloc_done \
- ? bfd_get_section_size_after_reloc (sec) \
- : bfd_get_section_size_before_reloc (sec))
-
-boolean
-bfd_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- bfd_size_type sz;
-
- if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS))
- {
- bfd_set_error (bfd_error_no_contents);
- return (false);
- }
-
- if (offset < 0)
- {
- bad_val:
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- sz = bfd_get_section_size_now (abfd, section);
- if ((bfd_size_type) offset > sz
- || count > sz
- || offset + count > sz)
- goto bad_val;
-
- switch (abfd->direction)
- {
- case read_direction:
- case no_direction:
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-
- case write_direction:
- break;
-
- case both_direction:
- /* File is opened for update. `output_has_begun' some time ago when
- the file was created. Do not recompute sections sizes or alignments
- in _bfd_set_section_content. */
- abfd->output_has_begun = true;
- break;
- }
-
- if (BFD_SEND (abfd, _bfd_set_section_contents,
- (abfd, section, location, offset, count)))
- {
- abfd->output_has_begun = true;
- return true;
- }
-
- return false;
-}
-
-/*
-FUNCTION
- bfd_get_section_contents
-
-SYNOPSIS
- boolean bfd_get_section_contents
- (bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count);
-
-DESCRIPTION
- Read data from @var{section} in BFD @var{abfd}
- into memory starting at @var{location}. The data is read at an
- offset of @var{offset} from the start of the input section,
- and is read for @var{count} bytes.
-
- If the contents of a constructor with the <<SEC_CONSTRUCTOR>>
- flag set are requested or if the section does not have the
- <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
- with zeroes. If no errors occur, <<true>> is returned, else
- <<false>>.
-
-
-
-*/
-boolean
-bfd_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- bfd_size_type sz;
-
- if (section->flags & SEC_CONSTRUCTOR)
- {
- memset (location, 0, (unsigned) count);
- return true;
- }
-
- if (offset < 0)
- {
- bad_val:
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- /* Even if reloc_done is true, this function reads unrelocated
- contents, so we want the raw size. */
- sz = section->_raw_size;
- if ((bfd_size_type) offset > sz || count > sz || offset + count > sz)
- goto bad_val;
-
- if (count == 0)
- /* Don't bother. */
- return true;
-
- if ((section->flags & SEC_HAS_CONTENTS) == 0)
- {
- memset (location, 0, (unsigned) count);
- return true;
- }
-
- if ((section->flags & SEC_IN_MEMORY) != 0)
- {
- memcpy (location, section->contents + offset, (size_t) count);
- return true;
- }
-
- return BFD_SEND (abfd, _bfd_get_section_contents,
- (abfd, section, location, offset, count));
-}
-
-/*
-FUNCTION
- bfd_copy_private_section_data
-
-SYNOPSIS
- boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
-
-DESCRIPTION
- Copy private section information from @var{isec} in the BFD
- @var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{osec}.
-
-.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
-. BFD_SEND (ibfd, _bfd_copy_private_section_data, \
-. (ibfd, isection, obfd, osection))
-*/
diff --git a/contrib/gdb/bfd/srec.c b/contrib/gdb/bfd/srec.c
deleted file mode 100644
index 33d28d5..0000000
--- a/contrib/gdb/bfd/srec.c
+++ /dev/null
@@ -1,1324 +0,0 @@
-/* BFD back-end for s-record objects.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SUBSECTION
- S-Record handling
-
-DESCRIPTION
-
- Ordinary S-Records cannot hold anything but addresses and
- data, so that's all that we implement.
-
- The only interesting thing is that S-Records may come out of
- order and there is no header, so an initial scan is required
- to discover the minimum and maximum addresses used to create
- the vma and size of the only section we create. We
- arbitrarily call this section ".text".
-
- When bfd_get_section_contents is called the file is read
- again, and this time the data is placed into a bfd_alloc'd
- area.
-
- Any number of sections may be created for output, we save them
- up and output them when it's time to close the bfd.
-
- An s record looks like:
-
-EXAMPLE
- S<type><length><address><data><checksum>
-
-DESCRIPTION
- Where
- o length
- is the number of bytes following upto the checksum. Note that
- this is not the number of chars following, since it takes two
- chars to represent a byte.
- o type
- is one of:
- 0) header record
- 1) two byte address data record
- 2) three byte address data record
- 3) four byte address data record
- 7) four byte address termination record
- 8) three byte address termination record
- 9) two byte address termination record
-
- o address
- is the start address of the data following, or in the case of
- a termination record, the start address of the image
- o data
- is the data.
- o checksum
- is the sum of all the raw byte data in the record, from the length
- upwards, modulo 256 and subtracted from 255.
-
-
-SUBSECTION
- Symbol S-Record handling
-
-DESCRIPTION
- Some ICE equipment understands an addition to the standard
- S-Record format; symbols and their addresses can be sent
- before the data.
-
- The format of this is:
- ($$ <modulename>
- (<space> <symbol> <address>)*)
- $$
-
- so a short symbol table could look like:
-
-EXAMPLE
- $$ flash.x
- $$ flash.c
- _port6 $0
- _delay $4
- _start $14
- _etext $8036
- _edata $8036
- _end $8036
- $$
-
-DESCRIPTION
- We allow symbols to be anywhere in the data stream - the module names
- are always ignored.
-
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-#include <ctype.h>
-
-static void srec_init PARAMS ((void));
-static boolean srec_mkobject PARAMS ((bfd *));
-static int srec_get_byte PARAMS ((bfd *, boolean *));
-static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
-static boolean srec_scan PARAMS ((bfd *));
-static const bfd_target *srec_object_p PARAMS ((bfd *));
-static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
-static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
-
-static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
- const bfd_byte *,
- const bfd_byte *));
-static boolean srec_write_header PARAMS ((bfd *));
-static boolean srec_write_symbols PARAMS ((bfd *));
-
-/* Macros for converting between hex and binary. */
-
-static CONST char digs[] = "0123456789ABCDEF";
-
-#define NIBBLE(x) hex_value(x)
-#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
-#define TOHEX(d, x, ch) \
- d[1] = digs[(x) & 0xf]; \
- d[0] = digs[((x)>>4)&0xf]; \
- ch += ((x) & 0xff);
-#define ISHEX(x) hex_p(x)
-
-/* Initialize by filling in the hex conversion array. */
-
-static void
-srec_init ()
-{
- static boolean inited = false;
-
- if (inited == false)
- {
- inited = true;
- hex_init ();
- }
-}
-
-/* The maximum number of bytes on a line is FF */
-#define MAXCHUNK 0xff
-/* The number of bytes we fit onto a line on output */
-#define CHUNK 21
-
-/* When writing an S-record file, the S-records can not be output as
- they are seen. This structure is used to hold them in memory. */
-
-struct srec_data_list_struct
-{
- struct srec_data_list_struct *next;
- bfd_byte *data;
- bfd_vma where;
- bfd_size_type size;
-};
-
-typedef struct srec_data_list_struct srec_data_list_type;
-
-/* When scanning the S-record file, a linked list of srec_symbol
- structures is built to represent the symbol table (if there is
- one). */
-
-struct srec_symbol
-{
- struct srec_symbol *next;
- const char *name;
- bfd_vma val;
-};
-
-/* The S-record tdata information. */
-
-typedef struct srec_data_struct
- {
- srec_data_list_type *head;
- srec_data_list_type *tail;
- unsigned int type;
- struct srec_symbol *symbols;
- struct srec_symbol *symtail;
- asymbol *csymbols;
- }
-tdata_type;
-
-static boolean srec_write_section PARAMS ((bfd *, tdata_type *,
- srec_data_list_type *));
-static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *));
-
-/* Set up the S-record tdata information. */
-
-static boolean
-srec_mkobject (abfd)
- bfd *abfd;
-{
- srec_init ();
-
- if (abfd->tdata.srec_data == NULL)
- {
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
- if (tdata == NULL)
- return false;
- abfd->tdata.srec_data = tdata;
- tdata->type = 1;
- tdata->head = NULL;
- tdata->tail = NULL;
- tdata->symbols = NULL;
- tdata->symtail = NULL;
- tdata->csymbols = NULL;
- }
-
- return true;
-}
-
-/* Read a byte from an S record file. Set *ERRORPTR if an error
- occurred. Return EOF on error or end of file. */
-
-static int
-srec_get_byte (abfd, errorptr)
- bfd *abfd;
- boolean *errorptr;
-{
- bfd_byte c;
-
- if (bfd_read (&c, 1, 1, abfd) != 1)
- {
- if (bfd_get_error () != bfd_error_file_truncated)
- *errorptr = true;
- return EOF;
- }
-
- return (int) (c & 0xff);
-}
-
-/* Report a problem in an S record file. FIXME: This probably should
- not call fprintf, but we really do need some mechanism for printing
- error messages. */
-
-static void
-srec_bad_byte (abfd, lineno, c, error)
- bfd *abfd;
- unsigned int lineno;
- int c;
- boolean error;
-{
- if (c == EOF)
- {
- if (! error)
- bfd_set_error (bfd_error_file_truncated);
- }
- else
- {
- char buf[10];
-
- if (! isprint (c))
- sprintf (buf, "\\%03o", (unsigned int) c);
- else
- {
- buf[0] = c;
- buf[1] = '\0';
- }
- (*_bfd_error_handler)
- ("%s:%d: Unexpected character `%s' in S-record file\n",
- bfd_get_filename (abfd), lineno, buf);
- bfd_set_error (bfd_error_bad_value);
- }
-}
-
-/* Add a new symbol found in an S-record file. */
-
-static boolean
-srec_new_symbol (abfd, name, val)
- bfd *abfd;
- const char *name;
- bfd_vma val;
-{
- struct srec_symbol *n;
-
- n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
- if (n == NULL)
- return false;
-
- n->name = name;
- n->val = val;
-
- if (abfd->tdata.srec_data->symbols == NULL)
- abfd->tdata.srec_data->symbols = n;
- else
- abfd->tdata.srec_data->symtail->next = n;
- abfd->tdata.srec_data->symtail = n;
- n->next = NULL;
-
- ++abfd->symcount;
-
- return true;
-}
-
-/* Read the S record file and turn it into sections. We create a new
- section for each contiguous set of bytes. */
-
-static boolean
-srec_scan (abfd)
- bfd *abfd;
-{
- int c;
- unsigned int lineno = 1;
- boolean error = false;
- bfd_byte *buf = NULL;
- size_t bufsize = 0;
- asection *sec = NULL;
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- while ((c = srec_get_byte (abfd, &error)) != EOF)
- {
- /* We only build sections from contiguous S-records, so if this
- is not an S-record, then stop building a section. */
- if (c != 'S' && c != '\r' && c != '\n')
- sec = NULL;
-
- switch (c)
- {
- default:
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
-
- case '\n':
- ++lineno;
- break;
-
- case '\r':
- break;
-
- case '$':
- /* Starting a module name, which we ignore. */
- while ((c = srec_get_byte (abfd, &error)) != '\n'
- && c != EOF)
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- ++lineno;
-
- break;
-
- case ' ':
- {
- char *symname;
- bfd_vma symval;
-
- /* Starting a symbol definition. */
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && (c == ' ' || c == '\t'))
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- obstack_1grow (&abfd->memory, c);
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && ! isspace (c))
- obstack_1grow (&abfd->memory, c);
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- symname = obstack_finish (&abfd->memory);
- if (symname == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
-
- while ((c = srec_get_byte (abfd, &error)) != EOF
- && (c == ' ' || c == '\t'))
- ;
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- /* Skip a dollar sign before the hex value. */
- if (c == '$')
- {
- c = srec_get_byte (abfd, &error);
- if (c == EOF)
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
- }
-
- symval = 0;
- while (ISHEX (c))
- {
- symval <<= 4;
- symval += NIBBLE (c);
- c = srec_get_byte (abfd, &error);
- }
-
- if (c == EOF || ! isspace (c))
- {
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- if (! srec_new_symbol (abfd, symname, symval))
- goto error_return;
-
- if (c == '\n')
- ++lineno;
-
- }
- break;
-
- case 'S':
- {
- file_ptr pos;
- char hdr[3];
- unsigned int bytes;
- bfd_vma address;
- bfd_byte *data;
-
- /* Starting an S-record. */
-
- pos = bfd_tell (abfd) - 1;
-
- if (bfd_read (hdr, 1, 3, abfd) != 3)
- goto error_return;
-
- if (! ISHEX (hdr[1]) || ! ISHEX (hdr[2]))
- {
- if (! ISHEX (hdr[1]))
- c = hdr[1];
- else
- c = hdr[2];
- srec_bad_byte (abfd, lineno, c, error);
- goto error_return;
- }
-
- bytes = HEX (hdr + 1);
- if (bytes * 2 > bufsize)
- {
- if (buf != NULL)
- free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = bytes * 2;
- }
-
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
- goto error_return;
-
- /* Ignore the checksum byte. */
- --bytes;
-
- address = 0;
- data = buf;
- switch (hdr[0])
- {
- case '0':
- case '5':
- /* Prologue--ignore the file name, but stop building a
- section at this point. */
- sec = NULL;
- break;
-
- case '3':
- address = HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '2':
- address = (address << 8) | HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '1':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
- bytes -= 2;
-
- if (sec != NULL
- && sec->vma + sec->_raw_size == address)
- {
- /* This data goes at the end of the section we are
- currently building. */
- sec->_raw_size += bytes;
- }
- else
- {
- char secbuf[20];
- char *secname;
-
- sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
- strcpy (secname, secbuf);
- sec = bfd_make_section (abfd, secname);
- if (sec == NULL)
- goto error_return;
- sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- sec->vma = address;
- sec->lma = address;
- sec->_raw_size = bytes;
- sec->filepos = pos;
- }
-
- break;
-
- case '7':
- address = HEX (data);
- data += 2;
- /* Fall through. */
- case '8':
- address = (address << 8) | HEX (data);
- data += 2;
- /* Fall through. */
- case '9':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
-
- /* This is a termination record. */
- abfd->start_address = address;
-
- if (buf != NULL)
- free (buf);
-
- return true;
- }
- }
- break;
- }
- }
-
- if (error)
- goto error_return;
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Check whether an existing file is an S-record file. */
-
-static const bfd_target *
-srec_object_p (abfd)
- bfd *abfd;
-{
- bfd_byte b[4];
-
- srec_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
- return NULL;
-
- if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Check whether an existing file is an S-record file with symbols. */
-
-static const bfd_target *
-symbolsrec_object_p (abfd)
- bfd *abfd;
-{
- char b[2];
-
- srec_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 2, abfd) != 2)
- return NULL;
-
- if (b[0] != '$' || b[1] != '$')
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (! srec_mkobject (abfd)
- || ! srec_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-/* Read in the contents of a section in an S-record file. */
-
-static boolean
-srec_read_section (abfd, section, contents)
- bfd *abfd;
- asection *section;
- bfd_byte *contents;
-{
- int c;
- bfd_size_type sofar = 0;
- boolean error = false;
- bfd_byte *buf = NULL;
- size_t bufsize = 0;
-
- if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
- goto error_return;
-
- while ((c = srec_get_byte (abfd, &error)) != EOF)
- {
- bfd_byte hdr[3];
- unsigned int bytes;
- bfd_vma address;
- bfd_byte *data;
-
- if (c == '\r' || c == '\n')
- continue;
-
- /* This is called after srec_scan has already been called, so we
- ought to know the exact format. */
- BFD_ASSERT (c == 'S');
-
- if (bfd_read (hdr, 1, 3, abfd) != 3)
- goto error_return;
-
- BFD_ASSERT (ISHEX (hdr[1]) && ISHEX (hdr[2]));
-
- bytes = HEX (hdr + 1);
-
- if (bytes * 2 > bufsize)
- {
- if (buf != NULL)
- free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
- if (buf == NULL)
- goto error_return;
- bufsize = bytes * 2;
- }
-
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
- goto error_return;
-
- address = 0;
- data = buf;
- switch (hdr[0])
- {
- default:
- BFD_ASSERT (sofar == section->_raw_size);
- if (buf != NULL)
- free (buf);
- return true;
-
- case '3':
- address = HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '2':
- address = (address << 8) | HEX (data);
- data += 2;
- --bytes;
- /* Fall through. */
- case '1':
- address = (address << 8) | HEX (data);
- data += 2;
- address = (address << 8) | HEX (data);
- data += 2;
- bytes -= 2;
-
- if (address != section->vma + sofar)
- {
- /* We've come to the end of this section. */
- BFD_ASSERT (sofar == section->_raw_size);
- if (buf != NULL)
- free (buf);
- return true;
- }
-
- /* Don't consider checksum. */
- --bytes;
-
- while (bytes-- != 0)
- {
- contents[sofar] = HEX (data);
- data += 2;
- ++sofar;
- }
-
- break;
- }
- }
-
- if (error)
- goto error_return;
-
- BFD_ASSERT (sofar == section->_raw_size);
-
- if (buf != NULL)
- free (buf);
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Get the contents of a section in an S-record file. */
-
-static boolean
-srec_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->used_by_bfd == NULL)
- {
- section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
- if (section->used_by_bfd == NULL
- && section->_raw_size != 0)
- return false;
-
- if (! srec_read_section (abfd, section, section->used_by_bfd))
- return false;
- }
-
- memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
- (size_t) count);
-
- return true;
-}
-
-/* we have to save up all the Srecords for a splurge before output */
-
-static boolean
-srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type bytes_to_do;
-{
- tdata_type *tdata = abfd->tdata.srec_data;
- register srec_data_list_type *entry;
-
- entry = ((srec_data_list_type *)
- bfd_alloc (abfd, sizeof (srec_data_list_type)));
- if (entry == NULL)
- return false;
-
- if (bytes_to_do
- && (section->flags & SEC_ALLOC)
- && (section->flags & SEC_LOAD))
- {
- bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
- if (data == NULL)
- return false;
- memcpy ((PTR) data, location, (size_t) bytes_to_do);
-
- if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
- {
-
- }
- else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
- && tdata->type < 2)
- {
- tdata->type = 2;
- }
- else
- {
- tdata->type = 3;
- }
-
- entry->data = data;
- entry->where = section->lma + offset;
- entry->size = bytes_to_do;
-
- /* Sort the records by address. Optimize for the common case of
- adding a record to the end of the list. */
- if (tdata->tail != NULL
- && entry->where >= tdata->tail->where)
- {
- tdata->tail->next = entry;
- entry->next = NULL;
- tdata->tail = entry;
- }
- else
- {
- register srec_data_list_type **look;
-
- for (look = &tdata->head;
- *look != NULL && (*look)->where < entry->where;
- look = &(*look)->next)
- ;
- entry->next = *look;
- *look = entry;
- if (entry->next == NULL)
- tdata->tail = entry;
- }
- }
- return true;
-}
-
-/* Write a record of type, of the supplied number of bytes. The
- supplied bytes and length don't have a checksum. That's worked out
- here
-*/
-static boolean
-srec_write_record (abfd, type, address, data, end)
- bfd *abfd;
- int type;
- bfd_vma address;
- const bfd_byte *data;
- const bfd_byte *end;
-{
- char buffer[MAXCHUNK];
- unsigned int check_sum = 0;
- CONST bfd_byte *src = data;
- char *dst = buffer;
- char *length;
- bfd_size_type wrlen;
-
- *dst++ = 'S';
- *dst++ = '0' + type;
-
- length = dst;
- dst += 2; /* leave room for dst*/
-
- switch (type)
- {
- case 3:
- case 7:
- TOHEX (dst, (address >> 24), check_sum);
- dst += 2;
- case 8:
- case 2:
- TOHEX (dst, (address >> 16), check_sum);
- dst += 2;
- case 9:
- case 1:
- case 0:
- TOHEX (dst, (address >> 8), check_sum);
- dst += 2;
- TOHEX (dst, (address), check_sum);
- dst += 2;
- break;
-
- }
- for (src = data; src < end; src++)
- {
- TOHEX (dst, *src, check_sum);
- dst += 2;
- }
-
- /* Fill in the length */
- TOHEX (length, (dst - length) / 2, check_sum);
- check_sum &= 0xff;
- check_sum = 255 - check_sum;
- TOHEX (dst, check_sum, check_sum);
- dst += 2;
-
- *dst++ = '\r';
- *dst++ = '\n';
- wrlen = dst - buffer;
- if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
- return false;
- return true;
-}
-
-
-
-static boolean
-srec_write_header (abfd)
- bfd *abfd;
-{
- bfd_byte buffer[MAXCHUNK];
- bfd_byte *dst = buffer;
- unsigned int i;
-
- /* I'll put an arbitary 40 char limit on header size */
- for (i = 0; i < 40 && abfd->filename[i]; i++)
- {
- *dst++ = abfd->filename[i];
- }
- return srec_write_record (abfd, 0, 0, buffer, dst);
-}
-
-static boolean
-srec_write_section (abfd, tdata, list)
- bfd *abfd;
- tdata_type *tdata;
- srec_data_list_type *list;
-{
- unsigned int bytes_written = 0;
- bfd_byte *location = list->data;
-
- while (bytes_written < list->size)
- {
- bfd_vma address;
-
- unsigned int bytes_this_chunk = list->size - bytes_written;
-
- if (bytes_this_chunk > CHUNK)
- {
- bytes_this_chunk = CHUNK;
- }
-
- address = list->where + bytes_written;
-
- if (! srec_write_record (abfd,
- tdata->type,
- address,
- location,
- location + bytes_this_chunk))
- return false;
-
- bytes_written += bytes_this_chunk;
- location += bytes_this_chunk;
- }
-
- return true;
-}
-
-static boolean
-srec_write_terminator (abfd, tdata)
- bfd *abfd;
- tdata_type *tdata;
-{
- bfd_byte buffer[2];
-
- return srec_write_record (abfd, 10 - tdata->type,
- abfd->start_address, buffer, buffer);
-}
-
-
-
-static boolean
-srec_write_symbols (abfd)
- bfd *abfd;
-{
- char buffer[MAXCHUNK];
- /* Dump out the symbols of a bfd */
- int i;
- int count = bfd_get_symcount (abfd);
-
- if (count)
- {
- size_t len;
- asymbol **table = bfd_get_outsymbols (abfd);
- sprintf (buffer, "$$ %s\r\n", abfd->filename);
-
- len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
- return false;
-
- for (i = 0; i < count; i++)
- {
- asymbol *s = table[i];
-#if 0
- int len = strlen (s->name);
-
- /* If this symbol has a .[ocs] in it, it's probably a file name
- and we'll output that as the module name */
-
- if (len > 3 && s->name[len - 2] == '.')
- {
- int l;
- sprintf (buffer, "$$ %s\r\n", s->name);
- l = strlen (buffer);
- if (bfd_write (buffer, l, 1, abfd) != l)
- return false;
- }
- else
-#endif
- if (s->flags & (BSF_GLOBAL | BSF_LOCAL)
- && (s->flags & BSF_DEBUGGING) == 0
- && s->name[0] != '.'
- && s->name[0] != 't')
- {
- /* Just dump out non debug symbols */
- bfd_size_type l;
- char buf2[40], *p;
-
- sprintf_vma (buf2,
- s->value + s->section->output_section->lma
- + s->section->output_offset);
- p = buf2;
- while (p[0] == '0' && p[1] != 0)
- p++;
- sprintf (buffer, " %s $%s\r\n", s->name, p);
- l = strlen (buffer);
- if (bfd_write (buffer, l, 1, abfd) != l)
- return false;
- }
- }
- sprintf (buffer, "$$ \r\n");
- len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
- return false;
- }
-
- return true;
-}
-
-static boolean
-internal_srec_write_object_contents (abfd, symbols)
- bfd *abfd;
- int symbols;
-{
- tdata_type *tdata = abfd->tdata.srec_data;
- srec_data_list_type *list;
-
- if (symbols)
- {
- if (! srec_write_symbols (abfd))
- return false;
- }
-
- if (! srec_write_header (abfd))
- return false;
-
- /* Now wander though all the sections provided and output them */
- list = tdata->head;
-
- while (list != (srec_data_list_type *) NULL)
- {
- if (! srec_write_section (abfd, tdata, list))
- return false;
- list = list->next;
- }
- return srec_write_terminator (abfd, tdata);
-}
-
-static boolean
-srec_write_object_contents (abfd)
- bfd *abfd;
-{
- return internal_srec_write_object_contents (abfd, 0);
-}
-
-static boolean
-symbolsrec_write_object_contents (abfd)
- bfd *abfd;
-{
- return internal_srec_write_object_contents (abfd, 1);
-}
-
-/*ARGSUSED*/
-static int
-srec_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-static asymbol *
-srec_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-/* Return the amount of memory needed to read the symbol table. */
-
-static long
-srec_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
-}
-
-/* Return the symbol table. */
-
-static long
-srec_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int symcount = bfd_get_symcount (abfd);
- asymbol *csymbols;
- unsigned int i;
-
- csymbols = abfd->tdata.srec_data->csymbols;
- if (csymbols == NULL)
- {
- asymbol *c;
- struct srec_symbol *s;
-
- csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
- if (csymbols == NULL && symcount != 0)
- return false;
- abfd->tdata.srec_data->csymbols = csymbols;
-
- for (s = abfd->tdata.srec_data->symbols, c = csymbols;
- s != NULL;
- s = s->next, ++c)
- {
- c->the_bfd = abfd;
- c->name = s->name;
- c->value = s->val;
- c->flags = BSF_GLOBAL;
- c->section = bfd_abs_section_ptr;
- c->udata.p = NULL;
- }
- }
-
- for (i = 0; i < symcount; i++)
- *alocation++ = csymbols++;
- *alocation = NULL;
-
- return symcount;
-}
-
-/*ARGSUSED*/
-void
-srec_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/*ARGSUSED*/
-void
-srec_print_symbol (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) afile;
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- default:
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %-5s %s",
- symbol->section->name,
- symbol->name);
-
- }
-}
-
-#define srec_close_and_cleanup _bfd_generic_close_and_cleanup
-#define srec_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define srec_new_section_hook _bfd_generic_new_section_hook
-
-#define srec_bfd_is_local_label bfd_generic_is_local_label
-#define srec_get_lineno _bfd_nosymbols_get_lineno
-#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define srec_read_minisymbols _bfd_generic_read_minisymbols
-#define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define srec_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
-#define srec_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
-#define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define srec_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define srec_set_arch_mach bfd_default_set_arch_mach
-
-#define srec_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define srec_bfd_relax_section bfd_generic_relax_section
-#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define srec_bfd_final_link _bfd_generic_final_link
-#define srec_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target srec_vec =
-{
- "srec", /* name */
- bfd_target_srec_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {
- _bfd_dummy_target,
- srec_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- srec_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- srec_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (srec),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (srec),
- BFD_JUMP_TABLE_RELOCS (srec),
- BFD_JUMP_TABLE_WRITE (srec),
- BFD_JUMP_TABLE_LINK (srec),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
-
-
-
-const bfd_target symbolsrec_vec =
-{
- "symbolsrec", /* name */
- bfd_target_srec_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {
- _bfd_dummy_target,
- symbolsrec_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- srec_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- symbolsrec_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (srec),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (srec),
- BFD_JUMP_TABLE_RELOCS (srec),
- BFD_JUMP_TABLE_WRITE (srec),
- BFD_JUMP_TABLE_LINK (srec),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/stab-syms.c b/contrib/gdb/bfd/stab-syms.c
deleted file mode 100644
index f4fe6c8..0000000
--- a/contrib/gdb/bfd/stab-syms.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Table of stab names for the BFD library.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-
-#define ARCH_SIZE 32 /* Value doesn't matter. */
-#include "libaout.h"
-#include "aout/aout64.h"
-
-/* Ignore duplicate stab codes; just return the string for the first
- one. */
-#define __define_stab(NAME, CODE, STRING) __define_name(CODE, STRING)
-#define __define_stab_duplicate(NAME, CODE, STRING)
-
-/* These are not really stab symbols, but it is
- convenient to have them here for the sake of nm.
- For completeness, we could also add N_TEXT etc, but those
- are never needed, since nm treats those specially. */
-#define EXTRA_SYMBOLS \
- __define_name (N_SETA, "SETA")/* Absolute set element symbol */ \
- __define_name (N_SETT, "SETT")/* Text set element symbol */ \
- __define_name (N_SETD, "SETD")/* Data set element symbol */ \
- __define_name (N_SETB, "SETB")/* Bss set element symbol */ \
- __define_name (N_SETV, "SETV")/* Pointer to set vector in data area. */ \
- __define_name (N_INDR, "INDR") \
- __define_name (N_WARNING, "WARNING")
-
-const char *
-bfd_get_stab_name (code)
- int code;
-{
- switch (code)
- {
-#define __define_name(val, str) case val: return str;
-#include "aout/stab.def"
- EXTRA_SYMBOLS
- }
-
- return (const char *) 0;
-}
diff --git a/contrib/gdb/bfd/syms.c b/contrib/gdb/bfd/syms.c
deleted file mode 100644
index e3007e4..0000000
--- a/contrib/gdb/bfd/syms.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* Generic symbol-table support for the BFD library.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SECTION
- Symbols
-
- BFD tries to maintain as much symbol information as it can when
- it moves information from file to file. BFD passes information
- to applications though the <<asymbol>> structure. When the
- application requests the symbol table, BFD reads the table in
- the native form and translates parts of it into the internal
- format. To maintain more than the information passed to
- applications, some targets keep some information ``behind the
- scenes'' in a structure only the particular back end knows
- about. For example, the coff back end keeps the original
- symbol table structure as well as the canonical structure when
- a BFD is read in. On output, the coff back end can reconstruct
- the output symbol table so that no information is lost, even
- information unique to coff which BFD doesn't know or
- understand. If a coff symbol table were read, but were written
- through an a.out back end, all the coff specific information
- would be lost. The symbol table of a BFD
- is not necessarily read in until a canonicalize request is
- made. Then the BFD back end fills in a table provided by the
- application with pointers to the canonical information. To
- output symbols, the application provides BFD with a table of
- pointers to pointers to <<asymbol>>s. This allows applications
- like the linker to output a symbol as it was read, since the ``behind
- the scenes'' information will be still available.
-@menu
-@* Reading Symbols::
-@* Writing Symbols::
-@* Mini Symbols::
-@* typedef asymbol::
-@* symbol handling functions::
-@end menu
-
-INODE
-Reading Symbols, Writing Symbols, Symbols, Symbols
-SUBSECTION
- Reading symbols
-
- There are two stages to reading a symbol table from a BFD:
- allocating storage, and the actual reading process. This is an
- excerpt from an application which reads the symbol table:
-
-| long storage_needed;
-| asymbol **symbol_table;
-| long number_of_symbols;
-| long i;
-|
-| storage_needed = bfd_get_symtab_upper_bound (abfd);
-|
-| if (storage_needed < 0)
-| FAIL
-|
-| if (storage_needed == 0) {
-| return ;
-| }
-| symbol_table = (asymbol **) xmalloc (storage_needed);
-| ...
-| number_of_symbols =
-| bfd_canonicalize_symtab (abfd, symbol_table);
-|
-| if (number_of_symbols < 0)
-| FAIL
-|
-| for (i = 0; i < number_of_symbols; i++) {
-| process_symbol (symbol_table[i]);
-| }
-
- All storage for the symbols themselves is in an obstack
- connected to the BFD; it is freed when the BFD is closed.
-
-
-INODE
-Writing Symbols, Mini Symbols, Reading Symbols, Symbols
-SUBSECTION
- Writing symbols
-
- Writing of a symbol table is automatic when a BFD open for
- writing is closed. The application attaches a vector of
- pointers to pointers to symbols to the BFD being written, and
- fills in the symbol count. The close and cleanup code reads
- through the table provided and performs all the necessary
- operations. The BFD output code must always be provided with an
- ``owned'' symbol: one which has come from another BFD, or one
- which has been created using <<bfd_make_empty_symbol>>. Here is an
- example showing the creation of a symbol table with only one element:
-
-| #include "bfd.h"
-| main()
-| {
-| bfd *abfd;
-| asymbol *ptrs[2];
-| asymbol *new;
-|
-| abfd = bfd_openw("foo","a.out-sunos-big");
-| bfd_set_format(abfd, bfd_object);
-| new = bfd_make_empty_symbol(abfd);
-| new->name = "dummy_symbol";
-| new->section = bfd_make_section_old_way(abfd, ".text");
-| new->flags = BSF_GLOBAL;
-| new->value = 0x12345;
-|
-| ptrs[0] = new;
-| ptrs[1] = (asymbol *)0;
-|
-| bfd_set_symtab(abfd, ptrs, 1);
-| bfd_close(abfd);
-| }
-|
-| ./makesym
-| nm foo
-| 00012345 A dummy_symbol
-
- Many formats cannot represent arbitary symbol information; for
- instance, the <<a.out>> object format does not allow an
- arbitary number of sections. A symbol pointing to a section
- which is not one of <<.text>>, <<.data>> or <<.bss>> cannot
- be described.
-
-INODE
-Mini Symbols, typedef asymbol, Writing Symbols, Symbols
-SUBSECTION
- Mini Symbols
-
- Mini symbols provide read-only access to the symbol table.
- They use less memory space, but require more time to access.
- They can be useful for tools like nm or objdump, which may
- have to handle symbol tables of extremely large executables.
-
- The <<bfd_read_minisymbols>> function will read the symbols
- into memory in an internal form. It will return a <<void *>>
- pointer to a block of memory, a symbol count, and the size of
- each symbol. The pointer is allocated using <<malloc>>, and
- should be freed by the caller when it is no longer needed.
-
- The function <<bfd_minisymbol_to_symbol>> will take a pointer
- to a minisymbol, and a pointer to a structure returned by
- <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
- The return value may or may not be the same as the value from
- <<bfd_make_empty_symbol>> which was passed in.
-
-*/
-
-
-
-/*
-DOCDD
-INODE
-typedef asymbol, symbol handling functions, Mini Symbols, Symbols
-
-*/
-/*
-SUBSECTION
- typedef asymbol
-
- An <<asymbol>> has the form:
-
-*/
-
-/*
-CODE_FRAGMENT
-
-.
-.typedef struct symbol_cache_entry
-.{
-. {* A pointer to the BFD which owns the symbol. This information
-. is necessary so that a back end can work out what additional
-. information (invisible to the application writer) is carried
-. with the symbol.
-.
-. This field is *almost* redundant, since you can use section->owner
-. instead, except that some symbols point to the global sections
-. bfd_{abs,com,und}_section. This could be fixed by making
-. these globals be per-bfd (or per-target-flavor). FIXME. *}
-.
-. struct _bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *}
-.
-. {* The text of the symbol. The name is left alone, and not copied; the
-. application may not alter it. *}
-. CONST char *name;
-.
-. {* The value of the symbol. This really should be a union of a
-. numeric value with a pointer, since some flags indicate that
-. a pointer to another symbol is stored here. *}
-. symvalue value;
-.
-. {* Attributes of a symbol: *}
-.
-.#define BSF_NO_FLAGS 0x00
-.
-. {* The symbol has local scope; <<static>> in <<C>>. The value
-. is the offset into the section of the data. *}
-.#define BSF_LOCAL 0x01
-.
-. {* The symbol has global scope; initialized data in <<C>>. The
-. value is the offset into the section of the data. *}
-.#define BSF_GLOBAL 0x02
-.
-. {* The symbol has global scope and is exported. The value is
-. the offset into the section of the data. *}
-.#define BSF_EXPORT BSF_GLOBAL {* no real difference *}
-.
-. {* A normal C symbol would be one of:
-. <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
-. <<BSF_GLOBAL>> *}
-.
-. {* The symbol is a debugging record. The value has an arbitary
-. meaning. *}
-.#define BSF_DEBUGGING 0x08
-.
-. {* The symbol denotes a function entry point. Used in ELF,
-. perhaps others someday. *}
-.#define BSF_FUNCTION 0x10
-.
-. {* Used by the linker. *}
-.#define BSF_KEEP 0x20
-.#define BSF_KEEP_G 0x40
-.
-. {* A weak global symbol, overridable without warnings by
-. a regular global symbol of the same name. *}
-.#define BSF_WEAK 0x80
-.
-. {* This symbol was created to point to a section, e.g. ELF's
-. STT_SECTION symbols. *}
-.#define BSF_SECTION_SYM 0x100
-.
-. {* The symbol used to be a common symbol, but now it is
-. allocated. *}
-.#define BSF_OLD_COMMON 0x200
-.
-. {* The default value for common data. *}
-.#define BFD_FORT_COMM_DEFAULT_VALUE 0
-.
-. {* In some files the type of a symbol sometimes alters its
-. location in an output file - ie in coff a <<ISFCN>> symbol
-. which is also <<C_EXT>> symbol appears where it was
-. declared and not at the end of a section. This bit is set
-. by the target BFD part to convey this information. *}
-.
-.#define BSF_NOT_AT_END 0x400
-.
-. {* Signal that the symbol is the label of constructor section. *}
-.#define BSF_CONSTRUCTOR 0x800
-.
-. {* Signal that the symbol is a warning symbol. The name is a
-. warning. The name of the next symbol is the one to warn about;
-. if a reference is made to a symbol with the same name as the next
-. symbol, a warning is issued by the linker. *}
-.#define BSF_WARNING 0x1000
-.
-. {* Signal that the symbol is indirect. This symbol is an indirect
-. pointer to the symbol with the same name as the next symbol. *}
-.#define BSF_INDIRECT 0x2000
-.
-. {* BSF_FILE marks symbols that contain a file name. This is used
-. for ELF STT_FILE symbols. *}
-.#define BSF_FILE 0x4000
-.
-. {* Symbol is from dynamic linking information. *}
-.#define BSF_DYNAMIC 0x8000
-.
-. {* The symbol denotes a data object. Used in ELF, and perhaps
-. others someday. *}
-.#define BSF_OBJECT 0x10000
-.
-. flagword flags;
-.
-. {* A pointer to the section to which this symbol is
-. relative. This will always be non NULL, there are special
-. sections for undefined and absolute symbols. *}
-. struct sec *section;
-.
-. {* Back end special data. *}
-. union
-. {
-. PTR p;
-. bfd_vma i;
-. } udata;
-.
-.} asymbol;
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "aout/stab_gnu.h"
-
-/*
-DOCDD
-INODE
-symbol handling functions, , typedef asymbol, Symbols
-SUBSECTION
- Symbol handling functions
-*/
-
-/*
-FUNCTION
- bfd_get_symtab_upper_bound
-
-DESCRIPTION
- Return the number of bytes required to store a vector of pointers
- to <<asymbols>> for all the symbols in the BFD @var{abfd},
- including a terminal NULL pointer. If there are no symbols in
- the BFD, then return 0. If an error occurs, return -1.
-
-.#define bfd_get_symtab_upper_bound(abfd) \
-. BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
-
-*/
-
-/*
-FUNCTION
- bfd_is_local_label
-
-SYNOPSIS
- boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
-
-DESCRIPTION
- Return true if the given symbol @var{sym} in the BFD @var{abfd} is
- a compiler generated local label, else return false.
-.#define bfd_is_local_label(abfd, sym) \
-. BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym))
-*/
-
-/*
-FUNCTION
- bfd_canonicalize_symtab
-
-DESCRIPTION
- Read the symbols from the BFD @var{abfd}, and fills in
- the vector @var{location} with pointers to the symbols and
- a trailing NULL.
- Return the actual number of symbol pointers, not
- including the NULL.
-
-
-.#define bfd_canonicalize_symtab(abfd, location) \
-. BFD_SEND (abfd, _bfd_canonicalize_symtab,\
-. (abfd, location))
-
-*/
-
-
-/*
-FUNCTION
- bfd_set_symtab
-
-SYNOPSIS
- boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
-
-DESCRIPTION
- Arrange that when the output BFD @var{abfd} is closed,
- the table @var{location} of @var{count} pointers to symbols
- will be written.
-*/
-
-boolean
-bfd_set_symtab (abfd, location, symcount)
- bfd *abfd;
- asymbol **location;
- unsigned int symcount;
-{
- if ((abfd->format != bfd_object) || (bfd_read_p (abfd)))
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- bfd_get_outsymbols (abfd) = location;
- bfd_get_symcount (abfd) = symcount;
- return true;
-}
-
-/*
-FUNCTION
- bfd_print_symbol_vandf
-
-SYNOPSIS
- void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
-
-DESCRIPTION
- Print the value and flags of the @var{symbol} supplied to the
- stream @var{file}.
-*/
-void
-bfd_print_symbol_vandf (arg, symbol)
- PTR arg;
- asymbol *symbol;
-{
- FILE *file = (FILE *) arg;
- flagword type = symbol->flags;
- if (symbol->section != (asection *) NULL)
- {
- fprintf_vma (file, symbol->value + symbol->section->vma);
- }
- else
- {
- fprintf_vma (file, symbol->value);
- }
-
- /* This presumes that a symbol can not be both BSF_DEBUGGING and
- BSF_DYNAMIC, nor more than one of BSF_FUNCTION, BSF_FILE, and
- BSF_OBJECT. */
- fprintf (file, " %c%c%c%c%c%c%c",
- ((type & BSF_LOCAL)
- ? (type & BSF_GLOBAL) ? '!' : 'l'
- : (type & BSF_GLOBAL) ? 'g' : ' '),
- (type & BSF_WEAK) ? 'w' : ' ',
- (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
- (type & BSF_WARNING) ? 'W' : ' ',
- (type & BSF_INDIRECT) ? 'I' : ' ',
- (type & BSF_DEBUGGING) ? 'd' : (type & BSF_DYNAMIC) ? 'D' : ' ',
- ((type & BSF_FUNCTION)
- ? 'F'
- : ((type & BSF_FILE)
- ? 'f'
- : ((type & BSF_OBJECT) ? 'O' : ' '))));
-}
-
-
-/*
-FUNCTION
- bfd_make_empty_symbol
-
-DESCRIPTION
- Create a new <<asymbol>> structure for the BFD @var{abfd}
- and return a pointer to it.
-
- This routine is necessary because each back end has private
- information surrounding the <<asymbol>>. Building your own
- <<asymbol>> and pointing to it will not create the private
- information, and will cause problems later on.
-
-.#define bfd_make_empty_symbol(abfd) \
-. BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
-*/
-
-/*
-FUNCTION
- bfd_make_debug_symbol
-
-DESCRIPTION
- Create a new <<asymbol>> structure for the BFD @var{abfd},
- to be used as a debugging symbol. Further details of its use have
- yet to be worked out.
-
-.#define bfd_make_debug_symbol(abfd,ptr,size) \
-. BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
-*/
-
-struct section_to_type
-{
- CONST char *section;
- char type;
-};
-
-/* Map section names to POSIX/BSD single-character symbol types.
- This table is probably incomplete. It is sorted for convenience of
- adding entries. Since it is so short, a linear search is used. */
-static CONST struct section_to_type stt[] =
-{
- {"*DEBUG*", 'N'},
- {".bss", 'b'},
- {"zerovars", 'b'}, /* MRI .bss */
- {".data", 'd'},
- {"vars", 'd'}, /* MRI .data */
- {".rdata", 'r'}, /* Read only data. */
- {".rodata", 'r'}, /* Read only data. */
- {".sbss", 's'}, /* Small BSS (uninitialized data). */
- {".scommon", 'c'}, /* Small common. */
- {".sdata", 'g'}, /* Small initialized data. */
- {".text", 't'},
- {"code", 't'}, /* MRI .text */
- {0, 0}
-};
-
-/* Return the single-character symbol type corresponding to
- section S, or '?' for an unknown COFF section.
-
- Check for any leading string which matches, so .text5 returns
- 't' as well as .text */
-
-static char
-coff_section_type (s)
- char *s;
-{
- CONST struct section_to_type *t;
-
- for (t = &stt[0]; t->section; t++)
- if (!strncmp (s, t->section, strlen (t->section)))
- return t->type;
-
- return '?';
-}
-
-#ifndef islower
-#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#endif
-#ifndef toupper
-#define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
-#endif
-
-/*
-FUNCTION
- bfd_decode_symclass
-
-DESCRIPTION
- Return a character corresponding to the symbol
- class of @var{symbol}, or '?' for an unknown class.
-
-SYNOPSIS
- int bfd_decode_symclass(asymbol *symbol);
-*/
-int
-bfd_decode_symclass (symbol)
- asymbol *symbol;
-{
- char c;
-
- if (bfd_is_com_section (symbol->section))
- return 'C';
- if (bfd_is_und_section (symbol->section))
- return 'U';
- if (bfd_is_ind_section (symbol->section))
- return 'I';
- if (symbol->flags & BSF_WEAK)
- return 'W';
- if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
- return '?';
-
- if (bfd_is_abs_section (symbol->section))
- c = 'a';
- else if (symbol->section)
- c = coff_section_type (symbol->section->name);
- else
- return '?';
- if (symbol->flags & BSF_GLOBAL)
- c = toupper (c);
- return c;
-
- /* We don't have to handle these cases just yet, but we will soon:
- N_SETV: 'v';
- N_SETA: 'l';
- N_SETT: 'x';
- N_SETD: 'z';
- N_SETB: 's';
- N_INDR: 'i';
- */
-}
-
-/*
-FUNCTION
- bfd_symbol_info
-
-DESCRIPTION
- Fill in the basic info about symbol that nm needs.
- Additional info may be added by the back-ends after
- calling this function.
-
-SYNOPSIS
- void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
-*/
-
-void
-bfd_symbol_info (symbol, ret)
- asymbol *symbol;
- symbol_info *ret;
-{
- ret->type = bfd_decode_symclass (symbol);
- if (ret->type != 'U')
- ret->value = symbol->value + symbol->section->vma;
- else
- ret->value = 0;
- ret->name = symbol->name;
-}
-
-void
-bfd_symbol_is_absolute ()
-{
- abort ();
-}
-
-/*
-FUNCTION
- bfd_copy_private_symbol_data
-
-SYNOPSIS
- boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
-
-DESCRIPTION
- Copy private symbol information from @var{isym} in the BFD
- @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
- Return <<true>> on success, <<false>> on error. Possible error
- returns are:
-
- o <<bfd_error_no_memory>> -
- Not enough memory exists to create private data for @var{osec}.
-
-.#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
-. BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \
-. (ibfd, isymbol, obfd, osymbol))
-
-*/
-
-/* The generic version of the function which returns mini symbols.
- This is used when the backend does not provide a more efficient
- version. It just uses BFD asymbol structures as mini symbols. */
-
-long
-_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
- bfd *abfd;
- boolean dynamic;
- PTR *minisymsp;
- unsigned int *sizep;
-{
- long storage;
- asymbol **syms = NULL;
- long symcount;
-
- if (dynamic)
- storage = bfd_get_dynamic_symtab_upper_bound (abfd);
- else
- storage = bfd_get_symtab_upper_bound (abfd);
- if (storage < 0)
- goto error_return;
-
- syms = (asymbol **) bfd_malloc ((size_t) storage);
- if (syms == NULL)
- goto error_return;
-
- if (dynamic)
- symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
- else
- symcount = bfd_canonicalize_symtab (abfd, syms);
- if (symcount < 0)
- goto error_return;
-
- *minisymsp = (PTR) syms;
- *sizep = sizeof (asymbol *);
- return symcount;
-
- error_return:
- if (syms != NULL)
- free (syms);
- return -1;
-}
-
-/* The generic version of the function which converts a minisymbol to
- an asymbol. We don't worry about the sym argument we are passed;
- we just return the asymbol the minisymbol points to. */
-
-/*ARGSUSED*/
-asymbol *
-_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
- bfd *abfd;
- boolean dynamic;
- const PTR minisym;
- asymbol *sym;
-{
- return *(asymbol **) minisym;
-}
-
-/* Look through stabs debugging information in .stab and .stabstr
- sections to find the source file and line closest to a desired
- location. This is used by COFF and ELF targets. It sets *pfound
- to true if it finds some information. The *pinfo field is used to
- pass cached information in and out of this routine; this first time
- the routine is called for a BFD, *pinfo should be NULL. The value
- placed in *pinfo should be saved with the BFD, and passed back each
- time this function is called. */
-
-/* A pointer to this structure is stored in *pinfo. */
-
-struct stab_find_info
-{
- /* The .stab section. */
- asection *stabsec;
- /* The .stabstr section. */
- asection *strsec;
- /* The contents of the .stab section. */
- bfd_byte *stabs;
- /* The contents of the .stabstr section. */
- bfd_byte *strs;
- /* An malloc buffer to hold the file name. */
- char *filename;
- /* Cached values to restart quickly. */
- bfd_vma cached_offset;
- bfd_byte *cached_stab;
- bfd_byte *cached_str;
- bfd_size_type cached_stroff;
-};
-
-boolean
-_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
- pfilename, pfnname, pline, pinfo)
- bfd *abfd;
- asymbol **symbols;
- asection *section;
- bfd_vma offset;
- boolean *pfound;
- const char **pfilename;
- const char **pfnname;
- unsigned int *pline;
- PTR *pinfo;
-{
- struct stab_find_info *info;
- bfd_size_type stabsize, strsize;
- bfd_byte *stab, *stabend, *str;
- bfd_size_type stroff;
- bfd_vma fnaddr;
- char *directory_name, *main_file_name, *current_file_name, *line_file_name;
- char *fnname;
- bfd_vma low_func_vma, low_line_vma;
-
- *pfound = false;
- *pfilename = bfd_get_filename (abfd);
- *pfnname = NULL;
- *pline = 0;
-
- info = (struct stab_find_info *) *pinfo;
- if (info != NULL)
- {
- if (info->stabsec == NULL || info->strsec == NULL)
- {
- /* No stabs debugging information. */
- return true;
- }
-
- stabsize = info->stabsec->_raw_size;
- strsize = info->strsec->_raw_size;
- }
- else
- {
- long reloc_size, reloc_count;
- arelent **reloc_vector;
-
- info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
- if (info == NULL)
- return false;
-
- /* FIXME: When using the linker --split-by-file or
- --split-by-reloc options, it is possible for the .stab and
- .stabstr sections to be split. We should handle that. */
-
- info->stabsec = bfd_get_section_by_name (abfd, ".stab");
- info->strsec = bfd_get_section_by_name (abfd, ".stabstr");
-
- if (info->stabsec == NULL || info->strsec == NULL)
- {
- /* No stabs debugging information. Set *pinfo so that we
- can return quickly in the info != NULL case above. */
- *pinfo = (PTR) info;
- return true;
- }
-
- stabsize = info->stabsec->_raw_size;
- strsize = info->strsec->_raw_size;
-
- info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
- info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
- if (info->stabs == NULL || info->strs == NULL)
- return false;
-
- if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
- stabsize)
- || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
- strsize))
- return false;
-
- /* If this is a relocateable object file, we have to relocate
- the entries in .stab. This should always be simple 32 bit
- relocations against symbols defined in this object file, so
- this should be no big deal. */
- reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
- if (reloc_size < 0)
- return false;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- return false;
- reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
- symbols);
- if (reloc_count < 0)
- {
- if (reloc_vector != NULL)
- free (reloc_vector);
- return false;
- }
- if (reloc_count > 0)
- {
- arelent **pr;
-
- for (pr = reloc_vector; *pr != NULL; pr++)
- {
- arelent *r;
- unsigned long val;
- asymbol *sym;
-
- r = *pr;
- if (r->howto->rightshift != 0
- || r->howto->size != 2
- || r->howto->bitsize != 32
- || r->howto->pc_relative
- || r->howto->bitpos != 0
- || r->howto->dst_mask != 0xffffffff)
- {
- (*_bfd_error_handler)
- ("Unsupported .stab relocation");
- bfd_set_error (bfd_error_invalid_operation);
- if (reloc_vector != NULL)
- free (reloc_vector);
- return false;
- }
-
- val = bfd_get_32 (abfd, info->stabs + r->address);
- val &= r->howto->src_mask;
- sym = *r->sym_ptr_ptr;
- val += sym->value + sym->section->vma + r->addend;
- bfd_put_32 (abfd, val, info->stabs + r->address);
- }
- }
-
- if (reloc_vector != NULL)
- free (reloc_vector);
-
- *pinfo = (PTR) info;
- }
-
- /* We are passed a section relative offset. The offsets in the
- stabs information are absolute. */
- offset += bfd_get_section_vma (abfd, section);
-
- /* Stabs entries use a 12 byte format:
- 4 byte string table index
- 1 byte stab type
- 1 byte stab other field
- 2 byte stab desc field
- 4 byte stab value
- FIXME: This will have to change for a 64 bit object format.
-
- The stabs symbols are divided into compilation units. For the
- first entry in each unit, the type of 0, the value is the length
- of the string table for this unit, and the desc field is the
- number of stabs symbols for this unit. */
-
-#define STRDXOFF (0)
-#define TYPEOFF (4)
-#define OTHEROFF (5)
-#define DESCOFF (6)
-#define VALOFF (8)
-#define STABSIZE (12)
-
- /* It would be nice if we could skip ahead to the stabs symbols for
- the next compilation unit to quickly scan through the compilation
- units. Unfortunately, since each line number gets a separate
- stabs entry, it is entirely plausible that a large source file
- will overflow the 16 bit count of stabs entries. */
- fnaddr = 0;
- directory_name = NULL;
- main_file_name = NULL;
- current_file_name = NULL;
- line_file_name = NULL;
- fnname = NULL;
- low_func_vma = 0;
- low_line_vma = 0;
-
- stabend = info->stabs + stabsize;
-
- if (info->cached_stab == NULL || offset < info->cached_offset)
- {
- stab = info->stabs;
- str = info->strs;
- stroff = 0;
- }
- else
- {
- stab = info->cached_stab;
- str = info->cached_str;
- stroff = info->cached_stroff;
- }
-
- info->cached_offset = offset;
-
- for (; stab < stabend; stab += STABSIZE)
- {
- boolean done;
- bfd_vma val;
- char *name;
-
- done = false;
-
- switch (stab[TYPEOFF])
- {
- case 0:
- /* This is the first entry in a compilation unit. */
- if ((bfd_size_type) ((info->strs + strsize) - str) < stroff)
- {
- done = true;
- break;
- }
- str += stroff;
- stroff = bfd_get_32 (abfd, stab + VALOFF);
- break;
-
- case N_SO:
- /* The main file name. */
-
- val = bfd_get_32 (abfd, stab + VALOFF);
- if (val > offset)
- {
- done = true;
- break;
- }
-
- name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
-
- /* An empty string indicates the end of the compilation
- unit. */
- if (*name == '\0')
- {
- /* If there are functions in different sections, they
- may have addresses larger than val, but we don't want
- to forget the file name. When there are functions in
- different cases, there is supposed to be an N_FUN at
- the end of the function indicating where it ends. */
- if (low_func_vma < val || fnname == NULL)
- main_file_name = NULL;
- break;
- }
-
- /* We know that we have to get to at least this point in the
- stabs entries for this offset. */
- info->cached_stab = stab;
- info->cached_str = str;
- info->cached_stroff = stroff;
-
- current_file_name = name;
-
- /* Look ahead to the next symbol. Two consecutive N_SO
- symbols are a directory and a file name. */
- if (stab + STABSIZE >= stabend
- || *(stab + STABSIZE + TYPEOFF) != N_SO)
- directory_name = NULL;
- else
- {
- stab += STABSIZE;
- directory_name = current_file_name;
- current_file_name = ((char *) str
- + bfd_get_32 (abfd, stab + STRDXOFF));
- }
-
- main_file_name = current_file_name;
-
- break;
-
- case N_SOL:
- /* The name of an include file. */
- current_file_name = ((char *) str
- + bfd_get_32 (abfd, stab + STRDXOFF));
- break;
-
- case N_SLINE:
- case N_DSLINE:
- case N_BSLINE:
- /* A line number. The value is relative to the start of the
- current function. */
- val = fnaddr + bfd_get_32 (abfd, stab + VALOFF);
- if (val >= low_line_vma && val <= offset)
- {
- *pline = bfd_get_16 (abfd, stab + DESCOFF);
- low_line_vma = val;
- line_file_name = current_file_name;
- }
- break;
-
- case N_FUN:
- /* A function name. */
- val = bfd_get_32 (abfd, stab + VALOFF);
- name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
-
- /* An empty string here indicates the end of a function, and
- the value is relative to fnaddr. */
-
- if (*name == '\0')
- {
- val += fnaddr;
- if (val >= low_func_vma && val < offset)
- fnname = NULL;
- }
- else
- {
- if (val >= low_func_vma && val <= offset)
- {
- fnname = name;
- low_func_vma = val;
- }
-
- fnaddr = val;
- }
-
- break;
- }
-
- if (done)
- break;
- }
-
- if (main_file_name == NULL)
- {
- /* No information found. */
- return true;
- }
-
- *pfound = true;
-
- if (*pline != 0)
- main_file_name = line_file_name;
-
- if (main_file_name != NULL)
- {
- if (main_file_name[0] == '/' || directory_name == NULL)
- *pfilename = main_file_name;
- else
- {
- size_t dirlen;
-
- dirlen = strlen (directory_name);
- if (info->filename == NULL
- || strncmp (info->filename, directory_name, dirlen) != 0
- || strcmp (info->filename + dirlen, main_file_name) != 0)
- {
- if (info->filename != NULL)
- free (info->filename);
- info->filename = (char *) bfd_malloc (dirlen +
- strlen (main_file_name)
- + 1);
- if (info->filename == NULL)
- return false;
- strcpy (info->filename, directory_name);
- strcpy (info->filename + dirlen, main_file_name);
- }
-
- *pfilename = info->filename;
- }
- }
-
- if (fnname != NULL)
- {
- char *s;
-
- /* This will typically be something like main:F(0,1), so we want
- to clobber the colon. It's OK to change the name, since the
- string is in our own local storage anyhow. */
-
- s = strchr (fnname, ':');
- if (s != NULL)
- *s = '\0';
-
- *pfnname = fnname;
- }
-
- return true;
-}
diff --git a/contrib/gdb/bfd/sysdep.h b/contrib/gdb/bfd/sysdep.h
deleted file mode 100644
index dd8146a..0000000
--- a/contrib/gdb/bfd/sysdep.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* sysdep.h -- handle host dependencies for the BFD library
- Copyright 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef BFD_SYSDEP_H
-#define BFD_SYSDEP_H
-
-#include "ansidecl.h"
-
-#include "config.h"
-
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#else
-extern char *strchr ();
-extern char *strrchr ();
-extern char *strstr ();
-#endif
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef USE_BINARY_FOPEN
-#include "fopen-bin.h"
-#else
-#include "fopen-same.h"
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
-#ifndef O_WRONLY
-#define O_WRONLY 1
-#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-
-#ifdef NEED_DECLARATION_MALLOC
-extern PTR malloc ();
-#endif
-
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
-
-#endif /* ! defined (BFD_SYSDEP_H) */
diff --git a/contrib/gdb/bfd/targets.c b/contrib/gdb/bfd/targets.c
deleted file mode 100644
index e1e6468..0000000
--- a/contrib/gdb/bfd/targets.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/* Generic target-file-type support for the BFD library.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/*
-SECTION
- Targets
-
-DESCRIPTION
- Each port of BFD to a different machine requries the creation
- of a target back end. All the back end provides to the root
- part of BFD is a structure containing pointers to functions
- which perform certain low level operations on files. BFD
- translates the applications's requests through a pointer into
- calls to the back end routines.
-
- When a file is opened with <<bfd_openr>>, its format and
- target are unknown. BFD uses various mechanisms to determine
- how to interpret the file. The operations performed are:
-
- o Create a BFD by calling the internal routine
- <<_bfd_new_bfd>>, then call <<bfd_find_target>> with the
- target string supplied to <<bfd_openr>> and the new BFD pointer.
-
- o If a null target string was provided to <<bfd_find_target>>,
- look up the environment variable <<GNUTARGET>> and use
- that as the target string.
-
- o If the target string is still <<NULL>>, or the target string is
- <<default>>, then use the first item in the target vector
- as the target type, and set <<target_defaulted>> in the BFD to
- cause <<bfd_check_format>> to loop through all the targets.
- @xref{bfd_target}. @xref{Formats}.
-
- o Otherwise, inspect the elements in the target vector
- one by one, until a match on target name is found. When found,
- use it.
-
- o Otherwise return the error <<bfd_error_invalid_target>> to
- <<bfd_openr>>.
-
- o <<bfd_openr>> attempts to open the file using
- <<bfd_open_file>>, and returns the BFD.
-
- Once the BFD has been opened and the target selected, the file
- format may be determined. This is done by calling
- <<bfd_check_format>> on the BFD with a suggested format.
- If <<target_defaulted>> has been set, each possible target
- type is tried to see if it recognizes the specified format.
- <<bfd_check_format>> returns <<true>> when the caller guesses right.
-@menu
-@* bfd_target::
-@end menu
-*/
-
-
-/*
-
-INODE
- bfd_target, , Targets, Targets
-DOCDD
-SUBSECTION
- bfd_target
-
-DESCRIPTION
- This structure contains everything that BFD knows about a
- target. It includes things like its byte order, name, and which
- routines to call to do various operations.
-
- Every BFD points to a target structure with its <<xvec>>
- member.
-
- The macros below are used to dispatch to functions through the
- <<bfd_target>> vector. They are used in a number of macros further
- down in @file{bfd.h}, and are also used when calling various
- routines by hand inside the BFD implementation. The @var{arglist}
- argument must be parenthesized; it contains all the arguments
- to the called function.
-
- They make the documentation (more) unpleasant to read, so if
- someone wants to fix this and not break the above, please do.
-
-.#define BFD_SEND(bfd, message, arglist) \
-. ((*((bfd)->xvec->message)) arglist)
-.
-.#ifdef DEBUG_BFD_SEND
-.#undef BFD_SEND
-.#define BFD_SEND(bfd, message, arglist) \
-. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
-. ((*((bfd)->xvec->message)) arglist) : \
-. (bfd_assert (__FILE__,__LINE__), NULL))
-.#endif
-
- For operations which index on the BFD format:
-
-.#define BFD_SEND_FMT(bfd, message, arglist) \
-. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
-.
-.#ifdef DEBUG_BFD_SEND
-.#undef BFD_SEND_FMT
-.#define BFD_SEND_FMT(bfd, message, arglist) \
-. (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
-. (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
-. (bfd_assert (__FILE__,__LINE__), NULL))
-.#endif
-
- This is the structure which defines the type of BFD this is. The
- <<xvec>> member of the struct <<bfd>> itself points here. Each
- module that implements access to a different target under BFD,
- defines one of these.
-
-
- FIXME, these names should be rationalised with the names of
- the entry points which call them. Too bad we can't have one
- macro to define them both!
-
-.enum bfd_flavour {
-. bfd_target_unknown_flavour,
-. bfd_target_aout_flavour,
-. bfd_target_coff_flavour,
-. bfd_target_ecoff_flavour,
-. bfd_target_elf_flavour,
-. bfd_target_ieee_flavour,
-. bfd_target_nlm_flavour,
-. bfd_target_oasys_flavour,
-. bfd_target_tekhex_flavour,
-. bfd_target_srec_flavour,
-. bfd_target_ihex_flavour,
-. bfd_target_som_flavour,
-. bfd_target_os9k_flavour,
-. bfd_target_versados_flavour,
-. bfd_target_msdos_flavour
-.};
-.
-.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
-.
-.{* Forward declaration. *}
-.typedef struct bfd_link_info _bfd_link_info;
-.
-.typedef struct bfd_target
-.{
-
-Identifies the kind of target, e.g., SunOS4, Ultrix, etc.
-
-. char *name;
-
-The "flavour" of a back end is a general indication about the contents
-of a file.
-
-. enum bfd_flavour flavour;
-
-The order of bytes within the data area of a file.
-
-. enum bfd_endian byteorder;
-
-The order of bytes within the header parts of a file.
-
-. enum bfd_endian header_byteorder;
-
-A mask of all the flags which an executable may have set -
-from the set <<NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>.
-
-. flagword object_flags;
-
-A mask of all the flags which a section may have set - from
-the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>.
-
-. flagword section_flags;
-
-The character normally found at the front of a symbol
-(if any), perhaps `_'.
-
-. char symbol_leading_char;
-
-The pad character for file names within an archive header.
-
-. char ar_pad_char;
-
-The maximum number of characters in an archive header.
-
-. unsigned short ar_max_namelen;
-
-Entries for byte swapping for data. These are different from the other
-entry points, since they don't take a BFD asthe first argument.
-Certain other handlers could do the same.
-
-. bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
-
-Byte swapping for the headers
-
-. bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
-. bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
-
-Format dependent routines: these are vectors of entry points
-within the target vector structure, one for each format to check.
-
-Check the format of a file being read. Return a <<bfd_target *>> or zero.
-
-. const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
-
-Set the format of a file being written.
-
-. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
-
-Write cached information into a file being written, at <<bfd_close>>.
-
-. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
-
-The general target vector.
-
-.
-. {* Generic entry points. *}
-.#define BFD_JUMP_TABLE_GENERIC(NAME)\
-.CAT(NAME,_close_and_cleanup),\
-.CAT(NAME,_bfd_free_cached_info),\
-.CAT(NAME,_new_section_hook),\
-.CAT(NAME,_get_section_contents),\
-.CAT(NAME,_get_section_contents_in_window)
-.
-. {* Called when the BFD is being closed to do any necessary cleanup. *}
-. boolean (*_close_and_cleanup) PARAMS ((bfd *));
-. {* Ask the BFD to free all cached information. *}
-. boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
-. {* Called when a new section is created. *}
-. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
-. {* Read the contents of a section. *}
-. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
-. file_ptr, bfd_size_type));
-. boolean (*_bfd_get_section_contents_in_window)
-. PARAMS ((bfd *, sec_ptr, bfd_window *,
-. file_ptr, bfd_size_type));
-.
-. {* Entry points to copy private data. *}
-.#define BFD_JUMP_TABLE_COPY(NAME)\
-.CAT(NAME,_bfd_copy_private_bfd_data),\
-.CAT(NAME,_bfd_merge_private_bfd_data),\
-.CAT(NAME,_bfd_copy_private_section_data),\
-.CAT(NAME,_bfd_copy_private_symbol_data),\
-.CAT(NAME,_bfd_set_private_flags),\
-.CAT(NAME,_bfd_print_private_bfd_data)\
-. {* Called to copy BFD general private data from one object file
-. to another. *}
-. boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
-. {* Called to merge BFD general private data from one object file
-. to a common output file when linking. *}
-. boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
-. {* Called to copy BFD private section data from one object file
-. to another. *}
-. boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
-. bfd *, sec_ptr));
-. {* Called to copy BFD private symbol data from one symbol
-. to another. *}
-. boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
-. bfd *, asymbol *));
-. {* Called to set private backend flags *}
-. boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
-.
-. {* Called to print private BFD data *}
-. boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
-.
-. {* Core file entry points. *}
-.#define BFD_JUMP_TABLE_CORE(NAME)\
-.CAT(NAME,_core_file_failing_command),\
-.CAT(NAME,_core_file_failing_signal),\
-.CAT(NAME,_core_file_matches_executable_p)
-. char * (*_core_file_failing_command) PARAMS ((bfd *));
-. int (*_core_file_failing_signal) PARAMS ((bfd *));
-. boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
-.
-. {* Archive entry points. *}
-.#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
-.CAT(NAME,_slurp_armap),\
-.CAT(NAME,_slurp_extended_name_table),\
-.CAT(NAME,_construct_extended_name_table),\
-.CAT(NAME,_truncate_arname),\
-.CAT(NAME,_write_armap),\
-.CAT(NAME,_read_ar_hdr),\
-.CAT(NAME,_openr_next_archived_file),\
-.CAT(NAME,_get_elt_at_index),\
-.CAT(NAME,_generic_stat_arch_elt),\
-.CAT(NAME,_update_armap_timestamp)
-. boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
-. boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
-. boolean (*_bfd_construct_extended_name_table)
-. PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-. void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
-. boolean (*write_armap) PARAMS ((bfd *arch,
-. unsigned int elength,
-. struct orl *map,
-. unsigned int orl_count,
-. int stridx));
-. PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
-. bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
-.#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
-. bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
-. int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
-. boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
-.
-. {* Entry points used for symbols. *}
-.#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
-.CAT(NAME,_get_symtab_upper_bound),\
-.CAT(NAME,_get_symtab),\
-.CAT(NAME,_make_empty_symbol),\
-.CAT(NAME,_print_symbol),\
-.CAT(NAME,_get_symbol_info),\
-.CAT(NAME,_bfd_is_local_label),\
-.CAT(NAME,_get_lineno),\
-.CAT(NAME,_find_nearest_line),\
-.CAT(NAME,_bfd_make_debug_symbol),\
-.CAT(NAME,_read_minisymbols),\
-.CAT(NAME,_minisymbol_to_symbol)
-. long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
-. long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
-. struct symbol_cache_entry **));
-. struct symbol_cache_entry *
-. (*_bfd_make_empty_symbol) PARAMS ((bfd *));
-. void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
-. struct symbol_cache_entry *,
-. bfd_print_symbol_type));
-.#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
-. void (*_bfd_get_symbol_info) PARAMS ((bfd *,
-. struct symbol_cache_entry *,
-. symbol_info *));
-.#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
-. boolean (*_bfd_is_local_label) PARAMS ((bfd *, asymbol *));
-.
-. alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
-. boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
-. struct sec *section, struct symbol_cache_entry **symbols,
-. bfd_vma offset, CONST char **file, CONST char **func,
-. unsigned int *line));
-. {* Back-door to allow format-aware applications to create debug symbols
-. while using BFD for everything else. Currently used by the assembler
-. when creating COFF files. *}
-. asymbol * (*_bfd_make_debug_symbol) PARAMS ((
-. bfd *abfd,
-. void *ptr,
-. unsigned long size));
-.#define bfd_read_minisymbols(b, d, m, s) \
-. BFD_SEND (b, _read_minisymbols, (b, d, m, s))
-. long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
-. unsigned int *));
-.#define bfd_minisymbol_to_symbol(b, d, m, f) \
-. BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
-. asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
-. asymbol *));
-.
-. {* Routines for relocs. *}
-.#define BFD_JUMP_TABLE_RELOCS(NAME)\
-.CAT(NAME,_get_reloc_upper_bound),\
-.CAT(NAME,_canonicalize_reloc),\
-.CAT(NAME,_bfd_reloc_type_lookup)
-. long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
-. long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
-. struct symbol_cache_entry **));
-. {* See documentation on reloc types. *}
-. reloc_howto_type *
-. (*reloc_type_lookup) PARAMS ((bfd *abfd,
-. bfd_reloc_code_real_type code));
-.
-. {* Routines used when writing an object file. *}
-.#define BFD_JUMP_TABLE_WRITE(NAME)\
-.CAT(NAME,_set_arch_mach),\
-.CAT(NAME,_set_section_contents)
-. boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
-. unsigned long));
-. boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
-. file_ptr, bfd_size_type));
-.
-. {* Routines used by the linker. *}
-.#define BFD_JUMP_TABLE_LINK(NAME)\
-.CAT(NAME,_sizeof_headers),\
-.CAT(NAME,_bfd_get_relocated_section_contents),\
-.CAT(NAME,_bfd_relax_section),\
-.CAT(NAME,_bfd_link_hash_table_create),\
-.CAT(NAME,_bfd_link_add_symbols),\
-.CAT(NAME,_bfd_final_link),\
-.CAT(NAME,_bfd_link_split_section)
-. int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
-. bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
-. struct bfd_link_info *, struct bfd_link_order *,
-. bfd_byte *data, boolean relocateable,
-. struct symbol_cache_entry **));
-.
-. boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
-. struct bfd_link_info *, boolean *again));
-.
-. {* Create a hash table for the linker. Different backends store
-. different information in this table. *}
-. struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
-.
-. {* Add symbols from this object file into the hash table. *}
-. boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
-.
-. {* Do a link based on the link_order structures attached to each
-. section of the BFD. *}
-. boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
-.
-. {* Should this section be split up into smaller pieces during linking. *}
-. boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
-.
-. {* Routines to handle dynamic symbols and relocs. *}
-.#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
-.CAT(NAME,_get_dynamic_symtab_upper_bound),\
-.CAT(NAME,_canonicalize_dynamic_symtab),\
-.CAT(NAME,_get_dynamic_reloc_upper_bound),\
-.CAT(NAME,_canonicalize_dynamic_reloc)
-. {* Get the amount of memory required to hold the dynamic symbols. *}
-. long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
-. {* Read in the dynamic symbols. *}
-. long (*_bfd_canonicalize_dynamic_symtab)
-. PARAMS ((bfd *, struct symbol_cache_entry **));
-. {* Get the amount of memory required to hold the dynamic relocs. *}
-. long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
-. {* Read in the dynamic relocs. *}
-. long (*_bfd_canonicalize_dynamic_reloc)
-. PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
-.
-
-Data for use by back-end routines, which isn't generic enough to belong
-in this structure.
-
-. PTR backend_data;
-.} bfd_target;
-
-*/
-
-/* All known xvecs (even those that don't compile on all systems).
- Alphabetized for easy reference.
- They are listed a second time below, since
- we can't intermix extern's and initializers. */
-extern const bfd_target a29kcoff_big_vec;
-extern const bfd_target a_out_adobe_vec;
-extern const bfd_target aout_arm_big_vec;
-extern const bfd_target aout_arm_little_vec;
-extern const bfd_target aout_mips_big_vec;
-extern const bfd_target aout_mips_little_vec;
-extern const bfd_target aout0_big_vec;
-extern const bfd_target apollocoff_vec;
-extern const bfd_target armcoff_little_vec;
-extern const bfd_target armcoff_big_vec;
-extern const bfd_target armpe_little_vec;
-extern const bfd_target armpe_big_vec;
-extern const bfd_target armpei_little_vec;
-extern const bfd_target armpei_big_vec;
-extern const bfd_target b_out_vec_big_host;
-extern const bfd_target b_out_vec_little_host;
-extern const bfd_target bfd_elf32_big_generic_vec;
-extern const bfd_target bfd_elf32_bigmips_vec;
-extern const bfd_target bfd_elf32_hppa_vec;
-extern const bfd_target bfd_elf32_i386_vec;
-extern const bfd_target bfd_elf32_i860_vec;
-extern const bfd_target bfd_elf32_little_generic_vec;
-extern const bfd_target bfd_elf32_littlemips_vec;
-extern const bfd_target bfd_elf32_m68k_vec;
-extern const bfd_target bfd_elf32_m88k_vec;
-extern const bfd_target bfd_elf32_powerpc_vec;
-extern const bfd_target bfd_elf32_powerpcle_vec;
-extern const bfd_target bfd_elf32_sparc_vec;
-extern const bfd_target bfd_elf64_big_generic_vec;
-extern const bfd_target bfd_elf64_little_generic_vec;
-extern const bfd_target bfd_elf64_sparc_vec;
-extern const bfd_target demo_64_vec;
-extern const bfd_target ecoff_big_vec;
-extern const bfd_target ecoff_little_vec;
-extern const bfd_target ecoffalpha_little_vec;
-extern const bfd_target h8300coff_vec;
-extern const bfd_target h8500coff_vec;
-extern const bfd_target host_aout_vec;
-extern const bfd_target hp300bsd_vec;
-extern const bfd_target hp300hpux_vec;
-extern const bfd_target som_vec;
-extern const bfd_target i386aout_vec;
-extern const bfd_target i386bsd_vec;
-extern const bfd_target i386dynix_vec;
-extern const bfd_target i386freebsd_vec;
-extern const bfd_target i386os9k_vec;
-extern const bfd_target i386coff_vec;
-extern const bfd_target bfd_powerpc_pe_vec;
-extern const bfd_target bfd_powerpcle_pe_vec;
-extern const bfd_target bfd_powerpc_pei_vec;
-extern const bfd_target bfd_powerpcle_pei_vec;
-extern const bfd_target i386pe_vec;
-extern const bfd_target i386pei_vec;
-extern const bfd_target go32coff_vec;
-extern const bfd_target i386linux_vec;
-extern const bfd_target i386lynx_aout_vec;
-extern const bfd_target i386lynx_coff_vec;
-extern const bfd_target i386mach3_vec;
-extern const bfd_target i386msdos_vec;
-extern const bfd_target i386netbsd_vec;
-extern const bfd_target i860coff_vec;
-extern const bfd_target icoff_big_vec;
-extern const bfd_target icoff_little_vec;
-extern const bfd_target ieee_vec;
-extern const bfd_target m68kaux_coff_vec;
-extern const bfd_target m68kcoff_vec;
-extern const bfd_target m68kcoffun_vec;
-extern const bfd_target m68klinux_vec;
-extern const bfd_target m68klynx_aout_vec;
-extern const bfd_target m68klynx_coff_vec;
-extern const bfd_target m68knetbsd_vec;
-extern const bfd_target m68k4knetbsd_vec;
-extern const bfd_target m88kbcs_vec;
-extern const bfd_target m88kmach3_vec;
-extern const bfd_target newsos3_vec;
-extern const bfd_target nlm32_i386_vec;
-extern const bfd_target nlm32_sparc_vec;
-extern const bfd_target nlm32_alpha_vec;
-extern const bfd_target nlm32_powerpc_vec;
-extern const bfd_target pc532netbsd_vec;
-extern const bfd_target oasys_vec;
-extern const bfd_target pc532machaout_vec;
-extern const bfd_target riscix_vec;
-extern const bfd_target pmac_xcoff_vec;
-extern const bfd_target rs6000coff_vec;
-extern const bfd_target shcoff_vec;
-extern const bfd_target shlcoff_vec;
-extern const bfd_target sparclynx_aout_vec;
-extern const bfd_target sparclynx_coff_vec;
-extern const bfd_target sparcnetbsd_vec;
-extern const bfd_target sparccoff_vec;
-extern const bfd_target sunos_big_vec;
-extern const bfd_target tekhex_vec;
-extern const bfd_target versados_vec;
-extern const bfd_target we32kcoff_vec;
-extern const bfd_target w65_vec;
-extern const bfd_target z8kcoff_vec;
-
-/* srec is always included. */
-extern const bfd_target srec_vec;
-extern const bfd_target symbolsrec_vec;
-
-/* binary is always included. */
-extern const bfd_target binary_vec;
-
-/* ihex is always included. */
-extern const bfd_target ihex_vec;
-
-/* All of the xvecs for core files. */
-extern const bfd_target aix386_core_vec;
-extern const bfd_target cisco_core_vec;
-extern const bfd_target hpux_core_vec;
-extern const bfd_target hppabsd_core_vec;
-extern const bfd_target irix_core_vec;
-extern const bfd_target osf_core_vec;
-extern const bfd_target sco_core_vec;
-extern const bfd_target trad_core_vec;
-extern const bfd_target ptrace_core_vec;
-
-const bfd_target * const bfd_target_vector[] = {
-
-#ifdef SELECT_VECS
-
- SELECT_VECS,
-
-#else /* not SELECT_VECS */
-
-#ifdef DEFAULT_VECTOR
- &DEFAULT_VECTOR,
-#endif
- /* This list is alphabetized to make it easy to compare
- with other vector lists -- the decls above and
- the case statement in configure.in.
- Vectors that don't compile on all systems, or aren't finished,
- should have an entry here with #if 0 around it, to show that
- it wasn't omitted by mistake. */
- &a29kcoff_big_vec,
- &a_out_adobe_vec,
-#if 0 /* No one seems to use this. */
- &aout_mips_big_vec,
-#endif
- &aout_mips_little_vec,
- &b_out_vec_big_host,
- &b_out_vec_little_host,
-
- /* This, and other vectors, may not be used in any *.mt configuration.
- But that does not mean they are unnecessary. If configured with
- --enable-targets=all, objdump or gdb should be able to examine
- the file even if we don't recognize the machine type. */
- &bfd_elf32_big_generic_vec,
- &bfd_elf32_bigmips_vec,
- &bfd_elf32_hppa_vec,
- &bfd_elf32_i386_vec,
- &bfd_elf32_i860_vec,
- &bfd_elf32_little_generic_vec,
- &bfd_elf32_littlemips_vec,
- &bfd_elf32_m68k_vec,
- &bfd_elf32_m88k_vec,
- &bfd_elf32_sparc_vec,
- &bfd_elf32_powerpc_vec,
-#ifdef BFD64 /* No one seems to use this. */
- &bfd_elf64_big_generic_vec,
- &bfd_elf64_little_generic_vec,
-#endif
-#if 0
- &bfd_elf64_sparc_vec,
-#endif
- /* We don't include cisco_core_vec. Although it has a magic number,
- the magic number isn't at the beginning of the file, and thus
- might spuriously match other kinds of files. */
-#ifdef BFD64
- &demo_64_vec, /* Only compiled if host has long-long support */
-#endif
- &ecoff_big_vec,
- &ecoff_little_vec,
-#if 0
- &ecoffalpha_little_vec,
-#endif
- &h8300coff_vec,
- &h8500coff_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &host_aout_vec,
-#endif
-#if 0 /* Clashes with sunos_big_vec magic no. */
- &hp300bsd_vec,
-#endif
- &hp300hpux_vec,
-#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
- &som_vec,
-#endif
- &i386aout_vec,
- &i386bsd_vec,
- &i386coff_vec,
- &i386freebsd_vec,
- &i860coff_vec,
- &bfd_powerpc_pe_vec,
- &bfd_powerpcle_pe_vec,
- &bfd_powerpc_pei_vec,
- &bfd_powerpcle_pei_vec,
- &go32coff_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &i386linux_vec,
-#endif
- &i386lynx_aout_vec,
- &i386lynx_coff_vec,
-#if 0
- /* No distinguishing features for Mach 3 executables. */
- &i386mach3_vec,
-#endif
- &i386msdos_vec,
- &i386netbsd_vec,
- &i386os9k_vec,
- &i386pe_vec,
- &i386pei_vec,
- &armcoff_little_vec,
- &armcoff_big_vec,
- &armpe_little_vec,
- &armpe_big_vec,
- &armpei_little_vec,
- &armpei_big_vec,
- &icoff_big_vec,
- &icoff_little_vec,
- &ieee_vec,
- &m68kcoff_vec,
- &m68kcoffun_vec,
-#if 0
- /* Since a.out files lack decent magic numbers, no way to recognize
- which kind of a.out file it is. */
- &m68klinux_vec,
-#endif
- &m68klynx_aout_vec,
- &m68klynx_coff_vec,
- &m68knetbsd_vec,
- &m88kbcs_vec,
- &m88kmach3_vec,
- &newsos3_vec,
- &nlm32_i386_vec,
- &nlm32_sparc_vec,
-#ifdef BFD64
- &nlm32_alpha_vec,
-#endif
- &pc532netbsd_vec,
-#if 0
- /* We have no oasys tools anymore, so we can't test any of this
- anymore. If you want to test the stuff yourself, go ahead...
- steve@cygnus.com
- Worse, since there is no magic number for archives, there
- can be annoying target mis-matches. */
- &oasys_vec,
-#endif
- &pc532machaout_vec,
-#if 0
- /* We have no way of distinguishing these from other a.out variants */
- &aout_arm_big_vec,
- &aout_arm_little_vec,
- &riscix_vec,
-#endif
-#if 0
- /* This has the same magic number as RS/6000. */
- &pmac_xcoff_vec,
-#endif
- &rs6000coff_vec,
- &shcoff_vec,
- &shlcoff_vec,
- &sparclynx_aout_vec,
- &sparclynx_coff_vec,
- &sparcnetbsd_vec,
- &sunos_big_vec,
- &aout0_big_vec,
- &tekhex_vec,
- &we32kcoff_vec,
- &versados_vec,
- &z8kcoff_vec,
-
-#endif /* not SELECT_VECS */
-
-/* Always support S-records, for convenience. */
- &srec_vec,
- &symbolsrec_vec,
-/* And tekhex */
- &tekhex_vec,
-/* Likewise for binary output. */
- &binary_vec,
-/* Likewise for ihex. */
- &ihex_vec,
-
-/* Add any required traditional-core-file-handler. */
-
-#ifdef AIX386_CORE
- &aix386_core_vec,
-#endif
-#ifdef HPUX_CORE
- &hpux_core_vec,
-#endif
-#ifdef HPPABSD_CORE
- &hppabsd_core_vec,
-#endif
-#ifdef IRIX_CORE
- &irix_core_vec,
-#endif
-#ifdef OSF_CORE
- &osf_core_vec,
-#endif
-#ifdef TRAD_CORE
- &trad_core_vec,
-#endif
-
-#ifdef PTRACE_CORE
- &ptrace_core_vec,
-#endif
-
- NULL /* end of list marker */
-};
-
-/* bfd_default_vector[0] contains either the address of the default vector,
- if there is one, or zero if there isn't. */
-
-const bfd_target * const bfd_default_vector[] = {
-#ifdef DEFAULT_VECTOR
- &DEFAULT_VECTOR,
-#endif
- NULL
-};
-
-/* When there is an ambiguous match, bfd_check_format_matches puts the
- names of the matching targets in an array. This variable is the maximum
- number of entries that the array could possibly need. */
-const size_t _bfd_target_vector_entries = sizeof(bfd_target_vector)/sizeof(*bfd_target_vector);
-
-/*
-FUNCTION
- bfd_find_target
-
-SYNOPSIS
- const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd);
-
-DESCRIPTION
- Return a pointer to the transfer vector for the object target
- named @var{target_name}. If @var{target_name} is <<NULL>>, choose the
- one in the environment variable <<GNUTARGET>>; if that is null or not
- defined, then choose the first entry in the target list.
- Passing in the string "default" or setting the environment
- variable to "default" will cause the first entry in the target
- list to be returned, and "target_defaulted" will be set in the
- BFD. This causes <<bfd_check_format>> to loop over all the
- targets to find the one that matches the file being read.
-*/
-
-const bfd_target *
-bfd_find_target (target_name, abfd)
- CONST char *target_name;
- bfd *abfd;
-{
- const bfd_target * const *target;
- extern char *getenv ();
- CONST char *targname = (target_name ? target_name :
- (CONST char *) getenv ("GNUTARGET"));
-
- /* This is safe; the vector cannot be null */
- if (targname == NULL || !strcmp (targname, "default")) {
- abfd->target_defaulted = true;
- return abfd->xvec = bfd_target_vector[0];
- }
-
- abfd->target_defaulted = false;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++) {
- if (!strcmp (targname, (*target)->name))
- return abfd->xvec = *target;
- }
-
- bfd_set_error (bfd_error_invalid_target);
- return NULL;
-}
-
-
-/*
-FUNCTION
- bfd_target_list
-
-SYNOPSIS
- const char **bfd_target_list(void);
-
-DESCRIPTION
- Return a freshly malloced NULL-terminated
- vector of the names of all the valid BFD targets. Do not
- modify the names.
-
-*/
-
-const char **
-bfd_target_list ()
-{
- int vec_length= 0;
-#if defined (HOST_HPPAHPUX) && ! defined (__STDC__)
- /* The native compiler on the HP9000/700 has a bug which causes it
- to loop endlessly when compiling this file. This avoids it. */
- volatile
-#endif
- const bfd_target * const *target;
- CONST char **name_list, **name_ptr;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++)
- vec_length++;
-
- name_ptr = name_list = (CONST char **)
- bfd_zmalloc ((vec_length + 1) * sizeof (char **));
-
- if (name_list == NULL)
- return NULL;
-
- for (target = &bfd_target_vector[0]; *target != NULL; target++)
- *(name_ptr++) = (*target)->name;
-
- return name_list;
-}
diff --git a/contrib/gdb/bfd/tekhex.c b/contrib/gdb/bfd/tekhex.c
deleted file mode 100644
index bf7957e..0000000
--- a/contrib/gdb/bfd/tekhex.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/* BFD backend for Extended Tektronix Hex Format objects.
- Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-
- Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-SUBSECTION
- Tektronix Hex Format handling
-
-DESCRIPTION
-
- Tek Hex records can hold symbols and data, but not
- relocations. Their main application is communication with
- devices like PROM programmers and ICE equipment.
-
- It seems that the sections are descibed as being really big,
- the example I have says that the text section is 0..ffffffff.
- BFD would barf with this, many apps would try to alloc 4GB to
- read in the file.
-
- Tex Hex may contain many sections, but the data which comes in
- has no tag saying which section it belongs to, so we create
- one section for each block of data, called "blknnnn" which we
- stick all the data into.
-
- TekHex may come out of order and there is no header, so an
- initial scan is required to discover the minimum and maximum
- addresses used to create the vma and size of the sections we
- create.
- We read in the data into pages of CHUNK_MASK+1 size and read
- them out from that whenever we need to.
-
- Any number of sections may be created for output, we save them
- up and output them when it's time to close the bfd.
-
-
- A TekHex record looks like:
-EXAMPLE
- %<block length><type><checksum><stuff><cr>
-
-DESCRIPTION
- Where
- o length
- is the number of bytes in the record not including the % sign.
- o type
- is one of:
- 3) symbol record
- 6) data record
- 8) termination record
-
-
-The data can come out of order, and may be discontigous. This is a
-serial protocol, so big files are unlikely, so we keep a list of 8k chunks
-*/
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-
-typedef struct
- {
- bfd_vma low;
- bfd_vma high;
- } addr_range_type;
-
-typedef struct tekhex_symbol_struct
- {
-
- asymbol symbol;
- struct tekhex_symbol_struct *prev;
-
- } tekhex_symbol_type;
-
-static const char digs[] = "0123456789ABCDEF";
-
-static char sum_block[256];
-
-#define NOT_HEX 20
-#define NIBBLE(x) hex_value(x)
-#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
-#define TOHEX(d,x) \
-(d)[1] = digs[(x) & 0xf]; \
-(d)[0] = digs[((x)>>4)&0xf];
-#define ISHEX(x) hex_p(x)
-
-/*
-Here's an example
-%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
-%1B3709T_SEGMENT1108FFFFFFFF
-%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
-%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
-%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
-%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
-%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
-%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
-%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
-%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
-%2734D9T_SEGMENT8Bvoid$t15$151035_main10
-%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
-%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
-%07 8 10 10
-
-explanation:
-%3A6C6480004E56FFFC4E717063B0AEFFFC6D0652AEFFFC60F24E5E4E75
- ^ ^^ ^ ^-data
- | || +------ 4 char integer 0x8000
- | |+-------- checksum
- | +--------- type 6 (data record)
- +----------- length 3a chars
- <---------------------- 3a (58 chars) ------------------->
-
-%1B3709T_SEGMENT1108FFFFFFFF
- ^ ^^ ^- 8 character integer 0xffffffff
- | |+- 1 character integer 0
- | +-- type 1 symbol (section definition)
- +------------ 9 char symbol T_SEGMENT
-
-%2B3AB9T_SEGMENT7Dgcc_compiled$1087hello$c10
-%373829T_SEGMENT80int$t1$r1$$214741080char$t2$r2$0$12710
-%373769T_SEGMENT80long$int$t3$r1$$1080unsigned$int$t4$10
-%373CA9T_SEGMENT80long$unsigned$in1080short$int$t6$r1$10
-%373049T_SEGMENT80long$long$int$t71080short$unsigned$i10
-%373A29T_SEGMENT80long$long$unsign1080signed$char$t10$10
-%373D69T_SEGMENT80unsigned$char$t11080float$t12$r1$4$010
-%373D19T_SEGMENT80double$t13$r1$8$1080long$double$t14$10
-%2734D9T_SEGMENT8Bvoid$t15$151035_main10
-%2F3CA9T_SEGMENT81$1081$1681$1E81$21487main$F110
-%2832F9T_SEGMENT83i$18FFFFFFFC81$1481$214
-%0781010
-
-Turns into
-sac@thepub$ ./objdump -dx -m m68k f
-
-f: file format tekhex
------x--- 9/55728 -134219416 Sep 29 15:13 1995 f
-architecture: UNKNOWN!, flags 0x00000010:
-HAS_SYMS
-start address 0x00000000
-SECTION 0 [D00000000] : size 00020000 vma 00000000 align 2**0
- ALLOC, LOAD
-SECTION 1 [D00008000] : size 00002001 vma 00008000 align 2**0
-
-SECTION 2 [T_SEGMENT] : size ffffffff vma 00000000 align 2**0
-
-SYMBOL TABLE:
-00000000 g T_SEGMENT gcc_compiled$
-00000000 g T_SEGMENT hello$c
-00000000 g T_SEGMENT int$t1$r1$$21474
-00000000 g T_SEGMENT char$t2$r2$0$127
-00000000 g T_SEGMENT long$int$t3$r1$$
-00000000 g T_SEGMENT unsigned$int$t4$
-00000000 g T_SEGMENT long$unsigned$in
-00000000 g T_SEGMENT short$int$t6$r1$
-00000000 g T_SEGMENT long$long$int$t7
-00000000 g T_SEGMENT short$unsigned$i
-00000000 g T_SEGMENT long$long$unsign
-00000000 g T_SEGMENT signed$char$t10$
-00000000 g T_SEGMENT unsigned$char$t1
-00000000 g T_SEGMENT float$t12$r1$4$0
-00000000 g T_SEGMENT double$t13$r1$8$
-00000000 g T_SEGMENT long$double$t14$
-00000000 g T_SEGMENT void$t15$15
-00000000 g T_SEGMENT _main
-00000000 g T_SEGMENT $
-00000000 g T_SEGMENT $
-00000000 g T_SEGMENT $
-00000010 g T_SEGMENT $
-00000000 g T_SEGMENT main$F1
-fcffffff g T_SEGMENT i$1
-00000000 g T_SEGMENT $
-00000010 g T_SEGMENT $
-
-
-RELOCATION RECORDS FOR [D00000000]: (none)
-
-RELOCATION RECORDS FOR [D00008000]: (none)
-
-RELOCATION RECORDS FOR [T_SEGMENT]: (none)
-
-Disassembly of section D00000000:
-...
-00008000 ($+)7ff0 linkw fp,#-4
-00008004 ($+)7ff4 nop
-00008006 ($+)7ff6 movel #99,d0
-00008008 ($+)7ff8 cmpl fp@(-4),d0
-0000800c ($+)7ffc blts 00008014 ($+)8004
-0000800e ($+)7ffe addql #1,fp@(-4)
-00008012 ($+)8002 bras 00008006 ($+)7ff6
-00008014 ($+)8004 unlk fp
-00008016 ($+)8006 rts
-...
-
-*/
-
-static void
-tekhex_init ()
-{
- unsigned int i;
- static boolean inited = false;
- int val;
-
- if (inited == false)
- {
- inited = true;
- hex_init ();
- val = 0;
- for (i = 0; i < 10; i++)
- {
- sum_block[i + '0'] = val++;
- }
- for (i = 'A'; i <= 'Z'; i++)
- {
- sum_block[i] = val++;
- }
- sum_block['$'] = val++;
- sum_block['%'] = val++;
- sum_block['.'] = val++;
- sum_block['_'] = val++;
- for (i = 'a'; i <= 'z'; i++)
- {
- sum_block[i] = val++;
- }
- }
-}
-
-/* The maximum number of bytes on a line is FF */
-#define MAXCHUNK 0xff
-/* The number of bytes we fit onto a line on output */
-#define CHUNK 21
-
-/* We cannot output our tekhexords as we see them, we have to glue them
- together, this is done in this structure : */
-
-struct tekhex_data_list_struct
-{
- unsigned char *data;
- bfd_vma where;
- bfd_size_type size;
- struct tekhex_data_list_struct *next;
-
-};
-typedef struct tekhex_data_list_struct tekhex_data_list_type;
-
-#define CHUNK_MASK 0x1fff
-
-struct data_struct
- {
- char chunk_data[CHUNK_MASK + 1];
- char chunk_init[CHUNK_MASK + 1];
- bfd_vma vma;
- struct data_struct *next;
- };
-
-typedef struct tekhex_data_struct
-{
- tekhex_data_list_type *head;
- unsigned int type;
- struct tekhex_symbol_struct *symbols;
- struct data_struct *data;
-} tdata_type;
-
-#define enda(x) (x->vma + x->size)
-
-static bfd_vma
-getvalue (srcp)
- char **srcp;
-{
- char *src = *srcp;
- bfd_vma value = 0;
- unsigned int len = hex_value(*src++);
-
- if (len == 0)
- len = 16;
- while (len--)
- {
- value = value << 4 | hex_value(*src++);
- }
- *srcp = src;
- return value;
-}
-
-static unsigned int
-getsym (dstp, srcp)
- char *dstp;
- char **srcp;
-{
- char *src = *srcp;
- unsigned int i;
- unsigned int len = hex_value(*src++);
-
- if (len == 0)
- len = 16;
- for (i = 0; i < len; i++)
- dstp[i] = src[i];
- dstp[i] = 0;
- *srcp = src + i;
- return len;
-}
-
-struct data_struct *
-find_chunk (abfd, vma)
- bfd *abfd;
- bfd_vma vma;
-{
- struct data_struct *d = abfd->tdata.tekhex_data->data;
-
- vma &= ~CHUNK_MASK;
- while (d && (d->vma) != vma)
- {
- d = d->next;
- }
- if (!d)
- {
- char *sname = bfd_alloc (abfd, 12);
-
- /* No chunk for this address, so make one up */
- d = (struct data_struct *)
- bfd_alloc (abfd, sizeof (struct data_struct));
-
- if (!sname || !d)
- return NULL;
-
- memset (d->chunk_init, 0, CHUNK_MASK + 1);
- memset (d->chunk_data, 0, CHUNK_MASK + 1);
- d->next = abfd->tdata.tekhex_data->data;
- d->vma = vma;
- abfd->tdata.tekhex_data->data = d;
- }
- return d;
-}
-
-static void
-insert_byte (abfd, value, addr)
- bfd *abfd;
- int value;
- bfd_vma addr;
-{
- /* Find the chunk that this byte needs and put it in */
- struct data_struct *d = find_chunk (abfd, addr);
-
- d->chunk_data[addr & CHUNK_MASK] = value;
- d->chunk_init[addr & CHUNK_MASK] = 1;
-}
-
-/* The first pass is to find the names of all the sections, and see
- how big the data is */
-static void
-first_phase (abfd, type, src)
- bfd *abfd;
- char type;
- char *src;
-{
- asection *section = bfd_abs_section_ptr;
- int len;
- char sym[17]; /* A symbol can only be 16chars long */
-
- switch (type)
- {
- case '6':
- /* Data record - read it and store it */
- {
- bfd_vma addr = getvalue (&src);
-
- while (*src)
- {
- insert_byte (abfd, HEX (src), addr);
- src += 2;
- addr++;
- }
- }
-
- return;
- case '3':
- /* Symbol record, read the segment */
- len = getsym (sym, &src);
- section = bfd_get_section_by_name (abfd, sym);
- if (section == (asection *) NULL)
- {
- char *n = bfd_alloc (abfd, len + 1);
-
- if (!n)
- abort(); /* FIXME */
- memcpy (n, sym, len + 1);
- section = bfd_make_section (abfd, n);
- }
- while (*src)
- {
- switch (*src)
- {
- case '1': /* section range */
- src++;
- section->vma = getvalue (&src);
- section->_raw_size = getvalue (&src) - section->vma;
- section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
- break;
- case '0':
- case '2':
- case '3':
- case '4':
- case '6':
- case '7':
- case '8':
- /* Symbols, add to section */
- {
- tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_alloc (abfd,
- sizeof (tekhex_symbol_type));
- char type = (*src);
-
- if (!new)
- abort(); /* FIXME */
- new->symbol.the_bfd = abfd;
- src++;
- abfd->symcount++;
- abfd->flags |= HAS_SYMS;
- new->prev = abfd->tdata.tekhex_data->symbols;
- abfd->tdata.tekhex_data->symbols = new;
- len = getsym (sym, &src);
- new->symbol.name = bfd_alloc (abfd, len + 1);
- if (!new->symbol.name)
- abort(); /* FIXME */
- memcpy ((char *) (new->symbol.name), sym, len + 1);
- new->symbol.section = section;
- if (type <= '4')
- new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
- else
- new->symbol.flags = BSF_LOCAL;
- new->symbol.value = getvalue (&src) - section->vma;
- }
- }
- }
- }
-}
-
-/* Pass over an tekhex, calling one of the above functions on each
- record. */
-
-static void
- pass_over (abfd, func)
- bfd *abfd;
- void (*func) ();
-{
- unsigned int chars_on_line;
- boolean eof = false;
-
- /* To the front of the file */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- abort ();
- while (eof == false)
- {
- char buffer[MAXCHUNK];
- char *src = buffer;
- char type;
-
- /* Find first '%' */
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
- while (*src != '%' && !eof)
- {
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
- }
- if (eof)
- break;
- src++;
-
- /* Fetch the type and the length and the checksum */
- if (bfd_read (src, 1, 5, abfd) != 5)
- abort (); /* FIXME */
-
- type = src[2];
-
- if (!ISHEX (src[0]) || !ISHEX (src[1]))
- break;
-
- chars_on_line = HEX (src) - 5; /* Already read five char */
-
- if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line)
- abort (); /* FIXME */
- src[chars_on_line] = 0; /* put a null at the end */
-
- func (abfd, type, src);
- }
-
-}
-
-long
-tekhex_get_symtab (abfd, table)
- bfd *abfd;
- asymbol **table;
-
-{
- tekhex_symbol_type *p = abfd->tdata.tekhex_data->symbols;
- unsigned int c = bfd_get_symcount (abfd);
-
- table[c] = 0;
- while (p)
- {
- table[--c] = &(p->symbol);
- p = p->prev;
- }
-
- return bfd_get_symcount (abfd);
-}
-
-long
-tekhex_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (abfd->symcount + 1) * (sizeof (struct tekhex_asymbol_struct *));
-
-}
-
-static boolean
-tekhex_mkobject (abfd)
- bfd *abfd;
-{
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
-
- if (!tdata)
- return false;
- abfd->tdata.tekhex_data = tdata;
- tdata->type = 1;
- tdata->head = (tekhex_data_list_type *) NULL;
- tdata->symbols = (struct tekhex_symbol_struct *) NULL;
- tdata->data = (struct data_struct *) NULL;
- return true;
-}
-
-/*
- Return true if the file looks like it's in TekHex format. Just look
- for a percent sign and some hex digits */
-
-static const bfd_target *
-tekhex_object_p (abfd)
- bfd *abfd;
-{
- char b[4];
-
- tekhex_init ();
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
- return NULL;
-
- if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
- return (const bfd_target *) NULL;
-
- tekhex_mkobject (abfd);
-
- pass_over (abfd, first_phase);
- return abfd->xvec;
-}
-
-static void
-move_section_contents (abfd, section, locationp, offset, count, get)
- bfd *abfd;
- asection *section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type count;
- boolean get;
-{
- bfd_vma addr;
- char *location = (char *) locationp;
- bfd_vma prev_number = 1; /* Nothing can have this as a high bit*/
- struct data_struct *d = (struct data_struct *) NULL;
-
- for (addr = section->vma; count != 0; count--, addr++)
- {
-
- bfd_vma chunk_number = addr & ~CHUNK_MASK; /* Get high bits of address */
- bfd_vma low_bits = addr & CHUNK_MASK;
-
- if (chunk_number != prev_number)
- {
- /* Different chunk, so move pointer */
- d = find_chunk (abfd, chunk_number);
- }
-
- if (get)
- {
- if (d->chunk_init[low_bits])
- {
- *location = d->chunk_data[low_bits];
- }
- else
- {
- *location = 0;
- }
- }
- else
- {
- d->chunk_data[low_bits] = *location;
- d->chunk_init[low_bits] = (*location != 0);
- }
-
- location++;
-
- }
-
-}
-static boolean
-tekhex_get_section_contents (abfd, section, locationp, offset, count)
- bfd *abfd;
- asection *section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type count;
-{
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, count, true);
- return true;
- }
- else
- return false;
-}
-
-boolean
-tekhex_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- return bfd_default_set_arch_mach (abfd, arch, machine);
-}
-
-/* we have to save up all the Tekhexords for a splurge before output,
- */
-
-static boolean
-tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do)
- bfd *abfd;
- sec_ptr section;
- PTR locationp;
- file_ptr offset;
- bfd_size_type bytes_to_do;
-{
-
- if (abfd->output_has_begun == false)
- {
- /* The first time around, allocate enough sections to hold all the chunks */
- asection *s = abfd->sections;
- bfd_vma vma;
-
- for (s = abfd->sections; s; s = s->next)
- {
- if (s->flags & SEC_LOAD)
- {
- for (vma = s->vma & ~CHUNK_MASK;
- vma < s->vma + s->_raw_size;
- vma += CHUNK_MASK)
- find_chunk (abfd, vma);
- }
- }
-
- }
- if (section->flags & (SEC_LOAD | SEC_ALLOC))
- {
- move_section_contents (abfd, section, locationp, offset, bytes_to_do, false);
- return true;
- }
- else
- return false;
-
-}
-
-static void
-writevalue (dst, value)
- char **dst;
- bfd_vma value;
-{
- char *p = *dst;
- int len;
- int shift;
-
- for (len = 8, shift = 28; shift; shift -= 4, len--)
- {
- if ((value >> shift) & 0xf)
- {
- *p++ = len + '0';
- while (len)
- {
- *p++ = digs[(value >> shift) & 0xf];
- shift -= 4;
- len--;
- }
- *dst = p;
- return;
-
- }
- }
- *p++ = '1';
- *p++ = '0';
- *dst = p;
-}
-
-static void
-writesym (dst, sym)
- char **dst;
- CONST char *sym;
-{
- char *p = *dst;
- int len = (sym ? strlen (sym) : 0);
-
- if (len >= 16)
- {
- *p++ = '0';
- len = 16;
- }
-
- else
- {
- if (len == 0)
- {
- *p++ = '1';
- sym = "$";
- len = 1;
- }
- else
- {
- *p++ = digs[len];
- }
- }
-
- while (len--)
- {
- *p++ = *sym++;
- }
- *dst = p;
-}
-
-static void
-out (abfd, type, start, end)
- bfd *abfd;
- char type;
- char *start;
- char *end;
-{
- int sum = 0;
- char *s;
- char front[6];
- bfd_size_type wrlen;
-
- front[0] = '%';
- TOHEX (front + 1, end - start + 5);
- front[3] = type;
-
- for (s = start; s < end; s++)
- {
- sum += sum_block[(unsigned char) *s];
- }
-
- sum += sum_block[(unsigned char) front[1]]; /* length */
- sum += sum_block[(unsigned char) front[2]];
- sum += sum_block[(unsigned char) front[3]]; /* type */
- TOHEX (front + 4, sum);
- if (bfd_write (front, 1, 6, abfd) != 6)
- abort ();
- end[0] = '\n';
- wrlen = end - start + 1;
- if (bfd_write (start, 1, wrlen, abfd) != wrlen)
- abort ();
-}
-
-static boolean
-tekhex_write_object_contents (abfd)
- bfd *abfd;
-{
- int bytes_written;
- char buffer[100];
- asymbol **p;
- asection *s;
- struct data_struct *d;
-
- bytes_written = 0;
-
- /* And the raw data */
- for (d = abfd->tdata.tekhex_data->data;
- d != (struct data_struct *) NULL;
- d = d->next)
- {
- int low;
-
- CONST int span = 32;
- int addr;
-
- /* Write it in blocks of 32 bytes */
-
- for (addr = 0; addr < CHUNK_MASK + 1; addr += span)
- {
- int need = 0;
-
- /* Check to see if necessary */
- for (low = 0; !need && low < span; low++)
- {
- if (d->chunk_init[addr + low])
- need = 1;
- }
- if (need)
- {
- char *dst = buffer;
-
- writevalue (&dst, addr + d->vma);
- for (low = 0; low < span; low++)
- {
- TOHEX (dst, d->chunk_data[addr + low]);
- dst += 2;
- }
- out (abfd, '6', buffer, dst);
- }
- }
- }
- /* write all the section headers for the sections */
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- char *dst = buffer;
-
- writesym (&dst, s->name);
- *dst++ = '1';
- writevalue (&dst, s->vma);
- writevalue (&dst, s->vma + s->_raw_size);
- out (abfd, '3', buffer, dst);
- }
-
- /* And the symbols */
- for (p = abfd->outsymbols; *p; p++)
- {
- int section_code = bfd_decode_symclass (*p);
-
- if (section_code != '?')
- { /* do not include debug symbols */
- asymbol *s = *p;
- char *dst = buffer;
-
- writesym (&dst, s->section->name);
-
- switch (section_code)
- {
- case 'A':
- *dst++ = '2';
- break;
- case 'a':
- *dst++ = '6';
- break;
- case 'D':
- case 'B':
- case 'O':
- *dst++ = '4';
- break;
- case 'd':
- case 'b':
- case 'o':
- *dst++ = '8';
- break;
- case 'T':
- *dst++ = '3';
- break;
- case 't':
- *dst++ = '7';
- break;
- case 'C':
- case 'U':
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- writesym (&dst, s->name);
- writevalue (&dst, s->value + s->section->vma);
- out (abfd, '3', buffer, dst);
- }
- }
-
- /* And the terminator */
- if (bfd_write ("%0781010\n", 1, 9, abfd) != 9)
- abort ();
- return true;
-}
-
-static int
- tekhex_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-
-{
- return 0;
-}
-
-static asymbol *
-tekhex_make_empty_symbol (abfd)
- bfd *abfd;
-{
- tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
-
- if (!new)
- return NULL;
- new->symbol.the_bfd = abfd;
- new->prev = (struct tekhex_symbol_struct *) NULL;
- return &(new->symbol);
-}
-
-static void
-tekhex_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-static void
-tekhex_print_symbol (ignore_abfd, filep, symbol, how)
- bfd *ignore_abfd;
- PTR filep;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) filep;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_more:
- break;
-
- case bfd_print_symbol_all:
- {
- CONST char *section_name = symbol->section->name;
-
- bfd_print_symbol_vandf ((PTR) file, symbol);
-
- fprintf (file, " %-5s %s",
- section_name,
- symbol->name);
- }
- }
-}
-
-#define tekhex_close_and_cleanup _bfd_generic_close_and_cleanup
-#define tekhex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define tekhex_new_section_hook _bfd_generic_new_section_hook
-
-#define tekhex_bfd_is_local_label bfd_generic_is_local_label
-#define tekhex_get_lineno _bfd_nosymbols_get_lineno
-#define tekhex_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define tekhex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define tekhex_read_minisymbols _bfd_generic_read_minisymbols
-#define tekhex_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define tekhex_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define tekhex_bfd_relax_section bfd_generic_relax_section
-#define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define tekhex_bfd_final_link _bfd_generic_final_link
-#define tekhex_bfd_link_split_section _bfd_generic_link_split_section
-
-#define tekhex_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-const bfd_target tekhex_vec =
-{
- "tekhex", /* name */
- bfd_target_tekhex_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (EXEC_P | /* object flags */
- HAS_SYMS | HAS_LINENO | HAS_DEBUG | HAS_RELOC | HAS_LOCALS |
- WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {
- _bfd_dummy_target,
- tekhex_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- tekhex_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- tekhex_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (tekhex),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (tekhex),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (tekhex),
- BFD_JUMP_TABLE_LINK (tekhex),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/trad-core.c b/contrib/gdb/bfd/trad-core.c
deleted file mode 100644
index 62d6192..0000000
--- a/contrib/gdb/bfd/trad-core.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* BFD back end for traditional Unix core files (U-area and raw sections)
- Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by John Gilmore of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <signal.h>
-
-#include <sys/user.h> /* After a.out.h */
-
-#ifdef TRAD_HEADER
-#include TRAD_HEADER
-#endif
-
- struct trad_core_struct
- {
- asection *data_section;
- asection *stack_section;
- asection *reg_section;
- struct user u;
- };
-
-#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
-#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
-#define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
-#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
-
-/* forward declarations */
-
-const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));
-char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-boolean trad_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
-
-/* ARGSUSED */
-const bfd_target *
-trad_unix_core_file_p (abfd)
- bfd *abfd;
-
-{
- int val;
- struct user u;
- struct trad_core_struct *rawptr;
-
-#ifdef TRAD_CORE_USER_OFFSET
- /* If defined, this macro is the file position of the user struct. */
- if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)
- return 0;
-#endif
-
- val = bfd_read ((void *)&u, 1, sizeof u, abfd);
- if (val != sizeof u)
- {
- /* Too small to be a core file */
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* Sanity check perhaps??? */
- if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- if (u.u_ssize > 0x1000000)
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* Check that the size claimed is no greater than the file size. */
- {
- FILE *stream = bfd_cache_lookup (abfd);
- struct stat statbuf;
- if (stream == NULL)
- return 0;
- if (fstat (fileno (stream), &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return 0;
- }
- if (NBPG * (UPAGES + u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - u.u_tsize
-#endif
- + u.u_ssize) > statbuf.st_size)
- {
- bfd_set_error (bfd_error_file_truncated);
- return 0;
- }
-#ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
- if (NBPG * (UPAGES + u.u_dsize + u.u_ssize)
-#ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
- /* Some systems write the file too big. */
- + TRAD_CORE_EXTRA_SIZE_ALLOWED
-#endif
- < statbuf.st_size)
- {
- /* The file is too big. Maybe it's not a core file
- or we otherwise have bad values for u_dsize and u_ssize). */
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-#endif
- }
-
- /* OK, we believe you. You're a core file (sure, sure). */
-
- /* Allocate both the upage and the struct core_data at once, so
- a single free() will free them both. */
- rawptr = (struct trad_core_struct *)
- bfd_zmalloc (sizeof (struct trad_core_struct));
- if (rawptr == NULL)
- return 0;
-
- abfd->tdata.trad_core_data = rawptr;
-
- rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */
-
- /* Create the sections. This is raunchy, but bfd_close wants to free
- them separately. */
-
- core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_stacksec (abfd) == NULL)
- return NULL;
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_datasec (abfd) == NULL)
- return NULL;
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_regsec (abfd) == NULL)
- return NULL;
-
- core_stacksec (abfd)->name = ".stack";
- core_datasec (abfd)->name = ".data";
- core_regsec (abfd)->name = ".reg";
-
- core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
-
- core_datasec (abfd)->_raw_size = NBPG * u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - NBPG * u.u_tsize
-#endif
- ;
- core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize;
- core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */
-
- /* What a hack... we'd like to steal it from the exec file,
- since the upage does not seem to provide it. FIXME. */
-#ifdef HOST_DATA_START_ADDR
- core_datasec (abfd)->vma = HOST_DATA_START_ADDR;
-#else
- core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);
-#endif
-
-#ifdef HOST_STACK_START_ADDR
- core_stacksec (abfd)->vma = HOST_STACK_START_ADDR;
-#else
- core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
-#endif
-
- /* This is tricky. As the "register section", we give them the entire
- upage and stack. u.u_ar0 points to where "register 0" is stored.
- There are two tricks with this, though. One is that the rest of the
- registers might be at positive or negative (or both) displacements
- from *u_ar0. The other is that u_ar0 is sometimes an absolute address
- in kernel memory, and on other systems it is an offset from the beginning
- of the `struct user'.
-
- As a practical matter, we don't know where the registers actually are,
- so we have to pass the whole area to GDB. We encode the value of u_ar0
- by setting the .regs section up so that its virtual memory address
- 0 is at the place pointed to by u_ar0 (by setting the vma of the start
- of the section to -u_ar0). GDB uses this info to locate the regs,
- using minor trickery to get around the offset-or-absolute-addr problem. */
- core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
-
- core_datasec (abfd)->filepos = NBPG * UPAGES;
- core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
-#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
- - NBPG * u.u_tsize
-#endif
- ;
- core_regsec (abfd)->filepos = 0; /* Register segment is the upage */
-
- /* Align to word at least */
- core_stacksec (abfd)->alignment_power = 2;
- core_datasec (abfd)->alignment_power = 2;
- core_regsec (abfd)->alignment_power = 2;
-
- abfd->sections = core_stacksec (abfd);
- core_stacksec (abfd)->next = core_datasec (abfd);
- core_datasec (abfd)->next = core_regsec (abfd);
- abfd->section_count = 3;
-
- return abfd->xvec;
-}
-
-char *
-trad_unix_core_file_failing_command (abfd)
- bfd *abfd;
-{
-#ifndef NO_CORE_COMMAND
- char *com = abfd->tdata.trad_core_data->u.u_comm;
- if (*com)
- return com;
- else
-#endif
- return 0;
-}
-
-/* ARGSUSED */
-int
-trad_unix_core_file_failing_signal (ignore_abfd)
- bfd *ignore_abfd;
-{
-#ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
- return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
-#else
- return -1; /* FIXME, where is it? */
-#endif
-}
-
-/* ARGSUSED */
-boolean
-trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- return true; /* FIXME, We have no way of telling at this point */
-}
-
-/* If somebody calls any byte-swapping routines, shoot them. */
-void
-swap_abort()
-{
- abort(); /* This way doesn't require any declaration for ANSI to fuck up */
-}
-#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target trad_core_vec =
- {
- "trad-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- trad_unix_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (trad_unix),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
OpenPOWER on IntegriCloud