Import binutils 2.19.1 as requested by matt@
OK'ed by board@
This commit is contained in:
parent
8813af9cf2
commit
2a6b7db32d
340
external/gpl3/binutils/dist/COPYING
vendored
Normal file
340
external/gpl3/binutils/dist/COPYING
vendored
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
|
||||
|
||||
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) <year> <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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) year 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.
|
482
external/gpl3/binutils/dist/COPYING.LIB
vendored
Normal file
482
external/gpl3/binutils/dist/COPYING.LIB
vendored
Normal file
@ -0,0 +1,482 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, 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!
|
674
external/gpl3/binutils/dist/COPYING3
vendored
Normal file
674
external/gpl3/binutils/dist/COPYING3
vendored
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
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
|
||||
state 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) <year> <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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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 Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
165
external/gpl3/binutils/dist/COPYING3.LIB
vendored
Normal file
165
external/gpl3/binutils/dist/COPYING3.LIB
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
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 that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser 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 as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
12571
external/gpl3/binutils/dist/ChangeLog
vendored
Normal file
12571
external/gpl3/binutils/dist/ChangeLog
vendored
Normal file
File diff suppressed because it is too large
Load Diff
128
external/gpl3/binutils/dist/MAINTAINERS
vendored
Normal file
128
external/gpl3/binutils/dist/MAINTAINERS
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
Please feel free to add, edit, delete this file.
|
||||
Please do not make ChangeLog entries.
|
||||
|
||||
COPYING, COPYING.LIB, README
|
||||
http://gnu.org.
|
||||
|
||||
Makefile.*; configure; configure.ac; src-release
|
||||
Any global maintainer can approve changes to these
|
||||
files, but they should be aware that they need to
|
||||
be kept in sync with their counterparts in the GCC
|
||||
repository. Also please notify the following of
|
||||
any committed patches:
|
||||
binutils@sources.redhat.com
|
||||
gdb-patches@sources.redhat.com
|
||||
|
||||
bfd/; binutils/; elfcpp/; gas/; gold/; gprof/; ld/; opcodes/; cpu/;
|
||||
BFD's part of include/
|
||||
|
||||
binutils: http://sources.redhat.com/binutils/
|
||||
Patches to binutils@sources.redhat.com.
|
||||
Please notify the following of any interface changes:
|
||||
gdb-patches@sources.redhat.com
|
||||
|
||||
cgen/; cgen parts of opcodes/, sim/ & include/
|
||||
cgen: http://sources.redhat.com/cgen/
|
||||
Patches to cgen@sources.redhat.com
|
||||
May need separate opcodes/ or sim/ approval for
|
||||
commits of regenerated files there.
|
||||
|
||||
config.guess; config.sub; readline/support/config.{sub,guess}
|
||||
config: http://savannah.gnu.org/projects/config
|
||||
Patches to config-patches@gnu.org.
|
||||
Changes need to be done in tandem with the official CONFIG
|
||||
sources or submitted to the master file maintainer and brought
|
||||
in via a merge. When updating any of these files, please be
|
||||
sure to update all of them.
|
||||
Please notify the following of any committed patches:
|
||||
binutils@sources.redhat.com
|
||||
gdb-patches@sources.redhat.com
|
||||
|
||||
depcomp
|
||||
Send bug reports and patches to bug-automake@gnu.org.
|
||||
|
||||
gdb/; readline/; sim/; GDB's part of include/
|
||||
GDB: http://www.gnu.org/software/gdb/
|
||||
Patches to gdb-patches@sources.redhat.com.
|
||||
See also gdb/MAINTAINERS and sim/MAINTAINERS.
|
||||
|
||||
include/
|
||||
See binutils/, gdb/, sid/, gcc/, libiberty/ etc.
|
||||
|
||||
intl/; config.rhost; libiberty/; libiberty's part of include/
|
||||
gcc: http://gcc.gnu.org
|
||||
Changes need to be done in tandem with the official GCC
|
||||
sources or submitted to the master file maintainer and brought
|
||||
in via a merge. Note: approved patches in gcc's libiberty or
|
||||
intl are automatically approved in this libiberty and intl also;
|
||||
feel free to merge them yourself if needed sooner than the next
|
||||
merge. Otherwise, changes are automatically merged, usually
|
||||
within a day.
|
||||
|
||||
libdecnumber/
|
||||
See libiberty. The master copy of this directory is in the GCC
|
||||
repository.
|
||||
|
||||
ltconfig; ltmain.sh; ltcf-*.sh
|
||||
libtool: http://www.gnu.org/software/libtool/
|
||||
Changes need to be done in tandem with the official LIBTOOL
|
||||
sources or submitted to the master file maintainer and brought
|
||||
in via a merge.
|
||||
|
||||
mkinstalldirs; move-if-change
|
||||
autoconf: http://gnu.org
|
||||
Patches to autoconf-patches@gnu.org.
|
||||
Changes need to be done in tandem with the official AUTOCONF
|
||||
sources or submitted to the master file maintainer and brought
|
||||
in via a merge.
|
||||
|
||||
symlink-tree
|
||||
gcc: http://gcc.gnu.org
|
||||
See libiberty.
|
||||
|
||||
newlib/; libgloss/
|
||||
http://sources.redhat.com/newlib/
|
||||
Patches to newlib@sources.redhat.com.
|
||||
|
||||
sid/; SID's part of cgen/
|
||||
sid: http://sources.redhat.com/sid/
|
||||
Patches to sid@sources.redhat.com
|
||||
|
||||
texinfo/texinfo.tex
|
||||
texinfo: http://ftp.gnu.org.
|
||||
Latest version can be found on ftp://ftp.gnu.org and can be
|
||||
imported at any (reasonable) time.
|
||||
Please not use GCC's texinfo. Please do not import texinfo.
|
||||
|
||||
tcl/; tix/; itcl/; tk/; libgui/
|
||||
insight: http://sources.redhat.com/insight/
|
||||
Contact insight@sources.redhat.com.
|
||||
|
||||
winsup/
|
||||
cygwin: http://sources.redhat.com/cygwin
|
||||
Patches to cygwin-patches@sources.redhat.com.
|
||||
General discussion cygwin@sources.redhat.com.
|
||||
See also winsup/MAINTAINERS.
|
||||
|
||||
config-ml.in; makefile.vms; mkdep; setup.com;
|
||||
etc/; utils/;
|
||||
Any global maintainer can approve changes to these
|
||||
files and directories.
|
||||
|
||||
compile; depcomp; install-sh; missing; ylwrap;
|
||||
config/
|
||||
Any global maintainer can approve changes to these
|
||||
files and directories, but they should be aware
|
||||
that they need to be kept in sync with their
|
||||
counterparts in the GCC repository.
|
||||
|
||||
modules file
|
||||
Obviously changes to this file should not go through
|
||||
overseers@sources.redhat.com. If you understand the file
|
||||
format (or can cut-and-paste existing entries), modify it. If
|
||||
it scares you, get someone who does understand it to help you.
|
||||
Be prepared to fix it if you do break it.
|
||||
|
||||
/* Local variables: */
|
||||
/* change-log-default-name: "/dev/null" */
|
||||
/* End: */
|
572
external/gpl3/binutils/dist/Makefile.def
vendored
Normal file
572
external/gpl3/binutils/dist/Makefile.def
vendored
Normal file
@ -0,0 +1,572 @@
|
||||
#! /usr/bin/autogen
|
||||
AutoGen definitions Makefile.tpl;
|
||||
|
||||
// Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
|
||||
// This file was originally written by Nathanael Nerode.
|
||||
//
|
||||
// Copyright 2002, 2003, 2004, 2005, 2006, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
// "missing" indicates that that module doesn't supply
|
||||
// that recursive target in its Makefile.
|
||||
|
||||
build_modules= { module= libiberty; };
|
||||
build_modules= { module= bison; };
|
||||
build_modules= { module= byacc; };
|
||||
build_modules= { module= flex; };
|
||||
build_modules= { module= m4; };
|
||||
build_modules= { module= texinfo; };
|
||||
build_modules= { module= fixincludes; };
|
||||
|
||||
host_modules= { module= ash; };
|
||||
host_modules= { module= autoconf; };
|
||||
host_modules= { module= automake; };
|
||||
host_modules= { module= bash; };
|
||||
host_modules= { module= bfd; lib_path=.libs; bootstrap=true; };
|
||||
host_modules= { module= opcodes; lib_path=.libs; bootstrap=true; };
|
||||
host_modules= { module= binutils; bootstrap=true; };
|
||||
host_modules= { module= bison; no_check_cross= true; };
|
||||
host_modules= { module= byacc; no_check_cross= true; };
|
||||
host_modules= { module= bzip2; };
|
||||
host_modules= { module= dejagnu; };
|
||||
host_modules= { module= diff; };
|
||||
host_modules= { module= dosutils; no_check= true; };
|
||||
host_modules= { module= etc; };
|
||||
host_modules= { module= fastjar; no_check_cross= true; };
|
||||
host_modules= { module= fileutils; };
|
||||
host_modules= { module= findutils; };
|
||||
host_modules= { module= find; };
|
||||
host_modules= { module= fixincludes;
|
||||
missing= TAGS; };
|
||||
host_modules= { module= flex; no_check_cross= true; };
|
||||
host_modules= { module= gas; bootstrap=true; };
|
||||
host_modules= { module= gcc; bootstrap=true;
|
||||
extra_make_flags="$(EXTRA_GCC_FLAGS)"; };
|
||||
host_modules= { module= gawk; };
|
||||
host_modules= { module= gettext; };
|
||||
host_modules= { module= gmp; lib_path=.libs; bootstrap=true;
|
||||
extra_configure_flags='--disable-shared';
|
||||
no_install= true;
|
||||
host="none-${host_vendor}-${host_os}";
|
||||
target="none-${host_vendor}-${host_os}"; };
|
||||
host_modules= { module= mpfr; lib_path=.libs; bootstrap=true;
|
||||
extra_configure_flags='--disable-shared --with-gmp-build=$$r/$(HOST_SUBDIR)/gmp';
|
||||
no_install= true;
|
||||
host="none-${host_vendor}-${host_os}";
|
||||
target="none-${host_vendor}-${host_os}"; };
|
||||
host_modules= { module= gnuserv; };
|
||||
host_modules= { module= gold; bootstrap=true; };
|
||||
host_modules= { module= gprof; };
|
||||
host_modules= { module= gzip; };
|
||||
host_modules= { module= hello; };
|
||||
host_modules= { module= indent; };
|
||||
host_modules= { module= intl; bootstrap=true; };
|
||||
host_modules= { module= tcl;
|
||||
missing=mostlyclean; };
|
||||
host_modules= { module= itcl; };
|
||||
host_modules= { module= ld; bootstrap=true; };
|
||||
host_modules= { module= libcpp; bootstrap=true; };
|
||||
host_modules= { module= libdecnumber; bootstrap=true; };
|
||||
host_modules= { module= libgui; };
|
||||
host_modules= { module= libiberty; bootstrap=true; };
|
||||
host_modules= { module= libtool; };
|
||||
host_modules= { module= m4; };
|
||||
host_modules= { module= make; };
|
||||
host_modules= { module= mmalloc; no_check=true; };
|
||||
host_modules= { module= patch; };
|
||||
host_modules= { module= perl; };
|
||||
host_modules= { module= prms; };
|
||||
host_modules= { module= rcs; };
|
||||
host_modules= { module= readline; };
|
||||
host_modules= { module= release; no_install= true; no_check= true; };
|
||||
host_modules= { module= recode; };
|
||||
host_modules= { module= sed; };
|
||||
host_modules= { module= send-pr; };
|
||||
host_modules= { module= shellutils; };
|
||||
host_modules= { module= sid; };
|
||||
host_modules= { module= sim; };
|
||||
host_modules= { module= tar; };
|
||||
host_modules= { module= texinfo; no_install= true; };
|
||||
host_modules= { module= textutils; };
|
||||
host_modules= { module= time; };
|
||||
host_modules= { module= uudecode; };
|
||||
host_modules= { module= wdiff; };
|
||||
host_modules= { module= zip; no_check_cross=true; };
|
||||
host_modules= { module= zlib; no_install=true; no_check=true; bootstrap=true; };
|
||||
host_modules= { module= gdb; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
|
||||
host_modules= { module= expect; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
|
||||
host_modules= { module= guile; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
|
||||
host_modules= { module= tk; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
|
||||
host_modules= { module= libtermcap; no_check=true;
|
||||
missing=mostlyclean;
|
||||
missing=clean;
|
||||
missing=distclean;
|
||||
missing=maintainer-clean; };
|
||||
host_modules= { module= utils; no_check=true; };
|
||||
host_modules= { module= gnattools; };
|
||||
|
||||
target_modules = { module= libstdc++-v3; lib_path=.libs; raw_cxx=true; };
|
||||
target_modules = { module= libmudflap; lib_path=.libs; };
|
||||
target_modules = { module= libssp; lib_path=.libs; };
|
||||
target_modules = { module= newlib; };
|
||||
target_modules = { module= libgcc; bootstrap=true; no_check=true; };
|
||||
target_modules = { module= libgfortran; };
|
||||
target_modules = { module= libobjc; };
|
||||
target_modules = { module= libtermcap; no_check=true;
|
||||
missing=mostlyclean;
|
||||
missing=clean;
|
||||
missing=distclean;
|
||||
missing=maintainer-clean; };
|
||||
target_modules = { module= winsup; };
|
||||
target_modules = { module= libgloss; no_check=true; };
|
||||
target_modules = { module= libiberty; };
|
||||
target_modules = { module= gperf; };
|
||||
target_modules = { module= examples; no_check=true; no_install=true; };
|
||||
target_modules = { module= libffi; };
|
||||
target_modules = { module= libjava; raw_cxx=true; };
|
||||
target_modules = { module= zlib; };
|
||||
target_modules = { module= boehm-gc; };
|
||||
target_modules = { module= qthreads; };
|
||||
target_modules = { module= rda; };
|
||||
target_modules = { module= libada; };
|
||||
target_modules = { module= libgomp; lib_path=.libs; };
|
||||
|
||||
// These are (some of) the make targets to be done in each subdirectory.
|
||||
// Not all; these are the ones which don't have special options.
|
||||
// "depend" indicates that a target depends on another target uniformly
|
||||
// for each subdirectory. There can be several such lines per target.
|
||||
recursive_targets = { make_target= info;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= dvi;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= pdf;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= html;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= TAGS;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= install-info;
|
||||
depend=configure;
|
||||
depend=info; };
|
||||
recursive_targets = { make_target= install-pdf;
|
||||
depend=configure;
|
||||
depend=pdf; };
|
||||
recursive_targets = { make_target= install-html;
|
||||
depend=configure;
|
||||
depend=html; };
|
||||
recursive_targets = { make_target= installcheck;
|
||||
depend=configure; };
|
||||
recursive_targets = { make_target= mostlyclean; };
|
||||
recursive_targets = { make_target= clean; };
|
||||
recursive_targets = { make_target= distclean; };
|
||||
recursive_targets = { make_target= maintainer-clean; };
|
||||
|
||||
// Flags which need to be passed down.
|
||||
|
||||
// Directories etc.
|
||||
flags_to_pass = { flag= DESTDIR ; };
|
||||
flags_to_pass = { flag= RPATH_ENVVAR ; };
|
||||
flags_to_pass = { flag= TARGET_SUBDIR ; };
|
||||
flags_to_pass = { flag= bindir ; };
|
||||
flags_to_pass = { flag= datadir ; };
|
||||
flags_to_pass = { flag= exec_prefix ; };
|
||||
flags_to_pass = { flag= includedir ; };
|
||||
flags_to_pass = { flag= datarootdir ; };
|
||||
flags_to_pass = { flag= docdir ; };
|
||||
flags_to_pass = { flag= infodir ; };
|
||||
flags_to_pass = { flag= pdfdir ; };
|
||||
flags_to_pass = { flag= htmldir ; };
|
||||
flags_to_pass = { flag= libdir ; };
|
||||
flags_to_pass = { flag= libexecdir ; };
|
||||
flags_to_pass = { flag= lispdir ; };
|
||||
flags_to_pass = { flag= localstatedir ; };
|
||||
flags_to_pass = { flag= mandir ; };
|
||||
flags_to_pass = { flag= oldincludedir ; };
|
||||
flags_to_pass = { flag= prefix ; };
|
||||
flags_to_pass = { flag= sbindir ; };
|
||||
flags_to_pass = { flag= sharedstatedir ; };
|
||||
flags_to_pass = { flag= sysconfdir ; };
|
||||
flags_to_pass = { flag= tooldir ; };
|
||||
flags_to_pass = { flag= build_tooldir ; };
|
||||
flags_to_pass = { flag= target_alias ; };
|
||||
|
||||
// Build tools
|
||||
flags_to_pass = { flag= BISON ; };
|
||||
flags_to_pass = { flag= CC_FOR_BUILD ; };
|
||||
flags_to_pass = { flag= CFLAGS_FOR_BUILD ; };
|
||||
flags_to_pass = { flag= CXX_FOR_BUILD ; };
|
||||
flags_to_pass = { flag= EXPECT ; };
|
||||
flags_to_pass = { flag= FLEX ; };
|
||||
flags_to_pass = { flag= INSTALL ; };
|
||||
flags_to_pass = { flag= INSTALL_DATA ; };
|
||||
flags_to_pass = { flag= INSTALL_PROGRAM ; };
|
||||
flags_to_pass = { flag= INSTALL_SCRIPT ; };
|
||||
flags_to_pass = { flag= LDFLAGS_FOR_BUILD ; };
|
||||
flags_to_pass = { flag= LEX ; };
|
||||
flags_to_pass = { flag= M4 ; };
|
||||
flags_to_pass = { flag= MAKE ; };
|
||||
flags_to_pass = { flag= RUNTEST ; };
|
||||
flags_to_pass = { flag= RUNTESTFLAGS ; };
|
||||
flags_to_pass = { flag= SHELL ; };
|
||||
flags_to_pass = { flag= YACC ; };
|
||||
|
||||
// Host tools
|
||||
flags_to_pass = { flag= ADAFLAGS ; optional=true ; };
|
||||
flags_to_pass = { flag= ADA_CFLAGS ; };
|
||||
flags_to_pass = { flag= AR_FLAGS ; };
|
||||
flags_to_pass = { flag= BOOT_ADAFLAGS ; optional=true ; };
|
||||
flags_to_pass = { flag= BOOT_CFLAGS ; };
|
||||
flags_to_pass = { flag= BOOT_LDFLAGS ; };
|
||||
flags_to_pass = { flag= CFLAGS ; };
|
||||
flags_to_pass = { flag= CXXFLAGS ; };
|
||||
flags_to_pass = { flag= LDFLAGS ; };
|
||||
flags_to_pass = { flag= LIBCFLAGS ; };
|
||||
flags_to_pass = { flag= LIBCXXFLAGS ; };
|
||||
flags_to_pass = { flag= STAGE1_CFLAGS ; };
|
||||
flags_to_pass = { flag= STAGE1_CHECKING ; };
|
||||
flags_to_pass = { flag= STAGE1_LANGUAGES ; };
|
||||
flags_to_pass = { flag= STAGE2_CFLAGS ; };
|
||||
flags_to_pass = { flag= STAGE3_CFLAGS ; };
|
||||
flags_to_pass = { flag= STAGE4_CFLAGS ; };
|
||||
flags_to_pass = { flag= GNATBIND ; };
|
||||
flags_to_pass = { flag= GNATMAKE ; };
|
||||
|
||||
// Target tools
|
||||
flags_to_pass = { flag= AR_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= AS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= CC_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= CFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= CPPFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= CXX_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= CXXFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= DLLTOOL_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= GCJ_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= LD_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= LIPO_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= LIBCFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= LIBCXXFLAGS_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= NM_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= OBJDUMP_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= RANLIB_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= STRIP_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= WINDRES_FOR_TARGET ; };
|
||||
flags_to_pass = { flag= WINDMC_FOR_TARGET ; };
|
||||
|
||||
// Miscellaneous
|
||||
flags_to_pass = { flag= LANGUAGES ; optional=true ; };
|
||||
flags_to_pass = { flag= LEAN ; };
|
||||
|
||||
// Inter-module dependencies
|
||||
|
||||
// Build modules
|
||||
dependencies = { module=all-build-bison; on=all-build-texinfo; };
|
||||
dependencies = { module=all-build-byacc; on=all-build-texinfo; };
|
||||
dependencies = { module=all-build-flex; on=all-build-texinfo; };
|
||||
dependencies = { module=all-build-flex; on=all-build-bison; };
|
||||
dependencies = { module=all-build-flex; on=all-build-byacc; };
|
||||
dependencies = { module=all-build-flex; on=all-build-m4; };
|
||||
dependencies = { module=all-build-libiberty; on=all-build-texinfo; };
|
||||
dependencies = { module=all-build-m4; on=all-build-texinfo; };
|
||||
dependencies = { module=all-build-fixincludes; on=all-build-libiberty; };
|
||||
|
||||
// Host modules specific to gcc.
|
||||
dependencies = { module=configure-gcc; on=configure-intl; };
|
||||
dependencies = { module=configure-gcc; on=all-binutils; };
|
||||
dependencies = { module=configure-gcc; on=all-gas; };
|
||||
dependencies = { module=configure-gcc; on=all-ld; };
|
||||
dependencies = { module=configure-gcc; on=all-gold; };
|
||||
dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
|
||||
dependencies = { module=all-gcc; on=all-gmp; };
|
||||
dependencies = { module=all-gcc; on=all-intl; };
|
||||
dependencies = { module=all-gcc; on=all-mpfr; };
|
||||
dependencies = { module=all-gcc; on=all-build-texinfo; };
|
||||
dependencies = { module=all-gcc; on=all-build-bison; };
|
||||
dependencies = { module=all-gcc; on=all-build-byacc; };
|
||||
dependencies = { module=all-gcc; on=all-build-flex; };
|
||||
dependencies = { module=all-gcc; on=all-build-libiberty; };
|
||||
dependencies = { module=all-gcc; on=all-build-fixincludes; };
|
||||
dependencies = { module=all-gcc; on=all-zlib; };
|
||||
dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
|
||||
dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
|
||||
dependencies = { module=all-gcc; on=all-libiberty; };
|
||||
dependencies = { module=all-gcc; on=all-fixincludes; };
|
||||
dependencies = { module=install-gcc ; on=install-fixincludes; };
|
||||
|
||||
dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
|
||||
dependencies = { module=configure-libcpp; on=configure-intl; };
|
||||
dependencies = { module=all-libcpp; on=all-libiberty; hard=true; };
|
||||
dependencies = { module=all-libcpp; on=all-intl; };
|
||||
|
||||
dependencies = { module=all-fixincludes; on=all-libiberty; };
|
||||
|
||||
dependencies = { module=all-gnattools; on=all-target-libada; };
|
||||
|
||||
dependencies = { module=configure-mpfr; on=all-gmp; };
|
||||
|
||||
// Host modules specific to gdb.
|
||||
dependencies = { module=configure-gdb; on=all-intl; };
|
||||
dependencies = { module=configure-gdb; on=configure-sim; };
|
||||
dependencies = { module=configure-gdb; on=all-bfd; };
|
||||
dependencies = { module=all-gdb; on=all-libiberty; };
|
||||
dependencies = { module=all-gdb; on=all-opcodes; };
|
||||
dependencies = { module=all-gdb; on=all-readline; };
|
||||
dependencies = { module=all-gdb; on=all-build-bison; };
|
||||
dependencies = { module=all-gdb; on=all-build-byacc; };
|
||||
dependencies = { module=all-gdb; on=all-sim; };
|
||||
dependencies = { module=all-gdb; on=all-libdecnumber; };
|
||||
|
||||
dependencies = { module=configure-libgui; on=configure-tcl; };
|
||||
dependencies = { module=configure-libgui; on=configure-tk; };
|
||||
dependencies = { module=all-libgui; on=all-tcl; };
|
||||
dependencies = { module=all-libgui; on=all-tk; };
|
||||
dependencies = { module=all-libgui; on=all-itcl; };
|
||||
|
||||
// Host modules specific to binutils.
|
||||
dependencies = { module=configure-bfd; on=configure-libiberty; hard=true; };
|
||||
dependencies = { module=configure-bfd; on=configure-intl; };
|
||||
dependencies = { module=all-bfd; on=all-libiberty; };
|
||||
dependencies = { module=all-bfd; on=all-intl; };
|
||||
|
||||
dependencies = { module=configure-binutils; on=configure-intl; };
|
||||
dependencies = { module=all-binutils; on=all-libiberty; };
|
||||
dependencies = { module=all-binutils; on=all-opcodes; };
|
||||
dependencies = { module=all-binutils; on=all-bfd; };
|
||||
dependencies = { module=all-binutils; on=all-build-flex; };
|
||||
dependencies = { module=all-binutils; on=all-build-bison; };
|
||||
dependencies = { module=all-binutils; on=all-build-byacc; };
|
||||
dependencies = { module=all-binutils; on=all-intl; };
|
||||
|
||||
// We put install-opcodes before install-binutils because the installed
|
||||
// binutils might be on PATH, and they might need the shared opcodes
|
||||
// library.
|
||||
dependencies = { module=install-binutils; on=install-opcodes; };
|
||||
|
||||
// libopcodes depends on libbfd
|
||||
dependencies = { module=install-opcodes; on=install-bfd; };
|
||||
|
||||
dependencies = { module=configure-gas; on=configure-intl; };
|
||||
dependencies = { module=all-gas; on=all-libiberty; };
|
||||
dependencies = { module=all-gas; on=all-opcodes; };
|
||||
dependencies = { module=all-gas; on=all-bfd; };
|
||||
dependencies = { module=all-gas; on=all-intl; };
|
||||
dependencies = { module=configure-gprof; on=configure-intl; };
|
||||
dependencies = { module=all-gprof; on=all-libiberty; };
|
||||
dependencies = { module=all-gprof; on=all-bfd; };
|
||||
dependencies = { module=all-gprof; on=all-opcodes; };
|
||||
dependencies = { module=all-gprof; on=all-intl; };
|
||||
dependencies = { module=configure-ld; on=configure-intl; };
|
||||
dependencies = { module=all-ld; on=all-libiberty; };
|
||||
dependencies = { module=all-ld; on=all-bfd; };
|
||||
dependencies = { module=all-ld; on=all-opcodes; };
|
||||
dependencies = { module=all-ld; on=all-build-bison; };
|
||||
dependencies = { module=all-ld; on=all-build-byacc; };
|
||||
dependencies = { module=all-ld; on=all-build-flex; };
|
||||
dependencies = { module=all-ld; on=all-intl; };
|
||||
dependencies = { module=configure-gold; on=configure-intl; };
|
||||
dependencies = { module=all-gold; on=all-libiberty; };
|
||||
dependencies = { module=all-gold; on=all-intl; };
|
||||
dependencies = { module=all-gold; on=all-bfd; };
|
||||
dependencies = { module=all-gold; on=all-build-bison; };
|
||||
dependencies = { module=all-gold; on=all-build-byacc; };
|
||||
dependencies = { module=check-gold; on=all-binutils; };
|
||||
|
||||
dependencies = { module=configure-opcodes; on=configure-intl; };
|
||||
dependencies = { module=all-opcodes; on=all-bfd; };
|
||||
dependencies = { module=all-opcodes; on=all-libiberty; };
|
||||
dependencies = { module=all-opcodes; on=all-intl; };
|
||||
|
||||
// Other host modules in the 'src' repository.
|
||||
dependencies = { module=all-dejagnu; on=all-tcl; };
|
||||
dependencies = { module=all-dejagnu; on=all-expect; };
|
||||
dependencies = { module=all-dejagnu; on=all-tk; };
|
||||
dependencies = { module=configure-expect; on=configure-tcl; };
|
||||
dependencies = { module=configure-expect; on=configure-tk; };
|
||||
dependencies = { module=all-expect; on=all-tcl; };
|
||||
dependencies = { module=all-expect; on=all-tk; };
|
||||
|
||||
// We put install-tcl before install-itcl because itcl wants to run a
|
||||
// program on installation which uses the Tcl libraries.
|
||||
dependencies = { module=configure-itcl; on=configure-tcl; };
|
||||
dependencies = { module=configure-itcl; on=configure-tk; };
|
||||
dependencies = { module=all-itcl; on=all-tcl; };
|
||||
dependencies = { module=all-itcl; on=all-tk; };
|
||||
dependencies = { module=install-itcl; on=install-tcl; };
|
||||
|
||||
dependencies = { module=configure-tk; on=configure-tcl; };
|
||||
dependencies = { module=all-tk; on=all-tcl; };
|
||||
|
||||
dependencies = { module=all-sid; on=all-libiberty; };
|
||||
dependencies = { module=all-sid; on=all-bfd; };
|
||||
dependencies = { module=all-sid; on=all-opcodes; };
|
||||
dependencies = { module=all-sid; on=all-tcl; };
|
||||
dependencies = { module=all-sid; on=all-tk; };
|
||||
dependencies = { module=install-sid; on=install-tcl; };
|
||||
dependencies = { module=install-sid; on=install-tk; };
|
||||
|
||||
dependencies = { module=configure-sim; on=configure-intl; };
|
||||
dependencies = { module=all-sim; on=all-intl; };
|
||||
dependencies = { module=all-sim; on=all-libiberty; };
|
||||
dependencies = { module=all-sim; on=all-bfd; };
|
||||
dependencies = { module=all-sim; on=all-opcodes; };
|
||||
dependencies = { module=all-sim; on=all-readline; };
|
||||
dependencies = { module=all-sim; on=configure-gdb; };
|
||||
|
||||
// Other host modules.
|
||||
dependencies = { module=all-fastjar; on=all-zlib; };
|
||||
dependencies = { module=all-fastjar; on=all-build-texinfo; };
|
||||
dependencies = { module=all-fastjar; on=all-libiberty; };
|
||||
|
||||
// Warning, these are not well tested.
|
||||
dependencies = { module=all-autoconf; on=all-m4; };
|
||||
dependencies = { module=all-autoconf; on=all-build-texinfo; };
|
||||
dependencies = { module=all-automake; on=all-m4; };
|
||||
dependencies = { module=all-automake; on=all-build-texinfo; };
|
||||
dependencies = { module=all-automake; on=all-autoconf; };
|
||||
dependencies = { module=all-bison; on=all-intl; };
|
||||
dependencies = { module=all-bison; on=all-build-texinfo; };
|
||||
dependencies = { module=all-diff; on=all-intl; };
|
||||
dependencies = { module=all-diff; on=all-build-texinfo; };
|
||||
dependencies = { module=all-fileutils; on=all-intl; };
|
||||
dependencies = { module=all-fileutils; on=all-build-texinfo; };
|
||||
dependencies = { module=all-flex; on=all-build-bison; };
|
||||
dependencies = { module=all-flex; on=all-build-byacc; };
|
||||
dependencies = { module=all-flex; on=all-intl; };
|
||||
dependencies = { module=all-flex; on=all-m4; };
|
||||
dependencies = { module=all-flex; on=all-build-texinfo; };
|
||||
dependencies = { module=all-gzip; on=all-intl; };
|
||||
dependencies = { module=all-gzip; on=all-zlib; };
|
||||
dependencies = { module=all-gzip; on=all-build-texinfo; };
|
||||
dependencies = { module=all-hello; on=all-intl; };
|
||||
dependencies = { module=all-hello; on=all-build-texinfo; };
|
||||
dependencies = { module=all-m4; on=all-intl; };
|
||||
dependencies = { module=all-m4; on=all-build-texinfo; };
|
||||
dependencies = { module=all-make; on=all-intl; };
|
||||
dependencies = { module=all-make; on=all-build-texinfo; };
|
||||
dependencies = { module=all-patch; on=all-build-texinfo; };
|
||||
dependencies = { module=all-make; on=all-build-texinfo; };
|
||||
dependencies = { module=all-prms; on=all-libiberty; };
|
||||
dependencies = { module=all-recode; on=all-build-texinfo; };
|
||||
dependencies = { module=all-sed; on=all-build-texinfo; };
|
||||
dependencies = { module=all-send-pr; on=all-prms; };
|
||||
dependencies = { module=all-tar; on=all-build-texinfo; };
|
||||
dependencies = { module=all-uudecode; on=all-build-texinfo; };
|
||||
|
||||
// Target modules. These can also have dependencies on the language
|
||||
// environment (e.g. on libstdc++). By default target modules depend
|
||||
// on libgcc and newlib/libgloss.
|
||||
lang_env_dependencies = { module=gperf; cxx=true; };
|
||||
lang_env_dependencies = { module=libjava; cxx=true; };
|
||||
lang_env_dependencies = { module=newlib; no_c=true; };
|
||||
lang_env_dependencies = { module=libgloss; no_c=true; };
|
||||
lang_env_dependencies = { module=libgcc; no_gcc=true; no_c=true; };
|
||||
// libiberty does not depend on newlib or libgloss because it must be
|
||||
// built newlib on some targets (e.g. Cygwin). It still needs
|
||||
// a dependency on libgcc for native targets to configure.
|
||||
lang_env_dependencies = { module=libiberty; no_c=true; };
|
||||
|
||||
dependencies = { module=configure-target-boehm-gc; on=configure-target-qthreads; };
|
||||
dependencies = { module=configure-target-fastjar; on=configure-target-zlib; };
|
||||
dependencies = { module=all-target-fastjar; on=all-target-zlib; };
|
||||
dependencies = { module=all-target-fastjar; on=all-target-libiberty; };
|
||||
dependencies = { module=configure-target-libjava; on=configure-target-zlib; };
|
||||
dependencies = { module=configure-target-libjava; on=configure-target-boehm-gc; };
|
||||
dependencies = { module=configure-target-libjava; on=configure-target-qthreads; };
|
||||
dependencies = { module=configure-target-libjava; on=configure-target-libffi; };
|
||||
dependencies = { module=all-target-libjava; on=all-fastjar; };
|
||||
dependencies = { module=all-target-libjava; on=all-target-zlib; };
|
||||
dependencies = { module=all-target-libjava; on=all-target-boehm-gc; };
|
||||
dependencies = { module=all-target-libjava; on=all-target-qthreads; };
|
||||
dependencies = { module=all-target-libjava; on=all-target-libffi; };
|
||||
dependencies = { module=configure-target-libobjc; on=configure-target-boehm-gc; };
|
||||
dependencies = { module=all-target-libobjc; on=all-target-libiberty; };
|
||||
dependencies = { module=all-target-libobjc; on=all-target-boehm-gc; };
|
||||
dependencies = { module=all-target-libstdc++-v3; on=all-target-libiberty; };
|
||||
dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
|
||||
|
||||
// Target modules in the 'src' repository.
|
||||
lang_env_dependencies = { module=examples; };
|
||||
lang_env_dependencies = { module=libtermcap; };
|
||||
lang_env_dependencies = { module=rda; };
|
||||
lang_env_dependencies = { module=winsup; };
|
||||
lang_env_dependencies = { module=qthreads; };
|
||||
|
||||
dependencies = { module=all-target-libgloss; on=all-target-newlib; };
|
||||
dependencies = { module=all-target-winsup; on=all-target-libiberty; };
|
||||
dependencies = { module=all-target-winsup; on=all-target-libtermcap; };
|
||||
|
||||
// Toplevel bootstrap
|
||||
bootstrap_stage = {
|
||||
id=1 ;
|
||||
|
||||
// * We force-disable intermodule optimizations, even if
|
||||
// --enable-intermodule was passed, since the installed compiler
|
||||
// probably can't handle them. Luckily, autoconf always respects
|
||||
// the last argument when conflicting --enable arguments are passed.
|
||||
// * Likewise, we force-disable coverage flags, since the installed
|
||||
// compiler probably has never heard of them.
|
||||
stage_configure_flags='--disable-intermodule $(STAGE1_CHECKING) \
|
||||
--disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"' ;
|
||||
stage_cflags='$(STAGE1_CFLAGS)' ;
|
||||
stage_libcflags='$(STAGE1_LIBCFLAGS)' ; };
|
||||
bootstrap_stage = {
|
||||
id=2 ; prev=1 ;
|
||||
bootstrap_target=bootstrap2 ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags="$(STAGE2_CFLAGS)" ;
|
||||
stage_libcflags="$(STAGE2_LIBCFLAGS)" ; };
|
||||
bootstrap_stage = {
|
||||
id=b2g0 ; prev=1 ;
|
||||
bootstrap_target=bootstrap2-debug ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags="$(STAGE2_CFLAGS) -g0" ;
|
||||
stage_libcflags="$(STAGE2_LIBCFLAGS) -g0" ; };
|
||||
bootstrap_stage = {
|
||||
id=3 ; prev=2 ; lean=1 ;
|
||||
compare_target=compare ;
|
||||
bootstrap_target=bootstrap ;
|
||||
cleanstrap_target=cleanstrap ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags="$(STAGE3_CFLAGS)" ;
|
||||
stage_libcflags="$(STAGE3_LIBCFLAGS)" ; };
|
||||
bootstrap_stage = {
|
||||
id=b3g2 ; prev=b2g0 ; lean=1 ;
|
||||
compare_target=compare-debug ;
|
||||
bootstrap_target=bootstrap-debug ;
|
||||
cleanstrap_target=cleanstrap-debug ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags="$(STAGE3_CFLAGS) -g2" ;
|
||||
stage_libcflags="$(STAGE3_LIBCFLAGS) -g2" ; };
|
||||
bootstrap_stage = {
|
||||
id=4 ; prev=3 ; lean=2 ;
|
||||
compare_target=compare3 ;
|
||||
bootstrap_target=bootstrap4 ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags="$(STAGE4_CFLAGS)" ;
|
||||
stage_libcflags="$(STAGE4_CFLAGS)" ; };
|
||||
bootstrap_stage = {
|
||||
id=profile ; prev=1 ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags='$(STAGE2_CFLAGS) -fprofile-generate' ;
|
||||
stage_libcflags='$(STAGE2_LIBCFLAGS)' ; };
|
||||
bootstrap_stage = {
|
||||
id=feedback ; prev=profile ;
|
||||
bootstrap_target=profiledbootstrap ;
|
||||
stage_configure_flags="@stage2_werror_flag@" ;
|
||||
stage_cflags='$(STAGE3_CFLAGS) -fprofile-use' ;
|
||||
stage_libcflags='$(STAGE3_LIBCFLAGS) -fprofile-use' ; };
|
53629
external/gpl3/binutils/dist/Makefile.in
vendored
Normal file
53629
external/gpl3/binutils/dist/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1672
external/gpl3/binutils/dist/Makefile.tpl
vendored
Normal file
1672
external/gpl3/binutils/dist/Makefile.tpl
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
external/gpl3/binutils/dist/README
vendored
Normal file
47
external/gpl3/binutils/dist/README
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
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 binutils release, see binutils/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
|
||||
|
||||
A similar example using csh:
|
||||
|
||||
setenv CC gcc
|
||||
./configure
|
||||
make
|
||||
|
||||
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, binutils/README, etc., for info
|
||||
on where and how to report problems.
|
14
external/gpl3/binutils/dist/README-maintainer-mode
vendored
Normal file
14
external/gpl3/binutils/dist/README-maintainer-mode
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
Notes on enabling maintainer mode
|
||||
|
||||
Note that if you configure with --enable-maintainer-mode, you will need
|
||||
special versions of automake, autoconf, libtool and gettext. You will
|
||||
find the sources for these in ftp://sources.redhat.com/pub/binutils.
|
||||
|
||||
Note - "make distclean" does not work with maintainer mode enabled.
|
||||
The Makefiles in the some of the po/ subdirectories depend upon the
|
||||
Makefiles in their parent directories, and distclean will delete the
|
||||
Makefiles in the parent directories before running the Makefiles in
|
||||
the child directories. There is no easy way around this (short of
|
||||
changing the automake macros) as these dependencies need to exist in
|
||||
order to correctly build the NLS files.
|
674
external/gpl3/binutils/dist/bfd/COPYING
vendored
Normal file
674
external/gpl3/binutils/dist/bfd/COPYING
vendored
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
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
|
||||
state 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) <year> <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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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 Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
2658
external/gpl3/binutils/dist/bfd/ChangeLog
vendored
Normal file
2658
external/gpl3/binutils/dist/bfd/ChangeLog
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9592
external/gpl3/binutils/dist/bfd/ChangeLog-0001
vendored
Normal file
9592
external/gpl3/binutils/dist/bfd/ChangeLog-0001
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11405
external/gpl3/binutils/dist/bfd/ChangeLog-0203
vendored
Normal file
11405
external/gpl3/binutils/dist/bfd/ChangeLog-0203
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5063
external/gpl3/binutils/dist/bfd/ChangeLog-2004
vendored
Normal file
5063
external/gpl3/binutils/dist/bfd/ChangeLog-2004
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5269
external/gpl3/binutils/dist/bfd/ChangeLog-2005
vendored
Normal file
5269
external/gpl3/binutils/dist/bfd/ChangeLog-2005
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3601
external/gpl3/binutils/dist/bfd/ChangeLog-2006
vendored
Normal file
3601
external/gpl3/binutils/dist/bfd/ChangeLog-2006
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3561
external/gpl3/binutils/dist/bfd/ChangeLog-2007
vendored
Normal file
3561
external/gpl3/binutils/dist/bfd/ChangeLog-2007
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7848
external/gpl3/binutils/dist/bfd/ChangeLog-9193
vendored
Normal file
7848
external/gpl3/binutils/dist/bfd/ChangeLog-9193
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10043
external/gpl3/binutils/dist/bfd/ChangeLog-9495
vendored
Normal file
10043
external/gpl3/binutils/dist/bfd/ChangeLog-9495
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6729
external/gpl3/binutils/dist/bfd/ChangeLog-9697
vendored
Normal file
6729
external/gpl3/binutils/dist/bfd/ChangeLog-9697
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5599
external/gpl3/binutils/dist/bfd/ChangeLog-9899
vendored
Normal file
5599
external/gpl3/binutils/dist/bfd/ChangeLog-9899
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
external/gpl3/binutils/dist/bfd/MAINTAINERS
vendored
Normal file
1
external/gpl3/binutils/dist/bfd/MAINTAINERS
vendored
Normal file
@ -0,0 +1 @@
|
||||
See ../binutils/MAINTAINERS
|
1997
external/gpl3/binutils/dist/bfd/Makefile.am
vendored
Normal file
1997
external/gpl3/binutils/dist/bfd/Makefile.am
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2584
external/gpl3/binutils/dist/bfd/Makefile.in
vendored
Normal file
2584
external/gpl3/binutils/dist/bfd/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
external/gpl3/binutils/dist/bfd/PORTING
vendored
Normal file
83
external/gpl3/binutils/dist/bfd/PORTING
vendored
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>"
|
49
external/gpl3/binutils/dist/bfd/README
vendored
Normal file
49
external/gpl3/binutils/dist/bfd/README
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
BFD is an object file library. It permits applications to use the
|
||||
same routines to process object files regardless of their format.
|
||||
|
||||
BFD is used by the GNU debugger, assembler, linker, and the binary
|
||||
utilities.
|
||||
|
||||
The documentation on using BFD is scanty and may be occasionally
|
||||
incorrect. Pointers to documentation problems, or an entirely
|
||||
rewritten manual, would be appreciated.
|
||||
|
||||
There is some BFD internals documentation in doc/bfdint.texi which may
|
||||
help programmers who want to modify BFD.
|
||||
|
||||
BFD is normally built as part of another package. See the build
|
||||
instructions for that package, probably in a README file in the
|
||||
appropriate directory.
|
||||
|
||||
BFD supports the following configure options:
|
||||
|
||||
--target=TARGET
|
||||
The default target for which to build the library. TARGET is
|
||||
a configuration target triplet, such as sparc-sun-solaris.
|
||||
--enable-targets=TARGET,TARGET,TARGET...
|
||||
Additional targets the library should support. To include
|
||||
support for all known targets, use --enable-targets=all.
|
||||
--enable-64-bit-bfd
|
||||
Include support for 64 bit targets. This is automatically
|
||||
turned on if you explicitly request a 64 bit target, but not
|
||||
for --enable-targets=all. This requires a compiler with a 64
|
||||
bit integer type, such as gcc.
|
||||
--enable-shared
|
||||
Build BFD as a shared library.
|
||||
--with-mmap
|
||||
Use mmap when accessing files. This is faster on some hosts,
|
||||
but slower on others. It may not work on all hosts.
|
||||
|
||||
Report bugs with BFD to bug-binutils@gnu.org.
|
||||
|
||||
Patches are encouraged. When sending patches, always send the output
|
||||
of diff -u or diff -c from the original file to the new file. Do not
|
||||
send default diff output. Do not make the diff from the new file to
|
||||
the original file. Remember that any patch must not break other
|
||||
systems. Remember that BFD must support cross compilation from any
|
||||
host to any target, so patches which use ``#ifdef HOST'' are not
|
||||
acceptable. Please also read the ``Reporting Bugs'' section of the
|
||||
gcc manual.
|
||||
|
||||
Bug reports without patches will be remembered, but they may never get
|
||||
fixed until somebody volunteers to fix them.
|
25
external/gpl3/binutils/dist/bfd/TODO
vendored
Normal file
25
external/gpl3/binutils/dist/bfd/TODO
vendored
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 unneeded 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.
|
||||
|
||||
|
||||
|
||||
|
69
external/gpl3/binutils/dist/bfd/acinclude.m4
vendored
Normal file
69
external/gpl3/binutils/dist/bfd/acinclude.m4
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
|
||||
AC_DEFUN([BFD_BINARY_FOPEN],
|
||||
[AC_REQUIRE([AC_CANONICAL_TARGET])
|
||||
case "${host}" in
|
||||
changequote(,)dnl
|
||||
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||
changequote([,])dnl
|
||||
AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
|
||||
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.
|
||||
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)
|
||||
# Also set EXEEXT_FOR_BUILD.
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
EXEEXT_FOR_BUILD='$(EXEEXT)'
|
||||
else
|
||||
AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
|
||||
[rm -f conftest*
|
||||
echo 'int main () { return 0; }' > conftest.c
|
||||
bfd_cv_build_exeext=
|
||||
${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
|
||||
for file in conftest.*; do
|
||||
case $file in
|
||||
*.c | *.o | *.obj | *.ilk | *.pdb) ;;
|
||||
*) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
|
||||
esac
|
||||
done
|
||||
rm -f conftest*
|
||||
test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
|
||||
EXEEXT_FOR_BUILD=""
|
||||
test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
|
||||
fi
|
||||
AC_SUBST(EXEEXT_FOR_BUILD)])dnl
|
||||
|
||||
AC_DEFUN([AM_INSTALL_LIBBFD],
|
||||
[AC_MSG_CHECKING([whether to install libbfd])
|
||||
AC_ARG_ENABLE(install-libbfd,
|
||||
[ --enable-install-libbfd controls installation of libbfd and related headers],
|
||||
install_libbfd_p=$enableval,
|
||||
if test "${host}" = "${target}" || test "$enable_shared" = "yes"; then
|
||||
install_libbfd_p=yes
|
||||
else
|
||||
install_libbfd_p=no
|
||||
fi)
|
||||
AC_MSG_RESULT($install_libbfd_p)
|
||||
AM_CONDITIONAL(INSTALL_LIBBFD, test $install_libbfd_p = yes)
|
||||
# Need _noncanonical variables for this.
|
||||
ACX_NONCANONICAL_HOST
|
||||
ACX_NONCANONICAL_TARGET
|
||||
# libbfd.a is a host library containing target dependent code
|
||||
bfdlibdir='$(libdir)'
|
||||
bfdincludedir='$(includedir)'
|
||||
if test "${host}" != "${target}"; then
|
||||
bfdlibdir='$(exec_prefix)/$(host_noncanonical)/$(target_noncanonical)/lib'
|
||||
bfdincludedir='$(exec_prefix)/$(host_noncanonical)/$(target_noncanonical)/include'
|
||||
fi
|
||||
AC_SUBST(bfdlibdir)
|
||||
AC_SUBST(bfdincludedir)
|
||||
]
|
||||
)
|
876
external/gpl3/binutils/dist/bfd/aclocal.m4
vendored
Normal file
876
external/gpl3/binutils/dist/bfd/aclocal.m4
vendored
Normal file
@ -0,0 +1,876 @@
|
||||
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_AUTOMAKE_VERSION(VERSION)
|
||||
# ----------------------------
|
||||
# Automake X.Y traces this macro to ensure aclocal.m4 has been
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
|
||||
|
||||
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||
# -------------------------------
|
||||
# Call AM_AUTOMAKE_VERSION so it can be traced.
|
||||
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.9.6])])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
|
||||
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
|
||||
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
|
||||
#
|
||||
# Of course, Automake must honor this variable whenever it calls a
|
||||
# tool from the auxiliary directory. The problem is that $srcdir (and
|
||||
# therefore $ac_aux_dir as well) can be either absolute or relative,
|
||||
# depending on how configure is run. This is pretty annoying, since
|
||||
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
|
||||
# source directory, any form will work fine, but in subdirectories a
|
||||
# relative path needs to be adjusted first.
|
||||
#
|
||||
# $ac_aux_dir/missing
|
||||
# fails when called from a subdirectory if $ac_aux_dir is relative
|
||||
# $top_srcdir/$ac_aux_dir/missing
|
||||
# fails if $ac_aux_dir is absolute,
|
||||
# fails when called from a subdirectory in a VPATH build with
|
||||
# a relative $ac_aux_dir
|
||||
#
|
||||
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
|
||||
# are both prefixed by $srcdir. In an in-source build this is usually
|
||||
# harmless because $srcdir is `.', but things will broke when you
|
||||
# start a VPATH build or use an absolute $srcdir.
|
||||
#
|
||||
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
|
||||
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
|
||||
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
|
||||
# and then we would define $MISSING as
|
||||
# MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
# This will work as long as MISSING is not called from configure, because
|
||||
# unfortunately $(top_srcdir) has no meaning in configure.
|
||||
# However there are other variables, like CC, which are often used in
|
||||
# configure, and could therefore not use this "fixed" $ac_aux_dir.
|
||||
#
|
||||
# Another solution, used here, is to always expand $ac_aux_dir to an
|
||||
# absolute PATH. The drawback is that using absolute paths prevent a
|
||||
# configured tree to be moved without reconfiguration.
|
||||
|
||||
AC_DEFUN([AM_AUX_DIR_EXPAND],
|
||||
[dnl Rely on autoconf to set up CDPATH properly.
|
||||
AC_PREREQ([2.50])dnl
|
||||
# expand $ac_aux_dir to an absolute path
|
||||
am_aux_dir=`cd $ac_aux_dir && pwd`
|
||||
])
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 7
|
||||
|
||||
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||
# -------------------------------------
|
||||
# Define a conditional.
|
||||
AC_DEFUN([AM_CONDITIONAL],
|
||||
[AC_PREREQ(2.52)dnl
|
||||
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
|
||||
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
|
||||
AC_SUBST([$1_TRUE])
|
||||
AC_SUBST([$1_FALSE])
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi
|
||||
AC_CONFIG_COMMANDS_PRE(
|
||||
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
|
||||
AC_MSG_ERROR([[conditional "$1" was never defined.
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 8
|
||||
|
||||
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
|
||||
# written in clear, in which case automake, when reading aclocal.m4,
|
||||
# will think it sees a *use*, and therefore will trigger all it's
|
||||
# C support machinery. Also note that it means that autoscan, seeing
|
||||
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
|
||||
|
||||
|
||||
# _AM_DEPENDENCIES(NAME)
|
||||
# ----------------------
|
||||
# See how the compiler implements dependency checking.
|
||||
# NAME is "CC", "CXX", "GCJ", or "OBJC".
|
||||
# We try a few techniques and use that to set a single cache variable.
|
||||
#
|
||||
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
|
||||
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
|
||||
# dependency, and given that the user is not expected to run this macro,
|
||||
# just rely on AC_PROG_CC.
|
||||
AC_DEFUN([_AM_DEPENDENCIES],
|
||||
[AC_REQUIRE([AM_SET_DEPDIR])dnl
|
||||
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
|
||||
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
|
||||
AC_REQUIRE([AM_DEP_TRACK])dnl
|
||||
|
||||
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
|
||||
[$1], CXX, [depcc="$CXX" am_compiler_list=],
|
||||
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
|
||||
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
|
||||
[depcc="$$1" am_compiler_list=])
|
||||
|
||||
AC_CACHE_CHECK([dependency style of $depcc],
|
||||
[am_cv_$1_dependencies_compiler_type],
|
||||
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
|
||||
# We make a subdir and do the tests there. Otherwise we can end up
|
||||
# making bogus files that we don't know about and never remove. For
|
||||
# instance it was reported that on HP-UX the gcc test will end up
|
||||
# making a dummy file named `D' -- because `-MD' means `put the output
|
||||
# in D'.
|
||||
mkdir conftest.dir
|
||||
# Copy depcomp to subdir because otherwise we won't find it if we're
|
||||
# using a relative directory.
|
||||
cp "$am_depcomp" conftest.dir
|
||||
cd conftest.dir
|
||||
# We will build objects and dependencies in a subdirectory because
|
||||
# it helps to detect inapplicable dependency modes. For instance
|
||||
# both Tru64's cc and ICC support -MD to output dependencies as a
|
||||
# side effect of compilation, but ICC will put the dependencies in
|
||||
# the current directory while Tru64 will put them in the object
|
||||
# directory.
|
||||
mkdir sub
|
||||
|
||||
am_cv_$1_dependencies_compiler_type=none
|
||||
if test "$am_compiler_list" = ""; then
|
||||
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
|
||||
fi
|
||||
for depmode in $am_compiler_list; do
|
||||
# Setup a source with many dependencies, because some compilers
|
||||
# like to wrap large dependency lists on column 80 (with \), and
|
||||
# we should not choose a depcomp mode which is confused by this.
|
||||
#
|
||||
# We need to recreate these files for each test, as the compiler may
|
||||
# overwrite some of them when testing with obscure command lines.
|
||||
# This happens at least with the AIX C compiler.
|
||||
: > sub/conftest.c
|
||||
for i in 1 2 3 4 5 6; do
|
||||
echo '#include "conftst'$i'.h"' >> sub/conftest.c
|
||||
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
|
||||
# Solaris 8's {/usr,}/bin/sh.
|
||||
touch sub/conftst$i.h
|
||||
done
|
||||
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
|
||||
|
||||
case $depmode in
|
||||
nosideeffect)
|
||||
# after this tag, mechanisms are not by side-effect, so they'll
|
||||
# only be used when explicitly requested
|
||||
if test "x$enable_dependency_tracking" = xyes; then
|
||||
continue
|
||||
else
|
||||
break
|
||||
fi
|
||||
;;
|
||||
none) break ;;
|
||||
esac
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this.
|
||||
if depmode=$depmode \
|
||||
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
|
||||
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
|
||||
>/dev/null 2>conftest.err &&
|
||||
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
|
||||
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||
# icc doesn't choke on unknown options, it will just issue warnings
|
||||
# or remarks (even with -Werror). So we grep stderr for any message
|
||||
# that says an option was ignored or not supported.
|
||||
# When given -MP, icc 7.0 and 7.1 complain thusly:
|
||||
# icc: Command line warning: ignoring option '-M'; no argument required
|
||||
# The diagnosis changed in icc 8.0:
|
||||
# icc: Command line remark: option '-MP' not supported
|
||||
if (grep 'ignoring option' conftest.err ||
|
||||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
|
||||
am_cv_$1_dependencies_compiler_type=$depmode
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
||||
rm -rf conftest.dir
|
||||
else
|
||||
am_cv_$1_dependencies_compiler_type=none
|
||||
fi
|
||||
])
|
||||
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
|
||||
AM_CONDITIONAL([am__fastdep$1], [
|
||||
test "x$enable_dependency_tracking" != xno \
|
||||
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
|
||||
])
|
||||
|
||||
|
||||
# AM_SET_DEPDIR
|
||||
# -------------
|
||||
# Choose a directory name for dependency files.
|
||||
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
|
||||
AC_DEFUN([AM_SET_DEPDIR],
|
||||
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
|
||||
])
|
||||
|
||||
|
||||
# AM_DEP_TRACK
|
||||
# ------------
|
||||
AC_DEFUN([AM_DEP_TRACK],
|
||||
[AC_ARG_ENABLE(dependency-tracking,
|
||||
[ --disable-dependency-tracking speeds up one-time build
|
||||
--enable-dependency-tracking do not reject slow dependency extractors])
|
||||
if test "x$enable_dependency_tracking" != xno; then
|
||||
am_depcomp="$ac_aux_dir/depcomp"
|
||||
AMDEPBACKSLASH='\'
|
||||
fi
|
||||
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
|
||||
AC_SUBST([AMDEPBACKSLASH])
|
||||
])
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
#serial 3
|
||||
|
||||
# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# ------------------------------
|
||||
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[for mf in $CONFIG_FILES; do
|
||||
# Strip MF so we end up with the name of the file.
|
||||
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile or not.
|
||||
# We used to match only the files named `Makefile.in', but
|
||||
# some people rename them; so instead we look at the file content.
|
||||
# Grep'ing the first line is not enough: some people post-process
|
||||
# each Makefile.in and add a new line on top of each file to say so.
|
||||
# So let's grep whole file.
|
||||
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
|
||||
dirpart=`AS_DIRNAME("$mf")`
|
||||
else
|
||||
continue
|
||||
fi
|
||||
# Extract the definition of DEPDIR, am__include, and am__quote
|
||||
# from the Makefile without running `make'.
|
||||
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
|
||||
test -z "$DEPDIR" && continue
|
||||
am__include=`sed -n 's/^am__include = //p' < "$mf"`
|
||||
test -z "am__include" && continue
|
||||
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
|
||||
# When using ansi2knr, U may be empty or an underscore; expand it
|
||||
U=`sed -n 's/^U = //p' < "$mf"`
|
||||
# Find all dependency output files, they are included files with
|
||||
# $(DEPDIR) in their names. We invoke sed twice because it is the
|
||||
# simplest approach to changing $(DEPDIR) to its actual value in the
|
||||
# expansion.
|
||||
for file in `sed -n "
|
||||
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
|
||||
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
|
||||
# Make sure the directory exists.
|
||||
test -f "$dirpart/$file" && continue
|
||||
fdir=`AS_DIRNAME(["$file"])`
|
||||
AS_MKDIR_P([$dirpart/$fdir])
|
||||
# echo "creating $dirpart/$file"
|
||||
echo '# dummy' > "$dirpart/$file"
|
||||
done
|
||||
done
|
||||
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
|
||||
|
||||
# AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# -----------------------------
|
||||
# This macro should only be invoked once -- use via AC_REQUIRE.
|
||||
#
|
||||
# This code is only required when automatic dependency tracking
|
||||
# is enabled. FIXME. This creates each `.P' file that we will
|
||||
# need in order to bootstrap the dependency handling code.
|
||||
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AC_CONFIG_COMMANDS([depfiles],
|
||||
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
|
||||
])
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 12
|
||||
|
||||
# This macro actually does too much. Some checks are only needed if
|
||||
# your package does certain things. But this isn't really a big deal.
|
||||
|
||||
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
|
||||
# AM_INIT_AUTOMAKE([OPTIONS])
|
||||
# -----------------------------------------------
|
||||
# The call with PACKAGE and VERSION arguments is the old style
|
||||
# call (pre autoconf-2.50), which is being phased out. PACKAGE
|
||||
# and VERSION should now be passed to AC_INIT and removed from
|
||||
# the call to AM_INIT_AUTOMAKE.
|
||||
# We support both call styles for the transition. After
|
||||
# the next Automake release, Autoconf can make the AC_INIT
|
||||
# arguments mandatory, and then we can depend on a new Autoconf
|
||||
# release and drop the old call support.
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_PREREQ([2.58])dnl
|
||||
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||
dnl the ones we care about.
|
||||
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
|
||||
AC_REQUIRE([AC_PROG_INSTALL])dnl
|
||||
# test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" &&
|
||||
test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
|
||||
# test whether we have cygpath
|
||||
if test -z "$CYGPATH_W"; then
|
||||
if (cygpath --version) >/dev/null 2>/dev/null; then
|
||||
CYGPATH_W='cygpath -w'
|
||||
else
|
||||
CYGPATH_W=echo
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([CYGPATH_W])
|
||||
|
||||
# Define the identity of the package.
|
||||
dnl Distinguish between old-style and new-style calls.
|
||||
m4_ifval([$2],
|
||||
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||
AC_SUBST([PACKAGE], [$1])dnl
|
||||
AC_SUBST([VERSION], [$2])],
|
||||
[_AM_SET_OPTIONS([$1])dnl
|
||||
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
|
||||
|
||||
_AM_IF_OPTION([no-define],,
|
||||
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
|
||||
|
||||
# Some tools Automake needs.
|
||||
AC_REQUIRE([AM_SANITY_CHECK])dnl
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])dnl
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo)
|
||||
AM_PROG_INSTALL_SH
|
||||
AM_PROG_INSTALL_STRIP
|
||||
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
|
||||
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||
[_AM_PROG_TAR([v7])])])
|
||||
_AM_IF_OPTION([no-dependencies],,
|
||||
[AC_PROVIDE_IFELSE([AC_PROG_CC],
|
||||
[_AM_DEPENDENCIES(CC)],
|
||||
[define([AC_PROG_CC],
|
||||
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
|
||||
AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
||||
[_AM_DEPENDENCIES(CXX)],
|
||||
[define([AC_PROG_CXX],
|
||||
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
# When config.status generates a header, we must update the stamp-h file.
|
||||
# This file resides in the same directory as the config header
|
||||
# that is generated. The stamp files are numbered to have different names.
|
||||
|
||||
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
|
||||
# loop where config.status creates the headers, so we can generate
|
||||
# our stamp files there.
|
||||
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
|
||||
[# Compute $1's index in $config_headers.
|
||||
_am_stamp_count=1
|
||||
for _am_header in $config_headers :; do
|
||||
case $_am_header in
|
||||
$1 | $1:* )
|
||||
break ;;
|
||||
* )
|
||||
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
|
||||
esac
|
||||
done
|
||||
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_INSTALL_SH
|
||||
# ------------------
|
||||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
install_sh=${install_sh-"$am_aux_dir/install-sh"}
|
||||
AC_SUBST(install_sh)])
|
||||
|
||||
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||
# From Jim Meyering
|
||||
|
||||
# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
AC_DEFUN([AM_MAINTAINER_MODE],
|
||||
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
dnl maintainer-mode is disabled by default
|
||||
AC_ARG_ENABLE(maintainer-mode,
|
||||
[ --enable-maintainer-mode enable make rules and dependencies not useful
|
||||
(and sometimes confusing) to the casual installer],
|
||||
USE_MAINTAINER_MODE=$enableval,
|
||||
USE_MAINTAINER_MODE=no)
|
||||
AC_MSG_RESULT([$USE_MAINTAINER_MODE])
|
||||
AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
|
||||
MAINT=$MAINTAINER_MODE_TRUE
|
||||
AC_SUBST(MAINT)dnl
|
||||
]
|
||||
)
|
||||
|
||||
AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 3
|
||||
|
||||
# AM_MAKE_INCLUDE()
|
||||
# -----------------
|
||||
# Check to see how make treats includes.
|
||||
AC_DEFUN([AM_MAKE_INCLUDE],
|
||||
[am_make=${MAKE-make}
|
||||
cat > confinc << 'END'
|
||||
am__doit:
|
||||
@echo done
|
||||
.PHONY: am__doit
|
||||
END
|
||||
# If we don't find an include directive, just comment out the code.
|
||||
AC_MSG_CHECKING([for style of include used by $am_make])
|
||||
am__include="#"
|
||||
am__quote=
|
||||
_am_result=none
|
||||
# First try GNU make style include.
|
||||
echo "include confinc" > confmf
|
||||
# We grep out `Entering directory' and `Leaving directory'
|
||||
# messages which can occur if `w' ends up in MAKEFLAGS.
|
||||
# In particular we don't look at `^make:' because GNU make might
|
||||
# be invoked under some other name (usually "gmake"), in which
|
||||
# case it prints its new name instead of `make'.
|
||||
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
|
||||
am__include=include
|
||||
am__quote=
|
||||
_am_result=GNU
|
||||
fi
|
||||
# Now try BSD make style include.
|
||||
if test "$am__include" = "#"; then
|
||||
echo '.include "confinc"' > confmf
|
||||
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
|
||||
am__include=.include
|
||||
am__quote="\""
|
||||
_am_result=BSD
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([am__include])
|
||||
AC_SUBST([am__quote])
|
||||
AC_MSG_RESULT([$_am_result])
|
||||
rm -f confinc confmf
|
||||
])
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||
# ------------------------------
|
||||
AC_DEFUN([AM_MISSING_PROG],
|
||||
[AC_REQUIRE([AM_MISSING_HAS_RUN])
|
||||
$1=${$1-"${am_missing_run}$2"}
|
||||
AC_SUBST($1)])
|
||||
|
||||
|
||||
# AM_MISSING_HAS_RUN
|
||||
# ------------------
|
||||
# Define MISSING if not defined so far and test if it supports --run.
|
||||
# If it does, set am_missing_run to use it, otherwise, to nothing.
|
||||
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --run true"; then
|
||||
am_missing_run="$MISSING --run "
|
||||
else
|
||||
am_missing_run=
|
||||
AC_MSG_WARN([`missing' script is too old or missing])
|
||||
fi
|
||||
])
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_MKDIR_P
|
||||
# ---------------
|
||||
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
|
||||
#
|
||||
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
|
||||
# created by `make install' are always world readable, even if the
|
||||
# installer happens to have an overly restrictive umask (e.g. 077).
|
||||
# This was a mistake. There are at least two reasons why we must not
|
||||
# use `-m 0755':
|
||||
# - it causes special bits like SGID to be ignored,
|
||||
# - it may be too restrictive (some setups expect 775 directories).
|
||||
#
|
||||
# Do not use -m 0755 and let people choose whatever they expect by
|
||||
# setting umask.
|
||||
#
|
||||
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
|
||||
# Some implementations (such as Solaris 8's) are not thread-safe: if a
|
||||
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
|
||||
# concurrently, both version can detect that a/ is missing, but only
|
||||
# one can create it and the other will error out. Consequently we
|
||||
# restrict ourselves to GNU make (using the --version option ensures
|
||||
# this.)
|
||||
AC_DEFUN([AM_PROG_MKDIR_P],
|
||||
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
|
||||
# We used to keeping the `.' as first argument, in order to
|
||||
# allow $(mkdir_p) to be used without argument. As in
|
||||
# $(mkdir_p) $(somedir)
|
||||
# where $(somedir) is conditionally defined. However this is wrong
|
||||
# for two reasons:
|
||||
# 1. if the package is installed by a user who cannot write `.'
|
||||
# make install will fail,
|
||||
# 2. the above comment should most certainly read
|
||||
# $(mkdir_p) $(DESTDIR)$(somedir)
|
||||
# so it does not work when $(somedir) is undefined and
|
||||
# $(DESTDIR) is not.
|
||||
# To support the latter case, we have to write
|
||||
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
|
||||
# so the `.' trick is pointless.
|
||||
mkdir_p='mkdir -p --'
|
||||
else
|
||||
# On NextStep and OpenStep, the `mkdir' command does not
|
||||
# recognize any option. It will interpret all options as
|
||||
# directories to create, and then abort because `.' already
|
||||
# exists.
|
||||
for d in ./-p ./--version;
|
||||
do
|
||||
test -d $d && rmdir $d
|
||||
done
|
||||
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
|
||||
if test -f "$ac_aux_dir/mkinstalldirs"; then
|
||||
mkdir_p='$(mkinstalldirs)'
|
||||
else
|
||||
mkdir_p='$(install_sh) -d'
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([mkdir_p])])
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 3
|
||||
|
||||
# _AM_MANGLE_OPTION(NAME)
|
||||
# -----------------------
|
||||
AC_DEFUN([_AM_MANGLE_OPTION],
|
||||
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
|
||||
|
||||
# _AM_SET_OPTION(NAME)
|
||||
# ------------------------------
|
||||
# Set option NAME. Presently that only means defining a flag for this option.
|
||||
AC_DEFUN([_AM_SET_OPTION],
|
||||
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
|
||||
|
||||
# _AM_SET_OPTIONS(OPTIONS)
|
||||
# ----------------------------------
|
||||
# OPTIONS is a space-separated list of Automake options.
|
||||
AC_DEFUN([_AM_SET_OPTIONS],
|
||||
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||
|
||||
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
|
||||
# -------------------------------------------
|
||||
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
# AM_SANITY_CHECK
|
||||
# ---------------
|
||||
AC_DEFUN([AM_SANITY_CHECK],
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftest.file
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
|
||||
if test "$[*]" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftest.file`
|
||||
fi
|
||||
rm -f conftest.file
|
||||
if test "$[*]" != "X $srcdir/configure conftest.file" \
|
||||
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "$[2]" = conftest.file
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_INSTALL_STRIP
|
||||
# ---------------------
|
||||
# One issue with vendor `install' (even GNU) is that you can't
|
||||
# specify the program used to strip binaries. This is especially
|
||||
# annoying in cross-compiling environments, where the build's strip
|
||||
# is unlikely to handle the host's binaries.
|
||||
# Fortunately install-sh will honor a STRIPPROG variable, so we
|
||||
# always use install-sh in `make install-strip', and initialize
|
||||
# STRIPPROG with the value of the STRIP variable (set by the user).
|
||||
AC_DEFUN([AM_PROG_INSTALL_STRIP],
|
||||
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||
# Installed binaries are usually stripped using `strip' when the user
|
||||
# run `make install-strip'. However `strip' might not be the right
|
||||
# tool to use in cross-compilation environments, therefore Automake
|
||||
# will honor the `STRIP' environment variable to overrule this program.
|
||||
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
|
||||
if test "$cross_compiling" != no; then
|
||||
AC_CHECK_TOOL([STRIP], [strip], :)
|
||||
fi
|
||||
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 2
|
||||
|
||||
# _AM_PROG_TAR(FORMAT)
|
||||
# --------------------
|
||||
# Check how to create a tarball in format FORMAT.
|
||||
# FORMAT should be one of `v7', `ustar', or `pax'.
|
||||
#
|
||||
# Substitute a variable $(am__tar) that is a command
|
||||
# writing to stdout a FORMAT-tarball containing the directory
|
||||
# $tardir.
|
||||
# tardir=directory && $(am__tar) > result.tar
|
||||
#
|
||||
# Substitute a variable $(am__untar) that extract such
|
||||
# a tarball read from stdin.
|
||||
# $(am__untar) < result.tar
|
||||
AC_DEFUN([_AM_PROG_TAR],
|
||||
[# Always define AMTAR for backward compatibility.
|
||||
AM_MISSING_PROG([AMTAR], [tar])
|
||||
m4_if([$1], [v7],
|
||||
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
|
||||
[m4_case([$1], [ustar],, [pax],,
|
||||
[m4_fatal([Unknown tar format])])
|
||||
AC_MSG_CHECKING([how to create a $1 tar archive])
|
||||
# Loop over all known methods to create a tar archive until one works.
|
||||
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
|
||||
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
|
||||
# Do not fold the above two line into one, because Tru64 sh and
|
||||
# Solaris sh will not grok spaces in the rhs of `-'.
|
||||
for _am_tool in $_am_tools
|
||||
do
|
||||
case $_am_tool in
|
||||
gnutar)
|
||||
for _am_tar in tar gnutar gtar;
|
||||
do
|
||||
AM_RUN_LOG([$_am_tar --version]) && break
|
||||
done
|
||||
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
|
||||
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
|
||||
am__untar="$_am_tar -xf -"
|
||||
;;
|
||||
plaintar)
|
||||
# Must skip GNU tar: if it does not support --format= it doesn't create
|
||||
# ustar tarball either.
|
||||
(tar --version) >/dev/null 2>&1 && continue
|
||||
am__tar='tar chf - "$$tardir"'
|
||||
am__tar_='tar chf - "$tardir"'
|
||||
am__untar='tar xf -'
|
||||
;;
|
||||
pax)
|
||||
am__tar='pax -L -x $1 -w "$$tardir"'
|
||||
am__tar_='pax -L -x $1 -w "$tardir"'
|
||||
am__untar='pax -r'
|
||||
;;
|
||||
cpio)
|
||||
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
|
||||
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
|
||||
am__untar='cpio -i -H $1 -d'
|
||||
;;
|
||||
none)
|
||||
am__tar=false
|
||||
am__tar_=false
|
||||
am__untar=false
|
||||
;;
|
||||
esac
|
||||
|
||||
# If the value was cached, stop now. We just wanted to have am__tar
|
||||
# and am__untar set.
|
||||
test -n "${am_cv_prog_tar_$1}" && break
|
||||
|
||||
# tar/untar a dummy directory, and stop if the command works
|
||||
rm -rf conftest.dir
|
||||
mkdir conftest.dir
|
||||
echo GrepMe > conftest.dir/file
|
||||
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
|
||||
rm -rf conftest.dir
|
||||
if test -s conftest.tar; then
|
||||
AM_RUN_LOG([$am__untar <conftest.tar])
|
||||
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
|
||||
fi
|
||||
done
|
||||
rm -rf conftest.dir
|
||||
|
||||
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
|
||||
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
|
||||
AC_SUBST([am__tar])
|
||||
AC_SUBST([am__untar])
|
||||
]) # _AM_PROG_TAR
|
||||
|
||||
m4_include([../config/acx.m4])
|
||||
m4_include([../config/depstand.m4])
|
||||
m4_include([../config/extensions.m4])
|
||||
m4_include([../config/gettext-sister.m4])
|
||||
m4_include([../config/lead-dot.m4])
|
||||
m4_include([../config/nls.m4])
|
||||
m4_include([../config/override.m4])
|
||||
m4_include([../config/po.m4])
|
||||
m4_include([../config/proginstall.m4])
|
||||
m4_include([../config/progtest.m4])
|
||||
m4_include([../config/stdint.m4])
|
||||
m4_include([../libtool.m4])
|
||||
m4_include([../ltoptions.m4])
|
||||
m4_include([../ltsugar.m4])
|
||||
m4_include([../ltversion.m4])
|
||||
m4_include([bfd.m4])
|
||||
m4_include([warning.m4])
|
||||
m4_include([acinclude.m4])
|
270
external/gpl3/binutils/dist/bfd/aix386-core.c
vendored
Normal file
270
external/gpl3/binutils/dist/bfd/aix386-core.c
vendored
Normal file
@ -0,0 +1,270 @@
|
||||
/* 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, 1996, 1998, 1999, 2000,
|
||||
2001, 2002, 2004, 2006, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/i386.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#include <signal.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 void swap_abort PARAMS ((void));
|
||||
|
||||
static const bfd_target *
|
||||
aix386_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int i, n;
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
bfd_size_type core_size = sizeof (struct corehdr);
|
||||
bfd_size_type amt;
|
||||
struct corehdr *core;
|
||||
struct mergem {
|
||||
struct trad_core_struct coredata;
|
||||
struct corehdr internal_core;
|
||||
} *mergem;
|
||||
flagword flags;
|
||||
|
||||
amt = sizeof (longbuf);
|
||||
if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
|
||||
{
|
||||
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, (file_ptr) 0, 0) != 0)
|
||||
return 0;
|
||||
|
||||
amt = sizeof (struct mergem);
|
||||
mergem = (struct mergem *) bfd_zalloc (abfd, amt);
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
core = &mergem->internal_core;
|
||||
|
||||
if ((bfd_bread ((PTR) core, core_size, abfd)) != core_size)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_tdata (abfd, &mergem->coredata);
|
||||
core_hdr (abfd) = core;
|
||||
|
||||
/* Create the sections. */
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
|
||||
flags);
|
||||
if (core_regsec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_regsec (abfd)->size = sizeof (core->cd_regs);
|
||||
core_regsec (abfd)->vma = (bfd_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]);
|
||||
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
|
||||
flags);
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
/* bfd_release frees everything allocated after it's arg. */
|
||||
goto loser;
|
||||
|
||||
core_reg2sec (abfd)->size = sizeof (core->cd_fpregs);
|
||||
core_reg2sec (abfd)->vma = (bfd_vma) -1;
|
||||
core_reg2sec (abfd)->filepos =
|
||||
(file_ptr) offsetof (struct corehdr, cd_fpregs);
|
||||
|
||||
for (i = 0, n = 0; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type); i++)
|
||||
{
|
||||
const char *sname;
|
||||
flagword flags;
|
||||
|
||||
if (core->cd_segs[i].cs_offset == 0)
|
||||
continue;
|
||||
|
||||
switch (core->cd_segs[i].cs_type)
|
||||
{
|
||||
case COR_TYPE_DATA:
|
||||
sname = ".data";
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case COR_TYPE_STACK:
|
||||
sname = ".stack";
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case COR_TYPE_LIBDATA:
|
||||
sname = ".libdata";
|
||||
flags = SEC_ALLOC + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case COR_TYPE_WRITE:
|
||||
sname = ".writeable";
|
||||
flags = SEC_ALLOC + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case COR_TYPE_MSC:
|
||||
sname = ".misc";
|
||||
flags = SEC_ALLOC + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
default:
|
||||
sname = ".unknown";
|
||||
flags = SEC_ALLOC + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
}
|
||||
core_section (abfd, n) = bfd_make_section_anyway_with_flags (abfd,
|
||||
sname,
|
||||
flags);
|
||||
if (core_section (abfd, n) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_section (abfd, n)->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;
|
||||
n++;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#define aix386_core_file_matches_executable_p generic_core_file_matches_executable_p
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
|
||||
static void
|
||||
swap_abort ()
|
||||
{
|
||||
/* This way doesn't require any declaration for ANSI to fuck up. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define NO_GET ((bfd_vma (*) (const void *)) swap_abort)
|
||||
#define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort)
|
||||
#define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort)
|
||||
#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort)
|
||||
#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
|
||||
#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort)
|
||||
|
||||
const bfd_target aix386_core_vec = {
|
||||
"aix386-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),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET64, NO_GETS64, NO_PUT64,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* data */
|
||||
NO_GET64, NO_GETS64, NO_PUT64,
|
||||
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),
|
||||
|
||||
NULL,
|
||||
|
||||
(PTR) 0
|
||||
};
|
358
external/gpl3/binutils/dist/bfd/aix5ppc-core.c
vendored
Normal file
358
external/gpl3/binutils/dist/bfd/aix5ppc-core.c
vendored
Normal file
@ -0,0 +1,358 @@
|
||||
/* IBM RS/6000 "XCOFF" back-end for BFD.
|
||||
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Written by Tom Rix
|
||||
Contributed by Red Hat 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
|
||||
const bfd_target *xcoff64_core_p (bfd *);
|
||||
bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
|
||||
char *xcoff64_core_file_failing_command (bfd *);
|
||||
int xcoff64_core_file_failing_signal (bfd *);
|
||||
|
||||
#ifdef AIX_5_CORE
|
||||
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Aix 5.1 system include file. */
|
||||
|
||||
/* Need to define this macro so struct ld_info64 get included. */
|
||||
#define __LDINFO_PTRACE64__
|
||||
#include <sys/ldr.h>
|
||||
#include <core.h>
|
||||
|
||||
/* The default architecture and machine for matching core files. */
|
||||
#define DEFAULT_ARCHITECTURE bfd_arch_powerpc
|
||||
#define DEFAULT_MACHINE bfd_mach_ppc_620
|
||||
|
||||
#define core_hdr(abfd) ((struct core_dumpxx *) abfd->tdata.any)
|
||||
|
||||
#define CHECK_FILE_OFFSET(s, v) \
|
||||
((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
|
||||
|
||||
const bfd_target *
|
||||
xcoff64_core_p (bfd *abfd)
|
||||
{
|
||||
enum bfd_architecture arch;
|
||||
unsigned long mach;
|
||||
struct core_dumpxx core, *new_core_hdr;
|
||||
struct stat statbuf;
|
||||
asection *sec;
|
||||
struct __ld_info64 ldinfo;
|
||||
bfd_vma ld_offset;
|
||||
bfd_size_type i;
|
||||
struct vm_infox vminfo;
|
||||
const bfd_target *return_value = NULL;
|
||||
flagword flags;
|
||||
|
||||
/* Get the header. */
|
||||
if (bfd_seek (abfd, 0, SEEK_SET) != 0)
|
||||
goto xcoff64_core_p_error;
|
||||
|
||||
if (sizeof (struct core_dumpxx)
|
||||
!= bfd_bread (&core, sizeof (struct core_dumpxx), abfd))
|
||||
goto xcoff64_core_p_error;
|
||||
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
goto xcoff64_core_p_error;
|
||||
|
||||
/* Sanity checks
|
||||
c_flag has CORE_VERSION_1, Aix 4+
|
||||
c_entries = 0 for Aix 4.3+
|
||||
IS_PROC64 is a macro defined in procinfo.h, test for 64 bit process.
|
||||
|
||||
We will still be confused if a Aix 4.3 64 bit core file is
|
||||
copied over to a Aix 5 machine.
|
||||
|
||||
Check file header offsets
|
||||
|
||||
See rs6000-core.c for comment on size of core
|
||||
If there isn't enough of a real core file, bail. */
|
||||
|
||||
if ((CORE_VERSION_1 != (core.c_flag & CORE_VERSION_1))
|
||||
|| (0 != core.c_entries)
|
||||
|| (! (IS_PROC64 (&core.c_u.U_proc)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_fdsinfox)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_loader)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_loader + core.c_lsize)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_thr)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_segregion)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_stack)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_stack + core.c_size)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_data)))
|
||||
|| ((CHECK_FILE_OFFSET (statbuf, core.c_data + core.c_datasize)))
|
||||
|| (! (core.c_flag & UBLOCK_VALID))
|
||||
|| (! (core.c_flag & LE_VALID)))
|
||||
goto xcoff64_core_p_error;
|
||||
|
||||
/* Check for truncated stack or general truncating. */
|
||||
if ((! (core.c_flag & USTACK_VALID))
|
||||
|| (core.c_flag & CORE_TRUNC))
|
||||
{
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
new_core_hdr = bfd_zalloc (abfd, sizeof (struct core_dumpxx));
|
||||
if (NULL == new_core_hdr)
|
||||
return return_value;
|
||||
|
||||
memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
|
||||
/* The core_hdr() macro is no longer used here because it would
|
||||
expand to code relying on gcc's cast-as-lvalue extension,
|
||||
which was removed in gcc 4.0. */
|
||||
abfd->tdata.any = new_core_hdr;
|
||||
|
||||
/* .stack section. */
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = core.c_size;
|
||||
sec->vma = core.c_stackorg;
|
||||
sec->filepos = core.c_stack;
|
||||
|
||||
/* .reg section for all registers. */
|
||||
flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = sizeof (struct __context64);
|
||||
sec->vma = 0;
|
||||
sec->filepos = 0;
|
||||
sec->contents = (bfd_byte *)&new_core_hdr->c_flt.r64;
|
||||
|
||||
/* .ldinfo section.
|
||||
To actually find out how long this section is in this particular
|
||||
core dump would require going down the whole list of struct
|
||||
ld_info's. See if we can just fake it. */
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = core.c_lsize;
|
||||
sec->vma = 0;
|
||||
sec->filepos = core.c_loader;
|
||||
|
||||
/* AIX 4 adds data sections from loaded objects to the core file,
|
||||
which can be found by examining ldinfo, and anonymously mmapped
|
||||
regions. */
|
||||
|
||||
/* .data section from executable. */
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = core.c_datasize;
|
||||
sec->vma = core.c_dataorg;
|
||||
sec->filepos = core.c_data;
|
||||
|
||||
/* .data sections from loaded objects. */
|
||||
ld_offset = core.c_loader;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0)
|
||||
return return_value;
|
||||
|
||||
if (sizeof (struct __ld_info64) !=
|
||||
bfd_bread (&ldinfo, sizeof (struct __ld_info64), abfd))
|
||||
return return_value;
|
||||
|
||||
if (ldinfo.ldinfo_core)
|
||||
{
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = ldinfo.ldinfo_datasize;
|
||||
sec->vma = ldinfo.ldinfo_dataorg;
|
||||
sec->filepos = ldinfo.ldinfo_core;
|
||||
}
|
||||
|
||||
if (0 == ldinfo.ldinfo_next)
|
||||
break;
|
||||
ld_offset += ldinfo.ldinfo_next;
|
||||
}
|
||||
|
||||
/* .vmdata sections from anonymously mmapped regions. */
|
||||
if (core.c_vmregions)
|
||||
{
|
||||
if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0)
|
||||
return return_value;
|
||||
|
||||
for (i = 0; i < core.c_vmregions; i++)
|
||||
if (sizeof (struct vm_infox) !=
|
||||
bfd_bread (&vminfo, sizeof (struct vm_infox), abfd))
|
||||
return return_value;
|
||||
|
||||
if (vminfo.vminfo_offset)
|
||||
{
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
|
||||
if (NULL == sec)
|
||||
return return_value;
|
||||
|
||||
sec->size = vminfo.vminfo_size;
|
||||
sec->vma = vminfo.vminfo_addr;
|
||||
sec->filepos = vminfo.vminfo_offset;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the architecture and machine. */
|
||||
arch = DEFAULT_ARCHITECTURE;
|
||||
mach = DEFAULT_MACHINE;
|
||||
bfd_default_set_arch_mach (abfd, arch, mach);
|
||||
|
||||
return_value = (bfd_target *) abfd->xvec; /* This is garbage for now. */
|
||||
|
||||
xcoff64_core_p_error:
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Return `TRUE' if given core is from the given executable. */
|
||||
|
||||
bfd_boolean
|
||||
xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
|
||||
{
|
||||
struct core_dumpxx core;
|
||||
char *path, *s;
|
||||
size_t alloc;
|
||||
const char *str1, *str2;
|
||||
bfd_boolean return_value = FALSE;
|
||||
|
||||
/* Get the header. */
|
||||
if (bfd_seek (core_bfd, 0, SEEK_SET) != 0)
|
||||
return return_value;
|
||||
|
||||
if (sizeof (struct core_dumpxx) !=
|
||||
bfd_bread (&core, sizeof (struct core_dumpxx), core_bfd))
|
||||
return return_value;
|
||||
|
||||
if (bfd_seek (core_bfd, core.c_loader, SEEK_SET) != 0)
|
||||
return return_value;
|
||||
|
||||
alloc = 100;
|
||||
path = bfd_malloc (alloc);
|
||||
if (path == NULL)
|
||||
return return_value;
|
||||
|
||||
s = path;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (bfd_bread (s, 1, core_bfd) != 1)
|
||||
goto xcoff64_core_file_matches_executable_p_end_1;
|
||||
|
||||
if (*s == '\0')
|
||||
break;
|
||||
++s;
|
||||
if (s == path + alloc)
|
||||
{
|
||||
char *n;
|
||||
|
||||
alloc *= 2;
|
||||
n = bfd_realloc (path, alloc);
|
||||
if (n == NULL)
|
||||
goto xcoff64_core_file_matches_executable_p_end_1;
|
||||
|
||||
s = n + (path - s);
|
||||
path = n;
|
||||
}
|
||||
}
|
||||
|
||||
str1 = strrchr (path, '/');
|
||||
str2 = strrchr (exec_bfd->filename, '/');
|
||||
|
||||
/* Step over character '/'. */
|
||||
str1 = str1 != NULL ? str1 + 1 : path;
|
||||
str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
|
||||
|
||||
if (strcmp (str1, str2) == 0)
|
||||
return_value = TRUE;
|
||||
|
||||
xcoff64_core_file_matches_executable_p_end_1:
|
||||
free (path);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
char *
|
||||
xcoff64_core_file_failing_command (bfd *abfd)
|
||||
{
|
||||
struct core_dumpxx *c = core_hdr (abfd);
|
||||
char *return_value = 0;
|
||||
|
||||
if (NULL != c)
|
||||
return_value = c->c_u.U_proc.pi_comm;
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
int
|
||||
xcoff64_core_file_failing_signal (bfd *abfd)
|
||||
{
|
||||
struct core_dumpxx *c = core_hdr (abfd);
|
||||
int return_value = 0;
|
||||
|
||||
if (NULL != c)
|
||||
return_value = c->c_signo;
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#else /* AIX_5_CORE */
|
||||
|
||||
const bfd_target *
|
||||
xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
|
||||
{
|
||||
return generic_core_file_matches_executable_p (core_bfd, exec_bfd);
|
||||
}
|
||||
|
||||
char *
|
||||
xcoff64_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xcoff64_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* AIX_5_CORE */
|
515
external/gpl3/binutils/dist/bfd/aout-adobe.c
vendored
Normal file
515
external/gpl3/binutils/dist/bfd/aout-adobe.c
vendored
Normal file
@ -0,0 +1,515 @@
|
||||
/* BFD back-end for a.out.adobe binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/adobe.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures. */
|
||||
|
||||
/* Forward decl. */
|
||||
extern const bfd_target a_out_adobe_vec;
|
||||
|
||||
/* Swaps the information in an executable header taken from a raw byte
|
||||
stream memory image, into the internal exec_header structure. */
|
||||
|
||||
static void
|
||||
aout_adobe_swap_exec_header_in (bfd *abfd,
|
||||
struct external_exec *bytes,
|
||||
struct internal_exec *execp)
|
||||
{
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = 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. */
|
||||
|
||||
static void
|
||||
aout_adobe_swap_exec_header_out (bfd *abfd,
|
||||
struct internal_exec *execp,
|
||||
struct external_exec *bytes)
|
||||
{
|
||||
/* Now fill in fields in the raw data, from the fields in the exec
|
||||
struct. */
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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 (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, 0L);
|
||||
|
||||
/* 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 (;;)
|
||||
{
|
||||
bfd_size_type amt = sizeof (*ext);
|
||||
if (bfd_bread ( ext, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
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)
|
||||
(_("%B: Unknown section type in a.out.adobe file: %x\n"),
|
||||
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_with_flags (abfd, section_name, flags);
|
||||
trynum = 0;
|
||||
|
||||
while (!sect)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_no_error)
|
||||
/* Some other error -- slide into the sunset. */
|
||||
return NULL;
|
||||
sprintf (try_again, "%s%d", section_name, ++trynum);
|
||||
sect = bfd_make_section_with_flags (abfd, try_again, flags);
|
||||
}
|
||||
|
||||
/* Fix the name, if it is a sprintf'd name. */
|
||||
if (sect->name == try_again)
|
||||
{
|
||||
amt = strlen (sect->name);
|
||||
newname = bfd_zalloc (abfd, amt);
|
||||
if (newname == NULL)
|
||||
return NULL;
|
||||
strcpy (newname, sect->name);
|
||||
sect->name = newname;
|
||||
}
|
||||
|
||||
/* Assumed big-endian. */
|
||||
sect->size = ((ext->e_size[0] << 8)
|
||||
| ext->e_size[1] << 8
|
||||
| ext->e_size[2]);
|
||||
sect->vma = H_GET_32 (abfd, ext->e_virtbase);
|
||||
sect->filepos = 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;
|
||||
|
||||
default:
|
||||
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;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_object_p (bfd *abfd)
|
||||
{
|
||||
struct internal_exec anexec;
|
||||
struct external_exec exec_bytes;
|
||||
char *targ;
|
||||
bfd_size_type amt = EXEC_BYTES_SIZE;
|
||||
|
||||
if (bfd_bread (& exec_bytes, amt, abfd) != amt)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
anexec.a_info = 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))
|
||||
{
|
||||
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 NULL;
|
||||
}
|
||||
}
|
||||
|
||||
aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
|
||||
return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
|
||||
}
|
||||
|
||||
struct bout_data_struct
|
||||
{
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_mkobject (bfd *abfd)
|
||||
{
|
||||
struct bout_data_struct *rawptr;
|
||||
bfd_size_type amt = sizeof (struct bout_data_struct);
|
||||
|
||||
rawptr = bfd_zalloc (abfd, amt);
|
||||
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 void
|
||||
aout_adobe_write_section (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
sec_ptr sect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* FIXME XXX. */
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_write_object_contents (bfd *abfd)
|
||||
{
|
||||
struct external_exec swapped_hdr;
|
||||
static struct external_segdesc sentinel[1]; /* Initialized to zero. */
|
||||
asection *sect;
|
||||
bfd_size_type amt;
|
||||
|
||||
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->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->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->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);
|
||||
|
||||
amt = EXEC_BYTES_SIZE;
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| bfd_bwrite (& swapped_hdr, amt, abfd) != amt)
|
||||
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). */
|
||||
amt = sizeof (*sentinel);
|
||||
if (bfd_bwrite (sentinel, amt, abfd) != amt)
|
||||
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 bfd_boolean
|
||||
aout_adobe_set_section_contents (bfd *abfd,
|
||||
asection *section,
|
||||
const void * location,
|
||||
file_ptr offset,
|
||||
bfd_size_type count)
|
||||
{
|
||||
file_ptr section_start;
|
||||
sec_ptr sect;
|
||||
|
||||
/* Set by bfd.c handler. */
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
/* 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->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->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->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 TRUE;
|
||||
|
||||
return bfd_bwrite (location, count, abfd) == count;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
aout_adobe_set_arch_mach (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 (bfd *ignore_abfd ATTRIBUTE_UNUSED,
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return sizeof (struct internal_exec);
|
||||
}
|
||||
|
||||
/* Build the transfer vector for Adobe A.Out files. */
|
||||
|
||||
#define aout_32_bfd_make_debug_symbol ((asymbol *(*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
|
||||
#define aout_32_bfd_reloc_type_lookup ((reloc_howto_type *(*) (bfd *, bfd_reloc_code_real_type)) bfd_nullvoidptr)
|
||||
#define aout_32_bfd_reloc_name_lookup ((reloc_howto_type *(*) (bfd *, const char *)) bfd_nullvoidptr)
|
||||
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||
#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_gc_sections bfd_generic_gc_sections
|
||||
#define aout_32_bfd_merge_sections bfd_generic_merge_sections
|
||||
#define aout_32_bfd_is_group_section bfd_generic_is_group_section
|
||||
#define aout_32_bfd_discard_group bfd_generic_discard_group
|
||||
#define aout_32_section_already_linked _bfd_generic_section_already_linked
|
||||
#define aout_32_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define aout_32_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
||||
#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define aout_32_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#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, /* Header 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, /* Headers. */
|
||||
|
||||
{_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),
|
||||
|
||||
NULL,
|
||||
|
||||
NULL
|
||||
};
|
547
external/gpl3/binutils/dist/bfd/aout-arm.c
vendored
Normal file
547
external/gpl3/binutils/dist/bfd/aout-arm.c
vendored
Normal file
@ -0,0 +1,547 @@
|
||||
/* BFD back-end for raw ARM a.out binaries.
|
||||
Copyright 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
|
||||
2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting standard a.out
|
||||
as well as our own. */
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define NAME(x,y) CONCAT3 (aoutarm,_32_,y)
|
||||
|
||||
#define N_TXTADDR(x) \
|
||||
((N_MAGIC (x) == NMAGIC) \
|
||||
? (bfd_vma) 0x8000 \
|
||||
: ((N_MAGIC (x) != ZMAGIC) \
|
||||
? (bfd_vma) 0 \
|
||||
: ((N_SHARED_LIB (x)) \
|
||||
? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \
|
||||
: (bfd_vma) 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) CONCAT2 (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)
|
||||
|
||||
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||
#define MY_bfd_reloc_name_lookup aoutarm_bfd_reloc_name_lookup
|
||||
|
||||
#include "libaout.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY (fix_pcrel_26) (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
||||
static bfd_reloc_status_type
|
||||
MY (fix_pcrel_26_done) (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
||||
|
||||
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),
|
||||
EMPTY_HOWTO (-1),
|
||||
HOWTO (9, 0, -1, 16, FALSE, 0, complain_overflow_bitfield, 0, "NEG16", TRUE,
|
||||
0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (10, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, 0, "NEG32", TRUE,
|
||||
0xffffffff, 0xffffffff, FALSE)
|
||||
};
|
||||
|
||||
#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
|
||||
#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
|
||||
|
||||
static reloc_howto_type *
|
||||
MY (reloc_howto) (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)
|
||||
|
||||
static void
|
||||
MY (put_reloc) (bfd *abfd,
|
||||
int r_extern,
|
||||
int r_index,
|
||||
bfd_vma 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);
|
||||
/* Size as a power of two. */
|
||||
r_length = howto->size;
|
||||
|
||||
/* 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)
|
||||
|
||||
static void
|
||||
MY (relocatable_reloc) (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) (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED,
|
||||
asymbol *symbol ATTRIBUTE_UNUSED,
|
||||
void * data ATTRIBUTE_UNUSED,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY (fix_pcrel_26) (bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol,
|
||||
void * data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
bfd_vma 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 != 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 & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~ (bfd_vma) 0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~ (bfd_vma) 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;
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
MY (bfd_reloc_type_lookup) (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 NULL;
|
||||
}
|
||||
|
||||
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 NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
MY (bfd_reloc_name_lookup) (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (MY (howto_table)) / sizeof (MY (howto_table)[0]);
|
||||
i++)
|
||||
if (MY (howto_table)[i].name != NULL
|
||||
&& strcasecmp (MY (howto_table)[i].name, r_name) == 0)
|
||||
return &MY (howto_table)[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
void MY_swap_std_reloc_in (bfd *, struct reloc_std_external *, arelent *, asymbol **, bfd_size_type);
|
||||
void MY_swap_std_reloc_out (bfd *, arelent *, struct reloc_std_external *);
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
void
|
||||
MY_swap_std_reloc_in (bfd *abfd,
|
||||
struct reloc_std_external *bytes,
|
||||
arelent *cache_ptr,
|
||||
asymbol **symbols,
|
||||
bfd_size_type symcount ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = 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 (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;
|
||||
}
|
||||
|
||||
/* 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"
|
||||
|
||||
extern const bfd_target aout_arm_big_vec;
|
||||
|
||||
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 | SEC_CODE | SEC_DATA),
|
||||
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, /* Headers. */
|
||||
{_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),
|
||||
|
||||
& aout_arm_big_vec,
|
||||
|
||||
(void *) 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 | SEC_CODE | SEC_DATA),
|
||||
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, /* Headers. */
|
||||
{_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),
|
||||
|
||||
& aout_arm_little_vec,
|
||||
|
||||
(void *) MY_backend_data,
|
||||
};
|
294
external/gpl3/binutils/dist/bfd/aout-cris.c
vendored
Normal file
294
external/gpl3/binutils/dist/bfd/aout-cris.c
vendored
Normal file
@ -0,0 +1,294 @@
|
||||
/* BFD backend for CRIS a.out binaries.
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Axis Communications AB.
|
||||
Written by Hans-Peter Nilsson.
|
||||
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/* See info in the file PORTING for documentation of these macros and
|
||||
functions. Beware; some of the information there is outdated. */
|
||||
|
||||
#define N_HEADER_IN_TEXT(x) 0
|
||||
#define N_TXTOFF(x) 32
|
||||
#define ENTRY_CAN_BE_ZERO
|
||||
#define TEXT_START_ADDR 0
|
||||
|
||||
/* Without reading symbols to get the text start symbol, there is no way
|
||||
to know where the text segment starts in an a.out file. Defaulting to
|
||||
anything as constant as TEXT_START_ADDR is bad. But we can guess from
|
||||
the entry point, which is usually within the first 64k of the text
|
||||
segment. We also assume here that the text segment is 64k-aligned.
|
||||
FIXME: It is also wrong to assume that data and bss follow immediately
|
||||
after text, but with those, we don't have any choice besides reading
|
||||
symbol info, and luckily there's no pressing need for correctness for
|
||||
those vma:s at this time. */
|
||||
#define N_TXTADDR(x) ((x).a_entry & ~(bfd_vma) 0xffff)
|
||||
|
||||
/* If you change this to 4, you can not link to an address N*4+2. */
|
||||
#define SEGMENT_SIZE 2
|
||||
|
||||
/* For some reason, if the a.out file has Z_MAGIC, then
|
||||
adata(abfd).exec_bytes_size is not used, but rather
|
||||
adata(abfd).zmagic_disk_block_size, even though the exec_header is
|
||||
*not* included in the text segment. A simple workaround is to
|
||||
#define ZMAGIC_DISK_BLOCK_SIZE, which is used if defined; otherwise
|
||||
TARGET_PAGE_SIZE is used. */
|
||||
#define ZMAGIC_DISK_BLOCK_SIZE N_TXTOFF (0)
|
||||
|
||||
/* It seems odd at first to set a page-size this low, but gives greater
|
||||
freedom in where things can be linked. The drawback is that you have
|
||||
to set alignment and padding in linker scripts. */
|
||||
#define TARGET_PAGE_SIZE SEGMENT_SIZE
|
||||
#define TARGETNAME "a.out-cris"
|
||||
|
||||
/* N_SHARED_LIB gets this reasonable default as of 1999-07-12, but we
|
||||
have to work with 2.9.1. Note that N_SHARED_LIB is used in a
|
||||
SUN-specific context, not applicable to CRIS. */
|
||||
#define N_SHARED_LIB(x) 0
|
||||
|
||||
/* The definition here seems not used; just provided as a convention. */
|
||||
#define DEFAULT_ARCH bfd_arch_cris
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (cris_aout_,OP)
|
||||
#define NAME(x, y) CONCAT3 (cris_aout,_32_,y)
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
/* Version 1 of the header. */
|
||||
#define MY_exec_hdr_flags 1
|
||||
|
||||
#define MY_write_object_contents MY (write_object_contents)
|
||||
static bfd_boolean MY (write_object_contents) (bfd *);
|
||||
|
||||
/* Forward this, so we can use a pointer to it in PARAMS. */
|
||||
struct reloc_ext_external;
|
||||
|
||||
#define MY_swap_ext_reloc_out MY (swap_ext_reloc_out)
|
||||
static void MY (swap_ext_reloc_out) (bfd *, arelent *, struct reloc_ext_external *);
|
||||
|
||||
#define MY_swap_ext_reloc_in MY (swap_ext_reloc_in)
|
||||
static void MY (swap_ext_reloc_in) (bfd *, struct reloc_ext_external *,
|
||||
arelent *, asymbol **, bfd_size_type);
|
||||
|
||||
#define MY_set_sizes MY (set_sizes)
|
||||
static bfd_boolean MY (set_sizes) (bfd *);
|
||||
|
||||
/* To set back reloc_size to ext, we make MY (set_sizes) be called
|
||||
through this construct. Note that MY_set_arch_mach is only called
|
||||
through SET_ARCH_MACH. The default bfd_default_set_arch_mach will
|
||||
not call set_sizes. */
|
||||
|
||||
#define MY_set_arch_mach NAME (aout, set_arch_mach)
|
||||
#define SET_ARCH_MACH(BFD, EXEC) \
|
||||
MY_set_arch_mach (BFD, DEFAULT_ARCH, N_MACHTYPE (EXEC))
|
||||
|
||||
/* These macros describe the binary layout of the reloc information we
|
||||
use in a file. */
|
||||
#define RELOC_EXT_BITS_EXTERN_LITTLE 0x80
|
||||
#define RELOC_EXT_BITS_TYPE_LITTLE 3
|
||||
#define RELOC_EXT_BITS_TYPE_SH_LITTLE 0
|
||||
|
||||
#ifndef MY_get_section_contents
|
||||
#define MY_get_section_contents aout_32_get_section_contents
|
||||
#endif
|
||||
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_CRIS)
|
||||
|
||||
/* Include generic functions (some are overridden above). */
|
||||
#include "aout32.c"
|
||||
#include "aout-target.h"
|
||||
|
||||
/* We need our own version to set header flags. */
|
||||
|
||||
static bfd_boolean
|
||||
MY (write_object_contents) (bfd *abfd)
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* We set the reloc type to RELOC_EXT_SIZE, although setting it at all
|
||||
seems unnecessary when inspecting as and ld behavior (not an
|
||||
exhaustive inspection). The default write_object_contents
|
||||
definition sets RELOC_EXT_SIZE, so we follow suite and set it too. */
|
||||
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||
|
||||
/* Setting N_SET_MACHTYPE and using N_SET_FLAGS is not performed by
|
||||
the default definition. */
|
||||
if (bfd_get_arch (abfd) == bfd_arch_cris)
|
||||
N_SET_MACHTYPE (*execp, M_CRIS);
|
||||
|
||||
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
|
||||
WRITE_HEADERS (abfd, execp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* We need our own for these reasons:
|
||||
- Assert that a normal 8, 16 or 32 reloc is output.
|
||||
- Fix what seems to be a weak-bug (perhaps there for valid reasons). */
|
||||
|
||||
static void
|
||||
MY (swap_ext_reloc_out) (bfd *abfd,
|
||||
arelent *g,
|
||||
struct reloc_ext_external *natptr)
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
bfd_vma r_addend;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD (abfd, g->address, natptr->r_address);
|
||||
|
||||
r_type = (unsigned int) g->howto->type;
|
||||
|
||||
r_addend = g->addend;
|
||||
if ((sym->flags & BSF_SECTION_SYM) != 0)
|
||||
r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here. */
|
||||
|
||||
if (bfd_is_abs_section (bfd_get_section (sym)))
|
||||
{
|
||||
r_extern = 0;
|
||||
r_index = N_ABS;
|
||||
}
|
||||
else if ((sym->flags & BSF_SECTION_SYM) == 0)
|
||||
{
|
||||
if (bfd_is_und_section (bfd_get_section (sym))
|
||||
/* Remember to check for weak symbols; they count as global. */
|
||||
|| (sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
|
||||
r_extern = 1;
|
||||
else
|
||||
r_extern = 0;
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section. */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* The relocation type is the same as the canonical ones, but only
|
||||
the first 3 are used: RELOC_8, RELOC_16, RELOC_32.
|
||||
We may change this later, but assert this for the moment. */
|
||||
if (r_type > 2)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%s: Invalid relocation type exported: %d"),
|
||||
bfd_get_filename (abfd), r_type);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
}
|
||||
|
||||
/* Now the fun stuff. */
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
|
||||
|
||||
PUT_WORD (abfd, r_addend, natptr->r_addend);
|
||||
}
|
||||
|
||||
/* We need our own to assert that a normal 8, 16 or 32 reloc is input. */
|
||||
|
||||
static void
|
||||
MY (swap_ext_reloc_in) (bfd *abfd,
|
||||
struct reloc_ext_external *bytes,
|
||||
arelent *cache_ptr,
|
||||
asymbol **symbols,
|
||||
bfd_size_type symcount)
|
||||
{
|
||||
unsigned int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
|
||||
|
||||
/* Now the fun stuff. */
|
||||
r_index = (bytes->r_index[2] << 16)
|
||||
| (bytes->r_index[1] << 8)
|
||||
| bytes->r_index[0];
|
||||
r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
|
||||
r_type = ((bytes->r_type[0]) >> RELOC_EXT_BITS_TYPE_SH_LITTLE)
|
||||
& RELOC_EXT_BITS_TYPE_LITTLE;
|
||||
|
||||
if (r_type > 2)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%B: Invalid relocation type imported: %d"),
|
||||
abfd, r_type);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
}
|
||||
|
||||
cache_ptr->howto = howto_table_ext + r_type;
|
||||
|
||||
if (r_extern && r_index > symcount)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: Bad relocation record imported: %d"), abfd, r_index);
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
/* We continue, so we can catch further errors. */
|
||||
r_extern = 0;
|
||||
r_index = N_ABS;
|
||||
}
|
||||
|
||||
/* Magically uses r_extern, symbols etc. Ugly, but it's what's in the
|
||||
default. */
|
||||
MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
|
||||
}
|
||||
|
||||
/* We use the same as the default, except that we also set
|
||||
"obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;", to avoid changing
|
||||
NAME (aout, set_arch_mach) in aoutx. */
|
||||
|
||||
static bfd_boolean
|
||||
MY (set_sizes) (bfd *abfd)
|
||||
{
|
||||
/* Just as the default in aout-target.h (with some #ifdefs folded)... */
|
||||
|
||||
adata (abfd).page_size = TARGET_PAGE_SIZE;
|
||||
adata (abfd).segment_size = SEGMENT_SIZE;
|
||||
adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
/* ... except for that we have the extended reloc. The alternative
|
||||
would be to add a check on bfd_arch_cris in NAME (aout,
|
||||
set_arch_mach) in aoutx.h, but I don't want to do that since
|
||||
target-specific things should not be added there. */
|
||||
|
||||
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||
|
||||
return TRUE;
|
||||
}
|
364
external/gpl3/binutils/dist/bfd/aout-ns32k.c
vendored
Normal file
364
external/gpl3/binutils/dist/bfd/aout-ns32k.c
vendored
Normal file
@ -0,0 +1,364 @@
|
||||
/* BFD back-end for ns32k a.out-ish binaries.
|
||||
Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2005, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "aout/aout64.h"
|
||||
#include "ns32k.h"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MYNS(OP) CONCAT2 (ns32kaout_,OP)
|
||||
|
||||
reloc_howto_type * MYNS (bfd_reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
|
||||
reloc_howto_type * MYNS (bfd_reloc_name_lookup) (bfd *, const char *);
|
||||
bfd_boolean MYNS (write_object_contents) (bfd *);
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting
|
||||
standard a.out format(s) as well as this one. */
|
||||
#define NAME(x,y) CONCAT3 (ns32kaout,_32_,y)
|
||||
|
||||
void bfd_ns32k_arch (void);
|
||||
|
||||
#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)
|
||||
|
||||
/* The ns32k series is ah, unusual, when it comes to relocation.
|
||||
There are three storage methods for relocatable 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 architecture).
|
||||
|
||||
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, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "NS32K_IMM_8",
|
||||
TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_IMM_16, 0, 1, 16, FALSE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "NS32K_IMM_16",
|
||||
TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_IMM_32, 0, 2, 32, FALSE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "NS32K_IMM_32",
|
||||
TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
|
||||
TRUE, 0x000000ff, 0x000000ff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
|
||||
TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
|
||||
TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
|
||||
/* ns32k displacements. */
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_8, 0, 0, 7, FALSE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_disp, "NS32K_DISP_8",
|
||||
TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_16, 0, 1, 14, FALSE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_disp, "NS32K_DISP_16",
|
||||
TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_32, 0, 2, 30, FALSE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_disp, "NS32K_DISP_32",
|
||||
TRUE, 0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 7, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
|
||||
TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 14, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
|
||||
TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 30, TRUE, 0, complain_overflow_signed,
|
||||
_bfd_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
|
||||
|
||||
static reloc_howto_type *
|
||||
MY (reloc_howto) (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
struct reloc_std_external *rel,
|
||||
int *r_index,
|
||||
int *r_extern,
|
||||
int *r_pcrel)
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_ns32k_type;
|
||||
|
||||
*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)
|
||||
|
||||
static void
|
||||
MY (put_reloc) (bfd *abfd,
|
||||
int r_extern,
|
||||
int r_index,
|
||||
bfd_vma 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;
|
||||
|
||||
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 _bfd_ns32k_final_link_relocate
|
||||
#define MY_relocate_contents _bfd_ns32k_relocate_contents
|
||||
|
||||
static void MY_swap_std_reloc_in (bfd *, struct reloc_std_external *, arelent *, asymbol **, bfd_size_type);
|
||||
static void MY_swap_std_reloc_out (bfd *, arelent *, struct reloc_std_external *);
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
reloc_howto_type *
|
||||
MY (bfd_reloc_type_lookup) (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;
|
||||
default:
|
||||
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 NULL;
|
||||
}
|
||||
#undef ENTRY
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
MY (bfd_reloc_name_lookup) (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (MY (howto_table)) / sizeof (MY (howto_table)[0]);
|
||||
i++)
|
||||
if (MY (howto_table)[i].name != NULL
|
||||
&& strcasecmp (MY (howto_table)[i].name, r_name) == 0)
|
||||
return &MY (howto_table)[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (bfd *abfd,
|
||||
struct reloc_std_external *bytes,
|
||||
arelent *cache_ptr,
|
||||
asymbol **symbols,
|
||||
bfd_size_type symcount ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = 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 (bfd *abfd,
|
||||
arelent *g,
|
||||
struct reloc_std_external *natptr)
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
/* 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
|
||||
_bfd_ns32k_relocate_contents (reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
bfd_vma relocation,
|
||||
bfd_byte *location)
|
||||
{
|
||||
int r_ns32k_type = (howto - MY (howto_table)) / 6;
|
||||
bfd_vma (*get_data) (bfd_byte *, int);
|
||||
void (*put_data) (bfd_vma, bfd_byte *, int);
|
||||
|
||||
switch (r_ns32k_type)
|
||||
{
|
||||
case 0:
|
||||
get_data = _bfd_ns32k_get_immediate;
|
||||
put_data = _bfd_ns32k_put_immediate;
|
||||
break;
|
||||
case 1:
|
||||
get_data = _bfd_ns32k_get_displacement;
|
||||
put_data = _bfd_ns32k_put_displacement;
|
||||
break;
|
||||
case 2:
|
||||
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
||||
location);
|
||||
default:
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
return _bfd_do_ns32k_reloc_contents (howto, input_bfd, relocation,
|
||||
location, get_data, put_data);
|
||||
}
|
36
external/gpl3/binutils/dist/bfd/aout-sparcle.c
vendored
Normal file
36
external/gpl3/binutils/dist/bfd/aout-sparcle.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* BFD backend for sparc little-endian aout binaries.
|
||||
Copyright 1996, 2001, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-sparc-little"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (sparcle_aout_,OP)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libaout.h"
|
||||
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_SPARCLET)
|
||||
|
||||
/* Include the usual a.out support. */
|
||||
#define TARGET_IS_LITTLE_ENDIAN_P
|
||||
#include "aoutf1.h"
|
654
external/gpl3/binutils/dist/bfd/aout-target.h
vendored
Normal file
654
external/gpl3/binutils/dist/bfd/aout-target.h
vendored
Normal file
@ -0,0 +1,654 @@
|
||||
/* Define a target vector and some small routines for a variant of a.out.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
/*#include "libaout.h"*/
|
||||
|
||||
#ifndef SEGMENT_SIZE
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
extern reloc_howto_type * NAME (aout, reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
|
||||
extern reloc_howto_type * NAME (aout, reloc_name_lookup) (bfd *, const char *);
|
||||
|
||||
/* 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) (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)->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);
|
||||
|
||||
/* For some targets, if the entry point is not in the same page
|
||||
as the start of the text, then adjust the VMA so that it is.
|
||||
FIXME: Do this with a macro like SET_ARCH_MACH instead? */
|
||||
if (aout_backend_info (abfd)->entry_is_text_address
|
||||
&& execp->a_entry > obj_textsec (abfd)->vma)
|
||||
{
|
||||
bfd_vma adjust;
|
||||
|
||||
adjust = execp->a_entry - obj_textsec (abfd)->vma;
|
||||
/* Adjust only by whole pages. */
|
||||
adjust &= ~(TARGET_PAGE_SIZE - 1);
|
||||
obj_textsec (abfd)->vma += adjust;
|
||||
obj_datasec (abfd)->vma += adjust;
|
||||
obj_bsssec (abfd)->vma += adjust;
|
||||
}
|
||||
|
||||
/* Set the load addresses to be the same as the virtual addresses. */
|
||||
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
|
||||
|
||||
/* The number of relocation records. This must be called after
|
||||
SET_ARCH_MACH. It assumes that SET_ARCH_MACH will set
|
||||
obj_reloc_entry_size correctly, if the reloc size is not
|
||||
RELOC_STD_SIZE. */
|
||||
obj_textsec (abfd)->reloc_count =
|
||||
execp->a_trsize / obj_reloc_entry_size (abfd);
|
||||
obj_datasec (abfd)->reloc_count =
|
||||
execp->a_drsize / obj_reloc_entry_size (abfd);
|
||||
|
||||
/* 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)->size, arch_align)
|
||||
== obj_textsec (abfd)->size)
|
||||
&& (BFD_ALIGN (obj_datasec (abfd)->size, arch_align)
|
||||
== obj_datasec (abfd)->size)
|
||||
&& (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align)
|
||||
== obj_bsssec (abfd)->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. */
|
||||
|
||||
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) (bfd *abfd)
|
||||
{
|
||||
struct external_exec exec_bytes; /* Raw exec header from file. */
|
||||
struct internal_exec exec; /* Cleaned-up exec header. */
|
||||
const bfd_target *target;
|
||||
bfd_size_type amt = EXEC_BYTES_SIZE;
|
||||
|
||||
if (bfd_bread ((void *) &exec_bytes, amt, abfd) != amt)
|
||||
{
|
||||
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 = GET_MAGIC (abfd, exec_bytes.e_info);
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
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 bfd_boolean
|
||||
MY (mkobject) (bfd *abfd)
|
||||
{
|
||||
return NAME (aout, mkobject (abfd));
|
||||
}
|
||||
|
||||
#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. */
|
||||
|
||||
static bfd_boolean
|
||||
MY_bfd_copy_private_section_data (bfd *ibfd,
|
||||
asection *isec ATTRIBUTE_UNUSED,
|
||||
bfd *obfd,
|
||||
asection *osec ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour
|
||||
&& 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 bfd_boolean
|
||||
MY (write_object_contents) (bfd *abfd)
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
|
||||
WRITE_HEADERS (abfd, execp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#define MY_write_object_contents MY (write_object_contents)
|
||||
#endif
|
||||
|
||||
#ifndef MY_set_sizes
|
||||
|
||||
static bfd_boolean
|
||||
MY (set_sizes) (bfd *abfd)
|
||||
{
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
|
||||
#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_entry_is_text_address
|
||||
#define MY_entry_is_text_address 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_entry_is_text_address,
|
||||
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 (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 bfd_boolean
|
||||
MY_bfd_final_link (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 (*) (bfd *, struct bfd_section *)) 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_canonicalize_symtab
|
||||
#define MY_canonicalize_symtab NAME (aout, canonicalize_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_find_inliner_info
|
||||
#define MY_find_inliner_info _bfd_nosymbols_find_inliner_info
|
||||
#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_gc_sections
|
||||
#define MY_bfd_gc_sections bfd_generic_gc_sections
|
||||
#endif
|
||||
#ifndef MY_bfd_merge_sections
|
||||
#define MY_bfd_merge_sections bfd_generic_merge_sections
|
||||
#endif
|
||||
#ifndef MY_bfd_is_group_section
|
||||
#define MY_bfd_is_group_section bfd_generic_is_group_section
|
||||
#endif
|
||||
#ifndef MY_bfd_discard_group
|
||||
#define MY_bfd_discard_group bfd_generic_discard_group
|
||||
#endif
|
||||
#ifndef MY_section_already_linked
|
||||
#define MY_section_already_linked \
|
||||
_bfd_generic_section_already_linked
|
||||
#endif
|
||||
#ifndef MY_bfd_reloc_type_lookup
|
||||
#define MY_bfd_reloc_type_lookup NAME (aout, reloc_type_lookup)
|
||||
#endif
|
||||
#ifndef MY_bfd_reloc_name_lookup
|
||||
#define MY_bfd_reloc_name_lookup NAME (aout, reloc_name_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_hash_table_free
|
||||
#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
||||
#endif
|
||||
#ifndef MY_bfd_link_add_symbols
|
||||
#define MY_bfd_link_add_symbols NAME (aout, link_add_symbols)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_just_syms
|
||||
#define MY_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#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_copy_private_header_data
|
||||
#define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_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_name
|
||||
#define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_is_target_special_symbol
|
||||
#define MY_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
|
||||
#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_synthetic_symtab
|
||||
#define MY_get_synthetic_symtab \
|
||||
_bfd_nodynamic_get_synthetic_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 | SEC_CODE | SEC_DATA),
|
||||
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, /* Headers. */
|
||||
#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, /* Headers. */
|
||||
#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),
|
||||
|
||||
/* Alternative_target. */
|
||||
NULL,
|
||||
|
||||
MY_backend_data
|
||||
};
|
||||
#endif /* MY_BFD_TARGET */
|
1096
external/gpl3/binutils/dist/bfd/aout-tic30.c
vendored
Normal file
1096
external/gpl3/binutils/dist/bfd/aout-tic30.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
38
external/gpl3/binutils/dist/bfd/aout0.c
vendored
Normal file
38
external/gpl3/binutils/dist/bfd/aout0.c
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/* BFD backend for SunOS style a.out with flags set to 0
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 2001, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-zero-big"
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (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"
|
24
external/gpl3/binutils/dist/bfd/aout32.c
vendored
Normal file
24
external/gpl3/binutils/dist/bfd/aout32.c
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/* BFD back-end for 32-bit a.out files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
#include "aoutx.h"
|
32
external/gpl3/binutils/dist/bfd/aout64.c
vendored
Normal file
32
external/gpl3/binutils/dist/bfd/aout64.c
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/* BFD back-end for 64-bit a.out files.
|
||||
Copyright 1990, 1991, 1992, 1994, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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"
|
794
external/gpl3/binutils/dist/bfd/aoutf1.h
vendored
Normal file
794
external/gpl3/binutils/dist/bfd/aoutf1.h
vendored
Normal file
@ -0,0 +1,794 @@
|
||||
/* A.out "format 1" file handling code for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.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. */
|
||||
|
||||
#if ARCH_SIZE == 64
|
||||
#define sunos_set_arch_mach sunos_64_set_arch_mach
|
||||
#define sunos_write_object_contents aout_64_sunos4_write_object_contents
|
||||
#else
|
||||
#define sunos_set_arch_mach sunos_32_set_arch_mach
|
||||
#define sunos_write_object_contents aout_32_sunos4_write_object_contents
|
||||
#endif
|
||||
|
||||
/* Merge backend data into the output file.
|
||||
This is necessary on sparclet-aout where we want the resultant machine
|
||||
number to be M_SPARCLET if any input file is M_SPARCLET. */
|
||||
|
||||
#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
|
||||
|
||||
static bfd_boolean
|
||||
sunos_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
|
||||
{
|
||||
if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
|
||||
|| bfd_get_flavour (obfd) != bfd_target_aout_flavour)
|
||||
return TRUE;
|
||||
|
||||
if (bfd_get_arch (obfd) == bfd_arch_sparc)
|
||||
{
|
||||
if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
|
||||
bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
|
||||
depending upon ARCH_SIZE. */
|
||||
|
||||
static void
|
||||
sunos_set_arch_mach (bfd *abfd, enum machine_type machtype)
|
||||
{
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
enum bfd_architecture arch;
|
||||
unsigned 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 = bfd_mach_m68000;
|
||||
break;
|
||||
|
||||
case M_68010:
|
||||
case M_HP200:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = bfd_mach_m68010;
|
||||
break;
|
||||
|
||||
case M_68020:
|
||||
case M_HP300:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = bfd_mach_m68020;
|
||||
break;
|
||||
|
||||
case M_SPARC:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_SPARCLET:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = bfd_mach_sparc_sparclet;
|
||||
break;
|
||||
|
||||
case M_SPARCLITE_LE:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = bfd_mach_sparc_sparclite_le;
|
||||
break;
|
||||
|
||||
case M_386:
|
||||
case M_386_DYNIX:
|
||||
arch = bfd_arch_i386;
|
||||
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 (bfd *abfd)
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_sparc:
|
||||
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. The real name of this function is either
|
||||
aout_64_sunos4_write_object_contents or
|
||||
aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */
|
||||
|
||||
static bfd_boolean
|
||||
sunos_write_object_contents (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 bfd_mach_m68000:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
break;
|
||||
case bfd_mach_m68010:
|
||||
N_SET_MACHTYPE (*execp, M_68010);
|
||||
break;
|
||||
default:
|
||||
case bfd_mach_m68020:
|
||||
N_SET_MACHTYPE (*execp, M_68020);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_sparc:
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case bfd_mach_sparc_sparclet:
|
||||
N_SET_MACHTYPE (*execp, M_SPARCLET);
|
||||
break;
|
||||
case bfd_mach_sparc_sparclite_le:
|
||||
N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);
|
||||
break;
|
||||
default:
|
||||
N_SET_MACHTYPE (*execp, M_SPARC);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_i386:
|
||||
N_SET_MACHTYPE (*execp, M_386);
|
||||
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, (long)(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
|
||||
struct regs c_regs; /* 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
|
||||
struct regs c_regs; /* 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 (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
|
||||
{
|
||||
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = offsetof (struct external_sun3_core, 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 = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = offsetof (struct external_sun3_core, fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
offsetof (struct external_sun3_core, fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end. */
|
||||
intcore->c_ucode = 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 (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
|
||||
{
|
||||
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = offsetof (struct external_sparc_core, 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 = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = offsetof (struct external_sparc_core, fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
offsetof (struct external_sparc_core, fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end. */
|
||||
intcore->c_ucode = 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 = H_GET_32 (abfd, &extcore->c_regs.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 (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
|
||||
{
|
||||
struct external_solaris_bcp_core *extcore =
|
||||
(struct external_solaris_bcp_core *) ext;
|
||||
|
||||
intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
|
||||
intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
|
||||
intcore->c_regs_pos = offsetof (struct external_solaris_bcp_core, 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 ((void *) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
|
||||
intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
|
||||
intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
|
||||
intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
|
||||
intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
|
||||
intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos =
|
||||
offsetof (struct external_solaris_bcp_core, fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
offsetof (struct external_solaris_bcp_core, fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode = 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 = H_GET_32 (abfd, &extcore->c_regs.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 (bfd *abfd)
|
||||
{
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields. */
|
||||
bfd_size_type core_size, amt;
|
||||
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;
|
||||
flagword flags;
|
||||
|
||||
if (bfd_bread ((void *) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
|
||||
!= sizeof (longbuf))
|
||||
return NULL;
|
||||
core_mag = H_GET_32 (abfd, longbuf);
|
||||
|
||||
if (core_mag != CORE_MAGIC)
|
||||
return NULL;
|
||||
|
||||
/* SunOS core headers can vary in length; second word is size; */
|
||||
if (bfd_bread ((void *) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
|
||||
!= sizeof (longbuf))
|
||||
return NULL;
|
||||
core_size = H_GET_32 (abfd, longbuf);
|
||||
/* Sanity check. */
|
||||
if (core_size > 20000)
|
||||
return NULL;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
amt = core_size + sizeof (struct mergem);
|
||||
mergem = bfd_zalloc (abfd, amt);
|
||||
if (mergem == NULL)
|
||||
return NULL;
|
||||
|
||||
extcore = mergem->external_core;
|
||||
|
||||
if ((bfd_bread ((void *) extcore, core_size, abfd)) != core_size)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
goto loser;
|
||||
}
|
||||
|
||||
abfd->tdata.sun_core_data = &mergem->suncoredata;
|
||||
abfd->tdata.sun_core_data->hdr = core;
|
||||
|
||||
/* Create the sections. */
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_stacksec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack",
|
||||
flags);
|
||||
if (core_stacksec (abfd) == NULL)
|
||||
/* bfd_release frees everything allocated after it's arg. */
|
||||
goto loser;
|
||||
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data",
|
||||
flags);
|
||||
if (core_datasec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
|
||||
flags);
|
||||
if (core_regsec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
|
||||
flags);
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
goto loser;
|
||||
|
||||
core_stacksec (abfd)->size = core->c_ssize;
|
||||
core_datasec (abfd)->size = core->c_dsize;
|
||||
core_regsec (abfd)->size = core->c_regs_size;
|
||||
core_reg2sec (abfd)->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;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
sunos4_core_file_failing_command (bfd *abfd)
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_cmdname;
|
||||
}
|
||||
|
||||
static int
|
||||
sunos4_core_file_failing_signal (bfd *abfd)
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_signo;
|
||||
}
|
||||
|
||||
static bfd_boolean
|
||||
sunos4_core_file_matches_executable_p (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;
|
||||
}
|
||||
|
||||
#define MY_set_sizes sunos4_set_sizes
|
||||
|
||||
static bfd_boolean
|
||||
sunos4_set_sizes (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_entry_is_text_address
|
||||
#define MY_entry_is_text_address 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 sunos4_aout_backend =
|
||||
{
|
||||
0, /* Zmagic files are not contiguous. */
|
||||
1, /* Text includes header. */
|
||||
MY_entry_is_text_address,
|
||||
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 (*) (bfd *, struct bfd_section *)) 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
|
||||
|
||||
#ifndef TARGET_IS_LITTLE_ENDIAN_P
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
#endif
|
||||
|
||||
#include "aout-target.h"
|
5619
external/gpl3/binutils/dist/bfd/aoutx.h
vendored
Normal file
5619
external/gpl3/binutils/dist/bfd/aoutx.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2451
external/gpl3/binutils/dist/bfd/archive.c
vendored
Normal file
2451
external/gpl3/binutils/dist/bfd/archive.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
241
external/gpl3/binutils/dist/bfd/archive64.c
vendored
Normal file
241
external/gpl3/binutils/dist/bfd/archive64.c
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
/* MIPS-specific support for 64-bit ELF
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
Ian Lance Taylor, Cygnus Support
|
||||
Linker support added by Mark Mitchell, CodeSourcery, LLC.
|
||||
<mark@codesourcery.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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/* This file supports the 64-bit (MIPS) ELF archives. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* Irix 6 defines a 64bit archive map format, so that they can
|
||||
have archives more than 4 GB in size. */
|
||||
|
||||
bfd_boolean bfd_elf64_archive_slurp_armap (bfd *);
|
||||
bfd_boolean bfd_elf64_archive_write_armap
|
||||
(bfd *, unsigned int, struct orl *, unsigned int, int);
|
||||
|
||||
/* Read an Irix 6 armap. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_elf64_archive_slurp_armap (bfd *abfd)
|
||||
{
|
||||
struct artdata *ardata = bfd_ardata (abfd);
|
||||
char nextname[17];
|
||||
file_ptr arhdrpos;
|
||||
bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;
|
||||
struct areltdata *mapdata;
|
||||
bfd_byte int_buf[8];
|
||||
char *stringbase;
|
||||
bfd_byte *raw_armap = NULL;
|
||||
carsym *carsyms;
|
||||
bfd_size_type amt;
|
||||
|
||||
ardata->symdefs = NULL;
|
||||
|
||||
/* Get the name of the first element. */
|
||||
arhdrpos = bfd_tell (abfd);
|
||||
i = bfd_bread (nextname, 16, abfd);
|
||||
if (i == 0)
|
||||
return TRUE;
|
||||
if (i != 16)
|
||||
return FALSE;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* Archives with traditional armaps are still permitted. */
|
||||
if (CONST_STRNEQ (nextname, "/ "))
|
||||
return bfd_slurp_armap (abfd);
|
||||
|
||||
if (! CONST_STRNEQ (nextname, "/SYM64/ "))
|
||||
{
|
||||
bfd_has_map (abfd) = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return FALSE;
|
||||
parsed_size = mapdata->parsed_size;
|
||||
bfd_release (abfd, mapdata);
|
||||
|
||||
if (bfd_bread (int_buf, 8, abfd) != 8)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nsymz = bfd_getb64 (int_buf);
|
||||
stringsize = parsed_size - 8 * nsymz - 8;
|
||||
|
||||
carsym_size = nsymz * sizeof (carsym);
|
||||
ptrsize = 8 * nsymz;
|
||||
|
||||
amt = carsym_size + stringsize + 1;
|
||||
ardata->symdefs = bfd_zalloc (abfd, amt);
|
||||
if (ardata->symdefs == NULL)
|
||||
return FALSE;
|
||||
carsyms = ardata->symdefs;
|
||||
stringbase = ((char *) ardata->symdefs) + carsym_size;
|
||||
|
||||
raw_armap = bfd_alloc (abfd, ptrsize);
|
||||
if (raw_armap == NULL)
|
||||
goto release_symdefs;
|
||||
|
||||
if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize
|
||||
|| bfd_bread (stringbase, stringsize, abfd) != stringsize)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
goto release_raw_armap;
|
||||
}
|
||||
|
||||
for (i = 0; i < nsymz; i++)
|
||||
{
|
||||
carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
|
||||
carsyms->name = stringbase;
|
||||
stringbase += strlen (stringbase) + 1;
|
||||
++carsyms;
|
||||
}
|
||||
*stringbase = '\0';
|
||||
|
||||
ardata->symdef_count = nsymz;
|
||||
ardata->first_file_filepos = bfd_tell (abfd);
|
||||
/* Pad to an even boundary if you have to. */
|
||||
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
|
||||
|
||||
bfd_has_map (abfd) = TRUE;
|
||||
bfd_release (abfd, raw_armap);
|
||||
|
||||
return TRUE;
|
||||
|
||||
release_raw_armap:
|
||||
bfd_release (abfd, raw_armap);
|
||||
release_symdefs:
|
||||
bfd_release (abfd, ardata->symdefs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Write out an Irix 6 armap. The Irix 6 tools are supposed to be
|
||||
able to handle ordinary ELF armaps, but at least on Irix 6.2 the
|
||||
linker crashes. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_elf64_archive_write_armap (bfd *arch,
|
||||
unsigned int elength,
|
||||
struct orl *map,
|
||||
unsigned int symbol_count,
|
||||
int stridx)
|
||||
{
|
||||
unsigned int ranlibsize = (symbol_count * 8) + 8;
|
||||
unsigned int stringsize = stridx;
|
||||
unsigned int mapsize = stringsize + ranlibsize;
|
||||
file_ptr archive_member_file_ptr;
|
||||
bfd *current = arch->archive_head;
|
||||
unsigned int count;
|
||||
struct ar_hdr hdr;
|
||||
int padding;
|
||||
bfd_byte buf[8];
|
||||
|
||||
padding = BFD_ALIGN (mapsize, 8) - mapsize;
|
||||
mapsize += padding;
|
||||
|
||||
/* work out where the first object file will go in the archive */
|
||||
archive_member_file_ptr = (mapsize
|
||||
+ elength
|
||||
+ sizeof (struct ar_hdr)
|
||||
+ SARMAG);
|
||||
|
||||
memset (&hdr, ' ', sizeof (struct ar_hdr));
|
||||
memcpy (hdr.ar_name, "/SYM64/", strlen ("/SYM64/"));
|
||||
_bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
|
||||
mapsize);
|
||||
_bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
|
||||
time (NULL));
|
||||
/* This, at least, is what Intel coff sets the values to.: */
|
||||
_bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
|
||||
_bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);
|
||||
_bfd_ar_spacepad (hdr.ar_mode, sizeof (hdr.ar_mode), "%-7lo", 0);
|
||||
memcpy (hdr.ar_fmag, ARFMAG, 2);
|
||||
|
||||
/* Write the ar header for this item and the number of symbols */
|
||||
|
||||
if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
|
||||
!= sizeof (struct ar_hdr))
|
||||
return FALSE;
|
||||
|
||||
bfd_putb64 ((bfd_vma) symbol_count, buf);
|
||||
if (bfd_bwrite (buf, 8, arch) != 8)
|
||||
return FALSE;
|
||||
|
||||
/* Two passes, first write the file offsets for each symbol -
|
||||
remembering that each offset is on a two byte boundary. */
|
||||
|
||||
/* Write out the file offset for the file associated with each
|
||||
symbol, and remember to keep the offsets padded out. */
|
||||
|
||||
current = arch->archive_head;
|
||||
count = 0;
|
||||
while (current != NULL && count < symbol_count)
|
||||
{
|
||||
/* For each symbol which is used defined in this object, write out
|
||||
the object file's address in the archive */
|
||||
|
||||
while (map[count].u.abfd == current)
|
||||
{
|
||||
bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
|
||||
if (bfd_bwrite (buf, 8, arch) != 8)
|
||||
return FALSE;
|
||||
count++;
|
||||
}
|
||||
/* Add size of this archive entry */
|
||||
archive_member_file_ptr += (arelt_size (current)
|
||||
+ sizeof (struct ar_hdr));
|
||||
/* remember about the even alignment */
|
||||
archive_member_file_ptr += archive_member_file_ptr % 2;
|
||||
current = current->archive_next;
|
||||
}
|
||||
|
||||
/* now write the strings themselves */
|
||||
for (count = 0; count < symbol_count; count++)
|
||||
{
|
||||
size_t len = strlen (*map[count].name) + 1;
|
||||
|
||||
if (bfd_bwrite (*map[count].name, len, arch) != len)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The spec says that this should be padded to an 8 byte boundary.
|
||||
However, the Irix 6.2 tools do not appear to do this. */
|
||||
while (padding != 0)
|
||||
{
|
||||
if (bfd_bwrite ("", 1, arch) != 1)
|
||||
return FALSE;
|
||||
--padding;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
1243
external/gpl3/binutils/dist/bfd/archures.c
vendored
Normal file
1243
external/gpl3/binutils/dist/bfd/archures.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
40
external/gpl3/binutils/dist/bfd/armnetbsd.c
vendored
Normal file
40
external/gpl3/binutils/dist/bfd/armnetbsd.c
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/* BFD back-end for NetBSD/ARM a.out-ish binaries.
|
||||
Copyright 1999, 2000, 2001, 2002, 2005, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
#undef TARGET_IS_BIG_ENDIAN_P
|
||||
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_arm
|
||||
#define DEFAULT_MID M_ARM6_NETBSD
|
||||
/*#define MACHTYPE_OK(mtype) ((mtype) == M_ARM6_NETBSD)*/
|
||||
|
||||
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
||||
remove whitespace added here, and thus will fail to concatenate
|
||||
the tokens. */
|
||||
#define MY(OP) CONCAT2 (armnetbsd_, OP)
|
||||
|
||||
/* This needs to start with a.out so GDB knows it is an a.out variant. */
|
||||
#define TARGETNAME "a.out-arm-netbsd"
|
||||
|
||||
#include "netbsd.h"
|
931
external/gpl3/binutils/dist/bfd/bfd-in.h
vendored
Normal file
931
external/gpl3/binutils/dist/bfd/bfd-in.h
vendored
Normal file
@ -0,0 +1,931 @@
|
||||
/* Main header file for the bfd library -- portable access to object files.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Contributed 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef __BFD_H_SEEN__
|
||||
#define __BFD_H_SEEN__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "symcat.h"
|
||||
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
||||
#ifndef SABER
|
||||
/* This 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 XCONCAT2 macro will
|
||||
cause the inner CONCAT2 macros to be evaluated first, producing
|
||||
still-valid pp-tokens. Then the final concatenation can be done. */
|
||||
#undef CONCAT4
|
||||
#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is a utility macro to handle the situation where the code
|
||||
wants to place a constant string into the code, followed by a
|
||||
comma and then the length of the string. Doing this by hand
|
||||
is error prone, so using this macro is safer. */
|
||||
#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
|
||||
/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
|
||||
to create the arguments to another macro, since the preprocessor
|
||||
will mis-count the number of arguments to the outer macro (by not
|
||||
evaluating STRING_COMMA_LEN and so missing the comma). This is a
|
||||
problem for example when trying to use STRING_COMMA_LEN to build
|
||||
the arguments to the strncmp() macro. Hence this alternative
|
||||
definition of strncmp is provided here.
|
||||
|
||||
Note - these macros do NOT work if STR2 is not a constant string. */
|
||||
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
|
||||
/* strcpy() can have a similar problem, but since we know we are
|
||||
copying a constant string, we can use memcpy which will be faster
|
||||
since there is no need to check for a NUL byte inside STR. We
|
||||
can also save time if we do not need to copy the terminating NUL. */
|
||||
#define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1)
|
||||
#define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2))
|
||||
|
||||
|
||||
/* The word size used by BFD on the host. This may be 64 with a 32
|
||||
bit target if the host is 64 bit, or if other 64 bit targets have
|
||||
been selected with --enable-targets, or if --enable-64-bit-bfd. */
|
||||
#define BFD_ARCH_SIZE @wordsize@
|
||||
|
||||
/* The word size of the default bfd target. */
|
||||
#define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
|
||||
|
||||
#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
|
||||
#define BFD_HOST_64BIT_LONG_LONG @BFD_HOST_64BIT_LONG_LONG@
|
||||
#if @BFD_HOST_64_BIT_DEFINED@
|
||||
#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
|
||||
#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
|
||||
typedef BFD_HOST_64_BIT bfd_int64_t;
|
||||
typedef BFD_HOST_U_64_BIT bfd_uint64_t;
|
||||
#endif
|
||||
|
||||
#if BFD_ARCH_SIZE >= 64
|
||||
#define BFD64
|
||||
#endif
|
||||
|
||||
#ifndef INLINE
|
||||
#if __GNUC__ >= 2
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Declaring a type wide enough to hold a host long and a host pointer. */
|
||||
#define BFD_HOSTPTR_T @BFD_HOSTPTR_T@
|
||||
typedef BFD_HOSTPTR_T bfd_hostptr_t;
|
||||
|
||||
/* Forward declaration. */
|
||||
typedef struct bfd bfd;
|
||||
|
||||
/* Boolean type used in bfd. Too many systems define their own
|
||||
versions of "boolean" for us to safely typedef a "boolean" of
|
||||
our own. Using an enum for "bfd_boolean" has its own set of
|
||||
problems, with strange looking casts required to avoid warnings
|
||||
on some older compilers. Thus we just use an int.
|
||||
|
||||
General rule: Functions which are bfd_boolean return TRUE on
|
||||
success and FALSE on failure (unless they're a predicate). */
|
||||
|
||||
typedef int bfd_boolean;
|
||||
#undef FALSE
|
||||
#undef TRUE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#ifdef BFD64
|
||||
|
||||
#ifndef BFD_HOST_64_BIT
|
||||
#error No 64 bit integer type available
|
||||
#endif /* ! defined (BFD_HOST_64_BIT) */
|
||||
|
||||
typedef BFD_HOST_U_64_BIT bfd_vma;
|
||||
typedef BFD_HOST_64_BIT bfd_signed_vma;
|
||||
typedef BFD_HOST_U_64_BIT bfd_size_type;
|
||||
typedef BFD_HOST_U_64_BIT symvalue;
|
||||
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define BFD_VMA_FMT "l"
|
||||
#elif defined (__MSVCRT__)
|
||||
#define BFD_VMA_FMT "I64"
|
||||
#else
|
||||
#define BFD_VMA_FMT "ll"
|
||||
#endif
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016" BFD_VMA_FMT "x", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016" BFD_VMA_FMT "x", x)
|
||||
#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 BFD_VMA_FMT "l"
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
|
||||
#endif /* not BFD64 */
|
||||
|
||||
#define HALF_BFD_SIZE_TYPE \
|
||||
(((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
|
||||
|
||||
#ifndef BFD_HOST_64_BIT
|
||||
/* Fall back on a 32 bit type. The idea is to make these types always
|
||||
available for function return types, but in the case that
|
||||
BFD_HOST_64_BIT is undefined such a function should abort or
|
||||
otherwise signal an error. */
|
||||
typedef bfd_signed_vma bfd_int64_t;
|
||||
typedef bfd_vma bfd_uint64_t;
|
||||
#endif
|
||||
|
||||
/* An offset into a file. BFD always uses the largest possible offset
|
||||
based on the build time availability of fseek, fseeko, or fseeko64. */
|
||||
typedef @bfd_file_ptr@ file_ptr;
|
||||
typedef unsigned @bfd_file_ptr@ ufile_ptr;
|
||||
|
||||
extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
|
||||
extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
|
||||
|
||||
#define printf_vma(x) fprintf_vma(stdout,x)
|
||||
#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,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/assembler/compiler output. */
|
||||
bfd_archive, /* Object archive file. */
|
||||
bfd_core, /* Core dump. */
|
||||
bfd_type_end /* Marks the end; don't use it! */
|
||||
}
|
||||
bfd_format;
|
||||
|
||||
/* 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) \
|
||||
(((x)->flags & BSF_SYNTHETIC) != 0 \
|
||||
? bfd_target_unknown_flavour \
|
||||
: 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. */
|
||||
union
|
||||
{
|
||||
file_ptr pos;
|
||||
bfd *abfd;
|
||||
} u; /* 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 bfd_symbol *sym; /* Function name. */
|
||||
bfd_vma offset; /* Offset into section. */
|
||||
} u;
|
||||
}
|
||||
alent;
|
||||
|
||||
/* Object and core file sections. */
|
||||
|
||||
#define align_power(addr, align) \
|
||||
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
|
||||
|
||||
typedef struct bfd_section *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_lma(bfd, ptr) ((ptr)->lma + 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) ((ptr)->size)
|
||||
#define bfd_get_section_size(ptr) ((ptr)->size)
|
||||
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
|
||||
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
|
||||
#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 = 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)
|
||||
/* Find the address one past the end of SEC. */
|
||||
#define bfd_get_section_limit(bfd, sec) \
|
||||
(((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
|
||||
/ bfd_octets_per_byte (bfd))
|
||||
|
||||
/* Return TRUE if section has been discarded. */
|
||||
#define elf_discarded_section(sec) \
|
||||
(!bfd_is_abs_section (sec) \
|
||||
&& bfd_is_abs_section ((sec)->output_section) \
|
||||
&& (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \
|
||||
&& (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
|
||||
|
||||
/* Forward define. */
|
||||
struct stat;
|
||||
|
||||
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 (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;
|
||||
/* 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)
|
||||
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
|
||||
/* An objalloc for this hash table. This is a struct objalloc *,
|
||||
but we use void * to avoid requiring the inclusion of objalloc.h. */
|
||||
void *memory;
|
||||
/* The number of slots in the hash table. */
|
||||
unsigned int size;
|
||||
/* The number of entries in the hash table. */
|
||||
unsigned int count;
|
||||
/* The size of elements. */
|
||||
unsigned int entsize;
|
||||
/* If non-zero, don't grow the hash table. */
|
||||
unsigned int frozen:1;
|
||||
};
|
||||
|
||||
/* Initialize a hash table. */
|
||||
extern bfd_boolean bfd_hash_table_init
|
||||
(struct bfd_hash_table *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *),
|
||||
unsigned int);
|
||||
|
||||
/* Initialize a hash table specifying a size. */
|
||||
extern bfd_boolean bfd_hash_table_init_n
|
||||
(struct bfd_hash_table *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *),
|
||||
unsigned int, unsigned int);
|
||||
|
||||
/* Free up a hash table. */
|
||||
extern void bfd_hash_table_free
|
||||
(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
|
||||
(struct bfd_hash_table *, const char *, bfd_boolean create,
|
||||
bfd_boolean copy);
|
||||
|
||||
/* Insert an entry in a hash table. */
|
||||
extern struct bfd_hash_entry *bfd_hash_insert
|
||||
(struct bfd_hash_table *, const char *, unsigned long);
|
||||
|
||||
/* Replace an entry in a hash table. */
|
||||
extern void bfd_hash_replace
|
||||
(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
|
||||
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
|
||||
|
||||
/* Grab some space for a hash table entry. */
|
||||
extern void *bfd_hash_allocate
|
||||
(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
|
||||
(struct bfd_hash_table *,
|
||||
bfd_boolean (*) (struct bfd_hash_entry *, void *),
|
||||
void *info);
|
||||
|
||||
/* Allows the default size of a hash table to be configured. New hash
|
||||
tables allocated using bfd_hash_table_init will be created with
|
||||
this size. */
|
||||
extern void bfd_hash_set_default_size (bfd_size_type);
|
||||
|
||||
/* This structure is used to keep track of stabs in sections
|
||||
information while linking. */
|
||||
|
||||
struct stab_info
|
||||
{
|
||||
/* A hash table used to hold stabs strings. */
|
||||
struct bfd_strtab_hash *strings;
|
||||
/* The header file hash table. */
|
||||
struct bfd_hash_table includes;
|
||||
/* The first .stabstr section. */
|
||||
struct bfd_section *stabstr;
|
||||
};
|
||||
|
||||
#define COFF_SWAP_TABLE (void *) &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_bread (void *, bfd_size_type, bfd *);
|
||||
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
||||
extern int bfd_seek (bfd *, file_ptr, int);
|
||||
extern file_ptr bfd_tell (bfd *);
|
||||
extern int bfd_flush (bfd *);
|
||||
extern int bfd_stat (bfd *, struct stat *);
|
||||
|
||||
/* Deprecated old routines. */
|
||||
#if __GNUC__
|
||||
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
|
||||
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
|
||||
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#else
|
||||
#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
|
||||
bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
|
||||
(warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
|
||||
bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
|
||||
#endif
|
||||
extern void warn_deprecated (const char *, const char *, int, const char *);
|
||||
|
||||
/* 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_family_coff(abfd) \
|
||||
(bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
|
||||
bfd_get_flavour (abfd) == bfd_target_xcoff_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_is_thin_archive(abfd) ((abfd)->is_thin_archive)
|
||||
|
||||
#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_dynamic_symcount(abfd) ((abfd)->dynsymcount)
|
||||
|
||||
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
|
||||
|
||||
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
|
||||
|
||||
extern bfd_boolean bfd_cache_close
|
||||
(bfd *abfd);
|
||||
/* NB: This declaration should match the autogenerated one in libbfd.h. */
|
||||
|
||||
extern bfd_boolean bfd_cache_close_all (void);
|
||||
|
||||
extern bfd_boolean bfd_record_phdr
|
||||
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
|
||||
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
|
||||
|
||||
/* Byte swapping routines. */
|
||||
|
||||
bfd_uint64_t bfd_getb64 (const void *);
|
||||
bfd_uint64_t bfd_getl64 (const void *);
|
||||
bfd_int64_t bfd_getb_signed_64 (const void *);
|
||||
bfd_int64_t bfd_getl_signed_64 (const void *);
|
||||
bfd_vma bfd_getb32 (const void *);
|
||||
bfd_vma bfd_getl32 (const void *);
|
||||
bfd_signed_vma bfd_getb_signed_32 (const void *);
|
||||
bfd_signed_vma bfd_getl_signed_32 (const void *);
|
||||
bfd_vma bfd_getb16 (const void *);
|
||||
bfd_vma bfd_getl16 (const void *);
|
||||
bfd_signed_vma bfd_getb_signed_16 (const void *);
|
||||
bfd_signed_vma bfd_getl_signed_16 (const void *);
|
||||
void bfd_putb64 (bfd_uint64_t, void *);
|
||||
void bfd_putl64 (bfd_uint64_t, void *);
|
||||
void bfd_putb32 (bfd_vma, void *);
|
||||
void bfd_putl32 (bfd_vma, void *);
|
||||
void bfd_putb16 (bfd_vma, void *);
|
||||
void bfd_putl16 (bfd_vma, void *);
|
||||
|
||||
/* Byte swapping routines which take size and endiannes as arguments. */
|
||||
|
||||
bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
|
||||
void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
|
||||
|
||||
extern bfd_boolean bfd_section_already_linked_table_init (void);
|
||||
extern void bfd_section_already_linked_table_free (void);
|
||||
|
||||
/* Externally visible ECOFF routines. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct ecoff_debug_info;
|
||||
struct ecoff_debug_swap;
|
||||
struct ecoff_extr;
|
||||
struct bfd_symbol;
|
||||
struct bfd_link_info;
|
||||
struct bfd_link_hash_entry;
|
||||
struct bfd_elf_version_tree;
|
||||
#endif
|
||||
extern bfd_vma bfd_ecoff_get_gp_value
|
||||
(bfd * abfd);
|
||||
extern bfd_boolean bfd_ecoff_set_gp_value
|
||||
(bfd *abfd, bfd_vma gp_value);
|
||||
extern bfd_boolean bfd_ecoff_set_regmasks
|
||||
(bfd *abfd, unsigned long gprmask, unsigned long fprmask,
|
||||
unsigned long *cprmask);
|
||||
extern void *bfd_ecoff_debug_init
|
||||
(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
|
||||
(void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_ecoff_debug_accumulate
|
||||
(void *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 bfd_boolean bfd_ecoff_debug_accumulate_other
|
||||
(void *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 bfd_boolean bfd_ecoff_debug_externals
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
|
||||
bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
|
||||
void (*set_index) (struct bfd_symbol *, bfd_size_type));
|
||||
extern bfd_boolean bfd_ecoff_debug_one_external
|
||||
(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
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap);
|
||||
extern bfd_boolean bfd_ecoff_write_debug
|
||||
(bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, file_ptr where);
|
||||
extern bfd_boolean bfd_ecoff_write_accumulated_debug
|
||||
(void *handle, bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap,
|
||||
struct bfd_link_info *info, file_ptr where);
|
||||
|
||||
/* Externally visible ELF routines. */
|
||||
|
||||
struct bfd_link_needed_list
|
||||
{
|
||||
struct bfd_link_needed_list *next;
|
||||
bfd *by;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
enum dynamic_lib_link_class {
|
||||
DYN_NORMAL = 0,
|
||||
DYN_AS_NEEDED = 1,
|
||||
DYN_DT_NEEDED = 2,
|
||||
DYN_NO_ADD_NEEDED = 4,
|
||||
DYN_NO_NEEDED = 8
|
||||
};
|
||||
|
||||
enum notice_asneeded_action {
|
||||
notice_as_needed,
|
||||
notice_not_needed,
|
||||
notice_needed
|
||||
};
|
||||
|
||||
extern bfd_boolean bfd_elf_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *, bfd_boolean,
|
||||
bfd_boolean);
|
||||
extern struct bfd_link_needed_list *bfd_elf_get_needed_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_elf_get_bfd_needed_list
|
||||
(bfd *, struct bfd_link_needed_list **);
|
||||
extern bfd_boolean bfd_elf_size_dynamic_sections
|
||||
(bfd *, const char *, const char *, const char *, const char * const *,
|
||||
struct bfd_link_info *, struct bfd_section **,
|
||||
struct bfd_elf_version_tree *);
|
||||
extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern void bfd_elf_set_dt_needed_name
|
||||
(bfd *, const char *);
|
||||
extern const char *bfd_elf_get_dt_soname
|
||||
(bfd *);
|
||||
extern void bfd_elf_set_dyn_lib_class
|
||||
(bfd *, enum dynamic_lib_link_class);
|
||||
extern int bfd_elf_get_dyn_lib_class
|
||||
(bfd *);
|
||||
extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_elf_discard_info
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern unsigned int _bfd_elf_default_action_discarded
|
||||
(struct bfd_section *);
|
||||
|
||||
/* Return an upper bound on the number of bytes required to store a
|
||||
copy of ABFD's program header table entries. Return -1 if an error
|
||||
occurs; bfd_get_error will return an appropriate code. */
|
||||
extern long bfd_get_elf_phdr_upper_bound
|
||||
(bfd *abfd);
|
||||
|
||||
/* Copy ABFD's program header table entries to *PHDRS. The entries
|
||||
will be stored as an array of Elf_Internal_Phdr structures, as
|
||||
defined in include/elf/internal.h. To find out how large the
|
||||
buffer needs to be, call bfd_get_elf_phdr_upper_bound.
|
||||
|
||||
Return the number of program header table entries read, or -1 if an
|
||||
error occurs; bfd_get_error will return an appropriate code. */
|
||||
extern int bfd_get_elf_phdrs
|
||||
(bfd *abfd, void *phdrs);
|
||||
|
||||
/* Create a new BFD as if by bfd_openr. Rather than opening a file,
|
||||
reconstruct an ELF file by reading the segments out of remote memory
|
||||
based on the ELF file header at EHDR_VMA and the ELF program headers it
|
||||
points to. If not null, *LOADBASEP is filled in with the difference
|
||||
between the VMAs from which the segments were read, and the VMAs the
|
||||
file headers (and hence BFD's idea of each section's VMA) put them at.
|
||||
|
||||
The function TARGET_READ_MEMORY is called to copy LEN bytes from the
|
||||
remote memory at target address VMA into the local buffer at MYADDR; it
|
||||
should return zero on success or an `errno' code on failure. TEMPL must
|
||||
be a BFD for an ELF target with the word size and byte order found in
|
||||
the remote memory. */
|
||||
extern bfd *bfd_elf_bfd_from_remote_memory
|
||||
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
|
||||
int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
|
||||
|
||||
/* Return the arch_size field of an elf bfd, or -1 if not elf. */
|
||||
extern int bfd_get_arch_size
|
||||
(bfd *);
|
||||
|
||||
/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
|
||||
extern int bfd_get_sign_extend_vma
|
||||
(bfd *);
|
||||
|
||||
extern struct bfd_section *_bfd_elf_tls_setup
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern void _bfd_fix_excluded_sec_syms
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern unsigned bfd_m68k_mach_to_features (int);
|
||||
|
||||
extern int bfd_m68k_features_to_mach (unsigned);
|
||||
|
||||
extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
|
||||
char **);
|
||||
|
||||
extern void bfd_elf_m68k_set_target_options (struct bfd_link_info *, int);
|
||||
|
||||
extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
|
||||
char **);
|
||||
|
||||
/* SunOS shared library support routines for the linker. */
|
||||
|
||||
extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_sunos_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_sunos_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section **,
|
||||
struct bfd_section **, struct bfd_section **);
|
||||
|
||||
/* Linux shared library support routines for the linker. */
|
||||
|
||||
extern bfd_boolean bfd_i386linux_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_m68klinux_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
|
||||
(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. */
|
||||
void *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
|
||||
(bfd_window *);
|
||||
extern void bfd_free_window
|
||||
(bfd_window *);
|
||||
extern bfd_boolean bfd_get_file_window
|
||||
(bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
|
||||
|
||||
/* XCOFF support routines for the linker. */
|
||||
|
||||
extern bfd_boolean bfd_xcoff_link_record_set
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
|
||||
extern bfd_boolean bfd_xcoff_import_symbol
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
|
||||
const char *, const char *, const char *, unsigned int);
|
||||
extern bfd_boolean bfd_xcoff_export_symbol
|
||||
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
|
||||
extern bfd_boolean bfd_xcoff_link_count_reloc
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_xcoff_record_link_assignment
|
||||
(bfd *, struct bfd_link_info *, const char *);
|
||||
extern bfd_boolean bfd_xcoff_size_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *, const char *, const char *,
|
||||
unsigned long, unsigned long, unsigned long, bfd_boolean,
|
||||
int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean);
|
||||
extern bfd_boolean bfd_xcoff_link_generate_rtinit
|
||||
(bfd *, const char *, const char *, bfd_boolean);
|
||||
|
||||
/* XCOFF support routines for ar. */
|
||||
extern bfd_boolean bfd_xcoff_ar_archive_set_magic
|
||||
(bfd *, char *);
|
||||
|
||||
/* Externally visible COFF routines. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct internal_syment;
|
||||
union internal_auxent;
|
||||
#endif
|
||||
|
||||
extern bfd_boolean bfd_coff_get_syment
|
||||
(bfd *, struct bfd_symbol *, struct internal_syment *);
|
||||
|
||||
extern bfd_boolean bfd_coff_get_auxent
|
||||
(bfd *, struct bfd_symbol *, int, union internal_auxent *);
|
||||
|
||||
extern bfd_boolean bfd_coff_set_symbol_class
|
||||
(bfd *, struct bfd_symbol *, unsigned int);
|
||||
|
||||
extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
|
||||
(bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
|
||||
|
||||
/* ARM VFP11 erratum workaround support. */
|
||||
typedef enum
|
||||
{
|
||||
BFD_ARM_VFP11_FIX_DEFAULT,
|
||||
BFD_ARM_VFP11_FIX_NONE,
|
||||
BFD_ARM_VFP11_FIX_SCALAR,
|
||||
BFD_ARM_VFP11_FIX_VECTOR
|
||||
} bfd_arm_vfp11_fix;
|
||||
|
||||
extern void bfd_elf32_arm_init_maps
|
||||
(bfd *);
|
||||
|
||||
extern void bfd_elf32_arm_set_vfp11_fix
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern void bfd_elf32_arm_vfp11_fix_veneer_locations
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_arm_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_arm_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *, int);
|
||||
|
||||
extern bfd_boolean bfd_arm_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* PE ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_arm_pe_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *, int);
|
||||
|
||||
extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* ELF ARM Interworking support. Called from linker. */
|
||||
extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
|
||||
(struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_process_before_allocation
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
void bfd_elf32_arm_set_target_relocs
|
||||
(bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix,
|
||||
int, int, int);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
|
||||
(bfd *, struct bfd_link_info *);
|
||||
|
||||
/* ELF ARM mapping symbol support */
|
||||
#define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0)
|
||||
#define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1)
|
||||
#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2)
|
||||
#define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0)
|
||||
extern bfd_boolean bfd_is_arm_special_symbol_name
|
||||
(const char * name, int type);
|
||||
|
||||
extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
|
||||
|
||||
/* ARM Note section processing. */
|
||||
extern bfd_boolean bfd_arm_merge_machines
|
||||
(bfd *, bfd *);
|
||||
|
||||
extern bfd_boolean bfd_arm_update_notes
|
||||
(bfd *, const char *);
|
||||
|
||||
extern unsigned int bfd_arm_get_mach_from_notes
|
||||
(bfd *, const char *);
|
||||
|
||||
/* ARM stub generation support. Called from the linker. */
|
||||
extern int elf32_arm_setup_section_lists
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern void elf32_arm_next_input_section
|
||||
(struct bfd_link_info *, struct bfd_section *);
|
||||
extern bfd_boolean elf32_arm_size_stubs
|
||||
(bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
|
||||
struct bfd_section * (*) (const char *, struct bfd_section *), void (*) (void));
|
||||
extern bfd_boolean elf32_arm_build_stubs
|
||||
(struct bfd_link_info *);
|
||||
|
||||
/* TI COFF load page support. */
|
||||
extern void bfd_ticoff_set_section_load_page
|
||||
(struct bfd_section *, int);
|
||||
|
||||
extern int bfd_ticoff_get_section_load_page
|
||||
(struct bfd_section *);
|
||||
|
||||
/* H8/300 functions. */
|
||||
extern bfd_vma bfd_h8300_pad_address
|
||||
(bfd *, bfd_vma);
|
||||
|
||||
/* IA64 Itanium code generation. Called from linker. */
|
||||
extern void bfd_elf32_ia64_after_parse
|
||||
(int);
|
||||
|
||||
extern void bfd_elf64_ia64_after_parse
|
||||
(int);
|
||||
|
||||
/* This structure is used for a comdat section, as in PE. A comdat
|
||||
section is associated with a particular symbol. When the linker
|
||||
sees a comdat section, it keeps only one of the sections with a
|
||||
given name and associated with a given symbol. */
|
||||
|
||||
struct coff_comdat_info
|
||||
{
|
||||
/* The name of the symbol associated with a comdat section. */
|
||||
const char *name;
|
||||
|
||||
/* The local symbol table index of the symbol associated with a
|
||||
comdat section. This is only meaningful to the object file format
|
||||
specific code; it is not an index into the list returned by
|
||||
bfd_canonicalize_symtab. */
|
||||
long symbol;
|
||||
};
|
||||
|
||||
extern struct coff_comdat_info *bfd_coff_get_comdat_section
|
||||
(bfd *, struct bfd_section *);
|
||||
|
5489
external/gpl3/binutils/dist/bfd/bfd-in2.h
vendored
Normal file
5489
external/gpl3/binutils/dist/bfd/bfd-in2.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1905
external/gpl3/binutils/dist/bfd/bfd.c
vendored
Normal file
1905
external/gpl3/binutils/dist/bfd/bfd.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
external/gpl3/binutils/dist/bfd/bfd.m4
vendored
Normal file
42
external/gpl3/binutils/dist/bfd/bfd.m4
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
dnl This file was derived from acinclude.m4.
|
||||
|
||||
|
||||
dnl Check for existence of a type $1 in sys/procfs.h
|
||||
|
||||
AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE],
|
||||
[AC_MSG_CHECKING([for $1 in sys/procfs.h])
|
||||
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
|
||||
[AC_TRY_COMPILE([
|
||||
#define _SYSCALL32
|
||||
#include <sys/procfs.h>],
|
||||
[$1 avar],
|
||||
bfd_cv_have_sys_procfs_type_$1=yes,
|
||||
bfd_cv_have_sys_procfs_type_$1=no
|
||||
)])
|
||||
if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
|
||||
AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
|
||||
[Define if <sys/procfs.h> has $1.])
|
||||
fi
|
||||
AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
|
||||
])
|
||||
|
||||
|
||||
dnl Check for existence of member $2 in type $1 in sys/procfs.h
|
||||
|
||||
AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBER],
|
||||
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
|
||||
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
|
||||
[AC_TRY_COMPILE([
|
||||
#define _SYSCALL32
|
||||
#include <sys/procfs.h>],
|
||||
[$1 avar; void* aref = (void*) &avar.$2],
|
||||
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
|
||||
bfd_cv_have_sys_procfs_type_member_$1_$2=no
|
||||
)])
|
||||
if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
|
||||
AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
|
||||
[Define if <sys/procfs.h> has $1.$2.])
|
||||
fi
|
||||
AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
|
||||
])
|
||||
|
455
external/gpl3/binutils/dist/bfd/bfdio.c
vendored
Normal file
455
external/gpl3/binutils/dist/bfd/bfdio.c
vendored
Normal file
@ -0,0 +1,455 @@
|
||||
/* Low-level I/O routines for BFDs.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include <limits.h>
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0100 /* Execute by owner. */
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
#define S_IXGRP 0010 /* Execute by group. */
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
#define S_IXOTH 0001 /* Execute by others. */
|
||||
#endif
|
||||
|
||||
file_ptr
|
||||
real_ftell (FILE *file)
|
||||
{
|
||||
#if defined (HAVE_FTELLO64)
|
||||
return ftello64 (file);
|
||||
#elif defined (HAVE_FTELLO)
|
||||
return ftello (file);
|
||||
#else
|
||||
return ftell (file);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
real_fseek (FILE *file, file_ptr offset, int whence)
|
||||
{
|
||||
#if defined (HAVE_FSEEKO64)
|
||||
return fseeko64 (file, offset, whence);
|
||||
#elif defined (HAVE_FSEEKO)
|
||||
return fseeko (file, offset, whence);
|
||||
#else
|
||||
return fseek (file, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
FILE *
|
||||
real_fopen (const char *filename, const char *modes)
|
||||
{
|
||||
#if defined (HAVE_FOPEN64)
|
||||
return fopen64 (filename, modes);
|
||||
#else
|
||||
return fopen (filename, modes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_DEFINITION
|
||||
struct bfd_iovec
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
The <<struct bfd_iovec>> contains the internal file I/O class.
|
||||
Each <<BFD>> has an instance of this class and all file I/O is
|
||||
routed through it (it is assumed that the instance implements
|
||||
all methods listed below).
|
||||
|
||||
.struct bfd_iovec
|
||||
.{
|
||||
. {* To avoid problems with macros, a "b" rather than "f"
|
||||
. prefix is prepended to each method name. *}
|
||||
. {* Attempt to read/write NBYTES on ABFD's IOSTREAM storing/fetching
|
||||
. bytes starting at PTR. Return the number of bytes actually
|
||||
. transfered (a read past end-of-file returns less than NBYTES),
|
||||
. or -1 (setting <<bfd_error>>) if an error occurs. *}
|
||||
. file_ptr (*bread) (struct bfd *abfd, void *ptr, file_ptr nbytes);
|
||||
. file_ptr (*bwrite) (struct bfd *abfd, const void *ptr,
|
||||
. file_ptr nbytes);
|
||||
. {* Return the current IOSTREAM file offset, or -1 (setting <<bfd_error>>
|
||||
. if an error occurs. *}
|
||||
. file_ptr (*btell) (struct bfd *abfd);
|
||||
. {* For the following, on successful completion a value of 0 is returned.
|
||||
. Otherwise, a value of -1 is returned (and <<bfd_error>> is set). *}
|
||||
. int (*bseek) (struct bfd *abfd, file_ptr offset, int whence);
|
||||
. int (*bclose) (struct bfd *abfd);
|
||||
. int (*bflush) (struct bfd *abfd);
|
||||
. int (*bstat) (struct bfd *abfd, struct stat *sb);
|
||||
.};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Return value is amount read. */
|
||||
|
||||
bfd_size_type
|
||||
bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
|
||||
{
|
||||
size_t nread;
|
||||
|
||||
/* If this is an archive element, don't read past the end of
|
||||
this element. */
|
||||
if (abfd->arelt_data != NULL)
|
||||
{
|
||||
size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
|
||||
if (size > maxbytes)
|
||||
size = maxbytes;
|
||||
}
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim;
|
||||
bfd_size_type get;
|
||||
|
||||
bim = abfd->iostream;
|
||||
get = size;
|
||||
if (abfd->where + get > bim->size)
|
||||
{
|
||||
if (bim->size < (bfd_size_type) abfd->where)
|
||||
get = 0;
|
||||
else
|
||||
get = bim->size - abfd->where;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
}
|
||||
memcpy (ptr, bim->buffer + abfd->where, (size_t) get);
|
||||
abfd->where += get;
|
||||
return get;
|
||||
}
|
||||
|
||||
if (abfd->iovec)
|
||||
nread = abfd->iovec->bread (abfd, ptr, size);
|
||||
else
|
||||
nread = 0;
|
||||
if (nread != (size_t) -1)
|
||||
abfd->where += nread;
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
bfd_size_type
|
||||
bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
|
||||
{
|
||||
size_t nwrote;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim = abfd->iostream;
|
||||
|
||||
size = (size_t) size;
|
||||
if (abfd->where + size > bim->size)
|
||||
{
|
||||
bfd_size_type newsize, oldsize;
|
||||
|
||||
oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
bim->size = abfd->where + size;
|
||||
/* Round up to cut down on memory fragmentation */
|
||||
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
bim->buffer = bfd_realloc_or_free (bim->buffer, newsize);
|
||||
if (bim->buffer == NULL)
|
||||
{
|
||||
bim->size = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy (bim->buffer + abfd->where, ptr, (size_t) size);
|
||||
abfd->where += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
if (abfd->iovec)
|
||||
nwrote = abfd->iovec->bwrite (abfd, ptr, size);
|
||||
else
|
||||
nwrote = 0;
|
||||
|
||||
if (nwrote != (size_t) -1)
|
||||
abfd->where += nwrote;
|
||||
if (nwrote != size)
|
||||
{
|
||||
#ifdef ENOSPC
|
||||
errno = ENOSPC;
|
||||
#endif
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
}
|
||||
return nwrote;
|
||||
}
|
||||
|
||||
file_ptr
|
||||
bfd_tell (bfd *abfd)
|
||||
{
|
||||
file_ptr ptr;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return abfd->where;
|
||||
|
||||
if (abfd->iovec)
|
||||
{
|
||||
ptr = abfd->iovec->btell (abfd);
|
||||
|
||||
if (abfd->my_archive)
|
||||
ptr -= abfd->origin;
|
||||
}
|
||||
else
|
||||
ptr = 0;
|
||||
|
||||
abfd->where = ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int
|
||||
bfd_flush (bfd *abfd)
|
||||
{
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec)
|
||||
return abfd->iovec->bflush (abfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns 0 for success, negative value for failure (in which case
|
||||
bfd_get_error can retrieve the error code). */
|
||||
int
|
||||
bfd_stat (bfd *abfd, struct stat *statbuf)
|
||||
{
|
||||
int result;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
abort ();
|
||||
|
||||
if (abfd->iovec)
|
||||
result = abfd->iovec->bstat (abfd, statbuf);
|
||||
else
|
||||
result = -1;
|
||||
|
||||
if (result < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Returns 0 for success, nonzero for failure (in which case bfd_get_error
|
||||
can retrieve the error code). */
|
||||
|
||||
int
|
||||
bfd_seek (bfd *abfd, file_ptr position, int direction)
|
||||
{
|
||||
int result;
|
||||
file_ptr file_position;
|
||||
/* For the time being, a BFD may not seek to it's end. The problem
|
||||
is that we don't easily have a way to recognize the end of an
|
||||
element in an archive. */
|
||||
|
||||
BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
|
||||
|
||||
if (direction == SEEK_CUR && position == 0)
|
||||
return 0;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
{
|
||||
struct bfd_in_memory *bim;
|
||||
|
||||
bim = abfd->iostream;
|
||||
|
||||
if (direction == SEEK_SET)
|
||||
abfd->where = position;
|
||||
else
|
||||
abfd->where += position;
|
||||
|
||||
if (abfd->where > bim->size)
|
||||
{
|
||||
if ((abfd->direction == write_direction) ||
|
||||
(abfd->direction == both_direction))
|
||||
{
|
||||
bfd_size_type newsize, oldsize;
|
||||
|
||||
oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
bim->size = abfd->where;
|
||||
/* Round up to cut down on memory fragmentation */
|
||||
newsize = (bim->size + 127) & ~(bfd_size_type) 127;
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
bim->buffer = bfd_realloc_or_free (bim->buffer, newsize);
|
||||
if (bim->buffer == NULL)
|
||||
{
|
||||
bim->size = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abfd->where = bim->size;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (abfd->format != bfd_archive && abfd->my_archive == 0)
|
||||
{
|
||||
if (direction == SEEK_SET && (bfd_vma) position == abfd->where)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We need something smarter to optimize access to archives.
|
||||
Currently, anything inside an archive is read via the file
|
||||
handle for the archive. Which means that a bfd_seek on one
|
||||
component affects the `current position' in the archive, as
|
||||
well as in any other component.
|
||||
|
||||
It might be sufficient to put a spike through the cache
|
||||
abstraction, and look to the archive for the file position,
|
||||
but I think we should try for something cleaner.
|
||||
|
||||
In the meantime, no optimization for archives. */
|
||||
}
|
||||
|
||||
file_position = position;
|
||||
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
||||
file_position += abfd->origin;
|
||||
|
||||
if (abfd->iovec)
|
||||
result = abfd->iovec->bseek (abfd, file_position, direction);
|
||||
else
|
||||
result = -1;
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
int hold_errno = errno;
|
||||
|
||||
/* Force redetermination of `where' field. */
|
||||
bfd_tell (abfd);
|
||||
|
||||
/* An EINVAL error probably means that the file offset was
|
||||
absurd. */
|
||||
if (hold_errno == EINVAL)
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
else
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
errno = hold_errno;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Adjust `where' field. */
|
||||
if (direction == SEEK_SET)
|
||||
abfd->where = position;
|
||||
else
|
||||
abfd->where += position;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_mtime
|
||||
|
||||
SYNOPSIS
|
||||
long bfd_get_mtime (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the file modification time (as read from the file system, or
|
||||
from the archive header for archive members).
|
||||
|
||||
*/
|
||||
|
||||
long
|
||||
bfd_get_mtime (bfd *abfd)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (abfd->mtime_set)
|
||||
return abfd->mtime;
|
||||
|
||||
if (abfd->iovec == NULL)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec->bstat (abfd, &buf) != 0)
|
||||
return 0;
|
||||
|
||||
abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_size
|
||||
|
||||
SYNOPSIS
|
||||
file_ptr bfd_get_size (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the file size (as read from file system) for the file
|
||||
associated with BFD @var{abfd}.
|
||||
|
||||
The initial motivation for, and use of, this routine is not
|
||||
so we can get the exact size of the object the BFD applies to, since
|
||||
that might not be generally possible (archive members for example).
|
||||
It would be ideal if someone could eventually modify
|
||||
it so that such results were guaranteed.
|
||||
|
||||
Instead, we want to ask questions like "is this NNN byte sized
|
||||
object I'm about to try read from file offset YYY reasonable?"
|
||||
As as example of where we might do this, some object formats
|
||||
use string tables for which the first <<sizeof (long)>> bytes of the
|
||||
table contain the size of the table itself, including the size bytes.
|
||||
If an application tries to read what it thinks is one of these
|
||||
string tables, without some way to validate the size, and for
|
||||
some reason the size is wrong (byte swapping error, wrong location
|
||||
for the string table, etc.), the only clue is likely to be a read
|
||||
error when it tries to read the table, or a "virtual memory
|
||||
exhausted" error when it tries to allocate 15 bazillon bytes
|
||||
of space for the 15 bazillon byte table it is about to read.
|
||||
This function at least allows us to answer the question, "is the
|
||||
size reasonable?".
|
||||
*/
|
||||
|
||||
file_ptr
|
||||
bfd_get_size (bfd *abfd)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return ((struct bfd_in_memory *) abfd->iostream)->size;
|
||||
|
||||
if (abfd->iovec == NULL)
|
||||
return 0;
|
||||
|
||||
if (abfd->iovec->bstat (abfd, &buf) != 0)
|
||||
return 0;
|
||||
|
||||
return buf.st_size;
|
||||
}
|
257
external/gpl3/binutils/dist/bfd/bfdwin.c
vendored
Normal file
257
external/gpl3/binutils/dist/bfd/bfdwin.c
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
/* Support for memory-mapped windows into a BFD.
|
||||
Copyright 1995, 1996, 2001, 2002, 2003, 2005, 2007, 2008
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Currently, if USE_MMAP is undefined, none if the window stuff is
|
||||
used. Okay, so it's mis-named. At least the command-line option
|
||||
"--without-mmap" is more obvious than "--without-windows" or some
|
||||
such. */
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
#undef HAVE_MPROTECT /* code's not tested yet */
|
||||
|
||||
#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
static int debug_windows;
|
||||
|
||||
/* The idea behind the next and refcount fields is that one mapped
|
||||
region can suffice for multiple read-only windows or multiple
|
||||
non-overlapping read-write windows. It's not implemented yet
|
||||
though. */
|
||||
|
||||
/*
|
||||
INTERNAL_DEFINITION
|
||||
|
||||
.struct _bfd_window_internal {
|
||||
. struct _bfd_window_internal *next;
|
||||
. void *data;
|
||||
. bfd_size_type size;
|
||||
. int refcount : 31; {* should be enough... *}
|
||||
. unsigned mapped : 1; {* 1 = mmap, 0 = malloc *}
|
||||
.};
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_init_window (bfd_window *windowp)
|
||||
{
|
||||
windowp->data = 0;
|
||||
windowp->i = 0;
|
||||
windowp->size = 0;
|
||||
}
|
||||
|
||||
void
|
||||
bfd_free_window (bfd_window *windowp)
|
||||
{
|
||||
bfd_window_internal *i = windowp->i;
|
||||
windowp->i = 0;
|
||||
windowp->data = 0;
|
||||
if (i == 0)
|
||||
return;
|
||||
i->refcount--;
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "freeing window @%p<%p,%lx,%p>\n",
|
||||
windowp, windowp->data, windowp->size, windowp->i);
|
||||
if (i->refcount != 0)
|
||||
return;
|
||||
|
||||
if (i->mapped)
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
munmap (i->data, i->size);
|
||||
goto no_free;
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MPROTECT
|
||||
mprotect (i->data, i->size, PROT_READ | PROT_WRITE);
|
||||
#endif
|
||||
free (i->data);
|
||||
#ifdef HAVE_MMAP
|
||||
no_free:
|
||||
#endif
|
||||
i->data = 0;
|
||||
/* There should be no more references to i at this point. */
|
||||
free (i);
|
||||
}
|
||||
|
||||
static int ok_to_map = 1;
|
||||
|
||||
bfd_boolean
|
||||
bfd_get_file_window (bfd *abfd,
|
||||
file_ptr offset,
|
||||
bfd_size_type size,
|
||||
bfd_window *windowp,
|
||||
bfd_boolean writable)
|
||||
{
|
||||
static size_t pagesize;
|
||||
bfd_window_internal *i = windowp->i;
|
||||
bfd_size_type size_to_alloc = size;
|
||||
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
|
||||
abfd, (long) offset, (long) size,
|
||||
windowp, windowp->data, (unsigned long) windowp->size,
|
||||
windowp->i, writable);
|
||||
|
||||
/* Make sure we know the page size, so we can be friendly to mmap. */
|
||||
if (pagesize == 0)
|
||||
pagesize = getpagesize ();
|
||||
if (pagesize == 0)
|
||||
abort ();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = bfd_zmalloc (sizeof (bfd_window_internal));
|
||||
windowp->i = i;
|
||||
if (i == 0)
|
||||
return FALSE;
|
||||
i->data = 0;
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
if (ok_to_map
|
||||
&& (i->data == 0 || i->mapped == 1)
|
||||
&& (abfd->flags & BFD_IN_MEMORY) == 0)
|
||||
{
|
||||
file_ptr file_offset, offset2;
|
||||
size_t real_size;
|
||||
int fd;
|
||||
|
||||
/* Find the real file and the real offset into it. */
|
||||
while (abfd->my_archive != NULL)
|
||||
{
|
||||
offset += abfd->origin;
|
||||
abfd = abfd->my_archive;
|
||||
}
|
||||
|
||||
/* Seek into the file, to ensure it is open if cacheable. */
|
||||
if (abfd->iostream == NULL
|
||||
&& (abfd->iovec == NULL
|
||||
|| abfd->iovec->bseek (abfd, offset, SEEK_SET) != 0))
|
||||
return FALSE;
|
||||
fd = fileno ((FILE *) abfd->iostream);
|
||||
|
||||
/* Compute offsets and size for mmap and for the user's data. */
|
||||
offset2 = offset % pagesize;
|
||||
if (offset2 < 0)
|
||||
abort ();
|
||||
file_offset = offset - offset2;
|
||||
real_size = offset + size - file_offset;
|
||||
real_size = real_size + pagesize - 1;
|
||||
real_size -= real_size % pagesize;
|
||||
|
||||
/* If we're re-using a memory region, make sure it's big enough. */
|
||||
if (i->data && i->size < size)
|
||||
{
|
||||
munmap (i->data, i->size);
|
||||
i->data = 0;
|
||||
}
|
||||
i->data = mmap (i->data, real_size,
|
||||
writable ? PROT_WRITE | PROT_READ : PROT_READ,
|
||||
(writable
|
||||
? MAP_FILE | MAP_PRIVATE
|
||||
: MAP_FILE | MAP_SHARED),
|
||||
fd, file_offset);
|
||||
if (i->data == (void *) -1)
|
||||
{
|
||||
/* An error happened. Report it, or try using malloc, or
|
||||
something. */
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
i->data = 0;
|
||||
windowp->data = 0;
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\t\tmmap failed!\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
|
||||
(long) real_size, i->data, (long) offset2);
|
||||
i->size = real_size;
|
||||
windowp->data = (bfd_byte *) i->data + offset2;
|
||||
windowp->size = size;
|
||||
i->mapped = 1;
|
||||
return TRUE;
|
||||
}
|
||||
else if (debug_windows)
|
||||
{
|
||||
if (ok_to_map)
|
||||
fprintf (stderr, _("not mapping: data=%lx mapped=%d\n"),
|
||||
(unsigned long) i->data, (int) i->mapped);
|
||||
else
|
||||
fprintf (stderr, _("not mapping: env var not set\n"));
|
||||
}
|
||||
#else
|
||||
ok_to_map = 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MPROTECT
|
||||
if (!writable)
|
||||
{
|
||||
size_to_alloc += pagesize - 1;
|
||||
size_to_alloc -= size_to_alloc % pagesize;
|
||||
}
|
||||
#endif
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\n\t%s(%6ld)",
|
||||
i->data ? "realloc" : " malloc", (long) size_to_alloc);
|
||||
i->data = bfd_realloc_or_free (i->data, size_to_alloc);
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\t-> %p\n", i->data);
|
||||
if (i->data == NULL)
|
||||
{
|
||||
if (size_to_alloc == 0)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
i->refcount = 1;
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
i->size = bfd_bread (i->data, size, abfd);
|
||||
if (i->size != size)
|
||||
return FALSE;
|
||||
i->mapped = 0;
|
||||
#ifdef HAVE_MPROTECT
|
||||
if (!writable)
|
||||
{
|
||||
if (debug_windows)
|
||||
fprintf (stderr, "\tmprotect (%p, %ld, PROT_READ)\n", i->data,
|
||||
(long) i->size);
|
||||
mprotect (i->data, i->size, PROT_READ);
|
||||
}
|
||||
#endif
|
||||
windowp->data = i->data;
|
||||
windowp->size = i->size;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* USE_MMAP */
|
377
external/gpl3/binutils/dist/bfd/binary.c
vendored
Normal file
377
external/gpl3/binutils/dist/bfd/binary.c
vendored
Normal file
@ -0,0 +1,377 @@
|
||||
/* BFD back-end for binary objects.
|
||||
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2006, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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 "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "safe-ctype.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
|
||||
|
||||
/* Set by external programs - specifies the BFD architecture and
|
||||
machine number to be uses when creating binary BFDs. */
|
||||
enum bfd_architecture bfd_external_binary_architecture = bfd_arch_unknown;
|
||||
unsigned long bfd_external_machine = 0;
|
||||
|
||||
/* Create a binary object. Invoked via bfd_set_format. */
|
||||
|
||||
static bfd_boolean
|
||||
binary_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
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 (bfd *abfd)
|
||||
{
|
||||
struct stat statbuf;
|
||||
asection *sec;
|
||||
flagword flags;
|
||||
|
||||
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. */
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
|
||||
sec = bfd_make_section_with_flags (abfd, ".data", flags);
|
||||
if (sec == NULL)
|
||||
return NULL;
|
||||
sec->vma = 0;
|
||||
sec->size = statbuf.st_size;
|
||||
sec->filepos = 0;
|
||||
|
||||
abfd->tdata.any = (void *) sec;
|
||||
|
||||
if (bfd_get_arch_info (abfd) != NULL)
|
||||
{
|
||||
if ((bfd_get_arch_info (abfd)->arch == bfd_arch_unknown)
|
||||
&& (bfd_external_binary_architecture != bfd_arch_unknown))
|
||||
bfd_set_arch_info (abfd, bfd_lookup_arch
|
||||
(bfd_external_binary_architecture, bfd_external_machine));
|
||||
}
|
||||
|
||||
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 bfd_boolean
|
||||
binary_get_section_contents (bfd *abfd,
|
||||
asection *section ATTRIBUTE_UNUSED,
|
||||
void * location,
|
||||
file_ptr offset,
|
||||
bfd_size_type count)
|
||||
{
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|
||||
|| bfd_bread (location, 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 (bfd *abfd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (BIN_SYMS + 1) * sizeof (asymbol *);
|
||||
}
|
||||
|
||||
/* Create a symbol name based on the bfd's filename. */
|
||||
|
||||
static char *
|
||||
mangle_name (bfd *abfd, char *suffix)
|
||||
{
|
||||
bfd_size_type size;
|
||||
char *buf;
|
||||
char *p;
|
||||
|
||||
size = (strlen (bfd_get_filename (abfd))
|
||||
+ strlen (suffix)
|
||||
+ sizeof "_binary__");
|
||||
|
||||
buf = 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_canonicalize_symtab (bfd *abfd, asymbol **alocation)
|
||||
{
|
||||
asection *sec = (asection *) abfd->tdata.any;
|
||||
asymbol *syms;
|
||||
unsigned int i;
|
||||
bfd_size_type amt = BIN_SYMS * sizeof (asymbol);
|
||||
|
||||
syms = bfd_alloc (abfd, amt);
|
||||
if (syms == NULL)
|
||||
return -1;
|
||||
|
||||
/* 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->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->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;
|
||||
}
|
||||
|
||||
#define binary_make_empty_symbol _bfd_generic_make_empty_symbol
|
||||
#define binary_print_symbol _bfd_nosymbols_print_symbol
|
||||
|
||||
/* Get information about a symbol. */
|
||||
|
||||
static void
|
||||
binary_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
|
||||
asymbol *symbol,
|
||||
symbol_info *ret)
|
||||
{
|
||||
bfd_symbol_info (symbol, ret);
|
||||
}
|
||||
|
||||
#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name
|
||||
#define binary_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define binary_find_inliner_info _bfd_nosymbols_find_inliner_info
|
||||
#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_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
|
||||
|
||||
/* 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 bfd_boolean
|
||||
binary_set_section_contents (bfd *abfd,
|
||||
asection *sec,
|
||||
const void * data,
|
||||
file_ptr offset,
|
||||
bfd_size_type size)
|
||||
{
|
||||
if (size == 0)
|
||||
return TRUE;
|
||||
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
bfd_boolean found_low;
|
||||
bfd_vma low;
|
||||
asection *s;
|
||||
|
||||
/* The lowest section LMA sets the virtual address of the start
|
||||
of the file. We use this to set the file position of all the
|
||||
sections. */
|
||||
found_low = FALSE;
|
||||
low = 0;
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
if (((s->flags
|
||||
& (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_NEVER_LOAD))
|
||||
== (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC))
|
||||
&& (s->size > 0)
|
||||
&& (! found_low || s->lma < low))
|
||||
{
|
||||
low = s->lma;
|
||||
found_low = TRUE;
|
||||
}
|
||||
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
{
|
||||
s->filepos = s->lma - low;
|
||||
|
||||
/* Skip following warning check for sections that will not
|
||||
occupy file space. */
|
||||
if ((s->flags
|
||||
& (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_NEVER_LOAD))
|
||||
!= (SEC_HAS_CONTENTS | SEC_ALLOC)
|
||||
|| (s->size == 0))
|
||||
continue;
|
||||
|
||||
/* If attempting to generate a binary file from a bfd with
|
||||
LMA's all over the place, huge (sparse?) binary files may
|
||||
result. This condition attempts to detect this situation
|
||||
and print a warning. Better heuristics would be nice to
|
||||
have. */
|
||||
|
||||
if (s->filepos < 0)
|
||||
(*_bfd_error_handler)
|
||||
(_("Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."),
|
||||
bfd_get_section_name (abfd, s),
|
||||
(unsigned long) s->filepos);
|
||||
}
|
||||
|
||||
abfd->output_has_begun = TRUE;
|
||||
}
|
||||
|
||||
/* We don't want to output anything for a section that is neither
|
||||
loaded nor allocated. The contents of such a section are not
|
||||
meaningful in the binary format. */
|
||||
if ((sec->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
|
||||
return TRUE;
|
||||
if ((sec->flags & SEC_NEVER_LOAD) != 0)
|
||||
return TRUE;
|
||||
|
||||
return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
|
||||
}
|
||||
|
||||
/* No space is required for header information. */
|
||||
|
||||
static int
|
||||
binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED)
|
||||
{
|
||||
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_gc_sections bfd_generic_gc_sections
|
||||
#define binary_bfd_merge_sections bfd_generic_merge_sections
|
||||
#define binary_bfd_is_group_section bfd_generic_is_group_section
|
||||
#define binary_bfd_discard_group bfd_generic_discard_group
|
||||
#define binary_section_already_linked _bfd_generic_section_already_linked
|
||||
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
||||
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms
|
||||
#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_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 (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (binary),
|
||||
BFD_JUMP_TABLE_LINK (binary),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
NULL
|
||||
};
|
1478
external/gpl3/binutils/dist/bfd/bout.c
vendored
Normal file
1478
external/gpl3/binutils/dist/bfd/bout.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
558
external/gpl3/binutils/dist/bfd/cache.c
vendored
Normal file
558
external/gpl3/binutils/dist/bfd/cache.c
vendored
Normal file
@ -0,0 +1,558 @@
|
||||
/* BFD library -- caching of file descriptors.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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.
|
||||
|
||||
SUBSECTION
|
||||
Caching functions
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
/* In some cases we can optimize cache operation when reopening files.
|
||||
For instance, a flush is entirely unnecessary if the file is already
|
||||
closed, so a flush would use CACHE_NO_OPEN. Similarly, a seek using
|
||||
SEEK_SET or SEEK_END need not first seek to the current position.
|
||||
For stat we ignore seek errors, just in case the file has changed
|
||||
while we weren't looking. If it has, then it's possible that the
|
||||
file is shorter and we don't want a seek error to prevent us doing
|
||||
the stat. */
|
||||
enum cache_flag {
|
||||
CACHE_NORMAL = 0,
|
||||
CACHE_NO_OPEN = 1,
|
||||
CACHE_NO_SEEK = 2,
|
||||
CACHE_NO_SEEK_ERROR = 4
|
||||
};
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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. */
|
||||
|
||||
static bfd *bfd_last_cache = NULL;
|
||||
|
||||
/* Insert a BFD into the cache. */
|
||||
|
||||
static void
|
||||
insert (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 void
|
||||
snip (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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Close a BFD and remove it from the cache. */
|
||||
|
||||
static bfd_boolean
|
||||
bfd_cache_delete (bfd *abfd)
|
||||
{
|
||||
bfd_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;
|
||||
}
|
||||
|
||||
/* We need to open a new file, and the cache is full. Find the least
|
||||
recently used cacheable BFD and close it. */
|
||||
|
||||
static bfd_boolean
|
||||
close_one (void)
|
||||
{
|
||||
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 = real_ftell ((FILE *) kill->iostream);
|
||||
|
||||
return bfd_cache_delete (kill);
|
||||
}
|
||||
|
||||
/* 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, flag) \
|
||||
((x) == bfd_last_cache \
|
||||
? (FILE *) (bfd_last_cache->iostream) \
|
||||
: bfd_cache_lookup_worker (x, flag))
|
||||
|
||||
/* 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. It will return NULL
|
||||
if it is unable to (re)open the @var{abfd}. */
|
||||
|
||||
static FILE *
|
||||
bfd_cache_lookup_worker (bfd *abfd, enum cache_flag flag)
|
||||
{
|
||||
bfd *orig_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);
|
||||
}
|
||||
return (FILE *) abfd->iostream;
|
||||
}
|
||||
|
||||
if (flag & CACHE_NO_OPEN)
|
||||
return NULL;
|
||||
|
||||
if (bfd_open_file (abfd) == NULL)
|
||||
;
|
||||
else if (!(flag & CACHE_NO_SEEK)
|
||||
&& real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0
|
||||
&& !(flag & CACHE_NO_SEEK_ERROR))
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
else
|
||||
return (FILE *) abfd->iostream;
|
||||
|
||||
(*_bfd_error_handler) (_("reopening %B: %s\n"),
|
||||
orig_bfd, bfd_errmsg (bfd_get_error ()));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static file_ptr
|
||||
cache_btell (struct bfd *abfd)
|
||||
{
|
||||
FILE *f = bfd_cache_lookup (abfd, CACHE_NO_OPEN);
|
||||
if (f == NULL)
|
||||
return abfd->where;
|
||||
return real_ftell (f);
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bseek (struct bfd *abfd, file_ptr offset, int whence)
|
||||
{
|
||||
FILE *f = bfd_cache_lookup (abfd, whence != SEEK_CUR ? CACHE_NO_SEEK : 0);
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
return real_fseek (f, offset, whence);
|
||||
}
|
||||
|
||||
/* Note that archive entries don't have streams; they share their parent's.
|
||||
This allows someone to play with the iostream behind BFD's back.
|
||||
|
||||
Also, note that the origin pointer points to the beginning of a file's
|
||||
contents (0 for non-archive elements). For archive entries this is the
|
||||
first octet in the file, NOT the beginning of the archive header. */
|
||||
|
||||
static file_ptr
|
||||
cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes)
|
||||
{
|
||||
FILE *f;
|
||||
file_ptr nread;
|
||||
/* FIXME - this looks like an optimization, but it's really to cover
|
||||
up for a feature of some OSs (not solaris - sigh) that
|
||||
ld/pe-dll.c takes advantage of (apparently) when it creates BFDs
|
||||
internally and tries to link against them. BFD seems to be smart
|
||||
enough to realize there are no symbol records in the "file" that
|
||||
doesn't exist but attempts to read them anyway. On Solaris,
|
||||
attempting to read zero bytes from a NULL file results in a core
|
||||
dump, but on other platforms it just returns zero bytes read.
|
||||
This makes it to something reasonable. - DJ */
|
||||
if (nbytes == 0)
|
||||
return 0;
|
||||
|
||||
f = bfd_cache_lookup (abfd, 0);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
|
||||
#if defined (__VAX) && defined (VMS)
|
||||
/* Apparently fread on Vax VMS does not keep the record length
|
||||
information. */
|
||||
nread = read (fileno (f), buf, nbytes);
|
||||
/* Set bfd_error if we did not read as much data as we expected. If
|
||||
the read failed due to an error set the bfd_error_system_call,
|
||||
else set bfd_error_file_truncated. */
|
||||
if (nread == (file_ptr)-1)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
nread = fread (buf, 1, nbytes, f);
|
||||
/* Set bfd_error if we did not read as much data as we expected. If
|
||||
the read failed due to an error set the bfd_error_system_call,
|
||||
else set bfd_error_file_truncated. */
|
||||
if (nread < nbytes && ferror (f))
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (nread < nbytes)
|
||||
/* This may or may not be an error, but in case the calling code
|
||||
bails out because of it, set the right error code. */
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return nread;
|
||||
}
|
||||
|
||||
static file_ptr
|
||||
cache_bread (struct bfd *abfd, void *buf, file_ptr nbytes)
|
||||
{
|
||||
file_ptr nread = 0;
|
||||
|
||||
/* Some filesystems are unable to handle reads that are too large
|
||||
(for instance, NetApp shares with oplocks turned off). To avoid
|
||||
hitting this limitation, we read the buffer in chunks of 8MB max. */
|
||||
while (nread < nbytes)
|
||||
{
|
||||
const file_ptr max_chunk_size = 0x800000;
|
||||
file_ptr chunk_size = nbytes - nread;
|
||||
file_ptr chunk_nread;
|
||||
|
||||
if (chunk_size > max_chunk_size)
|
||||
chunk_size = max_chunk_size;
|
||||
|
||||
chunk_nread = cache_bread_1 (abfd, buf + nread, chunk_size);
|
||||
|
||||
/* Update the nread count.
|
||||
|
||||
We just have to be careful of the case when cache_bread_1 returns
|
||||
a negative count: If this is our first read, then set nread to
|
||||
that negative count in order to return that negative value to the
|
||||
caller. Otherwise, don't add it to our total count, or we would
|
||||
end up returning a smaller number of bytes read than we actually
|
||||
did. */
|
||||
if (nread == 0 || chunk_nread > 0)
|
||||
nread += chunk_nread;
|
||||
|
||||
if (chunk_nread < chunk_size)
|
||||
break;
|
||||
}
|
||||
|
||||
return nread;
|
||||
}
|
||||
|
||||
static file_ptr
|
||||
cache_bwrite (struct bfd *abfd, const void *where, file_ptr nbytes)
|
||||
{
|
||||
file_ptr nwrite;
|
||||
FILE *f = bfd_cache_lookup (abfd, 0);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
nwrite = fwrite (where, 1, nbytes, f);
|
||||
if (nwrite < nbytes && ferror (f))
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return -1;
|
||||
}
|
||||
return nwrite;
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bclose (struct bfd *abfd)
|
||||
{
|
||||
return bfd_cache_close (abfd);
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bflush (struct bfd *abfd)
|
||||
{
|
||||
int sts;
|
||||
FILE *f = bfd_cache_lookup (abfd, CACHE_NO_OPEN);
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
sts = fflush (f);
|
||||
if (sts < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return sts;
|
||||
}
|
||||
|
||||
static int
|
||||
cache_bstat (struct bfd *abfd, struct stat *sb)
|
||||
{
|
||||
int sts;
|
||||
FILE *f = bfd_cache_lookup (abfd, CACHE_NO_SEEK_ERROR);
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
sts = fstat (fileno (f), sb);
|
||||
if (sts < 0)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return sts;
|
||||
}
|
||||
|
||||
static const struct bfd_iovec cache_iovec = {
|
||||
&cache_bread, &cache_bwrite, &cache_btell, &cache_bseek,
|
||||
&cache_bclose, &cache_bflush, &cache_bstat
|
||||
};
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_init
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_cache_init (bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Add a newly opened BFD to the cache.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_init (bfd *abfd)
|
||||
{
|
||||
BFD_ASSERT (abfd->iostream != NULL);
|
||||
if (open_files >= BFD_CACHE_MAX_OPEN)
|
||||
{
|
||||
if (! close_one ())
|
||||
return FALSE;
|
||||
}
|
||||
abfd->iovec = &cache_iovec;
|
||||
insert (abfd);
|
||||
++open_files;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_close
|
||||
|
||||
SYNOPSIS
|
||||
bfd_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.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_close (bfd *abfd)
|
||||
{
|
||||
if (abfd->iovec != &cache_iovec)
|
||||
return TRUE;
|
||||
|
||||
if (abfd->iostream == NULL)
|
||||
/* Previously closed. */
|
||||
return TRUE;
|
||||
|
||||
return bfd_cache_delete (abfd);
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_cache_close_all
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_cache_close_all (void);
|
||||
|
||||
DESCRIPTION
|
||||
Remove all BFDs from the cache. If the attached file is open,
|
||||
then close it too.
|
||||
|
||||
RETURNS
|
||||
<<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
|
||||
returned if all is well.
|
||||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_cache_close_all ()
|
||||
{
|
||||
bfd_boolean ret = TRUE;
|
||||
|
||||
while (bfd_last_cache != NULL)
|
||||
ret &= bfd_cache_close (bfd_last_cache);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
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 (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) real_fopen (abfd->filename, FOPEN_RB);
|
||||
break;
|
||||
case both_direction:
|
||||
case write_direction:
|
||||
if (abfd->opened_once)
|
||||
{
|
||||
abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RUB);
|
||||
if (abfd->iostream == NULL)
|
||||
abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Create the file.
|
||||
|
||||
Some operating systems won't let us overwrite a running
|
||||
binary. For them, we want to unlink the file first.
|
||||
|
||||
However, gcc 2.95 will create temporary files using
|
||||
O_EXCL and tight permissions to prevent other users from
|
||||
substituting other .o files during the compilation. gcc
|
||||
will then tell the assembler to use the newly created
|
||||
file as an output file. If we unlink the file here, we
|
||||
open a brief window when another user could still
|
||||
substitute a file.
|
||||
|
||||
So we unlink the output file if and only if it has
|
||||
non-zero size. */
|
||||
#ifndef __MSDOS__
|
||||
/* Don't do this for MSDOS: it doesn't care about overwriting
|
||||
a running binary, but if this file is already open by
|
||||
another BFD, we will be in deep trouble if we delete an
|
||||
open file. In fact, objdump does just that if invoked with
|
||||
the --info option. */
|
||||
struct stat s;
|
||||
|
||||
if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
|
||||
unlink_if_ordinary (abfd->filename);
|
||||
#endif
|
||||
abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
|
||||
abfd->opened_once = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (abfd->iostream == NULL)
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
else
|
||||
{
|
||||
if (! bfd_cache_init (abfd))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (FILE *) abfd->iostream;
|
||||
}
|
34
external/gpl3/binutils/dist/bfd/cf-i386lynx.c
vendored
Normal file
34
external/gpl3/binutils/dist/bfd/cf-i386lynx.c
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/* BFD back-end for Intel 386 COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
|
||||
#define TARGET_SYM i386lynx_coff_vec
|
||||
#define TARGET_NAME "coff-i386-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define bfd_pe_print_pdata NULL
|
||||
|
||||
#include "coff-i386.c"
|
29
external/gpl3/binutils/dist/bfd/cf-sparclynx.c
vendored
Normal file
29
external/gpl3/binutils/dist/bfd/cf-sparclynx.c
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/* BFD back-end for Sparc COFF LynxOS files.
|
||||
Copyright 1993, 1994, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define TARGET_SYM sparclynx_coff_vec
|
||||
#define TARGET_NAME "coff-sparc-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-sparc.c"
|
422
external/gpl3/binutils/dist/bfd/cisco-core.c
vendored
Normal file
422
external/gpl3/binutils/dist/bfd/cisco-core.c
vendored
Normal file
@ -0,0 +1,422 @@
|
||||
/* BFD back-end for CISCO crash dumps.
|
||||
Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004, 2006, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
/* core_file_failing_signal returns a host signal (this probably should
|
||||
be fixed). */
|
||||
#include <signal.h>
|
||||
|
||||
/* for MSVC builds */
|
||||
#ifndef SIGTRAP
|
||||
# define SIGTRAP 5
|
||||
#endif
|
||||
#ifndef SIGEMT
|
||||
# define SIGEMT 6
|
||||
#endif
|
||||
#ifndef SIGBUS
|
||||
# define SIGBUS 10
|
||||
#endif
|
||||
|
||||
int crash_info_locs[] = {
|
||||
0x0250, /* mips, ppc, x86, i960 */
|
||||
0x0400, /* m68k, mips, x86, i960 */
|
||||
0x0FFC, /* m68k, mips, ppc, x86, i960 */
|
||||
0x3000, /* ppc */
|
||||
0x4FFC, /* m68k */
|
||||
-1
|
||||
};
|
||||
|
||||
#define CRASH_MAGIC 0xdead1234
|
||||
#define MASK_ADDR(x) ((x) & 0x0fffffff) /* Mask crash info address */
|
||||
|
||||
typedef enum {
|
||||
CRASH_REASON_NOTCRASHED = 0,
|
||||
CRASH_REASON_EXCEPTION = 1,
|
||||
CRASH_REASON_CORRUPT = 2,
|
||||
} crashreason;
|
||||
|
||||
typedef struct {
|
||||
char magic[4]; /* Magic number */
|
||||
char version[4]; /* Version number */
|
||||
char reason[4]; /* Crash reason */
|
||||
char cpu_vector[4]; /* CPU vector for exceptions */
|
||||
char registers[4]; /* Pointer to saved registers */
|
||||
char rambase[4]; /* Base of RAM (not in V1 crash info) */
|
||||
char textbase[4]; /* Base of .text section (not in V3 crash info) */
|
||||
char database[4]; /* Base of .data section (not in V3 crash info) */
|
||||
char bssbase[4]; /* Base of .bss section (not in V3 crash info) */
|
||||
} crashinfo_external;
|
||||
|
||||
struct cisco_core_struct
|
||||
{
|
||||
int sig;
|
||||
};
|
||||
|
||||
static const bfd_target *cisco_core_file_validate PARAMS ((bfd *, int));
|
||||
static const bfd_target *cisco_core_file_p PARAMS ((bfd *));
|
||||
char *cisco_core_file_failing_command PARAMS ((bfd *));
|
||||
int cisco_core_file_failing_signal PARAMS ((bfd *));
|
||||
#define cisco_core_file_matches_executable_p generic_core_file_matches_executable_p
|
||||
|
||||
/* Examine the file for a crash info struct at the offset given by
|
||||
CRASH_INFO_LOC. */
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_validate (abfd, crash_info_loc)
|
||||
bfd *abfd;
|
||||
int crash_info_loc;
|
||||
{
|
||||
char buf[4];
|
||||
unsigned int crashinfo_offset;
|
||||
crashinfo_external crashinfo;
|
||||
bfd_size_type nread;
|
||||
unsigned int magic;
|
||||
unsigned int version;
|
||||
unsigned int rambase;
|
||||
sec_ptr asect;
|
||||
struct stat statbuf;
|
||||
bfd_size_type amt;
|
||||
flagword flags;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) crash_info_loc, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
nread = bfd_bread (buf, (bfd_size_type) 4, abfd);
|
||||
if (nread != 4)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
crashinfo_offset = MASK_ADDR (bfd_get_32 (abfd, buf));
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) crashinfo_offset, SEEK_SET) != 0)
|
||||
{
|
||||
/* Most likely we failed because of a bogus (huge) offset */
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nread = bfd_bread (&crashinfo, (bfd_size_type) 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;
|
||||
}
|
||||
|
||||
magic = bfd_get_32 (abfd, crashinfo.magic);
|
||||
if (magic != CRASH_MAGIC)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
version = bfd_get_32 (abfd, crashinfo.version);
|
||||
if (version == 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
else if (version == 1)
|
||||
{
|
||||
/* V1 core dumps don't specify the dump base, assume 0 */
|
||||
rambase = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rambase = bfd_get_32 (abfd, crashinfo.rambase);
|
||||
}
|
||||
|
||||
/* OK, we believe you. You're a core file. */
|
||||
|
||||
amt = sizeof (struct cisco_core_struct);
|
||||
abfd->tdata.cisco_core_data = (struct cisco_core_struct *) bfd_zmalloc (amt);
|
||||
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:
|
||||
#ifndef SIGEMT
|
||||
#define SIGEMT SIGTRAP
|
||||
#endif
|
||||
/* "software generated"*/
|
||||
abfd->tdata.cisco_core_data->sig = SIGEMT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Unknown crash reason. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Create a ".data" section that maps the entire file, which is
|
||||
essentially a dump of the target system's RAM. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
asect = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
/* The size of memory is the size of the core file itself. */
|
||||
asect->size = statbuf.st_size;
|
||||
asect->vma = rambase;
|
||||
asect->filepos = 0;
|
||||
|
||||
/* Create a ".crash" section to allow access to the saved
|
||||
crash information. */
|
||||
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
asect = bfd_make_section_anyway_with_flags (abfd, ".crash", flags);
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->vma = 0;
|
||||
asect->filepos = crashinfo_offset;
|
||||
asect->size = sizeof (crashinfo);
|
||||
|
||||
/* Create a ".reg" section to allow access to the saved
|
||||
registers. */
|
||||
|
||||
asect = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->vma = 0;
|
||||
asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
|
||||
/* Since we don't know the exact size of the saved register info,
|
||||
choose a register section size that is either the remaining part
|
||||
of the file, or 1024, whichever is smaller. */
|
||||
nread = statbuf.st_size - asect->filepos;
|
||||
asect->size = (nread < 1024) ? nread : 1024;
|
||||
|
||||
return abfd->xvec;
|
||||
|
||||
/* Get here if we have already started filling out the BFD
|
||||
and there is an error of some kind. */
|
||||
|
||||
error_return:
|
||||
bfd_release (abfd, abfd->tdata.any);
|
||||
abfd->tdata.any = NULL;
|
||||
bfd_section_list_clear (abfd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int *crash_info_locp;
|
||||
const bfd_target *target = NULL;
|
||||
|
||||
for (crash_info_locp = crash_info_locs;
|
||||
*crash_info_locp != -1 && target == NULL;
|
||||
crash_info_locp++)
|
||||
{
|
||||
target = cisco_core_file_validate (abfd, *crash_info_locp);
|
||||
}
|
||||
return (target);
|
||||
}
|
||||
|
||||
char *
|
||||
cisco_core_file_failing_command (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
cisco_core_file_failing_signal (abfd)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return abfd->tdata.cisco_core_data->sig;
|
||||
}
|
||||
|
||||
extern const bfd_target cisco_core_little_vec;
|
||||
|
||||
const bfd_target cisco_core_big_vec =
|
||||
{
|
||||
"cisco-ios-core-big",
|
||||
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),
|
||||
|
||||
& cisco_core_little_vec,
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
|
||||
const bfd_target cisco_core_little_vec =
|
||||
{
|
||||
"cisco-ios-core-little",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
cisco_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (cisco),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
&cisco_core_big_vec,
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
2443
external/gpl3/binutils/dist/bfd/coff-alpha.c
vendored
Normal file
2443
external/gpl3/binutils/dist/bfd/coff-alpha.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
124
external/gpl3/binutils/dist/bfd/coff-apollo.c
vendored
Normal file
124
external/gpl3/binutils/dist/bfd/coff-apollo.c
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/* BFD back-end for Apollo 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001, 2002, 2003,
|
||||
2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.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. */
|
||||
|
||||
extern void apollo_rtype2howto PARAMS ((arelent *, int));
|
||||
extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
#ifndef ONLY_DECLARE_RELOCS
|
||||
|
||||
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);
|
||||
|
||||
#define bfd_pe_print_pdata NULL
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM apollocoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "apollo-m68k"
|
||||
#endif
|
||||
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
#else
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, 0, NULL, COFF_SWAP_TABLE)
|
||||
#endif
|
2567
external/gpl3/binutils/dist/bfd/coff-arm.c
vendored
Normal file
2567
external/gpl3/binutils/dist/bfd/coff-arm.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
141
external/gpl3/binutils/dist/bfd/coff-aux.c
vendored
Normal file
141
external/gpl3/binutils/dist/bfd/coff-aux.c
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
/* BFD back-end for Apple M68K COFF A/UX 3.x files.
|
||||
Copyright 1996, 1997, 2000, 2002, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Written by Richard Henderson <rth@tamu.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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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 STATIC_RELOCS
|
||||
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
|
||||
static bfd_boolean coff_m68k_aux_link_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
|
||||
asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
|
||||
struct bfd_link_hash_entry **));
|
||||
|
||||
#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
|
||||
#include "coff-m68k.c"
|
||||
|
||||
/* 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. */
|
||||
|
||||
static bfd_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;
|
||||
bfd_boolean copy;
|
||||
bfd_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);
|
||||
}
|
46
external/gpl3/binutils/dist/bfd/coff-go32.c
vendored
Normal file
46
external/gpl3/binutils/dist/bfd/coff-go32.c
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/* BFD back-end for Intel 386 COFF files (DJGPP variant).
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define TARGET_SYM go32coff_vec
|
||||
#define TARGET_NAME "coff-go32"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
#define COFF_LONG_SECTION_NAMES
|
||||
#define COFF_SUPPORT_GNU_LINKONCE
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define COFF_SECTION_ALIGNMENT_ENTRIES \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.d"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.t"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.r"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
|
||||
|
||||
#include "coff-i386.c"
|
1445
external/gpl3/binutils/dist/bfd/coff-h8300.c
vendored
Normal file
1445
external/gpl3/binutils/dist/bfd/coff-h8300.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
313
external/gpl3/binutils/dist/bfd/coff-h8500.c
vendored
Normal file
313
external/gpl3/binutils/dist/bfd/coff-h8500.c
vendored
Normal file
@ -0,0 +1,313 @@
|
||||
/* BFD back-end for Renesas H8/500 COFF binaries.
|
||||
Copyright 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/h8500.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int coff_h8500_select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static void extra_case PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
|
||||
|
||||
#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 H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET 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 necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#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, (bfd_vma) 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, (bfd_vma) 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 = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ 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 > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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 = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ 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 > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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, (bfd_vma) gap, data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (h8500coff_vec, "coff-h8500", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
692
external/gpl3/binutils/dist/bfd/coff-i386.c
vendored
Normal file
692
external/gpl3/binutils/dist/bfd/coff-i386.c
vendored
Normal file
@ -0,0 +1,692 @@
|
||||
/* BFD back-end for Intel 386 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2007, 2008
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "coff/i386.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
#include "coff/pe.h"
|
||||
#endif
|
||||
|
||||
#ifdef COFF_GO32_EXE
|
||||
#include "coff/go32exe.h"
|
||||
#endif
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#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 *));
|
||||
static reloc_howto_type *coff_i386_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#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 relocatable 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 ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
#endif
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
#ifndef COFF_WITH_PE
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
#else
|
||||
/* In PE mode, we do not offset the common symbol. */
|
||||
diff = reloc_entry->addend;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocatable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
#ifdef COFF_WITH_PE
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
/* Although PC relative relocations are very similar between
|
||||
PE and non-PE formats, but they are off by 1 << howto->size
|
||||
bytes. For the external relocation, PE is very different
|
||||
from others. See md_apply_fix3 () in gas/config/tc-i386.c.
|
||||
When we link PE and non-PE object files together to
|
||||
generate a non-PE executable, we have to compensate it
|
||||
here. */
|
||||
if (howto->pc_relative && howto->pcrel_offset)
|
||||
diff = -(1 << howto->size);
|
||||
else if (symbol->flags & BSF_WEAK)
|
||||
diff = reloc_entry->addend - symbol->value;
|
||||
else
|
||||
diff = -reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* FIXME: How should this case be handled? */
|
||||
if (reloc_entry->howto->type == R_IMAGEBASE
|
||||
&& output_bfd != NULL
|
||||
&& bfd_get_flavour(output_bfd) == bfd_target_coff_flavour)
|
||||
diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
|
||||
#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, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) 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 bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
static bfd_boolean in_reloc_p (abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != R_IMAGEBASE;
|
||||
}
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET FALSE
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
/* PE IMAGE_REL_I386_DIR32NB relocation (7). */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
#ifdef COFF_WITH_PE
|
||||
/* 32-bit longword section relative relocation (013). */
|
||||
HOWTO (R_SECREL32, /* 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 */
|
||||
"secrel32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
#else
|
||||
EMPTY_HOWTO (013),
|
||||
#endif
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
/* Byte relocation (017). */
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word relocation (020). */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword relocation (021). */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* Byte PC relative relocation (022). */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word PC relative relocation (023). */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword PC relative relocation (024). */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
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 = \
|
||||
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \
|
||||
? howto_table + (dst)->r_type \
|
||||
: NULL))
|
||||
|
||||
/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
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. For normal i386 COFF, we
|
||||
can use the generic relocate_section routine. For PE, we need our
|
||||
own routine. */
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#else /* COFF_WITH_PE */
|
||||
|
||||
/* The PE relocate section routine. The only difference between this
|
||||
and the regular routine is that we don't want to do anything for a
|
||||
relocatable link. */
|
||||
|
||||
static bfd_boolean coff_pe_i386_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
|
||||
static bfd_boolean
|
||||
coff_pe_i386_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;
|
||||
{
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
|
||||
input_section, contents,
|
||||
relocs, syms, sections);
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_pe_i386_relocate_section
|
||||
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
/* Convert an rtype to howto for the COFF backend linker. */
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
reloc_howto_type *howto;
|
||||
|
||||
if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0]))
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Cancel out code in _bfd_coff_generic_relocate_section. */
|
||||
*addendp = 0;
|
||||
#endif
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* I think we *do* want to bypass this. If we don't, I have
|
||||
seen some data parameters get the wrong relocation address.
|
||||
If I link two versions with and without this section bypassed
|
||||
and then do a binary comparison, the addresses which are
|
||||
different can be looked up in the map. The case in which
|
||||
this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map. */
|
||||
*addendp -= sym->n_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
#endif
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (howto->pc_relative)
|
||||
{
|
||||
*addendp -= 4;
|
||||
|
||||
/* If the symbol is defined, then the generic code is going to
|
||||
add back the symbol value in order to cancel out an
|
||||
adjustment it made to the addend. However, we set the addend
|
||||
to 0 at the start of this function. We need to adjust here,
|
||||
to avoid the adjustment the generic code will make. FIXME:
|
||||
This is getting a bit hackish. */
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
if (rel->r_type == R_IMAGEBASE
|
||||
&& (bfd_get_flavour(sec->output_section->owner)
|
||||
== bfd_target_coff_flavour))
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
|
||||
BFD_ASSERT (sym != NULL);
|
||||
if (rel->r_type == R_SECREL32 && sym != NULL)
|
||||
{
|
||||
bfd_vma osect_vma;
|
||||
|
||||
if (h && (h->type == bfd_link_hash_defined
|
||||
|| h->type == bfd_link_hash_defweak))
|
||||
osect_vma = h->root.u.def.section->output_section->vma;
|
||||
else
|
||||
{
|
||||
asection *sec;
|
||||
int i;
|
||||
|
||||
/* Sigh, the only way to get the section to offset against
|
||||
is to find it the hard way. */
|
||||
|
||||
for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
|
||||
sec = sec->next;
|
||||
|
||||
osect_vma = sec->output_section->vma;
|
||||
}
|
||||
|
||||
*addendp -= osect_vma;
|
||||
}
|
||||
#endif
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup coff_i386_reloc_name_lookup
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
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;
|
||||
case BFD_RELOC_16:
|
||||
return howto_table + R_RELWORD;
|
||||
case BFD_RELOC_16_PCREL:
|
||||
return howto_table + R_PCRWORD;
|
||||
case BFD_RELOC_8:
|
||||
return howto_table + R_RELBYTE;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return howto_table + R_PCRBYTE;
|
||||
#ifdef COFF_WITH_PE
|
||||
case BFD_RELOC_32_SECREL:
|
||||
return howto_table + R_SECREL32;
|
||||
#endif
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
|
||||
if (howto_table[i].name != NULL
|
||||
&& strcasecmp (howto_table[i].name, r_name) == 0)
|
||||
return &howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i386_rtype_to_howto
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
|
||||
/* If i386 gcc uses underscores for symbol names, then it does not use
|
||||
a leading dot for local labels, so if TARGET_UNDERSCORE is defined
|
||||
we treat all symbols starting with L as local. */
|
||||
|
||||
static bfd_boolean coff_i386_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
static bfd_boolean
|
||||
coff_i386_is_local_label_name (abfd, name)
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
{
|
||||
if (name[0] == 'L')
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_is_local_label_name (abfd, name);
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name coff_i386_is_local_label_name
|
||||
|
||||
#endif /* TARGET_UNDERSCORE */
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
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 COFF_WITH_PE
|
||||
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY
|
||||
#endif
|
||||
| SEC_CODE | SEC_DATA),
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
708
external/gpl3/binutils/dist/bfd/coff-i860.c
vendored
Normal file
708
external/gpl3/binutils/dist/bfd/coff-i860.c
vendored
Normal file
@ -0,0 +1,708 @@
|
||||
/* BFD back-end for Intel i860 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "coff/i860.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
|
||||
#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 relocatable 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 (bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol,
|
||||
void *data,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* 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
|
||||
relocatable 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, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* This is just a temporary measure until we teach bfd to generate
|
||||
these relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol ATTRIBUTE_UNUSED,
|
||||
void *data ATTRIBUTE_UNUSED,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
fprintf (stderr, _("Relocation `%s' not yet implemented\n"), howto->name);
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET FALSE
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_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 */
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
EMPTY_HOWTO (013),
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
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 */
|
||||
EMPTY_HOWTO (0x15),
|
||||
EMPTY_HOWTO (0x16),
|
||||
EMPTY_HOWTO (0x17),
|
||||
EMPTY_HOWTO (0x18),
|
||||
EMPTY_HOWTO (0x19),
|
||||
EMPTY_HOWTO (0x1a),
|
||||
EMPTY_HOWTO (0x1b),
|
||||
HOWTO (COFF860_R_PAIR, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"PAIR", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
EMPTY_HOWTO (0x1d),
|
||||
HOWTO (COFF860_R_HIGH, /* type */
|
||||
16, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"HIGH", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW0, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW0", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW1, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW1", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfffe, /* src_mask */
|
||||
0xfffe, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW2, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfffc, /* src_mask */
|
||||
0xfffc, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW3, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW3", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfff8, /* src_mask */
|
||||
0xfff8, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_LOW4, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"LOW4", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xfff0, /* src_mask */
|
||||
0xfff0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT0, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT0", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07ff, /* src_mask */
|
||||
0x1f07ff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT1, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT1", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07fe, /* src_mask */
|
||||
0x1f07fe, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_SPLIT2, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"SPLIT2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x1f07fc, /* src_mask */
|
||||
0x1f07fc, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_HIGHADJ, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"HIGHADJ", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
HOWTO (COFF860_R_BRADDR, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
26, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc_nyi, /* special_function */
|
||||
"BRADDR", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x3ffffff, /* src_mask */
|
||||
0x3ffffff, /* dst_mask */
|
||||
TRUE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
#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 = \
|
||||
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \
|
||||
? howto_table + (dst)->r_type \
|
||||
: NULL))
|
||||
|
||||
/* 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)
|
||||
|
||||
/* 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 (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
asection *sec,
|
||||
struct internal_reloc *rel,
|
||||
struct coff_link_hash_entry *h,
|
||||
struct internal_syment *sym,
|
||||
bfd_vma *addendp)
|
||||
{
|
||||
|
||||
reloc_howto_type *howto;
|
||||
|
||||
if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
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 relocation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map. */
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable 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;
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + R_DIR32;
|
||||
case BFD_RELOC_860_PC26:
|
||||
return howto_table + COFF860_R_BRADDR;
|
||||
case BFD_RELOC_860_PC16:
|
||||
/* ??? How to handle PC16 for COFF? SPLIT0 is close for now. */
|
||||
return howto_table + COFF860_R_SPLIT0;
|
||||
case BFD_RELOC_860_LOW0:
|
||||
return howto_table + COFF860_R_LOW0;
|
||||
case BFD_RELOC_860_SPLIT0:
|
||||
return howto_table + COFF860_R_SPLIT0;
|
||||
case BFD_RELOC_860_LOW1:
|
||||
return howto_table + COFF860_R_LOW1;
|
||||
case BFD_RELOC_860_SPLIT1:
|
||||
return howto_table + COFF860_R_SPLIT1;
|
||||
case BFD_RELOC_860_LOW2:
|
||||
return howto_table + COFF860_R_LOW2;
|
||||
case BFD_RELOC_860_SPLIT2:
|
||||
return howto_table + COFF860_R_SPLIT2;
|
||||
case BFD_RELOC_860_LOW3:
|
||||
return howto_table + COFF860_R_LOW3;
|
||||
case BFD_RELOC_860_HIGHADJ:
|
||||
return howto_table + COFF860_R_HIGHADJ;
|
||||
case BFD_RELOC_860_HIGH:
|
||||
return howto_table + COFF860_R_HIGH;
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
|
||||
if (howto_table[i].name != NULL
|
||||
&& strcasecmp (howto_table[i].name, r_name) == 0)
|
||||
return &howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is called from coff_slurp_reloc_table for each relocation
|
||||
entry. This special handling is due to the `PAIR' relocation
|
||||
which has a different meaning for the `r_symndx' field. */
|
||||
|
||||
static void
|
||||
i860_reloc_processing (arelent *cache_ptr, struct internal_reloc *dst,
|
||||
asymbol **symbols, bfd *abfd, asection *asect)
|
||||
{
|
||||
if (dst->r_type == COFF860_R_PAIR)
|
||||
{
|
||||
/* Handle the PAIR relocation specially. */
|
||||
cache_ptr->howto = howto_table + dst->r_type;
|
||||
cache_ptr->address = dst->r_vaddr;
|
||||
cache_ptr->addend = dst->r_symndx;
|
||||
cache_ptr->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For every other relocation, do exactly what coff_slurp_reloc_table
|
||||
would do (which this code is taken directly from). */
|
||||
asymbol *ptr = NULL;
|
||||
cache_ptr->address = dst->r_vaddr;
|
||||
|
||||
if (dst->r_symndx != -1)
|
||||
{
|
||||
if (dst->r_symndx < 0 || dst->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: warning: illegal symbol index %ld in relocs"),
|
||||
abfd, dst->r_symndx);
|
||||
cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_ptr->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[dst->r_symndx]);
|
||||
ptr = *(cache_ptr->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been
|
||||
relocated as if their sections started at 0. But the offsets
|
||||
refering to the symbols in the raw data have not been
|
||||
modified, so we have to have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, (*dst), cache_ptr);
|
||||
|
||||
cache_ptr->address -= asect->vma;
|
||||
|
||||
/* Fill in the cache_ptr->howto field from dst->r_type. */
|
||||
RTYPE2HOWTO (cache_ptr, dst);
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i860_rtype_to_howto
|
||||
#define coff_bfd_reloc_type_lookup coff_i860_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup coff_i860_reloc_name_lookup
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
i860_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *
|
||||
i3coff_object_p(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),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
687
external/gpl3/binutils/dist/bfd/coff-i960.c
vendored
Normal file
687
external/gpl3/binutils/dist/bfd/coff-i960.c
vendored
Normal file
@ -0,0 +1,687 @@
|
||||
/* BFD back-end for Intel 960 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define I960 1
|
||||
#define BADMAG(x) I960BADMAG(x)
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/i960.h"
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "libcoff.h" /* To allow easier abstraction-breaking. */
|
||||
|
||||
static bfd_boolean coff_i960_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
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 bfd_boolean coff_i960_start_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static bfd_boolean coff_i960_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static bfd_boolean coff_i960_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, bfd_boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
#define COFF_ALIGN_IN_SECTION_HEADER 1
|
||||
|
||||
#define GET_SCNHDR_ALIGN H_GET_32
|
||||
#define PUT_SCNHDR_ALIGN H_PUT_32
|
||||
|
||||
/* 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 set of local label names is taken from gas. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
return (name[0] == 'L'
|
||||
|| (name[0] == '.'
|
||||
&& (name[1] == 'C'
|
||||
|| name[1] == 'I'
|
||||
|| name[1] == '.')));
|
||||
}
|
||||
|
||||
/* 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 ATTRIBUTE_UNUSED;
|
||||
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, (bfd_vma) 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 relocatable 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
|
||||
relocatable 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 ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
asection *osec;
|
||||
|
||||
if (output_bfd == NULL)
|
||||
{
|
||||
/* Not generating relocatable 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)
|
||||
{
|
||||
bfd_size_type amt = sizeof (struct coff_section_tdata);
|
||||
osec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
|
||||
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 ATTRIBUTE_UNUSED;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i960_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
if (strcasecmp (howto_optcall.name, r_name) == 0)
|
||||
return &howto_optcall;
|
||||
if (strcasecmp (howto_rellong.name, r_name) == 0)
|
||||
return &howto_rellong;
|
||||
if (strcasecmp (howto_iprmed.name, r_name) == 0)
|
||||
return &howto_iprmed;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 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 bfd_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->relocatable)
|
||||
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_bwrite (esym, symesz, 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 bfd_boolean
|
||||
coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
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;
|
||||
bfd_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->relocatable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
done = FALSE;
|
||||
|
||||
if (howto->type == R_OPTCALL && ! info->relocatable && 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,
|
||||
(bfd_vma) 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 = NULL;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, (h ? &h->root : NULL), 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. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
||||
bfd *ibfd;
|
||||
asection *sec ATTRIBUTE_UNUSED;
|
||||
struct internal_reloc *irel;
|
||||
bfd_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_bfd_is_local_label_name coff_i960_is_local_label_name
|
||||
|
||||
#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
|
||||
#define coff_bfd_reloc_name_lookup coff_i960_reloc_name_lookup
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
extern const bfd_target icoff_big_vec;
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (icoff_little_vec, "coff-Intel-little", 0, 0, '_', & icoff_big_vec, 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),
|
||||
|
||||
& icoff_little_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
208
external/gpl3/binutils/dist/bfd/coff-ia64.c
vendored
Normal file
208
external/gpl3/binutils/dist/bfd/coff-ia64.c
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
/* BFD back-end for HP/Intel IA-64 COFF files.
|
||||
Copyright 1999, 2000, 2001, 2002, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by David Mosberger <davidm@hpl.hp.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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/ia64.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/pe.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
};
|
||||
|
||||
#define BADMAG(x) IA64BADMAG(x)
|
||||
#define IA64 1 /* Customize coffcode.h */
|
||||
|
||||
#ifdef COFF_WITH_pep
|
||||
# undef AOUTSZ
|
||||
# define AOUTSZ PEPAOUTSZ
|
||||
# define PEAOUTHDR PEPAOUTHDR
|
||||
#endif
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return TRUE if this relocation should
|
||||
appear in the output .reloc section. */
|
||||
|
||||
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
static bfd_boolean
|
||||
in_reloc_p(abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type *howto ATTRIBUTE_UNUSED;
|
||||
{
|
||||
return FALSE; /* We don't do relocs for now... */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *ia64coff_object_p PARAMS ((bfd *));
|
||||
|
||||
static const bfd_target *
|
||||
ia64coff_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef COFF_IMAGE_WITH_PE
|
||||
{
|
||||
struct external_PEI_DOS_hdr dos_hdr;
|
||||
struct external_PEI_IMAGE_hdr image_hdr;
|
||||
file_ptr offset;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| (bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
|
||||
!= sizeof (dos_hdr)))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* There are really two magic numbers involved; the magic number
|
||||
that says this is a NT executable (PEI) and the magic number
|
||||
that determines the architecture. The former is DOSMAGIC,
|
||||
stored in the e_magic field. The latter is stored in the
|
||||
f_magic field. If the NT magic number isn't valid, the
|
||||
architecture magic number could be mimicked by some other
|
||||
field (specifically, the number of relocs in section 3). Since
|
||||
this routine can only be called correctly for a PEI file, check
|
||||
the e_magic number here, and, if it doesn't match, clobber the
|
||||
f_magic number so that we don't get a false match. */
|
||||
if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|
||||
|| (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
|
||||
!= sizeof (image_hdr)))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (H_GET_32 (abfd, image_hdr.nt_signature)
|
||||
!= 0x4550)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Here is the hack. coff_object_p wants to read filhsz bytes to
|
||||
pick up the COFF header for PE, see "struct external_PEI_filehdr"
|
||||
in include/coff/pe.h. We adjust so that that will work. */
|
||||
if (bfd_seek (abfd, offset - sizeof (dos_hdr), SEEK_SET) != 0)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return coff_object_p (abfd);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
ia64coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-ia64", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
|
||||
| SEC_CODE | SEC_DATA),
|
||||
#else
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
|
||||
| SEC_CODE | SEC_DATA
|
||||
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, ia64coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, ia64coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
566
external/gpl3/binutils/dist/bfd/coff-m68k.c
vendored
Normal file
566
external/gpl3/binutils/dist/bfd/coff-m68k.c
vendored
Normal file
@ -0,0 +1,566 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
|
||||
2000, 2001, 2002, 2003, 2005, 2007, 2008
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/m68k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
/* This source file is compiled multiple times for various m68k COFF
|
||||
variants. The following macros control its behaviour:
|
||||
|
||||
TARGET_SYM
|
||||
The C name of the BFD target vector. The default is m68kcoff_vec.
|
||||
TARGET_NAME
|
||||
The user visible target name. The default is "coff-m68k".
|
||||
NAMES_HAVE_UNDERSCORE
|
||||
Whether symbol names have an underscore.
|
||||
ONLY_DECLARE_RELOCS
|
||||
Only declare the relocation howto array. Don't actually compile
|
||||
it. The actual array will be picked up in another version of the
|
||||
file.
|
||||
STATIC_RELOCS
|
||||
Make the relocation howto array, and associated functions, static.
|
||||
COFF_COMMON_ADDEND
|
||||
If this is defined, then, for a relocation against a common
|
||||
symbol, the object file holds the value (the size) of the common
|
||||
symbol. If this is not defined, then, for a relocation against a
|
||||
common symbol, the object file holds zero. */
|
||||
|
||||
#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
|
||||
|
||||
#ifndef COFF_COMMON_ADDEND
|
||||
#define RELOC_SPECIAL_FN 0
|
||||
#else
|
||||
static bfd_reloc_status_type m68kcoff_common_addend_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
#define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn
|
||||
#endif
|
||||
|
||||
static bfd_boolean m68k_coff_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
/* On the delta, a symbol starting with L% is local. We won't see
|
||||
such a symbol on other platforms, so it should be safe to always
|
||||
consider it local here. */
|
||||
|
||||
static bfd_boolean
|
||||
m68k_coff_is_local_label_name (abfd, name)
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
{
|
||||
if (name[0] == 'L' && name[1] == '%')
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_is_local_label_name (abfd, name);
|
||||
}
|
||||
|
||||
#ifndef STATIC_RELOCS
|
||||
/* 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
|
||||
#define m68k_reloc_name_lookup _bfd_m68kcoff_reloc_name_lookup
|
||||
#endif
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type m68kcoff_howto_table[];
|
||||
#else
|
||||
#ifdef STATIC_RELOCS
|
||||
static
|
||||
#endif
|
||||
reloc_howto_type m68kcoff_howto_table[] =
|
||||
{
|
||||
HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE, 0, complain_overflow_bitfield, RELOC_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));
|
||||
extern reloc_howto_type *m68k_reloc_name_lookup
|
||||
PARAMS ((bfd *, const char *));
|
||||
#else
|
||||
|
||||
#ifdef STATIC_RELOCS
|
||||
#define STAT_REL static
|
||||
#else
|
||||
#define STAT_REL
|
||||
#endif
|
||||
|
||||
STAT_REL reloc_howto_type * m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
STAT_REL reloc_howto_type * m68k_reloc_name_lookup PARAMS ((bfd *, const char *));
|
||||
STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int));
|
||||
|
||||
|
||||
STAT_REL 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;
|
||||
}
|
||||
}
|
||||
|
||||
STAT_REL 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;
|
||||
}
|
||||
|
||||
STAT_REL reloc_howto_type *
|
||||
m68k_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
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*/
|
||||
}
|
||||
|
||||
STAT_REL reloc_howto_type *
|
||||
m68k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (m68kcoff_howto_table) / sizeof (m68kcoff_howto_table[0]);
|
||||
i++)
|
||||
if (m68kcoff_howto_table[i].name != NULL
|
||||
&& strcasecmp (m68kcoff_howto_table[i].name, r_name) == 0)
|
||||
return &m68kcoff_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#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_bfd_reloc_name_lookup m68k_reloc_name_lookup
|
||||
|
||||
#ifndef COFF_COMMON_ADDEND
|
||||
#ifndef coff_rtype_to_howto
|
||||
|
||||
#define coff_rtype_to_howto m68kcoff_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *m68kcoff_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
static reloc_howto_type *
|
||||
m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
relent.howto = NULL;
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (howto != NULL && howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#endif /* ! defined (coff_rtype_to_howto) */
|
||||
#endif /* ! defined (COFF_COMMON_ADDEND) */
|
||||
|
||||
#ifdef COFF_COMMON_ADDEND
|
||||
|
||||
/* If COFF_COMMON_ADDEND is defined, then 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 relocatable 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
|
||||
m68kcoff_common_addend_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 ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* 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
|
||||
relocatable 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, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) 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; \
|
||||
}
|
||||
|
||||
#ifndef coff_rtype_to_howto
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols. */
|
||||
|
||||
static reloc_howto_type *
|
||||
m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
relent.howto = NULL;
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
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);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable 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 m68kcoff_common_addend_rtype_to_howto
|
||||
|
||||
#endif /* ! defined (coff_rtype_to_howto) */
|
||||
|
||||
#endif /* COFF_COMMON_ADDEND */
|
||||
|
||||
#if !defined ONLY_DECLARE_RELOCS && ! defined STATIC_RELOCS
|
||||
/* Given a .data section and a .emreloc in-memory section, store
|
||||
relocation information into the .emreloc section which can be
|
||||
used at runtime to relocate the section. This is called by the
|
||||
linker when the --embedded-relocs switch is used. This is called
|
||||
after the add_symbols entry point has been called for all the
|
||||
objects, and before the final_link entry point is called. */
|
||||
|
||||
bfd_boolean
|
||||
bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
asection *datasec;
|
||||
asection *relsec;
|
||||
char **errmsg;
|
||||
{
|
||||
char *extsyms;
|
||||
bfd_size_type symesz;
|
||||
struct internal_reloc *irel, *irelend;
|
||||
bfd_byte *p;
|
||||
bfd_size_type amt;
|
||||
|
||||
BFD_ASSERT (! info->relocatable);
|
||||
|
||||
*errmsg = NULL;
|
||||
|
||||
if (datasec->reloc_count == 0)
|
||||
return TRUE;
|
||||
|
||||
extsyms = obj_coff_external_syms (abfd);
|
||||
symesz = bfd_coff_symesz (abfd);
|
||||
|
||||
irel = _bfd_coff_read_internal_relocs (abfd, datasec, TRUE, NULL, FALSE,
|
||||
NULL);
|
||||
irelend = irel + datasec->reloc_count;
|
||||
|
||||
amt = (bfd_size_type) datasec->reloc_count * 12;
|
||||
relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
|
||||
if (relsec->contents == NULL)
|
||||
return FALSE;
|
||||
|
||||
p = relsec->contents;
|
||||
|
||||
for (; irel < irelend; irel++, p += 12)
|
||||
{
|
||||
asection *targetsec;
|
||||
|
||||
/* We are going to write a four byte longword into the runtime
|
||||
reloc section. The longword will be the address in the data
|
||||
section which must be relocated. It is followed by the name
|
||||
of the target section NUL-padded or truncated to 8
|
||||
characters. */
|
||||
|
||||
/* We can only relocate absolute longword relocs at run time. */
|
||||
if (irel->r_type != R_RELLONG)
|
||||
{
|
||||
*errmsg = _("unsupported reloc type");
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (irel->r_symndx == -1)
|
||||
targetsec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
|
||||
h = obj_coff_sym_hashes (abfd)[irel->r_symndx];
|
||||
if (h == NULL)
|
||||
{
|
||||
struct internal_syment isym;
|
||||
|
||||
bfd_coff_swap_sym_in (abfd, extsyms + symesz * irel->r_symndx,
|
||||
&isym);
|
||||
targetsec = coff_section_from_bfd_index (abfd, isym.n_scnum);
|
||||
}
|
||||
else if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
targetsec = h->root.u.def.section;
|
||||
else
|
||||
targetsec = NULL;
|
||||
}
|
||||
|
||||
bfd_put_32 (abfd,
|
||||
(irel->r_vaddr - datasec->vma + datasec->output_offset), p);
|
||||
memset (p + 4, 0, 8);
|
||||
if (targetsec != NULL)
|
||||
strncpy ((char *) p + 4, targetsec->output_section->name, 8);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* neither ONLY_DECLARE_RELOCS not STATIC_RELOCS */
|
||||
|
||||
#define coff_bfd_is_local_label_name m68k_coff_is_local_label_name
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM m68kcoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "coff-m68k"
|
||||
#endif
|
||||
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
||||
#else
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, 0, NULL, COFF_SWAP_TABLE)
|
||||
#endif
|
296
external/gpl3/binutils/dist/bfd/coff-m88k.c
vendored
Normal file
296
external/gpl3/binutils/dist/bfd/coff-m88k.c
vendored
Normal file
@ -0,0 +1,296 @@
|
||||
/* BFD back-end for Motorola 88000 COFF "Binary Compatibility Standard" files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define M88 1 /* Customize various include files */
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/m88k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_boolean m88k_is_local_label_name PARAMS ((bfd *, const char *));
|
||||
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)
|
||||
|
||||
#define GET_SCNHDR_NRELOC H_GET_32
|
||||
#define GET_SCNHDR_NLNNO H_GET_32
|
||||
|
||||
/* On coff-m88k, local labels start with '@'. */
|
||||
|
||||
#define coff_bfd_is_local_label_name m88k_is_local_label_name
|
||||
|
||||
static bfd_boolean
|
||||
m88k_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
return name[0] == '@';
|
||||
}
|
||||
|
||||
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 ATTRIBUTE_UNUSED;
|
||||
{
|
||||
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 targeted 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, (bfd_vma) relocation,
|
||||
(unsigned char *) data + addr);
|
||||
}
|
||||
|
||||
/* If we are not producing relocatable output, return an error if
|
||||
the symbol is not defined. */
|
||||
if (bfd_is_und_section (symbol->section) && output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_undefined;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
|
||||
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 H_GET_16
|
||||
#define SWAP_OUT_RELOC_OFFSET 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)
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_write_armap
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (m88kbcs_vec, "coff-m88kbcs", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
447
external/gpl3/binutils/dist/bfd/coff-maxq.c
vendored
Normal file
447
external/gpl3/binutils/dist/bfd/coff-maxq.c
vendored
Normal file
@ -0,0 +1,447 @@
|
||||
/* BFD back-end for MAXQ COFF binaries.
|
||||
Copyright 2004, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Vineet Sharma (vineets@noida.hcltech.com) Inderpreet S.
|
||||
(inderpreetb@noida.hcltech.com)
|
||||
|
||||
HCL Technologies Ltd.
|
||||
|
||||
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 3 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.,
|
||||
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/maxq.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifndef MAXQ20
|
||||
#define MAXQ20 1
|
||||
#endif
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
((cache_ptr)->howto = \
|
||||
((dst)->r_type < 48 \
|
||||
? howto_table + (((dst)->r_type==47) ? 6: ((dst)->r_type)) \
|
||||
: NULL))
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
/* Code to swap in the reloc offset. */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_16
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_16
|
||||
|
||||
#define SHORT_JUMP BFD_RELOC_16_PCREL_S2
|
||||
#define LONG_JUMP BFD_RELOC_14
|
||||
#define ABSOLUTE_ADDR_FOR_DATA BFD_RELOC_24
|
||||
|
||||
/* checks the range of short jump -127 to 128 */
|
||||
#define IS_SJUMP_RANGE(x) ((x > -128) && (x < 129))
|
||||
#define HIGH_WORD_MASK 0xff00
|
||||
#define LOW_WORD_MASK 0x00ff
|
||||
|
||||
static long
|
||||
get_symbol_value (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 performs all the maxq relocations.
|
||||
FIXME: The handling of the addend in the 'BFD_*'
|
||||
relocations types. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_maxq20_reloc (bfd * abfd,
|
||||
arelent * reloc_entry,
|
||||
asymbol * symbol_in,
|
||||
void * data,
|
||||
asection * input_section ATTRIBUTE_UNUSED,
|
||||
bfd * output_bfd ATTRIBUTE_UNUSED,
|
||||
char ** error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
unsigned char *addr = NULL;
|
||||
unsigned long x = 0;
|
||||
long call_addr = 0;
|
||||
short addend = 0;
|
||||
long diff = 0;
|
||||
|
||||
/* If this is an undefined symbol, return error. */
|
||||
if (symbol_in->section == &bfd_und_section
|
||||
&& (symbol_in->flags & BSF_WEAK) == 0)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (data && reloc_entry)
|
||||
{
|
||||
addr = (unsigned char *) data + reloc_entry->address;
|
||||
call_addr = call_addr - call_addr;
|
||||
call_addr = get_symbol_value (symbol_in);
|
||||
|
||||
/* Over here the value val stores the 8 bit/16 bit value. We will put a
|
||||
check if we are moving a 16 bit immediate value into an 8 bit
|
||||
register. In that case we will generate a Upper bytes into PFX[0]
|
||||
and move the lower 8 bits as SRC. */
|
||||
|
||||
switch (reloc_entry->howto->type)
|
||||
{
|
||||
/* BFD_RELOC_16_PCREL_S2 47 Handles all the relative jumps and
|
||||
calls Note: Every relative jump or call is in words. */
|
||||
case SHORT_JUMP:
|
||||
/* Handle any addend. */
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
if (addend > call_addr || addend > 0)
|
||||
call_addr = symbol_in->section->output_section->vma + addend;
|
||||
else if (addend < call_addr && addend > 0)
|
||||
call_addr = call_addr + addend;
|
||||
else if (addend < 0)
|
||||
call_addr = call_addr + addend;
|
||||
|
||||
diff = ((call_addr << 1) - (reloc_entry->address << 1));
|
||||
|
||||
if (!IS_SJUMP_RANGE (diff))
|
||||
{
|
||||
bfd_perror (_("Can't Make it a Short Jump"));
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
|
||||
x = bfd_get_16 (abfd, addr);
|
||||
|
||||
x = x & LOW_WORD_MASK;
|
||||
x = x | (diff << 8);
|
||||
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
||||
|
||||
return bfd_reloc_ok;
|
||||
|
||||
case ABSOLUTE_ADDR_FOR_DATA:
|
||||
case LONG_JUMP:
|
||||
/* BFD_RELOC_14 Handles intersegment or long jumps which might be
|
||||
from code to code or code to data segment jumps. Note: When this
|
||||
fucntion is called by gas the section flags somehow do not
|
||||
contain the info about the section type(CODE or DATA). Thus the
|
||||
user needs to evoke the linker after assembling the files
|
||||
because the Code-Code relocs are word aligned but code-data are
|
||||
byte aligned. */
|
||||
addend = (reloc_entry->addend - reloc_entry->addend);
|
||||
|
||||
/* Handle any addend. */
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
/* For relocation involving multiple file added becomes zero thus
|
||||
this fails - check for zero added. In another case when we try
|
||||
to add a stub to a file the addend shows the offset from the
|
||||
start od this file. */
|
||||
addend = 0;
|
||||
|
||||
if (!bfd_is_com_section (symbol_in->section) &&
|
||||
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
||||
{
|
||||
if (reloc_entry->addend > symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
|
||||
if ((reloc_entry->addend < symbol_in->value)
|
||||
&& (reloc_entry->addend != 0))
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
|
||||
if (reloc_entry->addend == symbol_in->value)
|
||||
addend = 0;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (symbol_in->section) ||
|
||||
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
if (addend < 0
|
||||
&& (call_addr < (long) (addend * (-1))))
|
||||
addend = 0;
|
||||
|
||||
call_addr += addend;
|
||||
|
||||
/* FIXME: This check does not work well with the assembler,
|
||||
linker needs to be run always. */
|
||||
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
||||
{
|
||||
/* Convert it into words. */
|
||||
call_addr = call_addr >> 1;
|
||||
|
||||
if (call_addr > 0xFFFF) /* Intersegment Jump. */
|
||||
{
|
||||
bfd_perror (_("Exceeds Long Jump Range"));
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* case ABSOLUTE_ADDR_FOR_DATA : Resolves any code-data
|
||||
segemnt relocs. These are NOT word aligned. */
|
||||
|
||||
if (call_addr > 0xFFFF) /* Intersegment Jump. */
|
||||
{
|
||||
bfd_perror (_("Absolute address Exceeds 16 bit Range"));
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
}
|
||||
|
||||
x = bfd_get_32 (abfd, addr);
|
||||
|
||||
x = (x & 0xFF00FF00);
|
||||
x = (x | ((call_addr & HIGH_WORD_MASK) >> 8));
|
||||
x = (x | (call_addr & LOW_WORD_MASK) << 16);
|
||||
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
return bfd_reloc_ok;
|
||||
|
||||
case BFD_RELOC_8:
|
||||
addend = (reloc_entry->addend - reloc_entry->addend);
|
||||
|
||||
if (!bfd_is_com_section (symbol_in->section) &&
|
||||
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
||||
{
|
||||
if (reloc_entry->addend > symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
if (reloc_entry->addend < symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
if (reloc_entry->addend == symbol_in->value)
|
||||
addend = 0;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (symbol_in->section) ||
|
||||
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
if (addend < 0
|
||||
&& (call_addr < (long) (addend * (-1))))
|
||||
addend = 0;
|
||||
|
||||
if (call_addr + addend > 0xFF)
|
||||
{
|
||||
bfd_perror (_("Absolute address Exceeds 8 bit Range"));
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
|
||||
x = bfd_get_8 (abfd, addr);
|
||||
x = x & 0x00;
|
||||
x = x | (call_addr + addend);
|
||||
|
||||
bfd_put_8 (abfd, (bfd_vma) x, addr);
|
||||
return bfd_reloc_ok;
|
||||
|
||||
case BFD_RELOC_16:
|
||||
addend = (reloc_entry->addend - reloc_entry->addend);
|
||||
if (!bfd_is_com_section (symbol_in->section) &&
|
||||
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
||||
{
|
||||
if (reloc_entry->addend > symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
|
||||
if (reloc_entry->addend < symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
|
||||
if (reloc_entry->addend == symbol_in->value)
|
||||
addend = 0;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (symbol_in->section) ||
|
||||
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
if (addend < 0
|
||||
&& (call_addr < (long) (addend * (-1))))
|
||||
addend = 0;
|
||||
|
||||
if ((call_addr + addend) > 0xFFFF)
|
||||
{
|
||||
bfd_perror (_("Absolute address Exceeds 16 bit Range"));
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned short val = (call_addr + addend);
|
||||
|
||||
x = bfd_get_16 (abfd, addr);
|
||||
|
||||
/* LE */
|
||||
x = (x & 0x0000); /* Flush garbage value. */
|
||||
x = val;
|
||||
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
||||
x = x >> 1; /* Convert it into words. */
|
||||
}
|
||||
|
||||
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
||||
return bfd_reloc_ok;
|
||||
|
||||
case BFD_RELOC_32:
|
||||
addend = (reloc_entry->addend - reloc_entry->addend);
|
||||
|
||||
if (!bfd_is_com_section (symbol_in->section) &&
|
||||
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
||||
{
|
||||
if (reloc_entry->addend > symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
if (reloc_entry->addend < symbol_in->value)
|
||||
addend = reloc_entry->addend - symbol_in->value;
|
||||
if (reloc_entry->addend == symbol_in->value)
|
||||
addend = 0;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (symbol_in->section) ||
|
||||
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
||||
addend = reloc_entry->addend;
|
||||
|
||||
if (addend < 0
|
||||
&& (call_addr < (long) (addend * (-1))))
|
||||
addend = 0;
|
||||
|
||||
if ((call_addr + addend) < 0)
|
||||
{
|
||||
bfd_perror ("Absolute address Exceeds 32 bit Range");
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
|
||||
x = bfd_get_32 (abfd, addr);
|
||||
x = (x & 0x0000); /* Flush garbage value. */
|
||||
x = call_addr + addend;
|
||||
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
||||
x = x >> 1; /* Convert it into words. */
|
||||
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
return bfd_reloc_ok;
|
||||
|
||||
default:
|
||||
bfd_perror (_("Unrecognized Reloc Type"));
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
}
|
||||
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
{
|
||||
BFD_RELOC_32, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "32Bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
||||
},
|
||||
{
|
||||
SHORT_JUMP, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "SHORT_JMP", TRUE, 0x000000ff, 0x000000ff, TRUE
|
||||
},
|
||||
{
|
||||
ABSOLUTE_ADDR_FOR_DATA, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "INTERSEGMENT_RELOC", TRUE, 0x00000000, 0x00000000,
|
||||
FALSE
|
||||
},
|
||||
{
|
||||
BFD_RELOC_16, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "16Bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
||||
},
|
||||
{
|
||||
LONG_JUMP, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "LONG_JUMP", TRUE, 0x00000000, 0x00000000, FALSE
|
||||
},
|
||||
{
|
||||
BFD_RELOC_8, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
||||
coff_maxq20_reloc, "8bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
||||
},
|
||||
EMPTY_HOWTO (8),
|
||||
EMPTY_HOWTO (9),
|
||||
EMPTY_HOWTO (10),
|
||||
};
|
||||
|
||||
static reloc_howto_type *
|
||||
maxq_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
/* SHORT JUMP */
|
||||
case BFD_RELOC_16_PCREL_S2:
|
||||
return howto_table + 3;
|
||||
|
||||
/* INTERSEGMENT JUMP */
|
||||
case BFD_RELOC_24:
|
||||
return howto_table + 4;
|
||||
|
||||
/* BYTE RELOC */
|
||||
case BFD_RELOC_8:
|
||||
return howto_table + 7;
|
||||
|
||||
/* WORD RELOC */
|
||||
case BFD_RELOC_16:
|
||||
return howto_table + 5;
|
||||
|
||||
/* LONG RELOC */
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + 2;
|
||||
|
||||
/* LONG JUMP */
|
||||
case BFD_RELOC_14:
|
||||
return howto_table + 6;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
maxq_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
|
||||
if (howto_table[i].name != NULL
|
||||
&& strcasecmp (howto_table[i].name, r_name) == 0)
|
||||
return &howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define coff_bfd_reloc_type_lookup maxq_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup maxq_reloc_name_lookup
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry. */
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_UNDERSCORE
|
||||
#define TARGET_UNDERSCORE 1
|
||||
#endif
|
||||
|
||||
#ifndef EXTRA_S_FLAGS
|
||||
#define EXTRA_S_FLAGS 0
|
||||
#endif
|
||||
|
||||
/* Forward declaration for use initialising alternative_target field. */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (maxqcoff_vec, "coff-maxq", 0, EXTRA_S_FLAGS,
|
||||
TARGET_UNDERSCORE, NULL, COFF_SWAP_TABLE);
|
||||
|
583
external/gpl3/binutils/dist/bfd/coff-mcore.c
vendored
Normal file
583
external/gpl3/binutils/dist/bfd/coff-mcore.c
vendored
Normal file
@ -0,0 +1,583 @@
|
||||
/* BFD back-end for Motorola MCore COFF/PE
|
||||
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
|
||||
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 3 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, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/mcore.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/pe.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#ifdef BADMAG
|
||||
#undef BADMAG
|
||||
#endif
|
||||
#define BADMAG(x) MCOREBADMAG(x)
|
||||
|
||||
#ifndef NUM_ELEM
|
||||
#define NUM_ELEM(A) (sizeof (A) / sizeof (A)[0])
|
||||
#endif
|
||||
|
||||
/* This file is compiled more than once, but we only compile the
|
||||
final_link routine once. */
|
||||
extern bfd_boolean mcore_bfd_coff_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static bfd_reloc_status_type mcore_coff_unsupported_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_mcore_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static reloc_howto_type *mcore_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static reloc_howto_type *coff_mcore_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
|
||||
|
||||
/* The NT loader points the toc register to &toc + 32768, in order to
|
||||
use the complete range of a 16-bit displacement. We have to adjust
|
||||
for this when we fix up loads displaced off the toc reg. */
|
||||
#define TOC_LOAD_ADJUSTMENT (-32768)
|
||||
#define TOC_SECTION_NAME ".private.toc"
|
||||
|
||||
/* The main body of code is in coffcode.h. */
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
|
||||
|
||||
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
||||
from smaller values. Start with zero, widen, *then* decrement. */
|
||||
#define MINUS_ONE (((bfd_vma)0) - 1)
|
||||
|
||||
static reloc_howto_type mcore_coff_howto_table[] =
|
||||
{
|
||||
/* Unused: */
|
||||
HOWTO (IMAGE_REL_MCORE_ABSOLUTE,/* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
0, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* dont complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ABSOLUTE", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x00, /* src_mask */
|
||||
0x00, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (IMAGE_REL_MCORE_ADDR32,/* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ADDR32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
/* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
|
||||
Should not appear in object files. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM8BY4, /* type */
|
||||
2, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
mcore_coff_unsupported_reloc, /* special_function */
|
||||
"IMM8BY4", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
|
||||
Span 2k instructions == 4k bytes.
|
||||
Only useful pieces at the relocated address are the opcode (5 bits) */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM11BY2,/* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
11, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"IMM11BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0x7ff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_IMM4BY2, /* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
4, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
mcore_coff_unsupported_reloc, /* special_function */
|
||||
"IMM4BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* 32-bit pc-relative. Eventually this will help support PIC code. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_32,/* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PCREL_32", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
/* Like PCREL_IMM11BY2, this relocation indicates that there is a
|
||||
'jsri' at the specified address. There is a separate relocation
|
||||
entry for the literal pool entry that it references, but we
|
||||
might be able to change the jsri to a bsr if the target turns out
|
||||
to be close enough [even though we won't reclaim the literal pool
|
||||
entry, we'll get some runtime efficiency back]. Note that this
|
||||
is a relocation that we are allowed to safely ignore. */
|
||||
HOWTO (IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2,/* type */
|
||||
1, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
11, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"JSR_IMM11BY2", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0x0, /* src_mask */
|
||||
0x7ff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (IMAGE_REL_MCORE_RVA, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"MCORE_RVA", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Extend the coff_link_hash_table structure with a few M*Core specific fields.
|
||||
This allows us to store global data here without actually creating any
|
||||
global variables, which is a no-no in the BFD world. */
|
||||
typedef struct coff_mcore_link_hash_table
|
||||
{
|
||||
/* The original coff_link_hash_table structure. MUST be first field. */
|
||||
struct coff_link_hash_table root;
|
||||
|
||||
bfd * bfd_of_toc_owner;
|
||||
long int global_toc_size;
|
||||
long int import_table_size;
|
||||
long int first_thunk_address;
|
||||
long int thunk_size;
|
||||
}
|
||||
mcore_hash_table;
|
||||
|
||||
/* Get the MCore coff linker hash table from a link_info structure. */
|
||||
#define coff_mcore_hash_table(info) \
|
||||
((mcore_hash_table *) ((info)->hash))
|
||||
|
||||
|
||||
/* Add an entry to the base file. */
|
||||
|
||||
static bfd_boolean
|
||||
mcore_emit_base_file_entry (struct bfd_link_info *info,
|
||||
bfd *output_bfd,
|
||||
asection *input_section,
|
||||
bfd_vma reloc_offset)
|
||||
{
|
||||
bfd_vma addr = reloc_offset
|
||||
- input_section->vma
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma;
|
||||
|
||||
if (coff_data (output_bfd)->pe)
|
||||
addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
|
||||
|
||||
if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
|
||||
return TRUE;
|
||||
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
asymbol * symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection * input_section ATTRIBUTE_UNUSED;
|
||||
bfd * output_bfd ATTRIBUTE_UNUSED;
|
||||
char ** error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
|
||||
|
||||
_bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
|
||||
abfd,
|
||||
reloc_entry->howto->name,
|
||||
reloc_entry->howto->type);
|
||||
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
/* A cheesy little macro to make the code a little more readable. */
|
||||
#define HOW2MAP(bfd_rtype, mcore_rtype) \
|
||||
case bfd_rtype: return & mcore_coff_howto_table [mcore_rtype]
|
||||
|
||||
static reloc_howto_type *
|
||||
mcore_coff_reloc_type_lookup (abfd, code)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
HOW2MAP (BFD_RELOC_32, IMAGE_REL_MCORE_ADDR32);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM8BY4, IMAGE_REL_MCORE_PCREL_IMM8BY4);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM11BY2, IMAGE_REL_MCORE_PCREL_IMM11BY2);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM4BY2, IMAGE_REL_MCORE_PCREL_IMM4BY2);
|
||||
HOW2MAP (BFD_RELOC_32_PCREL, IMAGE_REL_MCORE_PCREL_32);
|
||||
HOW2MAP (BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2);
|
||||
HOW2MAP (BFD_RELOC_RVA, IMAGE_REL_MCORE_RVA);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
#undef HOW2MAP
|
||||
|
||||
static reloc_howto_type *
|
||||
mcore_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < (sizeof (mcore_coff_howto_table)
|
||||
/ sizeof (mcore_coff_howto_table[0]));
|
||||
i++)
|
||||
if (mcore_coff_howto_table[i].name != NULL
|
||||
&& strcasecmp (mcore_coff_howto_table[i].name, r_name) == 0)
|
||||
return &mcore_coff_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
asection * sec;
|
||||
struct internal_reloc * rel;
|
||||
struct coff_link_hash_entry * h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment * sym;
|
||||
bfd_vma * addendp;
|
||||
{
|
||||
reloc_howto_type * howto;
|
||||
|
||||
if (rel->r_type >= NUM_ELEM (mcore_coff_howto_table))
|
||||
return NULL;
|
||||
|
||||
howto = mcore_coff_howto_table + rel->r_type;
|
||||
|
||||
if (rel->r_type == IMAGE_REL_MCORE_RVA)
|
||||
* addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
|
||||
else if (howto->pc_relative)
|
||||
{
|
||||
* addendp = sec->vma - 2; /* XXX guess - is this right ? */
|
||||
|
||||
/* If the symbol is defined, then the generic code is going to
|
||||
add back the symbol value in order to cancel out an
|
||||
adjustment it made to the addend. However, we set the addend
|
||||
to 0 at the start of this function. We need to adjust here,
|
||||
to avoid the adjustment the generic code will make. FIXME:
|
||||
This is getting a bit hackish. */
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
* addendp -= sym->n_value;
|
||||
}
|
||||
else
|
||||
* addendp = 0;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
/* Return TRUE if this relocation should appear in the output .reloc section.
|
||||
This function is referenced in pe_mkobject in peicode.h. */
|
||||
|
||||
static bfd_boolean
|
||||
in_reloc_p (abfd, howto)
|
||||
bfd * abfd ATTRIBUTE_UNUSED;
|
||||
reloc_howto_type * howto;
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != IMAGE_REL_MCORE_RVA;
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
static bfd_boolean
|
||||
coff_mcore_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;
|
||||
bfd_boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocatable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
/* Check if we have the same endianess */
|
||||
if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder
|
||||
&& output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: compiled for a %s system and target is %s.\n"),
|
||||
input_bfd,
|
||||
bfd_big_endian (input_bfd) ? _("big endian") : _("little endian"),
|
||||
bfd_big_endian (output_bfd) ? _("big endian") : _("little endian"));
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hihalf = FALSE;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct internal_syment * sym;
|
||||
bfd_vma val;
|
||||
bfd_vma addend;
|
||||
bfd_reloc_status_type rstat;
|
||||
bfd_byte * loc;
|
||||
unsigned short r_type = rel->r_type;
|
||||
reloc_howto_type * howto = NULL;
|
||||
struct coff_link_hash_entry * h;
|
||||
const char * my_name;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
addend = 0;
|
||||
|
||||
/* Get the howto and initialise the addend. */
|
||||
howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
|
||||
sym, & addend);
|
||||
if (howto == NULL)
|
||||
return FALSE;
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
my_name = "*ABS*";
|
||||
else
|
||||
{
|
||||
asection * sec = sections[symndx];
|
||||
|
||||
val = (sym->n_value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
|
||||
if (sym == NULL)
|
||||
my_name = "*unknown*";
|
||||
else if ( sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
static char buf [SYMNMLEN + 1];
|
||||
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
my_name = buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection * 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, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
my_name = h->root.root.string;
|
||||
}
|
||||
|
||||
rstat = bfd_reloc_ok;
|
||||
|
||||
/* Each case must do its own relocation, setting rstat appropriately. */
|
||||
switch (r_type)
|
||||
{
|
||||
default:
|
||||
_bfd_error_handler (_("%B: unsupported relocation type 0x%02x"),
|
||||
input_bfd, r_type);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return FALSE;
|
||||
|
||||
case IMAGE_REL_MCORE_ABSOLUTE:
|
||||
_bfd_error_handler
|
||||
(_("Warning: unsupported reloc %s <file %B, section %A>\n"
|
||||
"sym %ld (%s), r_vaddr %ld (%lx)"),
|
||||
input_bfd, input_section, howto->name,
|
||||
rel->r_symndx, my_name, (long) rel->r_vaddr,
|
||||
(unsigned long) rel->r_vaddr);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_MCORE_PCREL_IMM8BY4:
|
||||
case IMAGE_REL_MCORE_PCREL_IMM11BY2:
|
||||
case IMAGE_REL_MCORE_PCREL_IMM4BY2:
|
||||
case IMAGE_REL_MCORE_PCREL_32:
|
||||
case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2:
|
||||
case IMAGE_REL_MCORE_ADDR32:
|
||||
/* XXX fixme - shouldn't this be like the code for the RVA reloc ? */
|
||||
rstat = _bfd_relocate_contents (howto, input_bfd, val, loc);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_MCORE_RVA:
|
||||
rstat = _bfd_final_link_relocate
|
||||
(howto, input_bfd,
|
||||
input_section, contents, rel->r_vaddr - input_section->vma,
|
||||
val, addend);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Emit a reloc if the backend thinks it needs it. */
|
||||
if (info->base_file
|
||||
&& sym
|
||||
&& pe_data (output_bfd)->in_reloc_p (output_bfd, howto)
|
||||
&& !mcore_emit_base_file_entry (info, output_bfd, input_section,
|
||||
rel->r_vaddr))
|
||||
return FALSE;
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
|
||||
case bfd_reloc_overflow:
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, (h ? &h->root : NULL), my_name, howto->name,
|
||||
(bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Tailor coffcode.h -- macro heaven. */
|
||||
|
||||
/* We use the special COFF backend linker, with our own special touch. */
|
||||
|
||||
#define coff_bfd_reloc_type_lookup mcore_coff_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup mcore_coff_reloc_name_lookup
|
||||
#define coff_relocate_section coff_mcore_relocate_section
|
||||
#define coff_rtype_to_howto coff_mcore_rtype_to_howto
|
||||
|
||||
#define SELECT_RELOC(internal, howto) {internal.r_type = howto->type;}
|
||||
|
||||
/* Make sure that the 'r_offset' field is copied properly
|
||||
so that identical binaries will compare the same. */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
/* Forward declaration to initialise alternative_target field. */
|
||||
extern const bfd_target TARGET_LITTLE_SYM;
|
||||
|
||||
/* The transfer vectors that lead the outside world to all of the above. */
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED,
|
||||
(SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
|
||||
0, & TARGET_LITTLE_SYM, COFF_SWAP_TABLE)
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED,
|
||||
(SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
|
||||
0, & TARGET_BIG_SYM, COFF_SWAP_TABLE)
|
1551
external/gpl3/binutils/dist/bfd/coff-mips.c
vendored
Normal file
1551
external/gpl3/binutils/dist/bfd/coff-mips.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
645
external/gpl3/binutils/dist/bfd/coff-or32.c
vendored
Normal file
645
external/gpl3/binutils/dist/bfd/coff-or32.c
vendored
Normal file
@ -0,0 +1,645 @@
|
||||
/* BFD back-end for OpenRISC 1000 COFF binaries.
|
||||
Copyright 2002, 2003, 2004, 2005, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Ivan Guzvinec <ivang@opencores.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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define OR32 1
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/or32.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static long get_symbol_value
|
||||
PARAMS ((asymbol *));
|
||||
static bfd_reloc_status_type or32_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_or32_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static bfd_boolean coff_or32_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, bfd_boolean *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#define INSERT_HWORD(WORD,HWORD) \
|
||||
(((WORD) & 0xffff0000) | ((HWORD)& 0x0000ffff))
|
||||
#define EXTRACT_HWORD(WORD) \
|
||||
((WORD) & 0x0000ffff)
|
||||
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
|
||||
|
||||
#define INSERT_JUMPTARG(WORD,JT) \
|
||||
(((WORD) & 0xfc000000) | ((JT)& 0x03ffffff))
|
||||
#define EXTRACT_JUMPTARG(WORD) \
|
||||
((WORD) & 0x03ffffff)
|
||||
#define SIGN_EXTEND_JUMPTARG(JT) \
|
||||
((JT) & 0x04000000 ? (JT)|(~0x03ffffffL) : (JT))
|
||||
|
||||
/* 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 or32 relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
or32_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 bfd_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_JUMPTARG (insn);
|
||||
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* See the note on the R_IREL reloc in coff_or32_relocate_section. */
|
||||
if (signed_value == - (long) reloc_entry->address)
|
||||
signed_value = 0;
|
||||
|
||||
signed_value += sym_value + reloc_entry->addend;
|
||||
/* 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 > 0x7ffffff || signed_value < -0x8000000)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_JUMPTARG (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)
|
||||
{
|
||||
*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, or32_reloc, "ABS", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
EMPTY_HOWTO (6),
|
||||
EMPTY_HOWTO (7),
|
||||
EMPTY_HOWTO (8),
|
||||
EMPTY_HOWTO (9),
|
||||
EMPTY_HOWTO (10),
|
||||
EMPTY_HOWTO (11),
|
||||
EMPTY_HOWTO (12),
|
||||
EMPTY_HOWTO (13),
|
||||
EMPTY_HOWTO (14),
|
||||
EMPTY_HOWTO (15),
|
||||
EMPTY_HOWTO (16),
|
||||
EMPTY_HOWTO (17),
|
||||
EMPTY_HOWTO (18),
|
||||
EMPTY_HOWTO (19),
|
||||
EMPTY_HOWTO (20),
|
||||
EMPTY_HOWTO (21),
|
||||
EMPTY_HOWTO (22),
|
||||
EMPTY_HOWTO (23),
|
||||
{ R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed, or32_reloc, "IREL", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
{ R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "IABS", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
{ R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE },
|
||||
{ R_IHIHALF, 0, 3, 16, TRUE, 16,complain_overflow_signed, or32_reloc, "IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE },
|
||||
{ R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE },
|
||||
{ R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, or32_reloc, "BYTE", TRUE, 0x000000ff,0x000000ff, FALSE },
|
||||
{ R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, or32_reloc, "HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE },
|
||||
{ R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "WORD", TRUE, 0xffffffff,0xffffffff, FALSE },
|
||||
};
|
||||
|
||||
#define BADMAG(x) OR32BADMAG (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
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
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 bfd_boolean
|
||||
coff_or32_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
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;
|
||||
bfd_boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocatable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocatable)
|
||||
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;
|
||||
bfd_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 || rel->r_type == R_IHCONST)
|
||||
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, TRUE)))
|
||||
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_JUMPTARG (insn);
|
||||
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* Determine the destination of the jump. */
|
||||
signed_value += val;
|
||||
|
||||
/* 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 > 0x7ffffff || signed_value < - 0x8000000)
|
||||
{
|
||||
overflow = TRUE;
|
||||
signed_value = 0;
|
||||
}
|
||||
|
||||
/* Put the adjusted value back into the instruction. */
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_JUMPTARG(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 = NULL;
|
||||
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, (h ? &h->root : NULL), 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_or32_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. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_or32_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
||||
bfd *ibfd ATTRIBUTE_UNUSED;
|
||||
asection *sec ATTRIBUTE_UNUSED;
|
||||
struct internal_reloc *irel;
|
||||
bfd_boolean *adjustedp;
|
||||
{
|
||||
if (irel->r_type == R_IHCONST)
|
||||
*adjustedp = TRUE;
|
||||
else
|
||||
*adjustedp = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define coff_adjust_symndx coff_or32_adjust_symndx
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target or32coff_big_vec =
|
||||
{
|
||||
"coff-or32-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,
|
||||
|
||||
/* Headers. */
|
||||
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),
|
||||
|
||||
/* Alternative_target. */
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
& TARGET_LITTLE_SYM,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
34
external/gpl3/binutils/dist/bfd/coff-pmac.c
vendored
Normal file
34
external/gpl3/binutils/dist/bfd/coff-pmac.c
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
|
||||
Copyright 1995, 2000, 2001, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
|
||||
|
||||
#define POWERMAC
|
||||
|
||||
#define TARGET_SYM pmac_xcoff_vec
|
||||
#define TARGET_NAME "xcoff-powermac"
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/rs6000.h"
|
||||
#include "libcoff.h"
|
||||
#include "xcoff-target.h"
|
2696
external/gpl3/binutils/dist/bfd/coff-ppc.c
vendored
Normal file
2696
external/gpl3/binutils/dist/bfd/coff-ppc.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4486
external/gpl3/binutils/dist/bfd/coff-rs6000.c
vendored
Normal file
4486
external/gpl3/binutils/dist/bfd/coff-rs6000.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3263
external/gpl3/binutils/dist/bfd/coff-sh.c
vendored
Normal file
3263
external/gpl3/binutils/dist/bfd/coff-sh.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
221
external/gpl3/binutils/dist/bfd/coff-sparc.c
vendored
Normal file
221
external/gpl3/binutils/dist/bfd/coff-sparc.c
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
/* BFD back-end for Sparc COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
|
||||
2002, 2003, 2005, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.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
|
||||
|
||||
|
||||
static reloc_howto_type *coff_sparc_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
/* 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 ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 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 {
|
||||
bfd_reloc_code_real_type 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 ATTRIBUTE_UNUSED;
|
||||
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 reloc_howto_type *
|
||||
coff_sparc_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < (sizeof (coff_sparc_howto_table)
|
||||
/ sizeof (coff_sparc_howto_table[0]));
|
||||
i++)
|
||||
if (coff_sparc_howto_table[i].name != NULL
|
||||
&& strcasecmp (coff_sparc_howto_table[i].name, r_name) == 0)
|
||||
return &coff_sparc_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#define coff_bfd_reloc_name_lookup coff_sparc_reloc_name_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 H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
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
|
||||
|
||||
#define bfd_pe_print_pdata NULL
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifndef TARGET_SYM
|
||||
#define TARGET_SYM sparccoff_vec
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_NAME
|
||||
#define TARGET_NAME "coff-sparc"
|
||||
#endif
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
415
external/gpl3/binutils/dist/bfd/coff-stgo32.c
vendored
Normal file
415
external/gpl3/binutils/dist/bfd/coff-stgo32.c
vendored
Normal file
@ -0,0 +1,415 @@
|
||||
/* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub).
|
||||
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
Written by Robert Hoehne.
|
||||
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/* This file handles now also stubbed coff images. The stub is a small
|
||||
DOS executable program before the coff image to load it in memory
|
||||
and execute it. This is needed, because DOS cannot run coff files.
|
||||
|
||||
All the functions below are called by the corresponding functions
|
||||
from coffswap.h.
|
||||
The only thing what they do is to adjust the information stored in
|
||||
the COFF file which are offset into the file.
|
||||
This is needed, because DJGPP uses a very special way to load and run
|
||||
the coff image. It loads the image in memory and assumes then, that the
|
||||
image had no stub by using the filepointers as pointers in the coff
|
||||
image and NOT in the file.
|
||||
|
||||
To be compatible with any existing executables I have fixed this
|
||||
here and NOT in the DJGPP startup code. */
|
||||
|
||||
#define TARGET_SYM go32stubbedcoff_vec
|
||||
#define TARGET_NAME "coff-go32-exe"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
#define COFF_GO32_EXE
|
||||
#define COFF_LONG_SECTION_NAMES
|
||||
#define COFF_SUPPORT_GNU_LINKONCE
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define COFF_SECTION_ALIGNMENT_ENTRIES \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
|
||||
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
|
||||
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
/* At first the prototypes. */
|
||||
|
||||
static void
|
||||
adjust_filehdr_in_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_filehdr_out_pre PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_filehdr_out_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_in_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_out_pre PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_scnhdr_out_post PARAMS ((bfd *, PTR, PTR));
|
||||
static void
|
||||
adjust_aux_in_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
adjust_aux_out_pre PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
adjust_aux_out_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
static void
|
||||
create_go32_stub PARAMS ((bfd *));
|
||||
|
||||
/* All that ..._PRE and ...POST functions are called from the corresponding
|
||||
coff_swap... functions. The ...PRE functions are called at the beginning
|
||||
of the function and the ...POST functions at the end of the swap routines. */
|
||||
|
||||
#define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post
|
||||
#define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre
|
||||
#define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post
|
||||
|
||||
#define COFF_ADJUST_SCNHDR_IN_POST adjust_scnhdr_in_post
|
||||
#define COFF_ADJUST_SCNHDR_OUT_PRE adjust_scnhdr_out_pre
|
||||
#define COFF_ADJUST_SCNHDR_OUT_POST adjust_scnhdr_out_post
|
||||
|
||||
#define COFF_ADJUST_AUX_IN_POST adjust_aux_in_post
|
||||
#define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre
|
||||
#define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post
|
||||
|
||||
static bfd_boolean
|
||||
go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
|
||||
#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
|
||||
|
||||
#include "coff-i386.c"
|
||||
|
||||
/* I hold in the usrdata the stub. */
|
||||
#define bfd_coff_go32stub bfd_usrdata
|
||||
|
||||
/* This macro is used, because I cannot assume the endianess of the
|
||||
host system. */
|
||||
#define _H(index) (H_GET_16 (abfd, (header+index*2)))
|
||||
|
||||
/* These bytes are a 2048-byte DOS executable, which loads the COFF
|
||||
image into memory and then runs it. It is called 'stub'. */
|
||||
|
||||
static const unsigned char stub_bytes[STUBSIZE] =
|
||||
{
|
||||
#include "go32stub.h"
|
||||
};
|
||||
|
||||
/*
|
||||
I have not commented each swap function below, because the
|
||||
technique is in any function the same. For the ...in function,
|
||||
all the pointers are adjusted by adding STUBSIZE and for the
|
||||
...out function, it is subtracted first and after calling the
|
||||
standard swap function it is reset to the old value. */
|
||||
|
||||
/* This macro is used for adjusting the filepointers, which
|
||||
is done only, if the pointer is nonzero. */
|
||||
|
||||
#define ADJUST_VAL(val,diff) \
|
||||
if (val != 0) val += diff
|
||||
|
||||
static void
|
||||
adjust_filehdr_in_post (abfd, src, dst)
|
||||
bfd *abfd;
|
||||
PTR src;
|
||||
PTR dst;
|
||||
{
|
||||
FILHDR *filehdr_src = (FILHDR *) src;
|
||||
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
|
||||
|
||||
ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
|
||||
|
||||
/* Save now the stub to be used later. */
|
||||
bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
|
||||
|
||||
/* Since this function returns no status, I do not set here
|
||||
any bfd_error_...
|
||||
That means, before the use of bfd_coff_go32stub (), this value
|
||||
should be checked if it is != NULL. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
return;
|
||||
memcpy (bfd_coff_go32stub (abfd), filehdr_src->stub, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_filehdr_out_pre (abfd, in, out)
|
||||
bfd *abfd;
|
||||
PTR in;
|
||||
PTR out;
|
||||
{
|
||||
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
|
||||
FILHDR *filehdr_out = (FILHDR *) out;
|
||||
|
||||
/* Generate the stub. */
|
||||
create_go32_stub (abfd);
|
||||
|
||||
/* Copy the stub to the file header. */
|
||||
if (bfd_coff_go32stub (abfd) != NULL)
|
||||
memcpy (filehdr_out->stub, bfd_coff_go32stub (abfd), STUBSIZE);
|
||||
else
|
||||
/* Use the default. */
|
||||
memcpy (filehdr_out->stub, stub_bytes, STUBSIZE);
|
||||
|
||||
ADJUST_VAL (filehdr_in->f_symptr, -STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_filehdr_out_post (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
|
||||
/* Undo the above change. */
|
||||
ADJUST_VAL (filehdr_in->f_symptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_in_post (abfd, ext, in)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR ext ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_out_pre (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, -STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, -STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, -STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_scnhdr_out_post (abfd, in, out)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR in;
|
||||
PTR out ATTRIBUTE_UNUSED;
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
ADJUST_VAL (scnhdr_int->s_scnptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_relptr, STUBSIZE);
|
||||
ADJUST_VAL (scnhdr_int->s_lnnoptr, STUBSIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_in_post (abfd, ext1, type, class, indx, numaux, in1)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR ext1 ATTRIBUTE_UNUSED;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR in1;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) in1;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_out_pre (abfd, inp, type, class, indx, numaux, extp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR inp;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR extp ATTRIBUTE_UNUSED;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) inp;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_aux_out_post (abfd, inp, type, class, indx, numaux, extp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR inp;
|
||||
int type;
|
||||
int class;
|
||||
int indx ATTRIBUTE_UNUSED;
|
||||
int numaux ATTRIBUTE_UNUSED;
|
||||
PTR extp ATTRIBUTE_UNUSED;
|
||||
{
|
||||
union internal_auxent *in = (union internal_auxent *) inp;
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* That's the function, which creates the stub. There are
|
||||
different cases from where the stub is taken.
|
||||
At first the environment variable $(GO32STUB) is checked and then
|
||||
$(STUB) if it was not set.
|
||||
If it exists and points to a valid stub the stub is taken from
|
||||
that file. This file can be also a whole executable file, because
|
||||
the stub is computed from the exe information at the start of that
|
||||
file.
|
||||
|
||||
If there was any error, the standard stub (compiled in this file)
|
||||
is taken. */
|
||||
|
||||
static void
|
||||
create_go32_stub (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
/* Do it only once. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
char *stub;
|
||||
struct stat st;
|
||||
int f;
|
||||
unsigned char header[10];
|
||||
char magic[8];
|
||||
unsigned long coff_start;
|
||||
long exe_start;
|
||||
|
||||
/* Check at first the environment variable $(GO32STUB). */
|
||||
stub = getenv ("GO32STUB");
|
||||
/* Now check the environment variable $(STUB). */
|
||||
if (stub == NULL)
|
||||
stub = getenv ("STUB");
|
||||
if (stub == NULL)
|
||||
goto stub_end;
|
||||
if (stat (stub, &st) != 0)
|
||||
goto stub_end;
|
||||
#ifdef O_BINARY
|
||||
f = open (stub, O_RDONLY | O_BINARY);
|
||||
#else
|
||||
f = open (stub, O_RDONLY);
|
||||
#endif
|
||||
if (f < 0)
|
||||
goto stub_end;
|
||||
if (read (f, &header, sizeof (header)) < 0)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (_H (0) != 0x5a4d) /* It is not an exe file. */
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
/* Compute the size of the stub (it is every thing up
|
||||
to the beginning of the coff image). */
|
||||
coff_start = (long) _H (2) * 512L;
|
||||
if (_H (1))
|
||||
coff_start += (long) _H (1) - 512L;
|
||||
|
||||
/* Currently there is only a fixed stub size of 2048 bytes
|
||||
supported. */
|
||||
if (coff_start != 2048)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
exe_start = _H (4) * 16;
|
||||
if ((long) lseek (f, exe_start, SEEK_SET) != exe_start)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (read (f, &magic, 8) != 8)
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
if (! CONST_STRNEQ (magic, "go32stub"))
|
||||
{
|
||||
close (f);
|
||||
goto stub_end;
|
||||
}
|
||||
/* Now we found a correct stub (hopefully). */
|
||||
bfd_coff_go32stub (abfd)
|
||||
= (PTR) bfd_alloc (abfd, (bfd_size_type) coff_start);
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
close (f);
|
||||
return;
|
||||
}
|
||||
lseek (f, 0L, SEEK_SET);
|
||||
if ((unsigned long) read (f, bfd_coff_go32stub (abfd), coff_start)
|
||||
!= coff_start)
|
||||
{
|
||||
bfd_release (abfd, bfd_coff_go32stub (abfd));
|
||||
bfd_coff_go32stub (abfd) = NULL;
|
||||
}
|
||||
close (f);
|
||||
}
|
||||
stub_end:
|
||||
/* There was something wrong above, so use now the standard builtin
|
||||
stub. */
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
{
|
||||
bfd_coff_go32stub (abfd)
|
||||
= (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
|
||||
if (bfd_coff_go32stub (abfd) == NULL)
|
||||
return;
|
||||
memcpy (bfd_coff_go32stub (abfd), stub_bytes, STUBSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/* If ibfd was a stubbed coff image, copy the stub from that bfd
|
||||
to the new obfd. */
|
||||
|
||||
static bfd_boolean
|
||||
go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
/* Check if both are the same targets. */
|
||||
if (ibfd->xvec != obfd->xvec)
|
||||
return TRUE;
|
||||
|
||||
/* Check if both have a valid stub. */
|
||||
if (bfd_coff_go32stub (ibfd) == NULL
|
||||
|| bfd_coff_go32stub (obfd) == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* Now copy the stub. */
|
||||
memcpy (bfd_coff_go32stub (obfd), bfd_coff_go32stub (ibfd), STUBSIZE);
|
||||
|
||||
return TRUE;
|
||||
}
|
27
external/gpl3/binutils/dist/bfd/coff-svm68k.c
vendored
Normal file
27
external/gpl3/binutils/dist/bfd/coff-svm68k.c
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/* BFD back-end for Motorola sysv68
|
||||
Copyright 1997, 2007 Free Software Foundation, Inc.
|
||||
Written by Philippe De Muyter <phdm@info.ucl.ac.be>.
|
||||
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define TARGET_SYM m68ksysvcoff_vec
|
||||
#define TARGET_NAME "coff-m68k-sysv"
|
||||
#define STATIC_RELOCS
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "coff-m68k.c"
|
233
external/gpl3/binutils/dist/bfd/coff-tic30.c
vendored
Normal file
233
external/gpl3/binutils/dist/bfd/coff-tic30.c
vendored
Normal file
@ -0,0 +1,233 @@
|
||||
/* BFD back-end for TMS320C30 coff binaries.
|
||||
Copyright 1998, 1999, 2000, 2001, 2002, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic30.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int coff_tic30_select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
reloc_howto_type * tic30_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
reloc_howto_type tic30_coff_howto_table[] =
|
||||
{
|
||||
HOWTO (R_TIC30_ABS16, 2, 1, 16, FALSE, 0, 0, NULL,
|
||||
"16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
|
||||
HOWTO (R_TIC30_ABS24, 2, 2, 24, FALSE, 8, complain_overflow_bitfield, NULL,
|
||||
"24", FALSE, 0xFFFFFF00, 0xFFFFFF00, FALSE),
|
||||
HOWTO (R_TIC30_LDP, 18, 0, 24, FALSE, 0, complain_overflow_bitfield, NULL,
|
||||
"LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
|
||||
HOWTO (R_TIC30_ABS32, 2, 2, 32, FALSE, 0, complain_overflow_bitfield, NULL,
|
||||
"32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
|
||||
HOWTO (R_TIC30_PC16, 2, 1, 16, TRUE, 0, complain_overflow_signed, NULL,
|
||||
"PCREL", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
|
||||
EMPTY_HOWTO (-1)
|
||||
};
|
||||
|
||||
#ifndef coff_bfd_reloc_type_lookup
|
||||
#define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup tic30_coff_reloc_name_lookup
|
||||
|
||||
/* For the case statement use the code values used in tc_gen_reloc to
|
||||
map to the howto table entries that match those in both the aout
|
||||
and coff implementations. */
|
||||
|
||||
reloc_howto_type *
|
||||
tic30_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_8:
|
||||
case BFD_RELOC_TIC30_LDP:
|
||||
return &tic30_coff_howto_table[2];
|
||||
case BFD_RELOC_16:
|
||||
return &tic30_coff_howto_table[0];
|
||||
case BFD_RELOC_24:
|
||||
return &tic30_coff_howto_table[1];
|
||||
case BFD_RELOC_16_PCREL:
|
||||
return &tic30_coff_howto_table[4];
|
||||
case BFD_RELOC_32:
|
||||
return &tic30_coff_howto_table[3];
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
tic30_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < (sizeof (tic30_coff_howto_table)
|
||||
/ sizeof (tic30_coff_howto_table[0]));
|
||||
i++)
|
||||
if (tic30_coff_howto_table[i].name != NULL
|
||||
&& strcasecmp (tic30_coff_howto_table[i].name, r_name) == 0)
|
||||
return &tic30_coff_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Turn a howto into a reloc number. */
|
||||
|
||||
static int
|
||||
coff_tic30_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto)
|
||||
|
||||
#define BADMAG(x) TIC30BADMAG(x)
|
||||
#define TIC30 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET 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)
|
||||
{
|
||||
case R_TIC30_ABS16:
|
||||
internal->howto = &tic30_coff_howto_table[0];
|
||||
break;
|
||||
case R_TIC30_ABS24:
|
||||
internal->howto = &tic30_coff_howto_table[1];
|
||||
break;
|
||||
case R_TIC30_ABS32:
|
||||
internal->howto = &tic30_coff_howto_table[3];
|
||||
break;
|
||||
case R_TIC30_LDP:
|
||||
internal->howto = &tic30_coff_howto_table[2];
|
||||
break;
|
||||
case R_TIC30_PC16:
|
||||
internal->howto = &tic30_coff_howto_table[4];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target tic30_coff_vec =
|
||||
{
|
||||
"coff-tic30", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
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 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_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),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
292
external/gpl3/binutils/dist/bfd/coff-tic4x.c
vendored
Normal file
292
external/gpl3/binutils/dist/bfd/coff-tic4x.c
vendored
Normal file
@ -0,0 +1,292 @@
|
||||
/* BFD back-end for TMS320C4X coff binaries.
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005, 2007,
|
||||
2008 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
|
||||
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic4x.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#undef F_LSYMS
|
||||
#define F_LSYMS F_LSYMS_TICOFF
|
||||
|
||||
static bfd_boolean ticoff_bfd_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
static bfd_reloc_status_type tic4x_relocation
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char ** ));
|
||||
static reloc_howto_type *tic4x_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type ));
|
||||
static void tic4x_lookup_howto
|
||||
PARAMS ((arelent *, struct internal_reloc * ));
|
||||
static reloc_howto_type *coff_tic4x_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma * ));
|
||||
static void tic4x_reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection * ));
|
||||
|
||||
|
||||
/* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
|
||||
labels. */
|
||||
static bfd_boolean
|
||||
ticoff_bfd_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
if (TICOFF_LOCAL_LABEL_P(name))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
|
||||
|
||||
#define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
|
||||
tic4x_reloc_processing (RELENT,RELOC,SYMS,ABFD,SECT)
|
||||
|
||||
/* Customize coffcode.h; the default coff_ functions are set up to use
|
||||
COFF2; coff_bad_format_hook uses BADMAG, so set that for COFF2.
|
||||
The COFF1 and COFF0 vectors use custom _bad_format_hook procs
|
||||
instead of setting BADMAG. */
|
||||
#define BADMAG(x) COFF2_BADMAG(x)
|
||||
|
||||
#undef coff_rtype_to_howto
|
||||
#define coff_rtype_to_howto coff_tic4x_rtype_to_howto
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
tic4x_relocation (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
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;
|
||||
}
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
reloc_howto_type tic4x_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELWORD, 0, 2, 16, FALSE, 0, complain_overflow_signed, tic4x_relocation, "RELWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_REL24, 0, 2, 24, FALSE, 0, complain_overflow_bitfield, tic4x_relocation, "REL24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_dont, tic4x_relocation, "RELLONG", TRUE, 0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO(R_PCRWORD, 0, 2, 16, TRUE, 0, complain_overflow_signed, tic4x_relocation, "PCRWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PCR24, 0, 2, 24, TRUE, 0, complain_overflow_signed, tic4x_relocation, "PCR24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_PARTLS16, 0, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "PARTLS16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PARTMS8, 16, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "PARTMS8", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_RELWORD, 0, 2, 16, FALSE, 0, complain_overflow_signed, tic4x_relocation, "ARELWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_REL24, 0, 2, 24, FALSE, 0, complain_overflow_signed, tic4x_relocation, "AREL24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_signed, tic4x_relocation, "ARELLONG", TRUE, 0xffffffff, 0xffffffff, FALSE),
|
||||
HOWTO(R_PCRWORD, 0, 2, 16, TRUE, 0, complain_overflow_signed, tic4x_relocation, "APCRWORD", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PCR24, 0, 2, 24, TRUE, 0, complain_overflow_signed, tic4x_relocation, "APCR24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
|
||||
HOWTO(R_PARTLS16, 0, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "APARTLS16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
HOWTO(R_PARTMS8, 16, 2, 16, FALSE, 0, complain_overflow_dont, tic4x_relocation, "APARTMS8", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
|
||||
};
|
||||
#define HOWTO_SIZE (sizeof(tic4x_howto_table) / sizeof(tic4x_howto_table[0]))
|
||||
|
||||
#undef coff_bfd_reloc_type_lookup
|
||||
#define coff_bfd_reloc_type_lookup tic4x_coff_reloc_type_lookup
|
||||
#undef coff_bfd_reloc_name_lookup
|
||||
#define coff_bfd_reloc_name_lookup tic4x_coff_reloc_name_lookup
|
||||
|
||||
/* For the case statement use the code values used tc_gen_reloc (defined in
|
||||
bfd/reloc.c) to map to the howto table entries. */
|
||||
|
||||
static reloc_howto_type *
|
||||
tic4x_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int type;
|
||||
unsigned int i;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_32: type = R_RELLONG; break;
|
||||
case BFD_RELOC_24: type = R_REL24; break;
|
||||
case BFD_RELOC_16: type = R_RELWORD; break;
|
||||
case BFD_RELOC_24_PCREL: type = R_PCR24; break;
|
||||
case BFD_RELOC_16_PCREL: type = R_PCRWORD; break;
|
||||
case BFD_RELOC_HI16: type = R_PARTMS8; break;
|
||||
case BFD_RELOC_LO16: type = R_PARTLS16; break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < HOWTO_SIZE; i++)
|
||||
{
|
||||
if (tic4x_howto_table[i].type == type)
|
||||
return tic4x_howto_table + i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
tic4x_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (tic4x_howto_table) / sizeof (tic4x_howto_table[0]);
|
||||
i++)
|
||||
if (tic4x_howto_table[i].name != NULL
|
||||
&& strcasecmp (tic4x_howto_table[i].name, r_name) == 0)
|
||||
return &tic4x_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table.
|
||||
Called after some initial checking by the tic4x_rtype_to_howto fn
|
||||
below. */
|
||||
static void
|
||||
tic4x_lookup_howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned int i;
|
||||
int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
|
||||
|
||||
for (i = 0; i < HOWTO_SIZE; i++)
|
||||
{
|
||||
if (tic4x_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
internal->howto = tic4x_howto_table + i + bank;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
abort();
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic4x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel->r_symndx == -1 && addendp != NULL)
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
|
||||
|
||||
tic4x_lookup_howto (&genrel, rel);
|
||||
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tic4x_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
asymbol *ptr;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
|
||||
if (reloc->r_symndx != -1)
|
||||
{
|
||||
if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%s: warning: illegal symbol index %ld in relocs"),
|
||||
bfd_get_filename (abfd), reloc->r_symndx);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[reloc->r_symndx]);
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = section->symbol_ptr_ptr;
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been relocated
|
||||
as if their sections started at 0. But the offsets refering to
|
||||
the symbols in the raw data have not been modified, so we have to
|
||||
have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, *reloc, relent);
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* !! relent->section = (asection *) NULL; */
|
||||
|
||||
/* Fill in the relent->howto field from reloc->r_type. */
|
||||
tic4x_lookup_howto (relent, reloc);
|
||||
}
|
||||
|
||||
|
||||
/* TI COFF v0, DOS tools (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x", HAS_LOAD_PAGE, 0, '_', NULL, (PTR)&ticoff0_swap_table);
|
||||
|
||||
/* TI COFF v0, SPARC tools (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_vec, (PTR)&ticoff0_swap_table);
|
||||
|
||||
/* TI COFF v1, DOS tools (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_beh_vec, (PTR)&ticoff1_swap_table);
|
||||
|
||||
/* TI COFF v1, SPARC tools (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_vec, (PTR)&ticoff1_swap_table);
|
||||
|
||||
/* TI COFF v2, TI DOS tools output (little-endian headers). */
|
||||
CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_beh_vec, COFF_SWAP_TABLE);
|
||||
|
||||
/* TI COFF v2, TI SPARC tools output (big-endian headers). */
|
||||
CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff2_vec, COFF_SWAP_TABLE);
|
700
external/gpl3/binutils/dist/bfd/coff-tic54x.c
vendored
Normal file
700
external/gpl3/binutils/dist/bfd/coff-tic54x.c
vendored
Normal file
@ -0,0 +1,700 @@
|
||||
/* BFD back-end for TMS320C54X coff binaries.
|
||||
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Timothy Wall (twall@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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/tic54x.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#undef F_LSYMS
|
||||
#define F_LSYMS F_LSYMS_TICOFF
|
||||
|
||||
static void tic54x_reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static bfd_reloc_status_type tic54x_relocation
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean tic54x_set_section_contents
|
||||
PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type));
|
||||
static reloc_howto_type *coff_tic54x_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
|
||||
static bfd_boolean tic54x_set_arch_mach
|
||||
PARAMS ((bfd *, enum bfd_architecture, unsigned long));
|
||||
static reloc_howto_type * tic54x_coff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void tic54x_lookup_howto
|
||||
PARAMS ((arelent *, struct internal_reloc *));
|
||||
static bfd_boolean ticoff_bfd_is_local_label_name
|
||||
PARAMS ((bfd *, const char *));
|
||||
|
||||
/* 32-bit operations
|
||||
The octet order is screwy. words are LSB first (LS octet, actually), but
|
||||
longwords are MSW first. For example, 0x12345678 is encoded 0x5678 in the
|
||||
first word and 0x1234 in the second. When looking at the data as stored in
|
||||
the COFF file, you would see the octets ordered as 0x78, 0x56, 0x34, 0x12.
|
||||
Don't bother with 64-bits, as there aren't any. */
|
||||
|
||||
static bfd_vma
|
||||
tic54x_getl32 (const void *p)
|
||||
{
|
||||
const bfd_byte *addr = p;
|
||||
unsigned long v;
|
||||
|
||||
v = (unsigned long) addr[2];
|
||||
v |= (unsigned long) addr[3] << 8;
|
||||
v |= (unsigned long) addr[0] << 16;
|
||||
v |= (unsigned long) addr[1] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
tic54x_putl32 (bfd_vma data, void *p)
|
||||
{
|
||||
bfd_byte *addr = p;
|
||||
addr[2] = data & 0xff;
|
||||
addr[3] = (data >> 8) & 0xff;
|
||||
addr[0] = (data >> 16) & 0xff;
|
||||
addr[1] = (data >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static bfd_signed_vma
|
||||
tic54x_getl_signed_32 (const void *p)
|
||||
{
|
||||
const bfd_byte *addr = p;
|
||||
unsigned long v;
|
||||
|
||||
v = (unsigned long) addr[2];
|
||||
v |= (unsigned long) addr[3] << 8;
|
||||
v |= (unsigned long) addr[0] << 16;
|
||||
v |= (unsigned long) addr[1] << 24;
|
||||
#define COERCE32(x) \
|
||||
((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
|
||||
return COERCE32 (v);
|
||||
}
|
||||
|
||||
#define coff_get_section_load_page bfd_ticoff_get_section_load_page
|
||||
#define coff_set_section_load_page bfd_ticoff_set_section_load_page
|
||||
|
||||
void
|
||||
bfd_ticoff_set_section_load_page (sect, page)
|
||||
asection *sect;
|
||||
int page;
|
||||
{
|
||||
sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page);
|
||||
}
|
||||
|
||||
int
|
||||
bfd_ticoff_get_section_load_page (sect)
|
||||
asection *sect;
|
||||
{
|
||||
int page;
|
||||
|
||||
/* Provide meaningful defaults for predefined sections. */
|
||||
if (sect == &bfd_com_section)
|
||||
page = PG_DATA;
|
||||
|
||||
else if (sect == &bfd_und_section
|
||||
|| sect == &bfd_abs_section
|
||||
|| sect == &bfd_ind_section)
|
||||
page = PG_PROG;
|
||||
|
||||
else
|
||||
page = FLAG_TO_PG (sect->lma);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/* Set the architecture appropriately. Allow unkown architectures
|
||||
(e.g. binary). */
|
||||
|
||||
static bfd_boolean
|
||||
tic54x_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
if (arch == bfd_arch_unknown)
|
||||
arch = bfd_arch_tic54x;
|
||||
|
||||
else if (arch != bfd_arch_tic54x)
|
||||
return FALSE;
|
||||
|
||||
return bfd_default_set_arch_mach (abfd, arch, machine);
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
tic54x_relocation (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
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;
|
||||
}
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
reloc_howto_type tic54x_howto_table[] =
|
||||
{
|
||||
/* type,rightshift,size (0=byte, 1=short, 2=long),
|
||||
bit size, pc_relative, bitpos, dont complain_on_overflow,
|
||||
special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset. */
|
||||
|
||||
/* NORMAL BANK */
|
||||
/* 16-bit direct reference to symbol's address. */
|
||||
HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"REL16",FALSE,0xFFFF,0xFFFF,FALSE),
|
||||
|
||||
/* 7 LSBs of an address */
|
||||
HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"LS7",FALSE,0x007F,0x007F,FALSE),
|
||||
|
||||
/* 9 MSBs of an address */
|
||||
/* TI assembler doesn't shift its encoding, and is thus incompatible */
|
||||
HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"MS9",FALSE,0x01FF,0x01FF,FALSE),
|
||||
|
||||
/* 23-bit relocation */
|
||||
HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* 16 bits of 23-bit extended address */
|
||||
HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* upper 7 bits of 23-bit extended address */
|
||||
HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"RELEXTMS7",FALSE,0x7F,0x7F,FALSE),
|
||||
|
||||
/* ABSOLUTE BANK */
|
||||
/* 16-bit direct reference to symbol's address, absolute */
|
||||
HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"AREL16",FALSE,0xFFFF,0xFFFF,FALSE),
|
||||
|
||||
/* 7 LSBs of an address, absolute */
|
||||
HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ALS7",FALSE,0x007F,0x007F,FALSE),
|
||||
|
||||
/* 9 MSBs of an address, absolute */
|
||||
/* TI assembler doesn't shift its encoding, and is thus incompatible */
|
||||
HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"AMS9",FALSE,0x01FF,0x01FF,FALSE),
|
||||
|
||||
/* 23-bit direct reference, absolute */
|
||||
HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* 16 bits of 23-bit extended address, absolute */
|
||||
HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
|
||||
|
||||
/* upper 7 bits of 23-bit extended address, absolute */
|
||||
HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"ARELEXTMS7",FALSE,0x7F,0x7F,FALSE),
|
||||
|
||||
/* 32-bit relocation exclusively for stabs */
|
||||
HOWTO (R_RELLONG,0,2,32,FALSE,0,complain_overflow_dont,
|
||||
tic54x_relocation,"STAB",FALSE,0xFFFFFFFF,0xFFFFFFFF,FALSE),
|
||||
};
|
||||
|
||||
#define coff_bfd_reloc_type_lookup tic54x_coff_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup tic54x_coff_reloc_name_lookup
|
||||
|
||||
/* For the case statement use the code values used tc_gen_reloc (defined in
|
||||
bfd/reloc.c) to map to the howto table entries. */
|
||||
|
||||
reloc_howto_type *
|
||||
tic54x_coff_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
return &tic54x_howto_table[0];
|
||||
case BFD_RELOC_TIC54X_PARTLS7:
|
||||
return &tic54x_howto_table[1];
|
||||
case BFD_RELOC_TIC54X_PARTMS9:
|
||||
return &tic54x_howto_table[2];
|
||||
case BFD_RELOC_TIC54X_23:
|
||||
return &tic54x_howto_table[3];
|
||||
case BFD_RELOC_TIC54X_16_OF_23:
|
||||
return &tic54x_howto_table[4];
|
||||
case BFD_RELOC_TIC54X_MS7_OF_23:
|
||||
return &tic54x_howto_table[5];
|
||||
case BFD_RELOC_32:
|
||||
return &tic54x_howto_table[12];
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
tic54x_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (tic54x_howto_table) / sizeof (tic54x_howto_table[0]);
|
||||
i++)
|
||||
if (tic54x_howto_table[i].name != NULL
|
||||
&& strcasecmp (tic54x_howto_table[i].name, r_name) == 0)
|
||||
return &tic54x_howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table.
|
||||
Called after some initial checking by the tic54x_rtype_to_howto fn below. */
|
||||
|
||||
static void
|
||||
tic54x_lookup_howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned i;
|
||||
int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
|
||||
|
||||
for (i = 0; i < sizeof tic54x_howto_table/sizeof tic54x_howto_table[0]; i++)
|
||||
{
|
||||
if (tic54x_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
internal->howto = tic54x_howto_table + i + bank;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
|
||||
tic54x_reloc_processing(RELENT,RELOC,SYMS,ABFD,SECT)
|
||||
|
||||
#define coff_rtype_to_howto coff_tic54x_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic54x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel->r_symndx == -1 && addendp != NULL)
|
||||
{
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
|
||||
}
|
||||
|
||||
tic54x_lookup_howto (&genrel, rel);
|
||||
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
/* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
|
||||
labels. */
|
||||
|
||||
static bfd_boolean
|
||||
ticoff_bfd_is_local_label_name (abfd, name)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
const char *name;
|
||||
{
|
||||
if (TICOFF_LOCAL_LABEL_P(name))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
|
||||
|
||||
/* Clear the r_reserved field in relocs. */
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||
do \
|
||||
{ \
|
||||
dst->r_reserved[0] = 0; \
|
||||
dst->r_reserved[1] = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Customize coffcode.h; the default coff_ functions are set up to use COFF2;
|
||||
coff_bad_format_hook uses BADMAG, so set that for COFF2. The COFF1
|
||||
and COFF0 vectors use custom _bad_format_hook procs instead of setting
|
||||
BADMAG. */
|
||||
#define BADMAG(x) COFF2_BADMAG(x)
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static bfd_boolean
|
||||
tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
const PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type bytes_to_do;
|
||||
{
|
||||
return coff_set_section_contents (abfd, section, location,
|
||||
offset, bytes_to_do);
|
||||
}
|
||||
|
||||
static void
|
||||
tic54x_reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
asymbol *ptr;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
|
||||
if (reloc->r_symndx != -1)
|
||||
{
|
||||
if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: warning: illegal symbol index %ld in relocs"),
|
||||
abfd, reloc->r_symndx);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
ptr = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (symbols
|
||||
+ obj_convert (abfd)[reloc->r_symndx]);
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = section->symbol_ptr_ptr;
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
}
|
||||
|
||||
/* The symbols definitions that we have read in have been
|
||||
relocated as if their sections started at 0. But the offsets
|
||||
refering to the symbols in the raw data have not been
|
||||
modified, so we have to have a negative addend to compensate.
|
||||
|
||||
Note that symbols which used to be common must be left alone. */
|
||||
|
||||
/* Calculate any reloc addend by looking at the symbol. */
|
||||
CALC_ADDEND (abfd, ptr, *reloc, relent);
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* !! relent->section = (asection *) NULL;*/
|
||||
|
||||
/* Fill in the relent->howto field from reloc->r_type. */
|
||||
tic54x_lookup_howto (relent, reloc);
|
||||
}
|
||||
|
||||
/* TI COFF v0, DOS tools (little-endian headers). */
|
||||
const bfd_target tic54x_coff0_vec =
|
||||
{
|
||||
"coff0-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(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_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
NULL,
|
||||
|
||||
(PTR) & ticoff0_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v0, SPARC tools (big-endian headers). */
|
||||
const bfd_target tic54x_coff0_beh_vec =
|
||||
{
|
||||
"coff0-beh-c54x", /* 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 symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff0_vec,
|
||||
|
||||
(PTR) & ticoff0_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v1, DOS tools (little-endian headers). */
|
||||
const bfd_target tic54x_coff1_vec =
|
||||
{
|
||||
"coff1-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(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_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff0_beh_vec,
|
||||
|
||||
(PTR) & ticoff1_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v1, SPARC tools (big-endian headers). */
|
||||
const bfd_target tic54x_coff1_beh_vec =
|
||||
{
|
||||
"coff1-beh-c54x", /* 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 symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff1_vec,
|
||||
|
||||
(PTR) & ticoff1_swap_table
|
||||
};
|
||||
|
||||
/* TI COFF v2, TI DOS tools output (little-endian headers). */
|
||||
const bfd_target tic54x_coff2_vec =
|
||||
{
|
||||
"coff2-c54x", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */
|
||||
|
||||
(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_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff1_beh_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
|
||||
/* TI COFF v2, TI SPARC tools output (big-endian headers). */
|
||||
const bfd_target tic54x_coff2_beh_vec =
|
||||
{
|
||||
"coff2-beh-c54x", /* 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 symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
tic54x_getl32, tic54x_getl_signed_32, tic54x_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_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 (tic54x),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
& tic54x_coff2_vec,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
744
external/gpl3/binutils/dist/bfd/coff-tic80.c
vendored
Normal file
744
external/gpl3/binutils/dist/bfd/coff-tic80.c
vendored
Normal file
@ -0,0 +1,744 @@
|
||||
/* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP).
|
||||
Copyright 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written by Fred Fish (fnf@cygnus.com)
|
||||
|
||||
There is nothing new under the sun. This file draws a lot on other
|
||||
coff 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 3 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, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libbfd.h"
|
||||
#ifdef _CONST
|
||||
/* Newlib-based hosts define _CONST as a STDC-safe alias for const,
|
||||
but to the tic80 toolchain it means something altogether different.
|
||||
Since sysdep.h will have pulled in stdio.h and hence _ansi.h which
|
||||
contains this definition, we must undef it before including the
|
||||
tic80-specific definition. */
|
||||
#undef _CONST
|
||||
#endif /* _CONST */
|
||||
#include "coff/tic80.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
#define COFF_ALIGN_IN_SECTION_HEADER 1
|
||||
#define COFF_ALIGN_IN_SFLAGS 1
|
||||
|
||||
#define GET_SCNHDR_FLAGS H_GET_16
|
||||
#define PUT_SCNHDR_FLAGS H_PUT_16
|
||||
|
||||
static void rtype2howto
|
||||
PARAMS ((arelent *cache_ptr, struct internal_reloc *dst));
|
||||
static bfd_reloc_status_type ppbase_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type glob15_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type glob16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type local16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_boolean coff_tic80_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static reloc_howto_type * coff_tic80_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
static reloc_howto_type tic80_howto_table[] =
|
||||
{
|
||||
|
||||
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 */
|
||||
NULL, /* special_function */
|
||||
"RELLONG", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_MPPCR, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"MPPCR", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_ABS, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"ABS", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
ppbase_reloc, /* special_function */
|
||||
"PPBASE", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
ppbase_reloc, /* special_function */
|
||||
"PPLBASE", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15W, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP15H, /* type */
|
||||
1, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PP15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PP16B, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob16_reloc, /* special_function */
|
||||
"PP16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x3ffc0, /* src_mask */
|
||||
0x3ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15W, /* type */
|
||||
2, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL15H, /* type */
|
||||
1, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPL15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPL16B, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
local16_reloc, /* special_function */
|
||||
"PPL16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15W, /* type */
|
||||
2, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN15H, /* type */
|
||||
1, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob15_reloc, /* special_function */
|
||||
"PPN15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x1ffc0, /* src_mask */
|
||||
0x1ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPN16B, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
6, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
glob16_reloc, /* special_function */
|
||||
"PPN16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x3ffc0, /* src_mask */
|
||||
0x3ffc0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15W, /* type */
|
||||
2, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15W", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN15H, /* type */
|
||||
1, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
NULL, /* special_function */
|
||||
"PPLN15H", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x7fff, /* src_mask */
|
||||
0x7fff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPLN16B, /* type */
|
||||
0, /* rightshift */
|
||||
-2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
15, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
local16_reloc, /* special_function */
|
||||
"PPLN16B", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffff, /* src_mask */
|
||||
0xffff, /* dst_mask */
|
||||
FALSE) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Special relocation functions, used when the output file is not
|
||||
itself a COFF TIc80 file. */
|
||||
|
||||
/* This special function is used for the base address type
|
||||
relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
ppbase_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the global 15 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
glob15_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the global 16 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
glob16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This special function is used for the local 16 bit relocations. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
local16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
arelent *reloc_entry ATTRIBUTE_UNUSED;
|
||||
asymbol *symbol_in ATTRIBUTE_UNUSED;
|
||||
PTR data ATTRIBUTE_UNUSED;
|
||||
asection *input_section ATTRIBUTE_UNUSED;
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
char **error_message ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* FIXME. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Code to turn an external r_type into a pointer to an entry in the howto_table.
|
||||
If passed an r_type we don't recognize the abort rather than silently failing
|
||||
to generate an output file. */
|
||||
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof tic80_howto_table / sizeof tic80_howto_table[0]; i++)
|
||||
{
|
||||
if (tic80_howto_table[i].type == dst->r_type)
|
||||
{
|
||||
cache_ptr->howto = tic80_howto_table + i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
|
||||
(unsigned int) dst->r_type);
|
||||
cache_ptr->howto = tic80_howto_table + 0;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||
#define coff_rtype_to_howto coff_tic80_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
|
||||
struct internal_syment *sym ATTRIBUTE_UNUSED;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent genrel;
|
||||
|
||||
if (rel -> r_symndx == -1 && addendp != NULL)
|
||||
{
|
||||
/* This is a TI "internal relocation", which means that the relocation
|
||||
amount is the amount by which the current section is being relocated
|
||||
in the output section. */
|
||||
*addendp = (sec -> output_section -> vma + sec -> output_offset) - sec -> vma;
|
||||
}
|
||||
RTYPE2HOWTO (&genrel, rel);
|
||||
return genrel.howto;
|
||||
}
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) TIC80BADMAG(x)
|
||||
#endif
|
||||
|
||||
#define coff_relocate_section coff_tic80_relocate_section
|
||||
|
||||
/* We need a special relocation routine to handle the PP relocs. Most
|
||||
of this is a copy of _bfd_coff_generic_relocate_section. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_tic80_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_vma addr;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
/* COFF treats common symbols in one of two ways. Either the
|
||||
size of the symbol is included in the section contents, or it
|
||||
is not. We assume that the size is not included, and force
|
||||
the rtype_to_howto function to adjust the addend as needed. */
|
||||
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
addend = - sym->n_value;
|
||||
else
|
||||
addend = 0;
|
||||
|
||||
howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
|
||||
sym, &addend);
|
||||
if (howto == NULL)
|
||||
return FALSE;
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
sec = bfd_abs_section_ptr;
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value);
|
||||
if (! obj_pe (output_bfd))
|
||||
val -= sec->vma;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
|
||||
else if (! info->relocatable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma, TRUE)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
addr = rel->r_vaddr - input_section->vma;
|
||||
|
||||
/* FIXME: This code assumes little endian, but the PP can
|
||||
apparently be bi-endian. I don't know if the bi-endianness
|
||||
applies to the instruction set or just to the data. */
|
||||
switch (howto->type)
|
||||
{
|
||||
default:
|
||||
case R_ABS:
|
||||
case R_RELLONGX:
|
||||
case R_PPL15:
|
||||
case R_PPL15W:
|
||||
case R_PPL15H:
|
||||
case R_PPLN15:
|
||||
case R_PPLN15W:
|
||||
case R_PPLN15H:
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents, addr, val, addend);
|
||||
break;
|
||||
|
||||
case R_PP15:
|
||||
case R_PP15W:
|
||||
case R_PP15H:
|
||||
case R_PPN15:
|
||||
case R_PPN15W:
|
||||
case R_PPN15H:
|
||||
/* Offset the address so that we can use 4 byte relocations. */
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents + 2, addr, val, addend);
|
||||
break;
|
||||
|
||||
case R_PP16B:
|
||||
case R_PPN16B:
|
||||
{
|
||||
/* The most significant bit is stored in bit 6. */
|
||||
bfd_byte hold;
|
||||
|
||||
hold = contents[addr + 4];
|
||||
contents[addr + 4] &=~ 0x20;
|
||||
contents[addr + 4] |= (contents[addr] >> 1) & 0x20;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents + 2, addr,
|
||||
val, addend);
|
||||
contents[addr] &=~ 0x40;
|
||||
contents[addr] |= (contents[addr + 4] << 1) & 0x40;
|
||||
contents[addr + 4] &=~ 0x20;
|
||||
contents[addr + 4] |= hold & 0x20;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_PPL16B:
|
||||
case R_PPLN16B:
|
||||
{
|
||||
/* The most significant bit is stored in bit 28. */
|
||||
bfd_byte hold;
|
||||
|
||||
hold = contents[addr + 1];
|
||||
contents[addr + 1] &=~ 0x80;
|
||||
contents[addr + 1] |= (contents[addr + 3] << 3) & 0x80;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents, addr,
|
||||
val, addend);
|
||||
contents[addr + 3] &= ~0x10;
|
||||
contents[addr + 3] |= (contents[addr + 1] >> 3) & 0x10;
|
||||
contents[addr + 1] &=~ 0x80;
|
||||
contents[addr + 1] |= hold & 0x80;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_PPBASE:
|
||||
/* Parameter RAM is from 0x1000000 to 0x1000800. */
|
||||
contents[addr] &=~ 0x3;
|
||||
if (val >= 0x1000000 && val < 0x1000800)
|
||||
contents[addr] |= 0x3;
|
||||
else
|
||||
contents[addr] |= 0x2;
|
||||
rstat = bfd_reloc_ok;
|
||||
break;
|
||||
|
||||
case R_PPLBASE:
|
||||
/* Parameter RAM is from 0x1000000 to 0x1000800. */
|
||||
contents[addr + 2] &= ~0xc0;
|
||||
if (val >= 0x1000000 && val < 0x1000800)
|
||||
contents[addr + 2] |= 0xc0;
|
||||
else
|
||||
contents[addr + 2] |= 0x80;
|
||||
rstat = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
case bfd_reloc_outofrange:
|
||||
(*_bfd_error_handler)
|
||||
(_("%B: bad reloc address 0x%lx in section `%A'"),
|
||||
input_bfd, input_section, (unsigned long) rel->r_vaddr);
|
||||
return FALSE;
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = NULL;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, (h ? &h->root : NULL), name, howto->name,
|
||||
(bfd_vma) 0, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Clear the r_reserved field in relocs. */
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||
do \
|
||||
{ \
|
||||
dst->r_reserved[0] = 0; \
|
||||
dst->r_reserved[1] = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define TIC80COFF 1 /* Customize coffcode.h */
|
||||
#undef C_AUTOARG /* Clashes with TIc80's C_UEXT */
|
||||
#undef C_LASTENT /* Clashes with TIc80's C_STATLAB */
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (tic80coff_vec, "coff-tic80", D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|
36
external/gpl3/binutils/dist/bfd/coff-u68k.c
vendored
Normal file
36
external/gpl3/binutils/dist/bfd/coff-u68k.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
|
||||
Copyright 1990, 1991, 1992, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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"
|
390
external/gpl3/binutils/dist/bfd/coff-w65.c
vendored
Normal file
390
external/gpl3/binutils/dist/bfd/coff-w65.c
vendored
Normal file
@ -0,0 +1,390 @@
|
||||
/* BFD back-end for WDC 65816 COFF binaries.
|
||||
Copyright 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/w65.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static int select_reloc PARAMS ((reloc_howto_type *));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
static int w65_reloc16_estimate PARAMS ((bfd *, asection *, arelent *, unsigned int, struct bfd_link_info *));
|
||||
static void w65_reloc16_extra_cases PARAMS ((bfd *,struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
|
||||
|
||||
#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 H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET 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 necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#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_section_ptr->symbol_ptr_ptr;
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
static int
|
||||
w65_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_MOV16B2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte. */
|
||||
case R_MOV16B1:
|
||||
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_MOV16B1 R_MOV16B2 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_MOV24B1 R_MOV24B2 24 or 8 bit reloc for mov.b */
|
||||
|
||||
static void
|
||||
w65_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, (bfd_vma) 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, (bfd_vma) 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, (bfd_vma) 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, (bfd_vma) 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 = (dst_address
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
|
||||
gap -= dot + 1;
|
||||
if (gap < -128 || gap > 127)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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 = (dst_address
|
||||
+ input_section->output_offset
|
||||
+ input_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, NULL,
|
||||
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 w65_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate w65_reloc16_estimate
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (w65_vec, "coff-w65", BFD_IS_RELAXABLE, 0, '_', NULL, COFF_SWAP_TABLE)
|
74
external/gpl3/binutils/dist/bfd/coff-we32k.c
vendored
Normal file
74
external/gpl3/binutils/dist/bfd/coff-we32k.c
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/* BFD back-end for we32k COFF files.
|
||||
Copyright 1992, 1993, 1994, 1999, 2000, 2002, 2003, 2007, 2008
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.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[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
EMPTY_HOWTO (1),
|
||||
EMPTY_HOWTO (2),
|
||||
EMPTY_HOWTO (3),
|
||||
EMPTY_HOWTO (4),
|
||||
EMPTY_HOWTO (5),
|
||||
HOWTO(R_DIR32, 0, 2, 32, FALSE, 0,complain_overflow_bitfield, 0, "dir32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
EMPTY_HOWTO (7),
|
||||
EMPTY_HOWTO (010),
|
||||
EMPTY_HOWTO (011),
|
||||
EMPTY_HOWTO (012),
|
||||
EMPTY_HOWTO (013),
|
||||
EMPTY_HOWTO (014),
|
||||
EMPTY_HOWTO (015),
|
||||
EMPTY_HOWTO (016),
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "8", TRUE, 0x000000ff,0x000000ff, FALSE),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "32", TRUE, 0xffffffff,0xffffffff, FALSE),
|
||||
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;
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#define coff_write_armap bsd_write_armap
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (we32kcoff_vec, "coff-we32k", 0, 0, 0, NULL, COFF_SWAP_TABLE)
|
788
external/gpl3/binutils/dist/bfd/coff-x86_64.c
vendored
Normal file
788
external/gpl3/binutils/dist/bfd/coff-x86_64.c
vendored
Normal file
@ -0,0 +1,788 @@
|
||||
/* BFD back-end for AMD 64 COFF files.
|
||||
Copyright 2006, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
Written by Kai Tietz, OneVision Software GmbH&CoKg. */
|
||||
|
||||
#ifndef COFF_WITH_pex64
|
||||
#define COFF_WITH_pex64
|
||||
#endif
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "coff/x86_64.h"
|
||||
#include "coff/internal.h"
|
||||
#include "coff/pe.h"
|
||||
#include "libcoff.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#define BADMAG(x) AMD64BADMAG(x)
|
||||
|
||||
#ifdef COFF_WITH_pex64
|
||||
# undef AOUTSZ
|
||||
# define AOUTSZ PEPAOUTSZ
|
||||
# define PEAOUTHDR PEPAOUTHDR
|
||||
#endif
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using AMD 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 relocatable 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_amd64_reloc (bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
asymbol *symbol,
|
||||
void * data,
|
||||
asection *input_section ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
#if !defined(COFF_WITH_PE)
|
||||
if (output_bfd == NULL)
|
||||
return bfd_reloc_continue;
|
||||
#endif
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
#if !defined(COFF_WITH_PE)
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
#else
|
||||
/* In PE mode, we do not offset the common symbol. */
|
||||
diff = reloc_entry->addend;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocatable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
#if defined(COFF_WITH_PE)
|
||||
if (output_bfd == NULL)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
/* Although PC relative relocations are very similar between
|
||||
PE and non-PE formats, but they are off by 1 << howto->size
|
||||
bytes. For the external relocation, PE is very different
|
||||
from others. See md_apply_fix3 () in gas/config/tc-amd64.c.
|
||||
When we link PE and non-PE object files together to
|
||||
generate a non-PE executable, we have to compensate it
|
||||
here. */
|
||||
if(howto->pc_relative && howto->pcrel_offset)
|
||||
diff = -(1 << howto->size);
|
||||
else if(symbol->flags & BSF_WEAK)
|
||||
diff = reloc_entry->addend - symbol->value;
|
||||
else
|
||||
diff = -reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#if defined(COFF_WITH_PE)
|
||||
/* FIXME: How should this case be handled? */
|
||||
if (reloc_entry->howto->type == R_AMD64_IMAGEBASE
|
||||
&& output_bfd != NULL
|
||||
&& bfd_get_flavour (output_bfd) == bfd_target_coff_flavour)
|
||||
diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
|
||||
#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, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
long long x = bfd_get_64 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_64 (abfd, (bfd_vma) x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#if defined(COFF_WITH_PE)
|
||||
/* Return TRUE if this relocation should appear in the output .reloc
|
||||
section. */
|
||||
|
||||
static bfd_boolean
|
||||
in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED, reloc_howto_type *howto)
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != R_AMD64_IMAGEBASE;
|
||||
}
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET TRUE
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
EMPTY_HOWTO (0),
|
||||
HOWTO (R_AMD64_DIR64, /* type 1*/
|
||||
0, /* rightshift */
|
||||
4, /* size (0 = byte, 1 = short, 2 = long, 4 = long long) */
|
||||
64, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"R_X86_64_64", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffffffffffffll, /* src_mask */
|
||||
0xffffffffffffffffll, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
HOWTO (R_AMD64_DIR32, /* type 2 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"R_X86_64_32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
/* PE IMAGE_REL_AMD64_ADDR32NB relocation (3). */
|
||||
HOWTO (R_AMD64_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_amd64_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
/* 32-bit longword PC relative relocation (4). */
|
||||
HOWTO (R_AMD64_PCRLONG, /* type 4 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"R_X86_64_PC32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_AMD64_PCRLONG_1, /* type 5 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"DISP32+1", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_AMD64_PCRLONG_2, /* type 6 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"DISP32+2", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_AMD64_PCRLONG_3, /* type 7 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"DISP32+3", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_AMD64_PCRLONG_4, /* type 8 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"DISP32+4", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_AMD64_PCRLONG_5, /* type 9 */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"DISP32+5", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
EMPTY_HOWTO (10), /* R_AMD64_SECTION 10 */
|
||||
#if defined(COFF_WITH_PE)
|
||||
/* 32-bit longword section relative relocation (11). */
|
||||
HOWTO (R_AMD64_SECREL, /* 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_amd64_reloc, /* special_function */
|
||||
"secrel32", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
TRUE), /* pcrel_offset */
|
||||
#else
|
||||
EMPTY_HOWTO (11),
|
||||
#endif
|
||||
EMPTY_HOWTO (12),
|
||||
EMPTY_HOWTO (13),
|
||||
#ifndef DONT_EXTEND_AMD64
|
||||
HOWTO (R_AMD64_PCRQUAD,
|
||||
0, /* rightshift */
|
||||
4, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
64, /* bitsize */
|
||||
TRUE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_amd64_reloc, /* special_function */
|
||||
"R_X86_64_PC64", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffffffffffffll, /* src_mask */
|
||||
0xffffffffffffffffll, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
#else
|
||||
EMPTY_HOWTO (14),
|
||||
#endif
|
||||
/* Byte relocation (15). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word relocation (16). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword relocation (17). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_32S", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* Byte PC relative relocation (18). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_PC8", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 16-bit word PC relative relocation (19). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_PC16", /* name */
|
||||
TRUE, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
/* 32-bit longword PC relative relocation (20). */
|
||||
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_amd64_reloc, /* special_function */
|
||||
"R_X86_64_PC32", /* 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 I386 1 /* Customize coffcode.h */
|
||||
#define AMD64 1
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
((cache_ptr)->howto = \
|
||||
((dst)->r_type < ARRAY_SIZE (howto_table)) \
|
||||
? howto_table + (dst)->r_type \
|
||||
: NULL)
|
||||
|
||||
/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
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 = 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 != 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 != 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. For normal AMD64 COFF, we
|
||||
can use the generic relocate_section routine. For PE, we need our
|
||||
own routine. */
|
||||
|
||||
#if !defined(COFF_WITH_PE)
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#else /* COFF_WITH_PE */
|
||||
|
||||
/* The PE relocate section routine. The only difference between this
|
||||
and the regular routine is that we don't want to do anything for a
|
||||
relocatable link. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_pe_amd64_relocate_section (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)
|
||||
{
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,input_section, contents,relocs, syms, sections);
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_pe_amd64_relocate_section
|
||||
|
||||
#endif /* COFF_WITH_PE */
|
||||
|
||||
/* Convert an rtype to howto for the COFF backend linker. */
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_amd64_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
asection *sec,
|
||||
struct internal_reloc *rel,
|
||||
struct coff_link_hash_entry *h,
|
||||
struct internal_syment *sym,
|
||||
bfd_vma *addendp)
|
||||
{
|
||||
reloc_howto_type *howto;
|
||||
|
||||
if (rel->r_type > ARRAY_SIZE (howto_table))
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
if (rel->r_type >= R_AMD64_PCRLONG_1 && rel->r_type <= R_AMD64_PCRLONG_5)
|
||||
{
|
||||
rel->r_vaddr += (bfd_vma)(rel->r_type-R_AMD64_PCRLONG);
|
||||
rel->r_type = R_AMD64_PCRLONG;
|
||||
}
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
#if defined(COFF_WITH_PE)
|
||||
/* Cancel out code in _bfd_coff_generic_relocate_section. */
|
||||
*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);
|
||||
|
||||
#if !defined(COFF_WITH_PE)
|
||||
/* I think we *do* want to bypass this. If we don't, I have
|
||||
seen some data parameters get the wrong relocation address.
|
||||
If I link two versions with and without this section bypassed
|
||||
and then do a binary comparison, the addresses which are
|
||||
different can be looked up in the map. The case in which
|
||||
this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map. */
|
||||
*addendp -= sym->n_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(COFF_WITH_PE)
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocatable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
#endif
|
||||
|
||||
#if defined(COFF_WITH_PE)
|
||||
if (howto->pc_relative)
|
||||
{
|
||||
*addendp -= 4;
|
||||
|
||||
/* If the symbol is defined, then the generic code is going to
|
||||
add back the symbol value in order to cancel out an
|
||||
adjustment it made to the addend. However, we set the addend
|
||||
to 0 at the start of this function. We need to adjust here,
|
||||
to avoid the adjustment the generic code will make. FIXME:
|
||||
This is getting a bit hackish. */
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
if (rel->r_type == R_AMD64_IMAGEBASE
|
||||
&& (bfd_get_flavour (sec->output_section->owner) == bfd_target_coff_flavour))
|
||||
*addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
|
||||
if (rel->r_type == R_AMD64_SECREL)
|
||||
{
|
||||
bfd_vma osect_vma;
|
||||
|
||||
if (h && (h->type == bfd_link_hash_defined || h->type == bfd_link_hash_defweak))
|
||||
osect_vma = h->root.u.def.section->output_section->vma;
|
||||
else
|
||||
{
|
||||
asection *sec;
|
||||
int i;
|
||||
|
||||
/* Sigh, the only way to get the section to offset against
|
||||
is to find it the hard way. */
|
||||
for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
|
||||
sec = sec->next;
|
||||
|
||||
osect_vma = sec->output_section->vma;
|
||||
}
|
||||
|
||||
*addendp -= osect_vma;
|
||||
}
|
||||
#endif
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_amd64_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup coff_amd64_reloc_name_lookup
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_amd64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_RVA:
|
||||
return howto_table + R_AMD64_IMAGEBASE;
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + R_AMD64_DIR32;
|
||||
case BFD_RELOC_64:
|
||||
return howto_table + R_AMD64_DIR64;
|
||||
case BFD_RELOC_64_PCREL:
|
||||
#ifndef DONT_EXTEND_AMD64
|
||||
return howto_table + R_AMD64_PCRQUAD;
|
||||
#else
|
||||
/* Fall through. */
|
||||
#endif
|
||||
case BFD_RELOC_32_PCREL:
|
||||
return howto_table + R_AMD64_PCRLONG;
|
||||
case BFD_RELOC_X86_64_32S:
|
||||
return howto_table + R_RELLONG;
|
||||
case BFD_RELOC_16:
|
||||
return howto_table + R_RELWORD;
|
||||
case BFD_RELOC_16_PCREL:
|
||||
return howto_table + R_PCRWORD;
|
||||
case BFD_RELOC_8:
|
||||
return howto_table + R_RELBYTE;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return howto_table + R_PCRBYTE;
|
||||
#if defined(COFF_WITH_PE)
|
||||
case BFD_RELOC_32_SECREL:
|
||||
return howto_table + R_AMD64_SECREL;
|
||||
#endif
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_amd64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
|
||||
if (howto_table[i].name != NULL
|
||||
&& strcasecmp (howto_table[i].name, r_name) == 0)
|
||||
return &howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_amd64_rtype_to_howto
|
||||
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
|
||||
/* If amd64 gcc uses underscores for symbol names, then it does not use
|
||||
a leading dot for local labels, so if TARGET_UNDERSCORE is defined
|
||||
we treat all symbols starting with L as local. */
|
||||
|
||||
static bfd_boolean
|
||||
coff_amd64_is_local_label_name (bfd *abfd, const char *name)
|
||||
{
|
||||
if (name[0] == 'L')
|
||||
return TRUE;
|
||||
|
||||
return _bfd_coff_is_local_label_name (abfd, name);
|
||||
}
|
||||
|
||||
#define coff_bfd_is_local_label_name coff_amd64_is_local_label_name
|
||||
|
||||
#endif /* TARGET_UNDERSCORE */
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifdef PE
|
||||
#define amd64coff_object_p pe_bfd_object_p
|
||||
#else
|
||||
#define amd64coff_object_p coff_object_p
|
||||
#endif
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
x86_64coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-x86-64", /* 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. */
|
||||
#if defined(COFF_WITH_PE)
|
||||
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY
|
||||
#endif
|
||||
| SEC_CODE | SEC_DATA),
|
||||
|
||||
#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, amd64coff_object_p, /* BFD_check_format. */
|
||||
bfd_generic_archive_p, amd64coff_object_p },
|
||||
{ bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format. */
|
||||
bfd_false },
|
||||
{ bfd_false, coff_write_object_contents, /* bfd_write_contents. */
|
||||
_bfd_write_archive_contents, bfd_false },
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
288
external/gpl3/binutils/dist/bfd/coff-z80.c
vendored
Normal file
288
external/gpl3/binutils/dist/bfd/coff-z80.c
vendored
Normal file
@ -0,0 +1,288 @@
|
||||
/* BFD back-end for Zilog Z80 COFF binaries.
|
||||
Copyright 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||
Contributed by Arnold Metselaar <arnold_m@operamail.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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/z80.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 0
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_IMM32, 0, 1, 32, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_imm32", TRUE, 0xffffffff, 0xffffffff,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_imm24 =
|
||||
HOWTO (R_IMM24, 0, 1, 24, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_imm24", TRUE, 0x00ffffff, 0x00ffffff,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_imm16 =
|
||||
HOWTO (R_IMM16, 0, 1, 16, FALSE, 0,
|
||||
complain_overflow_dont, 0, "r_imm16", TRUE, 0x0000ffff, 0x0000ffff,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_IMM8, 0, 0, 8, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", TRUE, 0x000000ff, 0x000000ff,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_jr =
|
||||
HOWTO (R_JR, 0, 0, 8, TRUE, 0,
|
||||
complain_overflow_signed, 0, "r_jr", FALSE, 0, 0xFF,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_off8 =
|
||||
HOWTO (R_OFF8, 0, 0, 8, FALSE, 0,
|
||||
complain_overflow_signed, 0,"r_off8", FALSE, 0, 0xff,
|
||||
FALSE);
|
||||
|
||||
|
||||
#define BADMAG(x) Z80BADMAG(x)
|
||||
#define Z80 1 /* Customize coffcode.h. */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc. */
|
||||
|
||||
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET 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 (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_imm16;
|
||||
break;
|
||||
case R_IMM24:
|
||||
internal->howto = &r_imm24;
|
||||
break;
|
||||
case R_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_JR:
|
||||
internal->howto = &r_jr;
|
||||
break;
|
||||
case R_OFF8:
|
||||
internal->howto = &r_off8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_z80_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_8: return & r_imm8;
|
||||
case BFD_RELOC_16: return & r_imm16;
|
||||
case BFD_RELOC_24: return & r_imm24;
|
||||
case BFD_RELOC_32: return & r_imm32;
|
||||
case BFD_RELOC_8_PCREL: return & r_jr;
|
||||
case BFD_RELOC_Z80_DISP8: return & r_off8;
|
||||
default: BFD_FAIL ();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_z80_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
if (strcasecmp (r_imm8.name, r_name) == 0)
|
||||
return &r_imm8;
|
||||
if (strcasecmp (r_imm16.name, r_name) == 0)
|
||||
return &r_imm16;
|
||||
if (strcasecmp (r_imm24.name, r_name) == 0)
|
||||
return &r_imm24;
|
||||
if (strcasecmp (r_imm32.name, r_name) == 0)
|
||||
return &r_imm32;
|
||||
if (strcasecmp (r_jr.name, r_name) == 0)
|
||||
return &r_jr;
|
||||
if (strcasecmp (r_off8.name, r_name) == 0)
|
||||
return &r_off8;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (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 (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;
|
||||
int val;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_OFF8:
|
||||
val = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
if (val>127 || val<-128) /* Test for overflow. */
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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, val, data + *dst_ptr);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_IMM8:
|
||||
val = bfd_get_8 ( in_abfd, data+*src_ptr)
|
||||
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
bfd_put_8 (in_abfd, val, data + *dst_ptr);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_IMM16:
|
||||
val = bfd_get_16 ( in_abfd, data+*src_ptr)
|
||||
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
bfd_put_16 (in_abfd, val, data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_IMM24:
|
||||
val = bfd_get_16 ( in_abfd, data+*src_ptr)
|
||||
+ (bfd_get_8 ( in_abfd, data+*src_ptr+2) << 16)
|
||||
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
bfd_put_16 (in_abfd, val, data + *dst_ptr);
|
||||
bfd_put_8 (in_abfd, val >> 16, data + *dst_ptr+2);
|
||||
(*dst_ptr) += 3;
|
||||
(*src_ptr) += 3;
|
||||
break;
|
||||
|
||||
case R_IMM32:
|
||||
val = bfd_get_32 ( in_abfd, data+*src_ptr)
|
||||
+ bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
bfd_put_32 (in_abfd, val, data + *dst_ptr);
|
||||
(*dst_ptr) += 4;
|
||||
(*src_ptr) += 4;
|
||||
break;
|
||||
|
||||
case R_JR:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1; /* -1, Since the offset is relative
|
||||
to the value of PC after reading
|
||||
the offset. */
|
||||
|
||||
if (gap >= 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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
|
||||
#define coff_bfd_reloc_type_lookup coff_z80_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup coff_z80_reloc_name_lookup
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
CREATE_LITTLE_COFF_TARGET_VEC (z80coff_vec, "coff-z80", 0, 0, '\0', NULL,
|
||||
COFF_SWAP_TABLE)
|
||||
|
388
external/gpl3/binutils/dist/bfd/coff-z8k.c
vendored
Normal file
388
external/gpl3/binutils/dist/bfd/coff-z8k.c
vendored
Normal file
@ -0,0 +1,388 @@
|
||||
/* BFD back-end for Zilog Z800n COFF binaries.
|
||||
Copyright 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2007, 2008 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.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, 2, 32, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", TRUE, 0xffffffff,
|
||||
0xffffffff, FALSE);
|
||||
|
||||
static reloc_howto_type r_imm4l =
|
||||
HOWTO (R_IMM4L, 0, 0, 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, 0, 8, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", TRUE, 0x000000ff, 0x000000ff,
|
||||
FALSE);
|
||||
|
||||
static reloc_howto_type r_rel16 =
|
||||
HOWTO (R_REL16, 0, 1, 16, FALSE, 0,
|
||||
complain_overflow_bitfield, 0, "r_rel16", TRUE, 0x0000ffff, 0x0000ffff,
|
||||
TRUE);
|
||||
|
||||
static reloc_howto_type r_jr =
|
||||
HOWTO (R_JR, 1, 0, 8, TRUE, 0, complain_overflow_signed, 0,
|
||||
"r_jr", TRUE, 0xff, 0xff, TRUE);
|
||||
|
||||
static reloc_howto_type r_disp7 =
|
||||
HOWTO (R_DISP7, 0, 0, 7, TRUE, 0, complain_overflow_bitfield, 0,
|
||||
"r_disp7", TRUE, 0x7f, 0x7f, TRUE);
|
||||
|
||||
static reloc_howto_type r_callr =
|
||||
HOWTO (R_CALLR, 1, 1, 12, TRUE, 0, complain_overflow_signed, 0,
|
||||
"r_callr", TRUE, 0xfff, 0xfff, TRUE);
|
||||
|
||||
#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 H_GET_32
|
||||
#define SWAP_OUT_RELOC_OFFSET 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 (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_DISP7:
|
||||
internal->howto = &r_disp7;
|
||||
break;
|
||||
case R_CALLR:
|
||||
internal->howto = &r_callr;
|
||||
break;
|
||||
case R_REL16:
|
||||
internal->howto = &r_rel16;
|
||||
break;
|
||||
case R_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_IMM4L:
|
||||
internal->howto = &r_imm4l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_z8k_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_8: return & r_imm8;
|
||||
case BFD_RELOC_16: return & r_da;
|
||||
case BFD_RELOC_32: return & r_imm32;
|
||||
case BFD_RELOC_8_PCREL: return & r_jr;
|
||||
case BFD_RELOC_16_PCREL: return & r_rel16;
|
||||
case BFD_RELOC_Z8K_DISP7: return & r_disp7;
|
||||
case BFD_RELOC_Z8K_CALLR: return & r_callr;
|
||||
case BFD_RELOC_Z8K_IMM4L: return & r_imm4l;
|
||||
default: BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_z8k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
const char *r_name)
|
||||
{
|
||||
if (strcasecmp (r_imm8.name, r_name) == 0)
|
||||
return &r_imm8;
|
||||
if (strcasecmp (r_da.name, r_name) == 0)
|
||||
return &r_da;
|
||||
if (strcasecmp (r_imm32.name, r_name) == 0)
|
||||
return &r_imm32;
|
||||
if (strcasecmp (r_jr.name, r_name) == 0)
|
||||
return &r_jr;
|
||||
if (strcasecmp (r_rel16.name, r_name) == 0)
|
||||
return &r_rel16;
|
||||
if (strcasecmp (r_disp7.name, r_name) == 0)
|
||||
return &r_disp7;
|
||||
if (strcasecmp (r_callr.name, r_name) == 0)
|
||||
return &r_callr;
|
||||
if (strcasecmp (r_imm4l.name, r_name) == 0)
|
||||
return &r_imm4l;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Perform any necessary magic to the addend in a reloc entry. */
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (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 (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:
|
||||
/* If no flags are set, assume immediate value. */
|
||||
if (! (*reloc->sym_ptr_ptr)->section->flags)
|
||||
{
|
||||
bfd_put_32 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section),
|
||||
data + *dst_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
/* Addresses are 23 bit, and the layout of those in a 32-bit
|
||||
value is as follows:
|
||||
1AAAAAAA xxxxxxxx AAAAAAAA AAAAAAAA
|
||||
(A - address bits, x - ignore). */
|
||||
dst = (dst & 0xffff) | ((dst & 0xff0000) << 8) | 0x80000000;
|
||||
bfd_put_32 (in_abfd, dst, 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 = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1; /* -1, since we're 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, NULL,
|
||||
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_DISP7:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1; /* -1, since we're in the odd byte of the
|
||||
word and the pc's been incremented. */
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
gap /= 2;
|
||||
|
||||
if (gap > 0 || gap < -127)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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,
|
||||
(bfd_get_8 ( in_abfd, data + *dst_ptr) & 0x80) + (-gap & 0x7f),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_CALLR:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 2;
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
if (gap > 4096 || gap < -4095)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
gap /= 2;
|
||||
bfd_put_16 (in_abfd,
|
||||
(bfd_get_16 ( in_abfd, data + *dst_ptr) & 0xf000) | (-gap & 0x0fff),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
case R_REL16:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (*dst_ptr
|
||||
+ input_section->output_offset
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 2;
|
||||
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, NULL,
|
||||
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, (bfd_vma) gap, data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
#define coff_bfd_reloc_type_lookup coff_z8k_reloc_type_lookup
|
||||
#define coff_bfd_reloc_name_lookup coff_z8k_reloc_name_lookup
|
||||
|
||||
#ifndef bfd_pe_print_pdata
|
||||
#define bfd_pe_print_pdata NULL
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE)
|
3037
external/gpl3/binutils/dist/bfd/coff64-rs6000.c
vendored
Normal file
3037
external/gpl3/binutils/dist/bfd/coff64-rs6000.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5610
external/gpl3/binutils/dist/bfd/coffcode.h
vendored
Normal file
5610
external/gpl3/binutils/dist/bfd/coffcode.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2343
external/gpl3/binutils/dist/bfd/coffgen.c
vendored
Normal file
2343
external/gpl3/binutils/dist/bfd/coffgen.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3046
external/gpl3/binutils/dist/bfd/cofflink.c
vendored
Normal file
3046
external/gpl3/binutils/dist/bfd/cofflink.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
840
external/gpl3/binutils/dist/bfd/coffswap.h
vendored
Normal file
840
external/gpl3/binutils/dist/bfd/coffswap.h
vendored
Normal file
@ -0,0 +1,840 @@
|
||||
/* Generic COFF swapping routines, for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
|
||||
2001, 2002, 2005, 2007
|
||||
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, 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 GET_FCN_LNNOPTR
|
||||
#define GET_FCN_LNNOPTR(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
||||
#endif
|
||||
|
||||
#ifndef GET_FCN_ENDNDX
|
||||
#define GET_FCN_ENDNDX(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
||||
#endif
|
||||
|
||||
#ifndef PUT_FCN_LNNOPTR
|
||||
#define PUT_FCN_LNNOPTR(abfd, in, ext) \
|
||||
H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
||||
#endif
|
||||
#ifndef PUT_FCN_ENDNDX
|
||||
#define PUT_FCN_ENDNDX(abfd, in, ext) \
|
||||
H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
||||
#endif
|
||||
#ifndef GET_LNSZ_LNNO
|
||||
#define GET_LNSZ_LNNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno)
|
||||
#endif
|
||||
#ifndef GET_LNSZ_SIZE
|
||||
#define GET_LNSZ_SIZE(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size)
|
||||
#endif
|
||||
#ifndef PUT_LNSZ_LNNO
|
||||
#define PUT_LNSZ_LNNO(abfd, in, ext) \
|
||||
H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_lnno)
|
||||
#endif
|
||||
#ifndef PUT_LNSZ_SIZE
|
||||
#define PUT_LNSZ_SIZE(abfd, in, ext) \
|
||||
H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_size)
|
||||
#endif
|
||||
#ifndef GET_SCN_SCNLEN
|
||||
#define GET_SCN_SCNLEN(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_scn.x_scnlen)
|
||||
#endif
|
||||
#ifndef GET_SCN_NRELOC
|
||||
#define GET_SCN_NRELOC(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_scn.x_nreloc)
|
||||
#endif
|
||||
#ifndef GET_SCN_NLINNO
|
||||
#define GET_SCN_NLINNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_scn.x_nlinno)
|
||||
#endif
|
||||
#ifndef PUT_SCN_SCNLEN
|
||||
#define PUT_SCN_SCNLEN(abfd, in, ext) \
|
||||
H_PUT_32 (abfd, in, ext->x_scn.x_scnlen)
|
||||
#endif
|
||||
#ifndef PUT_SCN_NRELOC
|
||||
#define PUT_SCN_NRELOC(abfd, in, ext) \
|
||||
H_PUT_16 (abfd, in, ext->x_scn.x_nreloc)
|
||||
#endif
|
||||
#ifndef PUT_SCN_NLINNO
|
||||
#define PUT_SCN_NLINNO(abfd, in, ext) \
|
||||
H_PUT_16 (abfd, in, ext->x_scn.x_nlinno)
|
||||
#endif
|
||||
#ifndef GET_LINENO_LNNO
|
||||
#define GET_LINENO_LNNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->l_lnno);
|
||||
#endif
|
||||
#ifndef PUT_LINENO_LNNO
|
||||
#define PUT_LINENO_LNNO(abfd, val, ext) \
|
||||
H_PUT_16 (abfd, val, ext->l_lnno);
|
||||
#endif
|
||||
|
||||
/* The f_symptr field in the filehdr is sometimes 64 bits. */
|
||||
#ifndef GET_FILEHDR_SYMPTR
|
||||
#define GET_FILEHDR_SYMPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_FILEHDR_SYMPTR
|
||||
#define PUT_FILEHDR_SYMPTR H_PUT_32
|
||||
#endif
|
||||
|
||||
/* Some fields in the aouthdr are sometimes 64 bits. */
|
||||
#ifndef GET_AOUTHDR_TSIZE
|
||||
#define GET_AOUTHDR_TSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_TSIZE
|
||||
#define PUT_AOUTHDR_TSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_DSIZE
|
||||
#define GET_AOUTHDR_DSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_DSIZE
|
||||
#define PUT_AOUTHDR_DSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_BSIZE
|
||||
#define GET_AOUTHDR_BSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_BSIZE
|
||||
#define PUT_AOUTHDR_BSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_ENTRY
|
||||
#define GET_AOUTHDR_ENTRY H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_ENTRY
|
||||
#define PUT_AOUTHDR_ENTRY H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_TEXT_START
|
||||
#define GET_AOUTHDR_TEXT_START H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_TEXT_START
|
||||
#define PUT_AOUTHDR_TEXT_START H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_DATA_START
|
||||
#define GET_AOUTHDR_DATA_START H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_DATA_START
|
||||
#define PUT_AOUTHDR_DATA_START H_PUT_32
|
||||
#endif
|
||||
|
||||
/* Some fields in the scnhdr are sometimes 64 bits. */
|
||||
#ifndef GET_SCNHDR_PADDR
|
||||
#define GET_SCNHDR_PADDR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_PADDR
|
||||
#define PUT_SCNHDR_PADDR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_VADDR
|
||||
#define GET_SCNHDR_VADDR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_VADDR
|
||||
#define PUT_SCNHDR_VADDR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_SIZE
|
||||
#define GET_SCNHDR_SIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_SIZE
|
||||
#define PUT_SCNHDR_SIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_SCNPTR
|
||||
#define GET_SCNHDR_SCNPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_SCNPTR
|
||||
#define PUT_SCNHDR_SCNPTR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_RELPTR
|
||||
#define GET_SCNHDR_RELPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_RELPTR
|
||||
#define PUT_SCNHDR_RELPTR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_LNNOPTR
|
||||
#define GET_SCNHDR_LNNOPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_LNNOPTR
|
||||
#define PUT_SCNHDR_LNNOPTR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_NRELOC
|
||||
#define GET_SCNHDR_NRELOC H_GET_16
|
||||
#endif
|
||||
#ifndef MAX_SCNHDR_NRELOC
|
||||
#define MAX_SCNHDR_NRELOC 0xffff
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_NRELOC
|
||||
#define PUT_SCNHDR_NRELOC H_PUT_16
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_NLNNO
|
||||
#define GET_SCNHDR_NLNNO H_GET_16
|
||||
#endif
|
||||
#ifndef MAX_SCNHDR_NLNNO
|
||||
#define MAX_SCNHDR_NLNNO 0xffff
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_NLNNO
|
||||
#define PUT_SCNHDR_NLNNO H_PUT_16
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_FLAGS
|
||||
#define GET_SCNHDR_FLAGS H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_FLAGS
|
||||
#define PUT_SCNHDR_FLAGS H_PUT_32
|
||||
#endif
|
||||
|
||||
#ifndef GET_RELOC_VADDR
|
||||
#define GET_RELOC_VADDR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_RELOC_VADDR
|
||||
#define PUT_RELOC_VADDR H_PUT_32
|
||||
#endif
|
||||
|
||||
#ifndef NO_COFF_RELOCS
|
||||
|
||||
static void
|
||||
coff_swap_reloc_in (bfd * abfd, void * src, void * dst)
|
||||
{
|
||||
RELOC *reloc_src = (RELOC *) src;
|
||||
struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
|
||||
|
||||
reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, reloc_src->r_vaddr);
|
||||
reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
|
||||
reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
|
||||
|
||||
#ifdef SWAP_IN_RELOC_OFFSET
|
||||
reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_reloc_out (bfd * abfd, void * src, void * dst)
|
||||
{
|
||||
struct internal_reloc *reloc_src = (struct internal_reloc *) src;
|
||||
struct external_reloc *reloc_dst = (struct external_reloc *) dst;
|
||||
|
||||
PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
|
||||
H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
|
||||
H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
|
||||
|
||||
#ifdef SWAP_OUT_RELOC_OFFSET
|
||||
SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
|
||||
#endif
|
||||
#ifdef SWAP_OUT_RELOC_EXTRA
|
||||
SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst);
|
||||
#endif
|
||||
|
||||
return bfd_coff_relsz (abfd);
|
||||
}
|
||||
|
||||
#endif /* NO_COFF_RELOCS */
|
||||
|
||||
static void
|
||||
coff_swap_filehdr_in (bfd * abfd, void * src, void * dst)
|
||||
{
|
||||
FILHDR *filehdr_src = (FILHDR *) src;
|
||||
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
|
||||
|
||||
#ifdef COFF_ADJUST_FILEHDR_IN_PRE
|
||||
COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
|
||||
#endif
|
||||
filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic);
|
||||
filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns);
|
||||
filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat);
|
||||
filehdr_dst->f_symptr = GET_FILEHDR_SYMPTR (abfd, filehdr_src->f_symptr);
|
||||
filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms);
|
||||
filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src->f_opthdr);
|
||||
filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags);
|
||||
#ifdef TIC80_TARGET_ID
|
||||
filehdr_dst->f_target_id = H_GET_16 (abfd, filehdr_src->f_target_id);
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ADJUST_FILEHDR_IN_POST
|
||||
COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_filehdr_out (bfd *abfd, void * in, void * out)
|
||||
{
|
||||
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
|
||||
FILHDR *filehdr_out = (FILHDR *) out;
|
||||
|
||||
#ifdef COFF_ADJUST_FILEHDR_OUT_PRE
|
||||
COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
|
||||
#endif
|
||||
H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
|
||||
H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
|
||||
H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
|
||||
PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
|
||||
H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
|
||||
H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
|
||||
H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
|
||||
#ifdef TIC80_TARGET_ID
|
||||
H_PUT_16 (abfd, filehdr_in->f_target_id, filehdr_out->f_target_id);
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ADJUST_FILEHDR_OUT_POST
|
||||
COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
|
||||
#endif
|
||||
return bfd_coff_filhsz (abfd);
|
||||
}
|
||||
|
||||
#ifndef NO_COFF_SYMBOLS
|
||||
|
||||
static void
|
||||
coff_swap_sym_in (bfd * abfd, void * ext1, void * 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 = H_GET_32 (abfd, 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 = H_GET_32 (abfd, ext->e_value);
|
||||
in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
|
||||
if (sizeof (ext->e_type) == 2)
|
||||
in->n_type = H_GET_16 (abfd, ext->e_type);
|
||||
else
|
||||
in->n_type = H_GET_32 (abfd, ext->e_type);
|
||||
in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
|
||||
in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
|
||||
#ifdef COFF_ADJUST_SYM_IN_POST
|
||||
COFF_ADJUST_SYM_IN_POST (abfd, ext1, in1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_sym_out (bfd * abfd, void * inp, void * extp)
|
||||
{
|
||||
struct internal_syment *in = (struct internal_syment *) inp;
|
||||
SYMENT *ext =(SYMENT *) extp;
|
||||
|
||||
#ifdef COFF_ADJUST_SYM_OUT_PRE
|
||||
COFF_ADJUST_SYM_OUT_PRE (abfd, inp, extp);
|
||||
#endif
|
||||
|
||||
if (in->_n._n_name[0] == 0)
|
||||
{
|
||||
H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
|
||||
H_PUT_32 (abfd, in->_n._n_n._n_offset, 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
|
||||
}
|
||||
|
||||
H_PUT_32 (abfd, in->n_value, ext->e_value);
|
||||
H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
|
||||
|
||||
if (sizeof (ext->e_type) == 2)
|
||||
H_PUT_16 (abfd, in->n_type, ext->e_type);
|
||||
else
|
||||
H_PUT_32 (abfd, in->n_type, ext->e_type);
|
||||
|
||||
H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
|
||||
H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
|
||||
|
||||
#ifdef COFF_ADJUST_SYM_OUT_POST
|
||||
COFF_ADJUST_SYM_OUT_POST (abfd, inp, extp);
|
||||
#endif
|
||||
|
||||
return SYMESZ;
|
||||
}
|
||||
|
||||
static void
|
||||
coff_swap_aux_in (bfd *abfd,
|
||||
void * ext1,
|
||||
int type,
|
||||
int class,
|
||||
int indx,
|
||||
int numaux,
|
||||
void * in1)
|
||||
{
|
||||
AUXENT *ext = (AUXENT *) ext1;
|
||||
union internal_auxent *in = (union internal_auxent *) in1;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_IN_PRE
|
||||
COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
|
||||
#endif
|
||||
|
||||
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 = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FILNMLEN != E_FILNMLEN
|
||||
#error we need to cope with truncating or extending FILNMLEN
|
||||
#else
|
||||
if (numaux > 1)
|
||||
{
|
||||
if (indx == 0)
|
||||
memcpy (in->x_file.x_fname, ext->x_file.x_fname,
|
||||
numaux * sizeof (AUXENT));
|
||||
}
|
||||
else
|
||||
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
|
||||
#endif
|
||||
}
|
||||
goto end;
|
||||
|
||||
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);
|
||||
|
||||
/* PE defines some extra fields; we zero them out for
|
||||
safety. */
|
||||
in->x_scn.x_checksum = 0;
|
||||
in->x_scn.x_associated = 0;
|
||||
in->x_scn.x_comdat = 0;
|
||||
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
|
||||
#ifndef NO_TVNDX
|
||||
in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
|
||||
#endif
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
|
||||
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DIMNUM != E_DIMNUM
|
||||
#error we need to cope with truncating or extending DIMNUM
|
||||
#endif
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[0] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[1] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[2] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||
in->x_sym.x_fcnary.x_ary.x_dimen[3] =
|
||||
H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||
}
|
||||
|
||||
if (ISFCN (type))
|
||||
in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, 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);
|
||||
}
|
||||
|
||||
end: ;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_IN_POST
|
||||
COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_aux_out (bfd * abfd,
|
||||
void * inp,
|
||||
int type,
|
||||
int class,
|
||||
int indx ATTRIBUTE_UNUSED,
|
||||
int numaux ATTRIBUTE_UNUSED,
|
||||
void * extp)
|
||||
{
|
||||
union internal_auxent * in = (union internal_auxent *) inp;
|
||||
AUXENT *ext = (AUXENT *) extp;
|
||||
|
||||
#ifdef COFF_ADJUST_AUX_OUT_PRE
|
||||
COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
|
||||
#endif
|
||||
|
||||
memset (ext, 0, AUXESZ);
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_FILE:
|
||||
if (in->x_file.x_fname[0] == 0)
|
||||
{
|
||||
H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
|
||||
H_PUT_32 (abfd, in->x_file.x_n.x_offset, 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
|
||||
}
|
||||
goto end;
|
||||
|
||||
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);
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
|
||||
#ifndef NO_TVNDX
|
||||
H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
|
||||
#endif
|
||||
|
||||
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
|
||||
{
|
||||
PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
|
||||
PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DIMNUM != E_DIMNUM
|
||||
#error we need to cope with truncating or extending DIMNUM
|
||||
#endif
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||
H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
|
||||
ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||
}
|
||||
|
||||
if (ISFCN (type))
|
||||
H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, 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);
|
||||
}
|
||||
|
||||
end:
|
||||
#ifdef COFF_ADJUST_AUX_OUT_POST
|
||||
COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
|
||||
#endif
|
||||
return AUXESZ;
|
||||
}
|
||||
|
||||
#endif /* NO_COFF_SYMBOLS */
|
||||
|
||||
#ifndef NO_COFF_LINENOS
|
||||
|
||||
static void
|
||||
coff_swap_lineno_in (bfd * abfd, void * ext1, void * in1)
|
||||
{
|
||||
LINENO *ext = (LINENO *) ext1;
|
||||
struct internal_lineno *in = (struct internal_lineno *) in1;
|
||||
|
||||
in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
|
||||
in->l_lnno = GET_LINENO_LNNO (abfd, ext);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_lineno_out (bfd * abfd, void * inp, void * outp)
|
||||
{
|
||||
struct internal_lineno *in = (struct internal_lineno *) inp;
|
||||
struct external_lineno *ext = (struct external_lineno *) outp;
|
||||
H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
|
||||
|
||||
PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
|
||||
return LINESZ;
|
||||
}
|
||||
|
||||
#endif /* NO_COFF_LINENOS */
|
||||
|
||||
static void
|
||||
coff_swap_aouthdr_in (bfd * abfd, void * aouthdr_ext1, void * aouthdr_int1)
|
||||
{
|
||||
AOUTHDR *aouthdr_ext;
|
||||
struct internal_aouthdr *aouthdr_int;
|
||||
|
||||
aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
|
||||
aouthdr_int = (struct internal_aouthdr *) aouthdr_int1;
|
||||
aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
|
||||
aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
|
||||
aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
|
||||
aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
|
||||
aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
|
||||
aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
|
||||
aouthdr_int->text_start =
|
||||
GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
|
||||
aouthdr_int->data_start =
|
||||
GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
|
||||
|
||||
#ifdef I960
|
||||
aouthdr_int->tagentries = H_GET_32 (abfd, aouthdr_ext->tagentries);
|
||||
#endif
|
||||
|
||||
#ifdef APOLLO_M68
|
||||
H_PUT_32 (abfd, aouthdr_int->o_inlib, aouthdr_ext->o_inlib);
|
||||
H_PUT_32 (abfd, aouthdr_int->o_sri, aouthdr_ext->o_sri);
|
||||
H_PUT_32 (abfd, aouthdr_int->vid[0], aouthdr_ext->vid);
|
||||
H_PUT_32 (abfd, aouthdr_int->vid[1], aouthdr_ext->vid + 4);
|
||||
#endif
|
||||
|
||||
#ifdef RS6000COFF_C
|
||||
#ifdef XCOFF64
|
||||
aouthdr_int->o_toc = H_GET_64 (abfd, aouthdr_ext->o_toc);
|
||||
#else
|
||||
aouthdr_int->o_toc = H_GET_32 (abfd, aouthdr_ext->o_toc);
|
||||
#endif
|
||||
aouthdr_int->o_snentry = H_GET_16 (abfd, aouthdr_ext->o_snentry);
|
||||
aouthdr_int->o_sntext = H_GET_16 (abfd, aouthdr_ext->o_sntext);
|
||||
aouthdr_int->o_sndata = H_GET_16 (abfd, aouthdr_ext->o_sndata);
|
||||
aouthdr_int->o_sntoc = H_GET_16 (abfd, aouthdr_ext->o_sntoc);
|
||||
aouthdr_int->o_snloader = H_GET_16 (abfd, aouthdr_ext->o_snloader);
|
||||
aouthdr_int->o_snbss = H_GET_16 (abfd, aouthdr_ext->o_snbss);
|
||||
aouthdr_int->o_algntext = H_GET_16 (abfd, aouthdr_ext->o_algntext);
|
||||
aouthdr_int->o_algndata = H_GET_16 (abfd, aouthdr_ext->o_algndata);
|
||||
aouthdr_int->o_modtype = H_GET_16 (abfd, aouthdr_ext->o_modtype);
|
||||
aouthdr_int->o_cputype = H_GET_16 (abfd, aouthdr_ext->o_cputype);
|
||||
#ifdef XCOFF64
|
||||
aouthdr_int->o_maxstack = H_GET_64 (abfd, aouthdr_ext->o_maxstack);
|
||||
aouthdr_int->o_maxdata = H_GET_64 (abfd, aouthdr_ext->o_maxdata);
|
||||
#else
|
||||
aouthdr_int->o_maxstack = H_GET_32 (abfd, aouthdr_ext->o_maxstack);
|
||||
aouthdr_int->o_maxdata = H_GET_32 (abfd, aouthdr_ext->o_maxdata);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MIPSECOFF
|
||||
aouthdr_int->bss_start = H_GET_32 (abfd, aouthdr_ext->bss_start);
|
||||
aouthdr_int->gp_value = H_GET_32 (abfd, aouthdr_ext->gp_value);
|
||||
aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
|
||||
aouthdr_int->cprmask[0] = H_GET_32 (abfd, aouthdr_ext->cprmask[0]);
|
||||
aouthdr_int->cprmask[1] = H_GET_32 (abfd, aouthdr_ext->cprmask[1]);
|
||||
aouthdr_int->cprmask[2] = H_GET_32 (abfd, aouthdr_ext->cprmask[2]);
|
||||
aouthdr_int->cprmask[3] = H_GET_32 (abfd, aouthdr_ext->cprmask[3]);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAECOFF
|
||||
aouthdr_int->bss_start = H_GET_64 (abfd, aouthdr_ext->bss_start);
|
||||
aouthdr_int->gp_value = H_GET_64 (abfd, aouthdr_ext->gp_value);
|
||||
aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
|
||||
aouthdr_int->fprmask = H_GET_32 (abfd, aouthdr_ext->fprmask);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_aouthdr_out (bfd * abfd, void * in, void * out)
|
||||
{
|
||||
struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
|
||||
AOUTHDR *aouthdr_out = (AOUTHDR *) out;
|
||||
|
||||
H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->magic);
|
||||
H_PUT_16 (abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
|
||||
PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->tsize);
|
||||
PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->dsize);
|
||||
PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->bsize);
|
||||
PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->entry);
|
||||
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
|
||||
aouthdr_out->text_start);
|
||||
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
|
||||
aouthdr_out->data_start);
|
||||
|
||||
#ifdef I960
|
||||
H_PUT_32 (abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
|
||||
#endif
|
||||
|
||||
#ifdef RS6000COFF_C
|
||||
#ifdef XCOFF64
|
||||
H_PUT_64 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
|
||||
#else
|
||||
H_PUT_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
|
||||
#endif
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
|
||||
H_PUT_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
|
||||
#ifdef XCOFF64
|
||||
H_PUT_64 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
|
||||
H_PUT_64 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
|
||||
#else
|
||||
H_PUT_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
|
||||
H_PUT_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
|
||||
#endif
|
||||
memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
|
||||
#ifdef XCOFF64
|
||||
memset (aouthdr_out->o_debugger, 0, sizeof aouthdr_out->o_debugger);
|
||||
memset (aouthdr_out->o_resv3, 0, sizeof aouthdr_out->o_resv3);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MIPSECOFF
|
||||
H_PUT_32 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
|
||||
H_PUT_32 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
|
||||
H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[0], aouthdr_out->cprmask[0]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[1], aouthdr_out->cprmask[1]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[2], aouthdr_out->cprmask[2]);
|
||||
H_PUT_32 (abfd, aouthdr_in->cprmask[3], aouthdr_out->cprmask[3]);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHAECOFF
|
||||
/* FIXME: What does bldrev mean? */
|
||||
H_PUT_16 (abfd, 2, aouthdr_out->bldrev);
|
||||
H_PUT_16 (abfd, 0, aouthdr_out->padding);
|
||||
H_PUT_64 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
|
||||
H_PUT_64 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
|
||||
H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
|
||||
H_PUT_32 (abfd, aouthdr_in->fprmask, aouthdr_out->fprmask);
|
||||
#endif
|
||||
|
||||
return AOUTSZ;
|
||||
}
|
||||
|
||||
static void
|
||||
coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in)
|
||||
{
|
||||
SCNHDR *scnhdr_ext = (SCNHDR *) ext;
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
|
||||
#ifdef COFF_ADJUST_SCNHDR_IN_PRE
|
||||
COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
|
||||
#endif
|
||||
memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));
|
||||
|
||||
scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
|
||||
scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
|
||||
scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
|
||||
|
||||
scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
|
||||
scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
|
||||
scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
|
||||
scnhdr_int->s_flags = GET_SCNHDR_FLAGS (abfd, scnhdr_ext->s_flags);
|
||||
scnhdr_int->s_nreloc = GET_SCNHDR_NRELOC (abfd, scnhdr_ext->s_nreloc);
|
||||
scnhdr_int->s_nlnno = GET_SCNHDR_NLNNO (abfd, scnhdr_ext->s_nlnno);
|
||||
#ifdef I960
|
||||
scnhdr_int->s_align = GET_SCNHDR_ALIGN (abfd, scnhdr_ext->s_align);
|
||||
#endif
|
||||
#ifdef COFF_ADJUST_SCNHDR_IN_POST
|
||||
COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
coff_swap_scnhdr_out (bfd * abfd, void * in, void * out)
|
||||
{
|
||||
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
|
||||
SCNHDR *scnhdr_ext = (SCNHDR *) out;
|
||||
unsigned int ret = bfd_coff_scnhsz (abfd);
|
||||
|
||||
#ifdef COFF_ADJUST_SCNHDR_OUT_PRE
|
||||
COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
|
||||
#endif
|
||||
memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
|
||||
PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
|
||||
PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
|
||||
PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
|
||||
PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
|
||||
PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
|
||||
PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
|
||||
PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
|
||||
#if defined(M88)
|
||||
H_PUT_32 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
|
||||
H_PUT_32 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
|
||||
#else
|
||||
if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
|
||||
PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
|
||||
else
|
||||
{
|
||||
char buf[sizeof (scnhdr_int->s_name) + 1];
|
||||
|
||||
memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
buf[sizeof (scnhdr_int->s_name)] = '\0';
|
||||
(*_bfd_error_handler)
|
||||
(_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
|
||||
bfd_get_filename (abfd),
|
||||
buf, scnhdr_int->s_nlnno);
|
||||
PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno);
|
||||
}
|
||||
|
||||
if (scnhdr_int->s_nreloc <= MAX_SCNHDR_NRELOC)
|
||||
PUT_SCNHDR_NRELOC (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
|
||||
else
|
||||
{
|
||||
char buf[sizeof (scnhdr_int->s_name) + 1];
|
||||
|
||||
memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
|
||||
buf[sizeof (scnhdr_int->s_name)] = '\0';
|
||||
(*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
|
||||
bfd_get_filename (abfd),
|
||||
buf, scnhdr_int->s_nreloc);
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
|
||||
ret = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef I960
|
||||
PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
|
||||
#endif
|
||||
#ifdef COFF_ADJUST_SCNHDR_OUT_POST
|
||||
COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user