This commit was generated by cvs2svn to compensate for changes in r19370,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
commit
6157b5cdfb
339
contrib/gdb/COPYING
Normal file
339
contrib/gdb/COPYING
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
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.
|
481
contrib/gdb/COPYING.LIB
Normal file
481
contrib/gdb/COPYING.LIB
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 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.
|
||||||
|
|
||||||
|
[This is the first released version of the library GPL. It is
|
||||||
|
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Library General Public License, applies to some
|
||||||
|
specially designated Free Software Foundation software, and to any
|
||||||
|
other libraries whose authors decide to use it. You can use it for
|
||||||
|
your libraries, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if
|
||||||
|
you distribute copies of the library, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link a program with the library, you must provide
|
||||||
|
complete object files to the recipients so that they can relink them
|
||||||
|
with the library, after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
Our method of protecting your rights has two steps: (1) copyright
|
||||||
|
the library, and (2) offer you this license which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
Also, for each distributor's protection, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
library. If the library is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original
|
||||||
|
version, so that any problems introduced by others will not reflect on
|
||||||
|
the original authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that companies distributing free
|
||||||
|
software will individually obtain patent licenses, thus in effect
|
||||||
|
transforming the program into proprietary software. To prevent this,
|
||||||
|
we have made it clear that any patent must be licensed for everyone's
|
||||||
|
free use or not licensed at all.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the ordinary
|
||||||
|
GNU General Public License, which was designed for utility programs. This
|
||||||
|
license, the GNU Library General Public License, applies to certain
|
||||||
|
designated libraries. This license is quite different from the ordinary
|
||||||
|
one; be sure to read it in full, and don't assume that anything in it is
|
||||||
|
the same as in the ordinary license.
|
||||||
|
|
||||||
|
The reason we have a separate public license for some libraries is that
|
||||||
|
they blur the distinction we usually make between modifying or adding to a
|
||||||
|
program and simply using it. Linking a program with a library, without
|
||||||
|
changing the library, is in some sense simply using the library, and is
|
||||||
|
analogous to running a utility program or application program. However, in
|
||||||
|
a textual and legal sense, the linked executable is a combined work, a
|
||||||
|
derivative of the original library, and the ordinary General Public License
|
||||||
|
treats it as such.
|
||||||
|
|
||||||
|
Because of this blurred distinction, using the ordinary General
|
||||||
|
Public License for libraries did not effectively promote software
|
||||||
|
sharing, because most developers did not use the libraries. We
|
||||||
|
concluded that weaker conditions might promote sharing better.
|
||||||
|
|
||||||
|
However, unrestricted linking of non-free programs would deprive the
|
||||||
|
users of those programs of all benefit from the free status of the
|
||||||
|
libraries themselves. This Library General Public License is intended to
|
||||||
|
permit developers of non-free programs to use free libraries, while
|
||||||
|
preserving your freedom as a user of such programs to change the free
|
||||||
|
libraries that are incorporated in them. (We have not seen how to achieve
|
||||||
|
this as regards changes in header files, but we have achieved it as regards
|
||||||
|
changes in the actual functions of the Library.) The hope is that this
|
||||||
|
will lead to faster development of free libraries.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, while the latter only
|
||||||
|
works together with the library.
|
||||||
|
|
||||||
|
Note that it is possible for a library to be covered by the ordinary
|
||||||
|
General Public License rather than by this special one.
|
||||||
|
|
||||||
|
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library which
|
||||||
|
contains a notice placed by the copyright holder or other authorized
|
||||||
|
party saying it may be distributed under the terms of this Library
|
||||||
|
General Public License (also called "this License"). Each licensee is
|
||||||
|
addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also compile or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
c) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
d) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the source code distributed need not include anything that is normally
|
||||||
|
distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Library General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Appendix: How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1990
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
1366
contrib/gdb/Makefile.in
Normal file
1366
contrib/gdb/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
50
contrib/gdb/README
Normal file
50
contrib/gdb/README
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
README for GNU development tools
|
||||||
|
|
||||||
|
This directory contains various GNU compilers, assemblers, linkers,
|
||||||
|
debuggers, etc., plus their support routines, definitions, and documentation.
|
||||||
|
|
||||||
|
If you are receiving this as part of a GDB release, see the file gdb/README.
|
||||||
|
If with a gas release, see gas/README; if with a libg++ release,
|
||||||
|
see libg++/README, etc. That'll give you info about this
|
||||||
|
package -- supported targets, how to use it, how to report bugs, etc.
|
||||||
|
|
||||||
|
It is now possible to automatically configure and build a variety of
|
||||||
|
tools with one command. To build all of the tools contained herein,
|
||||||
|
run the ``configure'' script here, e.g.:
|
||||||
|
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
To install them (by default in /usr/local/bin, /usr/local/lib, etc),
|
||||||
|
then do:
|
||||||
|
make install
|
||||||
|
|
||||||
|
If the configure script can't determine your type of computer, give it
|
||||||
|
the name as an argument, for instance ``./configure sun4''. You can
|
||||||
|
use the script ``config.sub'' to test whether a name is recognized; if
|
||||||
|
it is, config.sub translates it to a triplet specifying CPU, vendor,
|
||||||
|
and OS.)
|
||||||
|
|
||||||
|
If you have more than one compiler on your system, it is often best to
|
||||||
|
explicitly set CC in the environment before running configure, and to
|
||||||
|
also set CC when running make. For example (assuming sh/bash/ksh):
|
||||||
|
|
||||||
|
CC=gcc ./configure
|
||||||
|
make CC=gcc
|
||||||
|
|
||||||
|
A similar example using csh:
|
||||||
|
|
||||||
|
setenv CC gcc
|
||||||
|
./configure
|
||||||
|
make CC=gcc
|
||||||
|
|
||||||
|
See etc/cfg-paper.texi, etc/configure.texi, and/or the README files in
|
||||||
|
various subdirectories, for more details.
|
||||||
|
|
||||||
|
Much of the code and documentation enclosed is copyright by
|
||||||
|
the Free Software Foundation, Inc. See the file COPYING or
|
||||||
|
COPYING.LIB in the various directories, for a description of the
|
||||||
|
GNU General Public License terms under which you can copy the files.
|
||||||
|
|
||||||
|
REPORTING BUGS: Again, see gdb/README, gas/README, etc., for info on where and
|
||||||
|
how to report problems.
|
339
contrib/gdb/bfd/COPYING
Normal file
339
contrib/gdb/bfd/COPYING
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
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.
|
1090
contrib/gdb/bfd/Makefile.in
Normal file
1090
contrib/gdb/bfd/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
83
contrib/gdb/bfd/PORTING
Normal file
83
contrib/gdb/bfd/PORTING
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
Preliminary Notes on Porting BFD
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The 'host' is the system a tool runs *on*.
|
||||||
|
The 'target' is the system a tool runs *for*, i.e.
|
||||||
|
a tool can read/write the binaries of the target.
|
||||||
|
|
||||||
|
Porting to a new host
|
||||||
|
---------------------
|
||||||
|
Pick a name for your host. Call that <host>.
|
||||||
|
(<host> might be sun4, ...)
|
||||||
|
Create a file hosts/<host>.mh.
|
||||||
|
|
||||||
|
Porting to a new target
|
||||||
|
-----------------------
|
||||||
|
Pick a name for your target. Call that <target>.
|
||||||
|
Call the name for your CPU architecture <cpu>.
|
||||||
|
You need to create <target>.c and config/<target>.mt,
|
||||||
|
and add a case for it to a case statements in bfd/configure.host and
|
||||||
|
bfd/config.bfd, which associates each canonical host type with a BFD
|
||||||
|
host type (used as the base of the makefile fragment names), and to the
|
||||||
|
table in bfd/configure.in which associates each target vector with
|
||||||
|
the .o files it uses.
|
||||||
|
|
||||||
|
config/<target>.mt is a Makefile fragment.
|
||||||
|
The following is usually enough:
|
||||||
|
DEFAULT_VECTOR=<target>_vec
|
||||||
|
SELECT_ARCHITECTURES=bfd_<cpu>_arch
|
||||||
|
|
||||||
|
See the list of cpu types in archures.c, or "ls cpu-*.c".
|
||||||
|
If your architecture is new, you need to add it to the tables
|
||||||
|
in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
|
||||||
|
|
||||||
|
For more information about .mt and .mh files, see config/README.
|
||||||
|
|
||||||
|
The file <target>.c is the hard part. It implements the
|
||||||
|
bfd_target <target>_vec, which includes pointers to
|
||||||
|
functions that do the actual <target>-specific methods.
|
||||||
|
|
||||||
|
Porting to a <target> that uses the a.out binary format
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
In this case, the include file aout-target.h probaby does most
|
||||||
|
of what you need. The program gen-aout generates <target>.c for
|
||||||
|
you automatically for many a.out systems. Do:
|
||||||
|
make gen-aout
|
||||||
|
./gen-aout <target> > <target>.c
|
||||||
|
(This only works if you are building on the target ("native").
|
||||||
|
If you must make a cross-port from scratch, copy the most
|
||||||
|
similar existing file that includes aout-target.h, and fix what is wrong.)
|
||||||
|
|
||||||
|
Check the parameters in <target>.c, and fix anything that is wrong.
|
||||||
|
(Also let us know about it; perhaps we can improve gen-aout.c.)
|
||||||
|
|
||||||
|
TARGET_IS_BIG_ENDIAN_P
|
||||||
|
Should be defined if <target> is big-endian.
|
||||||
|
|
||||||
|
N_HEADER_IN_TEXT(x)
|
||||||
|
See discussion in ../include/aout/aout64.h.
|
||||||
|
|
||||||
|
BYTES_IN_WORD
|
||||||
|
Number of bytes per word. (Usually 4 but can be 8.)
|
||||||
|
|
||||||
|
ARCH
|
||||||
|
Number of bits per word. (Usually 32, but can be 64.)
|
||||||
|
|
||||||
|
ENTRY_CAN_BE_ZERO
|
||||||
|
Define if the extry point (start address of an
|
||||||
|
executable program) can be 0x0.
|
||||||
|
|
||||||
|
TEXT_START_ADDR
|
||||||
|
The address of the start of the text segemnt in
|
||||||
|
virtual memory. Normally, the same as the entry point.
|
||||||
|
|
||||||
|
TARGET_PAGE_SIZE
|
||||||
|
|
||||||
|
SEGMENT_SIZE
|
||||||
|
Usually, the same as the TARGET_PAGE_SIZE.
|
||||||
|
Alignment needed for the data segment.
|
||||||
|
|
||||||
|
TARGETNAME
|
||||||
|
The name of the target, for run-time lookups.
|
||||||
|
Usually "a.out-<target>"
|
25
contrib/gdb/bfd/TODO
Normal file
25
contrib/gdb/bfd/TODO
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
Things that still need to be done: -*- Text -*-
|
||||||
|
|
||||||
|
o - A source of space lossage is that all the target-dependent code
|
||||||
|
is in a single bfd_target structure. Hence all the code for
|
||||||
|
*writing* object files is still pulled into all the applications
|
||||||
|
that only care about *reading* (gdb, nm, objdump), while gas has
|
||||||
|
to carry along all the 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
contrib/gdb/bfd/VERSION
Normal file
1
contrib/gdb/bfd/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
cygnus-2.6
|
19
contrib/gdb/bfd/acconfig.h
Normal file
19
contrib/gdb/bfd/acconfig.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
/* 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
|
||||||
|
@TOP@
|
||||||
|
|
||||||
|
/* 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
|
43
contrib/gdb/bfd/aclocal.m4
vendored
Normal file
43
contrib/gdb/bfd/aclocal.m4
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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
|
285
contrib/gdb/bfd/aix386-core.c
Normal file
285
contrib/gdb/bfd/aix386-core.c
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
/* BFD back-end for AIX on PS/2 core files.
|
||||||
|
This was based on trad-core.c, which was written by John Gilmore of
|
||||||
|
Cygnus Support.
|
||||||
|
Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
|
||||||
|
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/i386.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#if defined (_AIX) && defined (_I386)
|
||||||
|
#define NOCHECKS /* this is for coredump.h */
|
||||||
|
#define _h_USER /* avoid including user.h from coredump.h */
|
||||||
|
#include <uinfo.h>
|
||||||
|
#include <sys/i386/coredump.h>
|
||||||
|
#endif /* _AIX && _I386 */
|
||||||
|
|
||||||
|
/* maybe this could work on some other i386 but I have not tried it
|
||||||
|
* mtranle@paris - Tue Sep 24 12:49:35 1991
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COR_MAGIC
|
||||||
|
# define COR_MAGIC "core"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* need this cast because ptr is really void * */
|
||||||
|
#define core_hdr(bfd) \
|
||||||
|
(((bfd->tdata.trad_core_data))->hdr)
|
||||||
|
#define core_section(bfd,n) \
|
||||||
|
(((bfd)->tdata.trad_core_data)->sections[n])
|
||||||
|
#define core_regsec(bfd) \
|
||||||
|
(((bfd)->tdata.trad_core_data)->reg_section)
|
||||||
|
#define core_reg2sec(bfd) \
|
||||||
|
(((bfd)->tdata.trad_core_data)->reg2_section)
|
||||||
|
|
||||||
|
/* These are stored in the bfd's tdata */
|
||||||
|
struct trad_core_struct {
|
||||||
|
struct corehdr *hdr; /* core file header */
|
||||||
|
asection *reg_section;
|
||||||
|
asection *reg2_section;
|
||||||
|
asection *sections[MAX_CORE_SEGS];
|
||||||
|
};
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
aix386_core_file_p (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
int i,n;
|
||||||
|
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||||
|
int core_size = sizeof (struct corehdr);
|
||||||
|
struct corehdr *core;
|
||||||
|
struct mergem {
|
||||||
|
struct trad_core_struct coredata;
|
||||||
|
struct corehdr internal_core;
|
||||||
|
} *mergem;
|
||||||
|
|
||||||
|
if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp(longbuf,COR_MAGIC,4)) return 0;
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, 0L, false) < 0) return 0;
|
||||||
|
|
||||||
|
mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
|
||||||
|
if (mergem == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
core = &mergem->internal_core;
|
||||||
|
|
||||||
|
if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
bfd_release (abfd, (char *)mergem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_tdata (abfd, &mergem->coredata);
|
||||||
|
core_hdr (abfd) = core;
|
||||||
|
|
||||||
|
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||||
|
them */
|
||||||
|
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_regsec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
loser:
|
||||||
|
bfd_release (abfd, (char *)mergem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_reg2sec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
loser1:
|
||||||
|
bfd_release (abfd, core_regsec (abfd));
|
||||||
|
goto loser;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0, n=0 ; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type) ; i++)
|
||||||
|
{
|
||||||
|
if (core->cd_segs[i].cs_offset == 0)
|
||||||
|
continue;
|
||||||
|
core_section (abfd,n) =
|
||||||
|
(asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_section (abfd,n) == NULL)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
if (n > 0)
|
||||||
|
{
|
||||||
|
for (j=0; j < n; j++)
|
||||||
|
bfd_release (abfd, core_section(abfd, j));
|
||||||
|
}
|
||||||
|
bfd_release (abfd, (char *)mergem);
|
||||||
|
goto loser1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (core->cd_segs[i].cs_type)
|
||||||
|
{
|
||||||
|
case COR_TYPE_DATA:
|
||||||
|
core_section (abfd, n)->name = ".data";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||||
|
SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
case COR_TYPE_STACK:
|
||||||
|
core_section (abfd, n)->name = ".stack";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||||
|
SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
case COR_TYPE_LIBDATA:
|
||||||
|
core_section (abfd, n)->name = ".libdata";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
case COR_TYPE_WRITE:
|
||||||
|
core_section (abfd, n)->name = ".writeable";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
case COR_TYPE_MSC:
|
||||||
|
core_section (abfd, n)->name = ".misc";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
core_section (abfd, n)->name = ".unknown";
|
||||||
|
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len;
|
||||||
|
core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
|
||||||
|
core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
|
||||||
|
core_section (abfd, n)->alignment_power = 2;
|
||||||
|
core_section (abfd, n)->next = NULL;
|
||||||
|
if (n > 0)
|
||||||
|
core_section (abfd, (n-1))->next = core_section (abfd, n);
|
||||||
|
|
||||||
|
abfd->section_count = ++n;
|
||||||
|
}
|
||||||
|
|
||||||
|
core_regsec (abfd)->name = ".reg";
|
||||||
|
core_reg2sec (abfd)->name = ".reg2";
|
||||||
|
|
||||||
|
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||||
|
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||||
|
|
||||||
|
core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
|
||||||
|
core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
|
||||||
|
|
||||||
|
core_regsec (abfd)->vma = -1;
|
||||||
|
core_reg2sec (abfd)->vma = -1;
|
||||||
|
|
||||||
|
/* We'll access the regs afresh in the core file, like any section: */
|
||||||
|
core_regsec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,cd_regs[0]);
|
||||||
|
core_reg2sec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,
|
||||||
|
cd_fpregs);
|
||||||
|
|
||||||
|
/* add the 2 reg fake sections to abfd */
|
||||||
|
abfd->section_count += 2;
|
||||||
|
abfd->sections = core_regsec (abfd);
|
||||||
|
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||||
|
core_reg2sec (abfd)->next = core_section (abfd, 0);
|
||||||
|
|
||||||
|
return abfd->xvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
aix386_core_file_failing_command (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return core_hdr (abfd)->cd_comm;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
aix386_core_file_failing_signal (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return core_hdr (abfd)->cd_cursig;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||||
|
bfd *core_bfd;
|
||||||
|
bfd *exec_bfd;
|
||||||
|
{
|
||||||
|
return true; /* FIXME, We have no way of telling at this
|
||||||
|
point */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||||
|
void
|
||||||
|
swap_abort()
|
||||||
|
{
|
||||||
|
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||||
|
}
|
||||||
|
#define NO_GET ((PROTO(bfd_vma, (*), ( const bfd_byte *))) swap_abort )
|
||||||
|
#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
|
||||||
|
#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
|
||||||
|
|
||||||
|
const bfd_target aix386_core_vec =
|
||||||
|
{
|
||||||
|
"aix386-core",
|
||||||
|
bfd_target_unknown_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* target byte order */
|
||||||
|
BFD_ENDIANG_BIG, /* target headers byte order */
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
0, /* leading underscore */
|
||||||
|
' ', /* ar_pad_char */
|
||||||
|
16, /* ar_max_namelen */
|
||||||
|
NO_GET, NO_GETS, NO_PUT,
|
||||||
|
NO_GET, NO_GETS, NO_PUT,
|
||||||
|
NO_GET, NO_GETS, NO_PUT, /* data */
|
||||||
|
NO_GET, NO_GETS, NO_PUT,
|
||||||
|
NO_GET, NO_GETS, NO_PUT,
|
||||||
|
NO_GET, NO_GETS, NO_PUT, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, _bfd_dummy_target,
|
||||||
|
_bfd_dummy_target, aix386_core_file_p},
|
||||||
|
{bfd_false, bfd_false, /* bfd_create_object */
|
||||||
|
bfd_false, bfd_false},
|
||||||
|
{bfd_false, bfd_false, /* bfd_write_contents */
|
||||||
|
bfd_false, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_CORE (aix386),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||||
|
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
(PTR) 0
|
||||||
|
};
|
528
contrib/gdb/bfd/aout-adobe.c
Normal file
528
contrib/gdb/bfd/aout-adobe.c
Normal file
@ -0,0 +1,528 @@
|
|||||||
|
/* BFD back-end for a.out.adobe binaries.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support. Based on bout.c.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
#include "aout/adobe.h"
|
||||||
|
|
||||||
|
#include "aout/stab_gnu.h"
|
||||||
|
#include "libaout.h" /* BFD a.out internal data structures */
|
||||||
|
|
||||||
|
extern const bfd_target a_out_adobe_vec; /* Forward decl */
|
||||||
|
|
||||||
|
static const bfd_target *aout_adobe_callback PARAMS ((bfd *));
|
||||||
|
|
||||||
|
extern boolean aout_32_slurp_symbol_table PARAMS ((bfd *abfd));
|
||||||
|
extern boolean aout_32_write_syms PARAMS ((bfd *));
|
||||||
|
static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect));
|
||||||
|
|
||||||
|
/* Swaps the information in an executable header taken from a raw byte
|
||||||
|
stream memory image, into the internal exec_header structure. */
|
||||||
|
|
||||||
|
void aout_adobe_swap_exec_header_in
|
||||||
|
PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
|
||||||
|
struct internal_exec *execp));
|
||||||
|
|
||||||
|
void
|
||||||
|
aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||||
|
bfd *abfd;
|
||||||
|
struct external_exec *raw_bytes;
|
||||||
|
struct internal_exec *execp;
|
||||||
|
{
|
||||||
|
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||||
|
|
||||||
|
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||||
|
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
|
||||||
|
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||||
|
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||||
|
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||||
|
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||||
|
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||||
|
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||||
|
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Swaps the information in an internal exec header structure into the
|
||||||
|
supplied buffer ready for writing to disk. */
|
||||||
|
|
||||||
|
PROTO(void, aout_adobe_swap_exec_header_out,
|
||||||
|
(bfd *abfd,
|
||||||
|
struct internal_exec *execp,
|
||||||
|
struct external_exec *raw_bytes));
|
||||||
|
void
|
||||||
|
aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
|
||||||
|
bfd *abfd;
|
||||||
|
struct internal_exec *execp;
|
||||||
|
struct external_exec *raw_bytes;
|
||||||
|
{
|
||||||
|
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||||
|
|
||||||
|
/* Now fill in fields in the raw data, from the fields in the exec struct. */
|
||||||
|
bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
|
||||||
|
PUT_WORD (abfd, execp->a_text , bytes->e_text);
|
||||||
|
PUT_WORD (abfd, execp->a_data , bytes->e_data);
|
||||||
|
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
|
||||||
|
PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
|
||||||
|
PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
|
||||||
|
PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
|
||||||
|
PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
aout_adobe_object_p (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct internal_exec anexec;
|
||||||
|
struct external_exec exec_bytes;
|
||||||
|
char *targ;
|
||||||
|
|
||||||
|
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||||
|
!= EXEC_BYTES_SIZE) {
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
||||||
|
|
||||||
|
/* Normally we just compare for the magic number.
|
||||||
|
However, a bunch of Adobe tools aren't fixed up yet; they generate
|
||||||
|
files using ZMAGIC(!).
|
||||||
|
If the environment variable GNUTARGET is set to "a.out.adobe", we will
|
||||||
|
take just about any a.out file as an Adobe a.out file. FIXME! */
|
||||||
|
|
||||||
|
if (N_BADMAG (anexec)) {
|
||||||
|
extern char *getenv ();
|
||||||
|
|
||||||
|
targ = getenv ("GNUTARGET");
|
||||||
|
if (targ && !strcmp (targ, a_out_adobe_vec.name))
|
||||||
|
; /* Just continue anyway, if specifically set to this format */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
|
||||||
|
return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Finish up the opening of a b.out file for reading. Fill in all the
|
||||||
|
fields that are not handled by common code. */
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
aout_adobe_callback (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct internal_exec *execp = exec_hdr (abfd);
|
||||||
|
asection *sect;
|
||||||
|
struct external_segdesc ext[1];
|
||||||
|
char *section_name;
|
||||||
|
char try_again[30]; /* name and number */
|
||||||
|
char *newname;
|
||||||
|
int trynum;
|
||||||
|
flagword flags;
|
||||||
|
|
||||||
|
/* Architecture and machine type -- unknown in this format. */
|
||||||
|
bfd_set_arch_mach(abfd, bfd_arch_unknown, 0);
|
||||||
|
|
||||||
|
/* The positions of the string table and symbol table. */
|
||||||
|
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||||
|
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||||
|
|
||||||
|
/* Suck up the section information from the file, one section at a time. */
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
switch (ext->e_type[0]) {
|
||||||
|
case N_TEXT:
|
||||||
|
section_name = ".text";
|
||||||
|
flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case N_DATA:
|
||||||
|
section_name = ".data";
|
||||||
|
flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case N_BSS:
|
||||||
|
section_name = ".bss";
|
||||||
|
flags = SEC_DATA | SEC_HAS_CONTENTS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
goto no_more_sections;
|
||||||
|
|
||||||
|
default:
|
||||||
|
(*_bfd_error_handler)
|
||||||
|
("%s: Unknown section type in a.out.adobe file: %x\n",
|
||||||
|
bfd_get_filename (abfd), ext->e_type[0]);
|
||||||
|
goto no_more_sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* First one is called ".text" or whatever; subsequent ones are
|
||||||
|
".text1", ".text2", ... */
|
||||||
|
|
||||||
|
bfd_set_error (bfd_error_no_error);
|
||||||
|
sect = bfd_make_section (abfd, section_name);
|
||||||
|
trynum = 0;
|
||||||
|
while (!sect) {
|
||||||
|
if (bfd_get_error () != bfd_error_no_error)
|
||||||
|
return 0; /* Some other error -- slide into the sunset */
|
||||||
|
sprintf (try_again, "%s%d", section_name, ++trynum);
|
||||||
|
sect = bfd_make_section (abfd, try_again);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix the name, if it is a sprintf'd name. */
|
||||||
|
if (sect->name == try_again) {
|
||||||
|
newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
|
||||||
|
if (newname == NULL)
|
||||||
|
return 0;
|
||||||
|
strcpy (newname, sect->name);
|
||||||
|
sect->name = newname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now set the section's attributes. */
|
||||||
|
bfd_set_section_flags (abfd, sect, flags);
|
||||||
|
sect->_raw_size = ((ext->e_size[0] << 8) /* Assumed big-endian */
|
||||||
|
| ext->e_size[1] << 8)
|
||||||
|
| ext->e_size[2];
|
||||||
|
sect->_cooked_size = sect->_raw_size;
|
||||||
|
sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
|
||||||
|
sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
|
||||||
|
/* FIXME XXX alignment? */
|
||||||
|
|
||||||
|
/* Set relocation information for first section of each type. */
|
||||||
|
if (trynum == 0) switch (ext->e_type[0]) {
|
||||||
|
case N_TEXT:
|
||||||
|
sect->rel_filepos = N_TRELOFF (*execp);
|
||||||
|
sect->reloc_count = execp->a_trsize;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case N_DATA:
|
||||||
|
sect->rel_filepos = N_DRELOFF (*execp);
|
||||||
|
sect->reloc_count = execp->a_drsize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
no_more_sections:
|
||||||
|
|
||||||
|
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||||
|
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||||
|
adata(abfd).page_size = 1; /* Not applicable. */
|
||||||
|
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||||
|
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||||
|
|
||||||
|
return abfd->xvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct bout_data_struct {
|
||||||
|
struct aoutdata a;
|
||||||
|
struct internal_exec e;
|
||||||
|
};
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
aout_adobe_mkobject (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct bout_data_struct *rawptr;
|
||||||
|
|
||||||
|
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
|
||||||
|
if (rawptr == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
abfd->tdata.bout_data = rawptr;
|
||||||
|
exec_hdr (abfd) = &rawptr->e;
|
||||||
|
|
||||||
|
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||||
|
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||||
|
adata(abfd).page_size = 1; /* Not applicable. */
|
||||||
|
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||||
|
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
aout_adobe_write_object_contents (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct external_exec swapped_hdr;
|
||||||
|
static struct external_segdesc sentinel[1]; /* Initialized to zero */
|
||||||
|
asection *sect;
|
||||||
|
|
||||||
|
exec_hdr (abfd)->a_info = ZMAGIC;
|
||||||
|
|
||||||
|
/* Calculate text size as total of text sections, etc. */
|
||||||
|
|
||||||
|
exec_hdr (abfd)->a_text = 0;
|
||||||
|
exec_hdr (abfd)->a_data = 0;
|
||||||
|
exec_hdr (abfd)->a_bss = 0;
|
||||||
|
exec_hdr (abfd)->a_trsize = 0;
|
||||||
|
exec_hdr (abfd)->a_drsize = 0;
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_CODE) {
|
||||||
|
exec_hdr (abfd)->a_text += sect->_raw_size;
|
||||||
|
exec_hdr (abfd)->a_trsize += sect->reloc_count *
|
||||||
|
sizeof (struct reloc_std_external);
|
||||||
|
} else if (sect->flags & SEC_DATA) {
|
||||||
|
exec_hdr (abfd)->a_data += sect->_raw_size;
|
||||||
|
exec_hdr (abfd)->a_drsize += sect->reloc_count *
|
||||||
|
sizeof (struct reloc_std_external);
|
||||||
|
} else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) {
|
||||||
|
exec_hdr (abfd)->a_bss += sect->_raw_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
|
||||||
|
* sizeof (struct external_nlist);
|
||||||
|
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||||
|
|
||||||
|
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||||
|
|| (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
|
||||||
|
!= EXEC_BYTES_SIZE))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Now write out the section information. Text first, data next, rest
|
||||||
|
afterward. */
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_CODE) {
|
||||||
|
aout_adobe_write_section (abfd, sect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_DATA) {
|
||||||
|
aout_adobe_write_section (abfd, sect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||||
|
aout_adobe_write_section (abfd, sect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write final `sentinel` section header (with type of 0). */
|
||||||
|
if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
|
||||||
|
!= sizeof (*sentinel))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Now write out reloc info, followed by syms and strings */
|
||||||
|
if (bfd_get_symcount (abfd) != 0)
|
||||||
|
{
|
||||||
|
if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||||
|
!= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (! aout_32_write_syms (abfd))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||||
|
!= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_CODE) {
|
||||||
|
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||||
|
!= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_DATA) {
|
||||||
|
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
aout_adobe_write_section (abfd, sect)
|
||||||
|
bfd *abfd;
|
||||||
|
sec_ptr sect;
|
||||||
|
{
|
||||||
|
/* FIXME XXX */
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
aout_adobe_set_section_contents (abfd, section, location, offset, count)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *section;
|
||||||
|
PTR location;
|
||||||
|
file_ptr offset;
|
||||||
|
bfd_size_type count;
|
||||||
|
{
|
||||||
|
file_ptr section_start;
|
||||||
|
sec_ptr sect;
|
||||||
|
|
||||||
|
if (abfd->output_has_begun == false) { /* set by bfd.c handler */
|
||||||
|
|
||||||
|
/* Assign file offsets to sections. Text sections are first, and
|
||||||
|
are contiguous. Then data sections. Everything else at the end. */
|
||||||
|
|
||||||
|
section_start = N_TXTOFF (ignore<-->me);
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_CODE) {
|
||||||
|
sect->filepos = section_start;
|
||||||
|
/* FIXME: Round to alignment */
|
||||||
|
section_start += sect->_raw_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_DATA) {
|
||||||
|
sect->filepos = section_start;
|
||||||
|
/* FIXME: Round to alignment */
|
||||||
|
section_start += sect->_raw_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||||
|
if (sect->flags & SEC_HAS_CONTENTS &&
|
||||||
|
!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||||
|
sect->filepos = section_start;
|
||||||
|
/* FIXME: Round to alignment */
|
||||||
|
section_start += sect->_raw_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* regardless, once we know what we're doing, we might as well get going */
|
||||||
|
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (count != 0) {
|
||||||
|
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
aout_adobe_set_arch_mach (abfd, arch, machine)
|
||||||
|
bfd *abfd;
|
||||||
|
enum bfd_architecture arch;
|
||||||
|
unsigned long machine;
|
||||||
|
{
|
||||||
|
if (! bfd_default_set_arch_mach (abfd, arch, machine))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (arch == bfd_arch_unknown
|
||||||
|
|| arch == bfd_arch_m68k)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
aout_adobe_sizeof_headers (ignore_abfd, ignore)
|
||||||
|
bfd *ignore_abfd;
|
||||||
|
boolean ignore;
|
||||||
|
{
|
||||||
|
return sizeof(struct internal_exec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Build the transfer vector for Adobe A.Out files. */
|
||||||
|
|
||||||
|
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||||
|
|
||||||
|
#define aout_32_bfd_make_debug_symbol \
|
||||||
|
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||||
|
|
||||||
|
#define aout_32_bfd_reloc_type_lookup \
|
||||||
|
((reloc_howto_type *(*) \
|
||||||
|
PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
|
||||||
|
|
||||||
|
#define aout_32_set_arch_mach aout_adobe_set_arch_mach
|
||||||
|
#define aout_32_set_section_contents aout_adobe_set_section_contents
|
||||||
|
|
||||||
|
#define aout_32_sizeof_headers aout_adobe_sizeof_headers
|
||||||
|
#define aout_32_bfd_get_relocated_section_contents \
|
||||||
|
bfd_generic_get_relocated_section_contents
|
||||||
|
#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||||
|
#define aout_32_bfd_relax_section bfd_generic_relax_section
|
||||||
|
#define aout_32_bfd_link_hash_table_create \
|
||||||
|
_bfd_generic_link_hash_table_create
|
||||||
|
#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||||
|
#define aout_32_bfd_final_link _bfd_generic_final_link
|
||||||
|
#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
|
||||||
|
|
||||||
|
const bfd_target a_out_adobe_vec =
|
||||||
|
{
|
||||||
|
"a.out.adobe", /* name */
|
||||||
|
bfd_target_aout_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
|
||||||
|
BFD_ENDIAN_BIG, /* hdr byte order is big */
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||||
|
/* section flags */
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
|
||||||
|
'_', /* symbol leading char */
|
||||||
|
' ', /* ar_pad_char */
|
||||||
|
16, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
{_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, aout_adobe_mkobject, /* bfd_set_format */
|
||||||
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
|
{bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (aout_32),
|
||||||
|
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (aout_32),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (aout_32),
|
||||||
|
BFD_JUMP_TABLE_WRITE (aout_32),
|
||||||
|
BFD_JUMP_TABLE_LINK (aout_32),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
(PTR) 0
|
||||||
|
};
|
548
contrib/gdb/bfd/aout-arm.c
Normal file
548
contrib/gdb/bfd/aout-arm.c
Normal file
@ -0,0 +1,548 @@
|
|||||||
|
/* BFD back-end for raw ARM a.out binaries.
|
||||||
|
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||||
|
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
|
||||||
|
#define N_TXTADDR(x) \
|
||||||
|
((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
|
||||||
|
(N_MAGIC(x) != ZMAGIC) ? 0 : \
|
||||||
|
(N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
|
||||||
|
TEXT_START_ADDR)
|
||||||
|
|
||||||
|
#define TEXT_START_ADDR 0x8000
|
||||||
|
#define TARGET_PAGE_SIZE 0x8000
|
||||||
|
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||||
|
#define DEFAULT_ARCH bfd_arch_arm
|
||||||
|
|
||||||
|
#define MY(OP) CAT(aoutarm_,OP)
|
||||||
|
#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
|
||||||
|
(((x).a_info & ~006000) != OMAGIC) && \
|
||||||
|
((x).a_info != NMAGIC))
|
||||||
|
#define N_MAGIC(x) ((x).a_info & ~07200)
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "assert.h"
|
||||||
|
|
||||||
|
#define MYARM(OP) CAT(aoutarm_,OP)
|
||||||
|
reloc_howto_type *MYARM(bfd_reloc_type_lookup)
|
||||||
|
PARAMS((bfd *, bfd_reloc_code_real_type));
|
||||||
|
static boolean MYARM(write_object_contents) PARAMS((bfd *));
|
||||||
|
|
||||||
|
/* Avoid multiple defininitions from aoutx if supporting standarad a.out
|
||||||
|
as well as our own. */
|
||||||
|
#define NAME(x,y) CAT3(aoutarm,_32_,y)
|
||||||
|
|
||||||
|
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||||
|
|
||||||
|
#include "libaout.h"
|
||||||
|
#include "aout/aout64.h"
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||||
|
asection *, bfd *, char **));
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||||
|
asection *, bfd *, char **));
|
||||||
|
static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
|
||||||
|
arelent *, asymbol **,
|
||||||
|
bfd_size_type));
|
||||||
|
void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *,
|
||||||
|
struct reloc_std_external *));
|
||||||
|
|
||||||
|
reloc_howto_type MY(howto_table)[] =
|
||||||
|
{
|
||||||
|
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask
|
||||||
|
pcdone */
|
||||||
|
HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,
|
||||||
|
0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,
|
||||||
|
0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,
|
||||||
|
0xffffffff, 0xffffffff, false),
|
||||||
|
HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),
|
||||||
|
"ARM26", true, 0x00ffffff, 0x00ffffff, true),
|
||||||
|
HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,
|
||||||
|
0x000000ff, 0x000000ff, true),
|
||||||
|
HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,
|
||||||
|
0x0000ffff, 0x0000ffff, true),
|
||||||
|
HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,
|
||||||
|
0xffffffff, 0xffffffff, true),
|
||||||
|
HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,
|
||||||
|
MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,
|
||||||
|
false),
|
||||||
|
{-1},
|
||||||
|
HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,
|
||||||
|
0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,
|
||||||
|
0xffffffff, 0xffffffff, false)
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
|
||||||
|
#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
|
||||||
|
|
||||||
|
reloc_howto_type *
|
||||||
|
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||||
|
bfd *abfd;
|
||||||
|
struct reloc_std_external *rel;
|
||||||
|
int *r_index;
|
||||||
|
int *r_extern;
|
||||||
|
int *r_pcrel;
|
||||||
|
{
|
||||||
|
unsigned int r_length;
|
||||||
|
unsigned int r_pcrel_done;
|
||||||
|
unsigned int r_neg;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
*r_pcrel = 0;
|
||||||
|
if (bfd_header_big_endian (abfd))
|
||||||
|
{
|
||||||
|
*r_index = ((rel->r_index[0] << 16)
|
||||||
|
| (rel->r_index[1] << 8)
|
||||||
|
| rel->r_index[2]);
|
||||||
|
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
|
||||||
|
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
|
||||||
|
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
|
||||||
|
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
|
||||||
|
>> RELOC_STD_BITS_LENGTH_SH_BIG);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*r_index = ((rel->r_index[2] << 16)
|
||||||
|
| (rel->r_index[1] << 8)
|
||||||
|
| rel->r_index[0]);
|
||||||
|
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||||
|
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||||
|
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
|
||||||
|
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||||
|
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||||
|
}
|
||||||
|
index = r_length + 4 * r_pcrel_done + 8 * r_neg;
|
||||||
|
if (index == 3)
|
||||||
|
*r_pcrel = 1;
|
||||||
|
|
||||||
|
return MY(howto_table) + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
|
||||||
|
MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
|
||||||
|
|
||||||
|
void
|
||||||
|
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||||
|
bfd *abfd;
|
||||||
|
int r_extern;
|
||||||
|
int r_index;
|
||||||
|
long value;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
struct reloc_std_external *reloc;
|
||||||
|
{
|
||||||
|
unsigned int r_length;
|
||||||
|
int r_pcrel;
|
||||||
|
int r_neg;
|
||||||
|
|
||||||
|
PUT_WORD (abfd, value, reloc->r_address);
|
||||||
|
r_length = howto->size ; /* Size as a power of two */
|
||||||
|
|
||||||
|
/* Special case for branch relocations. */
|
||||||
|
if (howto->type == 3 || howto->type == 7)
|
||||||
|
r_length = 3;
|
||||||
|
|
||||||
|
r_pcrel = howto->type & 4; /* PC Relative done? */
|
||||||
|
r_neg = howto->type & 8; /* Negative relocation */
|
||||||
|
if (bfd_header_big_endian (abfd))
|
||||||
|
{
|
||||||
|
reloc->r_index[0] = r_index >> 16;
|
||||||
|
reloc->r_index[1] = r_index >> 8;
|
||||||
|
reloc->r_index[2] = r_index;
|
||||||
|
reloc->r_type[0] =
|
||||||
|
((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
|
||||||
|
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
|
||||||
|
| (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
|
||||||
|
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reloc->r_index[2] = r_index >> 16;
|
||||||
|
reloc->r_index[1] = r_index >> 8;
|
||||||
|
reloc->r_index[0] = r_index;
|
||||||
|
reloc->r_type[0] =
|
||||||
|
((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
|
||||||
|
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
|
||||||
|
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
|
||||||
|
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||||
|
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||||
|
|
||||||
|
void
|
||||||
|
MY(relocatable_reloc)(howto, abfd, reloc, amount, r_addr)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
bfd *abfd;
|
||||||
|
struct reloc_std_external *reloc;
|
||||||
|
bfd_vma *amount;
|
||||||
|
bfd_vma r_addr;
|
||||||
|
{
|
||||||
|
if (howto->type == 3)
|
||||||
|
{
|
||||||
|
if (reloc->r_type[0]
|
||||||
|
& (bfd_header_big_endian (abfd)
|
||||||
|
? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
|
||||||
|
{
|
||||||
|
/* The reloc is still external, so don't modify anything. */
|
||||||
|
*amount = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*amount -= r_addr;
|
||||||
|
/* Change the r_pcrel value -- on the ARM, this bit is set once the
|
||||||
|
relocation is done. */
|
||||||
|
if (bfd_header_big_endian (abfd))
|
||||||
|
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
|
||||||
|
else
|
||||||
|
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (howto->type == 7)
|
||||||
|
*amount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
|
||||||
|
MY(relocatable_reloc)(HOW, BFD, REL, &(AMOUNT), ADDR)
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
/* This is dead simple at present. */
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
bfd_vma relocation;
|
||||||
|
bfd_size_type addr = reloc_entry->address;
|
||||||
|
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||||
|
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||||
|
|
||||||
|
/* If this is an undefined symbol, return error */
|
||||||
|
if (symbol->section == &bfd_und_section
|
||||||
|
&& (symbol->flags & BSF_WEAK) == 0)
|
||||||
|
return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
|
||||||
|
|
||||||
|
/* If the sections are different, and we are doing a partial relocation,
|
||||||
|
just ignore it for now. */
|
||||||
|
if (symbol->section->name != input_section->name
|
||||||
|
&& output_bfd != (bfd *)NULL)
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
|
||||||
|
relocation = (target & 0x00ffffff) << 2;
|
||||||
|
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||||
|
relocation += symbol->value;
|
||||||
|
relocation += symbol->section->output_section->vma;
|
||||||
|
relocation += symbol->section->output_offset;
|
||||||
|
relocation += reloc_entry->addend;
|
||||||
|
relocation -= input_section->output_section->vma;
|
||||||
|
relocation -= input_section->output_offset;
|
||||||
|
relocation -= addr;
|
||||||
|
if (relocation & 3)
|
||||||
|
return bfd_reloc_overflow;
|
||||||
|
|
||||||
|
/* Check for overflow */
|
||||||
|
if (relocation & 0x02000000)
|
||||||
|
{
|
||||||
|
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
else if (relocation & ~0x03ffffff)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
|
||||||
|
target &= ~0x00ffffff;
|
||||||
|
target |= (relocation >> 2) & 0x00ffffff;
|
||||||
|
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||||
|
Strictly this is only necessary if we are doing a partial relocation. */
|
||||||
|
reloc_entry->howto = &MY(howto_table)[7];
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
reloc_howto_type *
|
||||||
|
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
#define ASTD(i,j) case i: return &MY(howto_table)[j]
|
||||||
|
if (code == BFD_RELOC_CTOR)
|
||||||
|
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
code = BFD_RELOC_32;
|
||||||
|
break;
|
||||||
|
default: return (CONST struct reloc_howto_struct *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
ASTD (BFD_RELOC_16, 1);
|
||||||
|
ASTD (BFD_RELOC_32, 2);
|
||||||
|
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||||
|
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||||
|
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||||
|
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||||
|
default: return (CONST struct reloc_howto_struct *) 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||||
|
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||||
|
#define MY_get_section_contents _bfd_generic_get_section_contents
|
||||||
|
/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
|
||||||
|
/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
|
||||||
|
/* #define MY_bfd_final_link _bfd_generic_final_link */
|
||||||
|
|
||||||
|
#include "aoutx.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||||
|
bfd *abfd;
|
||||||
|
struct reloc_std_external *bytes;
|
||||||
|
arelent *cache_ptr;
|
||||||
|
asymbol **symbols;
|
||||||
|
bfd_size_type symcount;
|
||||||
|
{
|
||||||
|
int r_index;
|
||||||
|
int r_extern;
|
||||||
|
unsigned int r_length;
|
||||||
|
int r_pcrel;
|
||||||
|
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||||
|
|
||||||
|
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||||
|
|
||||||
|
cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
|
||||||
|
|
||||||
|
MOVE_ADDRESS (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *g;
|
||||||
|
struct reloc_std_external *natptr;
|
||||||
|
{
|
||||||
|
int r_index;
|
||||||
|
asymbol *sym = *(g->sym_ptr_ptr);
|
||||||
|
int r_extern;
|
||||||
|
int r_length;
|
||||||
|
int r_pcrel;
|
||||||
|
int r_neg = 0; /* Negative relocs use the BASEREL bit. */
|
||||||
|
asection *output_section = sym->section->output_section;
|
||||||
|
|
||||||
|
PUT_WORD(abfd, g->address, natptr->r_address);
|
||||||
|
|
||||||
|
r_length = g->howto->size ; /* Size as a power of two */
|
||||||
|
if (r_length < 0)
|
||||||
|
{
|
||||||
|
r_length = -r_length;
|
||||||
|
r_neg = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
|
||||||
|
|
||||||
|
/* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
|
||||||
|
relocation has been done already (Only for the 26-bit one I think)???!!!
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (g->howto->type == 3)
|
||||||
|
{
|
||||||
|
r_length = 3;
|
||||||
|
r_pcrel = 0;
|
||||||
|
}
|
||||||
|
else if (g->howto->type == 7)
|
||||||
|
{
|
||||||
|
r_length = 3;
|
||||||
|
r_pcrel = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* For a standard reloc, the addend is in the object file. */
|
||||||
|
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* name was clobbered by aout_write_syms to be symbol index */
|
||||||
|
|
||||||
|
/* If this relocation is relative to a symbol then set the
|
||||||
|
r_index to the symbols index, and the r_extern bit.
|
||||||
|
|
||||||
|
Absolute symbols can come in in two ways, either as an offset
|
||||||
|
from the abs section, or as a symbol which has an abs value.
|
||||||
|
check for that here
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (bfd_is_com_section (output_section)
|
||||||
|
|| output_section == &bfd_abs_section
|
||||||
|
|| output_section == &bfd_und_section)
|
||||||
|
{
|
||||||
|
if (bfd_abs_section.symbol == sym)
|
||||||
|
{
|
||||||
|
/* Whoops, looked like an abs symbol, but is really an offset
|
||||||
|
from the abs section */
|
||||||
|
r_index = 0;
|
||||||
|
r_extern = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Fill in symbol */
|
||||||
|
r_extern = 1;
|
||||||
|
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Just an ordinary section */
|
||||||
|
r_extern = 0;
|
||||||
|
r_index = output_section->target_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now the fun stuff */
|
||||||
|
if (bfd_header_big_endian (abfd))
|
||||||
|
{
|
||||||
|
natptr->r_index[0] = r_index >> 16;
|
||||||
|
natptr->r_index[1] = r_index >> 8;
|
||||||
|
natptr->r_index[2] = r_index;
|
||||||
|
natptr->r_type[0] =
|
||||||
|
( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
|
||||||
|
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
|
||||||
|
| (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0)
|
||||||
|
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
natptr->r_index[2] = r_index >> 16;
|
||||||
|
natptr->r_index[1] = r_index >> 8;
|
||||||
|
natptr->r_index[0] = r_index;
|
||||||
|
natptr->r_type[0] =
|
||||||
|
( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||||
|
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||||
|
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
|
||||||
|
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_BFD_TARGET
|
||||||
|
|
||||||
|
#include "aout-target.h"
|
||||||
|
|
||||||
|
const bfd_target aout_arm_little_vec =
|
||||||
|
{
|
||||||
|
"a.out-arm-little", /* name */
|
||||||
|
bfd_target_aout_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||||
|
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
MY_symbol_leading_char,
|
||||||
|
AR_PAD_CHAR, /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||||
|
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, MY_core_file_p},
|
||||||
|
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||||
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
|
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (MY),
|
||||||
|
BFD_JUMP_TABLE_COPY (MY),
|
||||||
|
BFD_JUMP_TABLE_CORE (MY),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (MY),
|
||||||
|
BFD_JUMP_TABLE_WRITE (MY),
|
||||||
|
BFD_JUMP_TABLE_LINK (MY),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||||
|
|
||||||
|
(PTR) MY_backend_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_target aout_arm_big_vec =
|
||||||
|
{
|
||||||
|
"a.out-arm-big", /* name */
|
||||||
|
bfd_target_aout_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||||
|
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
MY_symbol_leading_char,
|
||||||
|
AR_PAD_CHAR, /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, MY_core_file_p},
|
||||||
|
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||||
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
|
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (MY),
|
||||||
|
BFD_JUMP_TABLE_COPY (MY),
|
||||||
|
BFD_JUMP_TABLE_CORE (MY),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (MY),
|
||||||
|
BFD_JUMP_TABLE_WRITE (MY),
|
||||||
|
BFD_JUMP_TABLE_LINK (MY),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||||
|
|
||||||
|
(PTR) MY_backend_data,
|
||||||
|
};
|
236
contrib/gdb/bfd/aout-encap.c
Normal file
236
contrib/gdb/bfd/aout-encap.c
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/* BFD back-end for a.out files encapsulated with COFF headers.
|
||||||
|
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define TARGET_PAGE_SIZE 4096
|
||||||
|
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||||
|
#define TEXT_START_ADDR 0
|
||||||
|
#define BYTES_IN_WORD 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include <sysdep.h>
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include <aout/aout64.h>
|
||||||
|
#include "aout/stab_gnu.h"
|
||||||
|
#include "aout/ar.h"
|
||||||
|
#include "libaout.h" /* BFD a.out internal data structures */
|
||||||
|
|
||||||
|
const bfd_target *encap_real_callback ();
|
||||||
|
|
||||||
|
const bfd_target *
|
||||||
|
encap_object_p (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
||||||
|
unsigned long magic; /* Swapped magic number */
|
||||||
|
short coff_magic;
|
||||||
|
struct external_exec exec_bytes;
|
||||||
|
struct internal_exec exec;
|
||||||
|
|
||||||
|
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
|
||||||
|
sizeof (magicbuf))
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
coff_magic = bfd_h_get_16 (abfd, magicbuf);
|
||||||
|
if (coff_magic != COFF_MAGIC)
|
||||||
|
return 0; /* Not an encap coff file */
|
||||||
|
|
||||||
|
__header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
|
||||||
|
(fseek ((f), HEADER_OFFSET((f)), 1))
|
||||||
|
|
||||||
|
magic = bfd_h_get_32 (abfd, magicbuf);
|
||||||
|
|
||||||
|
if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
|
||||||
|
|
||||||
|
struct external_exec exec_bytes;
|
||||||
|
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||||
|
!= EXEC_BYTES_SIZE) {
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
||||||
|
|
||||||
|
return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finish up the reading of a encapsulated-coff a.out file header */
|
||||||
|
const bfd_target *
|
||||||
|
encap_real_callback (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct internal_exec *execp = exec_hdr (abfd);
|
||||||
|
|
||||||
|
MY(callback)(abfd, execp);
|
||||||
|
|
||||||
|
/* If we have a coff header, it can give us better values for
|
||||||
|
text_start and exec_data_start. This is particularly useful
|
||||||
|
for remote debugging of embedded systems. */
|
||||||
|
if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
|
||||||
|
{
|
||||||
|
struct coffheader ch;
|
||||||
|
int val;
|
||||||
|
val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
|
||||||
|
if (val == -1)
|
||||||
|
perror_with_name (filename);
|
||||||
|
val = myread (execchan, &ch, sizeof (ch));
|
||||||
|
if (val < 0)
|
||||||
|
perror_with_name (filename);
|
||||||
|
text_start = ch.text_start;
|
||||||
|
exec_data_start = ch.data_start;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
text_start =
|
||||||
|
IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
|
||||||
|
exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
|
||||||
|
? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine the architecture and machine type of the object file. */
|
||||||
|
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
|
||||||
|
|
||||||
|
return abfd->xvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write an object file in Encapsulated COFF format.
|
||||||
|
Section contents have already been written. We write the
|
||||||
|
file header, symbols, and relocation. */
|
||||||
|
|
||||||
|
boolean
|
||||||
|
encap_write_object_contents (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
bfd_size_type data_pad = 0;
|
||||||
|
struct external_exec exec_bytes;
|
||||||
|
struct internal_exec *execp = exec_hdr (abfd);
|
||||||
|
|
||||||
|
/****** FIXME: Fragments from the old GNU LD program for dealing with
|
||||||
|
encap coff. */
|
||||||
|
struct coffheader coffheader;
|
||||||
|
int need_coff_header;
|
||||||
|
|
||||||
|
/* Determine whether to count the header as part of
|
||||||
|
the text size, and initialize the text size accordingly.
|
||||||
|
This depends on the kind of system and on the output format selected. */
|
||||||
|
|
||||||
|
N_SET_MAGIC (outheader, magic);
|
||||||
|
#ifdef INITIALIZE_HEADER
|
||||||
|
INITIALIZE_HEADER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
text_size = sizeof (struct exec);
|
||||||
|
#ifdef COFF_ENCAPSULATE
|
||||||
|
if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
|
||||||
|
{
|
||||||
|
need_coff_header = 1;
|
||||||
|
/* set this flag now, since it will change the values of N_TXTOFF, etc */
|
||||||
|
N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
|
||||||
|
text_size += sizeof (struct coffheader);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef COFF_ENCAPSULATE
|
||||||
|
if (need_coff_header)
|
||||||
|
{
|
||||||
|
/* We are encapsulating BSD format within COFF format. */
|
||||||
|
struct coffscn *tp, *dp, *bp;
|
||||||
|
|
||||||
|
tp = &coffheader.scns[0];
|
||||||
|
dp = &coffheader.scns[1];
|
||||||
|
bp = &coffheader.scns[2];
|
||||||
|
|
||||||
|
strcpy (tp->s_name, ".text");
|
||||||
|
tp->s_paddr = text_start;
|
||||||
|
tp->s_vaddr = text_start;
|
||||||
|
tp->s_size = text_size;
|
||||||
|
tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
|
||||||
|
tp->s_relptr = 0;
|
||||||
|
tp->s_lnnoptr = 0;
|
||||||
|
tp->s_nreloc = 0;
|
||||||
|
tp->s_nlnno = 0;
|
||||||
|
tp->s_flags = 0x20;
|
||||||
|
strcpy (dp->s_name, ".data");
|
||||||
|
dp->s_paddr = data_start;
|
||||||
|
dp->s_vaddr = data_start;
|
||||||
|
dp->s_size = data_size;
|
||||||
|
dp->s_scnptr = tp->s_scnptr + tp->s_size;
|
||||||
|
dp->s_relptr = 0;
|
||||||
|
dp->s_lnnoptr = 0;
|
||||||
|
dp->s_nreloc = 0;
|
||||||
|
dp->s_nlnno = 0;
|
||||||
|
dp->s_flags = 0x40;
|
||||||
|
strcpy (bp->s_name, ".bss");
|
||||||
|
bp->s_paddr = dp->s_vaddr + dp->s_size;
|
||||||
|
bp->s_vaddr = bp->s_paddr;
|
||||||
|
bp->s_size = bss_size;
|
||||||
|
bp->s_scnptr = 0;
|
||||||
|
bp->s_relptr = 0;
|
||||||
|
bp->s_lnnoptr = 0;
|
||||||
|
bp->s_nreloc = 0;
|
||||||
|
bp->s_nlnno = 0;
|
||||||
|
bp->s_flags = 0x80;
|
||||||
|
|
||||||
|
coffheader.f_magic = COFF_MAGIC;
|
||||||
|
coffheader.f_nscns = 3;
|
||||||
|
/* store an unlikely time so programs can
|
||||||
|
* tell that there is a bsd header
|
||||||
|
*/
|
||||||
|
coffheader.f_timdat = 1;
|
||||||
|
coffheader.f_symptr = 0;
|
||||||
|
coffheader.f_nsyms = 0;
|
||||||
|
coffheader.f_opthdr = 28;
|
||||||
|
coffheader.f_flags = 0x103;
|
||||||
|
/* aouthdr */
|
||||||
|
coffheader.magic = ZMAGIC;
|
||||||
|
coffheader.vstamp = 0;
|
||||||
|
coffheader.tsize = tp->s_size;
|
||||||
|
coffheader.dsize = dp->s_size;
|
||||||
|
coffheader.bsize = bp->s_size;
|
||||||
|
coffheader.entry = outheader.a_entry;
|
||||||
|
coffheader.text_start = tp->s_vaddr;
|
||||||
|
coffheader.data_start = dp->s_vaddr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef COFF_ENCAPSULATE
|
||||||
|
if (need_coff_header)
|
||||||
|
mywrite (&coffheader, sizeof coffheader, 1, outdesc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef COFF_ENCAPSULATE
|
||||||
|
padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
text_size -= N_TXTOFF (outheader);
|
||||||
|
WRITE_HEADERS(abfd, execp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_write_object_content encap_write_object_contents
|
||||||
|
#define MY_object_p encap_object_p
|
||||||
|
#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
|
||||||
|
|
||||||
|
#include "aout-target.h"
|
399
contrib/gdb/bfd/aout-ns32k.c
Normal file
399
contrib/gdb/bfd/aout-ns32k.c
Normal file
@ -0,0 +1,399 @@
|
|||||||
|
/* BFD back-end for ns32k a.out-ish binaries.
|
||||||
|
Copyright (C) 1990, 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
|
||||||
|
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define BYTES_IN_WORD 4
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "aout/aout64.h"
|
||||||
|
|
||||||
|
#define MYNS(OP) CAT(ns32kaout_,OP)
|
||||||
|
reloc_howto_type *
|
||||||
|
MYNS(bfd_reloc_type_lookup)
|
||||||
|
PARAMS((bfd *abfd AND
|
||||||
|
bfd_reloc_code_real_type code));
|
||||||
|
|
||||||
|
boolean
|
||||||
|
MYNS(write_object_contents)
|
||||||
|
PARAMS((bfd *abfd));
|
||||||
|
|
||||||
|
/* Avoid multiple definitions from aoutx if supporting standard a.out format(s)
|
||||||
|
* as well as this one
|
||||||
|
*/
|
||||||
|
#define NAME(x,y) CAT3(ns32kaout,_32_,y)
|
||||||
|
|
||||||
|
void bfd_ns32k_arch PARAMS ((void));
|
||||||
|
long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||||
|
int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||||
|
long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||||
|
int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
|
||||||
|
struct symbol_cache_entry *symbol,
|
||||||
|
PTR data,
|
||||||
|
asection *input_section,
|
||||||
|
bfd *output_bfd,
|
||||||
|
char **error_message));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_imm PARAMS ((bfd *abfd,
|
||||||
|
arelent *reloc_entry,
|
||||||
|
struct symbol_cache_entry *symbol,
|
||||||
|
PTR data,
|
||||||
|
asection *input_section,
|
||||||
|
bfd *output_bfd,
|
||||||
|
char **error_message));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
|
||||||
|
bfd *input_bfd,
|
||||||
|
asection *input_section,
|
||||||
|
bfd_byte *contents,
|
||||||
|
bfd_vma address,
|
||||||
|
bfd_vma value,
|
||||||
|
bfd_vma addend ));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
|
||||||
|
bfd *input_bfd,
|
||||||
|
bfd_vma relocation,
|
||||||
|
bfd_byte *location));
|
||||||
|
|
||||||
|
#include "libaout.h"
|
||||||
|
|
||||||
|
#define MY(OP) MYNS(OP)
|
||||||
|
|
||||||
|
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||||
|
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||||
|
|
||||||
|
static void
|
||||||
|
MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes,
|
||||||
|
arelent *cache_ptr, asymbol **symbols,
|
||||||
|
bfd_size_type symcount));
|
||||||
|
|
||||||
|
static void
|
||||||
|
MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g,
|
||||||
|
struct reloc_std_external *natptr));
|
||||||
|
|
||||||
|
/* The ns32k series is ah, unusual, when it comes to relocation.
|
||||||
|
* There are three storage methods for relocateable objects. There
|
||||||
|
* are displacements, immediate operands and ordinary twos complement
|
||||||
|
* data. Of these, only the last fits into the standard relocation
|
||||||
|
* scheme. Immediate operands are stored huffman encoded and
|
||||||
|
* immediate operands are stored big endian (where as the natural byte
|
||||||
|
* order is little endian for this achitecture).
|
||||||
|
|
||||||
|
* Note that the ns32k displacement storage method is orthogonal to
|
||||||
|
* whether the relocation is pc relative or not. The "displacement"
|
||||||
|
* storage scheme is used for essentially all address constants. The
|
||||||
|
* displacement can be relative to zero (absolute displacement),
|
||||||
|
* relative to the pc (pc relative), the stack pointer, the frame
|
||||||
|
* pointer, the static base register and general purpose register etc.
|
||||||
|
|
||||||
|
* For example:
|
||||||
|
*
|
||||||
|
* sym1: .long . # pc relative 2's complement
|
||||||
|
* sym1: .long foo # 2's complement not pc relative
|
||||||
|
*
|
||||||
|
* self: movd @self, r0 # pc relative displacement
|
||||||
|
* movd foo, r0 # non pc relative displacement
|
||||||
|
*
|
||||||
|
* self: movd self, r0 # pc relative immediate
|
||||||
|
* movd foo, r0 # non pc relative immediate
|
||||||
|
*
|
||||||
|
* In addition, for historical reasons the encoding of the relocation types
|
||||||
|
* in the a.out format relocation entries is such that even the relocation
|
||||||
|
* methods which are standard are not encoded the standard way.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
reloc_howto_type MY(howto_table)[] =
|
||||||
|
{
|
||||||
|
/* ns32k immediate operands */
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true,
|
||||||
|
ns32k_reloc_imm, "NS32K_IMM_8",
|
||||||
|
true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true,
|
||||||
|
ns32k_reloc_imm, "NS32K_IMM_16",
|
||||||
|
true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true,
|
||||||
|
ns32k_reloc_imm, "NS32K_IMM_32",
|
||||||
|
true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false,
|
||||||
|
ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
|
||||||
|
true, 0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false,
|
||||||
|
ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
|
||||||
|
true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false,
|
||||||
|
ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
|
||||||
|
true, 0xffffffff,0xffffffff, false),
|
||||||
|
|
||||||
|
/* ns32k displacements */
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true,
|
||||||
|
ns32k_reloc_disp, "NS32K_DISP_8",
|
||||||
|
true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true,
|
||||||
|
ns32k_reloc_disp, "NS32K_DISP_16",
|
||||||
|
true, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true,
|
||||||
|
ns32k_reloc_disp, "NS32K_DISP_32",
|
||||||
|
true, 0xffffffff, 0xffffffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false,
|
||||||
|
ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
|
||||||
|
true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false,
|
||||||
|
ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
|
||||||
|
true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false,
|
||||||
|
ns32k_reloc_disp, "PCREL_NS32K_DISP_32",
|
||||||
|
true, 0xffffffff,0xffffffff, false),
|
||||||
|
|
||||||
|
/* Normal 2's complement */
|
||||||
|
HOWTO(BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,
|
||||||
|
"8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,
|
||||||
|
"16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,
|
||||||
|
"32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0,
|
||||||
|
"PCREL_8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0,
|
||||||
|
"PCREL_16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0,
|
||||||
|
"PCREL_32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14)
|
||||||
|
|
||||||
|
#define RELOC_STD_BITS_NS32K_TYPE_BIG 0x06
|
||||||
|
#define RELOC_STD_BITS_NS32K_TYPE_LITTLE 0x60
|
||||||
|
#define RELOC_STD_BITS_NS32K_TYPE_SH_BIG 1
|
||||||
|
#define RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE 5
|
||||||
|
|
||||||
|
reloc_howto_type *
|
||||||
|
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||||
|
bfd *abfd;
|
||||||
|
struct reloc_std_external *rel;
|
||||||
|
int *r_index;
|
||||||
|
int *r_extern;
|
||||||
|
int *r_pcrel;
|
||||||
|
{
|
||||||
|
unsigned int r_length;
|
||||||
|
int r_ns32k_type;
|
||||||
|
/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
|
||||||
|
*r_index = ((rel->r_index[2] << 16)
|
||||||
|
| (rel->r_index[1] << 8)
|
||||||
|
| rel->r_index[0] );
|
||||||
|
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||||
|
*r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||||
|
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||||
|
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||||
|
r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
|
||||||
|
>> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||||
|
return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto)(BFD, REL, &IN, &EX, &PC)
|
||||||
|
|
||||||
|
void
|
||||||
|
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||||
|
bfd *abfd;
|
||||||
|
int r_extern;
|
||||||
|
int r_index;
|
||||||
|
long value;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
struct reloc_std_external *reloc;
|
||||||
|
{
|
||||||
|
unsigned int r_length;
|
||||||
|
int r_pcrel;
|
||||||
|
int r_ns32k_type;
|
||||||
|
PUT_WORD (abfd, value, reloc->r_address);
|
||||||
|
r_length = howto->size ; /* Size as a power of two */
|
||||||
|
r_pcrel = (int) howto->pc_relative; /* Relative to PC? */
|
||||||
|
r_ns32k_type = (howto - MY(howto_table) )/6;
|
||||||
|
/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
|
||||||
|
reloc->r_index[2] = r_index >> 16;
|
||||||
|
reloc->r_index[1] = r_index >> 8;
|
||||||
|
reloc->r_index[0] = r_index;
|
||||||
|
reloc->r_type[0] =
|
||||||
|
(r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||||
|
| (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||||
|
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
|
||||||
|
| (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||||
|
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||||
|
|
||||||
|
#define STAT_FOR_EXEC
|
||||||
|
|
||||||
|
#define MY_final_link_relocate ns32k_final_link_relocate
|
||||||
|
#define MY_relocate_contents ns32k_relocate_contents
|
||||||
|
|
||||||
|
#include <aoutx.h>
|
||||||
|
|
||||||
|
reloc_howto_type *
|
||||||
|
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
|
||||||
|
#define ENTRY(i,j) case i: return &MY(howto_table)[j]
|
||||||
|
|
||||||
|
int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
|
||||||
|
|
||||||
|
BFD_ASSERT(ext == 0);
|
||||||
|
if (code == BFD_RELOC_CTOR)
|
||||||
|
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
code = BFD_RELOC_32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_8, 0);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_16, 1);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_32, 2);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_8_PCREL, 3);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_16_PCREL, 4);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_IMM_32_PCREL, 5);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_8, 6);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_16, 7);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_32, 8);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_8_PCREL, 9);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_16_PCREL, 10);
|
||||||
|
ENTRY(BFD_RELOC_NS32K_DISP_32_PCREL, 11);
|
||||||
|
ENTRY(BFD_RELOC_8, 12);
|
||||||
|
ENTRY(BFD_RELOC_16, 13);
|
||||||
|
ENTRY(BFD_RELOC_32, 14);
|
||||||
|
ENTRY(BFD_RELOC_8_PCREL, 15);
|
||||||
|
ENTRY(BFD_RELOC_16_PCREL, 16);
|
||||||
|
ENTRY(BFD_RELOC_32_PCREL, 17);
|
||||||
|
default: return (reloc_howto_type *) NULL;
|
||||||
|
}
|
||||||
|
#undef ENTRY
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||||
|
bfd *abfd;
|
||||||
|
struct reloc_std_external *bytes;
|
||||||
|
arelent *cache_ptr;
|
||||||
|
asymbol **symbols;
|
||||||
|
bfd_size_type symcount;
|
||||||
|
{
|
||||||
|
int r_index;
|
||||||
|
int r_extern;
|
||||||
|
int r_pcrel;
|
||||||
|
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||||
|
|
||||||
|
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||||
|
|
||||||
|
/* now the fun stuff */
|
||||||
|
|
||||||
|
cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
|
||||||
|
|
||||||
|
MOVE_ADDRESS(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *g;
|
||||||
|
struct reloc_std_external *natptr;
|
||||||
|
{
|
||||||
|
int r_index;
|
||||||
|
asymbol *sym = *(g->sym_ptr_ptr);
|
||||||
|
int r_extern;
|
||||||
|
unsigned int r_addend;
|
||||||
|
asection *output_section = sym->section->output_section;
|
||||||
|
|
||||||
|
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||||
|
|
||||||
|
/* name was clobbered by aout_write_syms to be symbol index */
|
||||||
|
|
||||||
|
/* If this relocation is relative to a symbol then set the
|
||||||
|
r_index to the symbols index, and the r_extern bit.
|
||||||
|
|
||||||
|
Absolute symbols can come in in two ways, either as an offset
|
||||||
|
from the abs section, or as a symbol which has an abs value.
|
||||||
|
Check for that here. */
|
||||||
|
|
||||||
|
if (bfd_is_com_section (output_section)
|
||||||
|
|| output_section == &bfd_abs_section
|
||||||
|
|| output_section == &bfd_und_section)
|
||||||
|
{
|
||||||
|
if (bfd_abs_section.symbol == sym)
|
||||||
|
{
|
||||||
|
/* Whoops, looked like an abs symbol, but is really an offset
|
||||||
|
from the abs section */
|
||||||
|
r_index = 0;
|
||||||
|
r_extern = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Fill in symbol */
|
||||||
|
r_extern = 1;
|
||||||
|
#undef KEEPIT
|
||||||
|
#define KEEPIT udata.i
|
||||||
|
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||||
|
#undef KEEPIT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Just an ordinary section */
|
||||||
|
r_extern = 0;
|
||||||
|
r_index = output_section->target_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_relocate_contents (howto, input_bfd, relocation, location)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
bfd *input_bfd;
|
||||||
|
bfd_vma relocation;
|
||||||
|
bfd_byte *location;
|
||||||
|
{
|
||||||
|
int r_ns32k_type = (howto - MY(howto_table)) / 6;
|
||||||
|
long (*get_data)();
|
||||||
|
int (*put_data)();
|
||||||
|
|
||||||
|
switch (r_ns32k_type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
get_data = ns32k_get_immediate;
|
||||||
|
put_data = ns32k_put_immediate;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
get_data = ns32k_get_displacement;
|
||||||
|
put_data = ns32k_put_displacement;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
||||||
|
location);
|
||||||
|
/* NOT REACHED */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return do_ns32k_reloc_contents (howto, input_bfd, relocation,
|
||||||
|
location, get_data, put_data);
|
||||||
|
}
|
607
contrib/gdb/bfd/aout-target.h
Normal file
607
contrib/gdb/bfd/aout-target.h
Normal file
@ -0,0 +1,607 @@
|
|||||||
|
/* 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 */
|
32
contrib/gdb/bfd/aout0.c
Normal file
32
contrib/gdb/bfd/aout0.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* BFD backend for SunOS style a.out with flags set to 0
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGETNAME "a.out-zero-big"
|
||||||
|
#define MY(OP) CAT(aout0_big_,OP)
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
|
||||||
|
#define MY_exec_hdr_flags 0
|
||||||
|
|
||||||
|
#define MACHTYPE_OK(mtype) \
|
||||||
|
((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
|
||||||
|
|
||||||
|
/* Include the usual a.out support. */
|
||||||
|
#include "aoutf1.h"
|
23
contrib/gdb/bfd/aout32.c
Normal file
23
contrib/gdb/bfd/aout32.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* BFD back-end for 32-bit a.out files.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define ARCH_SIZE 32
|
||||||
|
|
||||||
|
#include "aoutx.h"
|
31
contrib/gdb/bfd/aout64.c
Normal file
31
contrib/gdb/bfd/aout64.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* BFD back-end for 64-bit a.out files.
|
||||||
|
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define ARCH_SIZE 64
|
||||||
|
|
||||||
|
/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
|
||||||
|
#ifndef BMAGIC
|
||||||
|
#define BMAGIC 0
|
||||||
|
#endif
|
||||||
|
#ifndef QMAGIC
|
||||||
|
#define QMAGIC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "aoutx.h"
|
788
contrib/gdb/bfd/aoutf1.h
Normal file
788
contrib/gdb/bfd/aoutf1.h
Normal file
@ -0,0 +1,788 @@
|
|||||||
|
/* A.out "format 1" file handling code for BFD.
|
||||||
|
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
#include "aout/sun4.h"
|
||||||
|
#include "libaout.h" /* BFD a.out internal data structures */
|
||||||
|
|
||||||
|
#include "aout/aout64.h"
|
||||||
|
#include "aout/stab_gnu.h"
|
||||||
|
#include "aout/ar.h"
|
||||||
|
|
||||||
|
/* This is needed to reject a NewsOS file, e.g. in
|
||||||
|
gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
|
||||||
|
I needed to add M_UNKNOWN to recognize a 68000 object, so this will
|
||||||
|
probably no longer reject a NewsOS object. <ian@cygnus.com>. */
|
||||||
|
#ifndef MACHTYPE_OK
|
||||||
|
#define MACHTYPE_OK(mtype) \
|
||||||
|
(((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
|
||||||
|
|| (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
|
||||||
|
&& bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
The file @code{aoutf1.h} contains the code for BFD's
|
||||||
|
a.out back end. Control over the generated back end is given by these
|
||||||
|
two preprocessor names:
|
||||||
|
@table @code
|
||||||
|
@item ARCH_SIZE
|
||||||
|
This value should be either 32 or 64, depending upon the size of an
|
||||||
|
int in the target format. It changes the sizes of the structs which
|
||||||
|
perform the memory/disk mapping of structures.
|
||||||
|
|
||||||
|
The 64 bit backend may only be used if the host compiler supports 64
|
||||||
|
ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
|
||||||
|
With this name defined, @emph{all} bfd operations are performed with 64bit
|
||||||
|
arithmetic, not just those to a 64bit target.
|
||||||
|
|
||||||
|
@item TARGETNAME
|
||||||
|
The name put into the target vector.
|
||||||
|
@item
|
||||||
|
@end table
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*SUPPRESS558*/
|
||||||
|
/*SUPPRESS529*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
#if ARCH_SIZE == 64
|
||||||
|
sunos_64_set_arch_mach
|
||||||
|
#else
|
||||||
|
sunos_32_set_arch_mach
|
||||||
|
#endif
|
||||||
|
(abfd, machtype)
|
||||||
|
bfd *abfd;
|
||||||
|
int machtype;
|
||||||
|
{
|
||||||
|
/* Determine the architecture and machine type of the object file. */
|
||||||
|
enum bfd_architecture arch;
|
||||||
|
long machine;
|
||||||
|
switch (machtype)
|
||||||
|
{
|
||||||
|
|
||||||
|
case M_UNKNOWN:
|
||||||
|
/* Some Sun3s make magic numbers without cpu types in them, so
|
||||||
|
we'll default to the 68000. */
|
||||||
|
arch = bfd_arch_m68k;
|
||||||
|
machine = 68000;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_68010:
|
||||||
|
case M_HP200:
|
||||||
|
arch = bfd_arch_m68k;
|
||||||
|
machine = 68010;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_68020:
|
||||||
|
case M_HP300:
|
||||||
|
arch = bfd_arch_m68k;
|
||||||
|
machine = 68020;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_SPARC:
|
||||||
|
arch = bfd_arch_sparc;
|
||||||
|
machine = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_386:
|
||||||
|
case M_386_DYNIX:
|
||||||
|
arch = bfd_arch_i386;
|
||||||
|
machine = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_29K:
|
||||||
|
arch = bfd_arch_a29k;
|
||||||
|
machine = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_HPUX:
|
||||||
|
arch = bfd_arch_m68k;
|
||||||
|
machine = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
arch = bfd_arch_obscure;
|
||||||
|
machine = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bfd_set_arch_mach (abfd, arch, machine);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SET_ARCH_MACH(ABFD, EXEC) \
|
||||||
|
NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
|
||||||
|
choose_reloc_size(ABFD);
|
||||||
|
|
||||||
|
/* Determine the size of a relocation entry, based on the architecture */
|
||||||
|
static void
|
||||||
|
choose_reloc_size (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
switch (bfd_get_arch (abfd))
|
||||||
|
{
|
||||||
|
case bfd_arch_sparc:
|
||||||
|
case bfd_arch_a29k:
|
||||||
|
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write an object file in SunOS format.
|
||||||
|
Section contents have already been written. We write the
|
||||||
|
file header, symbols, and relocation. */
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
#if ARCH_SIZE == 64
|
||||||
|
aout_64_sunos4_write_object_contents
|
||||||
|
#else
|
||||||
|
aout_32_sunos4_write_object_contents
|
||||||
|
#endif
|
||||||
|
(abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
struct external_exec exec_bytes;
|
||||||
|
struct internal_exec *execp = exec_hdr (abfd);
|
||||||
|
|
||||||
|
/* Magic number, maestro, please! */
|
||||||
|
switch (bfd_get_arch (abfd))
|
||||||
|
{
|
||||||
|
case bfd_arch_m68k:
|
||||||
|
switch (bfd_get_mach (abfd))
|
||||||
|
{
|
||||||
|
case 68000:
|
||||||
|
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||||
|
break;
|
||||||
|
case 68010:
|
||||||
|
N_SET_MACHTYPE (*execp, M_68010);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 68020:
|
||||||
|
N_SET_MACHTYPE (*execp, M_68020);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case bfd_arch_sparc:
|
||||||
|
N_SET_MACHTYPE (*execp, M_SPARC);
|
||||||
|
break;
|
||||||
|
case bfd_arch_i386:
|
||||||
|
N_SET_MACHTYPE (*execp, M_386);
|
||||||
|
break;
|
||||||
|
case bfd_arch_a29k:
|
||||||
|
N_SET_MACHTYPE (*execp, M_29K);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
choose_reloc_size (abfd);
|
||||||
|
|
||||||
|
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||||
|
|
||||||
|
N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
|
||||||
|
|
||||||
|
WRITE_HEADERS (abfd, execp);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* core files */
|
||||||
|
|
||||||
|
#define CORE_MAGIC 0x080456
|
||||||
|
#define CORE_NAMELEN 16
|
||||||
|
|
||||||
|
/* The core structure is taken from the Sun documentation.
|
||||||
|
Unfortunately, they don't document the FPA structure, or at least I
|
||||||
|
can't find it easily. Fortunately the core header contains its own
|
||||||
|
length. So this shouldn't cause problems, except for c_ucode, which
|
||||||
|
so far we don't use but is easy to find with a little arithmetic. */
|
||||||
|
|
||||||
|
/* But the reg structure can be gotten from the SPARC processor handbook.
|
||||||
|
This really should be in a GNU include file though so that gdb can use
|
||||||
|
the same info. */
|
||||||
|
struct regs
|
||||||
|
{
|
||||||
|
int r_psr;
|
||||||
|
int r_pc;
|
||||||
|
int r_npc;
|
||||||
|
int r_y;
|
||||||
|
int r_g1;
|
||||||
|
int r_g2;
|
||||||
|
int r_g3;
|
||||||
|
int r_g4;
|
||||||
|
int r_g5;
|
||||||
|
int r_g6;
|
||||||
|
int r_g7;
|
||||||
|
int r_o0;
|
||||||
|
int r_o1;
|
||||||
|
int r_o2;
|
||||||
|
int r_o3;
|
||||||
|
int r_o4;
|
||||||
|
int r_o5;
|
||||||
|
int r_o6;
|
||||||
|
int r_o7;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Taken from Sun documentation: */
|
||||||
|
|
||||||
|
/* FIXME: It's worse than we expect. This struct contains TWO substructs
|
||||||
|
neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
|
||||||
|
even portably access the stuff in between! */
|
||||||
|
|
||||||
|
struct external_sparc_core
|
||||||
|
{
|
||||||
|
int c_magic; /* Corefile magic number */
|
||||||
|
int c_len; /* Sizeof (struct core) */
|
||||||
|
#define SPARC_CORE_LEN 432
|
||||||
|
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||||
|
struct external_exec c_aouthdr; /* A.out header */
|
||||||
|
int c_signo; /* Killing signal, if any */
|
||||||
|
int c_tsize; /* Text size (bytes) */
|
||||||
|
int c_dsize; /* Data size (bytes) */
|
||||||
|
int c_ssize; /* Stack size (bytes) */
|
||||||
|
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||||
|
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||||
|
/* The type "double" is critical here, for alignment.
|
||||||
|
SunOS declares a struct here, but the struct's alignment
|
||||||
|
is double since it contains doubles. */
|
||||||
|
int c_ucode; /* Exception no. from u_code */
|
||||||
|
/* (this member is not accessible by name since we don't
|
||||||
|
portably know the size of fp_stuff.) */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Core files generated by the BCP (the part of Solaris which allows
|
||||||
|
it to run SunOS4 a.out files). */
|
||||||
|
struct external_solaris_bcp_core
|
||||||
|
{
|
||||||
|
int c_magic; /* Corefile magic number */
|
||||||
|
int c_len; /* Sizeof (struct core) */
|
||||||
|
#define SOLARIS_BCP_CORE_LEN 456
|
||||||
|
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||||
|
int c_exdata_vp; /* exdata structure */
|
||||||
|
int c_exdata_tsize;
|
||||||
|
int c_exdata_dsize;
|
||||||
|
int c_exdata_bsize;
|
||||||
|
int c_exdata_lsize;
|
||||||
|
int c_exdata_nshlibs;
|
||||||
|
short c_exdata_mach;
|
||||||
|
short c_exdata_mag;
|
||||||
|
int c_exdata_toffset;
|
||||||
|
int c_exdata_doffset;
|
||||||
|
int c_exdata_loffset;
|
||||||
|
int c_exdata_txtorg;
|
||||||
|
int c_exdata_datorg;
|
||||||
|
int c_exdata_entloc;
|
||||||
|
int c_signo; /* Killing signal, if any */
|
||||||
|
int c_tsize; /* Text size (bytes) */
|
||||||
|
int c_dsize; /* Data size (bytes) */
|
||||||
|
int c_ssize; /* Stack size (bytes) */
|
||||||
|
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||||
|
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||||
|
/* The type "double" is critical here, for alignment.
|
||||||
|
SunOS declares a struct here, but the struct's alignment
|
||||||
|
is double since it contains doubles. */
|
||||||
|
int c_ucode; /* Exception no. from u_code */
|
||||||
|
/* (this member is not accessible by name since we don't
|
||||||
|
portably know the size of fp_stuff.) */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct external_sun3_core
|
||||||
|
{
|
||||||
|
int c_magic; /* Corefile magic number */
|
||||||
|
int c_len; /* Sizeof (struct core) */
|
||||||
|
#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
|
||||||
|
int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
|
||||||
|
struct external_exec c_aouthdr; /* A.out header */
|
||||||
|
int c_signo; /* Killing signal, if any */
|
||||||
|
int c_tsize; /* Text size (bytes) */
|
||||||
|
int c_dsize; /* Data size (bytes) */
|
||||||
|
int c_ssize; /* Stack size (bytes) */
|
||||||
|
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||||
|
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||||
|
/* The type "double" is critical here, for alignment.
|
||||||
|
SunOS declares a struct here, but the struct's alignment
|
||||||
|
is double since it contains doubles. */
|
||||||
|
int c_ucode; /* Exception no. from u_code */
|
||||||
|
/* (this member is not accessible by name since we don't
|
||||||
|
portably know the size of fp_stuff.) */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct internal_sunos_core
|
||||||
|
{
|
||||||
|
int c_magic; /* Corefile magic number */
|
||||||
|
int c_len; /* Sizeof (struct core) */
|
||||||
|
long c_regs_pos; /* file offset of General purpose registers */
|
||||||
|
int c_regs_size; /* size of General purpose registers */
|
||||||
|
struct internal_exec c_aouthdr; /* A.out header */
|
||||||
|
int c_signo; /* Killing signal, if any */
|
||||||
|
int c_tsize; /* Text size (bytes) */
|
||||||
|
int c_dsize; /* Data size (bytes) */
|
||||||
|
bfd_vma c_data_addr; /* Data start (address) */
|
||||||
|
int c_ssize; /* Stack size (bytes) */
|
||||||
|
bfd_vma c_stacktop; /* Stack top (address) */
|
||||||
|
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||||
|
long fp_stuff_pos; /* file offset of external FPU state (regs) */
|
||||||
|
int fp_stuff_size; /* Size of it */
|
||||||
|
int c_ucode; /* Exception no. from u_code */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* byte-swap in the Sun-3 core structure */
|
||||||
|
static void
|
||||||
|
swapcore_sun3 (abfd, ext, intcore)
|
||||||
|
bfd *abfd;
|
||||||
|
char *ext;
|
||||||
|
struct internal_sunos_core *intcore;
|
||||||
|
{
|
||||||
|
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
|
||||||
|
|
||||||
|
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||||
|
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||||
|
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
|
||||||
|
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||||
|
#if ARCH_SIZE == 64
|
||||||
|
aout_64_swap_exec_header_in
|
||||||
|
#else
|
||||||
|
aout_32_swap_exec_header_in
|
||||||
|
#endif
|
||||||
|
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||||
|
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||||
|
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||||
|
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||||
|
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||||
|
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||||
|
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||||
|
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||||
|
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||||
|
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||||
|
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||||
|
/* Ucode is the last thing in the struct -- just before the end */
|
||||||
|
intcore->c_ucode =
|
||||||
|
bfd_h_get_32 (abfd,
|
||||||
|
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||||
|
intcore->c_stacktop = 0x0E000000; /* By experimentation */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* byte-swap in the Sparc core structure */
|
||||||
|
static void
|
||||||
|
swapcore_sparc (abfd, ext, intcore)
|
||||||
|
bfd *abfd;
|
||||||
|
char *ext;
|
||||||
|
struct internal_sunos_core *intcore;
|
||||||
|
{
|
||||||
|
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
|
||||||
|
|
||||||
|
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||||
|
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||||
|
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
|
||||||
|
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||||
|
#if ARCH_SIZE == 64
|
||||||
|
aout_64_swap_exec_header_in
|
||||||
|
#else
|
||||||
|
aout_32_swap_exec_header_in
|
||||||
|
#endif
|
||||||
|
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||||
|
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||||
|
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||||
|
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||||
|
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||||
|
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||||
|
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||||
|
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||||
|
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||||
|
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||||
|
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||||
|
/* Ucode is the last thing in the struct -- just before the end */
|
||||||
|
intcore->c_ucode =
|
||||||
|
bfd_h_get_32 (abfd,
|
||||||
|
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||||
|
|
||||||
|
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||||
|
Presuming that this remains true, this definition will work. */
|
||||||
|
/* Now sun has provided us with another challenge. The value is different
|
||||||
|
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||||
|
the other based on the current value of the stack pointer. This
|
||||||
|
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||||
|
is larger than 128 megabytes.
|
||||||
|
|
||||||
|
It's times like these you're glad they're switching to ELF.
|
||||||
|
|
||||||
|
Note that using include files or nlist on /vmunix would be wrong,
|
||||||
|
because we want the value for this core file, no matter what kind of
|
||||||
|
machine we were compiled on or are running on. */
|
||||||
|
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||||
|
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||||
|
{
|
||||||
|
bfd_vma sp = bfd_h_get_32
|
||||||
|
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||||
|
if (sp < SPARC_USRSTACK_SPARC10)
|
||||||
|
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||||
|
else
|
||||||
|
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* byte-swap in the Solaris BCP core structure */
|
||||||
|
static void
|
||||||
|
swapcore_solaris_bcp (abfd, ext, intcore)
|
||||||
|
bfd *abfd;
|
||||||
|
char *ext;
|
||||||
|
struct internal_sunos_core *intcore;
|
||||||
|
{
|
||||||
|
struct external_solaris_bcp_core *extcore =
|
||||||
|
(struct external_solaris_bcp_core *) ext;
|
||||||
|
|
||||||
|
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||||
|
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||||
|
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
|
||||||
|
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||||
|
|
||||||
|
/* The Solaris BCP exdata structure does not contain an a_syms field,
|
||||||
|
so we are unable to synthesize an internal exec header.
|
||||||
|
Luckily we are able to figure out the start address of the data section,
|
||||||
|
which is the only thing needed from the internal exec header,
|
||||||
|
from the exdata structure.
|
||||||
|
|
||||||
|
As of Solaris 2.3, BCP core files for statically linked executables
|
||||||
|
are buggy. The exdata structure is not properly filled in, and
|
||||||
|
the data section is written from address zero instead of the data
|
||||||
|
start address. */
|
||||||
|
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
|
||||||
|
intcore->c_data_addr =
|
||||||
|
bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
|
||||||
|
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||||
|
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||||
|
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||||
|
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||||
|
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||||
|
intcore->fp_stuff_pos =
|
||||||
|
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||||
|
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||||
|
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||||
|
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||||
|
/* Ucode is the last thing in the struct -- just before the end */
|
||||||
|
intcore->c_ucode =
|
||||||
|
bfd_h_get_32 (abfd,
|
||||||
|
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||||
|
|
||||||
|
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||||
|
Presuming that this remains true, this definition will work. */
|
||||||
|
/* Now sun has provided us with another challenge. The value is different
|
||||||
|
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||||
|
the other based on the current value of the stack pointer. This
|
||||||
|
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||||
|
is larger than 128 megabytes.
|
||||||
|
|
||||||
|
It's times like these you're glad they're switching to ELF.
|
||||||
|
|
||||||
|
Note that using include files or nlist on /vmunix would be wrong,
|
||||||
|
because we want the value for this core file, no matter what kind of
|
||||||
|
machine we were compiled on or are running on. */
|
||||||
|
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||||
|
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||||
|
{
|
||||||
|
bfd_vma sp = bfd_h_get_32
|
||||||
|
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||||
|
if (sp < SPARC_USRSTACK_SPARC10)
|
||||||
|
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||||
|
else
|
||||||
|
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* need this cast because ptr is really void * */
|
||||||
|
#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
|
||||||
|
#define core_datasec(bfd) (core_hdr(bfd)->data_section)
|
||||||
|
#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
|
||||||
|
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
|
||||||
|
#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
|
||||||
|
|
||||||
|
/* These are stored in the bfd's tdata */
|
||||||
|
struct sun_core_struct
|
||||||
|
{
|
||||||
|
struct internal_sunos_core *hdr; /* core file header */
|
||||||
|
asection *data_section;
|
||||||
|
asection *stack_section;
|
||||||
|
asection *reg_section;
|
||||||
|
asection *reg2_section;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
sunos4_core_file_p (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||||
|
bfd_size_type core_size;
|
||||||
|
unsigned long core_mag;
|
||||||
|
struct internal_sunos_core *core;
|
||||||
|
char *extcore;
|
||||||
|
struct mergem
|
||||||
|
{
|
||||||
|
struct sun_core_struct suncoredata;
|
||||||
|
struct internal_sunos_core internal_sunos_core;
|
||||||
|
char external_core[1];
|
||||||
|
}
|
||||||
|
*mergem;
|
||||||
|
|
||||||
|
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||||
|
sizeof (longbuf))
|
||||||
|
return 0;
|
||||||
|
core_mag = bfd_h_get_32 (abfd, longbuf);
|
||||||
|
|
||||||
|
if (core_mag != CORE_MAGIC)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* SunOS core headers can vary in length; second word is size; */
|
||||||
|
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||||
|
sizeof (longbuf))
|
||||||
|
return 0;
|
||||||
|
core_size = bfd_h_get_32 (abfd, longbuf);
|
||||||
|
/* Sanity check */
|
||||||
|
if (core_size > 20000)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
|
||||||
|
if (mergem == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
extcore = mergem->external_core;
|
||||||
|
|
||||||
|
if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
|
||||||
|
{
|
||||||
|
bfd_release (abfd, (char *) mergem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate that it's a core file we know how to handle, due to sun
|
||||||
|
botching the positioning of registers and other fields in a machine
|
||||||
|
dependent way. */
|
||||||
|
core = &mergem->internal_sunos_core;
|
||||||
|
switch (core_size)
|
||||||
|
{
|
||||||
|
case SPARC_CORE_LEN:
|
||||||
|
swapcore_sparc (abfd, extcore, core);
|
||||||
|
break;
|
||||||
|
case SUN3_CORE_LEN:
|
||||||
|
swapcore_sun3 (abfd, extcore, core);
|
||||||
|
break;
|
||||||
|
case SOLARIS_BCP_CORE_LEN:
|
||||||
|
swapcore_solaris_bcp (abfd, extcore, core);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bfd_set_error (bfd_error_system_call); /* FIXME */
|
||||||
|
bfd_release (abfd, (char *) mergem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
abfd->tdata.sun_core_data = &mergem->suncoredata;
|
||||||
|
abfd->tdata.sun_core_data->hdr = core;
|
||||||
|
|
||||||
|
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||||
|
them */
|
||||||
|
core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_stacksec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
loser:
|
||||||
|
bfd_release (abfd, (char *) mergem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_datasec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
loser1:
|
||||||
|
bfd_release (abfd, core_stacksec (abfd));
|
||||||
|
goto loser;
|
||||||
|
}
|
||||||
|
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_regsec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
loser2:
|
||||||
|
bfd_release (abfd, core_datasec (abfd));
|
||||||
|
goto loser1;
|
||||||
|
}
|
||||||
|
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
if (core_reg2sec (abfd) == NULL)
|
||||||
|
{
|
||||||
|
bfd_release (abfd, core_regsec (abfd));
|
||||||
|
goto loser2;
|
||||||
|
}
|
||||||
|
|
||||||
|
core_stacksec (abfd)->name = ".stack";
|
||||||
|
core_datasec (abfd)->name = ".data";
|
||||||
|
core_regsec (abfd)->name = ".reg";
|
||||||
|
core_reg2sec (abfd)->name = ".reg2";
|
||||||
|
|
||||||
|
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||||
|
core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||||
|
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||||
|
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||||
|
|
||||||
|
core_stacksec (abfd)->_raw_size = core->c_ssize;
|
||||||
|
core_datasec (abfd)->_raw_size = core->c_dsize;
|
||||||
|
core_regsec (abfd)->_raw_size = core->c_regs_size;
|
||||||
|
core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
|
||||||
|
|
||||||
|
core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
|
||||||
|
core_datasec (abfd)->vma = core->c_data_addr;
|
||||||
|
core_regsec (abfd)->vma = 0;
|
||||||
|
core_reg2sec (abfd)->vma = 0;
|
||||||
|
|
||||||
|
core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
|
||||||
|
core_datasec (abfd)->filepos = core->c_len;
|
||||||
|
/* We'll access the regs afresh in the core file, like any section: */
|
||||||
|
core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
|
||||||
|
core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
|
||||||
|
|
||||||
|
/* Align to word at least */
|
||||||
|
core_stacksec (abfd)->alignment_power = 2;
|
||||||
|
core_datasec (abfd)->alignment_power = 2;
|
||||||
|
core_regsec (abfd)->alignment_power = 2;
|
||||||
|
core_reg2sec (abfd)->alignment_power = 2;
|
||||||
|
|
||||||
|
abfd->sections = core_stacksec (abfd);
|
||||||
|
core_stacksec (abfd)->next = core_datasec (abfd);
|
||||||
|
core_datasec (abfd)->next = core_regsec (abfd);
|
||||||
|
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||||
|
|
||||||
|
abfd->section_count = 4;
|
||||||
|
|
||||||
|
return abfd->xvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
sunos4_core_file_failing_command (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return core_hdr (abfd)->hdr->c_cmdname;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sunos4_core_file_failing_signal (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return core_hdr (abfd)->hdr->c_signo;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||||
|
bfd *core_bfd;
|
||||||
|
bfd *exec_bfd;
|
||||||
|
{
|
||||||
|
if (core_bfd->xvec != exec_bfd->xvec)
|
||||||
|
{
|
||||||
|
bfd_set_error (bfd_error_system_call);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Solaris core files do not include an aouthdr. */
|
||||||
|
if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
|
||||||
|
(char *) exec_hdr (exec_bfd),
|
||||||
|
sizeof (struct internal_exec)) == 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MY_set_sizes sunos4_set_sizes
|
||||||
|
static boolean
|
||||||
|
sunos4_set_sizes (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
switch (bfd_get_arch (abfd))
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
case bfd_arch_sparc:
|
||||||
|
adata (abfd).page_size = 0x2000;
|
||||||
|
adata (abfd).segment_size = 0x2000;
|
||||||
|
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||||
|
return true;
|
||||||
|
case bfd_arch_m68k:
|
||||||
|
adata (abfd).page_size = 0x2000;
|
||||||
|
adata (abfd).segment_size = 0x20000;
|
||||||
|
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We default to setting the toolversion field to 1, as is required by
|
||||||
|
SunOS. */
|
||||||
|
#ifndef MY_exec_hdr_flags
|
||||||
|
#define MY_exec_hdr_flags 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MY_add_dynamic_symbols
|
||||||
|
#define MY_add_dynamic_symbols 0
|
||||||
|
#endif
|
||||||
|
#ifndef MY_add_one_symbol
|
||||||
|
#define MY_add_one_symbol 0
|
||||||
|
#endif
|
||||||
|
#ifndef MY_link_dynamic_object
|
||||||
|
#define MY_link_dynamic_object 0
|
||||||
|
#endif
|
||||||
|
#ifndef MY_write_dynamic_symbol
|
||||||
|
#define MY_write_dynamic_symbol 0
|
||||||
|
#endif
|
||||||
|
#ifndef MY_check_dynamic_reloc
|
||||||
|
#define MY_check_dynamic_reloc 0
|
||||||
|
#endif
|
||||||
|
#ifndef MY_finish_dynamic_link
|
||||||
|
#define MY_finish_dynamic_link 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static CONST struct aout_backend_data sunos4_aout_backend =
|
||||||
|
{
|
||||||
|
0, /* zmagic files are not contiguous */
|
||||||
|
1, /* text includes header */
|
||||||
|
MY_exec_hdr_flags,
|
||||||
|
0, /* default text vma */
|
||||||
|
sunos4_set_sizes,
|
||||||
|
0, /* header is counted in zmagic text */
|
||||||
|
MY_add_dynamic_symbols,
|
||||||
|
MY_add_one_symbol,
|
||||||
|
MY_link_dynamic_object,
|
||||||
|
MY_write_dynamic_symbol,
|
||||||
|
MY_check_dynamic_reloc,
|
||||||
|
MY_finish_dynamic_link
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MY_core_file_failing_command sunos4_core_file_failing_command
|
||||||
|
#define MY_core_file_failing_signal sunos4_core_file_failing_signal
|
||||||
|
#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
|
||||||
|
|
||||||
|
#define MY_bfd_debug_info_start bfd_void
|
||||||
|
#define MY_bfd_debug_info_end bfd_void
|
||||||
|
#define MY_bfd_debug_info_accumulate \
|
||||||
|
(void (*) PARAMS ((bfd *, struct sec *))) bfd_void
|
||||||
|
#define MY_core_file_p sunos4_core_file_p
|
||||||
|
#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
|
||||||
|
#define MY_backend_data &sunos4_aout_backend
|
||||||
|
|
||||||
|
#define TARGET_IS_BIG_ENDIAN_P
|
||||||
|
|
||||||
|
#include "aout-target.h"
|
5525
contrib/gdb/bfd/aoutx.h
Normal file
5525
contrib/gdb/bfd/aoutx.h
Normal file
File diff suppressed because it is too large
Load Diff
2094
contrib/gdb/bfd/archive.c
Normal file
2094
contrib/gdb/bfd/archive.c
Normal file
File diff suppressed because it is too large
Load Diff
720
contrib/gdb/bfd/archures.c
Normal file
720
contrib/gdb/bfd/archures.c
Normal file
@ -0,0 +1,720 @@
|
|||||||
|
/* 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!";
|
||||||
|
}
|
668
contrib/gdb/bfd/bfd-in.h
Normal file
668
contrib/gdb/bfd/bfd-in.h
Normal file
@ -0,0 +1,668 @@
|
|||||||
|
/* 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. */
|
2479
contrib/gdb/bfd/bfd-in2.h
Normal file
2479
contrib/gdb/bfd/bfd-in2.h
Normal file
File diff suppressed because it is too large
Load Diff
1144
contrib/gdb/bfd/bfd.c
Normal file
1144
contrib/gdb/bfd/bfd.c
Normal file
File diff suppressed because it is too large
Load Diff
348
contrib/gdb/bfd/binary.c
Normal file
348
contrib/gdb/bfd/binary.c
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
/* 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
|
||||||
|
};
|
1471
contrib/gdb/bfd/bout.c
Normal file
1471
contrib/gdb/bfd/bout.c
Normal file
File diff suppressed because it is too large
Load Diff
347
contrib/gdb/bfd/cache.c
Normal file
347
contrib/gdb/bfd/cache.c
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
31
contrib/gdb/bfd/cf-i386lynx.c
Normal file
31
contrib/gdb/bfd/cf-i386lynx.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* BFD back-end for Intel 386 COFF LynxOS files.
|
||||||
|
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
|
||||||
|
#define TARGET_SYM i386lynx_coff_vec
|
||||||
|
#define TARGET_NAME "coff-i386-lynx"
|
||||||
|
|
||||||
|
#define LYNXOS
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
|
||||||
|
#include "coff-i386.c"
|
223
contrib/gdb/bfd/cf-m68klynx.c
Normal file
223
contrib/gdb/bfd/cf-m68klynx.c
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/* BFD back-end for Motorola M68K COFF LynxOS files.
|
||||||
|
Copyright 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. */
|
||||||
|
|
||||||
|
#define TARGET_SYM m68klynx_coff_vec
|
||||||
|
#define TARGET_NAME "coff-m68k-lynx"
|
||||||
|
|
||||||
|
#define LYNXOS
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
|
||||||
|
#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table
|
||||||
|
#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto
|
||||||
|
#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype
|
||||||
|
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
|
||||||
|
|
||||||
|
#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
|
||||||
|
#ifdef ANSI_PROTOTYPES
|
||||||
|
struct internal_reloc;
|
||||||
|
struct coff_link_hash_entry;
|
||||||
|
struct internal_syment;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static bfd_reloc_status_type _bfd_m68klynx_special_fn
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
|
||||||
|
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||||
|
struct coff_link_hash_entry *, struct internal_syment *,
|
||||||
|
bfd_vma *));
|
||||||
|
|
||||||
|
/* For some reason when using m68k COFF the value stored in the .text
|
||||||
|
section for a reference to a common symbol is the value itself plus
|
||||||
|
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||||
|
for I386 COFF). */
|
||||||
|
|
||||||
|
/* If we are producing relocateable output, we need to do some
|
||||||
|
adjustments to the object file that are not done by the
|
||||||
|
bfd_perform_relocation function. This function is called by every
|
||||||
|
reloc type to make any required adjustments. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
symvalue diff;
|
||||||
|
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
{
|
||||||
|
/* We are relocating a common symbol. The current value in the
|
||||||
|
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||||
|
common symbol as seen by the object file when it was compiled
|
||||||
|
(this may be zero if the symbol was undefined) and OFFSET is
|
||||||
|
the offset into the common symbol (normally zero, but may be
|
||||||
|
non-zero when referring to a field in a common structure).
|
||||||
|
ORIG is the negative of reloc_entry->addend, which is set by
|
||||||
|
the CALC_ADDEND macro below. We want to replace the value in
|
||||||
|
the object file with NEW + OFFSET, where NEW is the value of
|
||||||
|
the common symbol which we are going to put in the final
|
||||||
|
object file. NEW is symbol->value. */
|
||||||
|
diff = symbol->value + reloc_entry->addend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* For some reason bfd_perform_relocation always effectively
|
||||||
|
ignores the addend for a COFF target when producing
|
||||||
|
relocateable output. This seems to be always wrong for 386
|
||||||
|
COFF, so we handle the addend here instead. */
|
||||||
|
diff = reloc_entry->addend;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DOIT(x) \
|
||||||
|
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||||
|
|
||||||
|
if (diff != 0)
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||||
|
|
||||||
|
switch (howto->size)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char x = bfd_get_8 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_8 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
short x = bfd_get_16 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_16 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
long x = bfd_get_32 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_32 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now let bfd_perform_relocation finish everything up. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||||
|
the object file contains the value of the common symbol. By the
|
||||||
|
time this is called, the linker may be using a different symbol
|
||||||
|
from a different object file with a different value. Therefore, we
|
||||||
|
hack wildly to locate the original symbol from this file so that we
|
||||||
|
can make the correct adjustment. This macro sets coffsym to the
|
||||||
|
symbol from the original file, and uses it to set the addend value
|
||||||
|
correctly. If this is not a common symbol, the usual addend
|
||||||
|
calculation is done, except that an additional tweak is needed for
|
||||||
|
PC relative relocs.
|
||||||
|
FIXME: This macro refers to symbols and asect; these are from the
|
||||||
|
calling function, not the macro arguments. */
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||||
|
{ \
|
||||||
|
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||||
|
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||||
|
coffsym = (obj_symbols (abfd) \
|
||||||
|
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||||
|
else if (ptr) \
|
||||||
|
coffsym = coff_symbol_from (abfd, ptr); \
|
||||||
|
if (coffsym != (coff_symbol_type *) NULL \
|
||||||
|
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||||
|
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||||
|
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||||
|
&& ptr->section != (asection *) NULL) \
|
||||||
|
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||||
|
else \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||||
|
|| reloc.r_type == R_PCRWORD \
|
||||||
|
|| reloc.r_type == R_PCRLONG)) \
|
||||||
|
cache_ptr->addend += asect->vma; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
|
||||||
|
|
||||||
|
#include "coff-m68k.c"
|
||||||
|
|
||||||
|
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||||
|
adjust common symbols.
|
||||||
|
|
||||||
|
We can't define this function until after we have included
|
||||||
|
coff-m68k.c, because it uses RTYPE2HOWTO. */
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
bfd_vma *addendp;
|
||||||
|
{
|
||||||
|
arelent relent;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
|
||||||
|
RTYPE2HOWTO (&relent, rel);
|
||||||
|
|
||||||
|
howto = relent.howto;
|
||||||
|
|
||||||
|
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||||
|
{
|
||||||
|
/* This is a common symbol. The section contents include the
|
||||||
|
size (sym->n_value) as an addend. The relocate_section
|
||||||
|
function will be adding in the final value of the symbol. We
|
||||||
|
need to subtract out the current size in order to get the
|
||||||
|
correct result. */
|
||||||
|
BFD_ASSERT (h != NULL);
|
||||||
|
*addendp -= sym->n_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the output symbol is common (in which case this must be a
|
||||||
|
relocateable link), we need to add in the final size of the
|
||||||
|
common symbol. */
|
||||||
|
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||||
|
*addendp += h->root.u.c.size;
|
||||||
|
|
||||||
|
return howto;
|
||||||
|
}
|
28
contrib/gdb/bfd/cf-sparclynx.c
Normal file
28
contrib/gdb/bfd/cf-sparclynx.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* BFD back-end for Sparc COFF LynxOS files.
|
||||||
|
Copyright 1993 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGET_SYM sparclynx_coff_vec
|
||||||
|
#define TARGET_NAME "coff-sparc-lynx"
|
||||||
|
|
||||||
|
#define LYNXOS
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
|
||||||
|
#include "coff-sparc.c"
|
313
contrib/gdb/bfd/cisco-core.c
Normal file
313
contrib/gdb/bfd/cisco-core.c
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
/* BFD back-end for CISCO crash dumps.
|
||||||
|
|
||||||
|
Copyright 1994 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
/* core_file_failing_signal returns a host signal (this probably should
|
||||||
|
be fixed). */
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#define CRASH_INFO (0xffc)
|
||||||
|
#define CRASH_MAGIC 0xdead1234
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CRASH_REASON_NOTCRASHED = 0,
|
||||||
|
CRASH_REASON_EXCEPTION = 1,
|
||||||
|
CRASH_REASON_CORRUPT = 2,
|
||||||
|
} crashreason;
|
||||||
|
|
||||||
|
struct crashinfo_external
|
||||||
|
{
|
||||||
|
char magic[4]; /* Magic number */
|
||||||
|
char version[4]; /* Version number */
|
||||||
|
char reason[4]; /* Crash reason */
|
||||||
|
char cpu_vector[4]; /* CPU vector for exceptions */
|
||||||
|
char registers[4]; /* Pointer to saved registers */
|
||||||
|
char rambase[4]; /* Base of RAM (not in V1 crash info) */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cisco_core_struct
|
||||||
|
{
|
||||||
|
int sig;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
cisco_core_file_p (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
char buf[4];
|
||||||
|
unsigned int crashinfo_offset;
|
||||||
|
struct crashinfo_external crashinfo;
|
||||||
|
int nread;
|
||||||
|
unsigned int rambase;
|
||||||
|
sec_ptr asect;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
nread = bfd_read (buf, 1, 4, abfd);
|
||||||
|
if (nread != 4)
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
crashinfo_offset = bfd_get_32 (abfd, buf);
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
|
||||||
|
if (nread != sizeof (crashinfo))
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_system_call)
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_stat (abfd, &statbuf) < 0)
|
||||||
|
{
|
||||||
|
bfd_set_error (bfd_error_system_call);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC)
|
||||||
|
{
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (bfd_get_32 (abfd, crashinfo.version))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return NULL;
|
||||||
|
case 1:
|
||||||
|
rambase = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 2:
|
||||||
|
rambase = bfd_get_32 (abfd, crashinfo.rambase);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* OK, we believe you. You're a core file. */
|
||||||
|
|
||||||
|
abfd->tdata.cisco_core_data =
|
||||||
|
((struct cisco_core_struct *)
|
||||||
|
bfd_zmalloc (sizeof (struct cisco_core_struct)));
|
||||||
|
if (abfd->tdata.cisco_core_data == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
|
||||||
|
{
|
||||||
|
case CRASH_REASON_NOTCRASHED:
|
||||||
|
/* Crash file probably came from write core. */
|
||||||
|
abfd->tdata.cisco_core_data->sig = 0;
|
||||||
|
break;
|
||||||
|
case CRASH_REASON_CORRUPT:
|
||||||
|
/* The crash context area was corrupt -- proceed with caution.
|
||||||
|
We have no way of passing this information back to the caller. */
|
||||||
|
abfd->tdata.cisco_core_data->sig = 0;
|
||||||
|
break;
|
||||||
|
case CRASH_REASON_EXCEPTION:
|
||||||
|
/* Crash occured due to CPU exception. */
|
||||||
|
|
||||||
|
/* This is 68k-specific; for MIPS we'll need to interpret
|
||||||
|
cpu_vector differently based on the target configuration
|
||||||
|
(since CISCO core files don't seem to have the processor
|
||||||
|
encoded in them). */
|
||||||
|
|
||||||
|
switch (bfd_get_32 (abfd, crashinfo.cpu_vector))
|
||||||
|
{
|
||||||
|
/* bus error */
|
||||||
|
case 2 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||||
|
/* address error */
|
||||||
|
case 3 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||||
|
/* illegal instruction */
|
||||||
|
case 4 : abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||||
|
/* zero divide */
|
||||||
|
case 5 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* chk instruction */
|
||||||
|
case 6 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* trapv instruction */
|
||||||
|
case 7 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* privilege violation */
|
||||||
|
case 8 : abfd->tdata.cisco_core_data->sig = SIGSEGV; break;
|
||||||
|
/* trace trap */
|
||||||
|
case 9 : abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||||
|
/* line 1010 emulator */
|
||||||
|
case 10: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||||
|
/* line 1111 emulator */
|
||||||
|
case 11: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||||
|
|
||||||
|
/* Coprocessor protocol violation. Using a standard MMU or FPU
|
||||||
|
this cannot be triggered by software. Call it a SIGBUS. */
|
||||||
|
case 13: abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||||
|
|
||||||
|
/* interrupt */
|
||||||
|
case 31: abfd->tdata.cisco_core_data->sig = SIGINT; break;
|
||||||
|
/* breakpoint */
|
||||||
|
case 33: abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||||
|
|
||||||
|
/* floating point err */
|
||||||
|
case 48: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* floating point err */
|
||||||
|
case 49: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* zero divide */
|
||||||
|
case 50: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* underflow */
|
||||||
|
case 51: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* operand error */
|
||||||
|
case 52: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* overflow */
|
||||||
|
case 53: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
/* NAN */
|
||||||
|
case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||||
|
default:
|
||||||
|
/* "software generated"*/
|
||||||
|
abfd->tdata.cisco_core_data->sig = SIGEMT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Unknown crash reason. */
|
||||||
|
abfd->tdata.cisco_core_data->sig = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
abfd->sections = NULL;
|
||||||
|
abfd->section_count = 0;
|
||||||
|
|
||||||
|
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||||
|
if (asect == NULL)
|
||||||
|
goto error_return;
|
||||||
|
asect->name = ".reg";
|
||||||
|
asect->flags = SEC_HAS_CONTENTS;
|
||||||
|
/* This can be bigger than the real size. Set it to the size of the whole
|
||||||
|
core file. */
|
||||||
|
asect->_raw_size = statbuf.st_size;
|
||||||
|
asect->vma = 0;
|
||||||
|
asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
|
||||||
|
asect->next = abfd->sections;
|
||||||
|
abfd->sections = asect;
|
||||||
|
++abfd->section_count;
|
||||||
|
|
||||||
|
/* There is only one section containing data from the target system's RAM.
|
||||||
|
We call it .data. */
|
||||||
|
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||||
|
if (asect == NULL)
|
||||||
|
goto error_return;
|
||||||
|
asect->name = ".data";
|
||||||
|
asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||||
|
/* The size of memory is the size of the core file itself. */
|
||||||
|
asect->_raw_size = statbuf.st_size;
|
||||||
|
asect->vma = rambase;
|
||||||
|
asect->filepos = 0;
|
||||||
|
asect->next = abfd->sections;
|
||||||
|
abfd->sections = asect;
|
||||||
|
++abfd->section_count;
|
||||||
|
|
||||||
|
return abfd->xvec;
|
||||||
|
|
||||||
|
error_return:
|
||||||
|
{
|
||||||
|
sec_ptr nextsect;
|
||||||
|
for (asect = abfd->sections; asect != NULL;)
|
||||||
|
{
|
||||||
|
nextsect = asect->next;
|
||||||
|
free (asect);
|
||||||
|
asect = nextsect;
|
||||||
|
}
|
||||||
|
free (abfd->tdata.cisco_core_data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
cisco_core_file_failing_command (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cisco_core_file_failing_signal (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
return abfd->tdata.cisco_core_data->sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean
|
||||||
|
cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||||
|
bfd *core_bfd;
|
||||||
|
bfd *exec_bfd;
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bfd_target cisco_core_vec =
|
||||||
|
{
|
||||||
|
"trad-core",
|
||||||
|
bfd_target_unknown_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* target byte order */
|
||||||
|
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
0, /* symbol prefix */
|
||||||
|
' ', /* ar_pad_char */
|
||||||
|
16, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{ /* bfd_check_format */
|
||||||
|
_bfd_dummy_target, /* unknown format */
|
||||||
|
_bfd_dummy_target, /* object file */
|
||||||
|
_bfd_dummy_target, /* archive */
|
||||||
|
cisco_core_file_p /* a core file */
|
||||||
|
},
|
||||||
|
{ /* bfd_set_format */
|
||||||
|
bfd_false, bfd_false,
|
||||||
|
bfd_false, bfd_false
|
||||||
|
},
|
||||||
|
{ /* bfd_write_contents */
|
||||||
|
bfd_false, bfd_false,
|
||||||
|
bfd_false, bfd_false
|
||||||
|
},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_CORE (cisco),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||||
|
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||||
|
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
(PTR) 0 /* backend_data */
|
||||||
|
};
|
641
contrib/gdb/bfd/coff-a29k.c
Normal file
641
contrib/gdb/bfd/coff-a29k.c
Normal file
@ -0,0 +1,641 @@
|
|||||||
|
/* BFD back-end for AMD 29000 COFF binaries.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Contributed by David Wood at New York University 7/8/91.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define A29K 1
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/a29k.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
static long get_symbol_value PARAMS ((asymbol *));
|
||||||
|
static bfd_reloc_status_type a29k_reloc
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static boolean coff_a29k_relocate_section
|
||||||
|
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||||
|
struct internal_reloc *, struct internal_syment *, asection **));
|
||||||
|
static boolean coff_a29k_adjust_symndx
|
||||||
|
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||||
|
struct internal_reloc *, boolean *));
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||||
|
|
||||||
|
#define INSERT_HWORD(WORD,HWORD) \
|
||||||
|
(((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
|
||||||
|
#define EXTRACT_HWORD(WORD) \
|
||||||
|
((((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff))
|
||||||
|
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||||
|
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
|
||||||
|
|
||||||
|
/* Provided the symbol, returns the value reffed */
|
||||||
|
static long
|
||||||
|
get_symbol_value (symbol)
|
||||||
|
asymbol *symbol;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
{
|
||||||
|
relocation = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relocation = symbol->value +
|
||||||
|
symbol->section->output_section->vma +
|
||||||
|
symbol->section->output_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(relocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this function is in charge of performing all the 29k relocations */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||||
|
error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
/* the consth relocation comes in two parts, we have to remember
|
||||||
|
the state between calls, in these variables */
|
||||||
|
static boolean part1_consth_active = false;
|
||||||
|
static unsigned long part1_consth_value;
|
||||||
|
|
||||||
|
unsigned long insn;
|
||||||
|
unsigned long sym_value;
|
||||||
|
unsigned long unsigned_value;
|
||||||
|
unsigned short r_type;
|
||||||
|
long signed_value;
|
||||||
|
|
||||||
|
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
|
||||||
|
bfd_byte *hit_data =addr + (bfd_byte *)(data);
|
||||||
|
|
||||||
|
r_type = reloc_entry->howto->type;
|
||||||
|
|
||||||
|
if (output_bfd) {
|
||||||
|
/* Partial linking - do nothing */
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symbol_in != NULL
|
||||||
|
&& bfd_is_und_section (symbol_in->section))
|
||||||
|
{
|
||||||
|
/* Keep the state machine happy in case we're called again */
|
||||||
|
if (r_type == R_IHIHALF)
|
||||||
|
{
|
||||||
|
part1_consth_active = true;
|
||||||
|
part1_consth_value = 0;
|
||||||
|
}
|
||||||
|
return(bfd_reloc_undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((part1_consth_active) && (r_type != R_IHCONST))
|
||||||
|
{
|
||||||
|
part1_consth_active = false;
|
||||||
|
*error_message = (char *) "Missing IHCONST";
|
||||||
|
return(bfd_reloc_dangerous);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sym_value = get_symbol_value(symbol_in);
|
||||||
|
|
||||||
|
switch (r_type)
|
||||||
|
{
|
||||||
|
case R_IREL:
|
||||||
|
insn = bfd_get_32(abfd, hit_data);
|
||||||
|
/* Take the value in the field and sign extend it */
|
||||||
|
signed_value = EXTRACT_HWORD(insn);
|
||||||
|
signed_value = SIGN_EXTEND_HWORD(signed_value);
|
||||||
|
signed_value <<= 2;
|
||||||
|
|
||||||
|
/* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
|
||||||
|
if (signed_value == - (long) reloc_entry->address)
|
||||||
|
signed_value = 0;
|
||||||
|
|
||||||
|
signed_value += sym_value + reloc_entry->addend;
|
||||||
|
if ((signed_value & ~0x3ffff) == 0)
|
||||||
|
{ /* Absolute jmp/call */
|
||||||
|
insn |= (1<<24); /* Make it absolute */
|
||||||
|
/* FIXME: Should we change r_type to R_IABS */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Relative jmp/call, so subtract from the value the
|
||||||
|
address of the place we're coming from */
|
||||||
|
signed_value -= (reloc_entry->address
|
||||||
|
+ input_section->output_section->vma
|
||||||
|
+ input_section->output_offset);
|
||||||
|
if (signed_value>0x1ffff || signed_value<-0x20000)
|
||||||
|
return(bfd_reloc_overflow);
|
||||||
|
}
|
||||||
|
signed_value >>= 2;
|
||||||
|
insn = INSERT_HWORD(insn, signed_value);
|
||||||
|
bfd_put_32(abfd, insn ,hit_data);
|
||||||
|
break;
|
||||||
|
case R_ILOHALF:
|
||||||
|
insn = bfd_get_32(abfd, hit_data);
|
||||||
|
unsigned_value = EXTRACT_HWORD(insn);
|
||||||
|
unsigned_value += sym_value + reloc_entry->addend;
|
||||||
|
insn = INSERT_HWORD(insn, unsigned_value);
|
||||||
|
bfd_put_32(abfd, insn, hit_data);
|
||||||
|
break;
|
||||||
|
case R_IHIHALF:
|
||||||
|
insn = bfd_get_32(abfd, hit_data);
|
||||||
|
/* consth, part 1
|
||||||
|
Just get the symbol value that is referenced */
|
||||||
|
part1_consth_active = true;
|
||||||
|
part1_consth_value = sym_value + reloc_entry->addend;
|
||||||
|
/* Don't modify insn until R_IHCONST */
|
||||||
|
break;
|
||||||
|
case R_IHCONST:
|
||||||
|
insn = bfd_get_32(abfd, hit_data);
|
||||||
|
/* consth, part 2
|
||||||
|
Now relocate the reference */
|
||||||
|
if (part1_consth_active == false) {
|
||||||
|
*error_message = (char *) "Missing IHIHALF";
|
||||||
|
return(bfd_reloc_dangerous);
|
||||||
|
}
|
||||||
|
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
|
||||||
|
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
|
||||||
|
unsigned_value += reloc_entry->addend; /* r_symndx */
|
||||||
|
unsigned_value += part1_consth_value;
|
||||||
|
unsigned_value = unsigned_value >> 16;
|
||||||
|
insn = INSERT_HWORD(insn, unsigned_value);
|
||||||
|
part1_consth_active = false;
|
||||||
|
bfd_put_32(abfd, insn, hit_data);
|
||||||
|
break;
|
||||||
|
case R_BYTE:
|
||||||
|
insn = bfd_get_8(abfd, hit_data);
|
||||||
|
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||||
|
if (unsigned_value & 0xffffff00)
|
||||||
|
return(bfd_reloc_overflow);
|
||||||
|
bfd_put_8(abfd, unsigned_value, hit_data);
|
||||||
|
break;
|
||||||
|
case R_HWORD:
|
||||||
|
insn = bfd_get_16(abfd, hit_data);
|
||||||
|
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||||
|
if (unsigned_value & 0xffff0000)
|
||||||
|
return(bfd_reloc_overflow);
|
||||||
|
bfd_put_16(abfd, insn, hit_data);
|
||||||
|
break;
|
||||||
|
case R_WORD:
|
||||||
|
insn = bfd_get_32(abfd, hit_data);
|
||||||
|
insn += sym_value + reloc_entry->addend;
|
||||||
|
bfd_put_32(abfd, insn, hit_data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*error_message = "Unrecognized reloc";
|
||||||
|
return (bfd_reloc_dangerous);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return(bfd_reloc_ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* type rightshift
|
||||||
|
size
|
||||||
|
bitsize
|
||||||
|
pc-relative
|
||||||
|
bitpos
|
||||||
|
absolute
|
||||||
|
complain_on_overflow
|
||||||
|
special_function
|
||||||
|
relocation name
|
||||||
|
partial_inplace
|
||||||
|
src_mask
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*FIXME: I'm not real sure about this table */
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
{R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false},
|
||||||
|
{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10},
|
||||||
|
{11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20},
|
||||||
|
{21}, {22}, {23},
|
||||||
|
{R_IREL, 0, 3, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},
|
||||||
|
{R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},
|
||||||
|
{R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},
|
||||||
|
{R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},
|
||||||
|
{R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},
|
||||||
|
{R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},
|
||||||
|
{R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},
|
||||||
|
{R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BADMAG(x) A29KBADMAG(x)
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void
|
||||||
|
reloc_processing (relent,reloc, symbols, abfd, section)
|
||||||
|
arelent *relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol **symbols;
|
||||||
|
bfd *abfd;
|
||||||
|
asection *section;
|
||||||
|
{
|
||||||
|
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
|
||||||
|
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
relent->howto = howto_table + reloc->r_type;
|
||||||
|
if (reloc->r_type == R_IHCONST)
|
||||||
|
{
|
||||||
|
/* The address of an R_IHCONST should always be the address of
|
||||||
|
the immediately preceding R_IHIHALF. relocs generated by gas
|
||||||
|
are correct, but relocs generated by High C are different (I
|
||||||
|
can't figure out what the address means for High C). We can
|
||||||
|
handle both gas and High C by ignoring the address here, and
|
||||||
|
simply reusing the address saved for R_IHIHALF. */
|
||||||
|
if (ihihalf_vaddr == (bfd_vma) -1)
|
||||||
|
abort ();
|
||||||
|
relent->address = ihihalf_vaddr;
|
||||||
|
ihihalf_vaddr = (bfd_vma) -1;
|
||||||
|
relent->addend = reloc->r_symndx;
|
||||||
|
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
asymbol *ptr;
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
|
||||||
|
|
||||||
|
ptr = *(relent->sym_ptr_ptr);
|
||||||
|
|
||||||
|
if (ptr
|
||||||
|
&& bfd_asymbol_bfd(ptr) == abfd
|
||||||
|
|
||||||
|
&& ((ptr->flags & BSF_OLD_COMMON)== 0))
|
||||||
|
{
|
||||||
|
relent->addend = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->addend = 0;
|
||||||
|
}
|
||||||
|
relent->address-= section->vma;
|
||||||
|
if (reloc->r_type == R_IHIHALF)
|
||||||
|
ihihalf_vaddr = relent->address;
|
||||||
|
else if (ihihalf_vaddr != (bfd_vma) -1)
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The reloc processing routine for the optimized COFF linker. */
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||||
|
contents, relocs, syms, sections)
|
||||||
|
bfd *output_bfd;
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
bfd *input_bfd;
|
||||||
|
asection *input_section;
|
||||||
|
bfd_byte *contents;
|
||||||
|
struct internal_reloc *relocs;
|
||||||
|
struct internal_syment *syms;
|
||||||
|
asection **sections;
|
||||||
|
{
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct internal_reloc *relend;
|
||||||
|
boolean hihalf;
|
||||||
|
bfd_vma hihalf_val;
|
||||||
|
|
||||||
|
/* If we are performing a relocateable link, we don't need to do a
|
||||||
|
thing. The caller will take care of adjusting the reloc
|
||||||
|
addresses and symbol indices. */
|
||||||
|
if (info->relocateable)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
hihalf = false;
|
||||||
|
hihalf_val = 0;
|
||||||
|
|
||||||
|
rel = relocs;
|
||||||
|
relend = rel + input_section->reloc_count;
|
||||||
|
for (; rel < relend; rel++)
|
||||||
|
{
|
||||||
|
long symndx;
|
||||||
|
bfd_byte *loc;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
asection *sec;
|
||||||
|
bfd_vma val;
|
||||||
|
boolean overflow;
|
||||||
|
unsigned long insn;
|
||||||
|
long signed_value;
|
||||||
|
unsigned long unsigned_value;
|
||||||
|
bfd_reloc_status_type rstat;
|
||||||
|
|
||||||
|
symndx = rel->r_symndx;
|
||||||
|
loc = contents + rel->r_vaddr - input_section->vma;
|
||||||
|
|
||||||
|
if (symndx == -1)
|
||||||
|
h = NULL;
|
||||||
|
else
|
||||||
|
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||||
|
|
||||||
|
sym = NULL;
|
||||||
|
sec = NULL;
|
||||||
|
val = 0;
|
||||||
|
|
||||||
|
/* An R_IHCONST reloc does not have a symbol. Instead, the
|
||||||
|
symbol index is an addend. R_IHCONST is always used in
|
||||||
|
conjunction with R_IHHALF. */
|
||||||
|
if (rel->r_type != R_IHCONST)
|
||||||
|
{
|
||||||
|
if (h == NULL)
|
||||||
|
{
|
||||||
|
if (symndx == -1)
|
||||||
|
sec = bfd_abs_section_ptr;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sym = syms + symndx;
|
||||||
|
sec = sections[symndx];
|
||||||
|
val = (sec->output_section->vma
|
||||||
|
+ sec->output_offset
|
||||||
|
+ sym->n_value
|
||||||
|
- sec->vma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (h->root.type == bfd_link_hash_defined
|
||||||
|
|| h->root.type == bfd_link_hash_defweak)
|
||||||
|
{
|
||||||
|
sec = h->root.u.def.section;
|
||||||
|
val = (h->root.u.def.value
|
||||||
|
+ sec->output_section->vma
|
||||||
|
+ sec->output_offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! ((*info->callbacks->undefined_symbol)
|
||||||
|
(info, h->root.root.string, input_bfd, input_section,
|
||||||
|
rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hihalf)
|
||||||
|
{
|
||||||
|
if (! ((*info->callbacks->reloc_dangerous)
|
||||||
|
(info, "missing IHCONST reloc", input_bfd,
|
||||||
|
input_section, rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
hihalf = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
overflow = false;
|
||||||
|
|
||||||
|
switch (rel->r_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
bfd_set_error (bfd_error_bad_value);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case R_IREL:
|
||||||
|
insn = bfd_get_32 (input_bfd, loc);
|
||||||
|
|
||||||
|
/* Extract the addend. */
|
||||||
|
signed_value = EXTRACT_HWORD (insn);
|
||||||
|
signed_value = SIGN_EXTEND_HWORD (signed_value);
|
||||||
|
signed_value <<= 2;
|
||||||
|
|
||||||
|
/* Unfortunately, there are two different versions of COFF
|
||||||
|
a29k. In the original AMD version, the value stored in
|
||||||
|
the field for the R_IREL reloc is a simple addend. In
|
||||||
|
the GNU version, the value is the negative of the address
|
||||||
|
of the reloc within section. We try to cope here by
|
||||||
|
assuming the AMD version, unless the addend is exactly
|
||||||
|
the negative of the address; in the latter case we assume
|
||||||
|
the GNU version. This means that something like
|
||||||
|
.text
|
||||||
|
nop
|
||||||
|
jmp i-4
|
||||||
|
will fail, because the addend of -4 will happen to equal
|
||||||
|
the negative of the address within the section. The
|
||||||
|
compiler will never generate code like this.
|
||||||
|
|
||||||
|
At some point in the future we may want to take out this
|
||||||
|
check. */
|
||||||
|
|
||||||
|
if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
|
||||||
|
signed_value = 0;
|
||||||
|
|
||||||
|
/* Determine the destination of the jump. */
|
||||||
|
signed_value += val;
|
||||||
|
|
||||||
|
if ((signed_value & ~0x3ffff) == 0)
|
||||||
|
{
|
||||||
|
/* We can use an absolute jump. */
|
||||||
|
insn |= (1 << 24);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Make the destination PC relative. */
|
||||||
|
signed_value -= (input_section->output_section->vma
|
||||||
|
+ input_section->output_offset
|
||||||
|
+ (rel->r_vaddr - input_section->vma));
|
||||||
|
if (signed_value > 0x1ffff || signed_value < - 0x20000)
|
||||||
|
{
|
||||||
|
overflow = true;
|
||||||
|
signed_value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put the adjusted value back into the instruction. */
|
||||||
|
signed_value >>= 2;
|
||||||
|
insn = INSERT_HWORD (insn, signed_value);
|
||||||
|
|
||||||
|
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_ILOHALF:
|
||||||
|
insn = bfd_get_32 (input_bfd, loc);
|
||||||
|
unsigned_value = EXTRACT_HWORD (insn);
|
||||||
|
unsigned_value += val;
|
||||||
|
insn = INSERT_HWORD (insn, unsigned_value);
|
||||||
|
bfd_put_32 (input_bfd, insn, loc);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_IHIHALF:
|
||||||
|
/* Save the value for the R_IHCONST reloc. */
|
||||||
|
hihalf = true;
|
||||||
|
hihalf_val = val;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_IHCONST:
|
||||||
|
if (! hihalf)
|
||||||
|
{
|
||||||
|
if (! ((*info->callbacks->reloc_dangerous)
|
||||||
|
(info, "missing IHIHALF reloc", input_bfd,
|
||||||
|
input_section, rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
hihalf_val = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
insn = bfd_get_32 (input_bfd, loc);
|
||||||
|
unsigned_value = rel->r_symndx + hihalf_val;
|
||||||
|
unsigned_value >>= 16;
|
||||||
|
insn = INSERT_HWORD (insn, unsigned_value);
|
||||||
|
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||||
|
|
||||||
|
hihalf = false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_BYTE:
|
||||||
|
case R_HWORD:
|
||||||
|
case R_WORD:
|
||||||
|
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
|
||||||
|
input_bfd, val, loc);
|
||||||
|
if (rstat == bfd_reloc_overflow)
|
||||||
|
overflow = true;
|
||||||
|
else if (rstat != bfd_reloc_ok)
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overflow)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
char buf[SYMNMLEN + 1];
|
||||||
|
|
||||||
|
if (symndx == -1)
|
||||||
|
name = "*ABS*";
|
||||||
|
else if (h != NULL)
|
||||||
|
name = h->root.root.string;
|
||||||
|
else if (sym == NULL)
|
||||||
|
name = "*unknown*";
|
||||||
|
else if (sym->_n._n_n._n_zeroes == 0
|
||||||
|
&& sym->_n._n_n._n_offset != 0)
|
||||||
|
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||||
|
buf[SYMNMLEN] = '\0';
|
||||||
|
name = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! ((*info->callbacks->reloc_overflow)
|
||||||
|
(info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
|
||||||
|
input_bfd, input_section,
|
||||||
|
rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_relocate_section coff_a29k_relocate_section
|
||||||
|
|
||||||
|
/* We don't want to change the symndx of a R_IHCONST reloc, since it
|
||||||
|
is actually an addend, not a symbol index at all. */
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
static boolean
|
||||||
|
coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||||
|
bfd *obfd;
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
bfd *ibfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *irel;
|
||||||
|
boolean *adjustedp;
|
||||||
|
{
|
||||||
|
if (irel->r_type == R_IHCONST)
|
||||||
|
*adjustedp = true;
|
||||||
|
else
|
||||||
|
*adjustedp = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_adjust_symndx coff_a29k_adjust_symndx
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target a29kcoff_big_vec =
|
||||||
|
{
|
||||||
|
"coff-a29k-big", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
|
||||||
|
| SEC_LOAD | SEC_RELOC
|
||||||
|
| SEC_READONLY ),
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
/* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||||
|
/* hdrs */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
_bfd_dummy_target,
|
||||||
|
coff_object_p,
|
||||||
|
bfd_generic_archive_p,
|
||||||
|
_bfd_dummy_target
|
||||||
|
},
|
||||||
|
{
|
||||||
|
bfd_false,
|
||||||
|
coff_mkobject,
|
||||||
|
_bfd_generic_mkarchive,
|
||||||
|
bfd_false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
bfd_false,
|
||||||
|
coff_write_object_contents,
|
||||||
|
_bfd_write_archive_contents,
|
||||||
|
bfd_false
|
||||||
|
},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE
|
||||||
|
};
|
2390
contrib/gdb/bfd/coff-alpha.c
Normal file
2390
contrib/gdb/bfd/coff-alpha.c
Normal file
File diff suppressed because it is too large
Load Diff
162
contrib/gdb/bfd/coff-apollo.c
Normal file
162
contrib/gdb/bfd/coff-apollo.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* BFD back-end for Apollo 68000 COFF binaries.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
By Troy Rollo (troy@cbme.unsw.edu.au)
|
||||||
|
Based on m68k standard COFF version Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/apollo.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||||
|
|
||||||
|
#ifdef ONLY_DECLARE_RELOCS
|
||||||
|
extern reloc_howto_type apollocoff_howto_table[];
|
||||||
|
#else
|
||||||
|
reloc_howto_type apollocoff_howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
};
|
||||||
|
#endif /* not ONLY_DECLARE_RELOCS */
|
||||||
|
|
||||||
|
#ifndef BADMAG
|
||||||
|
#define BADMAG(x) M68KBADMAG(x)
|
||||||
|
#endif
|
||||||
|
#define APOLLO_M68 1 /* Customize coffcode.h */
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
#ifdef ONLY_DECLARE_RELOCS
|
||||||
|
extern void apollo_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||||
|
extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
apollo_rtype2howto(internal, relocentry)
|
||||||
|
arelent *internal;
|
||||||
|
int relocentry;
|
||||||
|
{
|
||||||
|
switch (relocentry)
|
||||||
|
{
|
||||||
|
case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
|
||||||
|
case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
|
||||||
|
case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
|
||||||
|
case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
|
||||||
|
case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
|
||||||
|
case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
|
||||||
|
case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
apollo_howto2rtype (internal)
|
||||||
|
reloc_howto_type *internal;
|
||||||
|
{
|
||||||
|
if (internal->pc_relative)
|
||||||
|
{
|
||||||
|
switch (internal->bitsize)
|
||||||
|
{
|
||||||
|
case 32: return R_PCRLONG;
|
||||||
|
case 16: return R_PCRWORD;
|
||||||
|
case 8: return R_PCRBYTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (internal->bitsize)
|
||||||
|
{
|
||||||
|
case 32: return R_RELLONG;
|
||||||
|
case 16: return R_RELWORD;
|
||||||
|
case 8: return R_RELBYTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R_RELLONG;
|
||||||
|
}
|
||||||
|
#endif /* not ONLY_DECLARE_RELOCS */
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) \
|
||||||
|
apollo_rtype2howto(internal, (relocentry)->r_type)
|
||||||
|
|
||||||
|
#define SELECT_RELOC(external, internal) \
|
||||||
|
external.r_type = apollo_howto2rtype(internal);
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_SYM
|
||||||
|
TARGET_SYM =
|
||||||
|
#else
|
||||||
|
apollocoff_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_NAME
|
||||||
|
TARGET_NAME,
|
||||||
|
#else
|
||||||
|
"apollo-m68k", /* name */
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
#ifdef NAMES_HAVE_UNDERSCORE
|
||||||
|
'_',
|
||||||
|
#else
|
||||||
|
0, /* leading underscore */
|
||||||
|
#endif
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE
|
||||||
|
};
|
537
contrib/gdb/bfd/coff-arm.c
Normal file
537
contrib/gdb/bfd/coff-arm.c
Normal file
@ -0,0 +1,537 @@
|
|||||||
|
/* BFD back-end for ARM 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/arm.h"
|
||||||
|
|
||||||
|
#include "coff/internal.h"
|
||||||
|
|
||||||
|
#ifdef COFF_WITH_PE
|
||||||
|
#include "coff/pe.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
aoutarm_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||||
|
asection *, bfd *, char **));
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
aoutarm_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||||
|
asection *, bfd *, char **));
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type coff_arm_reloc
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
|
||||||
|
|
||||||
|
/* Used by the assembler. */
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||||
|
error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
symvalue diff;
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
diff = reloc_entry->addend;
|
||||||
|
|
||||||
|
#define DOIT(x) \
|
||||||
|
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||||
|
|
||||||
|
if (diff != 0)
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||||
|
|
||||||
|
switch (howto->size)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char x = bfd_get_8 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_8 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
short x = bfd_get_16 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_16 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
long x = bfd_get_32 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_32 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now let bfd_perform_relocation finish everything up. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef PCRELOFFSET
|
||||||
|
#define PCRELOFFSET true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static reloc_howto_type aoutarm_std_reloc_howto[] =
|
||||||
|
{
|
||||||
|
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
|
||||||
|
HOWTO(0, /* type */
|
||||||
|
0, /* rs */
|
||||||
|
0, /* size */
|
||||||
|
8, /* bsz */
|
||||||
|
false, /* pcrel */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* ovf */
|
||||||
|
coff_arm_reloc, /* sf */
|
||||||
|
"8", /*name */
|
||||||
|
true, /* partial */
|
||||||
|
0x000000ff, /*read mask */
|
||||||
|
0x000000ff, /* setmask */
|
||||||
|
PCRELOFFSET /* pcdone */),
|
||||||
|
HOWTO(1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
16,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_bitfield,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"16",
|
||||||
|
true,
|
||||||
|
0x0000ffff,
|
||||||
|
0x0000ffff,
|
||||||
|
PCRELOFFSET),
|
||||||
|
HOWTO( 2,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
32,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_bitfield,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"32",
|
||||||
|
true,
|
||||||
|
0xffffffff,
|
||||||
|
0xffffffff,
|
||||||
|
PCRELOFFSET),
|
||||||
|
HOWTO( 3,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
26,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
complain_overflow_signed,
|
||||||
|
aoutarm_fix_pcrel_26 ,
|
||||||
|
"ARM26",
|
||||||
|
false,
|
||||||
|
0x00ffffff,
|
||||||
|
0x00ffffff,
|
||||||
|
PCRELOFFSET),
|
||||||
|
HOWTO( 4,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
8,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
complain_overflow_signed,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"DISP8",
|
||||||
|
true,
|
||||||
|
0x000000ff,
|
||||||
|
0x000000ff,
|
||||||
|
true),
|
||||||
|
HOWTO( 5,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
16,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
complain_overflow_signed,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"DISP16",
|
||||||
|
true,
|
||||||
|
0x0000ffff,
|
||||||
|
0x0000ffff,
|
||||||
|
true),
|
||||||
|
HOWTO( 6,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
32,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
complain_overflow_signed,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"DISP32",
|
||||||
|
true,
|
||||||
|
0xffffffff,
|
||||||
|
0xffffffff,
|
||||||
|
true),
|
||||||
|
HOWTO( 7,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
26,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_signed,
|
||||||
|
aoutarm_fix_pcrel_26_done,
|
||||||
|
"ARM26D",
|
||||||
|
true,
|
||||||
|
0x00ffffff,
|
||||||
|
0x00ffffff,
|
||||||
|
false),
|
||||||
|
{-1},
|
||||||
|
HOWTO( 9,
|
||||||
|
0,
|
||||||
|
-1,
|
||||||
|
16,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_bitfield,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"NEG16",
|
||||||
|
true,
|
||||||
|
0x0000ffff,
|
||||||
|
0x0000ffff,
|
||||||
|
false),
|
||||||
|
HOWTO( 10,
|
||||||
|
0,
|
||||||
|
-2,
|
||||||
|
32,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_bitfield,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"NEG32",
|
||||||
|
true,
|
||||||
|
0xffffffff,
|
||||||
|
0xffffffff,
|
||||||
|
false),
|
||||||
|
HOWTO( 11,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
32,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
complain_overflow_bitfield,
|
||||||
|
coff_arm_reloc,
|
||||||
|
"rva32",
|
||||||
|
true,
|
||||||
|
0xffffffff,
|
||||||
|
0xffffffff,
|
||||||
|
PCRELOFFSET),
|
||||||
|
};
|
||||||
|
#ifdef COFF_WITH_PE
|
||||||
|
/* Return true if this relocation should
|
||||||
|
appear in the output .reloc section. */
|
||||||
|
|
||||||
|
static boolean in_reloc_p (abfd, howto)
|
||||||
|
bfd * abfd;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
{
|
||||||
|
return !howto->pc_relative && howto->type != 11;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||||
|
(cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
|
||||||
|
|
||||||
|
#define coff_rtype_to_howto coff_arm_rtype_to_howto
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
bfd_vma *addendp;
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
|
||||||
|
howto = aoutarm_std_reloc_howto + rel->r_type;
|
||||||
|
|
||||||
|
if (rel->r_type == 11)
|
||||||
|
{
|
||||||
|
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||||
|
}
|
||||||
|
return howto;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Used by the assembler. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
/* This is dead simple at present. */
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Used by the assembler. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
bfd_vma relocation;
|
||||||
|
bfd_size_type addr = reloc_entry->address;
|
||||||
|
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||||
|
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||||
|
|
||||||
|
/* If this is an undefined symbol, return error */
|
||||||
|
if (symbol->section == &bfd_und_section
|
||||||
|
&& (symbol->flags & BSF_WEAK) == 0)
|
||||||
|
return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
|
||||||
|
|
||||||
|
/* If the sections are different, and we are doing a partial relocation,
|
||||||
|
just ignore it for now. */
|
||||||
|
if (symbol->section->name != input_section->name
|
||||||
|
&& output_bfd != (bfd *)NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
relocation = (target & 0x00ffffff) << 2;
|
||||||
|
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||||
|
relocation += symbol->value;
|
||||||
|
relocation += symbol->section->output_section->vma;
|
||||||
|
relocation += symbol->section->output_offset;
|
||||||
|
relocation += reloc_entry->addend;
|
||||||
|
relocation -= input_section->output_section->vma;
|
||||||
|
relocation -= input_section->output_offset;
|
||||||
|
relocation -= addr;
|
||||||
|
if (relocation & 3)
|
||||||
|
return bfd_reloc_overflow;
|
||||||
|
|
||||||
|
/* Check for overflow */
|
||||||
|
if (relocation & 0x02000000)
|
||||||
|
{
|
||||||
|
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
else if (relocation & ~0x03ffffff)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
|
||||||
|
target &= ~0x00ffffff;
|
||||||
|
target |= (relocation >> 2) & 0x00ffffff;
|
||||||
|
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||||
|
Strictly this is only necessary if we are doing a partial relocation. */
|
||||||
|
reloc_entry->howto = &aoutarm_std_reloc_howto[7];
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static CONST struct reloc_howto_struct *
|
||||||
|
arm_reloc_type_lookup(abfd,code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
|
||||||
|
if (code == BFD_RELOC_CTOR)
|
||||||
|
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
code = BFD_RELOC_32;
|
||||||
|
break;
|
||||||
|
default: return (CONST struct reloc_howto_struct *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
ASTD (BFD_RELOC_16, 1);
|
||||||
|
ASTD (BFD_RELOC_32, 2);
|
||||||
|
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||||
|
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||||
|
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||||
|
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||||
|
ASTD (BFD_RELOC_RVA, 11);
|
||||||
|
default: return (CONST struct reloc_howto_struct *) 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define coff_bfd_reloc_type_lookup arm_reloc_type_lookup
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||||
|
#define COFF_PAGE_SIZE 0x1000
|
||||||
|
/* Turn a howto into a reloc nunmber */
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||||
|
#define BADMAG(x) ARMBADMAG(x)
|
||||||
|
#define ARM 1 /* Customize coffcode.h */
|
||||||
|
|
||||||
|
|
||||||
|
/* We use the special COFF backend linker. */
|
||||||
|
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||||
|
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_LITTLE_SYM
|
||||||
|
TARGET_LITTLE_SYM =
|
||||||
|
#else
|
||||||
|
armcoff_little_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_LITTLE_NAME
|
||||||
|
TARGET_LITTLE_NAME,
|
||||||
|
#else
|
||||||
|
"coff-arm-little",
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||||
|
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
|
||||||
|
(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, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, coff_object_p},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_BIG_SYM
|
||||||
|
TARGET_BIG_SYM =
|
||||||
|
#else
|
||||||
|
armcoff_big_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_BIG_NAME
|
||||||
|
TARGET_BIG_NAME,
|
||||||
|
#else
|
||||||
|
"coff-arm-big",
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
|
||||||
|
(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_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
/* Note that we allow an object file to be treated as a core file as well. */
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, coff_object_p},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
332
contrib/gdb/bfd/coff-aux.c
Normal file
332
contrib/gdb/bfd/coff-aux.c
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
/* BFD back-end for Apple M68K COFF A/UX 3.x files.
|
||||||
|
Copyright 1996 Free Software Foundation, Inc.
|
||||||
|
Portions written by Richard Henderson <rth@tamu.edu>,
|
||||||
|
COMMON symbol munging cribbed from cf-m68klynx.c which was
|
||||||
|
written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGET_SYM m68kaux_coff_vec
|
||||||
|
#define TARGET_NAME "coff-m68k-aux"
|
||||||
|
|
||||||
|
#ifndef TARG_AUX
|
||||||
|
#define TARG_AUX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
|
||||||
|
/* 4k pages */
|
||||||
|
#define COFF_PAGE_SIZE 0x1000
|
||||||
|
|
||||||
|
/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
|
||||||
|
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||||
|
|
||||||
|
#define _bfd_m68kcoff_howto_table _bfd_m68kaux_howto_table
|
||||||
|
#define _bfd_m68kcoff_rtype2howto _bfd_m68kaux_rtype2howto
|
||||||
|
#define _bfd_m68kcoff_howto2rtype _bfd_m68kaux_howto2rtype
|
||||||
|
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68kaux_reloc_type_lookup
|
||||||
|
|
||||||
|
/* Rather than change names lots of places, reuse the same hack */
|
||||||
|
#define LYNX_SPECIAL_FN _bfd_m68kaux_special_fn
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
|
||||||
|
#ifdef ANSI_PROTOTYPES
|
||||||
|
struct internal_reloc;
|
||||||
|
struct coff_link_hash_entry;
|
||||||
|
struct internal_syment;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type _bfd_m68kaux_special_fn
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static reloc_howto_type *coff_m68k_aux_rtype_to_howto
|
||||||
|
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||||
|
struct coff_link_hash_entry *, struct internal_syment *,
|
||||||
|
bfd_vma *));
|
||||||
|
static boolean coff_m68k_aux_link_add_one_symbol
|
||||||
|
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
|
||||||
|
asection *, bfd_vma, const char *, boolean, boolean,
|
||||||
|
struct bfd_link_hash_entry **));
|
||||||
|
|
||||||
|
|
||||||
|
#define coff_rtype_to_howto coff_m68k_aux_rtype_to_howto
|
||||||
|
#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
|
||||||
|
|
||||||
|
|
||||||
|
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||||
|
the object file contains the value of the common symbol. By the
|
||||||
|
time this is called, the linker may be using a different symbol
|
||||||
|
from a different object file with a different value. Therefore, we
|
||||||
|
hack wildly to locate the original symbol from this file so that we
|
||||||
|
can make the correct adjustment. This macro sets coffsym to the
|
||||||
|
symbol from the original file, and uses it to set the addend value
|
||||||
|
correctly. If this is not a common symbol, the usual addend
|
||||||
|
calculation is done, except that an additional tweak is needed for
|
||||||
|
PC relative relocs.
|
||||||
|
FIXME: This macro refers to symbols and asect; these are from the
|
||||||
|
calling function, not the macro arguments. */
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||||
|
{ \
|
||||||
|
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||||
|
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||||
|
coffsym = (obj_symbols (abfd) \
|
||||||
|
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||||
|
else if (ptr) \
|
||||||
|
coffsym = coff_symbol_from (abfd, ptr); \
|
||||||
|
if (coffsym != (coff_symbol_type *) NULL \
|
||||||
|
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||||
|
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||||
|
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||||
|
&& ptr->section != (asection *) NULL) \
|
||||||
|
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||||
|
else \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||||
|
|| reloc.r_type == R_PCRWORD \
|
||||||
|
|| reloc.r_type == R_PCRLONG)) \
|
||||||
|
cache_ptr->addend += asect->vma; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
|
||||||
|
#include "coff-m68k.c"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* For some reason when using m68k COFF the value stored in the .text
|
||||||
|
section for a reference to a common symbol is the value itself plus
|
||||||
|
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||||
|
for I386 COFF). */
|
||||||
|
|
||||||
|
/* If we are producing relocateable output, we need to do some
|
||||||
|
adjustments to the object file that are not done by the
|
||||||
|
bfd_perform_relocation function. This function is called by every
|
||||||
|
reloc type to make any required adjustments. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
_bfd_m68kaux_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
symvalue diff;
|
||||||
|
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
{
|
||||||
|
/* We are relocating a common symbol. The current value in the
|
||||||
|
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||||
|
common symbol as seen by the object file when it was compiled
|
||||||
|
(this may be zero if the symbol was undefined) and OFFSET is
|
||||||
|
the offset into the common symbol (normally zero, but may be
|
||||||
|
non-zero when referring to a field in a common structure).
|
||||||
|
ORIG is the negative of reloc_entry->addend, which is set by
|
||||||
|
the CALC_ADDEND macro below. We want to replace the value in
|
||||||
|
the object file with NEW + OFFSET, where NEW is the value of
|
||||||
|
the common symbol which we are going to put in the final
|
||||||
|
object file. NEW is symbol->value. */
|
||||||
|
diff = symbol->value + reloc_entry->addend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* For some reason bfd_perform_relocation always effectively
|
||||||
|
ignores the addend for a COFF target when producing
|
||||||
|
relocateable output. This seems to be always wrong for 386
|
||||||
|
COFF, so we handle the addend here instead. */
|
||||||
|
diff = reloc_entry->addend;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DOIT(x) \
|
||||||
|
x = ((x & ~howto->dst_mask) | \
|
||||||
|
(((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||||
|
|
||||||
|
if (diff != 0)
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||||
|
|
||||||
|
switch (howto->size)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char x = bfd_get_8 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_8 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
short x = bfd_get_16 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_16 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
long x = bfd_get_32 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_32 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now let bfd_perform_relocation finish everything up. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||||
|
adjust common symbols. */
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_m68k_aux_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
bfd_vma *addendp;
|
||||||
|
{
|
||||||
|
arelent relent;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
|
||||||
|
RTYPE2HOWTO (&relent, rel);
|
||||||
|
|
||||||
|
howto = relent.howto;
|
||||||
|
|
||||||
|
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||||
|
{
|
||||||
|
/* This is a common symbol. The section contents include the
|
||||||
|
size (sym->n_value) as an addend. The relocate_section
|
||||||
|
function will be adding in the final value of the symbol. We
|
||||||
|
need to subtract out the current size in order to get the
|
||||||
|
correct result. */
|
||||||
|
BFD_ASSERT (h != NULL);
|
||||||
|
*addendp -= sym->n_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the output symbol is common (in which case this must be a
|
||||||
|
relocateable link), we need to add in the final size of the
|
||||||
|
common symbol. */
|
||||||
|
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||||
|
*addendp += h->root.u.c.size;
|
||||||
|
|
||||||
|
return howto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* We need non-absolute symbols to override absolute symbols. This
|
||||||
|
mirrors Apple's "solution" to let a static library symbol override
|
||||||
|
a shared library symbol. On the whole not a good thing, given how
|
||||||
|
shared libraries work here, but can work if you are careful with
|
||||||
|
what you include in the shared object. */
|
||||||
|
|
||||||
|
boolean
|
||||||
|
coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||||
|
string, copy, collect, hashp)
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
bfd *abfd;
|
||||||
|
const char *name;
|
||||||
|
flagword flags;
|
||||||
|
asection *section;
|
||||||
|
bfd_vma value;
|
||||||
|
const char *string;
|
||||||
|
boolean copy;
|
||||||
|
boolean collect;
|
||||||
|
struct bfd_link_hash_entry **hashp;
|
||||||
|
{
|
||||||
|
struct bfd_link_hash_entry *h;
|
||||||
|
|
||||||
|
if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
|
||||||
|
!bfd_is_und_section (section) &&
|
||||||
|
!bfd_is_com_section (section))
|
||||||
|
{
|
||||||
|
/* The new symbol is a definition or an indirect definition */
|
||||||
|
|
||||||
|
/* This bit copied from linker.c */
|
||||||
|
if (hashp != NULL && *hashp != NULL)
|
||||||
|
{
|
||||||
|
h = *hashp;
|
||||||
|
BFD_ASSERT (strcmp (h->root.string, name) == 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
|
||||||
|
if (h == NULL)
|
||||||
|
{
|
||||||
|
if (hashp != NULL)
|
||||||
|
*hashp = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->notice_hash != (struct bfd_hash_table *) NULL
|
||||||
|
&& (bfd_hash_lookup (info->notice_hash, name, false, false)
|
||||||
|
!= (struct bfd_hash_entry *) NULL))
|
||||||
|
{
|
||||||
|
if (! (*info->callbacks->notice) (info, name, abfd, section, value))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashp != (struct bfd_link_hash_entry **) NULL)
|
||||||
|
*hashp = h;
|
||||||
|
/* end duplication from linker.c */
|
||||||
|
|
||||||
|
if (h->type == bfd_link_hash_defined
|
||||||
|
|| h->type == bfd_link_hash_indirect)
|
||||||
|
{
|
||||||
|
asection *msec;
|
||||||
|
|
||||||
|
if (h->type == bfd_link_hash_defined)
|
||||||
|
msec = h->u.def.section;
|
||||||
|
else
|
||||||
|
msec = bfd_ind_section_ptr;
|
||||||
|
|
||||||
|
if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
|
||||||
|
{
|
||||||
|
h->u.def.section = section;
|
||||||
|
h->u.def.value = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we didn't exit early, finish processing in the generic routine */
|
||||||
|
return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
|
||||||
|
value, string, copy, collect,
|
||||||
|
hashp);
|
||||||
|
}
|
25
contrib/gdb/bfd/coff-go32.c
Normal file
25
contrib/gdb/bfd/coff-go32.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* BFD back-end for Intel 386 COFF files (go32 variant).
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by DJ Delorie.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGET_SYM go32coff_vec
|
||||||
|
#define TARGET_NAME "coff-go32"
|
||||||
|
#define TARGET_UNDERSCORE '_'
|
||||||
|
|
||||||
|
#include "coff-i386.c"
|
650
contrib/gdb/bfd/coff-h8300.c
Normal file
650
contrib/gdb/bfd/coff-h8300.c
Normal file
@ -0,0 +1,650 @@
|
|||||||
|
/* BFD back-end for Hitachi H8/300 COFF binaries.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995 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 "obstack.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "bfdlink.h"
|
||||||
|
#include "genlink.h"
|
||||||
|
#include "coff/h8300.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||||
|
|
||||||
|
|
||||||
|
/* special handling for H8/300 relocs.
|
||||||
|
We only come here for pcrel stuff and return normally if not an -r link.
|
||||||
|
When doing -r, we can't do any arithmetic for the pcrel stuff, because
|
||||||
|
the code in reloc.c assumes that we can manipulate the targets of
|
||||||
|
the pcrel branches. This isn't so, since the H8/300 can do relaxing,
|
||||||
|
which means that the gap after the instruction may not be enough to
|
||||||
|
contain the offset required for the branch, so we have to use the only
|
||||||
|
the addend until the final link */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||||
|
error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
|
||||||
|
HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
|
||||||
|
HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
|
||||||
|
HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
|
||||||
|
HOWTO (R_MOVB1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_MOVB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/16", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
|
||||||
|
|
||||||
|
|
||||||
|
HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
|
||||||
|
HOWTO (R_JMPL_B8, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
|
||||||
|
|
||||||
|
HOWTO (R_MOVLB1, 0, 1, 16, false, 0, complain_overflow_bitfield,special, "24/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_MOVLB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/24", false, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
|
||||||
|
/* An indirect reference to a function. This causes the function's address
|
||||||
|
to be added to the function vector in lo-mem and puts the address of
|
||||||
|
the function vector's entry in the jsr instruction. */
|
||||||
|
HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) \
|
||||||
|
{ x.r_type = select_reloc(howto); }
|
||||||
|
|
||||||
|
#define BADMAG(x) (H8300BADMAG(x)&& H8300HBADMAG(x))
|
||||||
|
#define H8300 1 /* Customize coffcode.h */
|
||||||
|
#define __A_MAGIC_SET__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Code to swap in the reloc */
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||||
|
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||||
|
dst->r_stuff[0] = 'S'; \
|
||||||
|
dst->r_stuff[1] = 'C';
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
select_reloc (howto)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
{
|
||||||
|
return howto->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtype2howto (internal, dst)
|
||||||
|
arelent *internal;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
switch (dst->r_type)
|
||||||
|
{
|
||||||
|
case R_RELBYTE:
|
||||||
|
internal->howto = howto_table + 0;
|
||||||
|
break;
|
||||||
|
case R_RELWORD:
|
||||||
|
internal->howto = howto_table + 1;
|
||||||
|
break;
|
||||||
|
case R_RELLONG:
|
||||||
|
internal->howto = howto_table + 2;
|
||||||
|
break;
|
||||||
|
case R_PCRBYTE:
|
||||||
|
internal->howto = howto_table + 3;
|
||||||
|
break;
|
||||||
|
case R_PCRWORD:
|
||||||
|
internal->howto = howto_table + 4;
|
||||||
|
break;
|
||||||
|
case R_PCRLONG:
|
||||||
|
internal->howto = howto_table + 5;
|
||||||
|
break;
|
||||||
|
case R_MOVB1:
|
||||||
|
internal->howto = howto_table + 6;
|
||||||
|
break;
|
||||||
|
case R_MOVB2:
|
||||||
|
internal->howto = howto_table + 7;
|
||||||
|
break;
|
||||||
|
case R_JMP1:
|
||||||
|
internal->howto = howto_table + 8;
|
||||||
|
break;
|
||||||
|
case R_JMP2:
|
||||||
|
internal->howto = howto_table + 9;
|
||||||
|
break;
|
||||||
|
case R_JMPL1:
|
||||||
|
internal->howto = howto_table + 10;
|
||||||
|
break;
|
||||||
|
case R_JMPL_B8:
|
||||||
|
internal->howto = howto_table + 11;
|
||||||
|
break;
|
||||||
|
case R_MOVLB1:
|
||||||
|
internal->howto = howto_table + 12;
|
||||||
|
break;
|
||||||
|
case R_MOVLB2:
|
||||||
|
internal->howto = howto_table + 13;
|
||||||
|
break;
|
||||||
|
case R_MEM_INDIRECT:
|
||||||
|
internal->howto = howto_table + 14;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||||
|
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||||
|
cache_ptr->addend = ext_reloc.r_offset;
|
||||||
|
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void
|
||||||
|
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||||
|
arelent * relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol ** symbols;
|
||||||
|
bfd * abfd;
|
||||||
|
asection * section;
|
||||||
|
{
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
rtype2howto (relent, reloc);
|
||||||
|
|
||||||
|
if (((int) reloc->r_symndx) > 0)
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
relent->addend = reloc->r_offset;
|
||||||
|
|
||||||
|
relent->address -= section->vma;
|
||||||
|
/* relent->section = 0;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *input_section;
|
||||||
|
arelent *reloc;
|
||||||
|
unsigned int shrink;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
{
|
||||||
|
bfd_vma value;
|
||||||
|
bfd_vma dot;
|
||||||
|
bfd_vma gap;
|
||||||
|
|
||||||
|
/* The address of the thing to be relocated will have moved back by
|
||||||
|
the size of the shrink - but we don't change reloc->address here,
|
||||||
|
since we need it to know where the relocation lives in the source
|
||||||
|
uncooked section */
|
||||||
|
|
||||||
|
/* reloc->address -= shrink; conceptual */
|
||||||
|
|
||||||
|
bfd_vma address = reloc->address - shrink;
|
||||||
|
|
||||||
|
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
case R_MOVB2:
|
||||||
|
case R_JMP2:
|
||||||
|
shrink+=2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Thing is a move one byte */
|
||||||
|
case R_MOVB1:
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
if (value >= 0xff00)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||||
|
possible 16 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* The place to relc moves back by one */
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
/* This is the 24 bit branch which could become an 8 bitter,
|
||||||
|
the relocation points to the first byte of the insn, not the
|
||||||
|
actual data */
|
||||||
|
|
||||||
|
case R_JMPL1:
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
dot = input_section->output_section->vma +
|
||||||
|
input_section->output_offset + address;
|
||||||
|
|
||||||
|
/* See if the address we're looking at within 127 bytes of where
|
||||||
|
we are, if so then we can use a small branch rather than the
|
||||||
|
jump we were going to */
|
||||||
|
|
||||||
|
gap = value - dot ;
|
||||||
|
|
||||||
|
if (-120 < (long)gap && (long)gap < 120 )
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||||
|
possible 32 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_JMP1:
|
||||||
|
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
dot = input_section->output_section->vma +
|
||||||
|
input_section->output_offset + address;
|
||||||
|
|
||||||
|
/* See if the address we're looking at within 127 bytes of where
|
||||||
|
we are, if so then we can use a small branch rather than the
|
||||||
|
jump we were going to */
|
||||||
|
|
||||||
|
gap = value - (dot - shrink);
|
||||||
|
|
||||||
|
|
||||||
|
if (-120 < (long)gap && (long)gap < 120 )
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||||
|
possible 16 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* The place to relc moves back by one */
|
||||||
|
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return shrink;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* First phase of a relaxing link */
|
||||||
|
|
||||||
|
/* Reloc types
|
||||||
|
large small
|
||||||
|
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||||
|
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||||
|
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||||
|
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||||
|
dst_ptr)
|
||||||
|
bfd *abfd;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
struct bfd_link_order *link_order;
|
||||||
|
arelent *reloc;
|
||||||
|
bfd_byte *data;
|
||||||
|
unsigned int *src_ptr;
|
||||||
|
unsigned int *dst_ptr;
|
||||||
|
{
|
||||||
|
unsigned int src_address = *src_ptr;
|
||||||
|
unsigned int dst_address = *dst_ptr;
|
||||||
|
asection *input_section = link_order->u.indirect.section;
|
||||||
|
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
/* A 24 bit branch which could be a 8 bit pcrel, really pointing to
|
||||||
|
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||||
|
case R_PCRBYTE:
|
||||||
|
{
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
- dot);
|
||||||
|
if (gap > 127 || gap < -128)
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
gap &= ~1;
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address++;
|
||||||
|
src_address++;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case R_PCRWORD:
|
||||||
|
{
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
- dot) - 1;
|
||||||
|
if (gap > 32767 || gap < -32768)
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
dst_address+=2;
|
||||||
|
src_address+=2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R_MEM_INDIRECT: /* Temporary */
|
||||||
|
case R_RELBYTE:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
if (gap < 0xff
|
||||||
|
|| (gap >= 0x0000ff00
|
||||||
|
&& gap <= 0x0000ffff)
|
||||||
|
|| ( gap >= 0x00ffff00
|
||||||
|
&& gap <= 0x00ffffff)
|
||||||
|
|| ( gap >= 0xffffff00
|
||||||
|
&& gap <= 0xffffffff))
|
||||||
|
{
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R_JMP1:
|
||||||
|
/* A relword which would have like to have been a pcrel */
|
||||||
|
case R_MOVB1:
|
||||||
|
/* A relword which would like to have been modified but
|
||||||
|
didn't make it */
|
||||||
|
case R_RELWORD:
|
||||||
|
bfd_put_16 (abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + dst_address);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 2;
|
||||||
|
break;
|
||||||
|
case R_RELLONG:
|
||||||
|
bfd_put_32 (abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + dst_address);
|
||||||
|
dst_address += 4;
|
||||||
|
src_address += 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_MOVB2:
|
||||||
|
/* Special relaxed type, there will be a gap between where we
|
||||||
|
get stuff from and where we put stuff to now
|
||||||
|
|
||||||
|
for a mov.b @aa:16 -> mov.b @aa:8
|
||||||
|
opcode 0x6a 0x0y offset
|
||||||
|
-> 0x2y off
|
||||||
|
*/
|
||||||
|
if (data[dst_address - 1] != 0x6a)
|
||||||
|
abort ();
|
||||||
|
switch (data[src_address] & 0xf0)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
/* Src is memory */
|
||||||
|
data[dst_address - 1] = (data[src_address] & 0xf) | 0x20;
|
||||||
|
break;
|
||||||
|
case 0x80:
|
||||||
|
/* Src is reg */
|
||||||
|
data[dst_address - 1] = (data[src_address] & 0xf) | 0x30;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the offset must fit ! after all, what was all the relaxing
|
||||||
|
about ? */
|
||||||
|
|
||||||
|
bfd_put_8 (abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + dst_address);
|
||||||
|
|
||||||
|
/* Note the magic - src goes up by two bytes, but dst by only
|
||||||
|
one */
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_JMP2:
|
||||||
|
|
||||||
|
/* Speciial relaxed type */
|
||||||
|
{
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
|
||||||
|
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
- dot - 1);
|
||||||
|
|
||||||
|
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
|
||||||
|
switch (data[dst_address - 1])
|
||||||
|
{
|
||||||
|
case 0x5e:
|
||||||
|
/* jsr -> bsr */
|
||||||
|
bfd_put_8 (abfd, 0x55, data + dst_address - 1);
|
||||||
|
break;
|
||||||
|
case 0x5a:
|
||||||
|
/* jmp ->bra */
|
||||||
|
bfd_put_8 (abfd, 0x40, data + dst_address - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
dst_address++;
|
||||||
|
src_address += 3;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_JMPL_B8: /* 24 bit branch which is now 8 bits */
|
||||||
|
|
||||||
|
/* Speciial relaxed type */
|
||||||
|
{
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
|
||||||
|
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
- dot - 2);
|
||||||
|
|
||||||
|
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
switch (data[src_address])
|
||||||
|
{
|
||||||
|
case 0x5e:
|
||||||
|
/* jsr -> bsr */
|
||||||
|
bfd_put_8 (abfd, 0x55, data + dst_address);
|
||||||
|
break;
|
||||||
|
case 0x5a:
|
||||||
|
/* jmp ->bra */
|
||||||
|
bfd_put_8 (abfd, 0x40, data + dst_address);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
bfd_put_8 (abfd, 0xde, data + dst_address);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address + 1);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 4;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R_JMPL1:
|
||||||
|
{
|
||||||
|
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||||
|
int o = bfd_get_32 (abfd, data + src_address);
|
||||||
|
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||||
|
bfd_put_32 (abfd, v, data + dst_address);
|
||||||
|
dst_address += 4;
|
||||||
|
src_address += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
/* A 24 bit mov which could be an 8 bit move, really pointing to
|
||||||
|
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||||
|
case R_MOVLB1:
|
||||||
|
{
|
||||||
|
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||||
|
int o = bfd_get_32 (abfd, data + dst_address);
|
||||||
|
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||||
|
bfd_put_32 (abfd, v, data + dst_address);
|
||||||
|
dst_address += 4;
|
||||||
|
src_address += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
*src_ptr = src_address;
|
||||||
|
*dst_ptr = dst_address;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||||
|
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef coff_bfd_get_relocated_section_contents
|
||||||
|
#undef coff_bfd_relax_section
|
||||||
|
#define coff_bfd_get_relocated_section_contents \
|
||||||
|
bfd_coff_reloc16_get_relocated_section_contents
|
||||||
|
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const bfd_target h8300coff_vec =
|
||||||
|
{
|
||||||
|
"coff-h8300", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading char */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
355
contrib/gdb/bfd/coff-h8500.c
Normal file
355
contrib/gdb/bfd/coff-h8500.c
Normal file
@ -0,0 +1,355 @@
|
|||||||
|
/* BFD back-end for Hitachi H8/500 COFF binaries.
|
||||||
|
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Contributed by Cygnus Support.
|
||||||
|
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "bfdlink.h"
|
||||||
|
#include "coff/h8500.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm8 =
|
||||||
|
HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm16 =
|
||||||
|
HOWTO (R_H8500_IMM16, 0, 1, 16, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm16", true, 0x0000ffff, 0x0000ffff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm24 =
|
||||||
|
HOWTO (R_H8500_IMM24, 0, 1, 24, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm24", true, 0x00ffffff, 0x00ffffff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm32 =
|
||||||
|
HOWTO (R_H8500_IMM32, 0, 1, 32, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff, 0xffffffff, false);
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type r_high8 =
|
||||||
|
HOWTO (R_H8500_HIGH8, 0, 1, 8, false, 0,
|
||||||
|
complain_overflow_dont, 0, "r_high8", true, 0x000000ff, 0x000000ff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_low16 =
|
||||||
|
HOWTO (R_H8500_LOW16, 0, 1, 16, false, 0,
|
||||||
|
complain_overflow_dont, 0, "r_low16", true, 0x0000ffff, 0x0000ffff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_pcrel8 =
|
||||||
|
HOWTO (R_H8500_PCREL8, 0, 1, 8, true, 0, complain_overflow_signed, 0, "r_pcrel8", true, 0, 0, true);
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type r_pcrel16 =
|
||||||
|
HOWTO (R_H8500_PCREL16, 0, 1, 16, true, 0, complain_overflow_signed, 0, "r_pcrel16", true, 0, 0, true);
|
||||||
|
|
||||||
|
static reloc_howto_type r_high16 =
|
||||||
|
HOWTO (R_H8500_HIGH16, 0, 1, 8, false, 0,
|
||||||
|
complain_overflow_dont, 0, "r_high16", true, 0x000ffff, 0x0000ffff, false);
|
||||||
|
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_h8500_select_reloc (howto)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
{
|
||||||
|
return howto->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
|
||||||
|
|
||||||
|
|
||||||
|
#define BADMAG(x) H8500BADMAG(x)
|
||||||
|
#define H8500 1 /* Customize coffcode.h */
|
||||||
|
|
||||||
|
#define __A_MAGIC_SET__
|
||||||
|
|
||||||
|
/* Code to swap in the reloc */
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||||
|
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||||
|
dst->r_stuff[0] = 'S'; \
|
||||||
|
dst->r_stuff[1] = 'C';
|
||||||
|
|
||||||
|
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtype2howto(internal, dst)
|
||||||
|
arelent * internal;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
switch (dst->r_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
case R_H8500_IMM8:
|
||||||
|
internal->howto = &r_imm8;
|
||||||
|
break;
|
||||||
|
case R_H8500_IMM16:
|
||||||
|
internal->howto = &r_imm16;
|
||||||
|
break;
|
||||||
|
case R_H8500_IMM24:
|
||||||
|
internal->howto = &r_imm24;
|
||||||
|
break;
|
||||||
|
case R_H8500_IMM32:
|
||||||
|
internal->howto = &r_imm32;
|
||||||
|
break;
|
||||||
|
case R_H8500_PCREL8:
|
||||||
|
internal->howto = &r_pcrel8;
|
||||||
|
break;
|
||||||
|
case R_H8500_PCREL16:
|
||||||
|
internal->howto = &r_pcrel16;
|
||||||
|
break;
|
||||||
|
case R_H8500_HIGH8:
|
||||||
|
internal->howto = &r_high8;
|
||||||
|
break;
|
||||||
|
case R_H8500_HIGH16:
|
||||||
|
internal->howto = &r_high16;
|
||||||
|
break;
|
||||||
|
case R_H8500_LOW16:
|
||||||
|
internal->howto = &r_low16;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||||
|
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||||
|
cache_ptr->addend = ext_reloc.r_offset;
|
||||||
|
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void reloc_processing (relent, reloc, symbols, abfd, section)
|
||||||
|
arelent * relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol ** symbols;
|
||||||
|
bfd * abfd;
|
||||||
|
asection * section;
|
||||||
|
{
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
rtype2howto (relent, reloc);
|
||||||
|
|
||||||
|
if (reloc->r_symndx > 0)
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
relent->addend = reloc->r_offset;
|
||||||
|
relent->address -= section->vma;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||||
|
bfd *in_abfd;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
struct bfd_link_order *link_order;
|
||||||
|
arelent *reloc;
|
||||||
|
bfd_byte *data;
|
||||||
|
unsigned int *src_ptr;
|
||||||
|
unsigned int *dst_ptr;
|
||||||
|
{
|
||||||
|
bfd_byte *d = data+*dst_ptr;
|
||||||
|
asection *input_section = link_order->u.indirect.section;
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
case R_H8500_IMM8:
|
||||||
|
bfd_put_8 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
d);
|
||||||
|
(*dst_ptr) += 1;
|
||||||
|
(*src_ptr) += 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_H8500_HIGH8:
|
||||||
|
bfd_put_8 (in_abfd,
|
||||||
|
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
>> 16),
|
||||||
|
d );
|
||||||
|
(*dst_ptr) += 1;
|
||||||
|
(*src_ptr) += 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_H8500_IMM16:
|
||||||
|
bfd_put_16 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
d );
|
||||||
|
(*dst_ptr) += 2;
|
||||||
|
(*src_ptr) += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_H8500_LOW16:
|
||||||
|
bfd_put_16 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
d);
|
||||||
|
|
||||||
|
(*dst_ptr) += 2;
|
||||||
|
(*src_ptr) += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_H8500_HIGH16:
|
||||||
|
bfd_put_16 (in_abfd,
|
||||||
|
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||||
|
>>16),
|
||||||
|
d);
|
||||||
|
|
||||||
|
(*dst_ptr) += 2;
|
||||||
|
(*src_ptr) += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_H8500_IMM24:
|
||||||
|
{
|
||||||
|
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
int o = bfd_get_32(in_abfd, data+ *dst_ptr -1);
|
||||||
|
v = (v & 0x00ffffff) | (o & 0xff00000);
|
||||||
|
bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
|
||||||
|
(*dst_ptr) +=3;
|
||||||
|
(*src_ptr)+=3;;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R_H8500_IMM32:
|
||||||
|
{
|
||||||
|
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
bfd_put_32 (in_abfd, v, data + *dst_ptr);
|
||||||
|
(*dst_ptr) +=4;
|
||||||
|
(*src_ptr)+=4;;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case R_H8500_PCREL8:
|
||||||
|
{
|
||||||
|
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ *dst_ptr
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||||
|
word and the pc's been incremented */
|
||||||
|
|
||||||
|
if (gap > 128 || gap < -128)
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||||
|
(*dst_ptr)++;
|
||||||
|
(*src_ptr)++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case R_H8500_PCREL16:
|
||||||
|
{
|
||||||
|
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ *dst_ptr
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||||
|
word and the pc's been incremented */
|
||||||
|
|
||||||
|
if (gap > 32767 || gap < -32768)
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
bfd_put_16 (in_abfd, gap, data + *dst_ptr);
|
||||||
|
(*dst_ptr)+=2;
|
||||||
|
(*src_ptr)+=2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_reloc16_extra_cases extra_case
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef coff_bfd_get_relocated_section_contents
|
||||||
|
#undef coff_bfd_relax_section
|
||||||
|
#define coff_bfd_get_relocated_section_contents \
|
||||||
|
bfd_coff_reloc16_get_relocated_section_contents
|
||||||
|
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||||
|
|
||||||
|
const bfd_target h8500coff_vec =
|
||||||
|
{
|
||||||
|
"coff-h8500", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading symbol underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
493
contrib/gdb/bfd/coff-i386.c
Normal file
493
contrib/gdb/bfd/coff-i386.c
Normal file
@ -0,0 +1,493 @@
|
|||||||
|
/* 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,
|
||||||
|
};
|
423
contrib/gdb/bfd/coff-i860.c
Normal file
423
contrib/gdb/bfd/coff-i860.c
Normal file
@ -0,0 +1,423 @@
|
|||||||
|
/* BFD back-end for Intel 860 COFF files.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
|
Created mostly by substituting "860" for "386" in coff-i386.c
|
||||||
|
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
|
||||||
|
#include "coff/i860.h"
|
||||||
|
|
||||||
|
#include "coff/internal.h"
|
||||||
|
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
static bfd_reloc_status_type coff_i860_reloc
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static reloc_howto_type *coff_i860_rtype_to_howto
|
||||||
|
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||||
|
struct coff_link_hash_entry *, struct internal_syment *,
|
||||||
|
bfd_vma *));
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||||
|
/* The page size is a guess based on ELF. */
|
||||||
|
|
||||||
|
#define COFF_PAGE_SIZE 0x1000
|
||||||
|
|
||||||
|
/* For some reason when using i860 COFF the value stored in the .text
|
||||||
|
section for a reference to a common symbol is the value itself plus
|
||||||
|
any desired offset. Ian Taylor, Cygnus Support. */
|
||||||
|
|
||||||
|
/* If we are producing relocateable output, we need to do some
|
||||||
|
adjustments to the object file that are not done by the
|
||||||
|
bfd_perform_relocation function. This function is called by every
|
||||||
|
reloc type to make any required adjustments. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||||
|
error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
symvalue diff;
|
||||||
|
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
{
|
||||||
|
/* We are relocating a common symbol. The current value in the
|
||||||
|
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||||
|
common symbol as seen by the object file when it was compiled
|
||||||
|
(this may be zero if the symbol was undefined) and OFFSET is
|
||||||
|
the offset into the common symbol (normally zero, but may be
|
||||||
|
non-zero when referring to a field in a common structure).
|
||||||
|
ORIG is the negative of reloc_entry->addend, which is set by
|
||||||
|
the CALC_ADDEND macro below. We want to replace the value in
|
||||||
|
the object file with NEW + OFFSET, where NEW is the value of
|
||||||
|
the common symbol which we are going to put in the final
|
||||||
|
object file. NEW is symbol->value. */
|
||||||
|
diff = symbol->value + reloc_entry->addend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* For some reason bfd_perform_relocation always effectively
|
||||||
|
ignores the addend for a COFF target when producing
|
||||||
|
relocateable output. This seems to be always wrong for 860
|
||||||
|
COFF, so we handle the addend here instead. */
|
||||||
|
diff = reloc_entry->addend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define DOIT(x) \
|
||||||
|
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||||
|
|
||||||
|
if (diff != 0)
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||||
|
|
||||||
|
switch (howto->size)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char x = bfd_get_8 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_8 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
short x = bfd_get_16 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_16 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
long x = bfd_get_32 (abfd, addr);
|
||||||
|
DOIT (x);
|
||||||
|
bfd_put_32 (abfd, x, addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now let bfd_perform_relocation finish everything up. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef PCRELOFFSET
|
||||||
|
#define PCRELOFFSET false
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
{0},
|
||||||
|
{1},
|
||||||
|
{2},
|
||||||
|
{3},
|
||||||
|
{4},
|
||||||
|
{5},
|
||||||
|
HOWTO (R_DIR32, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
32, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"dir32", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0xffffffff, /* src_mask */
|
||||||
|
0xffffffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
/* {7}, */
|
||||||
|
HOWTO (R_IMAGEBASE, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
32, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"rva32", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0xffffffff, /* src_mask */
|
||||||
|
0xffffffff, /* dst_mask */
|
||||||
|
false), /* pcrel_offset */
|
||||||
|
{010},
|
||||||
|
{011},
|
||||||
|
{012},
|
||||||
|
{013},
|
||||||
|
{014},
|
||||||
|
{015},
|
||||||
|
{016},
|
||||||
|
HOWTO (R_RELBYTE, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
8, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"8", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0x000000ff, /* src_mask */
|
||||||
|
0x000000ff, /* dst_mask */
|
||||||
|
PCRELOFFSET), /* pcrel_offset */
|
||||||
|
HOWTO (R_RELWORD, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"16", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
PCRELOFFSET), /* pcrel_offset */
|
||||||
|
HOWTO (R_RELLONG, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
32, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"32", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0xffffffff, /* src_mask */
|
||||||
|
0xffffffff, /* dst_mask */
|
||||||
|
PCRELOFFSET), /* pcrel_offset */
|
||||||
|
HOWTO (R_PCRBYTE, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
8, /* bitsize */
|
||||||
|
true, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_signed, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"DISP8", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0x000000ff, /* src_mask */
|
||||||
|
0x000000ff, /* dst_mask */
|
||||||
|
PCRELOFFSET), /* pcrel_offset */
|
||||||
|
HOWTO (R_PCRWORD, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
true, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_signed, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"DISP16", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
PCRELOFFSET), /* pcrel_offset */
|
||||||
|
HOWTO (R_PCRLONG, /* type */
|
||||||
|
0, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
32, /* bitsize */
|
||||||
|
true, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_signed, /* complain_on_overflow */
|
||||||
|
coff_i860_reloc, /* special_function */
|
||||||
|
"DISP32", /* name */
|
||||||
|
true, /* partial_inplace */
|
||||||
|
0xffffffff, /* src_mask */
|
||||||
|
0xffffffff, /* dst_mask */
|
||||||
|
PCRELOFFSET) /* pcrel_offset */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc nunmber */
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||||
|
#define BADMAG(x) I860BADMAG(x)
|
||||||
|
#define I860 1 /* Customize coffcode.h */
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||||
|
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||||
|
|
||||||
|
/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||||
|
library. On some other COFF targets STYP_BSS is normally
|
||||||
|
STYP_NOLOAD. */
|
||||||
|
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||||
|
|
||||||
|
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||||
|
the object file contains the value of the common symbol. By the
|
||||||
|
time this is called, the linker may be using a different symbol
|
||||||
|
from a different object file with a different value. Therefore, we
|
||||||
|
hack wildly to locate the original symbol from this file so that we
|
||||||
|
can make the correct adjustment. This macro sets coffsym to the
|
||||||
|
symbol from the original file, and uses it to set the addend value
|
||||||
|
correctly. If this is not a common symbol, the usual addend
|
||||||
|
calculation is done, except that an additional tweak is needed for
|
||||||
|
PC relative relocs.
|
||||||
|
FIXME: This macro refers to symbols and asect; these are from the
|
||||||
|
calling function, not the macro arguments. */
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||||
|
{ \
|
||||||
|
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||||
|
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||||
|
coffsym = (obj_symbols (abfd) \
|
||||||
|
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||||
|
else if (ptr) \
|
||||||
|
coffsym = coff_symbol_from (abfd, ptr); \
|
||||||
|
if (coffsym != (coff_symbol_type *) NULL \
|
||||||
|
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||||
|
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||||
|
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||||
|
&& ptr->section != (asection *) NULL) \
|
||||||
|
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||||
|
else \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||||
|
cache_ptr->addend += asect->vma; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We use the special COFF backend linker. */
|
||||||
|
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
bfd_vma *addendp;
|
||||||
|
{
|
||||||
|
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
|
||||||
|
howto = howto_table + rel->r_type;
|
||||||
|
|
||||||
|
if (howto->pc_relative)
|
||||||
|
*addendp += sec->vma;
|
||||||
|
|
||||||
|
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||||
|
{
|
||||||
|
/* This is a common symbol. The section contents include the
|
||||||
|
size (sym->n_value) as an addend. The relocate_section
|
||||||
|
function will be adding in the final value of the symbol. We
|
||||||
|
need to subtract out the current size in order to get the
|
||||||
|
correct result. */
|
||||||
|
|
||||||
|
BFD_ASSERT (h != NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||||
|
parameters get the wrong relcation address. If I link two versions
|
||||||
|
with and without this section bypassed and then do a binary comparison,
|
||||||
|
the addresses which are different can be looked up in the map. The
|
||||||
|
case in which this section has been bypassed has addresses which correspond
|
||||||
|
to values I can find in the map */
|
||||||
|
*addendp -= sym->n_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the output symbol is common (in which case this must be a
|
||||||
|
relocateable link), we need to add in the final size of the
|
||||||
|
common symbol. */
|
||||||
|
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||||
|
*addendp += h->root.u.c.size;
|
||||||
|
|
||||||
|
return howto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_rtype_to_howto coff_i860_rtype_to_howto
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
static const bfd_target *
|
||||||
|
i3coff_object_p(a)
|
||||||
|
bfd *a;
|
||||||
|
{
|
||||||
|
return coff_object_p(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_SYM
|
||||||
|
TARGET_SYM =
|
||||||
|
#else
|
||||||
|
i860coff_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_NAME
|
||||||
|
TARGET_NAME,
|
||||||
|
#else
|
||||||
|
"coff-i860", /* name */
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||||
|
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||||
|
|
||||||
|
/* Note that we allow an object file to be treated as a core file as well. */
|
||||||
|
{_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, i3coff_object_p},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
683
contrib/gdb/bfd/coff-i960.c
Normal file
683
contrib/gdb/bfd/coff-i960.c
Normal file
@ -0,0 +1,683 @@
|
|||||||
|
/* BFD back-end for Intel 960 COFF files.
|
||||||
|
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. */
|
||||||
|
|
||||||
|
#define I960 1
|
||||||
|
#define BADMAG(x) I960BADMAG(x)
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/i960.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type optcall_callback
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static bfd_reloc_status_type coff_i960_relocate
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static reloc_howto_type *coff_i960_reloc_type_lookup
|
||||||
|
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||||
|
static boolean coff_i960_start_final_link
|
||||||
|
PARAMS ((bfd *, struct bfd_link_info *));
|
||||||
|
static boolean coff_i960_relocate_section
|
||||||
|
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||||
|
struct internal_reloc *, struct internal_syment *, asection **));
|
||||||
|
static boolean coff_i960_adjust_symndx
|
||||||
|
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||||
|
struct internal_reloc *, boolean *));
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||||
|
|
||||||
|
/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
|
||||||
|
arbitrarily small. */
|
||||||
|
#define COFF_PAGE_SIZE 1
|
||||||
|
|
||||||
|
#define COFF_LONG_FILENAMES
|
||||||
|
|
||||||
|
/* This is just like the usual CALC_ADDEND, but it includes the
|
||||||
|
section VMA for PC relative relocs. */
|
||||||
|
#ifndef CALC_ADDEND
|
||||||
|
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||||
|
{ \
|
||||||
|
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||||
|
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||||
|
coffsym = (obj_symbols (abfd) \
|
||||||
|
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||||
|
else if (ptr) \
|
||||||
|
coffsym = coff_symbol_from (abfd, ptr); \
|
||||||
|
if (coffsym != (coff_symbol_type *) NULL \
|
||||||
|
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||||
|
&& ptr->section != (asection *) NULL) \
|
||||||
|
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||||
|
else \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
|
||||||
|
cache_ptr->addend += asect->vma; \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CALLS 0x66003800 /* Template for 'calls' instruction */
|
||||||
|
#define BAL 0x0b000000 /* Template for 'bal' instruction */
|
||||||
|
#define BAL_MASK 0x00ffffff
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
optcall_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
input_section, ignore_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
/* This item has already been relocated correctly, but we may be
|
||||||
|
* able to patch in yet better code - done by digging out the
|
||||||
|
* correct info on this symbol */
|
||||||
|
bfd_reloc_status_type result;
|
||||||
|
coff_symbol_type *cs = coffsymbol(symbol_in);
|
||||||
|
|
||||||
|
/* Don't do anything with symbols which aren't tied up yet,
|
||||||
|
except move the reloc. */
|
||||||
|
if (bfd_is_und_section (cs->symbol.section)) {
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* So the target symbol has to be of coff type, and the symbol
|
||||||
|
has to have the correct native information within it */
|
||||||
|
if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
|
||||||
|
|| (cs->native == (combined_entry_type *)NULL))
|
||||||
|
{
|
||||||
|
/* This is interesting, consider the case where we're outputting coff
|
||||||
|
from a mix n match input, linking from coff to a symbol defined in a
|
||||||
|
bout file will cause this match to be true. Should I complain? This
|
||||||
|
will only work if the bout symbol is non leaf. */
|
||||||
|
*error_message =
|
||||||
|
(char *) "uncertain calling convention for non-COFF symbol";
|
||||||
|
result = bfd_reloc_dangerous;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (cs->native->u.syment.n_sclass)
|
||||||
|
{
|
||||||
|
case C_LEAFSTAT:
|
||||||
|
case C_LEAFEXT:
|
||||||
|
/* This is a call to a leaf procedure, replace instruction with a bal
|
||||||
|
to the correct location. */
|
||||||
|
{
|
||||||
|
union internal_auxent *aux = &((cs->native+2)->u.auxent);
|
||||||
|
int word = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
||||||
|
int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
|
||||||
|
BFD_ASSERT(cs->native->u.syment.n_numaux==2);
|
||||||
|
|
||||||
|
/* We replace the original call instruction with a bal to
|
||||||
|
the bal entry point - the offset of which is described in
|
||||||
|
the 2nd auxent of the original symbol. We keep the native
|
||||||
|
sym and auxents untouched, so the delta between the two
|
||||||
|
is the offset of the bal entry point. */
|
||||||
|
word = ((word + olf) & BAL_MASK) | BAL;
|
||||||
|
bfd_put_32(abfd, word, (bfd_byte *) data + reloc_entry->address);
|
||||||
|
}
|
||||||
|
result = bfd_reloc_ok;
|
||||||
|
break;
|
||||||
|
case C_SCALL:
|
||||||
|
/* This is a call to a system call, replace with a calls to # */
|
||||||
|
BFD_ASSERT(0);
|
||||||
|
result = bfd_reloc_ok;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = bfd_reloc_ok;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||||
|
appear to correctly handle a reloc against a symbol defined in the
|
||||||
|
same object file. It appears to simply discard such relocs, rather
|
||||||
|
than adding their values into the object file. We handle this here
|
||||||
|
by converting all relocs against defined symbols into relocs
|
||||||
|
against the section symbol, when generating a relocateable output
|
||||||
|
file.
|
||||||
|
|
||||||
|
Note that this function is only called if we are not using the COFF
|
||||||
|
specific backend linker. It only does something when doing a
|
||||||
|
relocateable link, which will almost certainly fail when not
|
||||||
|
generating COFF i960 output, so this function is actually no longer
|
||||||
|
useful. It was used before this target was converted to use the
|
||||||
|
COFF specific backend linker. */
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
asection *osec;
|
||||||
|
|
||||||
|
if (output_bfd == NULL)
|
||||||
|
{
|
||||||
|
/* Not generating relocateable output file. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_is_und_section (bfd_get_section (symbol)))
|
||||||
|
{
|
||||||
|
/* Symbol is not defined, so no need to worry about it. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_is_com_section (bfd_get_section (symbol)))
|
||||||
|
{
|
||||||
|
/* I don't really know what the right action is for a common
|
||||||
|
symbol. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert the reloc to use the section symbol. FIXME: This method
|
||||||
|
is ridiculous. */
|
||||||
|
osec = bfd_get_section (symbol)->output_section;
|
||||||
|
if (coff_section_data (output_bfd, osec) != NULL
|
||||||
|
&& coff_section_data (output_bfd, osec)->tdata != NULL)
|
||||||
|
reloc_entry->sym_ptr_ptr =
|
||||||
|
(asymbol **) coff_section_data (output_bfd, osec)->tdata;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *sec_name;
|
||||||
|
asymbol **syms, **sym_end;
|
||||||
|
|
||||||
|
sec_name = bfd_get_section_name (output_bfd, osec);
|
||||||
|
syms = bfd_get_outsymbols (output_bfd);
|
||||||
|
sym_end = syms + bfd_get_symcount (output_bfd);
|
||||||
|
for (; syms < sym_end; syms++)
|
||||||
|
{
|
||||||
|
if (bfd_asymbol_name (*syms) != NULL
|
||||||
|
&& (*syms)->value == 0
|
||||||
|
&& strcmp ((*syms)->section->output_section->name,
|
||||||
|
sec_name) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syms >= sym_end)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
reloc_entry->sym_ptr_ptr = syms;
|
||||||
|
|
||||||
|
if (coff_section_data (output_bfd, osec) == NULL)
|
||||||
|
{
|
||||||
|
osec->used_by_bfd =
|
||||||
|
((PTR) bfd_zalloc (abfd,
|
||||||
|
sizeof (struct coff_section_tdata)));
|
||||||
|
if (osec->used_by_bfd == NULL)
|
||||||
|
return bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Let bfd_perform_relocation do its thing, which will include
|
||||||
|
stuffing the symbol addend into the object file. */
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
static reloc_howto_type howto_rellong =
|
||||||
|
HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,false, 0,
|
||||||
|
complain_overflow_bitfield, coff_i960_relocate,"rellong", true,
|
||||||
|
0xffffffff, 0xffffffff, 0);
|
||||||
|
static reloc_howto_type howto_iprmed =
|
||||||
|
HOWTO (R_IPRMED, 0, 2, 24,true,0, complain_overflow_signed,
|
||||||
|
coff_i960_relocate, "iprmed ", true, 0x00ffffff, 0x00ffffff, 0);
|
||||||
|
static reloc_howto_type howto_optcall =
|
||||||
|
HOWTO (R_OPTCALL, 0,2,24,true,0, complain_overflow_signed,
|
||||||
|
optcall_callback, "optcall", true, 0x00ffffff, 0x00ffffff, 0);
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_i960_reloc_type_lookup (abfd, code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
case BFD_RELOC_I960_CALLJ:
|
||||||
|
return &howto_optcall;
|
||||||
|
case BFD_RELOC_32:
|
||||||
|
case BFD_RELOC_CTOR:
|
||||||
|
return &howto_rellong;
|
||||||
|
case BFD_RELOC_24_PCREL:
|
||||||
|
return &howto_iprmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The real code is in coffcode.h */
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||||
|
{ \
|
||||||
|
reloc_howto_type *howto_ptr; \
|
||||||
|
switch ((dst)->r_type) { \
|
||||||
|
case 17: howto_ptr = &howto_rellong; break; \
|
||||||
|
case 25: howto_ptr = &howto_iprmed; break; \
|
||||||
|
case 27: howto_ptr = &howto_optcall; break; \
|
||||||
|
default: howto_ptr = 0; break; \
|
||||||
|
} \
|
||||||
|
(cache_ptr)->howto = howto_ptr; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||||
|
appear to correctly handle a reloc against a symbol defined in the
|
||||||
|
same object file. It appears to simply discard such relocs, rather
|
||||||
|
than adding their values into the object file. We handle this by
|
||||||
|
converting all relocs against global symbols into relocs against
|
||||||
|
internal symbols at the start of the section. This routine is
|
||||||
|
called at the start of the linking process, and it creates the
|
||||||
|
necessary symbols. */
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
coff_i960_start_final_link (abfd, info)
|
||||||
|
bfd *abfd;
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
{
|
||||||
|
bfd_size_type symesz = bfd_coff_symesz (abfd);
|
||||||
|
asection *o;
|
||||||
|
bfd_byte *esym;
|
||||||
|
|
||||||
|
if (! info->relocateable)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
esym = (bfd_byte *) bfd_malloc (symesz);
|
||||||
|
if (esym == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (o = abfd->sections; o != NULL; o = o->next)
|
||||||
|
{
|
||||||
|
struct internal_syment isym;
|
||||||
|
|
||||||
|
strncpy (isym._n._n_name, o->name, SYMNMLEN);
|
||||||
|
isym.n_value = 0;
|
||||||
|
isym.n_scnum = o->target_index;
|
||||||
|
isym.n_type = T_NULL;
|
||||||
|
isym.n_sclass = C_STAT;
|
||||||
|
isym.n_numaux = 0;
|
||||||
|
|
||||||
|
bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
|
||||||
|
|
||||||
|
if (bfd_write (esym, symesz, 1, abfd) != symesz)
|
||||||
|
{
|
||||||
|
free (esym);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj_raw_syment_count (abfd) += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
free (esym);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The reloc processing routine for the optimized COFF linker. */
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||||
|
contents, relocs, syms, sections)
|
||||||
|
bfd *output_bfd;
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
bfd *input_bfd;
|
||||||
|
asection *input_section;
|
||||||
|
bfd_byte *contents;
|
||||||
|
struct internal_reloc *relocs;
|
||||||
|
struct internal_syment *syms;
|
||||||
|
asection **sections;
|
||||||
|
{
|
||||||
|
struct internal_reloc *rel;
|
||||||
|
struct internal_reloc *relend;
|
||||||
|
|
||||||
|
rel = relocs;
|
||||||
|
relend = rel + input_section->reloc_count;
|
||||||
|
for (; rel < relend; rel++)
|
||||||
|
{
|
||||||
|
long symndx;
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
struct internal_syment *sym;
|
||||||
|
bfd_vma addend;
|
||||||
|
bfd_vma val;
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
bfd_reloc_status_type rstat = bfd_reloc_ok;
|
||||||
|
boolean done;
|
||||||
|
|
||||||
|
symndx = rel->r_symndx;
|
||||||
|
|
||||||
|
if (symndx == -1)
|
||||||
|
{
|
||||||
|
h = NULL;
|
||||||
|
sym = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||||
|
sym = syms + symndx;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sym != NULL && sym->n_scnum != 0)
|
||||||
|
addend = - sym->n_value;
|
||||||
|
else
|
||||||
|
addend = 0;
|
||||||
|
|
||||||
|
switch (rel->r_type)
|
||||||
|
{
|
||||||
|
case 17: howto = &howto_rellong; break;
|
||||||
|
case 25: howto = &howto_iprmed; break;
|
||||||
|
case 27: howto = &howto_optcall; break;
|
||||||
|
default:
|
||||||
|
bfd_set_error (bfd_error_bad_value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = 0;
|
||||||
|
|
||||||
|
if (h == NULL)
|
||||||
|
{
|
||||||
|
asection *sec;
|
||||||
|
|
||||||
|
if (symndx == -1)
|
||||||
|
{
|
||||||
|
sec = bfd_abs_section_ptr;
|
||||||
|
val = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sec = sections[symndx];
|
||||||
|
val = (sec->output_section->vma
|
||||||
|
+ sec->output_offset
|
||||||
|
+ sym->n_value
|
||||||
|
- sec->vma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (h->root.type == bfd_link_hash_defined
|
||||||
|
|| h->root.type == bfd_link_hash_defweak)
|
||||||
|
{
|
||||||
|
asection *sec;
|
||||||
|
|
||||||
|
sec = h->root.u.def.section;
|
||||||
|
val = (h->root.u.def.value
|
||||||
|
+ sec->output_section->vma
|
||||||
|
+ sec->output_offset);
|
||||||
|
}
|
||||||
|
else if (! info->relocateable)
|
||||||
|
{
|
||||||
|
if (! ((*info->callbacks->undefined_symbol)
|
||||||
|
(info, h->root.root.string, input_bfd, input_section,
|
||||||
|
rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done = false;
|
||||||
|
|
||||||
|
if (howto->type == R_OPTCALL && ! info->relocateable && symndx != -1)
|
||||||
|
{
|
||||||
|
int class;
|
||||||
|
|
||||||
|
if (h != NULL)
|
||||||
|
class = h->class;
|
||||||
|
else
|
||||||
|
class = sym->n_sclass;
|
||||||
|
|
||||||
|
switch (class)
|
||||||
|
{
|
||||||
|
case C_NULL:
|
||||||
|
/* This symbol is apparently not from a COFF input file.
|
||||||
|
We warn, and then assume that it is not a leaf
|
||||||
|
function. */
|
||||||
|
if (! ((*info->callbacks->reloc_dangerous)
|
||||||
|
(info,
|
||||||
|
"uncertain calling convention for non-COFF symbol",
|
||||||
|
input_bfd, input_section,
|
||||||
|
rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case C_LEAFSTAT:
|
||||||
|
case C_LEAFEXT:
|
||||||
|
/* This is a call to a leaf procedure; use the bal
|
||||||
|
instruction. */
|
||||||
|
{
|
||||||
|
long olf;
|
||||||
|
unsigned long word;
|
||||||
|
|
||||||
|
if (h != NULL)
|
||||||
|
{
|
||||||
|
BFD_ASSERT (h->numaux == 2);
|
||||||
|
olf = h->aux[1].x_bal.x_balntry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bfd_byte *esyms;
|
||||||
|
union internal_auxent aux;
|
||||||
|
|
||||||
|
BFD_ASSERT (sym->n_numaux == 2);
|
||||||
|
esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
||||||
|
esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
|
||||||
|
bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
|
||||||
|
sym->n_sclass, 1, sym->n_numaux,
|
||||||
|
(PTR) &aux);
|
||||||
|
olf = aux.x_bal.x_balntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
word = bfd_get_32 (input_bfd,
|
||||||
|
(contents
|
||||||
|
+ (rel->r_vaddr - input_section->vma)));
|
||||||
|
word = ((word + olf - val) & BAL_MASK) | BAL;
|
||||||
|
bfd_put_32 (input_bfd,
|
||||||
|
word,
|
||||||
|
(contents
|
||||||
|
+ (rel->r_vaddr - input_section->vma)));
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case C_SCALL:
|
||||||
|
BFD_ASSERT (0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! done)
|
||||||
|
{
|
||||||
|
if (howto->pc_relative)
|
||||||
|
addend += input_section->vma;
|
||||||
|
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||||
|
contents,
|
||||||
|
rel->r_vaddr - input_section->vma,
|
||||||
|
val, addend);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (rstat)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
case bfd_reloc_ok:
|
||||||
|
break;
|
||||||
|
case bfd_reloc_overflow:
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
char buf[SYMNMLEN + 1];
|
||||||
|
|
||||||
|
if (symndx == -1)
|
||||||
|
name = "*ABS*";
|
||||||
|
else if (h != NULL)
|
||||||
|
name = h->root.root.string;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||||
|
if (name == NULL)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! ((*info->callbacks->reloc_overflow)
|
||||||
|
(info, name, howto->name, (bfd_vma) 0, input_bfd,
|
||||||
|
input_section, rel->r_vaddr - input_section->vma)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adjust the symbol index of any reloc against a global symbol to
|
||||||
|
instead be a reloc against the internal symbol we created specially
|
||||||
|
for the section. */
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
static boolean
|
||||||
|
coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||||
|
bfd *obfd;
|
||||||
|
struct bfd_link_info *info;
|
||||||
|
bfd *ibfd;
|
||||||
|
asection *sec;
|
||||||
|
struct internal_reloc *irel;
|
||||||
|
boolean *adjustedp;
|
||||||
|
{
|
||||||
|
struct coff_link_hash_entry *h;
|
||||||
|
|
||||||
|
*adjustedp = false;
|
||||||
|
|
||||||
|
h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
|
||||||
|
if (h == NULL
|
||||||
|
|| (h->root.type != bfd_link_hash_defined
|
||||||
|
&& h->root.type != bfd_link_hash_defweak))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
|
||||||
|
*adjustedp = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_start_final_link coff_i960_start_final_link
|
||||||
|
|
||||||
|
#define coff_relocate_section coff_i960_relocate_section
|
||||||
|
|
||||||
|
#define coff_adjust_symndx coff_i960_adjust_symndx
|
||||||
|
|
||||||
|
#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target icoff_little_vec =
|
||||||
|
{
|
||||||
|
"coff-Intel-little", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||||
|
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||||
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const bfd_target icoff_big_vec =
|
||||||
|
{
|
||||||
|
"coff-Intel-big", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||||
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
203
contrib/gdb/bfd/coff-m68k.c
Normal file
203
contrib/gdb/bfd/coff-m68k.c
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/* BFD back-end for Motorola 68000 COFF binaries.
|
||||||
|
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/m68k.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#ifndef LYNX_SPECIAL_FN
|
||||||
|
#define LYNX_SPECIAL_FN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||||
|
|
||||||
|
#ifndef COFF_PAGE_SIZE
|
||||||
|
/* The page size is a guess based on ELF. */
|
||||||
|
#define COFF_PAGE_SIZE 0x2000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Clean up namespace. */
|
||||||
|
#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
|
||||||
|
#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
|
||||||
|
#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
|
||||||
|
#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
|
||||||
|
|
||||||
|
#ifdef ONLY_DECLARE_RELOCS
|
||||||
|
extern reloc_howto_type m68kcoff_howto_table[];
|
||||||
|
#else
|
||||||
|
reloc_howto_type m68kcoff_howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
};
|
||||||
|
#endif /* not ONLY_DECLARE_RELOCS */
|
||||||
|
|
||||||
|
#ifndef BADMAG
|
||||||
|
#define BADMAG(x) M68KBADMAG(x)
|
||||||
|
#endif
|
||||||
|
#define M68 1 /* Customize coffcode.h */
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
#ifdef ONLY_DECLARE_RELOCS
|
||||||
|
extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||||
|
extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||||
|
extern reloc_howto_type *m68k_reloc_type_lookup
|
||||||
|
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
m68k_rtype2howto(internal, relocentry)
|
||||||
|
arelent *internal;
|
||||||
|
int relocentry;
|
||||||
|
{
|
||||||
|
switch (relocentry)
|
||||||
|
{
|
||||||
|
case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
|
||||||
|
case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
|
||||||
|
case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
|
||||||
|
case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
|
||||||
|
case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
|
||||||
|
case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
|
||||||
|
case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
m68k_howto2rtype (internal)
|
||||||
|
reloc_howto_type *internal;
|
||||||
|
{
|
||||||
|
if (internal->pc_relative)
|
||||||
|
{
|
||||||
|
switch (internal->bitsize)
|
||||||
|
{
|
||||||
|
case 32: return R_PCRLONG;
|
||||||
|
case 16: return R_PCRWORD;
|
||||||
|
case 8: return R_PCRBYTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (internal->bitsize)
|
||||||
|
{
|
||||||
|
case 32: return R_RELLONG;
|
||||||
|
case 16: return R_RELWORD;
|
||||||
|
case 8: return R_RELBYTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R_RELLONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
reloc_howto_type *
|
||||||
|
m68k_reloc_type_lookup (abfd, code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
default: return NULL;
|
||||||
|
case BFD_RELOC_8: return m68kcoff_howto_table + 0;
|
||||||
|
case BFD_RELOC_16: return m68kcoff_howto_table + 1;
|
||||||
|
case BFD_RELOC_CTOR:
|
||||||
|
case BFD_RELOC_32: return m68kcoff_howto_table + 2;
|
||||||
|
case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
|
||||||
|
case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
|
||||||
|
case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
|
||||||
|
/* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
|
||||||
|
}
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* not ONLY_DECLARE_RELOCS */
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) \
|
||||||
|
m68k_rtype2howto(internal, (relocentry)->r_type)
|
||||||
|
|
||||||
|
#define SELECT_RELOC(external, internal) \
|
||||||
|
external.r_type = m68k_howto2rtype(internal);
|
||||||
|
|
||||||
|
#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
|
||||||
|
|
||||||
|
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_SYM
|
||||||
|
TARGET_SYM =
|
||||||
|
#else
|
||||||
|
m68kcoff_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_NAME
|
||||||
|
TARGET_NAME,
|
||||||
|
#else
|
||||||
|
"coff-m68k", /* name */
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
#ifdef NAMES_HAVE_UNDERSCORE
|
||||||
|
'_',
|
||||||
|
#else
|
||||||
|
0, /* leading underscore */
|
||||||
|
#endif
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE
|
||||||
|
};
|
311
contrib/gdb/bfd/coff-m88k.c
Normal file
311
contrib/gdb/bfd/coff-m88k.c
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define M88 1 /* Customize various include files */
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/m88k.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
static bfd_reloc_status_type m88k_special_reloc
|
||||||
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||||
|
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||||
|
static void reloc_processing
|
||||||
|
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
m88k_special_reloc (abfd, reloc_entry, symbol, data,
|
||||||
|
input_section, output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
|
||||||
|
switch (howto->type)
|
||||||
|
{
|
||||||
|
case R_HVRT16:
|
||||||
|
case R_LVRT16:
|
||||||
|
if (output_bfd != (bfd *) NULL)
|
||||||
|
{
|
||||||
|
/* This is a partial relocation, and we want to apply the
|
||||||
|
relocation to the reloc entry rather than the raw data.
|
||||||
|
Modify the reloc inplace to reflect what we now know. */
|
||||||
|
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bfd_vma output_base = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||||
|
asection *reloc_target_output_section;
|
||||||
|
long relocation = 0;
|
||||||
|
|
||||||
|
/* Work out which section the relocation is targetted at and the
|
||||||
|
initial relocation command value. */
|
||||||
|
|
||||||
|
/* Get symbol value. (Common symbols are special.) */
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
relocation = 0;
|
||||||
|
else
|
||||||
|
relocation = symbol->value;
|
||||||
|
|
||||||
|
reloc_target_output_section = symbol->section->output_section;
|
||||||
|
|
||||||
|
/* Convert input-section-relative symbol value to absolute. */
|
||||||
|
if (output_bfd)
|
||||||
|
output_base = 0;
|
||||||
|
else
|
||||||
|
output_base = reloc_target_output_section->vma;
|
||||||
|
|
||||||
|
relocation += output_base + symbol->section->output_offset;
|
||||||
|
|
||||||
|
/* Add in supplied addend. */
|
||||||
|
relocation += ((reloc_entry->addend << howto->bitsize) + x);
|
||||||
|
|
||||||
|
reloc_entry->addend = 0;
|
||||||
|
|
||||||
|
relocation >>= (bfd_vma) howto->rightshift;
|
||||||
|
|
||||||
|
/* Shift everything up to where it's going to be used */
|
||||||
|
|
||||||
|
relocation <<= (bfd_vma) howto->bitpos;
|
||||||
|
|
||||||
|
if (relocation)
|
||||||
|
bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (output_bfd != (bfd *) NULL)
|
||||||
|
{
|
||||||
|
/* This is a partial relocation, and we want to apply the
|
||||||
|
relocation to the reloc entry rather than the raw data.
|
||||||
|
Modify the reloc inplace to reflect what we now know. */
|
||||||
|
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output_bfd == (bfd *) NULL)
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO (R_PCR16L, /* type */
|
||||||
|
02, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
true, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_signed, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"PCR16L", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
|
||||||
|
HOWTO (R_PCR26L, /* type */
|
||||||
|
02, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
26, /* bitsize */
|
||||||
|
true, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_signed, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"PCR26L", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0x03ffffff, /* src_mask */
|
||||||
|
0x03ffffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
|
||||||
|
HOWTO (R_VRT16, /* type */
|
||||||
|
00, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"VRT16", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
|
||||||
|
HOWTO (R_HVRT16, /* type */
|
||||||
|
16, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_dont, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"HVRT16", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
|
||||||
|
HOWTO (R_LVRT16, /* type */
|
||||||
|
00, /* rightshift */
|
||||||
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
16, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_dont, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"LVRT16", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0x0000ffff, /* src_mask */
|
||||||
|
0x0000ffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
|
||||||
|
HOWTO (R_VRT32, /* type */
|
||||||
|
00, /* rightshift */
|
||||||
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||||
|
32, /* bitsize */
|
||||||
|
false, /* pc_relative */
|
||||||
|
0, /* bitpos */
|
||||||
|
complain_overflow_bitfield, /* complain_on_overflow */
|
||||||
|
m88k_special_reloc, /* special_function */
|
||||||
|
"VRT32", /* name */
|
||||||
|
false, /* partial_inplace */
|
||||||
|
0xffffffff, /* src_mask */
|
||||||
|
0xffffffff, /* dst_mask */
|
||||||
|
true), /* pcrel_offset */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Code to turn an external r_type into a pointer to an entry in the
|
||||||
|
above howto table. */
|
||||||
|
static void
|
||||||
|
rtype2howto (cache_ptr, dst)
|
||||||
|
arelent *cache_ptr;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
|
||||||
|
{
|
||||||
|
cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BFD_ASSERT (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||||
|
|
||||||
|
|
||||||
|
/* Code to swap in the reloc offset */
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
|
||||||
|
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void
|
||||||
|
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||||
|
arelent *relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol **symbols;
|
||||||
|
bfd *abfd;
|
||||||
|
asection *section;
|
||||||
|
{
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
rtype2howto (relent, reloc);
|
||||||
|
|
||||||
|
if (((int) reloc->r_symndx) > 0)
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
relent->addend = reloc->r_offset;
|
||||||
|
relent->address -= section->vma;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BADMAG(x) MC88BADMAG(x)
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
#undef coff_write_armap
|
||||||
|
|
||||||
|
const bfd_target m88kbcs_vec =
|
||||||
|
{
|
||||||
|
"coff-m88kbcs", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
2596
contrib/gdb/bfd/coff-mips.c
Normal file
2596
contrib/gdb/bfd/coff-mips.c
Normal file
File diff suppressed because it is too large
Load Diff
27
contrib/gdb/bfd/coff-pmac.c
Normal file
27
contrib/gdb/bfd/coff-pmac.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
|
||||||
|
Copyright 1995 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGET_SYM pmac_xcoff_vec
|
||||||
|
#define TARGET_NAME "xcoff-powermac"
|
||||||
|
|
||||||
|
/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
|
||||||
|
|
||||||
|
#define POWERMAC
|
||||||
|
|
||||||
|
#include "coff-rs6000.c"
|
3255
contrib/gdb/bfd/coff-ppc.c
Normal file
3255
contrib/gdb/bfd/coff-ppc.c
Normal file
File diff suppressed because it is too large
Load Diff
1403
contrib/gdb/bfd/coff-rs6000.c
Normal file
1403
contrib/gdb/bfd/coff-rs6000.c
Normal file
File diff suppressed because it is too large
Load Diff
1525
contrib/gdb/bfd/coff-sh.c
Normal file
1525
contrib/gdb/bfd/coff-sh.c
Normal file
File diff suppressed because it is too large
Load Diff
278
contrib/gdb/bfd/coff-sparc.c
Normal file
278
contrib/gdb/bfd/coff-sparc.c
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
/* BFD back-end for Sparc COFF files.
|
||||||
|
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/sparc.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||||
|
|
||||||
|
#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
|
||||||
|
|
||||||
|
/* The page size is a guess based on ELF. */
|
||||||
|
#define COFF_PAGE_SIZE 0x10000
|
||||||
|
|
||||||
|
enum reloc_type
|
||||||
|
{
|
||||||
|
R_SPARC_NONE = 0,
|
||||||
|
R_SPARC_8, R_SPARC_16, R_SPARC_32,
|
||||||
|
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
|
||||||
|
R_SPARC_WDISP30, R_SPARC_WDISP22,
|
||||||
|
R_SPARC_HI22, R_SPARC_22,
|
||||||
|
R_SPARC_13, R_SPARC_LO10,
|
||||||
|
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
|
||||||
|
R_SPARC_PC10, R_SPARC_PC22,
|
||||||
|
R_SPARC_WPLT30,
|
||||||
|
R_SPARC_COPY,
|
||||||
|
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
|
||||||
|
R_SPARC_RELATIVE,
|
||||||
|
R_SPARC_UA32,
|
||||||
|
R_SPARC_max
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static CONST char *CONST reloc_type_names[] =
|
||||||
|
{
|
||||||
|
"R_SPARC_NONE",
|
||||||
|
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
|
||||||
|
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
|
||||||
|
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
|
||||||
|
"R_SPARC_HI22", "R_SPARC_22",
|
||||||
|
"R_SPARC_13", "R_SPARC_LO10",
|
||||||
|
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
|
||||||
|
"R_SPARC_PC10", "R_SPARC_PC22",
|
||||||
|
"R_SPARC_WPLT30",
|
||||||
|
"R_SPARC_COPY",
|
||||||
|
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
|
||||||
|
"R_SPARC_RELATIVE",
|
||||||
|
"R_SPARC_UA32",
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is stolen pretty directly from elf.c. */
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||||
|
asection *, bfd *, char **));
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||||
|
output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
asymbol *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
if (output_bfd != (bfd *) NULL
|
||||||
|
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
||||||
|
&& reloc_entry->addend == 0)
|
||||||
|
{
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bfd_reloc_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
static reloc_howto_type coff_sparc_howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
|
||||||
|
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
|
||||||
|
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
|
||||||
|
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
|
||||||
|
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
|
||||||
|
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
|
||||||
|
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
|
||||||
|
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
|
||||||
|
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
|
||||||
|
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
|
||||||
|
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
|
||||||
|
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
|
||||||
|
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
|
||||||
|
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
|
||||||
|
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
|
||||||
|
HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
|
||||||
|
HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
|
||||||
|
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
|
||||||
|
HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
|
||||||
|
};
|
||||||
|
|
||||||
|
struct coff_reloc_map {
|
||||||
|
unsigned char bfd_reloc_val;
|
||||||
|
unsigned char coff_reloc_val;
|
||||||
|
};
|
||||||
|
|
||||||
|
static CONST struct coff_reloc_map sparc_reloc_map[] =
|
||||||
|
{
|
||||||
|
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
||||||
|
{ BFD_RELOC_16, R_SPARC_16, },
|
||||||
|
{ BFD_RELOC_8, R_SPARC_8 },
|
||||||
|
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
||||||
|
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
||||||
|
{ BFD_RELOC_32, R_SPARC_32 },
|
||||||
|
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
||||||
|
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
||||||
|
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
||||||
|
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
||||||
|
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
||||||
|
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
||||||
|
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
||||||
|
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
||||||
|
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
||||||
|
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
||||||
|
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
||||||
|
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
||||||
|
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
||||||
|
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
||||||
|
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
||||||
|
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
||||||
|
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
||||||
|
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
||||||
|
};
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
coff_sparc_reloc_type_lookup (abfd, code)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
|
||||||
|
{
|
||||||
|
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
||||||
|
return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtype2howto (cache_ptr, dst)
|
||||||
|
arelent *cache_ptr;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
|
||||||
|
cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||||
|
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||||
|
/* This is just like the standard one, except that we don't set up an
|
||||||
|
addend for relocs against global symbols (otherwise linking objects
|
||||||
|
created by -r fails), and we add in the reloc offset at the end. */
|
||||||
|
#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 \
|
||||||
|
&& (ptr->flags & BSF_GLOBAL) == 0) \
|
||||||
|
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||||
|
else \
|
||||||
|
cache_ptr->addend = 0; \
|
||||||
|
cache_ptr->addend += reloc.r_offset; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the r_spare field in relocs. */
|
||||||
|
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||||
|
do { \
|
||||||
|
dst->r_spare[0] = 0; \
|
||||||
|
dst->r_spare[1] = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define __A_MAGIC_SET__
|
||||||
|
|
||||||
|
/* Enable Sparc-specific hacks in coffcode.h. */
|
||||||
|
|
||||||
|
#define COFF_SPARC
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
const bfd_target
|
||||||
|
#ifdef TARGET_SYM
|
||||||
|
TARGET_SYM =
|
||||||
|
#else
|
||||||
|
sparccoff_vec =
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef TARGET_NAME
|
||||||
|
TARGET_NAME,
|
||||||
|
#else
|
||||||
|
"coff-sparc", /* name */
|
||||||
|
#endif
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
/* Note that we allow an object file to be treated as a core file as well. */
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, coff_object_p},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
35
contrib/gdb/bfd/coff-u68k.c
Normal file
35
contrib/gdb/bfd/coff-u68k.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
|
||||||
|
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define TARGET_SYM m68kcoffun_vec
|
||||||
|
#define TARGET_NAME "coff-m68k-un"
|
||||||
|
|
||||||
|
#define NAMES_HAVE_UNDERSCORE
|
||||||
|
|
||||||
|
/* define this to not have multiple copy of m68k_rtype2howto
|
||||||
|
in the executable file */
|
||||||
|
#define ONLY_DECLARE_RELOCS
|
||||||
|
|
||||||
|
/* This magic number indicates that the names have underscores.
|
||||||
|
Other 68k magic numbers indicate that the names do not have
|
||||||
|
underscores. */
|
||||||
|
#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
|
||||||
|
|
||||||
|
#include "coff-m68k.c"
|
446
contrib/gdb/bfd/coff-w65.c
Normal file
446
contrib/gdb/bfd/coff-w65.c
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
/* BFD back-end for WDC 65816 COFF binaries.
|
||||||
|
Copyright 1995 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 "obstack.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "bfdlink.h"
|
||||||
|
#include "coff/w65.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
HOWTO (R_W65_ABS8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "abs8", true, 0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO (R_W65_ABS16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_W65_ABS24, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs24", true, 0x00ffffff, 0x00ffffff, false),
|
||||||
|
HOWTO (R_W65_ABS8S8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, ">abs8", true, 0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO (R_W65_ABS8S16, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "^abs8", true, 0x000000ff, 0x000000ff, false),
|
||||||
|
HOWTO (R_W65_ABS16S8, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, ">abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_W65_ABS16S16,1, 0, 16, false, 0, complain_overflow_bitfield, 0, "^abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||||
|
HOWTO (R_W65_PCR8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrel8", true, 0x000000ff, 0x000000ff, true),
|
||||||
|
HOWTO (R_W65_PCR16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, true),
|
||||||
|
HOWTO (R_W65_DP, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "dp", true, 0x000000ff, 0x000000ff, false),
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) \
|
||||||
|
{ x.r_type = select_reloc(howto); }
|
||||||
|
|
||||||
|
#define BADMAG(x) (W65BADMAG(x))
|
||||||
|
#define W65 1 /* Customize coffcode.h */
|
||||||
|
#define __A_MAGIC_SET__
|
||||||
|
|
||||||
|
|
||||||
|
/* Code to swap in the reloc */
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||||
|
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||||
|
dst->r_stuff[0] = 'S'; \
|
||||||
|
dst->r_stuff[1] = 'C';
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
select_reloc (howto)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
{
|
||||||
|
return howto->type ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtype2howto (internal, dst)
|
||||||
|
arelent *internal;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
internal->howto = howto_table + dst->r_type - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||||
|
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||||
|
cache_ptr->addend = ext_reloc.r_offset;
|
||||||
|
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void
|
||||||
|
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||||
|
arelent * relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol ** symbols;
|
||||||
|
bfd * abfd;
|
||||||
|
asection * section;
|
||||||
|
{
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
rtype2howto (relent, reloc);
|
||||||
|
|
||||||
|
if (((int) reloc->r_symndx) > 0)
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
relent->addend = reloc->r_offset;
|
||||||
|
|
||||||
|
relent->address -= section->vma;
|
||||||
|
/* relent->section = 0;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||||
|
bfd *abfd;
|
||||||
|
asection *input_section;
|
||||||
|
arelent *reloc;
|
||||||
|
unsigned int shrink;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
{
|
||||||
|
bfd_vma value;
|
||||||
|
bfd_vma dot;
|
||||||
|
bfd_vma gap;
|
||||||
|
|
||||||
|
/* The address of the thing to be relocated will have moved back by
|
||||||
|
the size of the shrink - but we don't change reloc->address here,
|
||||||
|
since we need it to know where the relocation lives in the source
|
||||||
|
uncooked section */
|
||||||
|
|
||||||
|
/* reloc->address -= shrink; conceptual */
|
||||||
|
|
||||||
|
bfd_vma address = reloc->address - shrink;
|
||||||
|
|
||||||
|
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
case R_MOVB2:
|
||||||
|
case R_JMP2:
|
||||||
|
shrink+=2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Thing is a move one byte */
|
||||||
|
case R_MOVB1:
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
if (value >= 0xff00)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||||
|
possible 16 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* The place to relc moves back by one */
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
/* This is the 24 bit branch which could become an 8 bitter,
|
||||||
|
the relocation points to the first byte of the insn, not the
|
||||||
|
actual data */
|
||||||
|
|
||||||
|
case R_JMPL1:
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
dot = input_section->output_section->vma +
|
||||||
|
input_section->output_offset + address;
|
||||||
|
|
||||||
|
/* See if the address we're looking at within 127 bytes of where
|
||||||
|
we are, if so then we can use a small branch rather than the
|
||||||
|
jump we were going to */
|
||||||
|
|
||||||
|
gap = value - dot ;
|
||||||
|
|
||||||
|
if (-120 < (long)gap && (long)gap < 120 )
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||||
|
possible 32 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_JMP1:
|
||||||
|
|
||||||
|
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||||
|
|
||||||
|
dot = input_section->output_section->vma +
|
||||||
|
input_section->output_offset + address;
|
||||||
|
|
||||||
|
/* See if the address we're looking at within 127 bytes of where
|
||||||
|
we are, if so then we can use a small branch rather than the
|
||||||
|
jump we were going to */
|
||||||
|
|
||||||
|
gap = value - (dot - shrink);
|
||||||
|
|
||||||
|
|
||||||
|
if (-120 < (long)gap && (long)gap < 120 )
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||||
|
possible 16 */
|
||||||
|
reloc->howto = reloc->howto + 1;
|
||||||
|
/* The place to relc moves back by one */
|
||||||
|
|
||||||
|
/* This will be two bytes smaller in the long run */
|
||||||
|
shrink +=2 ;
|
||||||
|
bfd_perform_slip(abfd, 2, input_section, address);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return shrink;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* First phase of a relaxing link */
|
||||||
|
|
||||||
|
/* Reloc types
|
||||||
|
large small
|
||||||
|
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||||
|
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||||
|
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||||
|
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||||
|
dst_ptr)
|
||||||
|
bfd *abfd;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
struct bfd_link_order *link_order;
|
||||||
|
arelent *reloc;
|
||||||
|
bfd_byte *data;
|
||||||
|
unsigned int *src_ptr;
|
||||||
|
unsigned int *dst_ptr;
|
||||||
|
{
|
||||||
|
unsigned int src_address = *src_ptr;
|
||||||
|
unsigned int dst_address = *dst_ptr;
|
||||||
|
asection *input_section = link_order->u.indirect.section;
|
||||||
|
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
case R_W65_ABS8:
|
||||||
|
case R_W65_DP:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_ABS8S8:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
gap >>= 8;
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_ABS8S16:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
gap >>=16;
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_ABS16:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R_W65_ABS16S8:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
gap >>= 8;
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R_W65_ABS16S16:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
gap >>= 16;
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_ABS24:
|
||||||
|
{
|
||||||
|
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
bfd_put_8 (abfd, gap>>16, data+dst_address+2);
|
||||||
|
dst_address += 3;
|
||||||
|
src_address += 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_PCR8:
|
||||||
|
{
|
||||||
|
int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
|
||||||
|
gap -= dot + 1;
|
||||||
|
if (gap < -128 || gap > 127) {
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
bfd_put_8 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 1;
|
||||||
|
src_address += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_W65_PCR16:
|
||||||
|
{
|
||||||
|
bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_vma dot = link_order->offset
|
||||||
|
+ dst_address
|
||||||
|
+ link_order->u.indirect.section->output_section->vma;
|
||||||
|
|
||||||
|
|
||||||
|
/* This wraps within the page, so ignore the relativeness, look at the
|
||||||
|
high part */
|
||||||
|
if ((gap & 0xf0000) != (dot & 0xf0000)) {
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
gap -= dot + 2;
|
||||||
|
bfd_put_16 (abfd, gap, data + dst_address);
|
||||||
|
dst_address += 2;
|
||||||
|
src_address += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("ignoring reloc %s\n", reloc->howto->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
*src_ptr = src_address;
|
||||||
|
*dst_ptr = dst_address;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||||
|
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef coff_bfd_get_relocated_section_contents
|
||||||
|
#undef coff_bfd_relax_section
|
||||||
|
#define coff_bfd_get_relocated_section_contents \
|
||||||
|
bfd_coff_reloc16_get_relocated_section_contents
|
||||||
|
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bfd_target w65_vec =
|
||||||
|
{
|
||||||
|
"coff-w65", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||||
|
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading char */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||||
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||||
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||||
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
110
contrib/gdb/bfd/coff-we32k.c
Normal file
110
contrib/gdb/bfd/coff-we32k.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* BFD back-end for we32k COFF files.
|
||||||
|
Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "coff/we32k.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||||
|
|
||||||
|
static reloc_howto_type howto_table[] =
|
||||||
|
{
|
||||||
|
{0},
|
||||||
|
{1},
|
||||||
|
{2},
|
||||||
|
{3},
|
||||||
|
{4},
|
||||||
|
{5},
|
||||||
|
HOWTO(R_DIR32, 0, 2, 32, false, 0,complain_overflow_bitfield, 0, "dir32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
{7},
|
||||||
|
{010},
|
||||||
|
{011},
|
||||||
|
{012},
|
||||||
|
{013},
|
||||||
|
{014},
|
||||||
|
{015},
|
||||||
|
{016},
|
||||||
|
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||||
|
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||||
|
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc nunmber */
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||||
|
#define BADMAG(x) WE32KBADMAG(x)
|
||||||
|
#define WE32K 1
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||||
|
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
#define coff_write_armap bsd_write_armap
|
||||||
|
|
||||||
|
const bfd_target we32kcoff_vec =
|
||||||
|
{
|
||||||
|
"coff-we32k", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
0, /* leading underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
281
contrib/gdb/bfd/coff-z8k.c
Normal file
281
contrib/gdb/bfd/coff-z8k.c
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
/* BFD back-end for Zilog Z800n COFF binaries.
|
||||||
|
Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
Contributed by Cygnus Support.
|
||||||
|
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
#include "bfdlink.h"
|
||||||
|
#include "coff/z8k.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm32 =
|
||||||
|
HOWTO (R_IMM32, 0, 1, 32, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
|
||||||
|
0xffffffff, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm4l =
|
||||||
|
HOWTO (R_IMM4L, 0, 1, 4, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_da =
|
||||||
|
HOWTO (R_IMM16, 0, 1, 16, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,
|
||||||
|
false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_imm8 =
|
||||||
|
HOWTO (R_IMM8, 0, 1, 8, false, 0,
|
||||||
|
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
|
||||||
|
false);
|
||||||
|
|
||||||
|
static reloc_howto_type r_jr =
|
||||||
|
HOWTO (R_JR, 0, 1, 8, true, 0, complain_overflow_signed, 0,
|
||||||
|
"r_jr", true, 0, 0, true);
|
||||||
|
|
||||||
|
/* Turn a howto into a reloc number */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_z8k_select_reloc (howto)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
{
|
||||||
|
return howto->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SELECT_RELOC(x,howto) x.r_type = coff_z8k_select_reloc(howto)
|
||||||
|
|
||||||
|
|
||||||
|
#define BADMAG(x) Z8KBADMAG(x)
|
||||||
|
#define Z8K 1 /* Customize coffcode.h */
|
||||||
|
#define __A_MAGIC_SET__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Code to swap in the reloc */
|
||||||
|
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||||
|
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||||
|
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||||
|
dst->r_stuff[0] = 'S'; \
|
||||||
|
dst->r_stuff[1] = 'C';
|
||||||
|
|
||||||
|
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtype2howto (internal, dst)
|
||||||
|
arelent * internal;
|
||||||
|
struct internal_reloc *dst;
|
||||||
|
{
|
||||||
|
switch (dst->r_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
case R_IMM8:
|
||||||
|
internal->howto = &r_imm8;
|
||||||
|
break;
|
||||||
|
case R_IMM16:
|
||||||
|
internal->howto = &r_da;
|
||||||
|
break;
|
||||||
|
case R_JR:
|
||||||
|
internal->howto = &r_jr;
|
||||||
|
break;
|
||||||
|
case R_IMM32:
|
||||||
|
internal->howto = &r_imm32;
|
||||||
|
break;
|
||||||
|
case R_IMM4L:
|
||||||
|
internal->howto = &r_imm4l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||||
|
|
||||||
|
|
||||||
|
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||||
|
cache_ptr->addend = ext_reloc.r_offset;
|
||||||
|
|
||||||
|
|
||||||
|
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||||
|
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||||
|
|
||||||
|
static void
|
||||||
|
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||||
|
arelent * relent;
|
||||||
|
struct internal_reloc *reloc;
|
||||||
|
asymbol ** symbols;
|
||||||
|
bfd * abfd;
|
||||||
|
asection * section;
|
||||||
|
{
|
||||||
|
relent->address = reloc->r_vaddr;
|
||||||
|
rtype2howto (relent, reloc);
|
||||||
|
|
||||||
|
if (reloc->r_symndx > 0)
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
relent->addend = reloc->r_offset;
|
||||||
|
relent->address -= section->vma;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||||
|
bfd *in_abfd;
|
||||||
|
struct bfd_link_info *link_info;
|
||||||
|
struct bfd_link_order *link_order;
|
||||||
|
arelent *reloc;
|
||||||
|
bfd_byte *data;
|
||||||
|
unsigned int *src_ptr;
|
||||||
|
unsigned int *dst_ptr;
|
||||||
|
{
|
||||||
|
asection *input_section = link_order->u.indirect.section;
|
||||||
|
|
||||||
|
switch (reloc->howto->type)
|
||||||
|
{
|
||||||
|
case R_IMM8:
|
||||||
|
bfd_put_8 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + *dst_ptr);
|
||||||
|
(*dst_ptr) += 1;
|
||||||
|
(*src_ptr) += 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_IMM32:
|
||||||
|
bfd_put_32 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + *dst_ptr);
|
||||||
|
(*dst_ptr) += 4;
|
||||||
|
(*src_ptr) += 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_IMM4L:
|
||||||
|
bfd_put_8 (in_abfd,
|
||||||
|
((bfd_get_8 (in_abfd, data + *dst_ptr) & 0xf0)
|
||||||
|
| (0x0f
|
||||||
|
& bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section))),
|
||||||
|
data + *dst_ptr);
|
||||||
|
(*dst_ptr) += 1;
|
||||||
|
(*src_ptr) += 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_IMM16:
|
||||||
|
bfd_put_16 (in_abfd,
|
||||||
|
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||||
|
data + *dst_ptr);
|
||||||
|
(*dst_ptr) += 2;
|
||||||
|
(*src_ptr) += 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_JR:
|
||||||
|
{
|
||||||
|
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||||
|
input_section);
|
||||||
|
bfd_vma dot = (link_order->offset
|
||||||
|
+ *dst_ptr
|
||||||
|
+ input_section->output_section->vma);
|
||||||
|
int gap = dst - dot - 1;/* -1 since were in the odd byte of the
|
||||||
|
word and the pc's been incremented */
|
||||||
|
|
||||||
|
if (gap & 1)
|
||||||
|
abort ();
|
||||||
|
gap /= 2;
|
||||||
|
if (gap > 128 || gap < -128)
|
||||||
|
{
|
||||||
|
if (! ((*link_info->callbacks->reloc_overflow)
|
||||||
|
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||||
|
reloc->howto->name, reloc->addend, input_section->owner,
|
||||||
|
input_section, reloc->address)))
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||||
|
(*dst_ptr)++;
|
||||||
|
(*src_ptr)++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define coff_reloc16_extra_cases extra_case
|
||||||
|
|
||||||
|
#include "coffcode.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef coff_bfd_get_relocated_section_contents
|
||||||
|
#undef coff_bfd_relax_section
|
||||||
|
#define coff_bfd_get_relocated_section_contents \
|
||||||
|
bfd_coff_reloc16_get_relocated_section_contents
|
||||||
|
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||||
|
|
||||||
|
const bfd_target z8kcoff_vec =
|
||||||
|
{
|
||||||
|
"coff-z8k", /* name */
|
||||||
|
bfd_target_coff_flavour,
|
||||||
|
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||||
|
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||||
|
|
||||||
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
|
HAS_LINENO | HAS_DEBUG |
|
||||||
|
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||||
|
|
||||||
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
|
'_', /* leading symbol underscore */
|
||||||
|
'/', /* ar_pad_char */
|
||||||
|
15, /* ar_max_namelen */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||||
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||||
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||||
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||||
|
|
||||||
|
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||||
|
bfd_generic_archive_p, _bfd_dummy_target},
|
||||||
|
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||||
|
bfd_false},
|
||||||
|
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||||
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
|
BFD_JUMP_TABLE_GENERIC (coff),
|
||||||
|
BFD_JUMP_TABLE_COPY (coff),
|
||||||
|
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||||
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||||
|
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||||
|
BFD_JUMP_TABLE_RELOCS (coff),
|
||||||
|
BFD_JUMP_TABLE_WRITE (coff),
|
||||||
|
BFD_JUMP_TABLE_LINK (coff),
|
||||||
|
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||||
|
|
||||||
|
COFF_SWAP_TABLE,
|
||||||
|
};
|
3612
contrib/gdb/bfd/coffcode.h
Normal file
3612
contrib/gdb/bfd/coffcode.h
Normal file
File diff suppressed because it is too large
Load Diff
2121
contrib/gdb/bfd/coffgen.c
Normal file
2121
contrib/gdb/bfd/coffgen.c
Normal file
File diff suppressed because it is too large
Load Diff
2327
contrib/gdb/bfd/cofflink.c
Normal file
2327
contrib/gdb/bfd/cofflink.c
Normal file
File diff suppressed because it is too large
Load Diff
807
contrib/gdb/bfd/coffswap.h
Normal file
807
contrib/gdb/bfd/coffswap.h
Normal file
@ -0,0 +1,807 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
491
contrib/gdb/bfd/config.bfd
Normal file
491
contrib/gdb/bfd/config.bfd
Normal file
@ -0,0 +1,491 @@
|
|||||||
|
# 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
|
67
contrib/gdb/bfd/config.in
Normal file
67
contrib/gdb/bfd/config.in
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* 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
|
2439
contrib/gdb/bfd/configure
vendored
Normal file
2439
contrib/gdb/bfd/configure
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
contrib/gdb/bfd/configure.bat
Normal file
18
contrib/gdb/bfd/configure.bat
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@echo off
|
||||||
|
if "%1" == "h8/300" goto h8300
|
||||||
|
|
||||||
|
echo Configuring bfd for go32
|
||||||
|
update hosts\go32.h sysdep.h
|
||||||
|
update Makefile.dos Makefile
|
||||||
|
echo s/@WORDSIZE@/32/g>config.sed
|
||||||
|
sed -e s/^/s\/@VERSION@\// -e s/$/\/g/g version >>config.sed
|
||||||
|
sed -f config.sed < bfd-in2.h > bfd.h2
|
||||||
|
update bfd.h2 bfd.h
|
||||||
|
goto exit
|
||||||
|
|
||||||
|
:h8300
|
||||||
|
echo Configuring bfd for H8/300
|
||||||
|
update hosts\h-go32.h sysdep.h
|
||||||
|
update Makefile.dos Makefile
|
||||||
|
|
||||||
|
:exit
|
128
contrib/gdb/bfd/configure.host
Normal file
128
contrib/gdb/bfd/configure.host
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
# 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
|
577
contrib/gdb/bfd/configure.in
Normal file
577
contrib/gdb/bfd/configure.in
Normal file
@ -0,0 +1,577 @@
|
|||||||
|
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])
|
106
contrib/gdb/bfd/corefile.c
Normal file
106
contrib/gdb/bfd/corefile.c
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/* Core file generic interface routines for BFD.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
SECTION
|
||||||
|
Core files
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
These are functions pertaining to core files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
bfd_core_file_failing_command
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
CONST char *bfd_core_file_failing_command(bfd *abfd);
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Return a read-only string explaining which program was running
|
||||||
|
when it failed and produced the core file @var{abfd}.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
CONST char *
|
||||||
|
bfd_core_file_failing_command (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
if (abfd->format != bfd_core) {
|
||||||
|
bfd_set_error (bfd_error_invalid_operation);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return BFD_SEND (abfd, _core_file_failing_command, (abfd));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
bfd_core_file_failing_signal
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
int bfd_core_file_failing_signal(bfd *abfd);
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Returns the signal number which caused the core dump which
|
||||||
|
generated the file the BFD @var{abfd} is attached to.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
bfd_core_file_failing_signal (abfd)
|
||||||
|
bfd *abfd;
|
||||||
|
{
|
||||||
|
if (abfd->format != bfd_core) {
|
||||||
|
bfd_set_error (bfd_error_invalid_operation);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
core_file_matches_executable_p
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
boolean core_file_matches_executable_p
|
||||||
|
(bfd *core_bfd, bfd *exec_bfd);
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Return <<true>> if the core file attached to @var{core_bfd}
|
||||||
|
was generated by a run of the executable file attached to
|
||||||
|
@var{exec_bfd}, <<false>> otherwise.
|
||||||
|
*/
|
||||||
|
boolean
|
||||||
|
core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||||
|
bfd *core_bfd, *exec_bfd;
|
||||||
|
{
|
||||||
|
if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
|
||||||
|
bfd_set_error (bfd_error_wrong_format);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BFD_SEND (core_bfd, _core_file_matches_executable_p,
|
||||||
|
(core_bfd, exec_bfd));
|
||||||
|
}
|
39
contrib/gdb/bfd/cpu-a29k.c
Normal file
39
contrib/gdb/bfd/cpu-a29k.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* BFD support for the AMD 29000 architecture.
|
||||||
|
Copyright 1992 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_a29k_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_a29k,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"a29k",
|
||||||
|
"a29k",
|
||||||
|
4,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
38
contrib/gdb/bfd/cpu-alpha.c
Normal file
38
contrib/gdb/bfd/cpu-alpha.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* BFD support for the Alpha architecture.
|
||||||
|
Copyright 1992 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_alpha_arch =
|
||||||
|
{
|
||||||
|
64, /* 32 bits in a word */
|
||||||
|
64, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_alpha,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"alpha",
|
||||||
|
"alpha",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
39
contrib/gdb/bfd/cpu-arm.c
Normal file
39
contrib/gdb/bfd/cpu-arm.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* BFD support for the ARM processor
|
||||||
|
Copyright 1994 Free Software Foundation, Inc.
|
||||||
|
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_arm_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_arm,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"arm",
|
||||||
|
"arm",
|
||||||
|
4,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
246
contrib/gdb/bfd/cpu-h8300.c
Normal file
246
contrib/gdb/bfd/cpu-h8300.c
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/* BFD library support routines for the Hitachi H8/300 architecture.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
#if 0 /* not used currently */
|
||||||
|
/*
|
||||||
|
Relocations for the H8
|
||||||
|
|
||||||
|
*/
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd * abfd;
|
||||||
|
arelent * reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection * ignore_input_section;
|
||||||
|
bfd * ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd * abfd;
|
||||||
|
arelent * reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection * ignore_input_section;
|
||||||
|
bfd * ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd * abfd;
|
||||||
|
arelent * reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection * ignore_input_section;
|
||||||
|
bfd * ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
abort ();
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd * abfd;
|
||||||
|
arelent * reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection * ignore_input_section;
|
||||||
|
bfd * ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
abort ();
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static reloc_howto_type howto_16
|
||||||
|
= NEWHOWTO (howto16_callback, "abs16", 1, false, false);
|
||||||
|
static reloc_howto_type howto_8
|
||||||
|
= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_FFnn
|
||||||
|
= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_pcrel
|
||||||
|
= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
local_bfd_reloc_type_lookup (arch, code)
|
||||||
|
const struct bfd_arch_info *arch;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case BFD_RELOC_16:
|
||||||
|
return &howto_16;
|
||||||
|
case BFD_RELOC_8_FFnn:
|
||||||
|
return &howto_8_FFnn;
|
||||||
|
case BFD_RELOC_8:
|
||||||
|
return &howto_8;
|
||||||
|
case BFD_RELOC_8_PCREL:
|
||||||
|
return &howto_8_pcrel;
|
||||||
|
default:
|
||||||
|
return (reloc_howto_type *) NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach ();
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
h8300_scan (info, string)
|
||||||
|
const struct bfd_arch_info *info;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
if (*string != 'h' && *string != 'H')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string++;
|
||||||
|
if (*string != '8')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string++;
|
||||||
|
if (*string == '/')
|
||||||
|
string++;
|
||||||
|
|
||||||
|
if (*string != '3')
|
||||||
|
return false;
|
||||||
|
string++;
|
||||||
|
if (*string != '0')
|
||||||
|
return false;
|
||||||
|
string++;
|
||||||
|
if (*string != '0')
|
||||||
|
return false;
|
||||||
|
string++;
|
||||||
|
if (*string == '-')
|
||||||
|
string++;
|
||||||
|
if (*string == 'h' || *string == 'H')
|
||||||
|
{
|
||||||
|
return (info->mach == bfd_mach_h8300h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return info->mach == bfd_mach_h8300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This routine is provided two arch_infos and works out the
|
||||||
|
machine which would be compatible with both and returns a pointer
|
||||||
|
to its info structure */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
compatible (in, out)
|
||||||
|
const bfd_arch_info_type * in;
|
||||||
|
const bfd_arch_info_type * out;
|
||||||
|
{
|
||||||
|
/* If the output is non-H and the input is -H, that's bad */
|
||||||
|
if (in->mach == bfd_mach_h8300h &&
|
||||||
|
out->mach == bfd_mach_h8300)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* If either is an -H, the answer is -H */
|
||||||
|
if (in->mach == bfd_mach_h8300h)
|
||||||
|
return in;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const bfd_arch_info_type h8300_info_struct =
|
||||||
|
{
|
||||||
|
16, /* 16 bits in a word */
|
||||||
|
16, /* 16 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_h8300,
|
||||||
|
bfd_mach_h8300,
|
||||||
|
"h8300", /* arch_name */
|
||||||
|
"h8300", /* printable name */
|
||||||
|
1,
|
||||||
|
true, /* the default machine */
|
||||||
|
compatible,
|
||||||
|
h8300_scan,
|
||||||
|
/* local_bfd_reloc_type_lookup, */
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_h8300_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_h8300,
|
||||||
|
bfd_mach_h8300h,
|
||||||
|
"h8300h", /* arch_name */
|
||||||
|
"h8300h", /* printable name */
|
||||||
|
1,
|
||||||
|
false, /* the default machine */
|
||||||
|
compatible,
|
||||||
|
h8300_scan,
|
||||||
|
/* local_bfd_reloc_type_lookup, */
|
||||||
|
&h8300_info_struct,
|
||||||
|
};
|
199
contrib/gdb/bfd/cpu-h8500.c
Normal file
199
contrib/gdb/bfd/cpu-h8500.c
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
/* BFD library support routines for the H8/500 architecture.
|
||||||
|
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
Relocations for the Z8K
|
||||||
|
|
||||||
|
*/
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE(relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_16(abfd, x, (bfd_byte *)data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE(relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
|
||||||
|
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||||
|
abort();
|
||||||
|
HOWTO_PREPARE(relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||||
|
abort();
|
||||||
|
HOWTO_PREPARE(relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type howto_16
|
||||||
|
= NEWHOWTO(howto16_callback,"abs16",1,false,false);
|
||||||
|
static reloc_howto_type howto_8
|
||||||
|
= NEWHOWTO(howto8_callback,"abs8",0,false,false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_FFnn
|
||||||
|
= NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_pcrel
|
||||||
|
= NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
local_bfd_reloc_type_lookup (arch, code)
|
||||||
|
const struct bfd_arch_info *arch;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
switch (code) {
|
||||||
|
case BFD_RELOC_16:
|
||||||
|
return &howto_16;
|
||||||
|
case BFD_RELOC_8_FFnn:
|
||||||
|
return &howto_8_FFnn;
|
||||||
|
case BFD_RELOC_8:
|
||||||
|
return &howto_8;
|
||||||
|
case BFD_RELOC_8_PCREL:
|
||||||
|
return &howto_8_pcrel;
|
||||||
|
}
|
||||||
|
return (reloc_howto_type *)NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
scan_mach (info, string)
|
||||||
|
const struct bfd_arch_info *info;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
if (strcmp(string,"h8/500") == 0) return true;
|
||||||
|
if (strcmp(string,"H8/500") == 0) return true;
|
||||||
|
if (strcmp(string,"h8500") == 0) return true;
|
||||||
|
if (strcmp(string,"H8500") == 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 /* not used currently */
|
||||||
|
/* This routine is provided two arch_infos and returns whether
|
||||||
|
they'd be compatible */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
compatible (a,b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
if (a->arch != b->arch || a->mach != b->mach)
|
||||||
|
return NULL;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_h8500_arch =
|
||||||
|
{
|
||||||
|
16, /* 16 bits in a word */
|
||||||
|
24, /* 24 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_h8500,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"h8500", /* arch_name */
|
||||||
|
"h8500", /* printable name */
|
||||||
|
1,
|
||||||
|
true, /* the default machine */
|
||||||
|
bfd_default_compatible,
|
||||||
|
scan_mach,
|
||||||
|
0,
|
||||||
|
};
|
54
contrib/gdb/bfd/cpu-hppa.c
Normal file
54
contrib/gdb/bfd/cpu-hppa.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* BFD support for the HP Precision Architecture architecture.
|
||||||
|
Copyright 1992 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
static const bfd_arch_info_type bfd_hppa10_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_hppa,
|
||||||
|
10, /* By convention PA1.0 = 10 */
|
||||||
|
"hppa",
|
||||||
|
"hppa1.0",
|
||||||
|
3,
|
||||||
|
true, /* Unless we use 1.1 specific features */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_hppa_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_hppa,
|
||||||
|
11, /* By convention PA1.1 = 11 */
|
||||||
|
"hppa",
|
||||||
|
"hppa1.1",
|
||||||
|
3,
|
||||||
|
false, /* 1.1 specific features used */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
&bfd_hppa10_arch,
|
||||||
|
};
|
38
contrib/gdb/bfd/cpu-i386.c
Normal file
38
contrib/gdb/bfd/cpu-i386.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* 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,
|
||||||
|
};
|
40
contrib/gdb/bfd/cpu-i860.c
Normal file
40
contrib/gdb/bfd/cpu-i860.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* BFD support for the Intel 860 architecture.
|
||||||
|
Copyright 1992, 1995 Free Software Foundation, Inc.
|
||||||
|
Created mostly by substituting "860" for "386" in cpu-i386.c
|
||||||
|
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_i860_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_i860,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"i860",
|
||||||
|
"i860",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
162
contrib/gdb/bfd/cpu-i960.c
Normal file
162
contrib/gdb/bfd/cpu-i960.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* BFD library support routines for the i960 architecture.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* This routine is provided a string, and tries to work out if it
|
||||||
|
could possibly refer to the i960 machine pointed at in the
|
||||||
|
info_struct pointer */
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
scan_960_mach (ap, string)
|
||||||
|
const bfd_arch_info_type *ap;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
unsigned long machine;
|
||||||
|
|
||||||
|
/* Look for the string i960, or somesuch at the front of the string */
|
||||||
|
|
||||||
|
if (strncmp("i960",string,4) == 0) {
|
||||||
|
string+=4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* no match, can be us */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (string[0] == 0) {
|
||||||
|
/* i960 on it's own means core to us*/
|
||||||
|
if (ap->mach == bfd_mach_i960_core) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string[0] != ':') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string++;
|
||||||
|
if (string[0] == '\0')
|
||||||
|
return false;
|
||||||
|
if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
|
||||||
|
string[3] == 'e' && string[4] == '\0')
|
||||||
|
machine = bfd_mach_i960_core;
|
||||||
|
else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */
|
||||||
|
return false;
|
||||||
|
else if (string[0] == 'k' && string[1] == 'b')
|
||||||
|
machine = bfd_mach_i960_kb_sb;
|
||||||
|
else if (string[0] == 's' && string[1] == 'b')
|
||||||
|
machine = bfd_mach_i960_kb_sb;
|
||||||
|
else if (string[0] == 'm' && string[1] == 'c')
|
||||||
|
machine = bfd_mach_i960_mc;
|
||||||
|
else if (string[0] == 'x' && string[1] == 'a')
|
||||||
|
machine = bfd_mach_i960_xa;
|
||||||
|
else if (string[0] == 'c' && string[1] == 'a')
|
||||||
|
machine = bfd_mach_i960_ca;
|
||||||
|
else if (string[0] == 'k' && string[1] == 'a')
|
||||||
|
machine = bfd_mach_i960_ka_sa;
|
||||||
|
else if (string[0] == 's' && string[1] == 'a')
|
||||||
|
machine = bfd_mach_i960_ka_sa;
|
||||||
|
else if (string[0] == 'j' && string[1] == 'x')
|
||||||
|
machine = bfd_mach_i960_jx;
|
||||||
|
else if (string[0] == 'h' && string[1] == 'x')
|
||||||
|
machine = bfd_mach_i960_hx;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
if (machine == ap->mach) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This routine is provided two arch_infos and works out the i960
|
||||||
|
machine which would be compatible with both and returns a pointer
|
||||||
|
to its info structure */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
compatible (a,b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
|
||||||
|
/* The i960 has distinct subspecies which may not interbreed:
|
||||||
|
CORE CA
|
||||||
|
CORE KA KB MC XA
|
||||||
|
CORE HX JX
|
||||||
|
Any architecture on the same line is compatible, the one on
|
||||||
|
the right is the least restrictive.
|
||||||
|
|
||||||
|
We represent this information in an array, each machine to a side */
|
||||||
|
|
||||||
|
#define ERROR 0
|
||||||
|
#define CORE bfd_mach_i960_core /*1*/
|
||||||
|
#define KA bfd_mach_i960_ka_sa /*2*/
|
||||||
|
#define KB bfd_mach_i960_kb_sb /*3*/
|
||||||
|
#define MC bfd_mach_i960_mc /*4*/
|
||||||
|
#define XA bfd_mach_i960_xa /*5*/
|
||||||
|
#define CA bfd_mach_i960_ca /*6*/
|
||||||
|
#define JX bfd_mach_i960_jx /*7*/
|
||||||
|
#define HX bfd_mach_i960_hx /*8*/
|
||||||
|
#define MAX_ARCH ((int)HX)
|
||||||
|
|
||||||
|
static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
|
||||||
|
{
|
||||||
|
{ ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
|
||||||
|
{ CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
|
||||||
|
{ KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
|
||||||
|
{ KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
|
||||||
|
{ MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
|
||||||
|
{ XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
|
||||||
|
{ CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
|
||||||
|
{ JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
|
||||||
|
{ HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (a->mach == matrix[a->mach][b->mach]) ? a : b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
#define N(a,b,d,n) \
|
||||||
|
{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]),
|
||||||
|
N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]),
|
||||||
|
N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]),
|
||||||
|
N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]),
|
||||||
|
N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]),
|
||||||
|
N(bfd_mach_i960_jx, "i960:jx", false, &arch_info_struct[6]),
|
||||||
|
N(bfd_mach_i960_hx, "i960:hx", false, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_i960_arch =
|
||||||
|
N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]);
|
42
contrib/gdb/bfd/cpu-m68k.c
Normal file
42
contrib/gdb/bfd/cpu-m68k.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* BFD library support routines for architectures.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
|
||||||
|
|
||||||
|
#define N(name, print,d,next) \
|
||||||
|
{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, }
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
N(68008,"m68k:68008",false, &arch_info_struct[1]),
|
||||||
|
N(68010,"m68k:68010",false, &arch_info_struct[2]),
|
||||||
|
N(68020,"m68k:68020",true, &arch_info_struct[3]),
|
||||||
|
N(68030,"m68k:68030",false, &arch_info_struct[4]),
|
||||||
|
N(68040,"m68k:68040",false, &arch_info_struct[5]),
|
||||||
|
N(68070,"m68k:68070",false, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_m68k_arch =
|
||||||
|
N(68000,"m68k:68000",false, &arch_info_struct[0]);
|
42
contrib/gdb/bfd/cpu-m88k.c
Normal file
42
contrib/gdb/bfd/cpu-m88k.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* bfd back-end for m88k support
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_m88k_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_m88k,
|
||||||
|
88100, /* only 1 machine */
|
||||||
|
"m88k",
|
||||||
|
"m88k:88100",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
85
contrib/gdb/bfd/cpu-mips.c
Normal file
85
contrib/gdb/bfd/cpu-mips.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/* bfd back-end for mips support
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_mips,
|
||||||
|
6000,
|
||||||
|
"mips",
|
||||||
|
"mips:6000",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
64, /* 64 bits in a word */
|
||||||
|
64, /* 64 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_mips,
|
||||||
|
4000,
|
||||||
|
"mips",
|
||||||
|
"mips:4000",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
&arch_info_struct[2],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
64, /* 64 bits in a word */
|
||||||
|
64, /* 64 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_mips,
|
||||||
|
8000,
|
||||||
|
"mips",
|
||||||
|
"mips:8000",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_mips_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_mips,
|
||||||
|
3000,
|
||||||
|
"mips",
|
||||||
|
"mips:3000",
|
||||||
|
3,
|
||||||
|
true,
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[0],
|
||||||
|
};
|
868
contrib/gdb/bfd/cpu-ns32k.c
Normal file
868
contrib/gdb/bfd/cpu-ns32k.c
Normal file
@ -0,0 +1,868 @@
|
|||||||
|
/* BFD support for the ns32k architecture.
|
||||||
|
Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
|
||||||
|
Almost totally rewritten by Ian Dall from initial work
|
||||||
|
by Andrew Cagney.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||||
|
int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||||
|
long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||||
|
int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
|
||||||
|
struct symbol_cache_entry *symbol,
|
||||||
|
PTR data,
|
||||||
|
asection *input_section,
|
||||||
|
bfd *output_bfd,
|
||||||
|
char **error_message));
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_imm PARAMS ((bfd *abfd,
|
||||||
|
arelent *reloc_entry,
|
||||||
|
struct symbol_cache_entry *symbol,
|
||||||
|
PTR data,
|
||||||
|
asection *input_section,
|
||||||
|
bfd *output_bfd,
|
||||||
|
char **error_message));
|
||||||
|
bfd_reloc_status_type ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
|
||||||
|
bfd *input_bfd,
|
||||||
|
asection *input_section,
|
||||||
|
bfd_byte *contents,
|
||||||
|
bfd_vma address,
|
||||||
|
bfd_vma value,
|
||||||
|
bfd_vma addend ));
|
||||||
|
bfd_reloc_status_type ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
|
||||||
|
bfd *input_bfd,
|
||||||
|
bfd_vma relocation,
|
||||||
|
bfd_byte *location));
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
|
||||||
|
#define N(machine, printable, d, next) \
|
||||||
|
{ 32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
N(32532,"ns32k:32532",true, 0), /* the word ns32k will match this too */
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_ns32k_arch =
|
||||||
|
N(32032,"ns32k:32032",false, &arch_info_struct[0]);
|
||||||
|
|
||||||
|
static long
|
||||||
|
ns32k_sign_extend(value, bits)
|
||||||
|
int value;
|
||||||
|
int bits;
|
||||||
|
{
|
||||||
|
value = value & ((1 << bits) - 1);
|
||||||
|
return (value & (1 << (bits-1))
|
||||||
|
? value | (~((1 << bits) - 1))
|
||||||
|
: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
ns32k_get_displacement(buffer, offset, size)
|
||||||
|
bfd_byte *buffer;
|
||||||
|
long offset;
|
||||||
|
long size;
|
||||||
|
{
|
||||||
|
long value;
|
||||||
|
buffer += offset;
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
value = ns32k_sign_extend (*buffer, 7);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value = ns32k_sign_extend(*buffer++, 6);
|
||||||
|
value = (value << 8) | (0xff & *buffer);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
value = ns32k_sign_extend(*buffer++, 6);
|
||||||
|
value = (value << 8) | (0xff & *buffer++);
|
||||||
|
value = (value << 8) | (0xff & *buffer++);
|
||||||
|
value = (value << 8) | (0xff & *buffer);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ns32k_put_displacement(value, buffer, offset, size)
|
||||||
|
long value;
|
||||||
|
bfd_byte *buffer;
|
||||||
|
long offset;
|
||||||
|
long size;
|
||||||
|
{
|
||||||
|
buffer += offset;
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
if (value < -64 || value > 63)
|
||||||
|
return -1;
|
||||||
|
value&=0x7f;
|
||||||
|
*buffer++=value;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (value < -8192 || value > 8191)
|
||||||
|
return -1;
|
||||||
|
value&=0x3fff;
|
||||||
|
value|=0x8000;
|
||||||
|
*buffer++=(value>>8);
|
||||||
|
*buffer++=value;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (value < -0x1f000000 || value >= 0x20000000)
|
||||||
|
return -1;
|
||||||
|
value|=0xc0000000;
|
||||||
|
*buffer++=(value>>24);
|
||||||
|
*buffer++=(value>>16);
|
||||||
|
*buffer++=(value>>8);
|
||||||
|
*buffer++=value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
ns32k_get_immediate(buffer, offset, size)
|
||||||
|
bfd_byte *buffer;
|
||||||
|
long offset;
|
||||||
|
long size;
|
||||||
|
{
|
||||||
|
long value = 0;
|
||||||
|
buffer += offset;
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
value = (value << 8) | (*buffer++ & 0xff);
|
||||||
|
case 3:
|
||||||
|
value = (value << 8) | (*buffer++ & 0xff);
|
||||||
|
case 2:
|
||||||
|
value = (value << 8) | (*buffer++ & 0xff);
|
||||||
|
case 1:
|
||||||
|
value = (value << 8) | (*buffer++ & 0xff);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ns32k_put_immediate (value, buffer, offset, size)
|
||||||
|
long value;
|
||||||
|
bfd_byte *buffer;
|
||||||
|
long offset;
|
||||||
|
long size;
|
||||||
|
{
|
||||||
|
buffer += offset + size - 1;
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
*buffer-- = (value & 0xff); value >>= 8;
|
||||||
|
case 3:
|
||||||
|
*buffer-- = (value & 0xff); value >>= 8;
|
||||||
|
case 2:
|
||||||
|
*buffer-- = (value & 0xff); value >>= 8;
|
||||||
|
case 1:
|
||||||
|
*buffer-- = (value & 0xff); value >>= 8;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is just like the standard perform_relocation except we
|
||||||
|
* use get_data and put_data which know about the ns32k
|
||||||
|
* storage methods.
|
||||||
|
* This is probably a lot more complicated than it needs to be!
|
||||||
|
*/
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||||
|
error_message, get_data, put_data)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
long (*get_data)();
|
||||||
|
int (*put_data)();
|
||||||
|
{
|
||||||
|
int overflow = 0;
|
||||||
|
bfd_vma relocation;
|
||||||
|
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||||
|
bfd_size_type addr = reloc_entry->address;
|
||||||
|
bfd_vma output_base = 0;
|
||||||
|
reloc_howto_type *howto = reloc_entry->howto;
|
||||||
|
asection *reloc_target_output_section;
|
||||||
|
|
||||||
|
if ((symbol->section == &bfd_abs_section)
|
||||||
|
&& output_bfd != (bfd *) NULL)
|
||||||
|
{
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we are not producing relocateable output, return an error if
|
||||||
|
the symbol is not defined. An undefined weak symbol is
|
||||||
|
considered to have a value of zero (SVR4 ABI, p. 4-27). */
|
||||||
|
if (symbol->section == &bfd_und_section
|
||||||
|
&& (symbol->flags & BSF_WEAK) == 0
|
||||||
|
&& output_bfd == (bfd *) NULL)
|
||||||
|
flag = bfd_reloc_undefined;
|
||||||
|
|
||||||
|
|
||||||
|
/* Is the address of the relocation really within the section? */
|
||||||
|
if (reloc_entry->address > input_section->_cooked_size)
|
||||||
|
return bfd_reloc_outofrange;
|
||||||
|
|
||||||
|
/* Work out which section the relocation is targetted at and the
|
||||||
|
initial relocation command value. */
|
||||||
|
|
||||||
|
/* Get symbol value. (Common symbols are special.) */
|
||||||
|
if (bfd_is_com_section (symbol->section))
|
||||||
|
relocation = 0;
|
||||||
|
else
|
||||||
|
relocation = symbol->value;
|
||||||
|
|
||||||
|
|
||||||
|
reloc_target_output_section = symbol->section->output_section;
|
||||||
|
|
||||||
|
/* Convert input-section-relative symbol value to absolute. */
|
||||||
|
if (output_bfd && howto->partial_inplace == false)
|
||||||
|
output_base = 0;
|
||||||
|
else
|
||||||
|
output_base = reloc_target_output_section->vma;
|
||||||
|
|
||||||
|
relocation += output_base + symbol->section->output_offset;
|
||||||
|
|
||||||
|
/* Add in supplied addend. */
|
||||||
|
relocation += reloc_entry->addend;
|
||||||
|
|
||||||
|
/* Here the variable relocation holds the final address of the
|
||||||
|
symbol we are relocating against, plus any addend. */
|
||||||
|
|
||||||
|
if (howto->pc_relative == true)
|
||||||
|
{
|
||||||
|
/* This is a PC relative relocation. We want to set RELOCATION
|
||||||
|
to the distance between the address of the symbol and the
|
||||||
|
location. RELOCATION is already the address of the symbol.
|
||||||
|
|
||||||
|
We start by subtracting the address of the section containing
|
||||||
|
the location.
|
||||||
|
|
||||||
|
If pcrel_offset is set, we must further subtract the position
|
||||||
|
of the location within the section. Some targets arrange for
|
||||||
|
the addend to be the negative of the position of the location
|
||||||
|
within the section; for example, i386-aout does this. For
|
||||||
|
i386-aout, pcrel_offset is false. Some other targets do not
|
||||||
|
include the position of the location; for example, m88kbcs,
|
||||||
|
or ELF. For those targets, pcrel_offset is true.
|
||||||
|
|
||||||
|
If we are producing relocateable output, then we must ensure
|
||||||
|
that this reloc will be correctly computed when the final
|
||||||
|
relocation is done. If pcrel_offset is false we want to wind
|
||||||
|
up with the negative of the location within the section,
|
||||||
|
which means we must adjust the existing addend by the change
|
||||||
|
in the location within the section. If pcrel_offset is true
|
||||||
|
we do not want to adjust the existing addend at all.
|
||||||
|
|
||||||
|
FIXME: This seems logical to me, but for the case of
|
||||||
|
producing relocateable output it is not what the code
|
||||||
|
actually does. I don't want to change it, because it seems
|
||||||
|
far too likely that something will break. */
|
||||||
|
|
||||||
|
relocation -=
|
||||||
|
input_section->output_section->vma + input_section->output_offset;
|
||||||
|
|
||||||
|
if (howto->pcrel_offset == true)
|
||||||
|
relocation -= reloc_entry->address;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output_bfd != (bfd *) NULL)
|
||||||
|
{
|
||||||
|
if (howto->partial_inplace == false)
|
||||||
|
{
|
||||||
|
/* This is a partial relocation, and we want to apply the relocation
|
||||||
|
to the reloc entry rather than the raw data. Modify the reloc
|
||||||
|
inplace to reflect what we now know. */
|
||||||
|
reloc_entry->addend = relocation;
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This is a partial relocation, but inplace, so modify the
|
||||||
|
reloc record a bit.
|
||||||
|
|
||||||
|
If we've relocated with a symbol with a section, change
|
||||||
|
into a ref to the section belonging to the symbol. */
|
||||||
|
|
||||||
|
reloc_entry->address += input_section->output_offset;
|
||||||
|
|
||||||
|
/* WTF?? */
|
||||||
|
if (abfd->xvec->flavour == bfd_target_coff_flavour
|
||||||
|
&& strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
/* For m68k-coff, the addend was being subtracted twice during
|
||||||
|
relocation with -r. Removing the line below this comment
|
||||||
|
fixes that problem; see PR 2953.
|
||||||
|
|
||||||
|
However, Ian wrote the following, regarding removing the line below,
|
||||||
|
which explains why it is still enabled: --djm
|
||||||
|
|
||||||
|
If you put a patch like that into BFD you need to check all the COFF
|
||||||
|
linkers. I am fairly certain that patch will break coff-i386 (e.g.,
|
||||||
|
SCO); see coff_i386_reloc in coff-i386.c where I worked around the
|
||||||
|
problem in a different way. There may very well be a reason that the
|
||||||
|
code works as it does.
|
||||||
|
|
||||||
|
Hmmm. The first obvious point is that bfd_perform_relocation should
|
||||||
|
not have any tests that depend upon the flavour. It's seem like
|
||||||
|
entirely the wrong place for such a thing. The second obvious point
|
||||||
|
is that the current code ignores the reloc addend when producing
|
||||||
|
relocateable output for COFF. That's peculiar. In fact, I really
|
||||||
|
have no idea what the point of the line you want to remove is.
|
||||||
|
|
||||||
|
A typical COFF reloc subtracts the old value of the symbol and adds in
|
||||||
|
the new value to the location in the object file (if it's a pc
|
||||||
|
relative reloc it adds the difference between the symbol value and the
|
||||||
|
location). When relocating we need to preserve that property.
|
||||||
|
|
||||||
|
BFD handles this by setting the addend to the negative of the old
|
||||||
|
value of the symbol. Unfortunately it handles common symbols in a
|
||||||
|
non-standard way (it doesn't subtract the old value) but that's a
|
||||||
|
different story (we can't change it without losing backward
|
||||||
|
compatibility with old object files) (coff-i386 does subtract the old
|
||||||
|
value, to be compatible with existing coff-i386 targets, like SCO).
|
||||||
|
|
||||||
|
So everything works fine when not producing relocateable output. When
|
||||||
|
we are producing relocateable output, logically we should do exactly
|
||||||
|
what we do when not producing relocateable output. Therefore, your
|
||||||
|
patch is correct. In fact, it should probably always just set
|
||||||
|
reloc_entry->addend to 0 for all cases, since it is, in fact, going to
|
||||||
|
add the value into the object file. This won't hurt the COFF code,
|
||||||
|
which doesn't use the addend; I'm not sure what it will do to other
|
||||||
|
formats (the thing to check for would be whether any formats both use
|
||||||
|
the addend and set partial_inplace).
|
||||||
|
|
||||||
|
When I wanted to make coff-i386 produce relocateable output, I ran
|
||||||
|
into the problem that you are running into: I wanted to remove that
|
||||||
|
line. Rather than risk it, I made the coff-i386 relocs use a special
|
||||||
|
function; it's coff_i386_reloc in coff-i386.c. The function
|
||||||
|
specifically adds the addend field into the object file, knowing that
|
||||||
|
bfd_perform_relocation is not going to. If you remove that line, then
|
||||||
|
coff-i386.c will wind up adding the addend field in twice. It's
|
||||||
|
trivial to fix; it just needs to be done.
|
||||||
|
|
||||||
|
The problem with removing the line is just that it may break some
|
||||||
|
working code. With BFD it's hard to be sure of anything. The right
|
||||||
|
way to deal with this is simply to build and test at least all the
|
||||||
|
supported COFF targets. It should be straightforward if time and disk
|
||||||
|
space consuming. For each target:
|
||||||
|
1) build the linker
|
||||||
|
2) generate some executable, and link it using -r (I would
|
||||||
|
probably use paranoia.o and link against newlib/libc.a, which
|
||||||
|
for all the supported targets would be available in
|
||||||
|
/usr/cygnus/progressive/H-host/target/lib/libc.a).
|
||||||
|
3) make the change to reloc.c
|
||||||
|
4) rebuild the linker
|
||||||
|
5) repeat step 2
|
||||||
|
6) if the resulting object files are the same, you have at least
|
||||||
|
made it no worse
|
||||||
|
7) if they are different you have to figure out which version is
|
||||||
|
right
|
||||||
|
*/
|
||||||
|
relocation -= reloc_entry->addend;
|
||||||
|
#endif
|
||||||
|
reloc_entry->addend = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reloc_entry->addend = relocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reloc_entry->addend = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: This overflow checking is incomplete, because the value
|
||||||
|
might have overflowed before we get here. For a correct check we
|
||||||
|
need to compute the value in a size larger than bitsize, but we
|
||||||
|
can't reasonably do that for a reloc the same size as a host
|
||||||
|
machine word.
|
||||||
|
FIXME: We should also do overflow checking on the result after
|
||||||
|
adding in the value contained in the object file. */
|
||||||
|
if (howto->complain_on_overflow != complain_overflow_dont)
|
||||||
|
{
|
||||||
|
bfd_vma check;
|
||||||
|
|
||||||
|
/* Get the value that will be used for the relocation, but
|
||||||
|
starting at bit position zero. */
|
||||||
|
if (howto->rightshift > howto->bitpos)
|
||||||
|
check = relocation >> (howto->rightshift - howto->bitpos);
|
||||||
|
else
|
||||||
|
check = relocation << (howto->bitpos - howto->rightshift);
|
||||||
|
switch (howto->complain_on_overflow)
|
||||||
|
{
|
||||||
|
case complain_overflow_signed:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. */
|
||||||
|
bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
|
||||||
|
bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
|
||||||
|
|
||||||
|
/* The above right shift is incorrect for a signed value.
|
||||||
|
Fix it up by forcing on the upper bits. */
|
||||||
|
if (howto->rightshift > howto->bitpos
|
||||||
|
&& (bfd_signed_vma) relocation < 0)
|
||||||
|
check |= ((bfd_vma) - 1
|
||||||
|
& ~((bfd_vma) - 1
|
||||||
|
>> (howto->rightshift - howto->bitpos)));
|
||||||
|
if ((bfd_signed_vma) check > reloc_signed_max
|
||||||
|
|| (bfd_signed_vma) check < reloc_signed_min)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case complain_overflow_unsigned:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. This expression avoids
|
||||||
|
overflow if howto->bitsize is the number of bits in
|
||||||
|
bfd_vma. */
|
||||||
|
bfd_vma reloc_unsigned_max =
|
||||||
|
(((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||||
|
|
||||||
|
if ((bfd_vma) check > reloc_unsigned_max)
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case complain_overflow_bitfield:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. This expression avoids
|
||||||
|
overflow if howto->bitsize is the number of bits in
|
||||||
|
bfd_vma. */
|
||||||
|
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||||
|
|
||||||
|
if (((bfd_vma) check & ~reloc_bits) != 0
|
||||||
|
&& ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
|
||||||
|
{
|
||||||
|
/* The above right shift is incorrect for a signed
|
||||||
|
value. See if turning on the upper bits fixes the
|
||||||
|
overflow. */
|
||||||
|
if (howto->rightshift > howto->bitpos
|
||||||
|
&& (bfd_signed_vma) relocation < 0)
|
||||||
|
{
|
||||||
|
check |= ((bfd_vma) - 1
|
||||||
|
& ~((bfd_vma) - 1
|
||||||
|
>> (howto->rightshift - howto->bitpos)));
|
||||||
|
if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
flag = bfd_reloc_overflow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Either we are relocating all the way, or we don't want to apply
|
||||||
|
the relocation to the reloc entry (probably because there isn't
|
||||||
|
any room in the output format to describe addends to relocs)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
|
||||||
|
(OSF version 1.3, compiler version 3.11). It miscompiles the
|
||||||
|
following program:
|
||||||
|
|
||||||
|
struct str
|
||||||
|
{
|
||||||
|
unsigned int i0;
|
||||||
|
} s = { 0 };
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
unsigned long x;
|
||||||
|
|
||||||
|
x = 0x100000000;
|
||||||
|
x <<= (unsigned long) s.i0;
|
||||||
|
if (x == 0)
|
||||||
|
printf ("failed\n");
|
||||||
|
else
|
||||||
|
printf ("succeeded (%lx)\n", x);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
relocation >>= (bfd_vma) howto->rightshift;
|
||||||
|
|
||||||
|
/* Shift everything up to where it's going to be used */
|
||||||
|
|
||||||
|
relocation <<= (bfd_vma) howto->bitpos;
|
||||||
|
|
||||||
|
/* Wait for the day when all have the mask in them */
|
||||||
|
|
||||||
|
/* What we do:
|
||||||
|
i instruction to be left alone
|
||||||
|
o offset within instruction
|
||||||
|
r relocation offset to apply
|
||||||
|
S src mask
|
||||||
|
D dst mask
|
||||||
|
N ~dst mask
|
||||||
|
A part 1
|
||||||
|
B part 2
|
||||||
|
R result
|
||||||
|
|
||||||
|
Do this:
|
||||||
|
i i i i i o o o o o from bfd_get<size>
|
||||||
|
and S S S S S to get the size offset we want
|
||||||
|
+ r r r r r r r r r r to get the final value to place
|
||||||
|
and D D D D D to chop to right size
|
||||||
|
-----------------------
|
||||||
|
A A A A A
|
||||||
|
And this:
|
||||||
|
... i i i i i o o o o o from bfd_get<size>
|
||||||
|
and N N N N N get instruction
|
||||||
|
-----------------------
|
||||||
|
... B B B B B
|
||||||
|
|
||||||
|
And then:
|
||||||
|
B B B B B
|
||||||
|
or A A A A A
|
||||||
|
-----------------------
|
||||||
|
R R R R R R R R R R put into bfd_put<size>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DOIT(x) \
|
||||||
|
x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
|
||||||
|
|
||||||
|
switch (howto->size)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char x = get_data (data, addr, 1);
|
||||||
|
DOIT (x);
|
||||||
|
overflow = put_data(x, data, addr, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (relocation)
|
||||||
|
{
|
||||||
|
short x = get_data (data, addr, 2);
|
||||||
|
DOIT (x);
|
||||||
|
overflow = put_data(x, (unsigned char *) data, addr, 2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (relocation)
|
||||||
|
{
|
||||||
|
long x = get_data (data, addr, 4);
|
||||||
|
DOIT (x);
|
||||||
|
overflow = put_data(x, data, addr, 4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
{
|
||||||
|
long x = get_data(data, addr, 4);
|
||||||
|
relocation = -relocation;
|
||||||
|
DOIT(x);
|
||||||
|
overflow = put_data(x, data , addr, 4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
/* Do nothing */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
#ifdef BFD64
|
||||||
|
if (relocation)
|
||||||
|
{
|
||||||
|
bfd_vma x = get_data (data, addr, 8);
|
||||||
|
DOIT (x);
|
||||||
|
overflow = put_data(x, data, addr, 8);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
abort ();
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return bfd_reloc_other;
|
||||||
|
}
|
||||||
|
if ((howto->complain_on_overflow != complain_overflow_dont) && overflow)
|
||||||
|
return bfd_reloc_overflow;
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Relocate a given location using a given value and howto. */
|
||||||
|
|
||||||
|
bfd_reloc_status_type
|
||||||
|
do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, get_data,
|
||||||
|
put_data)
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
bfd *input_bfd;
|
||||||
|
bfd_vma relocation;
|
||||||
|
bfd_byte *location;
|
||||||
|
long (*get_data)();
|
||||||
|
int (*put_data)();
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
bfd_vma x;
|
||||||
|
boolean overflow;
|
||||||
|
|
||||||
|
/* If the size is negative, negate RELOCATION. This isn't very
|
||||||
|
general. */
|
||||||
|
if (howto->size < 0)
|
||||||
|
relocation = -relocation;
|
||||||
|
|
||||||
|
/* Get the value we are going to relocate. */
|
||||||
|
size = bfd_get_reloc_size (howto);
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
abort ();
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
#ifdef BFD64
|
||||||
|
case 8:
|
||||||
|
#endif
|
||||||
|
x = get_data (location, 0, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for overflow. FIXME: We may drop bits during the addition
|
||||||
|
which we don't check for. We must either check at every single
|
||||||
|
operation, which would be tedious, or we must do the computations
|
||||||
|
in a type larger than bfd_vma, which would be inefficient. */
|
||||||
|
overflow = false;
|
||||||
|
if (howto->complain_on_overflow != complain_overflow_dont)
|
||||||
|
{
|
||||||
|
bfd_vma check;
|
||||||
|
bfd_signed_vma signed_check;
|
||||||
|
bfd_vma add;
|
||||||
|
bfd_signed_vma signed_add;
|
||||||
|
|
||||||
|
if (howto->rightshift == 0)
|
||||||
|
{
|
||||||
|
check = relocation;
|
||||||
|
signed_check = (bfd_signed_vma) relocation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Drop unwanted bits from the value we are relocating to. */
|
||||||
|
check = relocation >> howto->rightshift;
|
||||||
|
|
||||||
|
/* If this is a signed value, the rightshift just dropped
|
||||||
|
leading 1 bits (assuming twos complement). */
|
||||||
|
if ((bfd_signed_vma) relocation >= 0)
|
||||||
|
signed_check = check;
|
||||||
|
else
|
||||||
|
signed_check = (check
|
||||||
|
| ((bfd_vma) - 1
|
||||||
|
& ~((bfd_vma) - 1 >> howto->rightshift)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the value from the object file. */
|
||||||
|
add = x & howto->src_mask;
|
||||||
|
|
||||||
|
/* Get the value from the object file with an appropriate sign.
|
||||||
|
The expression involving howto->src_mask isolates the upper
|
||||||
|
bit of src_mask. If that bit is set in the value we are
|
||||||
|
adding, it is negative, and we subtract out that number times
|
||||||
|
two. If src_mask includes the highest possible bit, then we
|
||||||
|
can not get the upper bit, but that does not matter since
|
||||||
|
signed_add needs no adjustment to become negative in that
|
||||||
|
case. */
|
||||||
|
signed_add = add;
|
||||||
|
if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
|
||||||
|
signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
|
||||||
|
|
||||||
|
/* Add the value from the object file, shifted so that it is a
|
||||||
|
straight number. */
|
||||||
|
if (howto->bitpos == 0)
|
||||||
|
{
|
||||||
|
check += add;
|
||||||
|
signed_check += signed_add;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
check += add >> howto->bitpos;
|
||||||
|
|
||||||
|
/* For the signed case we use ADD, rather than SIGNED_ADD,
|
||||||
|
to avoid warnings from SVR4 cc. This is OK since we
|
||||||
|
explictly handle the sign bits. */
|
||||||
|
if (signed_add >= 0)
|
||||||
|
signed_check += add >> howto->bitpos;
|
||||||
|
else
|
||||||
|
signed_check += ((add >> howto->bitpos)
|
||||||
|
| ((bfd_vma) - 1
|
||||||
|
& ~((bfd_vma) - 1 >> howto->bitpos)));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (howto->complain_on_overflow)
|
||||||
|
{
|
||||||
|
case complain_overflow_signed:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. */
|
||||||
|
bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
|
||||||
|
bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
|
||||||
|
|
||||||
|
if (signed_check > reloc_signed_max
|
||||||
|
|| signed_check < reloc_signed_min)
|
||||||
|
overflow = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case complain_overflow_unsigned:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. This expression avoids
|
||||||
|
overflow if howto->bitsize is the number of bits in
|
||||||
|
bfd_vma. */
|
||||||
|
bfd_vma reloc_unsigned_max =
|
||||||
|
(((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||||
|
|
||||||
|
if (check > reloc_unsigned_max)
|
||||||
|
overflow = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case complain_overflow_bitfield:
|
||||||
|
{
|
||||||
|
/* Assumes two's complement. This expression avoids
|
||||||
|
overflow if howto->bitsize is the number of bits in
|
||||||
|
bfd_vma. */
|
||||||
|
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||||
|
|
||||||
|
if ((check & ~reloc_bits) != 0
|
||||||
|
&& (((bfd_vma) signed_check & ~reloc_bits)
|
||||||
|
!= (-1 & ~reloc_bits)))
|
||||||
|
overflow = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put RELOCATION in the right bits. */
|
||||||
|
relocation >>= (bfd_vma) howto->rightshift;
|
||||||
|
relocation <<= (bfd_vma) howto->bitpos;
|
||||||
|
|
||||||
|
/* Add RELOCATION to the right bits of X. */
|
||||||
|
x = ((x & ~howto->dst_mask)
|
||||||
|
| (((x & howto->src_mask) + relocation) & howto->dst_mask));
|
||||||
|
|
||||||
|
/* Put the relocated value back in the object file. */
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
abort ();
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
#ifdef BFD64
|
||||||
|
case 8:
|
||||||
|
#endif
|
||||||
|
put_data(x, location, 0, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_disp(abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||||
|
error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_displacement, ns32k_put_displacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_reloc_imm (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol;
|
||||||
|
PTR data;
|
||||||
|
asection *input_section;
|
||||||
|
bfd *output_bfd;
|
||||||
|
char **error_message;
|
||||||
|
{
|
||||||
|
return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_immediate, ns32k_put_immediate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_reloc_status_type
|
||||||
|
ns32k_final_link_relocate (howto, input_bfd, input_section, contents, address, value, addend )
|
||||||
|
reloc_howto_type *howto;
|
||||||
|
bfd *input_bfd;
|
||||||
|
asection *input_section;
|
||||||
|
bfd_byte *contents;
|
||||||
|
bfd_vma address;
|
||||||
|
bfd_vma value;
|
||||||
|
bfd_vma addend;
|
||||||
|
{
|
||||||
|
bfd_vma relocation;
|
||||||
|
|
||||||
|
/* Sanity check the address. */
|
||||||
|
if (address > input_section->_cooked_size)
|
||||||
|
return bfd_reloc_outofrange;
|
||||||
|
|
||||||
|
/* This function assumes that we are dealing with a basic relocation
|
||||||
|
against a symbol. We want to compute the value of the symbol to
|
||||||
|
relocate to. This is just VALUE, the value of the symbol, plus
|
||||||
|
ADDEND, any addend associated with the reloc. */
|
||||||
|
relocation = value + addend;
|
||||||
|
|
||||||
|
/* If the relocation is PC relative, we want to set RELOCATION to
|
||||||
|
the distance between the symbol (currently in RELOCATION) and the
|
||||||
|
location we are relocating. Some targets (e.g., i386-aout)
|
||||||
|
arrange for the contents of the section to be the negative of the
|
||||||
|
offset of the location within the section; for such targets
|
||||||
|
pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
|
||||||
|
simply leave the contents of the section as zero; for such
|
||||||
|
targets pcrel_offset is true. If pcrel_offset is false we do not
|
||||||
|
need to subtract out the offset of the location within the
|
||||||
|
section (which is just ADDRESS). */
|
||||||
|
if (howto->pc_relative)
|
||||||
|
{
|
||||||
|
relocation -= (input_section->output_section->vma
|
||||||
|
+ input_section->output_offset);
|
||||||
|
if (howto->pcrel_offset)
|
||||||
|
relocation -= address;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ns32k_relocate_contents (howto, input_bfd, relocation,
|
||||||
|
contents + address);
|
||||||
|
}
|
124
contrib/gdb/bfd/cpu-powerpc.c
Normal file
124
contrib/gdb/bfd/cpu-powerpc.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/* BFD PowerPC CPU definition
|
||||||
|
Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||||
|
Contributed by Ian Lance Taylor, Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
/* The common PowerPC architecture is compatible with the RS/6000. */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *powerpc_compatible
|
||||||
|
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
powerpc_compatible (a,b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
BFD_ASSERT (a->arch == bfd_arch_powerpc);
|
||||||
|
switch (b->arch)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
case bfd_arch_powerpc:
|
||||||
|
return bfd_default_compatible (a, b);
|
||||||
|
case bfd_arch_rs6000:
|
||||||
|
if (a->mach == 0)
|
||||||
|
return a;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_powerpc,
|
||||||
|
603, /* for the mpc603 */
|
||||||
|
"powerpc",
|
||||||
|
"powerpc:603",
|
||||||
|
3,
|
||||||
|
false, /* not the default */
|
||||||
|
powerpc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_powerpc,
|
||||||
|
604, /* for the mpc604 */
|
||||||
|
"powerpc",
|
||||||
|
"powerpc:604",
|
||||||
|
3,
|
||||||
|
false, /* not the default */
|
||||||
|
powerpc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[2]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_powerpc,
|
||||||
|
403, /* for the 403 */
|
||||||
|
"powerpc",
|
||||||
|
"powerpc:403",
|
||||||
|
3,
|
||||||
|
false, /* not the default */
|
||||||
|
powerpc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[3]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_powerpc,
|
||||||
|
601, /* for the mpc601 */
|
||||||
|
"powerpc",
|
||||||
|
"powerpc:601",
|
||||||
|
3,
|
||||||
|
false, /* not the default */
|
||||||
|
powerpc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_powerpc_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_powerpc,
|
||||||
|
0, /* for the POWER/PowerPC common architecture */
|
||||||
|
"powerpc",
|
||||||
|
"powerpc:common",
|
||||||
|
3,
|
||||||
|
true, /* the default */
|
||||||
|
powerpc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[0]
|
||||||
|
};
|
70
contrib/gdb/bfd/cpu-rs6000.c
Normal file
70
contrib/gdb/bfd/cpu-rs6000.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* BFD back-end for rs6000 support
|
||||||
|
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||||
|
FIXME: Can someone provide a transliteration of this name into ASCII?
|
||||||
|
Using the following chars caused a compiler warning on HIUX (so I replaced
|
||||||
|
them with octal escapes), and isn't useful without an understanding of what
|
||||||
|
character set it is.
|
||||||
|
Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
|
||||||
|
and John Gilmore of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
/* The RS/6000 architecture is compatible with the PowerPC common
|
||||||
|
architecture. */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *rs6000_compatible
|
||||||
|
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
rs6000_compatible (a,b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
BFD_ASSERT (a->arch == bfd_arch_rs6000);
|
||||||
|
switch (b->arch)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
case bfd_arch_rs6000:
|
||||||
|
return bfd_default_compatible (a, b);
|
||||||
|
case bfd_arch_powerpc:
|
||||||
|
if (b->mach == 0)
|
||||||
|
return b;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_rs6000_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_rs6000,
|
||||||
|
6000, /* only 1 machine */
|
||||||
|
"rs6000",
|
||||||
|
"rs6000:6000",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
rs6000_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
0,
|
||||||
|
};
|
68
contrib/gdb/bfd/cpu-sh.c
Normal file
68
contrib/gdb/bfd/cpu-sh.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* BFD library support routines for the Hitachi-SH architecture.
|
||||||
|
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
scan_mach (info, string)
|
||||||
|
const struct bfd_arch_info *info;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
if (strcmp(string,"sh") == 0) return true;
|
||||||
|
if (strcmp(string,"SH") == 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* This routine is provided two arch_infos and returns whether
|
||||||
|
they'd be compatible */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
compatible (a,b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
if (a->arch != b->arch || a->mach != b->mach)
|
||||||
|
return NULL;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_sh_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_sh,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"sh", /* arch_name */
|
||||||
|
"sh", /* printable name */
|
||||||
|
1,
|
||||||
|
true, /* the default machine */
|
||||||
|
bfd_default_compatible,
|
||||||
|
scan_mach,
|
||||||
|
0,
|
||||||
|
};
|
111
contrib/gdb/bfd/cpu-sparc.c
Normal file
111
contrib/gdb/bfd/cpu-sparc.c
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/* BFD support for the SPARC architecture.
|
||||||
|
Copyright (C) 1992, 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. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
/* Don't mix 32 bit and 64 bit files. */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
sparc_compatible (a, b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
if (a->bits_per_word != b->bits_per_word)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return bfd_default_compatible (a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
32, /* bits in a word */
|
||||||
|
32, /* bits in an address */
|
||||||
|
8, /* bits in a byte */
|
||||||
|
bfd_arch_sparc,
|
||||||
|
bfd_mach_sparc_v8plus,
|
||||||
|
"sparc",
|
||||||
|
"sparc:v8plus",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
sparc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
32, /* bits in a word */
|
||||||
|
32, /* bits in an address */
|
||||||
|
8, /* bits in a byte */
|
||||||
|
bfd_arch_sparc,
|
||||||
|
bfd_mach_sparc_v8plusa,
|
||||||
|
"sparc",
|
||||||
|
"sparc:v8plusa",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
sparc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[2],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
64, /* bits in a word */
|
||||||
|
64, /* bits in an address */
|
||||||
|
8, /* bits in a byte */
|
||||||
|
bfd_arch_sparc,
|
||||||
|
bfd_mach_sparc_v9,
|
||||||
|
"sparc",
|
||||||
|
"sparc:v9",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
sparc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[3],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
64, /* bits in a word */
|
||||||
|
64, /* bits in an address */
|
||||||
|
8, /* bits in a byte */
|
||||||
|
bfd_arch_sparc,
|
||||||
|
bfd_mach_sparc_v9a,
|
||||||
|
"sparc",
|
||||||
|
"sparc:v9a",
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
sparc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_sparc_arch =
|
||||||
|
{
|
||||||
|
32, /* bits in a word */
|
||||||
|
32, /* bits in an address */
|
||||||
|
8, /* bits in a byte */
|
||||||
|
bfd_arch_sparc,
|
||||||
|
bfd_mach_sparc,
|
||||||
|
"sparc",
|
||||||
|
"sparc",
|
||||||
|
3,
|
||||||
|
true, /* the default */
|
||||||
|
sparc_compatible,
|
||||||
|
bfd_default_scan,
|
||||||
|
&arch_info_struct[0],
|
||||||
|
};
|
39
contrib/gdb/bfd/cpu-vax.c
Normal file
39
contrib/gdb/bfd/cpu-vax.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* bfd back-end for vax support
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_vax_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_vax,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"vax",
|
||||||
|
"vax",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
54
contrib/gdb/bfd/cpu-w65.c
Normal file
54
contrib/gdb/bfd/cpu-w65.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* BFD library support routines for the WDC 65816 architecture.
|
||||||
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as publiw65ed by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You w65ould have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach();
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
scan_mach (info, string)
|
||||||
|
const struct bfd_arch_info *info;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
if (strcmp(string,"w65") == 0) return true;
|
||||||
|
if (strcmp(string,"w65816") == 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_w65_arch =
|
||||||
|
{
|
||||||
|
16, /* 16 bits in a word */
|
||||||
|
24, /* 24 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_w65,
|
||||||
|
0, /* only 1 machine */
|
||||||
|
"w65", /* arch_name */
|
||||||
|
"w65", /* printable name */
|
||||||
|
1,
|
||||||
|
true, /* the default machine */
|
||||||
|
bfd_default_compatible,
|
||||||
|
scan_mach,
|
||||||
|
0,
|
||||||
|
};
|
39
contrib/gdb/bfd/cpu-we32k.c
Normal file
39
contrib/gdb/bfd/cpu-we32k.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* bfd back-end for we32k support
|
||||||
|
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||||
|
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_we32k_arch =
|
||||||
|
{
|
||||||
|
32, /* 32 bits in a word */
|
||||||
|
32, /* 32 bits in an address */
|
||||||
|
8, /* 8 bits in a byte */
|
||||||
|
bfd_arch_we32k,
|
||||||
|
32000, /* only 1 machine */
|
||||||
|
"we32k",
|
||||||
|
"we32k:32000",
|
||||||
|
3,
|
||||||
|
true, /* the one and only */
|
||||||
|
bfd_default_compatible,
|
||||||
|
bfd_default_scan ,
|
||||||
|
0,
|
||||||
|
};
|
198
contrib/gdb/bfd/cpu-z8k.c
Normal file
198
contrib/gdb/bfd/cpu-z8k.c
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
/* BFD library support routines for the Z800n architecture.
|
||||||
|
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||||
|
Hacked by Steve Chamberlain of Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 /* not used currently */
|
||||||
|
/*
|
||||||
|
Relocations for the Z8K
|
||||||
|
|
||||||
|
*/
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
abort ();
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_reloc_status_type
|
||||||
|
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||||
|
ignore_input_section, ignore_bfd)
|
||||||
|
bfd *abfd;
|
||||||
|
arelent *reloc_entry;
|
||||||
|
struct symbol_cache_entry *symbol_in;
|
||||||
|
PTR data;
|
||||||
|
asection *ignore_input_section;
|
||||||
|
bfd *ignore_bfd;
|
||||||
|
{
|
||||||
|
long relocation = 0;
|
||||||
|
bfd_vma addr = reloc_entry->address;
|
||||||
|
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||||
|
abort ();
|
||||||
|
HOWTO_PREPARE (relocation, symbol_in);
|
||||||
|
|
||||||
|
x = (x + relocation + reloc_entry->addend);
|
||||||
|
|
||||||
|
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||||
|
return bfd_reloc_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type howto_16
|
||||||
|
= NEWHOWTO (howto16_callback, "abs16", 1, false, false);
|
||||||
|
static reloc_howto_type howto_8
|
||||||
|
= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_FFnn
|
||||||
|
= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
|
||||||
|
|
||||||
|
static reloc_howto_type howto_8_pcrel
|
||||||
|
= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
|
||||||
|
|
||||||
|
|
||||||
|
static reloc_howto_type *
|
||||||
|
local_bfd_reloc_type_lookup (arch, code)
|
||||||
|
const struct bfd_arch_info *arch;
|
||||||
|
bfd_reloc_code_real_type code;
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case BFD_RELOC_16:
|
||||||
|
return &howto_16;
|
||||||
|
case BFD_RELOC_8_FFnn:
|
||||||
|
return &howto_8_FFnn;
|
||||||
|
case BFD_RELOC_8:
|
||||||
|
return &howto_8;
|
||||||
|
case BFD_RELOC_8_PCREL:
|
||||||
|
return &howto_8_pcrel;
|
||||||
|
default:
|
||||||
|
return (reloc_howto_type *) NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int bfd_default_scan_num_mach ();
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
scan_mach (info, string)
|
||||||
|
const struct bfd_arch_info *info;
|
||||||
|
const char *string;
|
||||||
|
{
|
||||||
|
if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
|
||||||
|
{
|
||||||
|
return bfd_mach_z8001 == info->mach;
|
||||||
|
}
|
||||||
|
if (strcmp (string, "z8002") == 0)
|
||||||
|
{
|
||||||
|
return bfd_mach_z8002 == info->mach;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This routine is provided two arch_infos and returns whether
|
||||||
|
they'd be compatible */
|
||||||
|
|
||||||
|
static const bfd_arch_info_type *
|
||||||
|
compatible (a, b)
|
||||||
|
const bfd_arch_info_type *a;
|
||||||
|
const bfd_arch_info_type *b;
|
||||||
|
{
|
||||||
|
if (a->arch != b->arch || a->mach != b->mach)
|
||||||
|
return NULL;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const bfd_arch_info_type arch_info_struct[] =
|
||||||
|
{
|
||||||
|
{32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
|
||||||
|
};
|
||||||
|
|
||||||
|
const bfd_arch_info_type bfd_z8k_arch =
|
||||||
|
{
|
||||||
|
32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
|
||||||
|
};
|
24
contrib/gdb/bfd/demo64.c
Normal file
24
contrib/gdb/bfd/demo64.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* BFD backend for demonstration 64-bit a.out binaries.
|
||||||
|
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#define ARCH_SIZE 64
|
||||||
|
#define MY(OP) CAT(demo_64_,OP)
|
||||||
|
#define TARGETNAME "demo64"
|
||||||
|
#include "aoutf1.h"
|
24
contrib/gdb/bfd/dep-in.sed
Normal file
24
contrib/gdb/bfd/dep-in.sed
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
: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
|
268
contrib/gdb/bfd/doc/ChangeLog
Normal file
268
contrib/gdb/bfd/doc/ChangeLog
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
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:
|
311
contrib/gdb/bfd/doc/Makefile.in
Normal file
311
contrib/gdb/bfd/doc/Makefile.in
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
348
contrib/gdb/bfd/doc/bfd.texinfo
Normal file
348
contrib/gdb/bfd/doc/bfd.texinfo
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
\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
|
148
contrib/gdb/bfd/doc/bfdsumm.texi
Normal file
148
contrib/gdb/bfd/doc/bfdsumm.texi
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
@c This summary of BFD is shared by the BFD and LD docs.
|
||||||
|
When an object file is opened, BFD subroutines automatically determine
|
||||||
|
the format of the input object file. They then build a descriptor in
|
||||||
|
memory with pointers to routines that will be used to access elements of
|
||||||
|
the object file's data structures.
|
||||||
|
|
||||||
|
As different information from the the object files is required,
|
||||||
|
BFD reads from different sections of the file and processes them.
|
||||||
|
For example, a very common operation for the linker is processing symbol
|
||||||
|
tables. Each BFD back end provides a routine for converting
|
||||||
|
between the object file's representation of symbols and an internal
|
||||||
|
canonical format. When the linker asks for the symbol table of an object
|
||||||
|
file, it calls through a memory pointer to the routine from the
|
||||||
|
relevant BFD back end which reads and converts the table into a canonical
|
||||||
|
form. The linker then operates upon the canonical form. When the link is
|
||||||
|
finished and the linker writes the output file's symbol table,
|
||||||
|
another BFD back end routine is called to take the newly
|
||||||
|
created symbol table and convert it into the chosen output format.
|
||||||
|
|
||||||
|
@menu
|
||||||
|
* BFD information loss:: Information Loss
|
||||||
|
* Canonical format:: The BFD canonical object-file format
|
||||||
|
@end menu
|
||||||
|
|
||||||
|
@node BFD information loss
|
||||||
|
@subsection Information Loss
|
||||||
|
|
||||||
|
@emph{Information can be lost during output.} The output formats
|
||||||
|
supported by BFD do not provide identical facilities, and
|
||||||
|
information which can be described in one form has nowhere to go in
|
||||||
|
another format. One example of this is alignment information in
|
||||||
|
@code{b.out}. There is nowhere in an @code{a.out} format file to store
|
||||||
|
alignment information on the contained data, so when a file is linked
|
||||||
|
from @code{b.out} and an @code{a.out} image is produced, alignment
|
||||||
|
information will not propagate to the output file. (The linker will
|
||||||
|
still use the alignment information internally, so the link is performed
|
||||||
|
correctly).
|
||||||
|
|
||||||
|
Another example is COFF section names. COFF files may contain an
|
||||||
|
unlimited number of sections, each one with a textual section name. If
|
||||||
|
the target of the link is a format which does not have many sections (e.g.,
|
||||||
|
@code{a.out}) or has sections without names (e.g., the Oasys format), the
|
||||||
|
link cannot be done simply. You can circumvent this problem by
|
||||||
|
describing the desired input-to-output section mapping with the linker command
|
||||||
|
language.
|
||||||
|
|
||||||
|
@emph{Information can be lost during canonicalization.} The BFD
|
||||||
|
internal canonical form of the external formats is not exhaustive; there
|
||||||
|
are structures in input formats for which there is no direct
|
||||||
|
representation internally. This means that the BFD back ends
|
||||||
|
cannot maintain all possible data richness through the transformation
|
||||||
|
between external to internal and back to external formats.
|
||||||
|
|
||||||
|
This limitation is only a problem when an application reads one
|
||||||
|
format and writes another. Each BFD back end is responsible for
|
||||||
|
maintaining as much data as possible, and the internal BFD
|
||||||
|
canonical form has structures which are opaque to the BFD core,
|
||||||
|
and exported only to the back ends. When a file is read in one format,
|
||||||
|
the canonical form is generated for BFD and the application. At the
|
||||||
|
same time, the back end saves away any information which may otherwise
|
||||||
|
be lost. If the data is then written back in the same format, the back
|
||||||
|
end routine will be able to use the canonical form provided by the
|
||||||
|
BFD core as well as the information it prepared earlier. Since
|
||||||
|
there is a great deal of commonality between back ends,
|
||||||
|
there is no information lost when
|
||||||
|
linking or copying big endian COFF to little endian COFF, or @code{a.out} to
|
||||||
|
@code{b.out}. When a mixture of formats is linked, the information is
|
||||||
|
only lost from the files whose format differs from the destination.
|
||||||
|
|
||||||
|
@node Canonical format
|
||||||
|
@subsection The BFD canonical object-file format
|
||||||
|
|
||||||
|
The greatest potential for loss of information occurs when there is the least
|
||||||
|
overlap between the information provided by the source format, that
|
||||||
|
stored by the canonical format, and that needed by the
|
||||||
|
destination format. A brief description of the canonical form may help
|
||||||
|
you understand which kinds of data you can count on preserving across
|
||||||
|
conversions.
|
||||||
|
@cindex BFD canonical format
|
||||||
|
@cindex internal object-file format
|
||||||
|
|
||||||
|
@table @emph
|
||||||
|
@item files
|
||||||
|
Information stored on a per-file basis includes target machine
|
||||||
|
architecture, particular implementation format type, a demand pageable
|
||||||
|
bit, and a write protected bit. Information like Unix magic numbers is
|
||||||
|
not stored here---only the magic numbers' meaning, so a @code{ZMAGIC}
|
||||||
|
file would have both the demand pageable bit and the write protected
|
||||||
|
text bit set. The byte order of the target is stored on a per-file
|
||||||
|
basis, so that big- and little-endian object files may be used with one
|
||||||
|
another.
|
||||||
|
|
||||||
|
@item sections
|
||||||
|
Each section in the input file contains the name of the section, the
|
||||||
|
section's original address in the object file, size and alignment
|
||||||
|
information, various flags, and pointers into other BFD data
|
||||||
|
structures.
|
||||||
|
|
||||||
|
@item symbols
|
||||||
|
Each symbol contains a pointer to the information for the object file
|
||||||
|
which originally defined it, its name, its value, and various flag
|
||||||
|
bits. When a BFD back end reads in a symbol table, it relocates all
|
||||||
|
symbols to make them relative to the base of the section where they were
|
||||||
|
defined. Doing this ensures that each symbol points to its containing
|
||||||
|
section. Each symbol also has a varying amount of hidden private data
|
||||||
|
for the BFD back end. Since the symbol points to the original file, the
|
||||||
|
private data format for that symbol is accessible. @code{ld} can
|
||||||
|
operate on a collection of symbols of wildly different formats without
|
||||||
|
problems.
|
||||||
|
|
||||||
|
Normal global and simple local symbols are maintained on output, so an
|
||||||
|
output file (no matter its format) will retain symbols pointing to
|
||||||
|
functions and to global, static, and common variables. Some symbol
|
||||||
|
information is not worth retaining; in @code{a.out}, type information is
|
||||||
|
stored in the symbol table as long symbol names. This information would
|
||||||
|
be useless to most COFF debuggers; the linker has command line switches
|
||||||
|
to allow users to throw it away.
|
||||||
|
|
||||||
|
There is one word of type information within the symbol, so if the
|
||||||
|
format supports symbol type information within symbols (for example, COFF,
|
||||||
|
IEEE, Oasys) and the type is simple enough to fit within one word
|
||||||
|
(nearly everything but aggregates), the information will be preserved.
|
||||||
|
|
||||||
|
@item relocation level
|
||||||
|
Each canonical BFD relocation record contains a pointer to the symbol to
|
||||||
|
relocate to, the offset of the data to relocate, the section the data
|
||||||
|
is in, and a pointer to a relocation type descriptor. Relocation is
|
||||||
|
performed by passing messages through the relocation type
|
||||||
|
descriptor and the symbol pointer. Therefore, relocations can be performed
|
||||||
|
on output data using a relocation method that is only available in one of the
|
||||||
|
input formats. For instance, Oasys provides a byte relocation format.
|
||||||
|
A relocation record requesting this relocation type would point
|
||||||
|
indirectly to a routine to perform this, so the relocation may be
|
||||||
|
performed on a byte being written to a 68k COFF file, even though 68k COFF
|
||||||
|
has no such relocation type.
|
||||||
|
|
||||||
|
@item line numbers
|
||||||
|
Object formats can contain, for debugging purposes, some form of mapping
|
||||||
|
between symbols, source line numbers, and addresses in the output file.
|
||||||
|
These addresses have to be relocated along with the symbol information.
|
||||||
|
Each symbol with an associated list of line number records points to the
|
||||||
|
first record of the list. The head of a line number list consists of a
|
||||||
|
pointer to the symbol, which allows finding out the address of the
|
||||||
|
function whose line number is being described. The rest of the list is
|
||||||
|
made up of pairs: offsets into the section and line numbers. Any format
|
||||||
|
which can simply derive this information can pass it successfully
|
||||||
|
between formats (COFF, IEEE and Oasys).
|
||||||
|
@end table
|
1551
contrib/gdb/bfd/doc/chew.c
Normal file
1551
contrib/gdb/bfd/doc/chew.c
Normal file
File diff suppressed because it is too large
Load Diff
158
contrib/gdb/bfd/doc/doc.str
Normal file
158
contrib/gdb/bfd/doc/doc.str
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
: DOCDD
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command kill_bogus_lines catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: ENDDD
|
||||||
|
skip_past_newline
|
||||||
|
;
|
||||||
|
|
||||||
|
: EXAMPLE
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command kill_bogus_lines do_fancy_stuff translatecomments
|
||||||
|
courierize catstr
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
: INODE
|
||||||
|
"@node " catstr skip_past_newline copy_past_newline catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: CODE_FRAGMENT
|
||||||
|
EXAMPLE
|
||||||
|
;
|
||||||
|
|
||||||
|
: COMMENT
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
drop
|
||||||
|
;
|
||||||
|
|
||||||
|
: SYNOPSIS
|
||||||
|
skip_past_newline
|
||||||
|
"@strong{Synopsis}\n" catstr
|
||||||
|
"@example\n" catstr
|
||||||
|
get_stuff_in_command
|
||||||
|
kill_bogus_lines
|
||||||
|
indent
|
||||||
|
catstr
|
||||||
|
"@end example\n" catstr
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
: func
|
||||||
|
"@findex " - a
|
||||||
|
skip_past_newline
|
||||||
|
copy_past_newline
|
||||||
|
dup - a x x
|
||||||
|
"@subsubsection @code{" - a x x b
|
||||||
|
swap
|
||||||
|
remchar
|
||||||
|
"}\n" - a x b x c
|
||||||
|
catstr catstr catstr catstr catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: FUNCTION
|
||||||
|
"@findex " - a
|
||||||
|
skip_past_newline
|
||||||
|
copy_past_newline
|
||||||
|
dup - a x x
|
||||||
|
"@subsubsection @code{" - a x x b
|
||||||
|
swap
|
||||||
|
remchar
|
||||||
|
"}\n" - a x b x c
|
||||||
|
catstr catstr catstr catstr catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: bodytext
|
||||||
|
get_stuff_in_command
|
||||||
|
bulletize
|
||||||
|
kill_bogus_lines
|
||||||
|
do_fancy_stuff
|
||||||
|
courierize
|
||||||
|
catstr
|
||||||
|
"@*\n" catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: asection
|
||||||
|
skip_past_newline
|
||||||
|
catstr
|
||||||
|
copy_past_newline
|
||||||
|
do_fancy_stuff catstr
|
||||||
|
bodytext
|
||||||
|
;
|
||||||
|
|
||||||
|
: SECTION
|
||||||
|
"@section " asection ;
|
||||||
|
|
||||||
|
: SUBSECTION
|
||||||
|
"@subsection " asection ;
|
||||||
|
|
||||||
|
: SUBSUBSECTION
|
||||||
|
"@subsubsection " asection ;
|
||||||
|
|
||||||
|
: subhead
|
||||||
|
skip_past_newline
|
||||||
|
bodytext
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
: DESCRIPTION
|
||||||
|
"@strong{Description}@*\n" catstr subhead ;
|
||||||
|
|
||||||
|
: RETURNS
|
||||||
|
"@strong{Returns}@*\n" catstr subhead ;
|
||||||
|
|
||||||
|
: INTERNAL_FUNCTION
|
||||||
|
func ;
|
||||||
|
|
||||||
|
|
||||||
|
: INTERNAL_DEFINITION
|
||||||
|
func ;
|
||||||
|
|
||||||
|
|
||||||
|
: INTERNAL
|
||||||
|
func ;
|
||||||
|
|
||||||
|
: TYPEDEF
|
||||||
|
FUNCTION ;
|
||||||
|
|
||||||
|
: SENUM
|
||||||
|
skip_past_newline
|
||||||
|
"Here are the possible values for @code{enum "
|
||||||
|
copy_past_newline remchar catstr
|
||||||
|
"}:\n\n" catstr catstr
|
||||||
|
;
|
||||||
|
: ENUM
|
||||||
|
skip_past_newline
|
||||||
|
"@deffn {} "
|
||||||
|
copy_past_newline catstr catstr
|
||||||
|
;
|
||||||
|
: ENUMX
|
||||||
|
skip_past_newline
|
||||||
|
"@deffnx {} "
|
||||||
|
copy_past_newline catstr
|
||||||
|
catstr
|
||||||
|
;
|
||||||
|
: ENUMEQ
|
||||||
|
skip_past_newline
|
||||||
|
"@deffn {} "
|
||||||
|
copy_past_newline catstr catstr
|
||||||
|
skip_past_newline
|
||||||
|
;
|
||||||
|
: ENUMEQX
|
||||||
|
skip_past_newline
|
||||||
|
"@deffnx {} "
|
||||||
|
copy_past_newline catstr
|
||||||
|
catstr
|
||||||
|
skip_past_newline
|
||||||
|
;
|
||||||
|
: ENUMDOC
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
strip_trailing_newlines
|
||||||
|
catstr
|
||||||
|
"\n@end deffn\n" catstr
|
||||||
|
;
|
135
contrib/gdb/bfd/doc/proto.str
Normal file
135
contrib/gdb/bfd/doc/proto.str
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
|
||||||
|
: SYNOPSIS
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
paramstuff
|
||||||
|
indent
|
||||||
|
maybecatstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: ignore
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
outputdots
|
||||||
|
maybecatstr
|
||||||
|
;
|
||||||
|
|
||||||
|
: CODE_FRAGMENT
|
||||||
|
ignore ;
|
||||||
|
|
||||||
|
: external
|
||||||
|
0 internalmode ignore ;
|
||||||
|
|
||||||
|
: internal
|
||||||
|
1 internalmode ignore ;
|
||||||
|
|
||||||
|
- input stack { a b } output b if internal, a if external
|
||||||
|
: ifinternal
|
||||||
|
"" swap 1 internalmode maybecatstr
|
||||||
|
swap
|
||||||
|
"" swap 0 internalmode maybecatstr
|
||||||
|
catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
- Put note in output string, regardless of internal mode.
|
||||||
|
: COMMENT
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
translatecomments
|
||||||
|
catstr
|
||||||
|
;
|
||||||
|
|
||||||
|
- SENUM enum-type-name
|
||||||
|
- ENUM enum-name
|
||||||
|
- ENUMX addl-enum-name
|
||||||
|
- ENUMDOC doc for preceding enums
|
||||||
|
- ENDSENUM max-enum-name
|
||||||
|
|
||||||
|
: make_enum_header
|
||||||
|
dup
|
||||||
|
"enum " swap catstr
|
||||||
|
" {\n" catstr
|
||||||
|
swap " _dummy_first_" swap catstr catstr
|
||||||
|
",\n" catstr
|
||||||
|
;
|
||||||
|
: make_string_table_header
|
||||||
|
dup
|
||||||
|
"#ifdef _BFD_MAKE_TABLE_" swap catstr swap
|
||||||
|
"\n\nstatic const char *const " swap catstr catstr
|
||||||
|
"_names[] = { \"@@uninitialized@@\",\n" catstr
|
||||||
|
;
|
||||||
|
: SENUM
|
||||||
|
skip_past_newline
|
||||||
|
copy_past_newline
|
||||||
|
remchar
|
||||||
|
dup
|
||||||
|
make_enum_header
|
||||||
|
swap
|
||||||
|
make_string_table_header
|
||||||
|
ifinternal
|
||||||
|
catstr
|
||||||
|
get_stuff_in_command catstr
|
||||||
|
translatecomments ;
|
||||||
|
: ENDSENUM
|
||||||
|
skip_past_newline
|
||||||
|
copy_past_newline strip_trailing_newlines
|
||||||
|
dup
|
||||||
|
" " swap catstr " };\n" catstr swap
|
||||||
|
" \"@@overflow: " swap catstr "@@\",\n};\n#endif\n\n" catstr
|
||||||
|
ifinternal
|
||||||
|
catstr
|
||||||
|
;
|
||||||
|
: make_enumerator
|
||||||
|
" " swap catstr
|
||||||
|
",\n" catstr
|
||||||
|
;
|
||||||
|
: make_enumerator_string
|
||||||
|
" \"" swap catstr
|
||||||
|
"\",\n" catstr
|
||||||
|
;
|
||||||
|
: ENUM
|
||||||
|
skip_past_newline
|
||||||
|
copy_past_newline
|
||||||
|
remchar
|
||||||
|
dup
|
||||||
|
make_enumerator
|
||||||
|
swap
|
||||||
|
make_enumerator_string
|
||||||
|
ifinternal
|
||||||
|
;
|
||||||
|
: ENUMX ENUM catstr ;
|
||||||
|
: ENUMEQ
|
||||||
|
skip_past_newline
|
||||||
|
"#define "
|
||||||
|
copy_past_newline remchar
|
||||||
|
catstr
|
||||||
|
" "
|
||||||
|
catstr
|
||||||
|
copy_past_newline
|
||||||
|
catstr
|
||||||
|
"" swap 0 internalmode maybecatstr
|
||||||
|
;
|
||||||
|
: ENUMEQX ENUMEQ catstr ;
|
||||||
|
: ENUMDOC
|
||||||
|
skip_past_newline
|
||||||
|
get_stuff_in_command
|
||||||
|
strip_trailing_newlines
|
||||||
|
"\n{* " swap catstr " *}\n" catstr
|
||||||
|
translatecomments
|
||||||
|
- discard it if we're doing internal mode
|
||||||
|
"" swap 0 internalmode maybecatstr
|
||||||
|
swap
|
||||||
|
catstr catstr
|
||||||
|
;
|
||||||
|
: ENDDD external ;
|
||||||
|
: SECTION ignore ;
|
||||||
|
: SUBSECTION ignore ;
|
||||||
|
: SUBSUBSECTION ignore ;
|
||||||
|
: INTERNAL_DEFINITION internal ;
|
||||||
|
: DESCRIPTION ignore ;
|
||||||
|
: FUNCTION external ;
|
||||||
|
: RETURNS ignore ;
|
||||||
|
: TYPEDEF external ;
|
||||||
|
: INTERNAL_FUNCTION internal ;
|
||||||
|
: INTERNAL internal ;
|
||||||
|
: INODE ignore ;
|
4740
contrib/gdb/bfd/ecoff.c
Normal file
4740
contrib/gdb/bfd/ecoff.c
Normal file
File diff suppressed because it is too large
Load Diff
2452
contrib/gdb/bfd/ecofflink.c
Normal file
2452
contrib/gdb/bfd/ecofflink.c
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user